documentation.d.ts 3.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430884318843288433884348843588436884378843888439884408844188442884438844488445884468844788448884498845088451884528845388454884558845688457884588845988460884618846288463884648846588466884678846888469884708847188472884738847488475884768847788478884798848088481884828848388484884858848688487884888848988490884918849288493884948849588496884978849888499885008850188502885038850488505885068850788508885098851088511885128851388514885158851688517885188851988520885218852288523885248852588526885278852888529885308853188532885338853488535885368853788538885398854088541885428854388544885458854688547885488854988550885518855288553885548855588556885578855888559885608856188562885638856488565885668856788568885698857088571885728857388574885758857688577885788857988580885818858288583885848858588586885878858888589885908859188592885938859488595885968859788598885998860088601886028860388604886058860688607886088860988610886118861288613886148861588616886178861888619886208862188622886238862488625886268862788628886298863088631886328863388634886358863688637886388863988640886418864288643886448864588646886478864888649886508865188652886538865488655886568865788658886598866088661886628866388664886658866688667886688866988670886718867288673886748867588676886778867888679886808868188682886838868488685886868868788688886898869088691886928869388694886958869688697886988869988700887018870288703887048870588706887078870888709887108871188712887138871488715887168871788718887198872088721887228872388724887258872688727887288872988730887318873288733887348873588736887378873888739887408874188742887438874488745887468874788748887498875088751887528875388754887558875688757887588875988760887618876288763887648876588766887678876888769887708877188772887738877488775887768877788778887798878088781887828878388784887858878688787887888878988790887918879288793887948879588796887978879888799888008880188802888038880488805888068880788808888098881088811888128881388814888158881688817888188881988820888218882288823888248882588826888278882888829888308883188832888338883488835888368883788838888398884088841888428884388844888458884688847888488884988850888518885288853888548885588856888578885888859888608886188862888638886488865888668886788868888698887088871888728887388874888758887688877888788887988880888818888288883888848888588886888878888888889888908889188892888938889488895888968889788898888998890088901889028890388904889058890688907889088890988910889118891288913889148891588916889178891888919889208892188922889238892488925889268892788928889298893088931889328893388934889358893688937889388893988940889418894288943889448894588946889478894888949889508895188952889538895488955889568895788958889598896088961889628896388964889658896688967889688896988970889718897288973889748897588976889778897888979889808898188982889838898488985889868898788988889898899088991889928899388994889958899688997889988899989000890018900289003890048900589006890078900889009890108901189012890138901489015890168901789018890198902089021890228902389024890258902689027890288902989030890318903289033890348903589036890378903889039890408904189042890438904489045890468904789048890498905089051890528905389054890558905689057890588905989060890618906289063890648906589066890678906889069890708907189072890738907489075
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private readonly _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** 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 */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** 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 */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** 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 */
  695. static readonly GEQUAL: number;
  696. /** 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 */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * 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.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * 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.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. * @param options options to be passed to the loader
  1123. */
  1124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1125. /**
  1126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1127. * @param data contains the texture data
  1128. * @param texture defines the BabylonJS internal texture
  1129. * @param callback defines the method to call once ready to upload
  1130. * @param options options to be passed to the loader
  1131. */
  1132. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1133. }
  1134. }
  1135. declare module BABYLON {
  1136. /**
  1137. * Class used to store and describe the pipeline context associated with an effect
  1138. */
  1139. export interface IPipelineContext {
  1140. /**
  1141. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1142. */
  1143. isAsync: boolean;
  1144. /**
  1145. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1146. */
  1147. isReady: boolean;
  1148. /** @hidden */
  1149. _getVertexShaderCode(): string | null;
  1150. /** @hidden */
  1151. _getFragmentShaderCode(): string | null;
  1152. /** @hidden */
  1153. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1154. }
  1155. }
  1156. declare module BABYLON {
  1157. /**
  1158. * Class used to store gfx data (like WebGLBuffer)
  1159. */
  1160. export class DataBuffer {
  1161. /**
  1162. * Gets or sets the number of objects referencing this buffer
  1163. */
  1164. references: number;
  1165. /** Gets or sets the size of the underlying buffer */
  1166. capacity: number;
  1167. /**
  1168. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1169. */
  1170. is32Bits: boolean;
  1171. /**
  1172. * Gets the underlying buffer
  1173. */
  1174. get underlyingResource(): any;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export interface IShaderProcessor {
  1180. attributeProcessor?: (attribute: string) => string;
  1181. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1182. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1183. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1184. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1185. lineProcessor?: (line: string, isFragment: boolean) => string;
  1186. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1187. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export interface ProcessingOptions {
  1193. defines: string[];
  1194. indexParameters: any;
  1195. isFragment: boolean;
  1196. shouldUseHighPrecisionShader: boolean;
  1197. supportsUniformBuffers: boolean;
  1198. shadersRepository: string;
  1199. includesShadersStore: {
  1200. [key: string]: string;
  1201. };
  1202. processor?: IShaderProcessor;
  1203. version: string;
  1204. platformName: string;
  1205. lookForClosingBracketForUniformBuffer?: boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1236. process(preprocessors: {
  1237. [key: string]: string;
  1238. }, options: ProcessingOptions): string;
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderDefineExpression {
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. private static _OperatorPriority;
  1248. private static _Stack;
  1249. static postfixToInfix(postfix: string[]): string;
  1250. static infixToPostfix(infix: string): string[];
  1251. }
  1252. }
  1253. declare module BABYLON {
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. not: boolean;
  1267. constructor(define: string, not?: boolean);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module BABYLON {
  1274. /** @hidden */
  1275. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1276. leftOperand: ShaderDefineExpression;
  1277. rightOperand: ShaderDefineExpression;
  1278. isTrue(preprocessors: {
  1279. [key: string]: string;
  1280. }): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON {
  1284. /** @hidden */
  1285. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1286. leftOperand: ShaderDefineExpression;
  1287. rightOperand: ShaderDefineExpression;
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /** @hidden */
  1295. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1296. define: string;
  1297. operand: string;
  1298. testValue: string;
  1299. constructor(define: string, operand: string, testValue: string);
  1300. isTrue(preprocessors: {
  1301. [key: string]: string;
  1302. }): boolean;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * Class used to enable access to offline support
  1308. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1309. */
  1310. export interface IOfflineProvider {
  1311. /**
  1312. * Gets a boolean indicating if scene must be saved in the database
  1313. */
  1314. enableSceneOffline: boolean;
  1315. /**
  1316. * Gets a boolean indicating if textures must be saved in the database
  1317. */
  1318. enableTexturesOffline: boolean;
  1319. /**
  1320. * Open the offline support and make it available
  1321. * @param successCallback defines the callback to call on success
  1322. * @param errorCallback defines the callback to call on error
  1323. */
  1324. open(successCallback: () => void, errorCallback: () => void): void;
  1325. /**
  1326. * Loads an image from the offline support
  1327. * @param url defines the url to load from
  1328. * @param image defines the target DOM image
  1329. */
  1330. loadImage(url: string, image: HTMLImageElement): void;
  1331. /**
  1332. * Loads a file from offline support
  1333. * @param url defines the URL to load from
  1334. * @param sceneLoaded defines a callback to call on success
  1335. * @param progressCallBack defines a callback to call when progress changed
  1336. * @param errorCallback defines a callback to call on error
  1337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1338. */
  1339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1340. }
  1341. }
  1342. declare module BABYLON {
  1343. /**
  1344. * Class used to help managing file picking and drag'n'drop
  1345. * File Storage
  1346. */
  1347. export class FilesInputStore {
  1348. /**
  1349. * List of files ready to be loaded
  1350. */
  1351. static FilesToLoad: {
  1352. [key: string]: File;
  1353. };
  1354. }
  1355. }
  1356. declare module BABYLON {
  1357. /**
  1358. * Class used to define a retry strategy when error happens while loading assets
  1359. */
  1360. export class RetryStrategy {
  1361. /**
  1362. * Function used to defines an exponential back off strategy
  1363. * @param maxRetries defines the maximum number of retries (3 by default)
  1364. * @param baseInterval defines the interval between retries
  1365. * @returns the strategy function to use
  1366. */
  1367. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * @ignore
  1373. * Application error to support additional information when loading a file
  1374. */
  1375. export abstract class BaseError extends Error {
  1376. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1377. }
  1378. }
  1379. declare module BABYLON {
  1380. /** @ignore */
  1381. export class LoadFileError extends BaseError {
  1382. request?: WebRequest;
  1383. file?: File;
  1384. /**
  1385. * Creates a new LoadFileError
  1386. * @param message defines the message of the error
  1387. * @param request defines the optional web request
  1388. * @param file defines the optional file
  1389. */
  1390. constructor(message: string, object?: WebRequest | File);
  1391. }
  1392. /** @ignore */
  1393. export class RequestFileError extends BaseError {
  1394. request: WebRequest;
  1395. /**
  1396. * Creates a new LoadFileError
  1397. * @param message defines the message of the error
  1398. * @param request defines the optional web request
  1399. */
  1400. constructor(message: string, request: WebRequest);
  1401. }
  1402. /** @ignore */
  1403. export class ReadFileError extends BaseError {
  1404. file: File;
  1405. /**
  1406. * Creates a new ReadFileError
  1407. * @param message defines the message of the error
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, file: File);
  1411. }
  1412. /**
  1413. * @hidden
  1414. */
  1415. export class FileTools {
  1416. /**
  1417. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1418. */
  1419. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1420. /**
  1421. * Gets or sets the base URL to use to load assets
  1422. */
  1423. static BaseUrl: string;
  1424. /**
  1425. * Default behaviour for cors in the application.
  1426. * It can be a string if the expected behavior is identical in the entire app.
  1427. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1428. */
  1429. static CorsBehavior: string | ((url: string | string[]) => string);
  1430. /**
  1431. * Gets or sets a function used to pre-process url before using them to load assets
  1432. */
  1433. static PreprocessUrl: (url: string) => string;
  1434. /**
  1435. * Removes unwanted characters from an url
  1436. * @param url defines the url to clean
  1437. * @returns the cleaned url
  1438. */
  1439. private static _CleanUrl;
  1440. /**
  1441. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1442. * @param url define the url we are trying
  1443. * @param element define the dom element where to configure the cors policy
  1444. */
  1445. static SetCorsBehavior(url: string | string[], element: {
  1446. crossOrigin: string | null;
  1447. }): void;
  1448. /**
  1449. * Loads an image as an HTMLImageElement.
  1450. * @param input url string, ArrayBuffer, or Blob to load
  1451. * @param onLoad callback called when the image successfully loads
  1452. * @param onError callback called when the image fails to load
  1453. * @param offlineProvider offline provider for caching
  1454. * @param mimeType optional mime type
  1455. * @returns the HTMLImageElement of the loaded image
  1456. */
  1457. 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>;
  1458. /**
  1459. * Reads a file from a File object
  1460. * @param file defines the file to load
  1461. * @param onSuccess defines the callback to call when data is loaded
  1462. * @param onProgress defines the callback to call during loading process
  1463. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1464. * @param onError defines the callback to call when an error occurs
  1465. * @returns a file request object
  1466. */
  1467. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1468. /**
  1469. * Loads a file from a url
  1470. * @param url url to load
  1471. * @param onSuccess callback called when the file successfully loads
  1472. * @param onProgress callback called while file is loading (if the server supports this mode)
  1473. * @param offlineProvider defines the offline provider for caching
  1474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1475. * @param onError callback called when the file fails to load
  1476. * @returns a file request object
  1477. */
  1478. 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;
  1479. /**
  1480. * Loads a file
  1481. * @param url url to load
  1482. * @param onSuccess callback called when the file successfully loads
  1483. * @param onProgress callback called while file is loading (if the server supports this mode)
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @param onOpened callback called when the web request is opened
  1487. * @returns a file request object
  1488. */
  1489. 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;
  1490. /**
  1491. * Checks if the loaded document was accessed via `file:`-Protocol.
  1492. * @returns boolean
  1493. */
  1494. static IsFileURL(): boolean;
  1495. }
  1496. }
  1497. declare module BABYLON {
  1498. /** @hidden */
  1499. export class ShaderProcessor {
  1500. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1501. private static _ProcessPrecision;
  1502. private static _ExtractOperation;
  1503. private static _BuildSubExpression;
  1504. private static _BuildExpression;
  1505. private static _MoveCursorWithinIf;
  1506. private static _MoveCursor;
  1507. private static _EvaluatePreProcessors;
  1508. private static _PreparePreProcessors;
  1509. private static _ProcessShaderConversion;
  1510. private static _ProcessIncludes;
  1511. /**
  1512. * Loads a file from a url
  1513. * @param url url to load
  1514. * @param onSuccess callback called when the file successfully loads
  1515. * @param onProgress callback called while file is loading (if the server supports this mode)
  1516. * @param offlineProvider defines the offline provider for caching
  1517. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1518. * @param onError callback called when the file fails to load
  1519. * @returns a file request object
  1520. * @hidden
  1521. */
  1522. 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;
  1523. }
  1524. }
  1525. declare module BABYLON {
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IColor4Like {
  1530. r: float;
  1531. g: float;
  1532. b: float;
  1533. a: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IColor3Like {
  1539. r: float;
  1540. g: float;
  1541. b: float;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IVector4Like {
  1547. x: float;
  1548. y: float;
  1549. z: float;
  1550. w: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector3Like {
  1556. x: float;
  1557. y: float;
  1558. z: float;
  1559. }
  1560. /**
  1561. * @hidden
  1562. */
  1563. export interface IVector2Like {
  1564. x: float;
  1565. y: float;
  1566. }
  1567. /**
  1568. * @hidden
  1569. */
  1570. export interface IMatrixLike {
  1571. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1572. updateFlag: int;
  1573. }
  1574. /**
  1575. * @hidden
  1576. */
  1577. export interface IViewportLike {
  1578. x: float;
  1579. y: float;
  1580. width: float;
  1581. height: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IPlaneLike {
  1587. normal: IVector3Like;
  1588. d: float;
  1589. normalize(): void;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /**
  1594. * Interface used to define common properties for effect fallbacks
  1595. */
  1596. export interface IEffectFallbacks {
  1597. /**
  1598. * Removes the defines that should be removed when falling back.
  1599. * @param currentDefines defines the current define statements for the shader.
  1600. * @param effect defines the current effect we try to compile
  1601. * @returns The resulting defines with defines of the current rank removed.
  1602. */
  1603. reduce(currentDefines: string, effect: Effect): string;
  1604. /**
  1605. * Removes the fallback from the bound mesh.
  1606. */
  1607. unBindMesh(): void;
  1608. /**
  1609. * Checks to see if more fallbacks are still availible.
  1610. */
  1611. hasMoreFallbacks: boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Interface for the size containing width and height
  1617. */
  1618. export interface ISize {
  1619. /**
  1620. * Width
  1621. */
  1622. width: number;
  1623. /**
  1624. * Heighht
  1625. */
  1626. height: number;
  1627. }
  1628. /**
  1629. * Size containing widht and height
  1630. */
  1631. export class Size implements ISize {
  1632. /**
  1633. * Width
  1634. */
  1635. width: number;
  1636. /**
  1637. * Height
  1638. */
  1639. height: number;
  1640. /**
  1641. * Creates a Size object from the given width and height (floats).
  1642. * @param width width of the new size
  1643. * @param height height of the new size
  1644. */
  1645. constructor(width: number, height: number);
  1646. /**
  1647. * Returns a string with the Size width and height
  1648. * @returns a string with the Size width and height
  1649. */
  1650. toString(): string;
  1651. /**
  1652. * "Size"
  1653. * @returns the string "Size"
  1654. */
  1655. getClassName(): string;
  1656. /**
  1657. * Returns the Size hash code.
  1658. * @returns a hash code for a unique width and height
  1659. */
  1660. getHashCode(): number;
  1661. /**
  1662. * Updates the current size from the given one.
  1663. * @param src the given size
  1664. */
  1665. copyFrom(src: Size): void;
  1666. /**
  1667. * Updates in place the current Size from the given floats.
  1668. * @param width width of the new size
  1669. * @param height height of the new size
  1670. * @returns the updated Size.
  1671. */
  1672. copyFromFloats(width: number, height: number): Size;
  1673. /**
  1674. * Updates in place the current Size from the given floats.
  1675. * @param width width to set
  1676. * @param height height to set
  1677. * @returns the updated Size.
  1678. */
  1679. set(width: number, height: number): Size;
  1680. /**
  1681. * Multiplies the width and height by numbers
  1682. * @param w factor to multiple the width by
  1683. * @param h factor to multiple the height by
  1684. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1685. */
  1686. multiplyByFloats(w: number, h: number): Size;
  1687. /**
  1688. * Clones the size
  1689. * @returns a new Size copied from the given one.
  1690. */
  1691. clone(): Size;
  1692. /**
  1693. * True if the current Size and the given one width and height are strictly equal.
  1694. * @param other the other size to compare against
  1695. * @returns True if the current Size and the given one width and height are strictly equal.
  1696. */
  1697. equals(other: Size): boolean;
  1698. /**
  1699. * The surface of the Size : width * height (float).
  1700. */
  1701. get surface(): number;
  1702. /**
  1703. * Create a new size of zero
  1704. * @returns a new Size set to (0.0, 0.0)
  1705. */
  1706. static Zero(): Size;
  1707. /**
  1708. * Sums the width and height of two sizes
  1709. * @param otherSize size to add to this size
  1710. * @returns a new Size set as the addition result of the current Size and the given one.
  1711. */
  1712. add(otherSize: Size): Size;
  1713. /**
  1714. * Subtracts the width and height of two
  1715. * @param otherSize size to subtract to this size
  1716. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1717. */
  1718. subtract(otherSize: Size): Size;
  1719. /**
  1720. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1721. * @param start starting size to lerp between
  1722. * @param end end size to lerp between
  1723. * @param amount amount to lerp between the start and end values
  1724. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1725. */
  1726. static Lerp(start: Size, end: Size, amount: number): Size;
  1727. }
  1728. }
  1729. declare module BABYLON {
  1730. /**
  1731. * Base class of all the textures in babylon.
  1732. * It groups all the common properties required to work with Thin Engine.
  1733. */
  1734. export class ThinTexture {
  1735. protected _wrapU: number;
  1736. /**
  1737. * | Value | Type | Description |
  1738. * | ----- | ------------------ | ----------- |
  1739. * | 0 | CLAMP_ADDRESSMODE | |
  1740. * | 1 | WRAP_ADDRESSMODE | |
  1741. * | 2 | MIRROR_ADDRESSMODE | |
  1742. */
  1743. get wrapU(): number;
  1744. set wrapU(value: number);
  1745. protected _wrapV: number;
  1746. /**
  1747. * | Value | Type | Description |
  1748. * | ----- | ------------------ | ----------- |
  1749. * | 0 | CLAMP_ADDRESSMODE | |
  1750. * | 1 | WRAP_ADDRESSMODE | |
  1751. * | 2 | MIRROR_ADDRESSMODE | |
  1752. */
  1753. get wrapV(): number;
  1754. set wrapV(value: number);
  1755. /**
  1756. * | Value | Type | Description |
  1757. * | ----- | ------------------ | ----------- |
  1758. * | 0 | CLAMP_ADDRESSMODE | |
  1759. * | 1 | WRAP_ADDRESSMODE | |
  1760. * | 2 | MIRROR_ADDRESSMODE | |
  1761. */
  1762. wrapR: number;
  1763. /**
  1764. * With compliant hardware and browser (supporting anisotropic filtering)
  1765. * this defines the level of anisotropic filtering in the texture.
  1766. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  1767. */
  1768. anisotropicFilteringLevel: number;
  1769. /**
  1770. * Define the current state of the loading sequence when in delayed load mode.
  1771. */
  1772. delayLoadState: number;
  1773. /**
  1774. * How a texture is mapped.
  1775. * Unused in thin texture mode.
  1776. */
  1777. get coordinatesMode(): number;
  1778. /**
  1779. * Define if the texture is a cube texture or if false a 2d texture.
  1780. */
  1781. get isCube(): boolean;
  1782. set isCube(value: boolean);
  1783. /**
  1784. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  1785. */
  1786. get is3D(): boolean;
  1787. set is3D(value: boolean);
  1788. /**
  1789. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  1790. */
  1791. get is2DArray(): boolean;
  1792. set is2DArray(value: boolean);
  1793. /**
  1794. * Get the class name of the texture.
  1795. * @returns "ThinTexture"
  1796. */
  1797. getClassName(): string;
  1798. /** @hidden */
  1799. _texture: Nullable<InternalTexture>;
  1800. protected _engine: Nullable<ThinEngine>;
  1801. private _cachedSize;
  1802. private _cachedBaseSize;
  1803. /**
  1804. * Instantiates a new ThinTexture.
  1805. * Base class of all the textures in babylon.
  1806. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  1807. * @param internalTexture Define the internalTexture to wrap
  1808. */
  1809. constructor(internalTexture: Nullable<InternalTexture>);
  1810. /**
  1811. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  1812. * @returns true if fully ready
  1813. */
  1814. isReady(): boolean;
  1815. /**
  1816. * Triggers the load sequence in delayed load mode.
  1817. */
  1818. delayLoad(): void;
  1819. /**
  1820. * Get the underlying lower level texture from Babylon.
  1821. * @returns the insternal texture
  1822. */
  1823. getInternalTexture(): Nullable<InternalTexture>;
  1824. /**
  1825. * Get the size of the texture.
  1826. * @returns the texture size.
  1827. */
  1828. getSize(): ISize;
  1829. /**
  1830. * Get the base size of the texture.
  1831. * It can be different from the size if the texture has been resized for POT for instance
  1832. * @returns the base size
  1833. */
  1834. getBaseSize(): ISize;
  1835. /**
  1836. * Update the sampling mode of the texture.
  1837. * Default is Trilinear mode.
  1838. *
  1839. * | Value | Type | Description |
  1840. * | ----- | ------------------ | ----------- |
  1841. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  1842. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  1843. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  1844. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  1845. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  1846. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  1847. * | 7 | NEAREST_LINEAR | |
  1848. * | 8 | NEAREST_NEAREST | |
  1849. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  1850. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  1851. * | 11 | LINEAR_LINEAR | |
  1852. * | 12 | LINEAR_NEAREST | |
  1853. *
  1854. * > _mag_: magnification filter (close to the viewer)
  1855. * > _min_: minification filter (far from the viewer)
  1856. * > _mip_: filter used between mip map levels
  1857. *@param samplingMode Define the new sampling mode of the texture
  1858. */
  1859. updateSamplingMode(samplingMode: number): void;
  1860. /**
  1861. * Release and destroy the underlying lower level texture aka internalTexture.
  1862. */
  1863. releaseInternalTexture(): void;
  1864. /**
  1865. * Dispose the texture and release its associated resources.
  1866. */
  1867. dispose(): void;
  1868. }
  1869. }
  1870. declare module BABYLON {
  1871. /**
  1872. * Defines an array and its length.
  1873. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  1874. */
  1875. export interface ISmartArrayLike<T> {
  1876. /**
  1877. * The data of the array.
  1878. */
  1879. data: Array<T>;
  1880. /**
  1881. * The active length of the array.
  1882. */
  1883. length: number;
  1884. }
  1885. /**
  1886. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1887. */
  1888. export class SmartArray<T> implements ISmartArrayLike<T> {
  1889. /**
  1890. * The full set of data from the array.
  1891. */
  1892. data: Array<T>;
  1893. /**
  1894. * The active length of the array.
  1895. */
  1896. length: number;
  1897. protected _id: number;
  1898. /**
  1899. * Instantiates a Smart Array.
  1900. * @param capacity defines the default capacity of the array.
  1901. */
  1902. constructor(capacity: number);
  1903. /**
  1904. * Pushes a value at the end of the active data.
  1905. * @param value defines the object to push in the array.
  1906. */
  1907. push(value: T): void;
  1908. /**
  1909. * Iterates over the active data and apply the lambda to them.
  1910. * @param func defines the action to apply on each value.
  1911. */
  1912. forEach(func: (content: T) => void): void;
  1913. /**
  1914. * Sorts the full sets of data.
  1915. * @param compareFn defines the comparison function to apply.
  1916. */
  1917. sort(compareFn: (a: T, b: T) => number): void;
  1918. /**
  1919. * Resets the active data to an empty array.
  1920. */
  1921. reset(): void;
  1922. /**
  1923. * Releases all the data from the array as well as the array.
  1924. */
  1925. dispose(): void;
  1926. /**
  1927. * Concats the active data with a given array.
  1928. * @param array defines the data to concatenate with.
  1929. */
  1930. concat(array: any): void;
  1931. /**
  1932. * Returns the position of a value in the active data.
  1933. * @param value defines the value to find the index for
  1934. * @returns the index if found in the active data otherwise -1
  1935. */
  1936. indexOf(value: T): number;
  1937. /**
  1938. * Returns whether an element is part of the active data.
  1939. * @param value defines the value to look for
  1940. * @returns true if found in the active data otherwise false
  1941. */
  1942. contains(value: T): boolean;
  1943. private static _GlobalId;
  1944. }
  1945. /**
  1946. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1947. * The data in this array can only be present once
  1948. */
  1949. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  1950. private _duplicateId;
  1951. /**
  1952. * Pushes a value at the end of the active data.
  1953. * THIS DOES NOT PREVENT DUPPLICATE DATA
  1954. * @param value defines the object to push in the array.
  1955. */
  1956. push(value: T): void;
  1957. /**
  1958. * Pushes a value at the end of the active data.
  1959. * If the data is already present, it won t be added again
  1960. * @param value defines the object to push in the array.
  1961. * @returns true if added false if it was already present
  1962. */
  1963. pushNoDuplicate(value: T): boolean;
  1964. /**
  1965. * Resets the active data to an empty array.
  1966. */
  1967. reset(): void;
  1968. /**
  1969. * Concats the active data with a given array.
  1970. * This ensures no dupplicate will be present in the result.
  1971. * @param array defines the data to concatenate with.
  1972. */
  1973. concatWithNoDuplicate(array: any): void;
  1974. }
  1975. }
  1976. declare module BABYLON {
  1977. /**
  1978. * Class used to evalaute queries containing `and` and `or` operators
  1979. */
  1980. export class AndOrNotEvaluator {
  1981. /**
  1982. * Evaluate a query
  1983. * @param query defines the query to evaluate
  1984. * @param evaluateCallback defines the callback used to filter result
  1985. * @returns true if the query matches
  1986. */
  1987. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1988. private static _HandleParenthesisContent;
  1989. private static _SimplifyNegation;
  1990. }
  1991. }
  1992. declare module BABYLON {
  1993. /**
  1994. * Class used to store custom tags
  1995. */
  1996. export class Tags {
  1997. /**
  1998. * Adds support for tags on the given object
  1999. * @param obj defines the object to use
  2000. */
  2001. static EnableFor(obj: any): void;
  2002. /**
  2003. * Removes tags support
  2004. * @param obj defines the object to use
  2005. */
  2006. static DisableFor(obj: any): void;
  2007. /**
  2008. * Gets a boolean indicating if the given object has tags
  2009. * @param obj defines the object to use
  2010. * @returns a boolean
  2011. */
  2012. static HasTags(obj: any): boolean;
  2013. /**
  2014. * Gets the tags available on a given object
  2015. * @param obj defines the object to use
  2016. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2017. * @returns the tags
  2018. */
  2019. static GetTags(obj: any, asString?: boolean): any;
  2020. /**
  2021. * Adds tags to an object
  2022. * @param obj defines the object to use
  2023. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2024. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2025. */
  2026. static AddTagsTo(obj: any, tagsString: string): void;
  2027. /**
  2028. * @hidden
  2029. */
  2030. static _AddTagTo(obj: any, tag: string): void;
  2031. /**
  2032. * Removes specific tags from a specific object
  2033. * @param obj defines the object to use
  2034. * @param tagsString defines the tags to remove
  2035. */
  2036. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2037. /**
  2038. * @hidden
  2039. */
  2040. static _RemoveTagFrom(obj: any, tag: string): void;
  2041. /**
  2042. * Defines if tags hosted on an object match a given query
  2043. * @param obj defines the object to use
  2044. * @param tagsQuery defines the tag query
  2045. * @returns a boolean
  2046. */
  2047. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2048. }
  2049. }
  2050. declare module BABYLON {
  2051. /**
  2052. * Scalar computation library
  2053. */
  2054. export class Scalar {
  2055. /**
  2056. * Two pi constants convenient for computation.
  2057. */
  2058. static TwoPi: number;
  2059. /**
  2060. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2061. * @param a number
  2062. * @param b number
  2063. * @param epsilon (default = 1.401298E-45)
  2064. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2065. */
  2066. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2067. /**
  2068. * Returns a string : the upper case translation of the number i to hexadecimal.
  2069. * @param i number
  2070. * @returns the upper case translation of the number i to hexadecimal.
  2071. */
  2072. static ToHex(i: number): string;
  2073. /**
  2074. * Returns -1 if value is negative and +1 is value is positive.
  2075. * @param value the value
  2076. * @returns the value itself if it's equal to zero.
  2077. */
  2078. static Sign(value: number): number;
  2079. /**
  2080. * Returns the value itself if it's between min and max.
  2081. * Returns min if the value is lower than min.
  2082. * Returns max if the value is greater than max.
  2083. * @param value the value to clmap
  2084. * @param min the min value to clamp to (default: 0)
  2085. * @param max the max value to clamp to (default: 1)
  2086. * @returns the clamped value
  2087. */
  2088. static Clamp(value: number, min?: number, max?: number): number;
  2089. /**
  2090. * the log2 of value.
  2091. * @param value the value to compute log2 of
  2092. * @returns the log2 of value.
  2093. */
  2094. static Log2(value: number): number;
  2095. /**
  2096. * Loops the value, so that it is never larger than length and never smaller than 0.
  2097. *
  2098. * This is similar to the modulo operator but it works with floating point numbers.
  2099. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2100. * With t = 5 and length = 2.5, the result would be 0.0.
  2101. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2102. * @param value the value
  2103. * @param length the length
  2104. * @returns the looped value
  2105. */
  2106. static Repeat(value: number, length: number): number;
  2107. /**
  2108. * Normalize the value between 0.0 and 1.0 using min and max values
  2109. * @param value value to normalize
  2110. * @param min max to normalize between
  2111. * @param max min to normalize between
  2112. * @returns the normalized value
  2113. */
  2114. static Normalize(value: number, min: number, max: number): number;
  2115. /**
  2116. * Denormalize the value from 0.0 and 1.0 using min and max values
  2117. * @param normalized value to denormalize
  2118. * @param min max to denormalize between
  2119. * @param max min to denormalize between
  2120. * @returns the denormalized value
  2121. */
  2122. static Denormalize(normalized: number, min: number, max: number): number;
  2123. /**
  2124. * Calculates the shortest difference between two given angles given in degrees.
  2125. * @param current current angle in degrees
  2126. * @param target target angle in degrees
  2127. * @returns the delta
  2128. */
  2129. static DeltaAngle(current: number, target: number): number;
  2130. /**
  2131. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2132. * @param tx value
  2133. * @param length length
  2134. * @returns The returned value will move back and forth between 0 and length
  2135. */
  2136. static PingPong(tx: number, length: number): number;
  2137. /**
  2138. * Interpolates between min and max with smoothing at the limits.
  2139. *
  2140. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2141. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2142. * @param from from
  2143. * @param to to
  2144. * @param tx value
  2145. * @returns the smooth stepped value
  2146. */
  2147. static SmoothStep(from: number, to: number, tx: number): number;
  2148. /**
  2149. * Moves a value current towards target.
  2150. *
  2151. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2152. * Negative values of maxDelta pushes the value away from target.
  2153. * @param current current value
  2154. * @param target target value
  2155. * @param maxDelta max distance to move
  2156. * @returns resulting value
  2157. */
  2158. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2159. /**
  2160. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2161. *
  2162. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2163. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2164. * @param current current value
  2165. * @param target target value
  2166. * @param maxDelta max distance to move
  2167. * @returns resulting angle
  2168. */
  2169. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2170. /**
  2171. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2172. * @param start start value
  2173. * @param end target value
  2174. * @param amount amount to lerp between
  2175. * @returns the lerped value
  2176. */
  2177. static Lerp(start: number, end: number, amount: number): number;
  2178. /**
  2179. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2180. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2181. * @param start start value
  2182. * @param end target value
  2183. * @param amount amount to lerp between
  2184. * @returns the lerped value
  2185. */
  2186. static LerpAngle(start: number, end: number, amount: number): number;
  2187. /**
  2188. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2189. * @param a start value
  2190. * @param b target value
  2191. * @param value value between a and b
  2192. * @returns the inverseLerp value
  2193. */
  2194. static InverseLerp(a: number, b: number, value: number): number;
  2195. /**
  2196. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2197. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2198. * @param value1 spline value
  2199. * @param tangent1 spline value
  2200. * @param value2 spline value
  2201. * @param tangent2 spline value
  2202. * @param amount input value
  2203. * @returns hermite result
  2204. */
  2205. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2206. /**
  2207. * Returns a random float number between and min and max values
  2208. * @param min min value of random
  2209. * @param max max value of random
  2210. * @returns random value
  2211. */
  2212. static RandomRange(min: number, max: number): number;
  2213. /**
  2214. * This function returns percentage of a number in a given range.
  2215. *
  2216. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2217. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2218. * @param number to convert to percentage
  2219. * @param min min range
  2220. * @param max max range
  2221. * @returns the percentage
  2222. */
  2223. static RangeToPercent(number: number, min: number, max: number): number;
  2224. /**
  2225. * This function returns number that corresponds to the percentage in a given range.
  2226. *
  2227. * PercentToRange(0.34,0,100) will return 34.
  2228. * @param percent to convert to number
  2229. * @param min min range
  2230. * @param max max range
  2231. * @returns the number
  2232. */
  2233. static PercentToRange(percent: number, min: number, max: number): number;
  2234. /**
  2235. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2236. * @param angle The angle to normalize in radian.
  2237. * @return The converted angle.
  2238. */
  2239. static NormalizeRadians(angle: number): number;
  2240. }
  2241. }
  2242. declare module BABYLON {
  2243. /**
  2244. * Constant used to convert a value to gamma space
  2245. * @ignorenaming
  2246. */
  2247. export const ToGammaSpace: number;
  2248. /**
  2249. * Constant used to convert a value to linear space
  2250. * @ignorenaming
  2251. */
  2252. export const ToLinearSpace = 2.2;
  2253. /**
  2254. * Constant used to define the minimal number value in Babylon.js
  2255. * @ignorenaming
  2256. */
  2257. let Epsilon: number;
  2258. }
  2259. declare module BABYLON {
  2260. /**
  2261. * Class used to represent a viewport on screen
  2262. */
  2263. export class Viewport {
  2264. /** viewport left coordinate */
  2265. x: number;
  2266. /** viewport top coordinate */
  2267. y: number;
  2268. /**viewport width */
  2269. width: number;
  2270. /** viewport height */
  2271. height: number;
  2272. /**
  2273. * Creates a Viewport object located at (x, y) and sized (width, height)
  2274. * @param x defines viewport left coordinate
  2275. * @param y defines viewport top coordinate
  2276. * @param width defines the viewport width
  2277. * @param height defines the viewport height
  2278. */
  2279. constructor(
  2280. /** viewport left coordinate */
  2281. x: number,
  2282. /** viewport top coordinate */
  2283. y: number,
  2284. /**viewport width */
  2285. width: number,
  2286. /** viewport height */
  2287. height: number);
  2288. /**
  2289. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2290. * @param renderWidth defines the rendering width
  2291. * @param renderHeight defines the rendering height
  2292. * @returns a new Viewport
  2293. */
  2294. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2295. /**
  2296. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2297. * @param renderWidth defines the rendering width
  2298. * @param renderHeight defines the rendering height
  2299. * @param ref defines the target viewport
  2300. * @returns the current viewport
  2301. */
  2302. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2303. /**
  2304. * Returns a new Viewport copied from the current one
  2305. * @returns a new Viewport
  2306. */
  2307. clone(): Viewport;
  2308. }
  2309. }
  2310. declare module BABYLON {
  2311. /**
  2312. * Class containing a set of static utilities functions for arrays.
  2313. */
  2314. export class ArrayTools {
  2315. /**
  2316. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2317. * @param size the number of element to construct and put in the array
  2318. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2319. * @returns a new array filled with new objects
  2320. */
  2321. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2322. }
  2323. }
  2324. declare module BABYLON {
  2325. /**
  2326. * Represents a plane by the equation ax + by + cz + d = 0
  2327. */
  2328. export class Plane {
  2329. private static _TmpMatrix;
  2330. /**
  2331. * Normal of the plane (a,b,c)
  2332. */
  2333. normal: Vector3;
  2334. /**
  2335. * d component of the plane
  2336. */
  2337. d: number;
  2338. /**
  2339. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2340. * @param a a component of the plane
  2341. * @param b b component of the plane
  2342. * @param c c component of the plane
  2343. * @param d d component of the plane
  2344. */
  2345. constructor(a: number, b: number, c: number, d: number);
  2346. /**
  2347. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2348. */
  2349. asArray(): number[];
  2350. /**
  2351. * @returns a new plane copied from the current Plane.
  2352. */
  2353. clone(): Plane;
  2354. /**
  2355. * @returns the string "Plane".
  2356. */
  2357. getClassName(): string;
  2358. /**
  2359. * @returns the Plane hash code.
  2360. */
  2361. getHashCode(): number;
  2362. /**
  2363. * Normalize the current Plane in place.
  2364. * @returns the updated Plane.
  2365. */
  2366. normalize(): Plane;
  2367. /**
  2368. * Applies a transformation the plane and returns the result
  2369. * @param transformation the transformation matrix to be applied to the plane
  2370. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2371. */
  2372. transform(transformation: DeepImmutable<Matrix>): Plane;
  2373. /**
  2374. * Compute the dot product between the point and the plane normal
  2375. * @param point point to calculate the dot product with
  2376. * @returns the dot product (float) of the point coordinates and the plane normal.
  2377. */
  2378. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2379. /**
  2380. * Updates the current Plane from the plane defined by the three given points.
  2381. * @param point1 one of the points used to contruct the plane
  2382. * @param point2 one of the points used to contruct the plane
  2383. * @param point3 one of the points used to contruct the plane
  2384. * @returns the updated Plane.
  2385. */
  2386. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2387. /**
  2388. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2389. * Note that for this function to work as expected you should make sure that:
  2390. * - direction and the plane normal are normalized
  2391. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2392. * @param direction the direction to check if the plane is facing
  2393. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2394. * @returns True if the plane is facing the given direction
  2395. */
  2396. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2397. /**
  2398. * Calculates the distance to a point
  2399. * @param point point to calculate distance to
  2400. * @returns the signed distance (float) from the given point to the Plane.
  2401. */
  2402. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2403. /**
  2404. * Creates a plane from an array
  2405. * @param array the array to create a plane from
  2406. * @returns a new Plane from the given array.
  2407. */
  2408. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2409. /**
  2410. * Creates a plane from three points
  2411. * @param point1 point used to create the plane
  2412. * @param point2 point used to create the plane
  2413. * @param point3 point used to create the plane
  2414. * @returns a new Plane defined by the three given points.
  2415. */
  2416. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2417. /**
  2418. * Creates a plane from an origin point and a normal
  2419. * @param origin origin of the plane to be constructed
  2420. * @param normal normal of the plane to be constructed
  2421. * @returns a new Plane the normal vector to this plane at the given origin point.
  2422. * Note : the vector "normal" is updated because normalized.
  2423. */
  2424. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2425. /**
  2426. * Calculates the distance from a plane and a point
  2427. * @param origin origin of the plane to be constructed
  2428. * @param normal normal of the plane to be constructed
  2429. * @param point point to calculate distance to
  2430. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2431. */
  2432. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2433. }
  2434. }
  2435. declare module BABYLON {
  2436. /** @hidden */
  2437. export class PerformanceConfigurator {
  2438. /** @hidden */
  2439. static MatrixUse64Bits: boolean;
  2440. /** @hidden */
  2441. static MatrixTrackPrecisionChange: boolean;
  2442. /** @hidden */
  2443. static MatrixCurrentType: any;
  2444. /** @hidden */
  2445. static MatrixTrackedMatrices: Array<any> | null;
  2446. /** @hidden */
  2447. static SetMatrixPrecision(use64bits: boolean): void;
  2448. }
  2449. }
  2450. declare module BABYLON {
  2451. /**
  2452. * Class representing a vector containing 2 coordinates
  2453. */
  2454. export class Vector2 {
  2455. /** defines the first coordinate */
  2456. x: number;
  2457. /** defines the second coordinate */
  2458. y: number;
  2459. /**
  2460. * Creates a new Vector2 from the given x and y coordinates
  2461. * @param x defines the first coordinate
  2462. * @param y defines the second coordinate
  2463. */
  2464. constructor(
  2465. /** defines the first coordinate */
  2466. x?: number,
  2467. /** defines the second coordinate */
  2468. y?: number);
  2469. /**
  2470. * Gets a string with the Vector2 coordinates
  2471. * @returns a string with the Vector2 coordinates
  2472. */
  2473. toString(): string;
  2474. /**
  2475. * Gets class name
  2476. * @returns the string "Vector2"
  2477. */
  2478. getClassName(): string;
  2479. /**
  2480. * Gets current vector hash code
  2481. * @returns the Vector2 hash code as a number
  2482. */
  2483. getHashCode(): number;
  2484. /**
  2485. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2486. * @param array defines the source array
  2487. * @param index defines the offset in source array
  2488. * @returns the current Vector2
  2489. */
  2490. toArray(array: FloatArray, index?: number): Vector2;
  2491. /**
  2492. * Update the current vector from an array
  2493. * @param array defines the destination array
  2494. * @param index defines the offset in the destination array
  2495. * @returns the current Vector3
  2496. */
  2497. fromArray(array: FloatArray, index?: number): Vector2;
  2498. /**
  2499. * Copy the current vector to an array
  2500. * @returns a new array with 2 elements: the Vector2 coordinates.
  2501. */
  2502. asArray(): number[];
  2503. /**
  2504. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2505. * @param source defines the source Vector2
  2506. * @returns the current updated Vector2
  2507. */
  2508. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2509. /**
  2510. * Sets the Vector2 coordinates with the given floats
  2511. * @param x defines the first coordinate
  2512. * @param y defines the second coordinate
  2513. * @returns the current updated Vector2
  2514. */
  2515. copyFromFloats(x: number, y: number): Vector2;
  2516. /**
  2517. * Sets the Vector2 coordinates with the given floats
  2518. * @param x defines the first coordinate
  2519. * @param y defines the second coordinate
  2520. * @returns the current updated Vector2
  2521. */
  2522. set(x: number, y: number): Vector2;
  2523. /**
  2524. * Add another vector with the current one
  2525. * @param otherVector defines the other vector
  2526. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2527. */
  2528. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2529. /**
  2530. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2531. * @param otherVector defines the other vector
  2532. * @param result defines the target vector
  2533. * @returns the unmodified current Vector2
  2534. */
  2535. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2536. /**
  2537. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2538. * @param otherVector defines the other vector
  2539. * @returns the current updated Vector2
  2540. */
  2541. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2542. /**
  2543. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2544. * @param otherVector defines the other vector
  2545. * @returns a new Vector2
  2546. */
  2547. addVector3(otherVector: Vector3): Vector2;
  2548. /**
  2549. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2550. * @param otherVector defines the other vector
  2551. * @returns a new Vector2
  2552. */
  2553. subtract(otherVector: Vector2): Vector2;
  2554. /**
  2555. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2556. * @param otherVector defines the other vector
  2557. * @param result defines the target vector
  2558. * @returns the unmodified current Vector2
  2559. */
  2560. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2561. /**
  2562. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2563. * @param otherVector defines the other vector
  2564. * @returns the current updated Vector2
  2565. */
  2566. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2567. /**
  2568. * Multiplies in place the current Vector2 coordinates by the given ones
  2569. * @param otherVector defines the other vector
  2570. * @returns the current updated Vector2
  2571. */
  2572. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2573. /**
  2574. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2575. * @param otherVector defines the other vector
  2576. * @returns a new Vector2
  2577. */
  2578. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2579. /**
  2580. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2581. * @param otherVector defines the other vector
  2582. * @param result defines the target vector
  2583. * @returns the unmodified current Vector2
  2584. */
  2585. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2586. /**
  2587. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2588. * @param x defines the first coordinate
  2589. * @param y defines the second coordinate
  2590. * @returns a new Vector2
  2591. */
  2592. multiplyByFloats(x: number, y: number): Vector2;
  2593. /**
  2594. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2595. * @param otherVector defines the other vector
  2596. * @returns a new Vector2
  2597. */
  2598. divide(otherVector: Vector2): Vector2;
  2599. /**
  2600. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2601. * @param otherVector defines the other vector
  2602. * @param result defines the target vector
  2603. * @returns the unmodified current Vector2
  2604. */
  2605. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2606. /**
  2607. * Divides the current Vector2 coordinates by the given ones
  2608. * @param otherVector defines the other vector
  2609. * @returns the current updated Vector2
  2610. */
  2611. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2612. /**
  2613. * Gets a new Vector2 with current Vector2 negated coordinates
  2614. * @returns a new Vector2
  2615. */
  2616. negate(): Vector2;
  2617. /**
  2618. * Negate this vector in place
  2619. * @returns this
  2620. */
  2621. negateInPlace(): Vector2;
  2622. /**
  2623. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2624. * @param result defines the Vector3 object where to store the result
  2625. * @returns the current Vector2
  2626. */
  2627. negateToRef(result: Vector2): Vector2;
  2628. /**
  2629. * Multiply the Vector2 coordinates by scale
  2630. * @param scale defines the scaling factor
  2631. * @returns the current updated Vector2
  2632. */
  2633. scaleInPlace(scale: number): Vector2;
  2634. /**
  2635. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2636. * @param scale defines the scaling factor
  2637. * @returns a new Vector2
  2638. */
  2639. scale(scale: number): Vector2;
  2640. /**
  2641. * Scale the current Vector2 values by a factor to a given Vector2
  2642. * @param scale defines the scale factor
  2643. * @param result defines the Vector2 object where to store the result
  2644. * @returns the unmodified current Vector2
  2645. */
  2646. scaleToRef(scale: number, result: Vector2): Vector2;
  2647. /**
  2648. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2649. * @param scale defines the scale factor
  2650. * @param result defines the Vector2 object where to store the result
  2651. * @returns the unmodified current Vector2
  2652. */
  2653. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2654. /**
  2655. * Gets a boolean if two vectors are equals
  2656. * @param otherVector defines the other vector
  2657. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2658. */
  2659. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2660. /**
  2661. * Gets a boolean if two vectors are equals (using an epsilon value)
  2662. * @param otherVector defines the other vector
  2663. * @param epsilon defines the minimal distance to consider equality
  2664. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2665. */
  2666. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2667. /**
  2668. * Gets a new Vector2 from current Vector2 floored values
  2669. * @returns a new Vector2
  2670. */
  2671. floor(): Vector2;
  2672. /**
  2673. * Gets a new Vector2 from current Vector2 floored values
  2674. * @returns a new Vector2
  2675. */
  2676. fract(): Vector2;
  2677. /**
  2678. * Gets the length of the vector
  2679. * @returns the vector length (float)
  2680. */
  2681. length(): number;
  2682. /**
  2683. * Gets the vector squared length
  2684. * @returns the vector squared length (float)
  2685. */
  2686. lengthSquared(): number;
  2687. /**
  2688. * Normalize the vector
  2689. * @returns the current updated Vector2
  2690. */
  2691. normalize(): Vector2;
  2692. /**
  2693. * Gets a new Vector2 copied from the Vector2
  2694. * @returns a new Vector2
  2695. */
  2696. clone(): Vector2;
  2697. /**
  2698. * Gets a new Vector2(0, 0)
  2699. * @returns a new Vector2
  2700. */
  2701. static Zero(): Vector2;
  2702. /**
  2703. * Gets a new Vector2(1, 1)
  2704. * @returns a new Vector2
  2705. */
  2706. static One(): Vector2;
  2707. /**
  2708. * Gets a new Vector2 set from the given index element of the given array
  2709. * @param array defines the data source
  2710. * @param offset defines the offset in the data source
  2711. * @returns a new Vector2
  2712. */
  2713. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2714. /**
  2715. * Sets "result" from the given index element of the given array
  2716. * @param array defines the data source
  2717. * @param offset defines the offset in the data source
  2718. * @param result defines the target vector
  2719. */
  2720. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2721. /**
  2722. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2723. * @param value1 defines 1st point of control
  2724. * @param value2 defines 2nd point of control
  2725. * @param value3 defines 3rd point of control
  2726. * @param value4 defines 4th point of control
  2727. * @param amount defines the interpolation factor
  2728. * @returns a new Vector2
  2729. */
  2730. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2731. /**
  2732. * 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".
  2733. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2734. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2735. * @param value defines the value to clamp
  2736. * @param min defines the lower limit
  2737. * @param max defines the upper limit
  2738. * @returns a new Vector2
  2739. */
  2740. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2741. /**
  2742. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2743. * @param value1 defines the 1st control point
  2744. * @param tangent1 defines the outgoing tangent
  2745. * @param value2 defines the 2nd control point
  2746. * @param tangent2 defines the incoming tangent
  2747. * @param amount defines the interpolation factor
  2748. * @returns a new Vector2
  2749. */
  2750. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2751. /**
  2752. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2753. * @param start defines the start vector
  2754. * @param end defines the end vector
  2755. * @param amount defines the interpolation factor
  2756. * @returns a new Vector2
  2757. */
  2758. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2759. /**
  2760. * Gets the dot product of the vector "left" and the vector "right"
  2761. * @param left defines first vector
  2762. * @param right defines second vector
  2763. * @returns the dot product (float)
  2764. */
  2765. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2766. /**
  2767. * Returns a new Vector2 equal to the normalized given vector
  2768. * @param vector defines the vector to normalize
  2769. * @returns a new Vector2
  2770. */
  2771. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2772. /**
  2773. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2774. * @param left defines 1st vector
  2775. * @param right defines 2nd vector
  2776. * @returns a new Vector2
  2777. */
  2778. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2779. /**
  2780. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2781. * @param left defines 1st vector
  2782. * @param right defines 2nd vector
  2783. * @returns a new Vector2
  2784. */
  2785. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2786. /**
  2787. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2788. * @param vector defines the vector to transform
  2789. * @param transformation defines the matrix to apply
  2790. * @returns a new Vector2
  2791. */
  2792. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2793. /**
  2794. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2795. * @param vector defines the vector to transform
  2796. * @param transformation defines the matrix to apply
  2797. * @param result defines the target vector
  2798. */
  2799. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2800. /**
  2801. * Determines if a given vector is included in a triangle
  2802. * @param p defines the vector to test
  2803. * @param p0 defines 1st triangle point
  2804. * @param p1 defines 2nd triangle point
  2805. * @param p2 defines 3rd triangle point
  2806. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2807. */
  2808. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2809. /**
  2810. * Gets the distance between the vectors "value1" and "value2"
  2811. * @param value1 defines first vector
  2812. * @param value2 defines second vector
  2813. * @returns the distance between vectors
  2814. */
  2815. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2816. /**
  2817. * Returns the squared distance between the vectors "value1" and "value2"
  2818. * @param value1 defines first vector
  2819. * @param value2 defines second vector
  2820. * @returns the squared distance between vectors
  2821. */
  2822. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2823. /**
  2824. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2825. * @param value1 defines first vector
  2826. * @param value2 defines second vector
  2827. * @returns a new Vector2
  2828. */
  2829. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2830. /**
  2831. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  2832. * @param value1 defines first vector
  2833. * @param value2 defines second vector
  2834. * @param ref defines third vector
  2835. * @returns ref
  2836. */
  2837. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  2838. /**
  2839. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2840. * @param p defines the middle point
  2841. * @param segA defines one point of the segment
  2842. * @param segB defines the other point of the segment
  2843. * @returns the shortest distance
  2844. */
  2845. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2846. }
  2847. /**
  2848. * Class used to store (x,y,z) vector representation
  2849. * A Vector3 is the main object used in 3D geometry
  2850. * It can represent etiher the coordinates of a point the space, either a direction
  2851. * Reminder: js uses a left handed forward facing system
  2852. */
  2853. export class Vector3 {
  2854. private static _UpReadOnly;
  2855. private static _ZeroReadOnly;
  2856. /** @hidden */
  2857. _x: number;
  2858. /** @hidden */
  2859. _y: number;
  2860. /** @hidden */
  2861. _z: number;
  2862. /** @hidden */
  2863. _isDirty: boolean;
  2864. /** Gets or sets the x coordinate */
  2865. get x(): number;
  2866. set x(value: number);
  2867. /** Gets or sets the y coordinate */
  2868. get y(): number;
  2869. set y(value: number);
  2870. /** Gets or sets the z coordinate */
  2871. get z(): number;
  2872. set z(value: number);
  2873. /**
  2874. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2875. * @param x defines the first coordinates (on X axis)
  2876. * @param y defines the second coordinates (on Y axis)
  2877. * @param z defines the third coordinates (on Z axis)
  2878. */
  2879. constructor(x?: number, y?: number, z?: number);
  2880. /**
  2881. * Creates a string representation of the Vector3
  2882. * @returns a string with the Vector3 coordinates.
  2883. */
  2884. toString(): string;
  2885. /**
  2886. * Gets the class name
  2887. * @returns the string "Vector3"
  2888. */
  2889. getClassName(): string;
  2890. /**
  2891. * Creates the Vector3 hash code
  2892. * @returns a number which tends to be unique between Vector3 instances
  2893. */
  2894. getHashCode(): number;
  2895. /**
  2896. * Creates an array containing three elements : the coordinates of the Vector3
  2897. * @returns a new array of numbers
  2898. */
  2899. asArray(): number[];
  2900. /**
  2901. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2902. * @param array defines the destination array
  2903. * @param index defines the offset in the destination array
  2904. * @returns the current Vector3
  2905. */
  2906. toArray(array: FloatArray, index?: number): Vector3;
  2907. /**
  2908. * Update the current vector from an array
  2909. * @param array defines the destination array
  2910. * @param index defines the offset in the destination array
  2911. * @returns the current Vector3
  2912. */
  2913. fromArray(array: FloatArray, index?: number): Vector3;
  2914. /**
  2915. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2916. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2917. */
  2918. toQuaternion(): Quaternion;
  2919. /**
  2920. * Adds the given vector to the current Vector3
  2921. * @param otherVector defines the second operand
  2922. * @returns the current updated Vector3
  2923. */
  2924. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2925. /**
  2926. * Adds the given coordinates to the current Vector3
  2927. * @param x defines the x coordinate of the operand
  2928. * @param y defines the y coordinate of the operand
  2929. * @param z defines the z coordinate of the operand
  2930. * @returns the current updated Vector3
  2931. */
  2932. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2933. /**
  2934. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2935. * @param otherVector defines the second operand
  2936. * @returns the resulting Vector3
  2937. */
  2938. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2939. /**
  2940. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2941. * @param otherVector defines the second operand
  2942. * @param result defines the Vector3 object where to store the result
  2943. * @returns the current Vector3
  2944. */
  2945. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2946. /**
  2947. * Subtract the given vector from the current Vector3
  2948. * @param otherVector defines the second operand
  2949. * @returns the current updated Vector3
  2950. */
  2951. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2952. /**
  2953. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2954. * @param otherVector defines the second operand
  2955. * @returns the resulting Vector3
  2956. */
  2957. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2958. /**
  2959. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2960. * @param otherVector defines the second operand
  2961. * @param result defines the Vector3 object where to store the result
  2962. * @returns the current Vector3
  2963. */
  2964. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2967. * @param x defines the x coordinate of the operand
  2968. * @param y defines the y coordinate of the operand
  2969. * @param z defines the z coordinate of the operand
  2970. * @returns the resulting Vector3
  2971. */
  2972. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2973. /**
  2974. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2975. * @param x defines the x coordinate of the operand
  2976. * @param y defines the y coordinate of the operand
  2977. * @param z defines the z coordinate of the operand
  2978. * @param result defines the Vector3 object where to store the result
  2979. * @returns the current Vector3
  2980. */
  2981. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2982. /**
  2983. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2984. * @returns a new Vector3
  2985. */
  2986. negate(): Vector3;
  2987. /**
  2988. * Negate this vector in place
  2989. * @returns this
  2990. */
  2991. negateInPlace(): Vector3;
  2992. /**
  2993. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2994. * @param result defines the Vector3 object where to store the result
  2995. * @returns the current Vector3
  2996. */
  2997. negateToRef(result: Vector3): Vector3;
  2998. /**
  2999. * Multiplies the Vector3 coordinates by the float "scale"
  3000. * @param scale defines the multiplier factor
  3001. * @returns the current updated Vector3
  3002. */
  3003. scaleInPlace(scale: number): Vector3;
  3004. /**
  3005. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3006. * @param scale defines the multiplier factor
  3007. * @returns a new Vector3
  3008. */
  3009. scale(scale: number): Vector3;
  3010. /**
  3011. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3012. * @param scale defines the multiplier factor
  3013. * @param result defines the Vector3 object where to store the result
  3014. * @returns the current Vector3
  3015. */
  3016. scaleToRef(scale: number, result: Vector3): Vector3;
  3017. /**
  3018. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3019. * @param scale defines the scale factor
  3020. * @param result defines the Vector3 object where to store the result
  3021. * @returns the unmodified current Vector3
  3022. */
  3023. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3024. /**
  3025. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3026. * @param origin defines the origin of the projection ray
  3027. * @param plane defines the plane to project to
  3028. * @returns the projected vector3
  3029. */
  3030. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3031. /**
  3032. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3033. * @param origin defines the origin of the projection ray
  3034. * @param plane defines the plane to project to
  3035. * @param result defines the Vector3 where to store the result
  3036. */
  3037. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3038. /**
  3039. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3040. * @param otherVector defines the second operand
  3041. * @returns true if both vectors are equals
  3042. */
  3043. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3044. /**
  3045. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3046. * @param otherVector defines the second operand
  3047. * @param epsilon defines the minimal distance to define values as equals
  3048. * @returns true if both vectors are distant less than epsilon
  3049. */
  3050. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3051. /**
  3052. * Returns true if the current Vector3 coordinates equals the given floats
  3053. * @param x defines the x coordinate of the operand
  3054. * @param y defines the y coordinate of the operand
  3055. * @param z defines the z coordinate of the operand
  3056. * @returns true if both vectors are equals
  3057. */
  3058. equalsToFloats(x: number, y: number, z: number): boolean;
  3059. /**
  3060. * Multiplies the current Vector3 coordinates by the given ones
  3061. * @param otherVector defines the second operand
  3062. * @returns the current updated Vector3
  3063. */
  3064. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3065. /**
  3066. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3067. * @param otherVector defines the second operand
  3068. * @returns the new Vector3
  3069. */
  3070. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3071. /**
  3072. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3073. * @param otherVector defines the second operand
  3074. * @param result defines the Vector3 object where to store the result
  3075. * @returns the current Vector3
  3076. */
  3077. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3078. /**
  3079. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3080. * @param x defines the x coordinate of the operand
  3081. * @param y defines the y coordinate of the operand
  3082. * @param z defines the z coordinate of the operand
  3083. * @returns the new Vector3
  3084. */
  3085. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3086. /**
  3087. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3088. * @param otherVector defines the second operand
  3089. * @returns the new Vector3
  3090. */
  3091. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3092. /**
  3093. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3094. * @param otherVector defines the second operand
  3095. * @param result defines the Vector3 object where to store the result
  3096. * @returns the current Vector3
  3097. */
  3098. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3099. /**
  3100. * Divides the current Vector3 coordinates by the given ones.
  3101. * @param otherVector defines the second operand
  3102. * @returns the current updated Vector3
  3103. */
  3104. divideInPlace(otherVector: Vector3): Vector3;
  3105. /**
  3106. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3107. * @param other defines the second operand
  3108. * @returns the current updated Vector3
  3109. */
  3110. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3111. /**
  3112. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3113. * @param other defines the second operand
  3114. * @returns the current updated Vector3
  3115. */
  3116. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3117. /**
  3118. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3119. * @param x defines the x coordinate of the operand
  3120. * @param y defines the y coordinate of the operand
  3121. * @param z defines the z coordinate of the operand
  3122. * @returns the current updated Vector3
  3123. */
  3124. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3125. /**
  3126. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3127. * @param x defines the x coordinate of the operand
  3128. * @param y defines the y coordinate of the operand
  3129. * @param z defines the z coordinate of the operand
  3130. * @returns the current updated Vector3
  3131. */
  3132. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3133. /**
  3134. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3135. * Check if is non uniform within a certain amount of decimal places to account for this
  3136. * @param epsilon the amount the values can differ
  3137. * @returns if the the vector is non uniform to a certain number of decimal places
  3138. */
  3139. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3140. /**
  3141. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3142. */
  3143. get isNonUniform(): boolean;
  3144. /**
  3145. * Gets a new Vector3 from current Vector3 floored values
  3146. * @returns a new Vector3
  3147. */
  3148. floor(): Vector3;
  3149. /**
  3150. * Gets a new Vector3 from current Vector3 floored values
  3151. * @returns a new Vector3
  3152. */
  3153. fract(): Vector3;
  3154. /**
  3155. * Gets the length of the Vector3
  3156. * @returns the length of the Vector3
  3157. */
  3158. length(): number;
  3159. /**
  3160. * Gets the squared length of the Vector3
  3161. * @returns squared length of the Vector3
  3162. */
  3163. lengthSquared(): number;
  3164. /**
  3165. * Normalize the current Vector3.
  3166. * Please note that this is an in place operation.
  3167. * @returns the current updated Vector3
  3168. */
  3169. normalize(): Vector3;
  3170. /**
  3171. * Reorders the x y z properties of the vector in place
  3172. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3173. * @returns the current updated vector
  3174. */
  3175. reorderInPlace(order: string): this;
  3176. /**
  3177. * Rotates the vector around 0,0,0 by a quaternion
  3178. * @param quaternion the rotation quaternion
  3179. * @param result vector to store the result
  3180. * @returns the resulting vector
  3181. */
  3182. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3183. /**
  3184. * Rotates a vector around a given point
  3185. * @param quaternion the rotation quaternion
  3186. * @param point the point to rotate around
  3187. * @param result vector to store the result
  3188. * @returns the resulting vector
  3189. */
  3190. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3191. /**
  3192. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3193. * The cross product is then orthogonal to both current and "other"
  3194. * @param other defines the right operand
  3195. * @returns the cross product
  3196. */
  3197. cross(other: Vector3): Vector3;
  3198. /**
  3199. * Normalize the current Vector3 with the given input length.
  3200. * Please note that this is an in place operation.
  3201. * @param len the length of the vector
  3202. * @returns the current updated Vector3
  3203. */
  3204. normalizeFromLength(len: number): Vector3;
  3205. /**
  3206. * Normalize the current Vector3 to a new vector
  3207. * @returns the new Vector3
  3208. */
  3209. normalizeToNew(): Vector3;
  3210. /**
  3211. * Normalize the current Vector3 to the reference
  3212. * @param reference define the Vector3 to update
  3213. * @returns the updated Vector3
  3214. */
  3215. normalizeToRef(reference: Vector3): Vector3;
  3216. /**
  3217. * Creates a new Vector3 copied from the current Vector3
  3218. * @returns the new Vector3
  3219. */
  3220. clone(): Vector3;
  3221. /**
  3222. * Copies the given vector coordinates to the current Vector3 ones
  3223. * @param source defines the source Vector3
  3224. * @returns the current updated Vector3
  3225. */
  3226. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3227. /**
  3228. * Copies the given floats to the current Vector3 coordinates
  3229. * @param x defines the x coordinate of the operand
  3230. * @param y defines the y coordinate of the operand
  3231. * @param z defines the z coordinate of the operand
  3232. * @returns the current updated Vector3
  3233. */
  3234. copyFromFloats(x: number, y: number, z: number): Vector3;
  3235. /**
  3236. * Copies the given floats to the current Vector3 coordinates
  3237. * @param x defines the x coordinate of the operand
  3238. * @param y defines the y coordinate of the operand
  3239. * @param z defines the z coordinate of the operand
  3240. * @returns the current updated Vector3
  3241. */
  3242. set(x: number, y: number, z: number): Vector3;
  3243. /**
  3244. * Copies the given float to the current Vector3 coordinates
  3245. * @param v defines the x, y and z coordinates of the operand
  3246. * @returns the current updated Vector3
  3247. */
  3248. setAll(v: number): Vector3;
  3249. /**
  3250. * Get the clip factor between two vectors
  3251. * @param vector0 defines the first operand
  3252. * @param vector1 defines the second operand
  3253. * @param axis defines the axis to use
  3254. * @param size defines the size along the axis
  3255. * @returns the clip factor
  3256. */
  3257. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3258. /**
  3259. * Get angle between two vectors
  3260. * @param vector0 angle between vector0 and vector1
  3261. * @param vector1 angle between vector0 and vector1
  3262. * @param normal direction of the normal
  3263. * @return the angle between vector0 and vector1
  3264. */
  3265. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3266. /**
  3267. * Returns a new Vector3 set from the index "offset" of the given array
  3268. * @param array defines the source array
  3269. * @param offset defines the offset in the source array
  3270. * @returns the new Vector3
  3271. */
  3272. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3273. /**
  3274. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3275. * @param array defines the source array
  3276. * @param offset defines the offset in the source array
  3277. * @returns the new Vector3
  3278. * @deprecated Please use FromArray instead.
  3279. */
  3280. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3281. /**
  3282. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3283. * @param array defines the source array
  3284. * @param offset defines the offset in the source array
  3285. * @param result defines the Vector3 where to store the result
  3286. */
  3287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3288. /**
  3289. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3290. * @param array defines the source array
  3291. * @param offset defines the offset in the source array
  3292. * @param result defines the Vector3 where to store the result
  3293. * @deprecated Please use FromArrayToRef instead.
  3294. */
  3295. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3296. /**
  3297. * Sets the given vector "result" with the given floats.
  3298. * @param x defines the x coordinate of the source
  3299. * @param y defines the y coordinate of the source
  3300. * @param z defines the z coordinate of the source
  3301. * @param result defines the Vector3 where to store the result
  3302. */
  3303. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3304. /**
  3305. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3306. * @returns a new empty Vector3
  3307. */
  3308. static Zero(): Vector3;
  3309. /**
  3310. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3311. * @returns a new unit Vector3
  3312. */
  3313. static One(): Vector3;
  3314. /**
  3315. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3316. * @returns a new up Vector3
  3317. */
  3318. static Up(): Vector3;
  3319. /**
  3320. * Gets a up Vector3 that must not be updated
  3321. */
  3322. static get UpReadOnly(): DeepImmutable<Vector3>;
  3323. /**
  3324. * Gets a zero Vector3 that must not be updated
  3325. */
  3326. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3327. /**
  3328. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3329. * @returns a new down Vector3
  3330. */
  3331. static Down(): Vector3;
  3332. /**
  3333. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3334. * @param rightHandedSystem is the scene right-handed (negative z)
  3335. * @returns a new forward Vector3
  3336. */
  3337. static Forward(rightHandedSystem?: boolean): Vector3;
  3338. /**
  3339. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3340. * @param rightHandedSystem is the scene right-handed (negative-z)
  3341. * @returns a new forward Vector3
  3342. */
  3343. static Backward(rightHandedSystem?: boolean): Vector3;
  3344. /**
  3345. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3346. * @returns a new right Vector3
  3347. */
  3348. static Right(): Vector3;
  3349. /**
  3350. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3351. * @returns a new left Vector3
  3352. */
  3353. static Left(): Vector3;
  3354. /**
  3355. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3356. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3357. * @param vector defines the Vector3 to transform
  3358. * @param transformation defines the transformation matrix
  3359. * @returns the transformed Vector3
  3360. */
  3361. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3362. /**
  3363. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3364. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3365. * @param vector defines the Vector3 to transform
  3366. * @param transformation defines the transformation matrix
  3367. * @param result defines the Vector3 where to store the result
  3368. */
  3369. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3370. /**
  3371. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3372. * This method computes tranformed coordinates only, not transformed direction vectors
  3373. * @param x define the x coordinate of the source vector
  3374. * @param y define the y coordinate of the source vector
  3375. * @param z define the z coordinate of the source vector
  3376. * @param transformation defines the transformation matrix
  3377. * @param result defines the Vector3 where to store the result
  3378. */
  3379. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3380. /**
  3381. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3382. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3383. * @param vector defines the Vector3 to transform
  3384. * @param transformation defines the transformation matrix
  3385. * @returns the new Vector3
  3386. */
  3387. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3388. /**
  3389. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3390. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3391. * @param vector defines the Vector3 to transform
  3392. * @param transformation defines the transformation matrix
  3393. * @param result defines the Vector3 where to store the result
  3394. */
  3395. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3396. /**
  3397. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3398. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3399. * @param x define the x coordinate of the source vector
  3400. * @param y define the y coordinate of the source vector
  3401. * @param z define the z coordinate of the source vector
  3402. * @param transformation defines the transformation matrix
  3403. * @param result defines the Vector3 where to store the result
  3404. */
  3405. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3406. /**
  3407. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3408. * @param value1 defines the first control point
  3409. * @param value2 defines the second control point
  3410. * @param value3 defines the third control point
  3411. * @param value4 defines the fourth control point
  3412. * @param amount defines the amount on the spline to use
  3413. * @returns the new Vector3
  3414. */
  3415. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3416. /**
  3417. * 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"
  3418. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3419. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3420. * @param value defines the current value
  3421. * @param min defines the lower range value
  3422. * @param max defines the upper range value
  3423. * @returns the new Vector3
  3424. */
  3425. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3426. /**
  3427. * 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"
  3428. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3429. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3430. * @param value defines the current value
  3431. * @param min defines the lower range value
  3432. * @param max defines the upper range value
  3433. * @param result defines the Vector3 where to store the result
  3434. */
  3435. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3436. /**
  3437. * Checks if a given vector is inside a specific range
  3438. * @param v defines the vector to test
  3439. * @param min defines the minimum range
  3440. * @param max defines the maximum range
  3441. */
  3442. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3443. /**
  3444. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3445. * @param value1 defines the first control point
  3446. * @param tangent1 defines the first tangent vector
  3447. * @param value2 defines the second control point
  3448. * @param tangent2 defines the second tangent vector
  3449. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3450. * @returns the new Vector3
  3451. */
  3452. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3453. /**
  3454. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3455. * @param start defines the start value
  3456. * @param end defines the end value
  3457. * @param amount max defines amount between both (between 0 and 1)
  3458. * @returns the new Vector3
  3459. */
  3460. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3461. /**
  3462. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3463. * @param start defines the start value
  3464. * @param end defines the end value
  3465. * @param amount max defines amount between both (between 0 and 1)
  3466. * @param result defines the Vector3 where to store the result
  3467. */
  3468. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3469. /**
  3470. * Returns the dot product (float) between the vectors "left" and "right"
  3471. * @param left defines the left operand
  3472. * @param right defines the right operand
  3473. * @returns the dot product
  3474. */
  3475. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3476. /**
  3477. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3478. * The cross product is then orthogonal to both "left" and "right"
  3479. * @param left defines the left operand
  3480. * @param right defines the right operand
  3481. * @returns the cross product
  3482. */
  3483. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3484. /**
  3485. * Sets the given vector "result" with the cross product of "left" and "right"
  3486. * The cross product is then orthogonal to both "left" and "right"
  3487. * @param left defines the left operand
  3488. * @param right defines the right operand
  3489. * @param result defines the Vector3 where to store the result
  3490. */
  3491. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3492. /**
  3493. * Returns a new Vector3 as the normalization of the given vector
  3494. * @param vector defines the Vector3 to normalize
  3495. * @returns the new Vector3
  3496. */
  3497. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3498. /**
  3499. * Sets the given vector "result" with the normalization of the given first vector
  3500. * @param vector defines the Vector3 to normalize
  3501. * @param result defines the Vector3 where to store the result
  3502. */
  3503. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3504. /**
  3505. * Project a Vector3 onto screen space
  3506. * @param vector defines the Vector3 to project
  3507. * @param world defines the world matrix to use
  3508. * @param transform defines the transform (view x projection) matrix to use
  3509. * @param viewport defines the screen viewport to use
  3510. * @returns the new Vector3
  3511. */
  3512. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3513. /**
  3514. * Project a Vector3 onto screen space to reference
  3515. * @param vector defines the Vector3 to project
  3516. * @param world defines the world matrix to use
  3517. * @param transform defines the transform (view x projection) matrix to use
  3518. * @param viewport defines the screen viewport to use
  3519. * @param result the vector in which the screen space will be stored
  3520. * @returns the new Vector3
  3521. */
  3522. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3523. /** @hidden */
  3524. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3525. /**
  3526. * Unproject from screen space to object space
  3527. * @param source defines the screen space Vector3 to use
  3528. * @param viewportWidth defines the current width of the viewport
  3529. * @param viewportHeight defines the current height of the viewport
  3530. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3531. * @param transform defines the transform (view x projection) matrix to use
  3532. * @returns the new Vector3
  3533. */
  3534. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3535. /**
  3536. * Unproject from screen space to object space
  3537. * @param source defines the screen space Vector3 to use
  3538. * @param viewportWidth defines the current width of the viewport
  3539. * @param viewportHeight defines the current height of the viewport
  3540. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3541. * @param view defines the view matrix to use
  3542. * @param projection defines the projection matrix to use
  3543. * @returns the new Vector3
  3544. */
  3545. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3546. /**
  3547. * Unproject from screen space to object space
  3548. * @param source defines the screen space Vector3 to use
  3549. * @param viewportWidth defines the current width of the viewport
  3550. * @param viewportHeight defines the current height of the viewport
  3551. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3552. * @param view defines the view matrix to use
  3553. * @param projection defines the projection matrix to use
  3554. * @param result defines the Vector3 where to store the result
  3555. */
  3556. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3557. /**
  3558. * Unproject from screen space to object space
  3559. * @param sourceX defines the screen space x coordinate to use
  3560. * @param sourceY defines the screen space y coordinate to use
  3561. * @param sourceZ defines the screen space z coordinate to use
  3562. * @param viewportWidth defines the current width of the viewport
  3563. * @param viewportHeight defines the current height of the viewport
  3564. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3565. * @param view defines the view matrix to use
  3566. * @param projection defines the projection matrix to use
  3567. * @param result defines the Vector3 where to store the result
  3568. */
  3569. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3570. /**
  3571. * Gets the minimal coordinate values between two Vector3
  3572. * @param left defines the first operand
  3573. * @param right defines the second operand
  3574. * @returns the new Vector3
  3575. */
  3576. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3577. /**
  3578. * Gets the maximal coordinate values between two Vector3
  3579. * @param left defines the first operand
  3580. * @param right defines the second operand
  3581. * @returns the new Vector3
  3582. */
  3583. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3584. /**
  3585. * Returns the distance between the vectors "value1" and "value2"
  3586. * @param value1 defines the first operand
  3587. * @param value2 defines the second operand
  3588. * @returns the distance
  3589. */
  3590. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3591. /**
  3592. * Returns the squared distance between the vectors "value1" and "value2"
  3593. * @param value1 defines the first operand
  3594. * @param value2 defines the second operand
  3595. * @returns the squared distance
  3596. */
  3597. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3598. /**
  3599. * Returns a new Vector3 located at the center between "value1" and "value2"
  3600. * @param value1 defines the first operand
  3601. * @param value2 defines the second operand
  3602. * @returns the new Vector3
  3603. */
  3604. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3605. /**
  3606. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3607. * @param value1 defines first vector
  3608. * @param value2 defines second vector
  3609. * @param ref defines third vector
  3610. * @returns ref
  3611. */
  3612. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3613. /**
  3614. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3615. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3616. * to something in order to rotate it from its local system to the given target system
  3617. * Note: axis1, axis2 and axis3 are normalized during this operation
  3618. * @param axis1 defines the first axis
  3619. * @param axis2 defines the second axis
  3620. * @param axis3 defines the third axis
  3621. * @returns a new Vector3
  3622. */
  3623. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3624. /**
  3625. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3626. * @param axis1 defines the first axis
  3627. * @param axis2 defines the second axis
  3628. * @param axis3 defines the third axis
  3629. * @param ref defines the Vector3 where to store the result
  3630. */
  3631. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3632. }
  3633. /**
  3634. * Vector4 class created for EulerAngle class conversion to Quaternion
  3635. */
  3636. export class Vector4 {
  3637. /** x value of the vector */
  3638. x: number;
  3639. /** y value of the vector */
  3640. y: number;
  3641. /** z value of the vector */
  3642. z: number;
  3643. /** w value of the vector */
  3644. w: number;
  3645. /**
  3646. * Creates a Vector4 object from the given floats.
  3647. * @param x x value of the vector
  3648. * @param y y value of the vector
  3649. * @param z z value of the vector
  3650. * @param w w value of the vector
  3651. */
  3652. constructor(
  3653. /** x value of the vector */
  3654. x: number,
  3655. /** y value of the vector */
  3656. y: number,
  3657. /** z value of the vector */
  3658. z: number,
  3659. /** w value of the vector */
  3660. w: number);
  3661. /**
  3662. * Returns the string with the Vector4 coordinates.
  3663. * @returns a string containing all the vector values
  3664. */
  3665. toString(): string;
  3666. /**
  3667. * Returns the string "Vector4".
  3668. * @returns "Vector4"
  3669. */
  3670. getClassName(): string;
  3671. /**
  3672. * Returns the Vector4 hash code.
  3673. * @returns a unique hash code
  3674. */
  3675. getHashCode(): number;
  3676. /**
  3677. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3678. * @returns the resulting array
  3679. */
  3680. asArray(): number[];
  3681. /**
  3682. * Populates the given array from the given index with the Vector4 coordinates.
  3683. * @param array array to populate
  3684. * @param index index of the array to start at (default: 0)
  3685. * @returns the Vector4.
  3686. */
  3687. toArray(array: FloatArray, index?: number): Vector4;
  3688. /**
  3689. * Update the current vector from an array
  3690. * @param array defines the destination array
  3691. * @param index defines the offset in the destination array
  3692. * @returns the current Vector3
  3693. */
  3694. fromArray(array: FloatArray, index?: number): Vector4;
  3695. /**
  3696. * Adds the given vector to the current Vector4.
  3697. * @param otherVector the vector to add
  3698. * @returns the updated Vector4.
  3699. */
  3700. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3701. /**
  3702. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3703. * @param otherVector the vector to add
  3704. * @returns the resulting vector
  3705. */
  3706. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3707. /**
  3708. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3709. * @param otherVector the vector to add
  3710. * @param result the vector to store the result
  3711. * @returns the current Vector4.
  3712. */
  3713. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3714. /**
  3715. * Subtract in place the given vector from the current Vector4.
  3716. * @param otherVector the vector to subtract
  3717. * @returns the updated Vector4.
  3718. */
  3719. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3720. /**
  3721. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3722. * @param otherVector the vector to add
  3723. * @returns the new vector with the result
  3724. */
  3725. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3726. /**
  3727. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3728. * @param otherVector the vector to subtract
  3729. * @param result the vector to store the result
  3730. * @returns the current Vector4.
  3731. */
  3732. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3733. /**
  3734. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3735. */
  3736. /**
  3737. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3738. * @param x value to subtract
  3739. * @param y value to subtract
  3740. * @param z value to subtract
  3741. * @param w value to subtract
  3742. * @returns new vector containing the result
  3743. */
  3744. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3745. /**
  3746. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3747. * @param x value to subtract
  3748. * @param y value to subtract
  3749. * @param z value to subtract
  3750. * @param w value to subtract
  3751. * @param result the vector to store the result in
  3752. * @returns the current Vector4.
  3753. */
  3754. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3755. /**
  3756. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3757. * @returns a new vector with the negated values
  3758. */
  3759. negate(): Vector4;
  3760. /**
  3761. * Negate this vector in place
  3762. * @returns this
  3763. */
  3764. negateInPlace(): Vector4;
  3765. /**
  3766. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3767. * @param result defines the Vector3 object where to store the result
  3768. * @returns the current Vector4
  3769. */
  3770. negateToRef(result: Vector4): Vector4;
  3771. /**
  3772. * Multiplies the current Vector4 coordinates by scale (float).
  3773. * @param scale the number to scale with
  3774. * @returns the updated Vector4.
  3775. */
  3776. scaleInPlace(scale: number): Vector4;
  3777. /**
  3778. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3779. * @param scale the number to scale with
  3780. * @returns a new vector with the result
  3781. */
  3782. scale(scale: number): Vector4;
  3783. /**
  3784. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3785. * @param scale the number to scale with
  3786. * @param result a vector to store the result in
  3787. * @returns the current Vector4.
  3788. */
  3789. scaleToRef(scale: number, result: Vector4): Vector4;
  3790. /**
  3791. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3792. * @param scale defines the scale factor
  3793. * @param result defines the Vector4 object where to store the result
  3794. * @returns the unmodified current Vector4
  3795. */
  3796. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3797. /**
  3798. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3799. * @param otherVector the vector to compare against
  3800. * @returns true if they are equal
  3801. */
  3802. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3803. /**
  3804. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3805. * @param otherVector vector to compare against
  3806. * @param epsilon (Default: very small number)
  3807. * @returns true if they are equal
  3808. */
  3809. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3810. /**
  3811. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3812. * @param x x value to compare against
  3813. * @param y y value to compare against
  3814. * @param z z value to compare against
  3815. * @param w w value to compare against
  3816. * @returns true if equal
  3817. */
  3818. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3819. /**
  3820. * Multiplies in place the current Vector4 by the given one.
  3821. * @param otherVector vector to multiple with
  3822. * @returns the updated Vector4.
  3823. */
  3824. multiplyInPlace(otherVector: Vector4): Vector4;
  3825. /**
  3826. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3827. * @param otherVector vector to multiple with
  3828. * @returns resulting new vector
  3829. */
  3830. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3831. /**
  3832. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3833. * @param otherVector vector to multiple with
  3834. * @param result vector to store the result
  3835. * @returns the current Vector4.
  3836. */
  3837. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3838. /**
  3839. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3840. * @param x x value multiply with
  3841. * @param y y value multiply with
  3842. * @param z z value multiply with
  3843. * @param w w value multiply with
  3844. * @returns resulting new vector
  3845. */
  3846. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3847. /**
  3848. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3849. * @param otherVector vector to devide with
  3850. * @returns resulting new vector
  3851. */
  3852. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3853. /**
  3854. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3855. * @param otherVector vector to devide with
  3856. * @param result vector to store the result
  3857. * @returns the current Vector4.
  3858. */
  3859. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3860. /**
  3861. * Divides the current Vector3 coordinates by the given ones.
  3862. * @param otherVector vector to devide with
  3863. * @returns the updated Vector3.
  3864. */
  3865. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3866. /**
  3867. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3868. * @param other defines the second operand
  3869. * @returns the current updated Vector4
  3870. */
  3871. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3872. /**
  3873. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3874. * @param other defines the second operand
  3875. * @returns the current updated Vector4
  3876. */
  3877. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3878. /**
  3879. * Gets a new Vector4 from current Vector4 floored values
  3880. * @returns a new Vector4
  3881. */
  3882. floor(): Vector4;
  3883. /**
  3884. * Gets a new Vector4 from current Vector3 floored values
  3885. * @returns a new Vector4
  3886. */
  3887. fract(): Vector4;
  3888. /**
  3889. * Returns the Vector4 length (float).
  3890. * @returns the length
  3891. */
  3892. length(): number;
  3893. /**
  3894. * Returns the Vector4 squared length (float).
  3895. * @returns the length squared
  3896. */
  3897. lengthSquared(): number;
  3898. /**
  3899. * Normalizes in place the Vector4.
  3900. * @returns the updated Vector4.
  3901. */
  3902. normalize(): Vector4;
  3903. /**
  3904. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3905. * @returns this converted to a new vector3
  3906. */
  3907. toVector3(): Vector3;
  3908. /**
  3909. * Returns a new Vector4 copied from the current one.
  3910. * @returns the new cloned vector
  3911. */
  3912. clone(): Vector4;
  3913. /**
  3914. * Updates the current Vector4 with the given one coordinates.
  3915. * @param source the source vector to copy from
  3916. * @returns the updated Vector4.
  3917. */
  3918. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3919. /**
  3920. * Updates the current Vector4 coordinates with the given floats.
  3921. * @param x float to copy from
  3922. * @param y float to copy from
  3923. * @param z float to copy from
  3924. * @param w float to copy from
  3925. * @returns the updated Vector4.
  3926. */
  3927. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3928. /**
  3929. * Updates the current Vector4 coordinates with the given floats.
  3930. * @param x float to set from
  3931. * @param y float to set from
  3932. * @param z float to set from
  3933. * @param w float to set from
  3934. * @returns the updated Vector4.
  3935. */
  3936. set(x: number, y: number, z: number, w: number): Vector4;
  3937. /**
  3938. * Copies the given float to the current Vector3 coordinates
  3939. * @param v defines the x, y, z and w coordinates of the operand
  3940. * @returns the current updated Vector3
  3941. */
  3942. setAll(v: number): Vector4;
  3943. /**
  3944. * Returns a new Vector4 set from the starting index of the given array.
  3945. * @param array the array to pull values from
  3946. * @param offset the offset into the array to start at
  3947. * @returns the new vector
  3948. */
  3949. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3950. /**
  3951. * Updates the given vector "result" from the starting index of the given array.
  3952. * @param array the array to pull values from
  3953. * @param offset the offset into the array to start at
  3954. * @param result the vector to store the result in
  3955. */
  3956. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3957. /**
  3958. * Updates the given vector "result" from the starting index of the given Float32Array.
  3959. * @param array the array to pull values from
  3960. * @param offset the offset into the array to start at
  3961. * @param result the vector to store the result in
  3962. */
  3963. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3964. /**
  3965. * Updates the given vector "result" coordinates from the given floats.
  3966. * @param x float to set from
  3967. * @param y float to set from
  3968. * @param z float to set from
  3969. * @param w float to set from
  3970. * @param result the vector to the floats in
  3971. */
  3972. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3973. /**
  3974. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3975. * @returns the new vector
  3976. */
  3977. static Zero(): Vector4;
  3978. /**
  3979. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3980. * @returns the new vector
  3981. */
  3982. static One(): Vector4;
  3983. /**
  3984. * Returns a new normalized Vector4 from the given one.
  3985. * @param vector the vector to normalize
  3986. * @returns the vector
  3987. */
  3988. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3989. /**
  3990. * Updates the given vector "result" from the normalization of the given one.
  3991. * @param vector the vector to normalize
  3992. * @param result the vector to store the result in
  3993. */
  3994. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3995. /**
  3996. * Returns a vector with the minimum values from the left and right vectors
  3997. * @param left left vector to minimize
  3998. * @param right right vector to minimize
  3999. * @returns a new vector with the minimum of the left and right vector values
  4000. */
  4001. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4002. /**
  4003. * Returns a vector with the maximum values from the left and right vectors
  4004. * @param left left vector to maximize
  4005. * @param right right vector to maximize
  4006. * @returns a new vector with the maximum of the left and right vector values
  4007. */
  4008. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4009. /**
  4010. * Returns the distance (float) between the vectors "value1" and "value2".
  4011. * @param value1 value to calulate the distance between
  4012. * @param value2 value to calulate the distance between
  4013. * @return the distance between the two vectors
  4014. */
  4015. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4016. /**
  4017. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4018. * @param value1 value to calulate the distance between
  4019. * @param value2 value to calulate the distance between
  4020. * @return the distance between the two vectors squared
  4021. */
  4022. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4023. /**
  4024. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4025. * @param value1 value to calulate the center between
  4026. * @param value2 value to calulate the center between
  4027. * @return the center between the two vectors
  4028. */
  4029. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4030. /**
  4031. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4032. * @param value1 defines first vector
  4033. * @param value2 defines second vector
  4034. * @param ref defines third vector
  4035. * @returns ref
  4036. */
  4037. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4038. /**
  4039. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4040. * This methods computes transformed normalized direction vectors only.
  4041. * @param vector the vector to transform
  4042. * @param transformation the transformation matrix to apply
  4043. * @returns the new vector
  4044. */
  4045. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4046. /**
  4047. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4048. * This methods computes transformed normalized direction vectors only.
  4049. * @param vector the vector to transform
  4050. * @param transformation the transformation matrix to apply
  4051. * @param result the vector to store the result in
  4052. */
  4053. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4054. /**
  4055. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4056. * This methods computes transformed normalized direction vectors only.
  4057. * @param x value to transform
  4058. * @param y value to transform
  4059. * @param z value to transform
  4060. * @param w value to transform
  4061. * @param transformation the transformation matrix to apply
  4062. * @param result the vector to store the results in
  4063. */
  4064. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4065. /**
  4066. * Creates a new Vector4 from a Vector3
  4067. * @param source defines the source data
  4068. * @param w defines the 4th component (default is 0)
  4069. * @returns a new Vector4
  4070. */
  4071. static FromVector3(source: Vector3, w?: number): Vector4;
  4072. }
  4073. /**
  4074. * Class used to store quaternion data
  4075. * @see https://en.wikipedia.org/wiki/Quaternion
  4076. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4077. */
  4078. export class Quaternion {
  4079. /** @hidden */
  4080. _x: number;
  4081. /** @hidden */
  4082. _y: number;
  4083. /** @hidden */
  4084. _z: number;
  4085. /** @hidden */
  4086. _w: number;
  4087. /** @hidden */
  4088. _isDirty: boolean;
  4089. /** Gets or sets the x coordinate */
  4090. get x(): number;
  4091. set x(value: number);
  4092. /** Gets or sets the y coordinate */
  4093. get y(): number;
  4094. set y(value: number);
  4095. /** Gets or sets the z coordinate */
  4096. get z(): number;
  4097. set z(value: number);
  4098. /** Gets or sets the w coordinate */
  4099. get w(): number;
  4100. set w(value: number);
  4101. /**
  4102. * Creates a new Quaternion from the given floats
  4103. * @param x defines the first component (0 by default)
  4104. * @param y defines the second component (0 by default)
  4105. * @param z defines the third component (0 by default)
  4106. * @param w defines the fourth component (1.0 by default)
  4107. */
  4108. constructor(x?: number, y?: number, z?: number, w?: number);
  4109. /**
  4110. * Gets a string representation for the current quaternion
  4111. * @returns a string with the Quaternion coordinates
  4112. */
  4113. toString(): string;
  4114. /**
  4115. * Gets the class name of the quaternion
  4116. * @returns the string "Quaternion"
  4117. */
  4118. getClassName(): string;
  4119. /**
  4120. * Gets a hash code for this quaternion
  4121. * @returns the quaternion hash code
  4122. */
  4123. getHashCode(): number;
  4124. /**
  4125. * Copy the quaternion to an array
  4126. * @returns a new array populated with 4 elements from the quaternion coordinates
  4127. */
  4128. asArray(): number[];
  4129. /**
  4130. * Check if two quaternions are equals
  4131. * @param otherQuaternion defines the second operand
  4132. * @return true if the current quaternion and the given one coordinates are strictly equals
  4133. */
  4134. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4135. /**
  4136. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4137. * @param otherQuaternion defines the other quaternion
  4138. * @param epsilon defines the minimal distance to consider equality
  4139. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4140. */
  4141. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4142. /**
  4143. * Clone the current quaternion
  4144. * @returns a new quaternion copied from the current one
  4145. */
  4146. clone(): Quaternion;
  4147. /**
  4148. * Copy a quaternion to the current one
  4149. * @param other defines the other quaternion
  4150. * @returns the updated current quaternion
  4151. */
  4152. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4153. /**
  4154. * Updates the current quaternion with the given float coordinates
  4155. * @param x defines the x coordinate
  4156. * @param y defines the y coordinate
  4157. * @param z defines the z coordinate
  4158. * @param w defines the w coordinate
  4159. * @returns the updated current quaternion
  4160. */
  4161. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4162. /**
  4163. * Updates the current quaternion from the given float coordinates
  4164. * @param x defines the x coordinate
  4165. * @param y defines the y coordinate
  4166. * @param z defines the z coordinate
  4167. * @param w defines the w coordinate
  4168. * @returns the updated current quaternion
  4169. */
  4170. set(x: number, y: number, z: number, w: number): Quaternion;
  4171. /**
  4172. * Adds two quaternions
  4173. * @param other defines the second operand
  4174. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4175. */
  4176. add(other: DeepImmutable<Quaternion>): Quaternion;
  4177. /**
  4178. * Add a quaternion to the current one
  4179. * @param other defines the quaternion to add
  4180. * @returns the current quaternion
  4181. */
  4182. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4183. /**
  4184. * Subtract two quaternions
  4185. * @param other defines the second operand
  4186. * @returns a new quaternion as the subtraction result of the given one from the current one
  4187. */
  4188. subtract(other: Quaternion): Quaternion;
  4189. /**
  4190. * Multiplies the current quaternion by a scale factor
  4191. * @param value defines the scale factor
  4192. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4193. */
  4194. scale(value: number): Quaternion;
  4195. /**
  4196. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4197. * @param scale defines the scale factor
  4198. * @param result defines the Quaternion object where to store the result
  4199. * @returns the unmodified current quaternion
  4200. */
  4201. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4202. /**
  4203. * Multiplies in place the current quaternion by a scale factor
  4204. * @param value defines the scale factor
  4205. * @returns the current modified quaternion
  4206. */
  4207. scaleInPlace(value: number): Quaternion;
  4208. /**
  4209. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4210. * @param scale defines the scale factor
  4211. * @param result defines the Quaternion object where to store the result
  4212. * @returns the unmodified current quaternion
  4213. */
  4214. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4215. /**
  4216. * Multiplies two quaternions
  4217. * @param q1 defines the second operand
  4218. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4219. */
  4220. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4221. /**
  4222. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4223. * @param q1 defines the second operand
  4224. * @param result defines the target quaternion
  4225. * @returns the current quaternion
  4226. */
  4227. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4228. /**
  4229. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4230. * @param q1 defines the second operand
  4231. * @returns the currentupdated quaternion
  4232. */
  4233. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4234. /**
  4235. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4236. * @param ref defines the target quaternion
  4237. * @returns the current quaternion
  4238. */
  4239. conjugateToRef(ref: Quaternion): Quaternion;
  4240. /**
  4241. * Conjugates in place (1-q) the current quaternion
  4242. * @returns the current updated quaternion
  4243. */
  4244. conjugateInPlace(): Quaternion;
  4245. /**
  4246. * Conjugates in place (1-q) the current quaternion
  4247. * @returns a new quaternion
  4248. */
  4249. conjugate(): Quaternion;
  4250. /**
  4251. * Gets length of current quaternion
  4252. * @returns the quaternion length (float)
  4253. */
  4254. length(): number;
  4255. /**
  4256. * Normalize in place the current quaternion
  4257. * @returns the current updated quaternion
  4258. */
  4259. normalize(): Quaternion;
  4260. /**
  4261. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4262. * @param order is a reserved parameter and is ignored for now
  4263. * @returns a new Vector3 containing the Euler angles
  4264. */
  4265. toEulerAngles(order?: string): Vector3;
  4266. /**
  4267. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4268. * @param result defines the vector which will be filled with the Euler angles
  4269. * @returns the current unchanged quaternion
  4270. */
  4271. toEulerAnglesToRef(result: Vector3): Quaternion;
  4272. /**
  4273. * Updates the given rotation matrix with the current quaternion values
  4274. * @param result defines the target matrix
  4275. * @returns the current unchanged quaternion
  4276. */
  4277. toRotationMatrix(result: Matrix): Quaternion;
  4278. /**
  4279. * Updates the current quaternion from the given rotation matrix values
  4280. * @param matrix defines the source matrix
  4281. * @returns the current updated quaternion
  4282. */
  4283. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4284. /**
  4285. * Creates a new quaternion from a rotation matrix
  4286. * @param matrix defines the source matrix
  4287. * @returns a new quaternion created from the given rotation matrix values
  4288. */
  4289. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4290. /**
  4291. * Updates the given quaternion with the given rotation matrix values
  4292. * @param matrix defines the source matrix
  4293. * @param result defines the target quaternion
  4294. */
  4295. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4296. /**
  4297. * Returns the dot product (float) between the quaternions "left" and "right"
  4298. * @param left defines the left operand
  4299. * @param right defines the right operand
  4300. * @returns the dot product
  4301. */
  4302. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4303. /**
  4304. * Checks if the two quaternions are close to each other
  4305. * @param quat0 defines the first quaternion to check
  4306. * @param quat1 defines the second quaternion to check
  4307. * @returns true if the two quaternions are close to each other
  4308. */
  4309. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4310. /**
  4311. * Creates an empty quaternion
  4312. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4313. */
  4314. static Zero(): Quaternion;
  4315. /**
  4316. * Inverse a given quaternion
  4317. * @param q defines the source quaternion
  4318. * @returns a new quaternion as the inverted current quaternion
  4319. */
  4320. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4321. /**
  4322. * Inverse a given quaternion
  4323. * @param q defines the source quaternion
  4324. * @param result the quaternion the result will be stored in
  4325. * @returns the result quaternion
  4326. */
  4327. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4328. /**
  4329. * Creates an identity quaternion
  4330. * @returns the identity quaternion
  4331. */
  4332. static Identity(): Quaternion;
  4333. /**
  4334. * Gets a boolean indicating if the given quaternion is identity
  4335. * @param quaternion defines the quaternion to check
  4336. * @returns true if the quaternion is identity
  4337. */
  4338. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4339. /**
  4340. * Creates a quaternion from a rotation around an axis
  4341. * @param axis defines the axis to use
  4342. * @param angle defines the angle to use
  4343. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4344. */
  4345. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4346. /**
  4347. * Creates a rotation around an axis and stores it into the given quaternion
  4348. * @param axis defines the axis to use
  4349. * @param angle defines the angle to use
  4350. * @param result defines the target quaternion
  4351. * @returns the target quaternion
  4352. */
  4353. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4354. /**
  4355. * Creates a new quaternion from data stored into an array
  4356. * @param array defines the data source
  4357. * @param offset defines the offset in the source array where the data starts
  4358. * @returns a new quaternion
  4359. */
  4360. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4361. /**
  4362. * Updates the given quaternion "result" from the starting index of the given array.
  4363. * @param array the array to pull values from
  4364. * @param offset the offset into the array to start at
  4365. * @param result the quaternion to store the result in
  4366. */
  4367. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4368. /**
  4369. * Create a quaternion from Euler rotation angles
  4370. * @param x Pitch
  4371. * @param y Yaw
  4372. * @param z Roll
  4373. * @returns the new Quaternion
  4374. */
  4375. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4376. /**
  4377. * Updates a quaternion from Euler rotation angles
  4378. * @param x Pitch
  4379. * @param y Yaw
  4380. * @param z Roll
  4381. * @param result the quaternion to store the result
  4382. * @returns the updated quaternion
  4383. */
  4384. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4385. /**
  4386. * Create a quaternion from Euler rotation vector
  4387. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4388. * @returns the new Quaternion
  4389. */
  4390. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4391. /**
  4392. * Updates a quaternion from Euler rotation vector
  4393. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4394. * @param result the quaternion to store the result
  4395. * @returns the updated quaternion
  4396. */
  4397. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4398. /**
  4399. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4400. * @param yaw defines the rotation around Y axis
  4401. * @param pitch defines the rotation around X axis
  4402. * @param roll defines the rotation around Z axis
  4403. * @returns the new quaternion
  4404. */
  4405. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4406. /**
  4407. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4408. * @param yaw defines the rotation around Y axis
  4409. * @param pitch defines the rotation around X axis
  4410. * @param roll defines the rotation around Z axis
  4411. * @param result defines the target quaternion
  4412. */
  4413. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4414. /**
  4415. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4416. * @param alpha defines the rotation around first axis
  4417. * @param beta defines the rotation around second axis
  4418. * @param gamma defines the rotation around third axis
  4419. * @returns the new quaternion
  4420. */
  4421. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4422. /**
  4423. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4424. * @param alpha defines the rotation around first axis
  4425. * @param beta defines the rotation around second axis
  4426. * @param gamma defines the rotation around third axis
  4427. * @param result defines the target quaternion
  4428. */
  4429. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4430. /**
  4431. * 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)
  4432. * @param axis1 defines the first axis
  4433. * @param axis2 defines the second axis
  4434. * @param axis3 defines the third axis
  4435. * @returns the new quaternion
  4436. */
  4437. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4438. /**
  4439. * 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
  4440. * @param axis1 defines the first axis
  4441. * @param axis2 defines the second axis
  4442. * @param axis3 defines the third axis
  4443. * @param ref defines the target quaternion
  4444. */
  4445. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4446. /**
  4447. * Interpolates between two quaternions
  4448. * @param left defines first quaternion
  4449. * @param right defines second quaternion
  4450. * @param amount defines the gradient to use
  4451. * @returns the new interpolated quaternion
  4452. */
  4453. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4454. /**
  4455. * Interpolates between two quaternions and stores it into a target quaternion
  4456. * @param left defines first quaternion
  4457. * @param right defines second quaternion
  4458. * @param amount defines the gradient to use
  4459. * @param result defines the target quaternion
  4460. */
  4461. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4462. /**
  4463. * Interpolate between two quaternions using Hermite interpolation
  4464. * @param value1 defines first quaternion
  4465. * @param tangent1 defines the incoming tangent
  4466. * @param value2 defines second quaternion
  4467. * @param tangent2 defines the outgoing tangent
  4468. * @param amount defines the target quaternion
  4469. * @returns the new interpolated quaternion
  4470. */
  4471. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4472. }
  4473. /**
  4474. * Class used to store matrix data (4x4)
  4475. */
  4476. export class Matrix {
  4477. /**
  4478. * Gets the precision of matrix computations
  4479. */
  4480. static get Use64Bits(): boolean;
  4481. private static _updateFlagSeed;
  4482. private static _identityReadOnly;
  4483. private _isIdentity;
  4484. private _isIdentityDirty;
  4485. private _isIdentity3x2;
  4486. private _isIdentity3x2Dirty;
  4487. /**
  4488. * Gets the update flag of the matrix which is an unique number for the matrix.
  4489. * It will be incremented every time the matrix data change.
  4490. * You can use it to speed the comparison between two versions of the same matrix.
  4491. */
  4492. updateFlag: number;
  4493. private readonly _m;
  4494. /**
  4495. * Gets the internal data of the matrix
  4496. */
  4497. get m(): DeepImmutable<Float32Array | Array<number>>;
  4498. /** @hidden */
  4499. _markAsUpdated(): void;
  4500. /** @hidden */
  4501. private _updateIdentityStatus;
  4502. /**
  4503. * Creates an empty matrix (filled with zeros)
  4504. */
  4505. constructor();
  4506. /**
  4507. * Check if the current matrix is identity
  4508. * @returns true is the matrix is the identity matrix
  4509. */
  4510. isIdentity(): boolean;
  4511. /**
  4512. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4513. * @returns true is the matrix is the identity matrix
  4514. */
  4515. isIdentityAs3x2(): boolean;
  4516. /**
  4517. * Gets the determinant of the matrix
  4518. * @returns the matrix determinant
  4519. */
  4520. determinant(): number;
  4521. /**
  4522. * Returns the matrix as a Float32Array or Array<number>
  4523. * @returns the matrix underlying array
  4524. */
  4525. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4526. /**
  4527. * Returns the matrix as a Float32Array or Array<number>
  4528. * @returns the matrix underlying array.
  4529. */
  4530. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4531. /**
  4532. * Inverts the current matrix in place
  4533. * @returns the current inverted matrix
  4534. */
  4535. invert(): Matrix;
  4536. /**
  4537. * Sets all the matrix elements to zero
  4538. * @returns the current matrix
  4539. */
  4540. reset(): Matrix;
  4541. /**
  4542. * Adds the current matrix with a second one
  4543. * @param other defines the matrix to add
  4544. * @returns a new matrix as the addition of the current matrix and the given one
  4545. */
  4546. add(other: DeepImmutable<Matrix>): Matrix;
  4547. /**
  4548. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4549. * @param other defines the matrix to add
  4550. * @param result defines the target matrix
  4551. * @returns the current matrix
  4552. */
  4553. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4554. /**
  4555. * Adds in place the given matrix to the current matrix
  4556. * @param other defines the second operand
  4557. * @returns the current updated matrix
  4558. */
  4559. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4560. /**
  4561. * Sets the given matrix to the current inverted Matrix
  4562. * @param other defines the target matrix
  4563. * @returns the unmodified current matrix
  4564. */
  4565. invertToRef(other: Matrix): Matrix;
  4566. /**
  4567. * add a value at the specified position in the current Matrix
  4568. * @param index the index of the value within the matrix. between 0 and 15.
  4569. * @param value the value to be added
  4570. * @returns the current updated matrix
  4571. */
  4572. addAtIndex(index: number, value: number): Matrix;
  4573. /**
  4574. * mutiply the specified position in the current Matrix by a value
  4575. * @param index the index of the value within the matrix. between 0 and 15.
  4576. * @param value the value to be added
  4577. * @returns the current updated matrix
  4578. */
  4579. multiplyAtIndex(index: number, value: number): Matrix;
  4580. /**
  4581. * Inserts the translation vector (using 3 floats) in the current matrix
  4582. * @param x defines the 1st component of the translation
  4583. * @param y defines the 2nd component of the translation
  4584. * @param z defines the 3rd component of the translation
  4585. * @returns the current updated matrix
  4586. */
  4587. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4588. /**
  4589. * Adds the translation vector (using 3 floats) in the current matrix
  4590. * @param x defines the 1st component of the translation
  4591. * @param y defines the 2nd component of the translation
  4592. * @param z defines the 3rd component of the translation
  4593. * @returns the current updated matrix
  4594. */
  4595. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4596. /**
  4597. * Inserts the translation vector in the current matrix
  4598. * @param vector3 defines the translation to insert
  4599. * @returns the current updated matrix
  4600. */
  4601. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4602. /**
  4603. * Gets the translation value of the current matrix
  4604. * @returns a new Vector3 as the extracted translation from the matrix
  4605. */
  4606. getTranslation(): Vector3;
  4607. /**
  4608. * Fill a Vector3 with the extracted translation from the matrix
  4609. * @param result defines the Vector3 where to store the translation
  4610. * @returns the current matrix
  4611. */
  4612. getTranslationToRef(result: Vector3): Matrix;
  4613. /**
  4614. * Remove rotation and scaling part from the matrix
  4615. * @returns the updated matrix
  4616. */
  4617. removeRotationAndScaling(): Matrix;
  4618. /**
  4619. * Multiply two matrices
  4620. * @param other defines the second operand
  4621. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4622. */
  4623. multiply(other: DeepImmutable<Matrix>): Matrix;
  4624. /**
  4625. * Copy the current matrix from the given one
  4626. * @param other defines the source matrix
  4627. * @returns the current updated matrix
  4628. */
  4629. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4630. /**
  4631. * Populates the given array from the starting index with the current matrix values
  4632. * @param array defines the target array
  4633. * @param offset defines the offset in the target array where to start storing values
  4634. * @returns the current matrix
  4635. */
  4636. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4637. /**
  4638. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4639. * @param other defines the second operand
  4640. * @param result defines the matrix where to store the multiplication
  4641. * @returns the current matrix
  4642. */
  4643. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4644. /**
  4645. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4646. * @param other defines the second operand
  4647. * @param result defines the array where to store the multiplication
  4648. * @param offset defines the offset in the target array where to start storing values
  4649. * @returns the current matrix
  4650. */
  4651. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4652. /**
  4653. * Check equality between this matrix and a second one
  4654. * @param value defines the second matrix to compare
  4655. * @returns true is the current matrix and the given one values are strictly equal
  4656. */
  4657. equals(value: DeepImmutable<Matrix>): boolean;
  4658. /**
  4659. * Clone the current matrix
  4660. * @returns a new matrix from the current matrix
  4661. */
  4662. clone(): Matrix;
  4663. /**
  4664. * Returns the name of the current matrix class
  4665. * @returns the string "Matrix"
  4666. */
  4667. getClassName(): string;
  4668. /**
  4669. * Gets the hash code of the current matrix
  4670. * @returns the hash code
  4671. */
  4672. getHashCode(): number;
  4673. /**
  4674. * Decomposes the current Matrix into a translation, rotation and scaling components
  4675. * @param scale defines the scale vector3 given as a reference to update
  4676. * @param rotation defines the rotation quaternion given as a reference to update
  4677. * @param translation defines the translation vector3 given as a reference to update
  4678. * @returns true if operation was successful
  4679. */
  4680. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4681. /**
  4682. * Gets specific row of the matrix
  4683. * @param index defines the number of the row to get
  4684. * @returns the index-th row of the current matrix as a new Vector4
  4685. */
  4686. getRow(index: number): Nullable<Vector4>;
  4687. /**
  4688. * Sets the index-th row of the current matrix to the vector4 values
  4689. * @param index defines the number of the row to set
  4690. * @param row defines the target vector4
  4691. * @returns the updated current matrix
  4692. */
  4693. setRow(index: number, row: Vector4): Matrix;
  4694. /**
  4695. * Compute the transpose of the matrix
  4696. * @returns the new transposed matrix
  4697. */
  4698. transpose(): Matrix;
  4699. /**
  4700. * Compute the transpose of the matrix and store it in a given matrix
  4701. * @param result defines the target matrix
  4702. * @returns the current matrix
  4703. */
  4704. transposeToRef(result: Matrix): Matrix;
  4705. /**
  4706. * Sets the index-th row of the current matrix with the given 4 x float values
  4707. * @param index defines the row index
  4708. * @param x defines the x component to set
  4709. * @param y defines the y component to set
  4710. * @param z defines the z component to set
  4711. * @param w defines the w component to set
  4712. * @returns the updated current matrix
  4713. */
  4714. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4715. /**
  4716. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4717. * @param scale defines the scale factor
  4718. * @returns a new matrix
  4719. */
  4720. scale(scale: number): Matrix;
  4721. /**
  4722. * Scale the current matrix values by a factor to a given result matrix
  4723. * @param scale defines the scale factor
  4724. * @param result defines the matrix to store the result
  4725. * @returns the current matrix
  4726. */
  4727. scaleToRef(scale: number, result: Matrix): Matrix;
  4728. /**
  4729. * Scale the current matrix values by a factor and add the result to a given matrix
  4730. * @param scale defines the scale factor
  4731. * @param result defines the Matrix to store the result
  4732. * @returns the current matrix
  4733. */
  4734. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4735. /**
  4736. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4737. * @param ref matrix to store the result
  4738. */
  4739. toNormalMatrix(ref: Matrix): void;
  4740. /**
  4741. * Gets only rotation part of the current matrix
  4742. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4743. */
  4744. getRotationMatrix(): Matrix;
  4745. /**
  4746. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4747. * @param result defines the target matrix to store data to
  4748. * @returns the current matrix
  4749. */
  4750. getRotationMatrixToRef(result: Matrix): Matrix;
  4751. /**
  4752. * Toggles model matrix from being right handed to left handed in place and vice versa
  4753. */
  4754. toggleModelMatrixHandInPlace(): void;
  4755. /**
  4756. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4757. */
  4758. toggleProjectionMatrixHandInPlace(): void;
  4759. /**
  4760. * Creates a matrix from an array
  4761. * @param array defines the source array
  4762. * @param offset defines an offset in the source array
  4763. * @returns a new Matrix set from the starting index of the given array
  4764. */
  4765. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4766. /**
  4767. * Copy the content of an array into a given matrix
  4768. * @param array defines the source array
  4769. * @param offset defines an offset in the source array
  4770. * @param result defines the target matrix
  4771. */
  4772. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4773. /**
  4774. * Stores an array into a matrix after having multiplied each component by a given factor
  4775. * @param array defines the source array
  4776. * @param offset defines the offset in the source array
  4777. * @param scale defines the scaling factor
  4778. * @param result defines the target matrix
  4779. */
  4780. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4781. /**
  4782. * Gets an identity matrix that must not be updated
  4783. */
  4784. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4785. /**
  4786. * Stores a list of values (16) inside a given matrix
  4787. * @param initialM11 defines 1st value of 1st row
  4788. * @param initialM12 defines 2nd value of 1st row
  4789. * @param initialM13 defines 3rd value of 1st row
  4790. * @param initialM14 defines 4th value of 1st row
  4791. * @param initialM21 defines 1st value of 2nd row
  4792. * @param initialM22 defines 2nd value of 2nd row
  4793. * @param initialM23 defines 3rd value of 2nd row
  4794. * @param initialM24 defines 4th value of 2nd row
  4795. * @param initialM31 defines 1st value of 3rd row
  4796. * @param initialM32 defines 2nd value of 3rd row
  4797. * @param initialM33 defines 3rd value of 3rd row
  4798. * @param initialM34 defines 4th value of 3rd row
  4799. * @param initialM41 defines 1st value of 4th row
  4800. * @param initialM42 defines 2nd value of 4th row
  4801. * @param initialM43 defines 3rd value of 4th row
  4802. * @param initialM44 defines 4th value of 4th row
  4803. * @param result defines the target matrix
  4804. */
  4805. 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;
  4806. /**
  4807. * Creates new matrix from a list of values (16)
  4808. * @param initialM11 defines 1st value of 1st row
  4809. * @param initialM12 defines 2nd value of 1st row
  4810. * @param initialM13 defines 3rd value of 1st row
  4811. * @param initialM14 defines 4th value of 1st row
  4812. * @param initialM21 defines 1st value of 2nd row
  4813. * @param initialM22 defines 2nd value of 2nd row
  4814. * @param initialM23 defines 3rd value of 2nd row
  4815. * @param initialM24 defines 4th value of 2nd row
  4816. * @param initialM31 defines 1st value of 3rd row
  4817. * @param initialM32 defines 2nd value of 3rd row
  4818. * @param initialM33 defines 3rd value of 3rd row
  4819. * @param initialM34 defines 4th value of 3rd row
  4820. * @param initialM41 defines 1st value of 4th row
  4821. * @param initialM42 defines 2nd value of 4th row
  4822. * @param initialM43 defines 3rd value of 4th row
  4823. * @param initialM44 defines 4th value of 4th row
  4824. * @returns the new matrix
  4825. */
  4826. 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;
  4827. /**
  4828. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4829. * @param scale defines the scale vector3
  4830. * @param rotation defines the rotation quaternion
  4831. * @param translation defines the translation vector3
  4832. * @returns a new matrix
  4833. */
  4834. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4835. /**
  4836. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4837. * @param scale defines the scale vector3
  4838. * @param rotation defines the rotation quaternion
  4839. * @param translation defines the translation vector3
  4840. * @param result defines the target matrix
  4841. */
  4842. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4843. /**
  4844. * Creates a new identity matrix
  4845. * @returns a new identity matrix
  4846. */
  4847. static Identity(): Matrix;
  4848. /**
  4849. * Creates a new identity matrix and stores the result in a given matrix
  4850. * @param result defines the target matrix
  4851. */
  4852. static IdentityToRef(result: Matrix): void;
  4853. /**
  4854. * Creates a new zero matrix
  4855. * @returns a new zero matrix
  4856. */
  4857. static Zero(): Matrix;
  4858. /**
  4859. * Creates a new rotation matrix for "angle" radians around the X axis
  4860. * @param angle defines the angle (in radians) to use
  4861. * @return the new matrix
  4862. */
  4863. static RotationX(angle: number): Matrix;
  4864. /**
  4865. * Creates a new matrix as the invert of a given matrix
  4866. * @param source defines the source matrix
  4867. * @returns the new matrix
  4868. */
  4869. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4870. /**
  4871. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4872. * @param angle defines the angle (in radians) to use
  4873. * @param result defines the target matrix
  4874. */
  4875. static RotationXToRef(angle: number, result: Matrix): void;
  4876. /**
  4877. * Creates a new rotation matrix for "angle" radians around the Y axis
  4878. * @param angle defines the angle (in radians) to use
  4879. * @return the new matrix
  4880. */
  4881. static RotationY(angle: number): Matrix;
  4882. /**
  4883. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4884. * @param angle defines the angle (in radians) to use
  4885. * @param result defines the target matrix
  4886. */
  4887. static RotationYToRef(angle: number, result: Matrix): void;
  4888. /**
  4889. * Creates a new rotation matrix for "angle" radians around the Z axis
  4890. * @param angle defines the angle (in radians) to use
  4891. * @return the new matrix
  4892. */
  4893. static RotationZ(angle: number): Matrix;
  4894. /**
  4895. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4896. * @param angle defines the angle (in radians) to use
  4897. * @param result defines the target matrix
  4898. */
  4899. static RotationZToRef(angle: number, result: Matrix): void;
  4900. /**
  4901. * Creates a new rotation matrix for "angle" radians around the given axis
  4902. * @param axis defines the axis to use
  4903. * @param angle defines the angle (in radians) to use
  4904. * @return the new matrix
  4905. */
  4906. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4907. /**
  4908. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4909. * @param axis defines the axis to use
  4910. * @param angle defines the angle (in radians) to use
  4911. * @param result defines the target matrix
  4912. */
  4913. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4914. /**
  4915. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4916. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4917. * @param from defines the vector to align
  4918. * @param to defines the vector to align to
  4919. * @param result defines the target matrix
  4920. */
  4921. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4922. /**
  4923. * Creates a rotation matrix
  4924. * @param yaw defines the yaw angle in radians (Y axis)
  4925. * @param pitch defines the pitch angle in radians (X axis)
  4926. * @param roll defines the roll angle in radians (Z axis)
  4927. * @returns the new rotation matrix
  4928. */
  4929. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4930. /**
  4931. * Creates a rotation matrix and stores it in a given matrix
  4932. * @param yaw defines the yaw angle in radians (Y axis)
  4933. * @param pitch defines the pitch angle in radians (X axis)
  4934. * @param roll defines the roll angle in radians (Z axis)
  4935. * @param result defines the target matrix
  4936. */
  4937. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4938. /**
  4939. * Creates a scaling matrix
  4940. * @param x defines the scale factor on X axis
  4941. * @param y defines the scale factor on Y axis
  4942. * @param z defines the scale factor on Z axis
  4943. * @returns the new matrix
  4944. */
  4945. static Scaling(x: number, y: number, z: number): Matrix;
  4946. /**
  4947. * Creates a scaling matrix and stores it in a given matrix
  4948. * @param x defines the scale factor on X axis
  4949. * @param y defines the scale factor on Y axis
  4950. * @param z defines the scale factor on Z axis
  4951. * @param result defines the target matrix
  4952. */
  4953. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4954. /**
  4955. * Creates a translation matrix
  4956. * @param x defines the translation on X axis
  4957. * @param y defines the translation on Y axis
  4958. * @param z defines the translationon Z axis
  4959. * @returns the new matrix
  4960. */
  4961. static Translation(x: number, y: number, z: number): Matrix;
  4962. /**
  4963. * Creates a translation matrix and stores it in a given matrix
  4964. * @param x defines the translation on X axis
  4965. * @param y defines the translation on Y axis
  4966. * @param z defines the translationon Z axis
  4967. * @param result defines the target matrix
  4968. */
  4969. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4970. /**
  4971. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4972. * @param startValue defines the start value
  4973. * @param endValue defines the end value
  4974. * @param gradient defines the gradient factor
  4975. * @returns the new matrix
  4976. */
  4977. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4978. /**
  4979. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4980. * @param startValue defines the start value
  4981. * @param endValue defines the end value
  4982. * @param gradient defines the gradient factor
  4983. * @param result defines the Matrix object where to store data
  4984. */
  4985. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4986. /**
  4987. * Builds a new matrix whose values are computed by:
  4988. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4989. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4990. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4991. * @param startValue defines the first matrix
  4992. * @param endValue defines the second matrix
  4993. * @param gradient defines the gradient between the two matrices
  4994. * @returns the new matrix
  4995. */
  4996. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4997. /**
  4998. * Update a matrix to values which are computed by:
  4999. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5000. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5001. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5002. * @param startValue defines the first matrix
  5003. * @param endValue defines the second matrix
  5004. * @param gradient defines the gradient between the two matrices
  5005. * @param result defines the target matrix
  5006. */
  5007. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5008. /**
  5009. * 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"
  5010. * This function works in left handed mode
  5011. * @param eye defines the final position of the entity
  5012. * @param target defines where the entity should look at
  5013. * @param up defines the up vector for the entity
  5014. * @returns the new matrix
  5015. */
  5016. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5017. /**
  5018. * 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".
  5019. * This function works in left handed mode
  5020. * @param eye defines the final position of the entity
  5021. * @param target defines where the entity should look at
  5022. * @param up defines the up vector for the entity
  5023. * @param result defines the target matrix
  5024. */
  5025. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5026. /**
  5027. * 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"
  5028. * This function works in right handed mode
  5029. * @param eye defines the final position of the entity
  5030. * @param target defines where the entity should look at
  5031. * @param up defines the up vector for the entity
  5032. * @returns the new matrix
  5033. */
  5034. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5035. /**
  5036. * 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".
  5037. * This function works in right handed mode
  5038. * @param eye defines the final position of the entity
  5039. * @param target defines where the entity should look at
  5040. * @param up defines the up vector for the entity
  5041. * @param result defines the target matrix
  5042. */
  5043. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5044. /**
  5045. * Create a left-handed orthographic projection matrix
  5046. * @param width defines the viewport width
  5047. * @param height defines the viewport height
  5048. * @param znear defines the near clip plane
  5049. * @param zfar defines the far clip plane
  5050. * @returns a new matrix as a left-handed orthographic projection matrix
  5051. */
  5052. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5053. /**
  5054. * Store a left-handed orthographic projection to a given matrix
  5055. * @param width defines the viewport width
  5056. * @param height defines the viewport height
  5057. * @param znear defines the near clip plane
  5058. * @param zfar defines the far clip plane
  5059. * @param result defines the target matrix
  5060. */
  5061. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5062. /**
  5063. * Create a left-handed orthographic projection matrix
  5064. * @param left defines the viewport left coordinate
  5065. * @param right defines the viewport right coordinate
  5066. * @param bottom defines the viewport bottom coordinate
  5067. * @param top defines the viewport top coordinate
  5068. * @param znear defines the near clip plane
  5069. * @param zfar defines the far clip plane
  5070. * @returns a new matrix as a left-handed orthographic projection matrix
  5071. */
  5072. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5073. /**
  5074. * Stores a left-handed orthographic projection into a given matrix
  5075. * @param left defines the viewport left coordinate
  5076. * @param right defines the viewport right coordinate
  5077. * @param bottom defines the viewport bottom coordinate
  5078. * @param top defines the viewport top coordinate
  5079. * @param znear defines the near clip plane
  5080. * @param zfar defines the far clip plane
  5081. * @param result defines the target matrix
  5082. */
  5083. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5084. /**
  5085. * Creates a right-handed orthographic projection matrix
  5086. * @param left defines the viewport left coordinate
  5087. * @param right defines the viewport right coordinate
  5088. * @param bottom defines the viewport bottom coordinate
  5089. * @param top defines the viewport top coordinate
  5090. * @param znear defines the near clip plane
  5091. * @param zfar defines the far clip plane
  5092. * @returns a new matrix as a right-handed orthographic projection matrix
  5093. */
  5094. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5095. /**
  5096. * Stores a right-handed orthographic projection into a given matrix
  5097. * @param left defines the viewport left coordinate
  5098. * @param right defines the viewport right coordinate
  5099. * @param bottom defines the viewport bottom coordinate
  5100. * @param top defines the viewport top coordinate
  5101. * @param znear defines the near clip plane
  5102. * @param zfar defines the far clip plane
  5103. * @param result defines the target matrix
  5104. */
  5105. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5106. /**
  5107. * Creates a left-handed perspective projection matrix
  5108. * @param width defines the viewport width
  5109. * @param height defines the viewport height
  5110. * @param znear defines the near clip plane
  5111. * @param zfar defines the far clip plane
  5112. * @returns a new matrix as a left-handed perspective projection matrix
  5113. */
  5114. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5115. /**
  5116. * Creates a left-handed perspective projection matrix
  5117. * @param fov defines the horizontal field of view
  5118. * @param aspect defines the aspect ratio
  5119. * @param znear defines the near clip plane
  5120. * @param zfar defines the far clip plane
  5121. * @returns a new matrix as a left-handed perspective projection matrix
  5122. */
  5123. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5124. /**
  5125. * Stores a left-handed perspective projection into a given matrix
  5126. * @param fov defines the horizontal field of view
  5127. * @param aspect defines the aspect ratio
  5128. * @param znear defines the near clip plane
  5129. * @param zfar defines the far clip plane
  5130. * @param result defines the target matrix
  5131. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5132. */
  5133. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5134. /**
  5135. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5136. * @param fov defines the horizontal field of view
  5137. * @param aspect defines the aspect ratio
  5138. * @param znear defines the near clip plane
  5139. * @param zfar not used as infinity is used as far clip
  5140. * @param result defines the target matrix
  5141. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5142. */
  5143. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5144. /**
  5145. * Creates a right-handed perspective projection matrix
  5146. * @param fov defines the horizontal field of view
  5147. * @param aspect defines the aspect ratio
  5148. * @param znear defines the near clip plane
  5149. * @param zfar defines the far clip plane
  5150. * @returns a new matrix as a right-handed perspective projection matrix
  5151. */
  5152. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5153. /**
  5154. * Stores a right-handed perspective projection into a given matrix
  5155. * @param fov defines the horizontal field of view
  5156. * @param aspect defines the aspect ratio
  5157. * @param znear defines the near clip plane
  5158. * @param zfar defines the far clip plane
  5159. * @param result defines the target matrix
  5160. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5161. */
  5162. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5163. /**
  5164. * Stores a right-handed perspective projection into a given matrix
  5165. * @param fov defines the horizontal field of view
  5166. * @param aspect defines the aspect ratio
  5167. * @param znear defines the near clip plane
  5168. * @param zfar not used as infinity is used as far clip
  5169. * @param result defines the target matrix
  5170. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5171. */
  5172. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5173. /**
  5174. * Stores a perspective projection for WebVR info a given matrix
  5175. * @param fov defines the field of view
  5176. * @param znear defines the near clip plane
  5177. * @param zfar defines the far clip plane
  5178. * @param result defines the target matrix
  5179. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5180. */
  5181. static PerspectiveFovWebVRToRef(fov: {
  5182. upDegrees: number;
  5183. downDegrees: number;
  5184. leftDegrees: number;
  5185. rightDegrees: number;
  5186. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5187. /**
  5188. * Computes a complete transformation matrix
  5189. * @param viewport defines the viewport to use
  5190. * @param world defines the world matrix
  5191. * @param view defines the view matrix
  5192. * @param projection defines the projection matrix
  5193. * @param zmin defines the near clip plane
  5194. * @param zmax defines the far clip plane
  5195. * @returns the transformation matrix
  5196. */
  5197. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5198. /**
  5199. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5200. * @param matrix defines the matrix to use
  5201. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5202. */
  5203. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5204. /**
  5205. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5206. * @param matrix defines the matrix to use
  5207. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5208. */
  5209. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5210. /**
  5211. * Compute the transpose of a given matrix
  5212. * @param matrix defines the matrix to transpose
  5213. * @returns the new matrix
  5214. */
  5215. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5216. /**
  5217. * Compute the transpose of a matrix and store it in a target matrix
  5218. * @param matrix defines the matrix to transpose
  5219. * @param result defines the target matrix
  5220. */
  5221. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5222. /**
  5223. * Computes a reflection matrix from a plane
  5224. * @param plane defines the reflection plane
  5225. * @returns a new matrix
  5226. */
  5227. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5228. /**
  5229. * Computes a reflection matrix from a plane
  5230. * @param plane defines the reflection plane
  5231. * @param result defines the target matrix
  5232. */
  5233. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5234. /**
  5235. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5236. * @param xaxis defines the value of the 1st axis
  5237. * @param yaxis defines the value of the 2nd axis
  5238. * @param zaxis defines the value of the 3rd axis
  5239. * @param result defines the target matrix
  5240. */
  5241. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5242. /**
  5243. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5244. * @param quat defines the quaternion to use
  5245. * @param result defines the target matrix
  5246. */
  5247. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5248. }
  5249. /**
  5250. * @hidden
  5251. */
  5252. export class TmpVectors {
  5253. static Vector2: Vector2[];
  5254. static Vector3: Vector3[];
  5255. static Vector4: Vector4[];
  5256. static Quaternion: Quaternion[];
  5257. static Matrix: Matrix[];
  5258. }
  5259. }
  5260. declare module BABYLON {
  5261. /**
  5262. * Defines potential orientation for back face culling
  5263. */
  5264. export enum Orientation {
  5265. /**
  5266. * Clockwise
  5267. */
  5268. CW = 0,
  5269. /** Counter clockwise */
  5270. CCW = 1
  5271. }
  5272. /** Class used to represent a Bezier curve */
  5273. export class BezierCurve {
  5274. /**
  5275. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5276. * @param t defines the time
  5277. * @param x1 defines the left coordinate on X axis
  5278. * @param y1 defines the left coordinate on Y axis
  5279. * @param x2 defines the right coordinate on X axis
  5280. * @param y2 defines the right coordinate on Y axis
  5281. * @returns the interpolated value
  5282. */
  5283. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5284. }
  5285. /**
  5286. * Defines angle representation
  5287. */
  5288. export class Angle {
  5289. private _radians;
  5290. /**
  5291. * Creates an Angle object of "radians" radians (float).
  5292. * @param radians the angle in radians
  5293. */
  5294. constructor(radians: number);
  5295. /**
  5296. * Get value in degrees
  5297. * @returns the Angle value in degrees (float)
  5298. */
  5299. degrees(): number;
  5300. /**
  5301. * Get value in radians
  5302. * @returns the Angle value in radians (float)
  5303. */
  5304. radians(): number;
  5305. /**
  5306. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5307. * @param a defines first point as the origin
  5308. * @param b defines point
  5309. * @returns a new Angle
  5310. */
  5311. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5312. /**
  5313. * Gets a new Angle object from the given float in radians
  5314. * @param radians defines the angle value in radians
  5315. * @returns a new Angle
  5316. */
  5317. static FromRadians(radians: number): Angle;
  5318. /**
  5319. * Gets a new Angle object from the given float in degrees
  5320. * @param degrees defines the angle value in degrees
  5321. * @returns a new Angle
  5322. */
  5323. static FromDegrees(degrees: number): Angle;
  5324. }
  5325. /**
  5326. * This represents an arc in a 2d space.
  5327. */
  5328. export class Arc2 {
  5329. /** Defines the start point of the arc */
  5330. startPoint: Vector2;
  5331. /** Defines the mid point of the arc */
  5332. midPoint: Vector2;
  5333. /** Defines the end point of the arc */
  5334. endPoint: Vector2;
  5335. /**
  5336. * Defines the center point of the arc.
  5337. */
  5338. centerPoint: Vector2;
  5339. /**
  5340. * Defines the radius of the arc.
  5341. */
  5342. radius: number;
  5343. /**
  5344. * Defines the angle of the arc (from mid point to end point).
  5345. */
  5346. angle: Angle;
  5347. /**
  5348. * Defines the start angle of the arc (from start point to middle point).
  5349. */
  5350. startAngle: Angle;
  5351. /**
  5352. * Defines the orientation of the arc (clock wise/counter clock wise).
  5353. */
  5354. orientation: Orientation;
  5355. /**
  5356. * Creates an Arc object from the three given points : start, middle and end.
  5357. * @param startPoint Defines the start point of the arc
  5358. * @param midPoint Defines the midlle point of the arc
  5359. * @param endPoint Defines the end point of the arc
  5360. */
  5361. constructor(
  5362. /** Defines the start point of the arc */
  5363. startPoint: Vector2,
  5364. /** Defines the mid point of the arc */
  5365. midPoint: Vector2,
  5366. /** Defines the end point of the arc */
  5367. endPoint: Vector2);
  5368. }
  5369. /**
  5370. * Represents a 2D path made up of multiple 2D points
  5371. */
  5372. export class Path2 {
  5373. private _points;
  5374. private _length;
  5375. /**
  5376. * If the path start and end point are the same
  5377. */
  5378. closed: boolean;
  5379. /**
  5380. * Creates a Path2 object from the starting 2D coordinates x and y.
  5381. * @param x the starting points x value
  5382. * @param y the starting points y value
  5383. */
  5384. constructor(x: number, y: number);
  5385. /**
  5386. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5387. * @param x the added points x value
  5388. * @param y the added points y value
  5389. * @returns the updated Path2.
  5390. */
  5391. addLineTo(x: number, y: number): Path2;
  5392. /**
  5393. * 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.
  5394. * @param midX middle point x value
  5395. * @param midY middle point y value
  5396. * @param endX end point x value
  5397. * @param endY end point y value
  5398. * @param numberOfSegments (default: 36)
  5399. * @returns the updated Path2.
  5400. */
  5401. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5402. /**
  5403. * Closes the Path2.
  5404. * @returns the Path2.
  5405. */
  5406. close(): Path2;
  5407. /**
  5408. * Gets the sum of the distance between each sequential point in the path
  5409. * @returns the Path2 total length (float).
  5410. */
  5411. length(): number;
  5412. /**
  5413. * Gets the points which construct the path
  5414. * @returns the Path2 internal array of points.
  5415. */
  5416. getPoints(): Vector2[];
  5417. /**
  5418. * Retreives the point at the distance aways from the starting point
  5419. * @param normalizedLengthPosition the length along the path to retreive the point from
  5420. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5421. */
  5422. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5423. /**
  5424. * Creates a new path starting from an x and y position
  5425. * @param x starting x value
  5426. * @param y starting y value
  5427. * @returns a new Path2 starting at the coordinates (x, y).
  5428. */
  5429. static StartingAt(x: number, y: number): Path2;
  5430. }
  5431. /**
  5432. * Represents a 3D path made up of multiple 3D points
  5433. */
  5434. export class Path3D {
  5435. /**
  5436. * an array of Vector3, the curve axis of the Path3D
  5437. */
  5438. path: Vector3[];
  5439. private _curve;
  5440. private _distances;
  5441. private _tangents;
  5442. private _normals;
  5443. private _binormals;
  5444. private _raw;
  5445. private _alignTangentsWithPath;
  5446. private readonly _pointAtData;
  5447. /**
  5448. * new Path3D(path, normal, raw)
  5449. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5450. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5451. * @param path an array of Vector3, the curve axis of the Path3D
  5452. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5453. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5454. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5455. */
  5456. constructor(
  5457. /**
  5458. * an array of Vector3, the curve axis of the Path3D
  5459. */
  5460. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5461. /**
  5462. * Returns the Path3D array of successive Vector3 designing its curve.
  5463. * @returns the Path3D array of successive Vector3 designing its curve.
  5464. */
  5465. getCurve(): Vector3[];
  5466. /**
  5467. * Returns the Path3D array of successive Vector3 designing its curve.
  5468. * @returns the Path3D array of successive Vector3 designing its curve.
  5469. */
  5470. getPoints(): Vector3[];
  5471. /**
  5472. * @returns the computed length (float) of the path.
  5473. */
  5474. length(): number;
  5475. /**
  5476. * Returns an array populated with tangent vectors on each Path3D curve point.
  5477. * @returns an array populated with tangent vectors on each Path3D curve point.
  5478. */
  5479. getTangents(): Vector3[];
  5480. /**
  5481. * Returns an array populated with normal vectors on each Path3D curve point.
  5482. * @returns an array populated with normal vectors on each Path3D curve point.
  5483. */
  5484. getNormals(): Vector3[];
  5485. /**
  5486. * Returns an array populated with binormal vectors on each Path3D curve point.
  5487. * @returns an array populated with binormal vectors on each Path3D curve point.
  5488. */
  5489. getBinormals(): Vector3[];
  5490. /**
  5491. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5492. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5493. */
  5494. getDistances(): number[];
  5495. /**
  5496. * Returns an interpolated point along this path
  5497. * @param position the position of the point along this path, from 0.0 to 1.0
  5498. * @returns a new Vector3 as the point
  5499. */
  5500. getPointAt(position: number): Vector3;
  5501. /**
  5502. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5503. * @param position the position of the point along this path, from 0.0 to 1.0
  5504. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5505. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5506. */
  5507. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5508. /**
  5509. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5510. * @param position the position of the point along this path, from 0.0 to 1.0
  5511. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5512. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5513. */
  5514. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5515. /**
  5516. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5517. * @param position the position of the point along this path, from 0.0 to 1.0
  5518. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5519. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5520. */
  5521. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5522. /**
  5523. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5524. * @param position the position of the point along this path, from 0.0 to 1.0
  5525. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5526. */
  5527. getDistanceAt(position: number): number;
  5528. /**
  5529. * Returns the array index of the previous point of an interpolated point along this path
  5530. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5531. * @returns the array index
  5532. */
  5533. getPreviousPointIndexAt(position: number): number;
  5534. /**
  5535. * 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)
  5536. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5537. * @returns the sub position
  5538. */
  5539. getSubPositionAt(position: number): number;
  5540. /**
  5541. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5542. * @param target the vector of which to get the closest position to
  5543. * @returns the position of the closest virtual point on this path to the target vector
  5544. */
  5545. getClosestPositionTo(target: Vector3): number;
  5546. /**
  5547. * Returns a sub path (slice) of this path
  5548. * @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
  5549. * @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
  5550. * @returns a sub path (slice) of this path
  5551. */
  5552. slice(start?: number, end?: number): Path3D;
  5553. /**
  5554. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5555. * @param path path which all values are copied into the curves points
  5556. * @param firstNormal which should be projected onto the curve
  5557. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5558. * @returns the same object updated.
  5559. */
  5560. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5561. private _compute;
  5562. private _getFirstNonNullVector;
  5563. private _getLastNonNullVector;
  5564. private _normalVector;
  5565. /**
  5566. * Updates the point at data for an interpolated point along this curve
  5567. * @param position the position of the point along this curve, from 0.0 to 1.0
  5568. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5569. * @returns the (updated) point at data
  5570. */
  5571. private _updatePointAtData;
  5572. /**
  5573. * Updates the point at data from the specified parameters
  5574. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5575. * @param point the interpolated point
  5576. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5577. */
  5578. private _setPointAtData;
  5579. /**
  5580. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5581. */
  5582. private _updateInterpolationMatrix;
  5583. }
  5584. /**
  5585. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5586. * A Curve3 is designed from a series of successive Vector3.
  5587. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5588. */
  5589. export class Curve3 {
  5590. private _points;
  5591. private _length;
  5592. /**
  5593. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5594. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5595. * @param v1 (Vector3) the control point
  5596. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5597. * @param nbPoints (integer) the wanted number of points in the curve
  5598. * @returns the created Curve3
  5599. */
  5600. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5601. /**
  5602. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5603. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5604. * @param v1 (Vector3) the first control point
  5605. * @param v2 (Vector3) the second control point
  5606. * @param v3 (Vector3) the end point of the Cubic Bezier
  5607. * @param nbPoints (integer) the wanted number of points in the curve
  5608. * @returns the created Curve3
  5609. */
  5610. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5611. /**
  5612. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5613. * @param p1 (Vector3) the origin point of the Hermite Spline
  5614. * @param t1 (Vector3) the tangent vector at the origin point
  5615. * @param p2 (Vector3) the end point of the Hermite Spline
  5616. * @param t2 (Vector3) the tangent vector at the end point
  5617. * @param nbPoints (integer) the wanted number of points in the curve
  5618. * @returns the created Curve3
  5619. */
  5620. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5621. /**
  5622. * Returns a Curve3 object along a CatmullRom Spline curve :
  5623. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5624. * @param nbPoints (integer) the wanted number of points between each curve control points
  5625. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5626. * @returns the created Curve3
  5627. */
  5628. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5629. /**
  5630. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5631. * A Curve3 is designed from a series of successive Vector3.
  5632. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5633. * @param points points which make up the curve
  5634. */
  5635. constructor(points: Vector3[]);
  5636. /**
  5637. * @returns the Curve3 stored array of successive Vector3
  5638. */
  5639. getPoints(): Vector3[];
  5640. /**
  5641. * @returns the computed length (float) of the curve.
  5642. */
  5643. length(): number;
  5644. /**
  5645. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5646. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5647. * curveA and curveB keep unchanged.
  5648. * @param curve the curve to continue from this curve
  5649. * @returns the newly constructed curve
  5650. */
  5651. continue(curve: DeepImmutable<Curve3>): Curve3;
  5652. private _computeLength;
  5653. }
  5654. }
  5655. declare module BABYLON {
  5656. /**
  5657. * This represents the main contract an easing function should follow.
  5658. * Easing functions are used throughout the animation system.
  5659. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5660. */
  5661. export interface IEasingFunction {
  5662. /**
  5663. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5664. * of the easing function.
  5665. * The link below provides some of the most common examples of easing functions.
  5666. * @see https://easings.net/
  5667. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5668. * @returns the corresponding value on the curve defined by the easing function
  5669. */
  5670. ease(gradient: number): number;
  5671. }
  5672. /**
  5673. * Base class used for every default easing function.
  5674. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5675. */
  5676. export class EasingFunction implements IEasingFunction {
  5677. /**
  5678. * Interpolation follows the mathematical formula associated with the easing function.
  5679. */
  5680. static readonly EASINGMODE_EASEIN: number;
  5681. /**
  5682. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5683. */
  5684. static readonly EASINGMODE_EASEOUT: number;
  5685. /**
  5686. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5687. */
  5688. static readonly EASINGMODE_EASEINOUT: number;
  5689. private _easingMode;
  5690. /**
  5691. * Sets the easing mode of the current function.
  5692. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5693. */
  5694. setEasingMode(easingMode: number): void;
  5695. /**
  5696. * Gets the current easing mode.
  5697. * @returns the easing mode
  5698. */
  5699. getEasingMode(): number;
  5700. /**
  5701. * @hidden
  5702. */
  5703. easeInCore(gradient: number): number;
  5704. /**
  5705. * Given an input gradient between 0 and 1, this returns the corresponding value
  5706. * of the easing function.
  5707. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5708. * @returns the corresponding value on the curve defined by the easing function
  5709. */
  5710. ease(gradient: number): number;
  5711. }
  5712. /**
  5713. * Easing function with a circle shape (see link below).
  5714. * @see https://easings.net/#easeInCirc
  5715. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5716. */
  5717. export class CircleEase extends EasingFunction implements IEasingFunction {
  5718. /** @hidden */
  5719. easeInCore(gradient: number): number;
  5720. }
  5721. /**
  5722. * Easing function with a ease back shape (see link below).
  5723. * @see https://easings.net/#easeInBack
  5724. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5725. */
  5726. export class BackEase extends EasingFunction implements IEasingFunction {
  5727. /** Defines the amplitude of the function */
  5728. amplitude: number;
  5729. /**
  5730. * Instantiates a back ease easing
  5731. * @see https://easings.net/#easeInBack
  5732. * @param amplitude Defines the amplitude of the function
  5733. */
  5734. constructor(
  5735. /** Defines the amplitude of the function */
  5736. amplitude?: number);
  5737. /** @hidden */
  5738. easeInCore(gradient: number): number;
  5739. }
  5740. /**
  5741. * Easing function with a bouncing shape (see link below).
  5742. * @see https://easings.net/#easeInBounce
  5743. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5744. */
  5745. export class BounceEase extends EasingFunction implements IEasingFunction {
  5746. /** Defines the number of bounces */
  5747. bounces: number;
  5748. /** Defines the amplitude of the bounce */
  5749. bounciness: number;
  5750. /**
  5751. * Instantiates a bounce easing
  5752. * @see https://easings.net/#easeInBounce
  5753. * @param bounces Defines the number of bounces
  5754. * @param bounciness Defines the amplitude of the bounce
  5755. */
  5756. constructor(
  5757. /** Defines the number of bounces */
  5758. bounces?: number,
  5759. /** Defines the amplitude of the bounce */
  5760. bounciness?: number);
  5761. /** @hidden */
  5762. easeInCore(gradient: number): number;
  5763. }
  5764. /**
  5765. * Easing function with a power of 3 shape (see link below).
  5766. * @see https://easings.net/#easeInCubic
  5767. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5768. */
  5769. export class CubicEase extends EasingFunction implements IEasingFunction {
  5770. /** @hidden */
  5771. easeInCore(gradient: number): number;
  5772. }
  5773. /**
  5774. * Easing function with an elastic shape (see link below).
  5775. * @see https://easings.net/#easeInElastic
  5776. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5777. */
  5778. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5779. /** Defines the number of oscillations*/
  5780. oscillations: number;
  5781. /** Defines the amplitude of the oscillations*/
  5782. springiness: number;
  5783. /**
  5784. * Instantiates an elastic easing function
  5785. * @see https://easings.net/#easeInElastic
  5786. * @param oscillations Defines the number of oscillations
  5787. * @param springiness Defines the amplitude of the oscillations
  5788. */
  5789. constructor(
  5790. /** Defines the number of oscillations*/
  5791. oscillations?: number,
  5792. /** Defines the amplitude of the oscillations*/
  5793. springiness?: number);
  5794. /** @hidden */
  5795. easeInCore(gradient: number): number;
  5796. }
  5797. /**
  5798. * Easing function with an exponential shape (see link below).
  5799. * @see https://easings.net/#easeInExpo
  5800. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5801. */
  5802. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5803. /** Defines the exponent of the function */
  5804. exponent: number;
  5805. /**
  5806. * Instantiates an exponential easing function
  5807. * @see https://easings.net/#easeInExpo
  5808. * @param exponent Defines the exponent of the function
  5809. */
  5810. constructor(
  5811. /** Defines the exponent of the function */
  5812. exponent?: number);
  5813. /** @hidden */
  5814. easeInCore(gradient: number): number;
  5815. }
  5816. /**
  5817. * Easing function with a power shape (see link below).
  5818. * @see https://easings.net/#easeInQuad
  5819. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5820. */
  5821. export class PowerEase extends EasingFunction implements IEasingFunction {
  5822. /** Defines the power of the function */
  5823. power: number;
  5824. /**
  5825. * Instantiates an power base easing function
  5826. * @see https://easings.net/#easeInQuad
  5827. * @param power Defines the power of the function
  5828. */
  5829. constructor(
  5830. /** Defines the power of the function */
  5831. power?: number);
  5832. /** @hidden */
  5833. easeInCore(gradient: number): number;
  5834. }
  5835. /**
  5836. * Easing function with a power of 2 shape (see link below).
  5837. * @see https://easings.net/#easeInQuad
  5838. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5839. */
  5840. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5841. /** @hidden */
  5842. easeInCore(gradient: number): number;
  5843. }
  5844. /**
  5845. * Easing function with a power of 4 shape (see link below).
  5846. * @see https://easings.net/#easeInQuart
  5847. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5848. */
  5849. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5850. /** @hidden */
  5851. easeInCore(gradient: number): number;
  5852. }
  5853. /**
  5854. * Easing function with a power of 5 shape (see link below).
  5855. * @see https://easings.net/#easeInQuint
  5856. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5857. */
  5858. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5859. /** @hidden */
  5860. easeInCore(gradient: number): number;
  5861. }
  5862. /**
  5863. * Easing function with a sin shape (see link below).
  5864. * @see https://easings.net/#easeInSine
  5865. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5866. */
  5867. export class SineEase extends EasingFunction implements IEasingFunction {
  5868. /** @hidden */
  5869. easeInCore(gradient: number): number;
  5870. }
  5871. /**
  5872. * Easing function with a bezier shape (see link below).
  5873. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5874. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5875. */
  5876. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5877. /** Defines the x component of the start tangent in the bezier curve */
  5878. x1: number;
  5879. /** Defines the y component of the start tangent in the bezier curve */
  5880. y1: number;
  5881. /** Defines the x component of the end tangent in the bezier curve */
  5882. x2: number;
  5883. /** Defines the y component of the end tangent in the bezier curve */
  5884. y2: number;
  5885. /**
  5886. * Instantiates a bezier function
  5887. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5888. * @param x1 Defines the x component of the start tangent in the bezier curve
  5889. * @param y1 Defines the y component of the start tangent in the bezier curve
  5890. * @param x2 Defines the x component of the end tangent in the bezier curve
  5891. * @param y2 Defines the y component of the end tangent in the bezier curve
  5892. */
  5893. constructor(
  5894. /** Defines the x component of the start tangent in the bezier curve */
  5895. x1?: number,
  5896. /** Defines the y component of the start tangent in the bezier curve */
  5897. y1?: number,
  5898. /** Defines the x component of the end tangent in the bezier curve */
  5899. x2?: number,
  5900. /** Defines the y component of the end tangent in the bezier curve */
  5901. y2?: number);
  5902. /** @hidden */
  5903. easeInCore(gradient: number): number;
  5904. }
  5905. }
  5906. declare module BABYLON {
  5907. /**
  5908. * Class used to hold a RBG color
  5909. */
  5910. export class Color3 {
  5911. /**
  5912. * Defines the red component (between 0 and 1, default is 0)
  5913. */
  5914. r: number;
  5915. /**
  5916. * Defines the green component (between 0 and 1, default is 0)
  5917. */
  5918. g: number;
  5919. /**
  5920. * Defines the blue component (between 0 and 1, default is 0)
  5921. */
  5922. b: number;
  5923. /**
  5924. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5925. * @param r defines the red component (between 0 and 1, default is 0)
  5926. * @param g defines the green component (between 0 and 1, default is 0)
  5927. * @param b defines the blue component (between 0 and 1, default is 0)
  5928. */
  5929. constructor(
  5930. /**
  5931. * Defines the red component (between 0 and 1, default is 0)
  5932. */
  5933. r?: number,
  5934. /**
  5935. * Defines the green component (between 0 and 1, default is 0)
  5936. */
  5937. g?: number,
  5938. /**
  5939. * Defines the blue component (between 0 and 1, default is 0)
  5940. */
  5941. b?: number);
  5942. /**
  5943. * Creates a string with the Color3 current values
  5944. * @returns the string representation of the Color3 object
  5945. */
  5946. toString(): string;
  5947. /**
  5948. * Returns the string "Color3"
  5949. * @returns "Color3"
  5950. */
  5951. getClassName(): string;
  5952. /**
  5953. * Compute the Color3 hash code
  5954. * @returns an unique number that can be used to hash Color3 objects
  5955. */
  5956. getHashCode(): number;
  5957. /**
  5958. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5959. * @param array defines the array where to store the r,g,b components
  5960. * @param index defines an optional index in the target array to define where to start storing values
  5961. * @returns the current Color3 object
  5962. */
  5963. toArray(array: FloatArray, index?: number): Color3;
  5964. /**
  5965. * Update the current color with values stored in an array from the starting index of the given array
  5966. * @param array defines the source array
  5967. * @param offset defines an offset in the source array
  5968. * @returns the current Color3 object
  5969. */
  5970. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5971. /**
  5972. * Returns a new Color4 object from the current Color3 and the given alpha
  5973. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5974. * @returns a new Color4 object
  5975. */
  5976. toColor4(alpha?: number): Color4;
  5977. /**
  5978. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5979. * @returns the new array
  5980. */
  5981. asArray(): number[];
  5982. /**
  5983. * Returns the luminance value
  5984. * @returns a float value
  5985. */
  5986. toLuminance(): number;
  5987. /**
  5988. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5989. * @param otherColor defines the second operand
  5990. * @returns the new Color3 object
  5991. */
  5992. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5993. /**
  5994. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5995. * @param otherColor defines the second operand
  5996. * @param result defines the Color3 object where to store the result
  5997. * @returns the current Color3
  5998. */
  5999. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6000. /**
  6001. * Determines equality between Color3 objects
  6002. * @param otherColor defines the second operand
  6003. * @returns true if the rgb values are equal to the given ones
  6004. */
  6005. equals(otherColor: DeepImmutable<Color3>): boolean;
  6006. /**
  6007. * Determines equality between the current Color3 object and a set of r,b,g values
  6008. * @param r defines the red component to check
  6009. * @param g defines the green component to check
  6010. * @param b defines the blue component to check
  6011. * @returns true if the rgb values are equal to the given ones
  6012. */
  6013. equalsFloats(r: number, g: number, b: number): boolean;
  6014. /**
  6015. * Multiplies in place each rgb value by scale
  6016. * @param scale defines the scaling factor
  6017. * @returns the updated Color3
  6018. */
  6019. scale(scale: number): Color3;
  6020. /**
  6021. * Multiplies the rgb values by scale and stores the result into "result"
  6022. * @param scale defines the scaling factor
  6023. * @param result defines the Color3 object where to store the result
  6024. * @returns the unmodified current Color3
  6025. */
  6026. scaleToRef(scale: number, result: Color3): Color3;
  6027. /**
  6028. * Scale the current Color3 values by a factor and add the result to a given Color3
  6029. * @param scale defines the scale factor
  6030. * @param result defines color to store the result into
  6031. * @returns the unmodified current Color3
  6032. */
  6033. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6034. /**
  6035. * Clamps the rgb values by the min and max values and stores the result into "result"
  6036. * @param min defines minimum clamping value (default is 0)
  6037. * @param max defines maximum clamping value (default is 1)
  6038. * @param result defines color to store the result into
  6039. * @returns the original Color3
  6040. */
  6041. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6042. /**
  6043. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6044. * @param otherColor defines the second operand
  6045. * @returns the new Color3
  6046. */
  6047. add(otherColor: DeepImmutable<Color3>): Color3;
  6048. /**
  6049. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6050. * @param otherColor defines the second operand
  6051. * @param result defines Color3 object to store the result into
  6052. * @returns the unmodified current Color3
  6053. */
  6054. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6055. /**
  6056. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6057. * @param otherColor defines the second operand
  6058. * @returns the new Color3
  6059. */
  6060. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6061. /**
  6062. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6063. * @param otherColor defines the second operand
  6064. * @param result defines Color3 object to store the result into
  6065. * @returns the unmodified current Color3
  6066. */
  6067. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6068. /**
  6069. * Copy the current object
  6070. * @returns a new Color3 copied the current one
  6071. */
  6072. clone(): Color3;
  6073. /**
  6074. * Copies the rgb values from the source in the current Color3
  6075. * @param source defines the source Color3 object
  6076. * @returns the updated Color3 object
  6077. */
  6078. copyFrom(source: DeepImmutable<Color3>): Color3;
  6079. /**
  6080. * Updates the Color3 rgb values from the given floats
  6081. * @param r defines the red component to read from
  6082. * @param g defines the green component to read from
  6083. * @param b defines the blue component to read from
  6084. * @returns the current Color3 object
  6085. */
  6086. copyFromFloats(r: number, g: number, b: number): Color3;
  6087. /**
  6088. * Updates the Color3 rgb values from the given floats
  6089. * @param r defines the red component to read from
  6090. * @param g defines the green component to read from
  6091. * @param b defines the blue component to read from
  6092. * @returns the current Color3 object
  6093. */
  6094. set(r: number, g: number, b: number): Color3;
  6095. /**
  6096. * Compute the Color3 hexadecimal code as a string
  6097. * @returns a string containing the hexadecimal representation of the Color3 object
  6098. */
  6099. toHexString(): string;
  6100. /**
  6101. * Computes a new Color3 converted from the current one to linear space
  6102. * @returns a new Color3 object
  6103. */
  6104. toLinearSpace(): Color3;
  6105. /**
  6106. * Converts current color in rgb space to HSV values
  6107. * @returns a new color3 representing the HSV values
  6108. */
  6109. toHSV(): Color3;
  6110. /**
  6111. * Converts current color in rgb space to HSV values
  6112. * @param result defines the Color3 where to store the HSV values
  6113. */
  6114. toHSVToRef(result: Color3): void;
  6115. /**
  6116. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6117. * @param convertedColor defines the Color3 object where to store the linear space version
  6118. * @returns the unmodified Color3
  6119. */
  6120. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6121. /**
  6122. * Computes a new Color3 converted from the current one to gamma space
  6123. * @returns a new Color3 object
  6124. */
  6125. toGammaSpace(): Color3;
  6126. /**
  6127. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6128. * @param convertedColor defines the Color3 object where to store the gamma space version
  6129. * @returns the unmodified Color3
  6130. */
  6131. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6132. private static _BlackReadOnly;
  6133. /**
  6134. * Convert Hue, saturation and value to a Color3 (RGB)
  6135. * @param hue defines the hue
  6136. * @param saturation defines the saturation
  6137. * @param value defines the value
  6138. * @param result defines the Color3 where to store the RGB values
  6139. */
  6140. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6141. /**
  6142. * Creates a new Color3 from the string containing valid hexadecimal values
  6143. * @param hex defines a string containing valid hexadecimal values
  6144. * @returns a new Color3 object
  6145. */
  6146. static FromHexString(hex: string): Color3;
  6147. /**
  6148. * Creates a new Color3 from the starting index of the given array
  6149. * @param array defines the source array
  6150. * @param offset defines an offset in the source array
  6151. * @returns a new Color3 object
  6152. */
  6153. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6154. /**
  6155. * Creates a new Color3 from the starting index element of the given array
  6156. * @param array defines the source array to read from
  6157. * @param offset defines the offset in the source array
  6158. * @param result defines the target Color3 object
  6159. */
  6160. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6161. /**
  6162. * Creates a new Color3 from integer values (< 256)
  6163. * @param r defines the red component to read from (value between 0 and 255)
  6164. * @param g defines the green component to read from (value between 0 and 255)
  6165. * @param b defines the blue component to read from (value between 0 and 255)
  6166. * @returns a new Color3 object
  6167. */
  6168. static FromInts(r: number, g: number, b: number): Color3;
  6169. /**
  6170. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6171. * @param start defines the start Color3 value
  6172. * @param end defines the end Color3 value
  6173. * @param amount defines the gradient value between start and end
  6174. * @returns a new Color3 object
  6175. */
  6176. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6177. /**
  6178. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6179. * @param left defines the start value
  6180. * @param right defines the end value
  6181. * @param amount defines the gradient factor
  6182. * @param result defines the Color3 object where to store the result
  6183. */
  6184. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6185. /**
  6186. * Returns a Color3 value containing a red color
  6187. * @returns a new Color3 object
  6188. */
  6189. static Red(): Color3;
  6190. /**
  6191. * Returns a Color3 value containing a green color
  6192. * @returns a new Color3 object
  6193. */
  6194. static Green(): Color3;
  6195. /**
  6196. * Returns a Color3 value containing a blue color
  6197. * @returns a new Color3 object
  6198. */
  6199. static Blue(): Color3;
  6200. /**
  6201. * Returns a Color3 value containing a black color
  6202. * @returns a new Color3 object
  6203. */
  6204. static Black(): Color3;
  6205. /**
  6206. * Gets a Color3 value containing a black color that must not be updated
  6207. */
  6208. static get BlackReadOnly(): DeepImmutable<Color3>;
  6209. /**
  6210. * Returns a Color3 value containing a white color
  6211. * @returns a new Color3 object
  6212. */
  6213. static White(): Color3;
  6214. /**
  6215. * Returns a Color3 value containing a purple color
  6216. * @returns a new Color3 object
  6217. */
  6218. static Purple(): Color3;
  6219. /**
  6220. * Returns a Color3 value containing a magenta color
  6221. * @returns a new Color3 object
  6222. */
  6223. static Magenta(): Color3;
  6224. /**
  6225. * Returns a Color3 value containing a yellow color
  6226. * @returns a new Color3 object
  6227. */
  6228. static Yellow(): Color3;
  6229. /**
  6230. * Returns a Color3 value containing a gray color
  6231. * @returns a new Color3 object
  6232. */
  6233. static Gray(): Color3;
  6234. /**
  6235. * Returns a Color3 value containing a teal color
  6236. * @returns a new Color3 object
  6237. */
  6238. static Teal(): Color3;
  6239. /**
  6240. * Returns a Color3 value containing a random color
  6241. * @returns a new Color3 object
  6242. */
  6243. static Random(): Color3;
  6244. }
  6245. /**
  6246. * Class used to hold a RBGA color
  6247. */
  6248. export class Color4 {
  6249. /**
  6250. * Defines the red component (between 0 and 1, default is 0)
  6251. */
  6252. r: number;
  6253. /**
  6254. * Defines the green component (between 0 and 1, default is 0)
  6255. */
  6256. g: number;
  6257. /**
  6258. * Defines the blue component (between 0 and 1, default is 0)
  6259. */
  6260. b: number;
  6261. /**
  6262. * Defines the alpha component (between 0 and 1, default is 1)
  6263. */
  6264. a: number;
  6265. /**
  6266. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6267. * @param r defines the red component (between 0 and 1, default is 0)
  6268. * @param g defines the green component (between 0 and 1, default is 0)
  6269. * @param b defines the blue component (between 0 and 1, default is 0)
  6270. * @param a defines the alpha component (between 0 and 1, default is 1)
  6271. */
  6272. constructor(
  6273. /**
  6274. * Defines the red component (between 0 and 1, default is 0)
  6275. */
  6276. r?: number,
  6277. /**
  6278. * Defines the green component (between 0 and 1, default is 0)
  6279. */
  6280. g?: number,
  6281. /**
  6282. * Defines the blue component (between 0 and 1, default is 0)
  6283. */
  6284. b?: number,
  6285. /**
  6286. * Defines the alpha component (between 0 and 1, default is 1)
  6287. */
  6288. a?: number);
  6289. /**
  6290. * Adds in place the given Color4 values to the current Color4 object
  6291. * @param right defines the second operand
  6292. * @returns the current updated Color4 object
  6293. */
  6294. addInPlace(right: DeepImmutable<Color4>): Color4;
  6295. /**
  6296. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6297. * @returns the new array
  6298. */
  6299. asArray(): number[];
  6300. /**
  6301. * Stores from the starting index in the given array the Color4 successive values
  6302. * @param array defines the array where to store the r,g,b components
  6303. * @param index defines an optional index in the target array to define where to start storing values
  6304. * @returns the current Color4 object
  6305. */
  6306. toArray(array: number[], index?: number): Color4;
  6307. /**
  6308. * Update the current color with values stored in an array from the starting index of the given array
  6309. * @param array defines the source array
  6310. * @param offset defines an offset in the source array
  6311. * @returns the current Color4 object
  6312. */
  6313. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6314. /**
  6315. * Determines equality between Color4 objects
  6316. * @param otherColor defines the second operand
  6317. * @returns true if the rgba values are equal to the given ones
  6318. */
  6319. equals(otherColor: DeepImmutable<Color4>): boolean;
  6320. /**
  6321. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6322. * @param right defines the second operand
  6323. * @returns a new Color4 object
  6324. */
  6325. add(right: DeepImmutable<Color4>): Color4;
  6326. /**
  6327. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6328. * @param right defines the second operand
  6329. * @returns a new Color4 object
  6330. */
  6331. subtract(right: DeepImmutable<Color4>): Color4;
  6332. /**
  6333. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6334. * @param right defines the second operand
  6335. * @param result defines the Color4 object where to store the result
  6336. * @returns the current Color4 object
  6337. */
  6338. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6339. /**
  6340. * Creates a new Color4 with the current Color4 values multiplied by scale
  6341. * @param scale defines the scaling factor to apply
  6342. * @returns a new Color4 object
  6343. */
  6344. scale(scale: number): Color4;
  6345. /**
  6346. * Multiplies the current Color4 values by scale and stores the result in "result"
  6347. * @param scale defines the scaling factor to apply
  6348. * @param result defines the Color4 object where to store the result
  6349. * @returns the current unmodified Color4
  6350. */
  6351. scaleToRef(scale: number, result: Color4): Color4;
  6352. /**
  6353. * Scale the current Color4 values by a factor and add the result to a given Color4
  6354. * @param scale defines the scale factor
  6355. * @param result defines the Color4 object where to store the result
  6356. * @returns the unmodified current Color4
  6357. */
  6358. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6359. /**
  6360. * Clamps the rgb values by the min and max values and stores the result into "result"
  6361. * @param min defines minimum clamping value (default is 0)
  6362. * @param max defines maximum clamping value (default is 1)
  6363. * @param result defines color to store the result into.
  6364. * @returns the cuurent Color4
  6365. */
  6366. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6367. /**
  6368. * Multipy an Color4 value by another and return a new Color4 object
  6369. * @param color defines the Color4 value to multiply by
  6370. * @returns a new Color4 object
  6371. */
  6372. multiply(color: Color4): Color4;
  6373. /**
  6374. * Multipy a Color4 value by another and push the result in a reference value
  6375. * @param color defines the Color4 value to multiply by
  6376. * @param result defines the Color4 to fill the result in
  6377. * @returns the result Color4
  6378. */
  6379. multiplyToRef(color: Color4, result: Color4): Color4;
  6380. /**
  6381. * Creates a string with the Color4 current values
  6382. * @returns the string representation of the Color4 object
  6383. */
  6384. toString(): string;
  6385. /**
  6386. * Returns the string "Color4"
  6387. * @returns "Color4"
  6388. */
  6389. getClassName(): string;
  6390. /**
  6391. * Compute the Color4 hash code
  6392. * @returns an unique number that can be used to hash Color4 objects
  6393. */
  6394. getHashCode(): number;
  6395. /**
  6396. * Creates a new Color4 copied from the current one
  6397. * @returns a new Color4 object
  6398. */
  6399. clone(): Color4;
  6400. /**
  6401. * Copies the given Color4 values into the current one
  6402. * @param source defines the source Color4 object
  6403. * @returns the current updated Color4 object
  6404. */
  6405. copyFrom(source: Color4): Color4;
  6406. /**
  6407. * Copies the given float values into the current one
  6408. * @param r defines the red component to read from
  6409. * @param g defines the green component to read from
  6410. * @param b defines the blue component to read from
  6411. * @param a defines the alpha component to read from
  6412. * @returns the current updated Color4 object
  6413. */
  6414. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6415. /**
  6416. * Copies the given float values into the current one
  6417. * @param r defines the red component to read from
  6418. * @param g defines the green component to read from
  6419. * @param b defines the blue component to read from
  6420. * @param a defines the alpha component to read from
  6421. * @returns the current updated Color4 object
  6422. */
  6423. set(r: number, g: number, b: number, a: number): Color4;
  6424. /**
  6425. * Compute the Color4 hexadecimal code as a string
  6426. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6427. * @returns a string containing the hexadecimal representation of the Color4 object
  6428. */
  6429. toHexString(returnAsColor3?: boolean): string;
  6430. /**
  6431. * Computes a new Color4 converted from the current one to linear space
  6432. * @returns a new Color4 object
  6433. */
  6434. toLinearSpace(): Color4;
  6435. /**
  6436. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6437. * @param convertedColor defines the Color4 object where to store the linear space version
  6438. * @returns the unmodified Color4
  6439. */
  6440. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6441. /**
  6442. * Computes a new Color4 converted from the current one to gamma space
  6443. * @returns a new Color4 object
  6444. */
  6445. toGammaSpace(): Color4;
  6446. /**
  6447. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6448. * @param convertedColor defines the Color4 object where to store the gamma space version
  6449. * @returns the unmodified Color4
  6450. */
  6451. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6452. /**
  6453. * Creates a new Color4 from the string containing valid hexadecimal values
  6454. * @param hex defines a string containing valid hexadecimal values
  6455. * @returns a new Color4 object
  6456. */
  6457. static FromHexString(hex: string): Color4;
  6458. /**
  6459. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6460. * @param left defines the start value
  6461. * @param right defines the end value
  6462. * @param amount defines the gradient factor
  6463. * @returns a new Color4 object
  6464. */
  6465. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6466. /**
  6467. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6468. * @param left defines the start value
  6469. * @param right defines the end value
  6470. * @param amount defines the gradient factor
  6471. * @param result defines the Color4 object where to store data
  6472. */
  6473. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6474. /**
  6475. * Creates a new Color4 from a Color3 and an alpha value
  6476. * @param color3 defines the source Color3 to read from
  6477. * @param alpha defines the alpha component (1.0 by default)
  6478. * @returns a new Color4 object
  6479. */
  6480. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6481. /**
  6482. * Creates a new Color4 from the starting index element of the given array
  6483. * @param array defines the source array to read from
  6484. * @param offset defines the offset in the source array
  6485. * @returns a new Color4 object
  6486. */
  6487. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6488. /**
  6489. * Creates a new Color4 from the starting index element of the given array
  6490. * @param array defines the source array to read from
  6491. * @param offset defines the offset in the source array
  6492. * @param result defines the target Color4 object
  6493. */
  6494. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6495. /**
  6496. * Creates a new Color3 from integer values (< 256)
  6497. * @param r defines the red component to read from (value between 0 and 255)
  6498. * @param g defines the green component to read from (value between 0 and 255)
  6499. * @param b defines the blue component to read from (value between 0 and 255)
  6500. * @param a defines the alpha component to read from (value between 0 and 255)
  6501. * @returns a new Color3 object
  6502. */
  6503. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6504. /**
  6505. * Check the content of a given array and convert it to an array containing RGBA data
  6506. * If the original array was already containing count * 4 values then it is returned directly
  6507. * @param colors defines the array to check
  6508. * @param count defines the number of RGBA data to expect
  6509. * @returns an array containing count * 4 values (RGBA)
  6510. */
  6511. static CheckColors4(colors: number[], count: number): number[];
  6512. }
  6513. /**
  6514. * @hidden
  6515. */
  6516. export class TmpColors {
  6517. static Color3: Color3[];
  6518. static Color4: Color4[];
  6519. }
  6520. }
  6521. declare module BABYLON {
  6522. /**
  6523. * Defines an interface which represents an animation key frame
  6524. */
  6525. export interface IAnimationKey {
  6526. /**
  6527. * Frame of the key frame
  6528. */
  6529. frame: number;
  6530. /**
  6531. * Value at the specifies key frame
  6532. */
  6533. value: any;
  6534. /**
  6535. * The input tangent for the cubic hermite spline
  6536. */
  6537. inTangent?: any;
  6538. /**
  6539. * The output tangent for the cubic hermite spline
  6540. */
  6541. outTangent?: any;
  6542. /**
  6543. * The animation interpolation type
  6544. */
  6545. interpolation?: AnimationKeyInterpolation;
  6546. }
  6547. /**
  6548. * Enum for the animation key frame interpolation type
  6549. */
  6550. export enum AnimationKeyInterpolation {
  6551. /**
  6552. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6553. */
  6554. STEP = 1
  6555. }
  6556. }
  6557. declare module BABYLON {
  6558. /**
  6559. * Represents the range of an animation
  6560. */
  6561. export class AnimationRange {
  6562. /**The name of the animation range**/
  6563. name: string;
  6564. /**The starting frame of the animation */
  6565. from: number;
  6566. /**The ending frame of the animation*/
  6567. to: number;
  6568. /**
  6569. * Initializes the range of an animation
  6570. * @param name The name of the animation range
  6571. * @param from The starting frame of the animation
  6572. * @param to The ending frame of the animation
  6573. */
  6574. constructor(
  6575. /**The name of the animation range**/
  6576. name: string,
  6577. /**The starting frame of the animation */
  6578. from: number,
  6579. /**The ending frame of the animation*/
  6580. to: number);
  6581. /**
  6582. * Makes a copy of the animation range
  6583. * @returns A copy of the animation range
  6584. */
  6585. clone(): AnimationRange;
  6586. }
  6587. }
  6588. declare module BABYLON {
  6589. /**
  6590. * Composed of a frame, and an action function
  6591. */
  6592. export class AnimationEvent {
  6593. /** The frame for which the event is triggered **/
  6594. frame: number;
  6595. /** The event to perform when triggered **/
  6596. action: (currentFrame: number) => void;
  6597. /** Specifies if the event should be triggered only once**/
  6598. onlyOnce?: boolean | undefined;
  6599. /**
  6600. * Specifies if the animation event is done
  6601. */
  6602. isDone: boolean;
  6603. /**
  6604. * Initializes the animation event
  6605. * @param frame The frame for which the event is triggered
  6606. * @param action The event to perform when triggered
  6607. * @param onlyOnce Specifies if the event should be triggered only once
  6608. */
  6609. constructor(
  6610. /** The frame for which the event is triggered **/
  6611. frame: number,
  6612. /** The event to perform when triggered **/
  6613. action: (currentFrame: number) => void,
  6614. /** Specifies if the event should be triggered only once**/
  6615. onlyOnce?: boolean | undefined);
  6616. /** @hidden */
  6617. _clone(): AnimationEvent;
  6618. }
  6619. }
  6620. declare module BABYLON {
  6621. /**
  6622. * Interface used to define a behavior
  6623. */
  6624. export interface Behavior<T> {
  6625. /** gets or sets behavior's name */
  6626. name: string;
  6627. /**
  6628. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6629. */
  6630. init(): void;
  6631. /**
  6632. * Called when the behavior is attached to a target
  6633. * @param target defines the target where the behavior is attached to
  6634. */
  6635. attach(target: T): void;
  6636. /**
  6637. * Called when the behavior is detached from its target
  6638. */
  6639. detach(): void;
  6640. }
  6641. /**
  6642. * Interface implemented by classes supporting behaviors
  6643. */
  6644. export interface IBehaviorAware<T> {
  6645. /**
  6646. * Attach a behavior
  6647. * @param behavior defines the behavior to attach
  6648. * @returns the current host
  6649. */
  6650. addBehavior(behavior: Behavior<T>): T;
  6651. /**
  6652. * Remove a behavior from the current object
  6653. * @param behavior defines the behavior to detach
  6654. * @returns the current host
  6655. */
  6656. removeBehavior(behavior: Behavior<T>): T;
  6657. /**
  6658. * Gets a behavior using its name to search
  6659. * @param name defines the name to search
  6660. * @returns the behavior or null if not found
  6661. */
  6662. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6663. }
  6664. }
  6665. declare module BABYLON {
  6666. /**
  6667. * Class used to store data that will be store in GPU memory
  6668. */
  6669. export class Buffer {
  6670. private _engine;
  6671. private _buffer;
  6672. /** @hidden */
  6673. _data: Nullable<DataArray>;
  6674. private _updatable;
  6675. private _instanced;
  6676. private _divisor;
  6677. private _isAlreadyOwned;
  6678. /**
  6679. * Gets the byte stride.
  6680. */
  6681. readonly byteStride: number;
  6682. /**
  6683. * Constructor
  6684. * @param engine the engine
  6685. * @param data the data to use for this buffer
  6686. * @param updatable whether the data is updatable
  6687. * @param stride the stride (optional)
  6688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6689. * @param instanced whether the buffer is instanced (optional)
  6690. * @param useBytes set to true if the stride in in bytes (optional)
  6691. * @param divisor sets an optional divisor for instances (1 by default)
  6692. */
  6693. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6694. /**
  6695. * Create a new VertexBuffer based on the current buffer
  6696. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6697. * @param offset defines offset in the buffer (0 by default)
  6698. * @param size defines the size in floats of attributes (position is 3 for instance)
  6699. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6700. * @param instanced defines if the vertex buffer contains indexed data
  6701. * @param useBytes defines if the offset and stride are in bytes *
  6702. * @param divisor sets an optional divisor for instances (1 by default)
  6703. * @returns the new vertex buffer
  6704. */
  6705. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6706. /**
  6707. * Gets a boolean indicating if the Buffer is updatable?
  6708. * @returns true if the buffer is updatable
  6709. */
  6710. isUpdatable(): boolean;
  6711. /**
  6712. * Gets current buffer's data
  6713. * @returns a DataArray or null
  6714. */
  6715. getData(): Nullable<DataArray>;
  6716. /**
  6717. * Gets underlying native buffer
  6718. * @returns underlying native buffer
  6719. */
  6720. getBuffer(): Nullable<DataBuffer>;
  6721. /**
  6722. * Gets the stride in float32 units (i.e. byte stride / 4).
  6723. * May not be an integer if the byte stride is not divisible by 4.
  6724. * @returns the stride in float32 units
  6725. * @deprecated Please use byteStride instead.
  6726. */
  6727. getStrideSize(): number;
  6728. /**
  6729. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6730. * @param data defines the data to store
  6731. */
  6732. create(data?: Nullable<DataArray>): void;
  6733. /** @hidden */
  6734. _rebuild(): void;
  6735. /**
  6736. * Update current buffer data
  6737. * @param data defines the data to store
  6738. */
  6739. update(data: DataArray): void;
  6740. /**
  6741. * Updates the data directly.
  6742. * @param data the new data
  6743. * @param offset the new offset
  6744. * @param vertexCount the vertex count (optional)
  6745. * @param useBytes set to true if the offset is in bytes
  6746. */
  6747. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6748. /** @hidden */
  6749. _increaseReferences(): void;
  6750. /**
  6751. * Release all resources
  6752. */
  6753. dispose(): void;
  6754. }
  6755. /**
  6756. * Specialized buffer used to store vertex data
  6757. */
  6758. export class VertexBuffer {
  6759. /** @hidden */
  6760. _buffer: Buffer;
  6761. private _kind;
  6762. private _size;
  6763. private _ownsBuffer;
  6764. private _instanced;
  6765. private _instanceDivisor;
  6766. /**
  6767. * The byte type.
  6768. */
  6769. static readonly BYTE: number;
  6770. /**
  6771. * The unsigned byte type.
  6772. */
  6773. static readonly UNSIGNED_BYTE: number;
  6774. /**
  6775. * The short type.
  6776. */
  6777. static readonly SHORT: number;
  6778. /**
  6779. * The unsigned short type.
  6780. */
  6781. static readonly UNSIGNED_SHORT: number;
  6782. /**
  6783. * The integer type.
  6784. */
  6785. static readonly INT: number;
  6786. /**
  6787. * The unsigned integer type.
  6788. */
  6789. static readonly UNSIGNED_INT: number;
  6790. /**
  6791. * The float type.
  6792. */
  6793. static readonly FLOAT: number;
  6794. /**
  6795. * Gets or sets the instance divisor when in instanced mode
  6796. */
  6797. get instanceDivisor(): number;
  6798. set instanceDivisor(value: number);
  6799. /**
  6800. * Gets the byte stride.
  6801. */
  6802. readonly byteStride: number;
  6803. /**
  6804. * Gets the byte offset.
  6805. */
  6806. readonly byteOffset: number;
  6807. /**
  6808. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6809. */
  6810. readonly normalized: boolean;
  6811. /**
  6812. * Gets the data type of each component in the array.
  6813. */
  6814. readonly type: number;
  6815. /**
  6816. * Constructor
  6817. * @param engine the engine
  6818. * @param data the data to use for this vertex buffer
  6819. * @param kind the vertex buffer kind
  6820. * @param updatable whether the data is updatable
  6821. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6822. * @param stride the stride (optional)
  6823. * @param instanced whether the buffer is instanced (optional)
  6824. * @param offset the offset of the data (optional)
  6825. * @param size the number of components (optional)
  6826. * @param type the type of the component (optional)
  6827. * @param normalized whether the data contains normalized data (optional)
  6828. * @param useBytes set to true if stride and offset are in bytes (optional)
  6829. * @param divisor defines the instance divisor to use (1 by default)
  6830. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  6831. */
  6832. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number, takeBufferOwnership?: boolean);
  6833. /** @hidden */
  6834. _rebuild(): void;
  6835. /**
  6836. * Returns the kind of the VertexBuffer (string)
  6837. * @returns a string
  6838. */
  6839. getKind(): string;
  6840. /**
  6841. * Gets a boolean indicating if the VertexBuffer is updatable?
  6842. * @returns true if the buffer is updatable
  6843. */
  6844. isUpdatable(): boolean;
  6845. /**
  6846. * Gets current buffer's data
  6847. * @returns a DataArray or null
  6848. */
  6849. getData(): Nullable<DataArray>;
  6850. /**
  6851. * Gets underlying native buffer
  6852. * @returns underlying native buffer
  6853. */
  6854. getBuffer(): Nullable<DataBuffer>;
  6855. /**
  6856. * Gets the stride in float32 units (i.e. byte stride / 4).
  6857. * May not be an integer if the byte stride is not divisible by 4.
  6858. * @returns the stride in float32 units
  6859. * @deprecated Please use byteStride instead.
  6860. */
  6861. getStrideSize(): number;
  6862. /**
  6863. * Returns the offset as a multiple of the type byte length.
  6864. * @returns the offset in bytes
  6865. * @deprecated Please use byteOffset instead.
  6866. */
  6867. getOffset(): number;
  6868. /**
  6869. * Returns the number of components per vertex attribute (integer)
  6870. * @returns the size in float
  6871. */
  6872. getSize(): number;
  6873. /**
  6874. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6875. * @returns true if this buffer is instanced
  6876. */
  6877. getIsInstanced(): boolean;
  6878. /**
  6879. * Returns the instancing divisor, zero for non-instanced (integer).
  6880. * @returns a number
  6881. */
  6882. getInstanceDivisor(): number;
  6883. /**
  6884. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6885. * @param data defines the data to store
  6886. */
  6887. create(data?: DataArray): void;
  6888. /**
  6889. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6890. * This function will create a new buffer if the current one is not updatable
  6891. * @param data defines the data to store
  6892. */
  6893. update(data: DataArray): void;
  6894. /**
  6895. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6896. * Returns the directly updated WebGLBuffer.
  6897. * @param data the new data
  6898. * @param offset the new offset
  6899. * @param useBytes set to true if the offset is in bytes
  6900. */
  6901. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6902. /**
  6903. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6904. */
  6905. dispose(): void;
  6906. /**
  6907. * Enumerates each value of this vertex buffer as numbers.
  6908. * @param count the number of values to enumerate
  6909. * @param callback the callback function called for each value
  6910. */
  6911. forEach(count: number, callback: (value: number, index: number) => void): void;
  6912. /**
  6913. * Positions
  6914. */
  6915. static readonly PositionKind: string;
  6916. /**
  6917. * Normals
  6918. */
  6919. static readonly NormalKind: string;
  6920. /**
  6921. * Tangents
  6922. */
  6923. static readonly TangentKind: string;
  6924. /**
  6925. * Texture coordinates
  6926. */
  6927. static readonly UVKind: string;
  6928. /**
  6929. * Texture coordinates 2
  6930. */
  6931. static readonly UV2Kind: string;
  6932. /**
  6933. * Texture coordinates 3
  6934. */
  6935. static readonly UV3Kind: string;
  6936. /**
  6937. * Texture coordinates 4
  6938. */
  6939. static readonly UV4Kind: string;
  6940. /**
  6941. * Texture coordinates 5
  6942. */
  6943. static readonly UV5Kind: string;
  6944. /**
  6945. * Texture coordinates 6
  6946. */
  6947. static readonly UV6Kind: string;
  6948. /**
  6949. * Colors
  6950. */
  6951. static readonly ColorKind: string;
  6952. /**
  6953. * Matrix indices (for bones)
  6954. */
  6955. static readonly MatricesIndicesKind: string;
  6956. /**
  6957. * Matrix weights (for bones)
  6958. */
  6959. static readonly MatricesWeightsKind: string;
  6960. /**
  6961. * Additional matrix indices (for bones)
  6962. */
  6963. static readonly MatricesIndicesExtraKind: string;
  6964. /**
  6965. * Additional matrix weights (for bones)
  6966. */
  6967. static readonly MatricesWeightsExtraKind: string;
  6968. /**
  6969. * Deduces the stride given a kind.
  6970. * @param kind The kind string to deduce
  6971. * @returns The deduced stride
  6972. */
  6973. static DeduceStride(kind: string): number;
  6974. /**
  6975. * Gets the byte length of the given type.
  6976. * @param type the type
  6977. * @returns the number of bytes
  6978. */
  6979. static GetTypeByteLength(type: number): number;
  6980. /**
  6981. * Enumerates each value of the given parameters as numbers.
  6982. * @param data the data to enumerate
  6983. * @param byteOffset the byte offset of the data
  6984. * @param byteStride the byte stride of the data
  6985. * @param componentCount the number of components per element
  6986. * @param componentType the type of the component
  6987. * @param count the number of values to enumerate
  6988. * @param normalized whether the data is normalized
  6989. * @param callback the callback function called for each value
  6990. */
  6991. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6992. private static _GetFloatValue;
  6993. }
  6994. }
  6995. declare module BABYLON {
  6996. /**
  6997. * @hidden
  6998. */
  6999. export class IntersectionInfo {
  7000. bu: Nullable<number>;
  7001. bv: Nullable<number>;
  7002. distance: number;
  7003. faceId: number;
  7004. subMeshId: number;
  7005. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7006. }
  7007. }
  7008. declare module BABYLON {
  7009. /**
  7010. * Class used to store bounding sphere information
  7011. */
  7012. export class BoundingSphere {
  7013. /**
  7014. * Gets the center of the bounding sphere in local space
  7015. */
  7016. readonly center: Vector3;
  7017. /**
  7018. * Radius of the bounding sphere in local space
  7019. */
  7020. radius: number;
  7021. /**
  7022. * Gets the center of the bounding sphere in world space
  7023. */
  7024. readonly centerWorld: Vector3;
  7025. /**
  7026. * Radius of the bounding sphere in world space
  7027. */
  7028. radiusWorld: number;
  7029. /**
  7030. * Gets the minimum vector in local space
  7031. */
  7032. readonly minimum: Vector3;
  7033. /**
  7034. * Gets the maximum vector in local space
  7035. */
  7036. readonly maximum: Vector3;
  7037. private _worldMatrix;
  7038. private static readonly TmpVector3;
  7039. /**
  7040. * Creates a new bounding sphere
  7041. * @param min defines the minimum vector (in local space)
  7042. * @param max defines the maximum vector (in local space)
  7043. * @param worldMatrix defines the new world matrix
  7044. */
  7045. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7046. /**
  7047. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7048. * @param min defines the new minimum vector (in local space)
  7049. * @param max defines the new maximum vector (in local space)
  7050. * @param worldMatrix defines the new world matrix
  7051. */
  7052. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7053. /**
  7054. * Scale the current bounding sphere by applying a scale factor
  7055. * @param factor defines the scale factor to apply
  7056. * @returns the current bounding box
  7057. */
  7058. scale(factor: number): BoundingSphere;
  7059. /**
  7060. * Gets the world matrix of the bounding box
  7061. * @returns a matrix
  7062. */
  7063. getWorldMatrix(): DeepImmutable<Matrix>;
  7064. /** @hidden */
  7065. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7066. /**
  7067. * Tests if the bounding sphere is intersecting the frustum planes
  7068. * @param frustumPlanes defines the frustum planes to test
  7069. * @returns true if there is an intersection
  7070. */
  7071. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7072. /**
  7073. * Tests if the bounding sphere center is in between the frustum planes.
  7074. * Used for optimistic fast inclusion.
  7075. * @param frustumPlanes defines the frustum planes to test
  7076. * @returns true if the sphere center is in between the frustum planes
  7077. */
  7078. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7079. /**
  7080. * Tests if a point is inside the bounding sphere
  7081. * @param point defines the point to test
  7082. * @returns true if the point is inside the bounding sphere
  7083. */
  7084. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7085. /**
  7086. * Checks if two sphere intersct
  7087. * @param sphere0 sphere 0
  7088. * @param sphere1 sphere 1
  7089. * @returns true if the speres intersect
  7090. */
  7091. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7092. }
  7093. }
  7094. declare module BABYLON {
  7095. /**
  7096. * Class used to store bounding box information
  7097. */
  7098. export class BoundingBox implements ICullable {
  7099. /**
  7100. * Gets the 8 vectors representing the bounding box in local space
  7101. */
  7102. readonly vectors: Vector3[];
  7103. /**
  7104. * Gets the center of the bounding box in local space
  7105. */
  7106. readonly center: Vector3;
  7107. /**
  7108. * Gets the center of the bounding box in world space
  7109. */
  7110. readonly centerWorld: Vector3;
  7111. /**
  7112. * Gets the extend size in local space
  7113. */
  7114. readonly extendSize: Vector3;
  7115. /**
  7116. * Gets the extend size in world space
  7117. */
  7118. readonly extendSizeWorld: Vector3;
  7119. /**
  7120. * Gets the OBB (object bounding box) directions
  7121. */
  7122. readonly directions: Vector3[];
  7123. /**
  7124. * Gets the 8 vectors representing the bounding box in world space
  7125. */
  7126. readonly vectorsWorld: Vector3[];
  7127. /**
  7128. * Gets the minimum vector in world space
  7129. */
  7130. readonly minimumWorld: Vector3;
  7131. /**
  7132. * Gets the maximum vector in world space
  7133. */
  7134. readonly maximumWorld: Vector3;
  7135. /**
  7136. * Gets the minimum vector in local space
  7137. */
  7138. readonly minimum: Vector3;
  7139. /**
  7140. * Gets the maximum vector in local space
  7141. */
  7142. readonly maximum: Vector3;
  7143. private _worldMatrix;
  7144. private static readonly TmpVector3;
  7145. /**
  7146. * @hidden
  7147. */
  7148. _tag: number;
  7149. /**
  7150. * Creates a new bounding box
  7151. * @param min defines the minimum vector (in local space)
  7152. * @param max defines the maximum vector (in local space)
  7153. * @param worldMatrix defines the new world matrix
  7154. */
  7155. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7156. /**
  7157. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7158. * @param min defines the new minimum vector (in local space)
  7159. * @param max defines the new maximum vector (in local space)
  7160. * @param worldMatrix defines the new world matrix
  7161. */
  7162. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7163. /**
  7164. * Scale the current bounding box by applying a scale factor
  7165. * @param factor defines the scale factor to apply
  7166. * @returns the current bounding box
  7167. */
  7168. scale(factor: number): BoundingBox;
  7169. /**
  7170. * Gets the world matrix of the bounding box
  7171. * @returns a matrix
  7172. */
  7173. getWorldMatrix(): DeepImmutable<Matrix>;
  7174. /** @hidden */
  7175. _update(world: DeepImmutable<Matrix>): void;
  7176. /**
  7177. * Tests if the bounding box is intersecting the frustum planes
  7178. * @param frustumPlanes defines the frustum planes to test
  7179. * @returns true if there is an intersection
  7180. */
  7181. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7182. /**
  7183. * Tests if the bounding box is entirely inside the frustum planes
  7184. * @param frustumPlanes defines the frustum planes to test
  7185. * @returns true if there is an inclusion
  7186. */
  7187. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7188. /**
  7189. * Tests if a point is inside the bounding box
  7190. * @param point defines the point to test
  7191. * @returns true if the point is inside the bounding box
  7192. */
  7193. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7194. /**
  7195. * Tests if the bounding box intersects with a bounding sphere
  7196. * @param sphere defines the sphere to test
  7197. * @returns true if there is an intersection
  7198. */
  7199. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7200. /**
  7201. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7202. * @param min defines the min vector to use
  7203. * @param max defines the max vector to use
  7204. * @returns true if there is an intersection
  7205. */
  7206. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7207. /**
  7208. * Tests if two bounding boxes are intersections
  7209. * @param box0 defines the first box to test
  7210. * @param box1 defines the second box to test
  7211. * @returns true if there is an intersection
  7212. */
  7213. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7214. /**
  7215. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7216. * @param minPoint defines the minimum vector of the bounding box
  7217. * @param maxPoint defines the maximum vector of the bounding box
  7218. * @param sphereCenter defines the sphere center
  7219. * @param sphereRadius defines the sphere radius
  7220. * @returns true if there is an intersection
  7221. */
  7222. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7223. /**
  7224. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7225. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7226. * @param frustumPlanes defines the frustum planes to test
  7227. * @return true if there is an inclusion
  7228. */
  7229. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7230. /**
  7231. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7232. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7233. * @param frustumPlanes defines the frustum planes to test
  7234. * @return true if there is an intersection
  7235. */
  7236. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7237. }
  7238. }
  7239. declare module BABYLON {
  7240. /** @hidden */
  7241. export class Collider {
  7242. /** Define if a collision was found */
  7243. collisionFound: boolean;
  7244. /**
  7245. * Define last intersection point in local space
  7246. */
  7247. intersectionPoint: Vector3;
  7248. /**
  7249. * Define last collided mesh
  7250. */
  7251. collidedMesh: Nullable<AbstractMesh>;
  7252. private _collisionPoint;
  7253. private _planeIntersectionPoint;
  7254. private _tempVector;
  7255. private _tempVector2;
  7256. private _tempVector3;
  7257. private _tempVector4;
  7258. private _edge;
  7259. private _baseToVertex;
  7260. private _destinationPoint;
  7261. private _slidePlaneNormal;
  7262. private _displacementVector;
  7263. /** @hidden */
  7264. _radius: Vector3;
  7265. /** @hidden */
  7266. _retry: number;
  7267. private _velocity;
  7268. private _basePoint;
  7269. private _epsilon;
  7270. /** @hidden */
  7271. _velocityWorldLength: number;
  7272. /** @hidden */
  7273. _basePointWorld: Vector3;
  7274. private _velocityWorld;
  7275. private _normalizedVelocity;
  7276. /** @hidden */
  7277. _initialVelocity: Vector3;
  7278. /** @hidden */
  7279. _initialPosition: Vector3;
  7280. private _nearestDistance;
  7281. private _collisionMask;
  7282. get collisionMask(): number;
  7283. set collisionMask(mask: number);
  7284. /**
  7285. * Gets the plane normal used to compute the sliding response (in local space)
  7286. */
  7287. get slidePlaneNormal(): Vector3;
  7288. /** @hidden */
  7289. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7290. /** @hidden */
  7291. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7292. /** @hidden */
  7293. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7294. /** @hidden */
  7295. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7296. /** @hidden */
  7297. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7298. /** @hidden */
  7299. _getResponse(pos: Vector3, vel: Vector3): void;
  7300. }
  7301. }
  7302. declare module BABYLON {
  7303. /**
  7304. * Interface for cullable objects
  7305. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7306. */
  7307. export interface ICullable {
  7308. /**
  7309. * Checks if the object or part of the object is in the frustum
  7310. * @param frustumPlanes Camera near/planes
  7311. * @returns true if the object is in frustum otherwise false
  7312. */
  7313. isInFrustum(frustumPlanes: Plane[]): boolean;
  7314. /**
  7315. * Checks if a cullable object (mesh...) is in the camera frustum
  7316. * Unlike isInFrustum this cheks the full bounding box
  7317. * @param frustumPlanes Camera near/planes
  7318. * @returns true if the object is in frustum otherwise false
  7319. */
  7320. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7321. }
  7322. /**
  7323. * Info for a bounding data of a mesh
  7324. */
  7325. export class BoundingInfo implements ICullable {
  7326. /**
  7327. * Bounding box for the mesh
  7328. */
  7329. readonly boundingBox: BoundingBox;
  7330. /**
  7331. * Bounding sphere for the mesh
  7332. */
  7333. readonly boundingSphere: BoundingSphere;
  7334. private _isLocked;
  7335. private static readonly TmpVector3;
  7336. /**
  7337. * Constructs bounding info
  7338. * @param minimum min vector of the bounding box/sphere
  7339. * @param maximum max vector of the bounding box/sphere
  7340. * @param worldMatrix defines the new world matrix
  7341. */
  7342. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7343. /**
  7344. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7345. * @param min defines the new minimum vector (in local space)
  7346. * @param max defines the new maximum vector (in local space)
  7347. * @param worldMatrix defines the new world matrix
  7348. */
  7349. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7350. /**
  7351. * min vector of the bounding box/sphere
  7352. */
  7353. get minimum(): Vector3;
  7354. /**
  7355. * max vector of the bounding box/sphere
  7356. */
  7357. get maximum(): Vector3;
  7358. /**
  7359. * If the info is locked and won't be updated to avoid perf overhead
  7360. */
  7361. get isLocked(): boolean;
  7362. set isLocked(value: boolean);
  7363. /**
  7364. * Updates the bounding sphere and box
  7365. * @param world world matrix to be used to update
  7366. */
  7367. update(world: DeepImmutable<Matrix>): void;
  7368. /**
  7369. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7370. * @param center New center of the bounding info
  7371. * @param extend New extend of the bounding info
  7372. * @returns the current bounding info
  7373. */
  7374. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7375. /**
  7376. * Scale the current bounding info by applying a scale factor
  7377. * @param factor defines the scale factor to apply
  7378. * @returns the current bounding info
  7379. */
  7380. scale(factor: number): BoundingInfo;
  7381. /**
  7382. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7383. * @param frustumPlanes defines the frustum to test
  7384. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7385. * @returns true if the bounding info is in the frustum planes
  7386. */
  7387. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7388. /**
  7389. * Gets the world distance between the min and max points of the bounding box
  7390. */
  7391. get diagonalLength(): number;
  7392. /**
  7393. * Checks if a cullable object (mesh...) is in the camera frustum
  7394. * Unlike isInFrustum this cheks the full bounding box
  7395. * @param frustumPlanes Camera near/planes
  7396. * @returns true if the object is in frustum otherwise false
  7397. */
  7398. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7399. /** @hidden */
  7400. _checkCollision(collider: Collider): boolean;
  7401. /**
  7402. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7403. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7404. * @param point the point to check intersection with
  7405. * @returns if the point intersects
  7406. */
  7407. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7408. /**
  7409. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7410. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7411. * @param boundingInfo the bounding info to check intersection with
  7412. * @param precise if the intersection should be done using OBB
  7413. * @returns if the bounding info intersects
  7414. */
  7415. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7416. }
  7417. }
  7418. declare module BABYLON {
  7419. /**
  7420. * Extracts minimum and maximum values from a list of indexed positions
  7421. * @param positions defines the positions to use
  7422. * @param indices defines the indices to the positions
  7423. * @param indexStart defines the start index
  7424. * @param indexCount defines the end index
  7425. * @param bias defines bias value to add to the result
  7426. * @return minimum and maximum values
  7427. */
  7428. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7429. minimum: Vector3;
  7430. maximum: Vector3;
  7431. };
  7432. /**
  7433. * Extracts minimum and maximum values from a list of positions
  7434. * @param positions defines the positions to use
  7435. * @param start defines the start index in the positions array
  7436. * @param count defines the number of positions to handle
  7437. * @param bias defines bias value to add to the result
  7438. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7439. * @return minimum and maximum values
  7440. */
  7441. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7442. minimum: Vector3;
  7443. maximum: Vector3;
  7444. };
  7445. }
  7446. declare module BABYLON {
  7447. /**
  7448. * Class used to manipulate GUIDs
  7449. */
  7450. export class GUID {
  7451. /**
  7452. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7453. * Be aware Math.random() could cause collisions, but:
  7454. * "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"
  7455. * @returns a pseudo random id
  7456. */
  7457. static RandomId(): string;
  7458. }
  7459. }
  7460. declare module BABYLON {
  7461. /**
  7462. * Base class of all the textures in babylon.
  7463. * It groups all the common properties the materials, post process, lights... might need
  7464. * in order to make a correct use of the texture.
  7465. */
  7466. export class BaseTexture extends ThinTexture implements IAnimatable {
  7467. /**
  7468. * Default anisotropic filtering level for the application.
  7469. * It is set to 4 as a good tradeoff between perf and quality.
  7470. */
  7471. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7472. /**
  7473. * Gets or sets the unique id of the texture
  7474. */
  7475. uniqueId: number;
  7476. /**
  7477. * Define the name of the texture.
  7478. */
  7479. name: string;
  7480. /**
  7481. * Gets or sets an object used to store user defined information.
  7482. */
  7483. metadata: any;
  7484. /**
  7485. * For internal use only. Please do not use.
  7486. */
  7487. reservedDataStore: any;
  7488. private _hasAlpha;
  7489. /**
  7490. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7491. */
  7492. set hasAlpha(value: boolean);
  7493. get hasAlpha(): boolean;
  7494. /**
  7495. * Defines if the alpha value should be determined via the rgb values.
  7496. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7497. */
  7498. getAlphaFromRGB: boolean;
  7499. /**
  7500. * Intensity or strength of the texture.
  7501. * It is commonly used by materials to fine tune the intensity of the texture
  7502. */
  7503. level: number;
  7504. /**
  7505. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7506. * This is part of the texture as textures usually maps to one uv set.
  7507. */
  7508. coordinatesIndex: number;
  7509. protected _coordinatesMode: number;
  7510. /**
  7511. * How a texture is mapped.
  7512. *
  7513. * | Value | Type | Description |
  7514. * | ----- | ----------------------------------- | ----------- |
  7515. * | 0 | EXPLICIT_MODE | |
  7516. * | 1 | SPHERICAL_MODE | |
  7517. * | 2 | PLANAR_MODE | |
  7518. * | 3 | CUBIC_MODE | |
  7519. * | 4 | PROJECTION_MODE | |
  7520. * | 5 | SKYBOX_MODE | |
  7521. * | 6 | INVCUBIC_MODE | |
  7522. * | 7 | EQUIRECTANGULAR_MODE | |
  7523. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7524. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7525. */
  7526. set coordinatesMode(value: number);
  7527. get coordinatesMode(): number;
  7528. /**
  7529. * | Value | Type | Description |
  7530. * | ----- | ------------------ | ----------- |
  7531. * | 0 | CLAMP_ADDRESSMODE | |
  7532. * | 1 | WRAP_ADDRESSMODE | |
  7533. * | 2 | MIRROR_ADDRESSMODE | |
  7534. */
  7535. get wrapU(): number;
  7536. set wrapU(value: number);
  7537. /**
  7538. * | Value | Type | Description |
  7539. * | ----- | ------------------ | ----------- |
  7540. * | 0 | CLAMP_ADDRESSMODE | |
  7541. * | 1 | WRAP_ADDRESSMODE | |
  7542. * | 2 | MIRROR_ADDRESSMODE | |
  7543. */
  7544. get wrapV(): number;
  7545. set wrapV(value: number);
  7546. /**
  7547. * | Value | Type | Description |
  7548. * | ----- | ------------------ | ----------- |
  7549. * | 0 | CLAMP_ADDRESSMODE | |
  7550. * | 1 | WRAP_ADDRESSMODE | |
  7551. * | 2 | MIRROR_ADDRESSMODE | |
  7552. */
  7553. wrapR: number;
  7554. /**
  7555. * With compliant hardware and browser (supporting anisotropic filtering)
  7556. * this defines the level of anisotropic filtering in the texture.
  7557. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7558. */
  7559. anisotropicFilteringLevel: number;
  7560. private _isCube;
  7561. /**
  7562. * Define if the texture is a cube texture or if false a 2d texture.
  7563. */
  7564. get isCube(): boolean;
  7565. set isCube(value: boolean);
  7566. /**
  7567. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7568. */
  7569. get is3D(): boolean;
  7570. set is3D(value: boolean);
  7571. /**
  7572. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7573. */
  7574. get is2DArray(): boolean;
  7575. set is2DArray(value: boolean);
  7576. private _gammaSpace;
  7577. /**
  7578. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7579. * HDR texture are usually stored in linear space.
  7580. * This only impacts the PBR and Background materials
  7581. */
  7582. get gammaSpace(): boolean;
  7583. set gammaSpace(gamma: boolean);
  7584. /**
  7585. * Gets or sets whether or not the texture contains RGBD data.
  7586. */
  7587. get isRGBD(): boolean;
  7588. set isRGBD(value: boolean);
  7589. /**
  7590. * Is Z inverted in the texture (useful in a cube texture).
  7591. */
  7592. invertZ: boolean;
  7593. /**
  7594. * Are mip maps generated for this texture or not.
  7595. */
  7596. get noMipmap(): boolean;
  7597. /**
  7598. * @hidden
  7599. */
  7600. lodLevelInAlpha: boolean;
  7601. /**
  7602. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7603. */
  7604. get lodGenerationOffset(): number;
  7605. set lodGenerationOffset(value: number);
  7606. /**
  7607. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7608. */
  7609. get lodGenerationScale(): number;
  7610. set lodGenerationScale(value: number);
  7611. /**
  7612. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7613. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7614. * average roughness values.
  7615. */
  7616. get linearSpecularLOD(): boolean;
  7617. set linearSpecularLOD(value: boolean);
  7618. /**
  7619. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7620. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7621. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7622. */
  7623. get irradianceTexture(): Nullable<BaseTexture>;
  7624. set irradianceTexture(value: Nullable<BaseTexture>);
  7625. /**
  7626. * Define if the texture is a render target.
  7627. */
  7628. isRenderTarget: boolean;
  7629. /**
  7630. * Define the unique id of the texture in the scene.
  7631. */
  7632. get uid(): string;
  7633. /** @hidden */
  7634. _prefiltered: boolean;
  7635. /**
  7636. * Return a string representation of the texture.
  7637. * @returns the texture as a string
  7638. */
  7639. toString(): string;
  7640. /**
  7641. * Get the class name of the texture.
  7642. * @returns "BaseTexture"
  7643. */
  7644. getClassName(): string;
  7645. /**
  7646. * Define the list of animation attached to the texture.
  7647. */
  7648. animations: Animation[];
  7649. /**
  7650. * An event triggered when the texture is disposed.
  7651. */
  7652. onDisposeObservable: Observable<BaseTexture>;
  7653. private _onDisposeObserver;
  7654. /**
  7655. * Callback triggered when the texture has been disposed.
  7656. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7657. */
  7658. set onDispose(callback: () => void);
  7659. protected _scene: Nullable<Scene>;
  7660. /** @hidden */
  7661. _texture: Nullable<InternalTexture>;
  7662. private _uid;
  7663. /**
  7664. * Define if the texture is preventinga material to render or not.
  7665. * If not and the texture is not ready, the engine will use a default black texture instead.
  7666. */
  7667. get isBlocking(): boolean;
  7668. /**
  7669. * Instantiates a new BaseTexture.
  7670. * Base class of all the textures in babylon.
  7671. * It groups all the common properties the materials, post process, lights... might need
  7672. * in order to make a correct use of the texture.
  7673. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7674. */
  7675. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7676. /**
  7677. * Get the scene the texture belongs to.
  7678. * @returns the scene or null if undefined
  7679. */
  7680. getScene(): Nullable<Scene>;
  7681. /** @hidden */
  7682. protected _getEngine(): Nullable<ThinEngine>;
  7683. /**
  7684. * Checks if the texture has the same transform matrix than another texture
  7685. * @param texture texture to check against
  7686. * @returns true if the transforms are the same, else false
  7687. */
  7688. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7689. /**
  7690. * Get the texture transform matrix used to offset tile the texture for istance.
  7691. * @returns the transformation matrix
  7692. */
  7693. getTextureMatrix(): Matrix;
  7694. /**
  7695. * Get the texture reflection matrix used to rotate/transform the reflection.
  7696. * @returns the reflection matrix
  7697. */
  7698. getReflectionTextureMatrix(): Matrix;
  7699. /**
  7700. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7701. * @returns true if ready or not blocking
  7702. */
  7703. isReadyOrNotBlocking(): boolean;
  7704. /**
  7705. * Scales the texture if is `canRescale()`
  7706. * @param ratio the resize factor we want to use to rescale
  7707. */
  7708. scale(ratio: number): void;
  7709. /**
  7710. * Get if the texture can rescale.
  7711. */
  7712. get canRescale(): boolean;
  7713. /** @hidden */
  7714. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7715. /** @hidden */
  7716. _rebuild(): void;
  7717. /**
  7718. * Clones the texture.
  7719. * @returns the cloned texture
  7720. */
  7721. clone(): Nullable<BaseTexture>;
  7722. /**
  7723. * Get the texture underlying type (INT, FLOAT...)
  7724. */
  7725. get textureType(): number;
  7726. /**
  7727. * Get the texture underlying format (RGB, RGBA...)
  7728. */
  7729. get textureFormat(): number;
  7730. /**
  7731. * Indicates that textures need to be re-calculated for all materials
  7732. */
  7733. protected _markAllSubMeshesAsTexturesDirty(): void;
  7734. /**
  7735. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7736. * This will returns an RGBA array buffer containing either in values (0-255) or
  7737. * float values (0-1) depending of the underlying buffer type.
  7738. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7739. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7740. * @param buffer defines a user defined buffer to fill with data (can be null)
  7741. * @returns The Array buffer containing the pixels data.
  7742. */
  7743. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  7744. /** @hidden */
  7745. get _lodTextureHigh(): Nullable<BaseTexture>;
  7746. /** @hidden */
  7747. get _lodTextureMid(): Nullable<BaseTexture>;
  7748. /** @hidden */
  7749. get _lodTextureLow(): Nullable<BaseTexture>;
  7750. /**
  7751. * Dispose the texture and release its associated resources.
  7752. */
  7753. dispose(): void;
  7754. /**
  7755. * Serialize the texture into a JSON representation that can be parsed later on.
  7756. * @returns the JSON representation of the texture
  7757. */
  7758. serialize(): any;
  7759. /**
  7760. * Helper function to be called back once a list of texture contains only ready textures.
  7761. * @param textures Define the list of textures to wait for
  7762. * @param callback Define the callback triggered once the entire list will be ready
  7763. */
  7764. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  7765. private static _isScene;
  7766. }
  7767. }
  7768. declare module BABYLON {
  7769. /** @hidden */
  7770. export class WebGLDataBuffer extends DataBuffer {
  7771. private _buffer;
  7772. constructor(resource: WebGLBuffer);
  7773. get underlyingResource(): any;
  7774. }
  7775. }
  7776. declare module BABYLON {
  7777. /** @hidden */
  7778. export class WebGLPipelineContext implements IPipelineContext {
  7779. engine: ThinEngine;
  7780. program: Nullable<WebGLProgram>;
  7781. context?: WebGLRenderingContext;
  7782. vertexShader?: WebGLShader;
  7783. fragmentShader?: WebGLShader;
  7784. isParallelCompiled: boolean;
  7785. onCompiled?: () => void;
  7786. transformFeedback?: WebGLTransformFeedback | null;
  7787. vertexCompilationError: Nullable<string>;
  7788. fragmentCompilationError: Nullable<string>;
  7789. programLinkError: Nullable<string>;
  7790. programValidationError: Nullable<string>;
  7791. get isAsync(): boolean;
  7792. get isReady(): boolean;
  7793. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7794. _getVertexShaderCode(): string | null;
  7795. _getFragmentShaderCode(): string | null;
  7796. }
  7797. }
  7798. declare module BABYLON {
  7799. interface ThinEngine {
  7800. /**
  7801. * Create an uniform buffer
  7802. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7803. * @param elements defines the content of the uniform buffer
  7804. * @returns the webGL uniform buffer
  7805. */
  7806. createUniformBuffer(elements: FloatArray): DataBuffer;
  7807. /**
  7808. * Create a dynamic uniform buffer
  7809. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7810. * @param elements defines the content of the uniform buffer
  7811. * @returns the webGL uniform buffer
  7812. */
  7813. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7814. /**
  7815. * Update an existing uniform buffer
  7816. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7817. * @param uniformBuffer defines the target uniform buffer
  7818. * @param elements defines the content to update
  7819. * @param offset defines the offset in the uniform buffer where update should start
  7820. * @param count defines the size of the data to update
  7821. */
  7822. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7823. /**
  7824. * Bind an uniform buffer to the current webGL context
  7825. * @param buffer defines the buffer to bind
  7826. */
  7827. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7828. /**
  7829. * Bind a buffer to the current webGL context at a given location
  7830. * @param buffer defines the buffer to bind
  7831. * @param location defines the index where to bind the buffer
  7832. */
  7833. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7834. /**
  7835. * Bind a specific block at a given index in a specific shader program
  7836. * @param pipelineContext defines the pipeline context to use
  7837. * @param blockName defines the block name
  7838. * @param index defines the index where to bind the block
  7839. */
  7840. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7841. }
  7842. }
  7843. declare module BABYLON {
  7844. /**
  7845. * Uniform buffer objects.
  7846. *
  7847. * Handles blocks of uniform on the GPU.
  7848. *
  7849. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7850. *
  7851. * For more information, please refer to :
  7852. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7853. */
  7854. export class UniformBuffer {
  7855. private _engine;
  7856. private _buffer;
  7857. private _data;
  7858. private _bufferData;
  7859. private _dynamic?;
  7860. private _uniformLocations;
  7861. private _uniformSizes;
  7862. private _uniformLocationPointer;
  7863. private _needSync;
  7864. private _noUBO;
  7865. private _currentEffect;
  7866. /** @hidden */
  7867. _alreadyBound: boolean;
  7868. private static _MAX_UNIFORM_SIZE;
  7869. private static _tempBuffer;
  7870. /**
  7871. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7872. * This is dynamic to allow compat with webgl 1 and 2.
  7873. * You will need to pass the name of the uniform as well as the value.
  7874. */
  7875. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7876. /**
  7877. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7878. * This is dynamic to allow compat with webgl 1 and 2.
  7879. * You will need to pass the name of the uniform as well as the value.
  7880. */
  7881. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7882. /**
  7883. * Lambda to Update a single float in a uniform buffer.
  7884. * This is dynamic to allow compat with webgl 1 and 2.
  7885. * You will need to pass the name of the uniform as well as the value.
  7886. */
  7887. updateFloat: (name: string, x: number) => void;
  7888. /**
  7889. * Lambda to Update a vec2 of float in a uniform buffer.
  7890. * This is dynamic to allow compat with webgl 1 and 2.
  7891. * You will need to pass the name of the uniform as well as the value.
  7892. */
  7893. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7894. /**
  7895. * Lambda to Update a vec3 of float in a uniform buffer.
  7896. * This is dynamic to allow compat with webgl 1 and 2.
  7897. * You will need to pass the name of the uniform as well as the value.
  7898. */
  7899. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7900. /**
  7901. * Lambda to Update a vec4 of float in a uniform buffer.
  7902. * This is dynamic to allow compat with webgl 1 and 2.
  7903. * You will need to pass the name of the uniform as well as the value.
  7904. */
  7905. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7906. /**
  7907. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7908. * This is dynamic to allow compat with webgl 1 and 2.
  7909. * You will need to pass the name of the uniform as well as the value.
  7910. */
  7911. updateMatrix: (name: string, mat: Matrix) => void;
  7912. /**
  7913. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7914. * This is dynamic to allow compat with webgl 1 and 2.
  7915. * You will need to pass the name of the uniform as well as the value.
  7916. */
  7917. updateVector3: (name: string, vector: Vector3) => void;
  7918. /**
  7919. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7920. * This is dynamic to allow compat with webgl 1 and 2.
  7921. * You will need to pass the name of the uniform as well as the value.
  7922. */
  7923. updateVector4: (name: string, vector: Vector4) => void;
  7924. /**
  7925. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7926. * This is dynamic to allow compat with webgl 1 and 2.
  7927. * You will need to pass the name of the uniform as well as the value.
  7928. */
  7929. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7930. /**
  7931. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7932. * This is dynamic to allow compat with webgl 1 and 2.
  7933. * You will need to pass the name of the uniform as well as the value.
  7934. */
  7935. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7936. /**
  7937. * Instantiates a new Uniform buffer objects.
  7938. *
  7939. * Handles blocks of uniform on the GPU.
  7940. *
  7941. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7942. *
  7943. * For more information, please refer to :
  7944. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7945. * @param engine Define the engine the buffer is associated with
  7946. * @param data Define the data contained in the buffer
  7947. * @param dynamic Define if the buffer is updatable
  7948. */
  7949. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7950. /**
  7951. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7952. * or just falling back on setUniformXXX calls.
  7953. */
  7954. get useUbo(): boolean;
  7955. /**
  7956. * Indicates if the WebGL underlying uniform buffer is in sync
  7957. * with the javascript cache data.
  7958. */
  7959. get isSync(): boolean;
  7960. /**
  7961. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7962. * Also, a dynamic UniformBuffer will disable cache verification and always
  7963. * update the underlying WebGL uniform buffer to the GPU.
  7964. * @returns if Dynamic, otherwise false
  7965. */
  7966. isDynamic(): boolean;
  7967. /**
  7968. * The data cache on JS side.
  7969. * @returns the underlying data as a float array
  7970. */
  7971. getData(): Float32Array;
  7972. /**
  7973. * The underlying WebGL Uniform buffer.
  7974. * @returns the webgl buffer
  7975. */
  7976. getBuffer(): Nullable<DataBuffer>;
  7977. /**
  7978. * std140 layout specifies how to align data within an UBO structure.
  7979. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7980. * for specs.
  7981. */
  7982. private _fillAlignment;
  7983. /**
  7984. * Adds an uniform in the buffer.
  7985. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7986. * for the layout to be correct !
  7987. * @param name Name of the uniform, as used in the uniform block in the shader.
  7988. * @param size Data size, or data directly.
  7989. */
  7990. addUniform(name: string, size: number | number[]): void;
  7991. /**
  7992. * Adds a Matrix 4x4 to the uniform buffer.
  7993. * @param name Name of the uniform, as used in the uniform block in the shader.
  7994. * @param mat A 4x4 matrix.
  7995. */
  7996. addMatrix(name: string, mat: Matrix): void;
  7997. /**
  7998. * Adds a vec2 to the uniform buffer.
  7999. * @param name Name of the uniform, as used in the uniform block in the shader.
  8000. * @param x Define the x component value of the vec2
  8001. * @param y Define the y component value of the vec2
  8002. */
  8003. addFloat2(name: string, x: number, y: number): void;
  8004. /**
  8005. * Adds a vec3 to the uniform buffer.
  8006. * @param name Name of the uniform, as used in the uniform block in the shader.
  8007. * @param x Define the x component value of the vec3
  8008. * @param y Define the y component value of the vec3
  8009. * @param z Define the z component value of the vec3
  8010. */
  8011. addFloat3(name: string, x: number, y: number, z: number): void;
  8012. /**
  8013. * Adds a vec3 to the uniform buffer.
  8014. * @param name Name of the uniform, as used in the uniform block in the shader.
  8015. * @param color Define the vec3 from a Color
  8016. */
  8017. addColor3(name: string, color: Color3): void;
  8018. /**
  8019. * Adds a vec4 to the uniform buffer.
  8020. * @param name Name of the uniform, as used in the uniform block in the shader.
  8021. * @param color Define the rgb components from a Color
  8022. * @param alpha Define the a component of the vec4
  8023. */
  8024. addColor4(name: string, color: Color3, alpha: number): void;
  8025. /**
  8026. * Adds a vec3 to the uniform buffer.
  8027. * @param name Name of the uniform, as used in the uniform block in the shader.
  8028. * @param vector Define the vec3 components from a Vector
  8029. */
  8030. addVector3(name: string, vector: Vector3): void;
  8031. /**
  8032. * Adds a Matrix 3x3 to the uniform buffer.
  8033. * @param name Name of the uniform, as used in the uniform block in the shader.
  8034. */
  8035. addMatrix3x3(name: string): void;
  8036. /**
  8037. * Adds a Matrix 2x2 to the uniform buffer.
  8038. * @param name Name of the uniform, as used in the uniform block in the shader.
  8039. */
  8040. addMatrix2x2(name: string): void;
  8041. /**
  8042. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8043. */
  8044. create(): void;
  8045. /** @hidden */
  8046. _rebuild(): void;
  8047. /**
  8048. * Updates the WebGL Uniform Buffer on the GPU.
  8049. * If the `dynamic` flag is set to true, no cache comparison is done.
  8050. * Otherwise, the buffer will be updated only if the cache differs.
  8051. */
  8052. update(): void;
  8053. /**
  8054. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8055. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8056. * @param data Define the flattened data
  8057. * @param size Define the size of the data.
  8058. */
  8059. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8060. private _valueCache;
  8061. private _cacheMatrix;
  8062. private _updateMatrix3x3ForUniform;
  8063. private _updateMatrix3x3ForEffect;
  8064. private _updateMatrix2x2ForEffect;
  8065. private _updateMatrix2x2ForUniform;
  8066. private _updateFloatForEffect;
  8067. private _updateFloatForUniform;
  8068. private _updateFloat2ForEffect;
  8069. private _updateFloat2ForUniform;
  8070. private _updateFloat3ForEffect;
  8071. private _updateFloat3ForUniform;
  8072. private _updateFloat4ForEffect;
  8073. private _updateFloat4ForUniform;
  8074. private _updateMatrixForEffect;
  8075. private _updateMatrixForUniform;
  8076. private _updateVector3ForEffect;
  8077. private _updateVector3ForUniform;
  8078. private _updateVector4ForEffect;
  8079. private _updateVector4ForUniform;
  8080. private _updateColor3ForEffect;
  8081. private _updateColor3ForUniform;
  8082. private _updateColor4ForEffect;
  8083. private _updateColor4ForUniform;
  8084. /**
  8085. * Sets a sampler uniform on the effect.
  8086. * @param name Define the name of the sampler.
  8087. * @param texture Define the texture to set in the sampler
  8088. */
  8089. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8090. /**
  8091. * Directly updates the value of the uniform in the cache AND on the GPU.
  8092. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8093. * @param data Define the flattened data
  8094. */
  8095. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8096. /**
  8097. * Binds this uniform buffer to an effect.
  8098. * @param effect Define the effect to bind the buffer to
  8099. * @param name Name of the uniform block in the shader.
  8100. */
  8101. bindToEffect(effect: Effect, name: string): void;
  8102. /**
  8103. * Disposes the uniform buffer.
  8104. */
  8105. dispose(): void;
  8106. }
  8107. }
  8108. declare module BABYLON {
  8109. /**
  8110. * Manages the defines for the Material
  8111. */
  8112. export class MaterialDefines {
  8113. /** @hidden */
  8114. protected _keys: string[];
  8115. private _isDirty;
  8116. /** @hidden */
  8117. _renderId: number;
  8118. /** @hidden */
  8119. _areLightsDirty: boolean;
  8120. /** @hidden */
  8121. _areLightsDisposed: boolean;
  8122. /** @hidden */
  8123. _areAttributesDirty: boolean;
  8124. /** @hidden */
  8125. _areTexturesDirty: boolean;
  8126. /** @hidden */
  8127. _areFresnelDirty: boolean;
  8128. /** @hidden */
  8129. _areMiscDirty: boolean;
  8130. /** @hidden */
  8131. _arePrePassDirty: boolean;
  8132. /** @hidden */
  8133. _areImageProcessingDirty: boolean;
  8134. /** @hidden */
  8135. _normals: boolean;
  8136. /** @hidden */
  8137. _uvs: boolean;
  8138. /** @hidden */
  8139. _needNormals: boolean;
  8140. /** @hidden */
  8141. _needUVs: boolean;
  8142. [id: string]: any;
  8143. /**
  8144. * Specifies if the material needs to be re-calculated
  8145. */
  8146. get isDirty(): boolean;
  8147. /**
  8148. * Marks the material to indicate that it has been re-calculated
  8149. */
  8150. markAsProcessed(): void;
  8151. /**
  8152. * Marks the material to indicate that it needs to be re-calculated
  8153. */
  8154. markAsUnprocessed(): void;
  8155. /**
  8156. * Marks the material to indicate all of its defines need to be re-calculated
  8157. */
  8158. markAllAsDirty(): void;
  8159. /**
  8160. * Marks the material to indicate that image processing needs to be re-calculated
  8161. */
  8162. markAsImageProcessingDirty(): void;
  8163. /**
  8164. * Marks the material to indicate the lights need to be re-calculated
  8165. * @param disposed Defines whether the light is dirty due to dispose or not
  8166. */
  8167. markAsLightDirty(disposed?: boolean): void;
  8168. /**
  8169. * Marks the attribute state as changed
  8170. */
  8171. markAsAttributesDirty(): void;
  8172. /**
  8173. * Marks the texture state as changed
  8174. */
  8175. markAsTexturesDirty(): void;
  8176. /**
  8177. * Marks the fresnel state as changed
  8178. */
  8179. markAsFresnelDirty(): void;
  8180. /**
  8181. * Marks the misc state as changed
  8182. */
  8183. markAsMiscDirty(): void;
  8184. /**
  8185. * Marks the prepass state as changed
  8186. */
  8187. markAsPrePassDirty(): void;
  8188. /**
  8189. * Rebuilds the material defines
  8190. */
  8191. rebuild(): void;
  8192. /**
  8193. * Specifies if two material defines are equal
  8194. * @param other - A material define instance to compare to
  8195. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8196. */
  8197. isEqual(other: MaterialDefines): boolean;
  8198. /**
  8199. * Clones this instance's defines to another instance
  8200. * @param other - material defines to clone values to
  8201. */
  8202. cloneTo(other: MaterialDefines): void;
  8203. /**
  8204. * Resets the material define values
  8205. */
  8206. reset(): void;
  8207. /**
  8208. * Converts the material define values to a string
  8209. * @returns - String of material define information
  8210. */
  8211. toString(): string;
  8212. }
  8213. }
  8214. declare module BABYLON {
  8215. /**
  8216. * Enum that determines the text-wrapping mode to use.
  8217. */
  8218. export enum InspectableType {
  8219. /**
  8220. * Checkbox for booleans
  8221. */
  8222. Checkbox = 0,
  8223. /**
  8224. * Sliders for numbers
  8225. */
  8226. Slider = 1,
  8227. /**
  8228. * Vector3
  8229. */
  8230. Vector3 = 2,
  8231. /**
  8232. * Quaternions
  8233. */
  8234. Quaternion = 3,
  8235. /**
  8236. * Color3
  8237. */
  8238. Color3 = 4,
  8239. /**
  8240. * String
  8241. */
  8242. String = 5
  8243. }
  8244. /**
  8245. * Interface used to define custom inspectable properties.
  8246. * This interface is used by the inspector to display custom property grids
  8247. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8248. */
  8249. export interface IInspectable {
  8250. /**
  8251. * Gets the label to display
  8252. */
  8253. label: string;
  8254. /**
  8255. * Gets the name of the property to edit
  8256. */
  8257. propertyName: string;
  8258. /**
  8259. * Gets the type of the editor to use
  8260. */
  8261. type: InspectableType;
  8262. /**
  8263. * Gets the minimum value of the property when using in "slider" mode
  8264. */
  8265. min?: number;
  8266. /**
  8267. * Gets the maximum value of the property when using in "slider" mode
  8268. */
  8269. max?: number;
  8270. /**
  8271. * Gets the setp to use when using in "slider" mode
  8272. */
  8273. step?: number;
  8274. }
  8275. }
  8276. declare module BABYLON {
  8277. /**
  8278. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8279. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8280. * 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.
  8281. */
  8282. export abstract class Light extends Node {
  8283. /**
  8284. * Falloff Default: light is falling off following the material specification:
  8285. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8286. */
  8287. static readonly FALLOFF_DEFAULT: number;
  8288. /**
  8289. * Falloff Physical: light is falling off following the inverse squared distance law.
  8290. */
  8291. static readonly FALLOFF_PHYSICAL: number;
  8292. /**
  8293. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8294. * to enhance interoperability with other engines.
  8295. */
  8296. static readonly FALLOFF_GLTF: number;
  8297. /**
  8298. * Falloff Standard: light is falling off like in the standard material
  8299. * to enhance interoperability with other materials.
  8300. */
  8301. static readonly FALLOFF_STANDARD: number;
  8302. /**
  8303. * If every light affecting the material is in this lightmapMode,
  8304. * material.lightmapTexture adds or multiplies
  8305. * (depends on material.useLightmapAsShadowmap)
  8306. * after every other light calculations.
  8307. */
  8308. static readonly LIGHTMAP_DEFAULT: number;
  8309. /**
  8310. * material.lightmapTexture as only diffuse lighting from this light
  8311. * adds only specular lighting from this light
  8312. * adds dynamic shadows
  8313. */
  8314. static readonly LIGHTMAP_SPECULAR: number;
  8315. /**
  8316. * material.lightmapTexture as only lighting
  8317. * no light calculation from this light
  8318. * only adds dynamic shadows from this light
  8319. */
  8320. static readonly LIGHTMAP_SHADOWSONLY: number;
  8321. /**
  8322. * Each light type uses the default quantity according to its type:
  8323. * point/spot lights use luminous intensity
  8324. * directional lights use illuminance
  8325. */
  8326. static readonly INTENSITYMODE_AUTOMATIC: number;
  8327. /**
  8328. * lumen (lm)
  8329. */
  8330. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8331. /**
  8332. * candela (lm/sr)
  8333. */
  8334. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8335. /**
  8336. * lux (lm/m^2)
  8337. */
  8338. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8339. /**
  8340. * nit (cd/m^2)
  8341. */
  8342. static readonly INTENSITYMODE_LUMINANCE: number;
  8343. /**
  8344. * Light type const id of the point light.
  8345. */
  8346. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8347. /**
  8348. * Light type const id of the directional light.
  8349. */
  8350. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8351. /**
  8352. * Light type const id of the spot light.
  8353. */
  8354. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8355. /**
  8356. * Light type const id of the hemispheric light.
  8357. */
  8358. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8359. /**
  8360. * Diffuse gives the basic color to an object.
  8361. */
  8362. diffuse: Color3;
  8363. /**
  8364. * Specular produces a highlight color on an object.
  8365. * Note: This is note affecting PBR materials.
  8366. */
  8367. specular: Color3;
  8368. /**
  8369. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8370. * falling off base on range or angle.
  8371. * This can be set to any values in Light.FALLOFF_x.
  8372. *
  8373. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8374. * other types of materials.
  8375. */
  8376. falloffType: number;
  8377. /**
  8378. * Strength of the light.
  8379. * Note: By default it is define in the framework own unit.
  8380. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8381. */
  8382. intensity: number;
  8383. private _range;
  8384. protected _inverseSquaredRange: number;
  8385. /**
  8386. * Defines how far from the source the light is impacting in scene units.
  8387. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8388. */
  8389. get range(): number;
  8390. /**
  8391. * Defines how far from the source the light is impacting in scene units.
  8392. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8393. */
  8394. set range(value: number);
  8395. /**
  8396. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8397. * of light.
  8398. */
  8399. private _photometricScale;
  8400. private _intensityMode;
  8401. /**
  8402. * Gets the photometric scale used to interpret the intensity.
  8403. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8404. */
  8405. get intensityMode(): number;
  8406. /**
  8407. * Sets the photometric scale used to interpret the intensity.
  8408. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8409. */
  8410. set intensityMode(value: number);
  8411. private _radius;
  8412. /**
  8413. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8414. */
  8415. get radius(): number;
  8416. /**
  8417. * sets the light radius used by PBR Materials to simulate soft area lights.
  8418. */
  8419. set radius(value: number);
  8420. private _renderPriority;
  8421. /**
  8422. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8423. * exceeding the number allowed of the materials.
  8424. */
  8425. renderPriority: number;
  8426. private _shadowEnabled;
  8427. /**
  8428. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8429. * the current shadow generator.
  8430. */
  8431. get shadowEnabled(): boolean;
  8432. /**
  8433. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8434. * the current shadow generator.
  8435. */
  8436. set shadowEnabled(value: boolean);
  8437. private _includedOnlyMeshes;
  8438. /**
  8439. * Gets the only meshes impacted by this light.
  8440. */
  8441. get includedOnlyMeshes(): AbstractMesh[];
  8442. /**
  8443. * Sets the only meshes impacted by this light.
  8444. */
  8445. set includedOnlyMeshes(value: AbstractMesh[]);
  8446. private _excludedMeshes;
  8447. /**
  8448. * Gets the meshes not impacted by this light.
  8449. */
  8450. get excludedMeshes(): AbstractMesh[];
  8451. /**
  8452. * Sets the meshes not impacted by this light.
  8453. */
  8454. set excludedMeshes(value: AbstractMesh[]);
  8455. private _excludeWithLayerMask;
  8456. /**
  8457. * Gets the layer id use to find what meshes are not impacted by the light.
  8458. * Inactive if 0
  8459. */
  8460. get excludeWithLayerMask(): number;
  8461. /**
  8462. * Sets the layer id use to find what meshes are not impacted by the light.
  8463. * Inactive if 0
  8464. */
  8465. set excludeWithLayerMask(value: number);
  8466. private _includeOnlyWithLayerMask;
  8467. /**
  8468. * Gets the layer id use to find what meshes are impacted by the light.
  8469. * Inactive if 0
  8470. */
  8471. get includeOnlyWithLayerMask(): number;
  8472. /**
  8473. * Sets the layer id use to find what meshes are impacted by the light.
  8474. * Inactive if 0
  8475. */
  8476. set includeOnlyWithLayerMask(value: number);
  8477. private _lightmapMode;
  8478. /**
  8479. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8480. */
  8481. get lightmapMode(): number;
  8482. /**
  8483. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8484. */
  8485. set lightmapMode(value: number);
  8486. /**
  8487. * Shadow generator associted to the light.
  8488. * @hidden Internal use only.
  8489. */
  8490. _shadowGenerator: Nullable<IShadowGenerator>;
  8491. /**
  8492. * @hidden Internal use only.
  8493. */
  8494. _excludedMeshesIds: string[];
  8495. /**
  8496. * @hidden Internal use only.
  8497. */
  8498. _includedOnlyMeshesIds: string[];
  8499. /**
  8500. * The current light unifom buffer.
  8501. * @hidden Internal use only.
  8502. */
  8503. _uniformBuffer: UniformBuffer;
  8504. /** @hidden */
  8505. _renderId: number;
  8506. /**
  8507. * Creates a Light object in the scene.
  8508. * Documentation : https://doc.babylonjs.com/babylon101/lights
  8509. * @param name The firendly name of the light
  8510. * @param scene The scene the light belongs too
  8511. */
  8512. constructor(name: string, scene: Scene);
  8513. protected abstract _buildUniformLayout(): void;
  8514. /**
  8515. * Sets the passed Effect "effect" with the Light information.
  8516. * @param effect The effect to update
  8517. * @param lightIndex The index of the light in the effect to update
  8518. * @returns The light
  8519. */
  8520. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8521. /**
  8522. * Sets the passed Effect "effect" with the Light textures.
  8523. * @param effect The effect to update
  8524. * @param lightIndex The index of the light in the effect to update
  8525. * @returns The light
  8526. */
  8527. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  8528. /**
  8529. * Binds the lights information from the scene to the effect for the given mesh.
  8530. * @param lightIndex Light index
  8531. * @param scene The scene where the light belongs to
  8532. * @param effect The effect we are binding the data to
  8533. * @param useSpecular Defines if specular is supported
  8534. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8535. */
  8536. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  8537. /**
  8538. * Sets the passed Effect "effect" with the Light information.
  8539. * @param effect The effect to update
  8540. * @param lightDataUniformName The uniform used to store light data (position or direction)
  8541. * @returns The light
  8542. */
  8543. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  8544. /**
  8545. * Returns the string "Light".
  8546. * @returns the class name
  8547. */
  8548. getClassName(): string;
  8549. /** @hidden */
  8550. readonly _isLight: boolean;
  8551. /**
  8552. * Converts the light information to a readable string for debug purpose.
  8553. * @param fullDetails Supports for multiple levels of logging within scene loading
  8554. * @returns the human readable light info
  8555. */
  8556. toString(fullDetails?: boolean): string;
  8557. /** @hidden */
  8558. protected _syncParentEnabledState(): void;
  8559. /**
  8560. * Set the enabled state of this node.
  8561. * @param value - the new enabled state
  8562. */
  8563. setEnabled(value: boolean): void;
  8564. /**
  8565. * Returns the Light associated shadow generator if any.
  8566. * @return the associated shadow generator.
  8567. */
  8568. getShadowGenerator(): Nullable<IShadowGenerator>;
  8569. /**
  8570. * Returns a Vector3, the absolute light position in the World.
  8571. * @returns the world space position of the light
  8572. */
  8573. getAbsolutePosition(): Vector3;
  8574. /**
  8575. * Specifies if the light will affect the passed mesh.
  8576. * @param mesh The mesh to test against the light
  8577. * @return true the mesh is affected otherwise, false.
  8578. */
  8579. canAffectMesh(mesh: AbstractMesh): boolean;
  8580. /**
  8581. * Sort function to order lights for rendering.
  8582. * @param a First Light object to compare to second.
  8583. * @param b Second Light object to compare first.
  8584. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8585. */
  8586. static CompareLightsPriority(a: Light, b: Light): number;
  8587. /**
  8588. * Releases resources associated with this node.
  8589. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8590. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8591. */
  8592. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8593. /**
  8594. * Returns the light type ID (integer).
  8595. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8596. */
  8597. getTypeID(): number;
  8598. /**
  8599. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8600. * @returns the scaled intensity in intensity mode unit
  8601. */
  8602. getScaledIntensity(): number;
  8603. /**
  8604. * Returns a new Light object, named "name", from the current one.
  8605. * @param name The name of the cloned light
  8606. * @param newParent The parent of this light, if it has one
  8607. * @returns the new created light
  8608. */
  8609. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  8610. /**
  8611. * Serializes the current light into a Serialization object.
  8612. * @returns the serialized object.
  8613. */
  8614. serialize(): any;
  8615. /**
  8616. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8617. * This new light is named "name" and added to the passed scene.
  8618. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8619. * @param name The friendly name of the light
  8620. * @param scene The scene the new light will belong to
  8621. * @returns the constructor function
  8622. */
  8623. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8624. /**
  8625. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8626. * @param parsedLight The JSON representation of the light
  8627. * @param scene The scene to create the parsed light in
  8628. * @returns the created light after parsing
  8629. */
  8630. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8631. private _hookArrayForExcluded;
  8632. private _hookArrayForIncludedOnly;
  8633. private _resyncMeshes;
  8634. /**
  8635. * Forces the meshes to update their light related information in their rendering used effects
  8636. * @hidden Internal Use Only
  8637. */
  8638. _markMeshesAsLightDirty(): void;
  8639. /**
  8640. * Recomputes the cached photometric scale if needed.
  8641. */
  8642. private _computePhotometricScale;
  8643. /**
  8644. * Returns the Photometric Scale according to the light type and intensity mode.
  8645. */
  8646. private _getPhotometricScale;
  8647. /**
  8648. * Reorder the light in the scene according to their defined priority.
  8649. * @hidden Internal Use Only
  8650. */
  8651. _reorderLightsInScene(): void;
  8652. /**
  8653. * Prepares the list of defines specific to the light type.
  8654. * @param defines the list of defines
  8655. * @param lightIndex defines the index of the light for the effect
  8656. */
  8657. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /** Defines supported spaces */
  8662. export enum Space {
  8663. /** Local (object) space */
  8664. LOCAL = 0,
  8665. /** World space */
  8666. WORLD = 1,
  8667. /** Bone space */
  8668. BONE = 2
  8669. }
  8670. /** Defines the 3 main axes */
  8671. export class Axis {
  8672. /** X axis */
  8673. static X: Vector3;
  8674. /** Y axis */
  8675. static Y: Vector3;
  8676. /** Z axis */
  8677. static Z: Vector3;
  8678. }
  8679. /**
  8680. * Defines cartesian components.
  8681. */
  8682. export enum Coordinate {
  8683. /** X axis */
  8684. X = 0,
  8685. /** Y axis */
  8686. Y = 1,
  8687. /** Z axis */
  8688. Z = 2
  8689. }
  8690. }
  8691. declare module BABYLON {
  8692. /**
  8693. * Interface describing all the common properties and methods a shadow light needs to implement.
  8694. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8695. * as well as binding the different shadow properties to the effects.
  8696. */
  8697. export interface IShadowLight extends Light {
  8698. /**
  8699. * The light id in the scene (used in scene.findLighById for instance)
  8700. */
  8701. id: string;
  8702. /**
  8703. * The position the shdow will be casted from.
  8704. */
  8705. position: Vector3;
  8706. /**
  8707. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8708. */
  8709. direction: Vector3;
  8710. /**
  8711. * The transformed position. Position of the light in world space taking parenting in account.
  8712. */
  8713. transformedPosition: Vector3;
  8714. /**
  8715. * The transformed direction. Direction of the light in world space taking parenting in account.
  8716. */
  8717. transformedDirection: Vector3;
  8718. /**
  8719. * The friendly name of the light in the scene.
  8720. */
  8721. name: string;
  8722. /**
  8723. * Defines the shadow projection clipping minimum z value.
  8724. */
  8725. shadowMinZ: number;
  8726. /**
  8727. * Defines the shadow projection clipping maximum z value.
  8728. */
  8729. shadowMaxZ: number;
  8730. /**
  8731. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8732. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8733. */
  8734. computeTransformedInformation(): boolean;
  8735. /**
  8736. * Gets the scene the light belongs to.
  8737. * @returns The scene
  8738. */
  8739. getScene(): Scene;
  8740. /**
  8741. * Callback defining a custom Projection Matrix Builder.
  8742. * This can be used to override the default projection matrix computation.
  8743. */
  8744. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8745. /**
  8746. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8747. * @param matrix The materix to updated with the projection information
  8748. * @param viewMatrix The transform matrix of the light
  8749. * @param renderList The list of mesh to render in the map
  8750. * @returns The current light
  8751. */
  8752. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8753. /**
  8754. * Gets the current depth scale used in ESM.
  8755. * @returns The scale
  8756. */
  8757. getDepthScale(): number;
  8758. /**
  8759. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8760. * @returns true if a cube texture needs to be use
  8761. */
  8762. needCube(): boolean;
  8763. /**
  8764. * Detects if the projection matrix requires to be recomputed this frame.
  8765. * @returns true if it requires to be recomputed otherwise, false.
  8766. */
  8767. needProjectionMatrixCompute(): boolean;
  8768. /**
  8769. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8770. */
  8771. forceProjectionMatrixCompute(): void;
  8772. /**
  8773. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8774. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8775. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8776. */
  8777. getShadowDirection(faceIndex?: number): Vector3;
  8778. /**
  8779. * Gets the minZ used for shadow according to both the scene and the light.
  8780. * @param activeCamera The camera we are returning the min for
  8781. * @returns the depth min z
  8782. */
  8783. getDepthMinZ(activeCamera: Camera): number;
  8784. /**
  8785. * Gets the maxZ used for shadow according to both the scene and the light.
  8786. * @param activeCamera The camera we are returning the max for
  8787. * @returns the depth max z
  8788. */
  8789. getDepthMaxZ(activeCamera: Camera): number;
  8790. }
  8791. /**
  8792. * Base implementation IShadowLight
  8793. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8794. */
  8795. export abstract class ShadowLight extends Light implements IShadowLight {
  8796. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8797. protected _position: Vector3;
  8798. protected _setPosition(value: Vector3): void;
  8799. /**
  8800. * Sets the position the shadow will be casted from. Also use as the light position for both
  8801. * point and spot lights.
  8802. */
  8803. get position(): Vector3;
  8804. /**
  8805. * Sets the position the shadow will be casted from. Also use as the light position for both
  8806. * point and spot lights.
  8807. */
  8808. set position(value: Vector3);
  8809. protected _direction: Vector3;
  8810. protected _setDirection(value: Vector3): void;
  8811. /**
  8812. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8813. * Also use as the light direction on spot and directional lights.
  8814. */
  8815. get direction(): Vector3;
  8816. /**
  8817. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8818. * Also use as the light direction on spot and directional lights.
  8819. */
  8820. set direction(value: Vector3);
  8821. protected _shadowMinZ: number;
  8822. /**
  8823. * Gets the shadow projection clipping minimum z value.
  8824. */
  8825. get shadowMinZ(): number;
  8826. /**
  8827. * Sets the shadow projection clipping minimum z value.
  8828. */
  8829. set shadowMinZ(value: number);
  8830. protected _shadowMaxZ: number;
  8831. /**
  8832. * Sets the shadow projection clipping maximum z value.
  8833. */
  8834. get shadowMaxZ(): number;
  8835. /**
  8836. * Gets the shadow projection clipping maximum z value.
  8837. */
  8838. set shadowMaxZ(value: number);
  8839. /**
  8840. * Callback defining a custom Projection Matrix Builder.
  8841. * This can be used to override the default projection matrix computation.
  8842. */
  8843. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8844. /**
  8845. * The transformed position. Position of the light in world space taking parenting in account.
  8846. */
  8847. transformedPosition: Vector3;
  8848. /**
  8849. * The transformed direction. Direction of the light in world space taking parenting in account.
  8850. */
  8851. transformedDirection: Vector3;
  8852. private _needProjectionMatrixCompute;
  8853. /**
  8854. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8855. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8856. */
  8857. computeTransformedInformation(): boolean;
  8858. /**
  8859. * Return the depth scale used for the shadow map.
  8860. * @returns the depth scale.
  8861. */
  8862. getDepthScale(): number;
  8863. /**
  8864. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8865. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8866. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8867. */
  8868. getShadowDirection(faceIndex?: number): Vector3;
  8869. /**
  8870. * Returns the ShadowLight absolute position in the World.
  8871. * @returns the position vector in world space
  8872. */
  8873. getAbsolutePosition(): Vector3;
  8874. /**
  8875. * Sets the ShadowLight direction toward the passed target.
  8876. * @param target The point to target in local space
  8877. * @returns the updated ShadowLight direction
  8878. */
  8879. setDirectionToTarget(target: Vector3): Vector3;
  8880. /**
  8881. * Returns the light rotation in euler definition.
  8882. * @returns the x y z rotation in local space.
  8883. */
  8884. getRotation(): Vector3;
  8885. /**
  8886. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8887. * @returns true if a cube texture needs to be use
  8888. */
  8889. needCube(): boolean;
  8890. /**
  8891. * Detects if the projection matrix requires to be recomputed this frame.
  8892. * @returns true if it requires to be recomputed otherwise, false.
  8893. */
  8894. needProjectionMatrixCompute(): boolean;
  8895. /**
  8896. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8897. */
  8898. forceProjectionMatrixCompute(): void;
  8899. /** @hidden */
  8900. _initCache(): void;
  8901. /** @hidden */
  8902. _isSynchronized(): boolean;
  8903. /**
  8904. * Computes the world matrix of the node
  8905. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8906. * @returns the world matrix
  8907. */
  8908. computeWorldMatrix(force?: boolean): Matrix;
  8909. /**
  8910. * Gets the minZ used for shadow according to both the scene and the light.
  8911. * @param activeCamera The camera we are returning the min for
  8912. * @returns the depth min z
  8913. */
  8914. getDepthMinZ(activeCamera: Camera): number;
  8915. /**
  8916. * Gets the maxZ used for shadow according to both the scene and the light.
  8917. * @param activeCamera The camera we are returning the max for
  8918. * @returns the depth max z
  8919. */
  8920. getDepthMaxZ(activeCamera: Camera): number;
  8921. /**
  8922. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8923. * @param matrix The materix to updated with the projection information
  8924. * @param viewMatrix The transform matrix of the light
  8925. * @param renderList The list of mesh to render in the map
  8926. * @returns The current light
  8927. */
  8928. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8929. }
  8930. }
  8931. declare module BABYLON {
  8932. /**
  8933. * Configuration needed for prepass-capable materials
  8934. */
  8935. export class PrePassConfiguration {
  8936. /**
  8937. * Previous world matrices of meshes carrying this material
  8938. * Used for computing velocity
  8939. */
  8940. previousWorldMatrices: {
  8941. [index: number]: Matrix;
  8942. };
  8943. /**
  8944. * Previous view project matrix
  8945. * Used for computing velocity
  8946. */
  8947. previousViewProjection: Matrix;
  8948. /**
  8949. * Previous bones of meshes carrying this material
  8950. * Used for computing velocity
  8951. */
  8952. previousBones: {
  8953. [index: number]: Float32Array;
  8954. };
  8955. /**
  8956. * Add the required uniforms to the current list.
  8957. * @param uniforms defines the current uniform list.
  8958. */
  8959. static AddUniforms(uniforms: string[]): void;
  8960. /**
  8961. * Add the required samplers to the current list.
  8962. * @param samplers defines the current sampler list.
  8963. */
  8964. static AddSamplers(samplers: string[]): void;
  8965. /**
  8966. * Binds the material data.
  8967. * @param effect defines the effect to update
  8968. * @param scene defines the scene the material belongs to.
  8969. * @param mesh The mesh
  8970. * @param world World matrix of this mesh
  8971. * @param isFrozen Is the material frozen
  8972. */
  8973. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  8974. }
  8975. }
  8976. declare module BABYLON {
  8977. /**
  8978. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8979. * This is the base of the follow, arc rotate cameras and Free camera
  8980. * @see https://doc.babylonjs.com/features/cameras
  8981. */
  8982. export class TargetCamera extends Camera {
  8983. private static _RigCamTransformMatrix;
  8984. private static _TargetTransformMatrix;
  8985. private static _TargetFocalPoint;
  8986. private _tmpUpVector;
  8987. private _tmpTargetVector;
  8988. /**
  8989. * Define the current direction the camera is moving to
  8990. */
  8991. cameraDirection: Vector3;
  8992. /**
  8993. * Define the current rotation the camera is rotating to
  8994. */
  8995. cameraRotation: Vector2;
  8996. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  8997. ignoreParentScaling: boolean;
  8998. /**
  8999. * When set, the up vector of the camera will be updated by the rotation of the camera
  9000. */
  9001. updateUpVectorFromRotation: boolean;
  9002. private _tmpQuaternion;
  9003. /**
  9004. * Define the current rotation of the camera
  9005. */
  9006. rotation: Vector3;
  9007. /**
  9008. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9009. */
  9010. rotationQuaternion: Quaternion;
  9011. /**
  9012. * Define the current speed of the camera
  9013. */
  9014. speed: number;
  9015. /**
  9016. * Add constraint to the camera to prevent it to move freely in all directions and
  9017. * around all axis.
  9018. */
  9019. noRotationConstraint: boolean;
  9020. /**
  9021. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9022. * panning
  9023. */
  9024. invertRotation: boolean;
  9025. /**
  9026. * Speed multiplier for inverse camera panning
  9027. */
  9028. inverseRotationSpeed: number;
  9029. /**
  9030. * Define the current target of the camera as an object or a position.
  9031. */
  9032. lockedTarget: any;
  9033. /** @hidden */
  9034. _currentTarget: Vector3;
  9035. /** @hidden */
  9036. _initialFocalDistance: number;
  9037. /** @hidden */
  9038. _viewMatrix: Matrix;
  9039. /** @hidden */
  9040. _camMatrix: Matrix;
  9041. /** @hidden */
  9042. _cameraTransformMatrix: Matrix;
  9043. /** @hidden */
  9044. _cameraRotationMatrix: Matrix;
  9045. /** @hidden */
  9046. _referencePoint: Vector3;
  9047. /** @hidden */
  9048. _transformedReferencePoint: Vector3;
  9049. /** @hidden */
  9050. _reset: () => void;
  9051. private _defaultUp;
  9052. /**
  9053. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9054. * This is the base of the follow, arc rotate cameras and Free camera
  9055. * @see https://doc.babylonjs.com/features/cameras
  9056. * @param name Defines the name of the camera in the scene
  9057. * @param position Defines the start position of the camera in the scene
  9058. * @param scene Defines the scene the camera belongs to
  9059. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9060. */
  9061. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9062. /**
  9063. * Gets the position in front of the camera at a given distance.
  9064. * @param distance The distance from the camera we want the position to be
  9065. * @returns the position
  9066. */
  9067. getFrontPosition(distance: number): Vector3;
  9068. /** @hidden */
  9069. _getLockedTargetPosition(): Nullable<Vector3>;
  9070. private _storedPosition;
  9071. private _storedRotation;
  9072. private _storedRotationQuaternion;
  9073. /**
  9074. * Store current camera state of the camera (fov, position, rotation, etc..)
  9075. * @returns the camera
  9076. */
  9077. storeState(): Camera;
  9078. /**
  9079. * Restored camera state. You must call storeState() first
  9080. * @returns whether it was successful or not
  9081. * @hidden
  9082. */
  9083. _restoreStateValues(): boolean;
  9084. /** @hidden */
  9085. _initCache(): void;
  9086. /** @hidden */
  9087. _updateCache(ignoreParentClass?: boolean): void;
  9088. /** @hidden */
  9089. _isSynchronizedViewMatrix(): boolean;
  9090. /** @hidden */
  9091. _computeLocalCameraSpeed(): number;
  9092. /**
  9093. * Defines the target the camera should look at.
  9094. * @param target Defines the new target as a Vector or a mesh
  9095. */
  9096. setTarget(target: Vector3): void;
  9097. /**
  9098. * Defines the target point of the camera.
  9099. * The camera looks towards it form the radius distance.
  9100. */
  9101. get target(): Vector3;
  9102. set target(value: Vector3);
  9103. /**
  9104. * Return the current target position of the camera. This value is expressed in local space.
  9105. * @returns the target position
  9106. */
  9107. getTarget(): Vector3;
  9108. /** @hidden */
  9109. _decideIfNeedsToMove(): boolean;
  9110. /** @hidden */
  9111. _updatePosition(): void;
  9112. /** @hidden */
  9113. _checkInputs(): void;
  9114. protected _updateCameraRotationMatrix(): void;
  9115. /**
  9116. * 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)
  9117. * @returns the current camera
  9118. */
  9119. private _rotateUpVectorWithCameraRotationMatrix;
  9120. private _cachedRotationZ;
  9121. private _cachedQuaternionRotationZ;
  9122. /** @hidden */
  9123. _getViewMatrix(): Matrix;
  9124. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9125. /**
  9126. * @hidden
  9127. */
  9128. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9129. /**
  9130. * @hidden
  9131. */
  9132. _updateRigCameras(): void;
  9133. private _getRigCamPositionAndTarget;
  9134. /**
  9135. * Gets the current object class name.
  9136. * @return the class name
  9137. */
  9138. getClassName(): string;
  9139. }
  9140. }
  9141. declare module BABYLON {
  9142. /**
  9143. * @ignore
  9144. * This is a list of all the different input types that are available in the application.
  9145. * Fo instance: ArcRotateCameraGamepadInput...
  9146. */
  9147. export var CameraInputTypes: {};
  9148. /**
  9149. * This is the contract to implement in order to create a new input class.
  9150. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9151. */
  9152. export interface ICameraInput<TCamera extends Camera> {
  9153. /**
  9154. * Defines the camera the input is attached to.
  9155. */
  9156. camera: Nullable<TCamera>;
  9157. /**
  9158. * Gets the class name of the current intput.
  9159. * @returns the class name
  9160. */
  9161. getClassName(): string;
  9162. /**
  9163. * Get the friendly name associated with the input class.
  9164. * @returns the input friendly name
  9165. */
  9166. getSimpleName(): string;
  9167. /**
  9168. * Attach the input controls to a specific dom element to get the input from.
  9169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9170. */
  9171. attachControl(noPreventDefault?: boolean): void;
  9172. /**
  9173. * Detach the current controls from the specified dom element.
  9174. */
  9175. detachControl(): void;
  9176. /**
  9177. * Update the current camera state depending on the inputs that have been used this frame.
  9178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9179. */
  9180. checkInputs?: () => void;
  9181. }
  9182. /**
  9183. * Represents a map of input types to input instance or input index to input instance.
  9184. */
  9185. export interface CameraInputsMap<TCamera extends Camera> {
  9186. /**
  9187. * Accessor to the input by input type.
  9188. */
  9189. [name: string]: ICameraInput<TCamera>;
  9190. /**
  9191. * Accessor to the input by input index.
  9192. */
  9193. [idx: number]: ICameraInput<TCamera>;
  9194. }
  9195. /**
  9196. * This represents the input manager used within a camera.
  9197. * It helps dealing with all the different kind of input attached to a camera.
  9198. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9199. */
  9200. export class CameraInputsManager<TCamera extends Camera> {
  9201. /**
  9202. * Defines the list of inputs attahed to the camera.
  9203. */
  9204. attached: CameraInputsMap<TCamera>;
  9205. /**
  9206. * Defines the dom element the camera is collecting inputs from.
  9207. * This is null if the controls have not been attached.
  9208. */
  9209. attachedToElement: boolean;
  9210. /**
  9211. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9212. */
  9213. noPreventDefault: boolean;
  9214. /**
  9215. * Defined the camera the input manager belongs to.
  9216. */
  9217. camera: TCamera;
  9218. /**
  9219. * Update the current camera state depending on the inputs that have been used this frame.
  9220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9221. */
  9222. checkInputs: () => void;
  9223. /**
  9224. * Instantiate a new Camera Input Manager.
  9225. * @param camera Defines the camera the input manager blongs to
  9226. */
  9227. constructor(camera: TCamera);
  9228. /**
  9229. * Add an input method to a camera
  9230. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9231. * @param input camera input method
  9232. */
  9233. add(input: ICameraInput<TCamera>): void;
  9234. /**
  9235. * Remove a specific input method from a camera
  9236. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9237. * @param inputToRemove camera input method
  9238. */
  9239. remove(inputToRemove: ICameraInput<TCamera>): void;
  9240. /**
  9241. * Remove a specific input type from a camera
  9242. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9243. * @param inputType the type of the input to remove
  9244. */
  9245. removeByType(inputType: string): void;
  9246. private _addCheckInputs;
  9247. /**
  9248. * Attach the input controls to the currently attached dom element to listen the events from.
  9249. * @param input Defines the input to attach
  9250. */
  9251. attachInput(input: ICameraInput<TCamera>): void;
  9252. /**
  9253. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9254. * @param element Defines the dom element to collect the events from
  9255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9256. */
  9257. attachElement(noPreventDefault?: boolean): void;
  9258. /**
  9259. * Detach the current manager inputs controls from a specific dom element.
  9260. * @param element Defines the dom element to collect the events from
  9261. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9262. */
  9263. detachElement(disconnect?: boolean): void;
  9264. /**
  9265. * Rebuild the dynamic inputCheck function from the current list of
  9266. * defined inputs in the manager.
  9267. */
  9268. rebuildInputCheck(): void;
  9269. /**
  9270. * Remove all attached input methods from a camera
  9271. */
  9272. clear(): void;
  9273. /**
  9274. * Serialize the current input manager attached to a camera.
  9275. * This ensures than once parsed,
  9276. * the input associated to the camera will be identical to the current ones
  9277. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9278. */
  9279. serialize(serializedCamera: any): void;
  9280. /**
  9281. * Parses an input manager serialized JSON to restore the previous list of inputs
  9282. * and states associated to a camera.
  9283. * @param parsedCamera Defines the JSON to parse
  9284. */
  9285. parse(parsedCamera: any): void;
  9286. }
  9287. }
  9288. declare module BABYLON {
  9289. /**
  9290. * Gather the list of keyboard event types as constants.
  9291. */
  9292. export class KeyboardEventTypes {
  9293. /**
  9294. * The keydown event is fired when a key becomes active (pressed).
  9295. */
  9296. static readonly KEYDOWN: number;
  9297. /**
  9298. * The keyup event is fired when a key has been released.
  9299. */
  9300. static readonly KEYUP: number;
  9301. }
  9302. /**
  9303. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9304. */
  9305. export class KeyboardInfo {
  9306. /**
  9307. * Defines the type of event (KeyboardEventTypes)
  9308. */
  9309. type: number;
  9310. /**
  9311. * Defines the related dom event
  9312. */
  9313. event: KeyboardEvent;
  9314. /**
  9315. * Instantiates a new keyboard info.
  9316. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9317. * @param type Defines the type of event (KeyboardEventTypes)
  9318. * @param event Defines the related dom event
  9319. */
  9320. constructor(
  9321. /**
  9322. * Defines the type of event (KeyboardEventTypes)
  9323. */
  9324. type: number,
  9325. /**
  9326. * Defines the related dom event
  9327. */
  9328. event: KeyboardEvent);
  9329. }
  9330. /**
  9331. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9332. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9333. */
  9334. export class KeyboardInfoPre extends KeyboardInfo {
  9335. /**
  9336. * Defines the type of event (KeyboardEventTypes)
  9337. */
  9338. type: number;
  9339. /**
  9340. * Defines the related dom event
  9341. */
  9342. event: KeyboardEvent;
  9343. /**
  9344. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9345. */
  9346. skipOnPointerObservable: boolean;
  9347. /**
  9348. * Instantiates a new keyboard pre info.
  9349. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9350. * @param type Defines the type of event (KeyboardEventTypes)
  9351. * @param event Defines the related dom event
  9352. */
  9353. constructor(
  9354. /**
  9355. * Defines the type of event (KeyboardEventTypes)
  9356. */
  9357. type: number,
  9358. /**
  9359. * Defines the related dom event
  9360. */
  9361. event: KeyboardEvent);
  9362. }
  9363. }
  9364. declare module BABYLON {
  9365. /**
  9366. * Manage the keyboard inputs to control the movement of a free camera.
  9367. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9368. */
  9369. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9370. /**
  9371. * Defines the camera the input is attached to.
  9372. */
  9373. camera: FreeCamera;
  9374. /**
  9375. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9376. */
  9377. keysUp: number[];
  9378. /**
  9379. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9380. */
  9381. keysUpward: number[];
  9382. /**
  9383. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9384. */
  9385. keysDown: number[];
  9386. /**
  9387. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9388. */
  9389. keysDownward: number[];
  9390. /**
  9391. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9392. */
  9393. keysLeft: number[];
  9394. /**
  9395. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9396. */
  9397. keysRight: number[];
  9398. private _keys;
  9399. private _onCanvasBlurObserver;
  9400. private _onKeyboardObserver;
  9401. private _engine;
  9402. private _scene;
  9403. /**
  9404. * Attach the input controls to a specific dom element to get the input from.
  9405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9406. */
  9407. attachControl(noPreventDefault?: boolean): void;
  9408. /**
  9409. * Detach the current controls from the specified dom element.
  9410. */
  9411. detachControl(): void;
  9412. /**
  9413. * Update the current camera state depending on the inputs that have been used this frame.
  9414. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9415. */
  9416. checkInputs(): void;
  9417. /**
  9418. * Gets the class name of the current intput.
  9419. * @returns the class name
  9420. */
  9421. getClassName(): string;
  9422. /** @hidden */
  9423. _onLostFocus(): void;
  9424. /**
  9425. * Get the friendly name associated with the input class.
  9426. * @returns the input friendly name
  9427. */
  9428. getSimpleName(): string;
  9429. }
  9430. }
  9431. declare module BABYLON {
  9432. /**
  9433. * Interface used to define Action
  9434. */
  9435. export interface IAction {
  9436. /**
  9437. * Trigger for the action
  9438. */
  9439. trigger: number;
  9440. /** Options of the trigger */
  9441. triggerOptions: any;
  9442. /**
  9443. * Gets the trigger parameters
  9444. * @returns the trigger parameters
  9445. */
  9446. getTriggerParameter(): any;
  9447. /**
  9448. * Internal only - executes current action event
  9449. * @hidden
  9450. */
  9451. _executeCurrent(evt?: ActionEvent): void;
  9452. /**
  9453. * Serialize placeholder for child classes
  9454. * @param parent of child
  9455. * @returns the serialized object
  9456. */
  9457. serialize(parent: any): any;
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _prepare(): void;
  9463. /**
  9464. * Internal only - manager for action
  9465. * @hidden
  9466. */
  9467. _actionManager: Nullable<AbstractActionManager>;
  9468. /**
  9469. * Adds action to chain of actions, may be a DoNothingAction
  9470. * @param action defines the next action to execute
  9471. * @returns The action passed in
  9472. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9473. */
  9474. then(action: IAction): IAction;
  9475. }
  9476. /**
  9477. * The action to be carried out following a trigger
  9478. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9479. */
  9480. export class Action implements IAction {
  9481. /** the trigger, with or without parameters, for the action */
  9482. triggerOptions: any;
  9483. /**
  9484. * Trigger for the action
  9485. */
  9486. trigger: number;
  9487. /**
  9488. * Internal only - manager for action
  9489. * @hidden
  9490. */
  9491. _actionManager: ActionManager;
  9492. private _nextActiveAction;
  9493. private _child;
  9494. private _condition?;
  9495. private _triggerParameter;
  9496. /**
  9497. * An event triggered prior to action being executed.
  9498. */
  9499. onBeforeExecuteObservable: Observable<Action>;
  9500. /**
  9501. * Creates a new Action
  9502. * @param triggerOptions the trigger, with or without parameters, for the action
  9503. * @param condition an optional determinant of action
  9504. */
  9505. constructor(
  9506. /** the trigger, with or without parameters, for the action */
  9507. triggerOptions: any, condition?: Condition);
  9508. /**
  9509. * Internal only
  9510. * @hidden
  9511. */
  9512. _prepare(): void;
  9513. /**
  9514. * Gets the trigger parameter
  9515. * @returns the trigger parameter
  9516. */
  9517. getTriggerParameter(): any;
  9518. /**
  9519. * Sets the trigger parameter
  9520. * @param value defines the new trigger parameter
  9521. */
  9522. setTriggerParameter(value: any): void;
  9523. /**
  9524. * Internal only - executes current action event
  9525. * @hidden
  9526. */
  9527. _executeCurrent(evt?: ActionEvent): void;
  9528. /**
  9529. * Execute placeholder for child classes
  9530. * @param evt optional action event
  9531. */
  9532. execute(evt?: ActionEvent): void;
  9533. /**
  9534. * Skips to next active action
  9535. */
  9536. skipToNextActiveAction(): void;
  9537. /**
  9538. * Adds action to chain of actions, may be a DoNothingAction
  9539. * @param action defines the next action to execute
  9540. * @returns The action passed in
  9541. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9542. */
  9543. then(action: Action): Action;
  9544. /**
  9545. * Internal only
  9546. * @hidden
  9547. */
  9548. _getProperty(propertyPath: string): string;
  9549. /**
  9550. * Internal only
  9551. * @hidden
  9552. */
  9553. _getEffectiveTarget(target: any, propertyPath: string): any;
  9554. /**
  9555. * Serialize placeholder for child classes
  9556. * @param parent of child
  9557. * @returns the serialized object
  9558. */
  9559. serialize(parent: any): any;
  9560. /**
  9561. * Internal only called by serialize
  9562. * @hidden
  9563. */
  9564. protected _serialize(serializedAction: any, parent?: any): any;
  9565. /**
  9566. * Internal only
  9567. * @hidden
  9568. */
  9569. static _SerializeValueAsString: (value: any) => string;
  9570. /**
  9571. * Internal only
  9572. * @hidden
  9573. */
  9574. static _GetTargetProperty: (target: Scene | Node) => {
  9575. name: string;
  9576. targetType: string;
  9577. value: string;
  9578. };
  9579. }
  9580. }
  9581. declare module BABYLON {
  9582. /**
  9583. * A Condition applied to an Action
  9584. */
  9585. export class Condition {
  9586. /**
  9587. * Internal only - manager for action
  9588. * @hidden
  9589. */
  9590. _actionManager: ActionManager;
  9591. /**
  9592. * Internal only
  9593. * @hidden
  9594. */
  9595. _evaluationId: number;
  9596. /**
  9597. * Internal only
  9598. * @hidden
  9599. */
  9600. _currentResult: boolean;
  9601. /**
  9602. * Creates a new Condition
  9603. * @param actionManager the manager of the action the condition is applied to
  9604. */
  9605. constructor(actionManager: ActionManager);
  9606. /**
  9607. * Check if the current condition is valid
  9608. * @returns a boolean
  9609. */
  9610. isValid(): boolean;
  9611. /**
  9612. * Internal only
  9613. * @hidden
  9614. */
  9615. _getProperty(propertyPath: string): string;
  9616. /**
  9617. * Internal only
  9618. * @hidden
  9619. */
  9620. _getEffectiveTarget(target: any, propertyPath: string): any;
  9621. /**
  9622. * Serialize placeholder for child classes
  9623. * @returns the serialized object
  9624. */
  9625. serialize(): any;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. protected _serialize(serializedCondition: any): any;
  9631. }
  9632. /**
  9633. * Defines specific conditional operators as extensions of Condition
  9634. */
  9635. export class ValueCondition extends Condition {
  9636. /** path to specify the property of the target the conditional operator uses */
  9637. propertyPath: string;
  9638. /** the value compared by the conditional operator against the current value of the property */
  9639. value: any;
  9640. /** the conditional operator, default ValueCondition.IsEqual */
  9641. operator: number;
  9642. /**
  9643. * Internal only
  9644. * @hidden
  9645. */
  9646. private static _IsEqual;
  9647. /**
  9648. * Internal only
  9649. * @hidden
  9650. */
  9651. private static _IsDifferent;
  9652. /**
  9653. * Internal only
  9654. * @hidden
  9655. */
  9656. private static _IsGreater;
  9657. /**
  9658. * Internal only
  9659. * @hidden
  9660. */
  9661. private static _IsLesser;
  9662. /**
  9663. * returns the number for IsEqual
  9664. */
  9665. static get IsEqual(): number;
  9666. /**
  9667. * Returns the number for IsDifferent
  9668. */
  9669. static get IsDifferent(): number;
  9670. /**
  9671. * Returns the number for IsGreater
  9672. */
  9673. static get IsGreater(): number;
  9674. /**
  9675. * Returns the number for IsLesser
  9676. */
  9677. static get IsLesser(): number;
  9678. /**
  9679. * Internal only The action manager for the condition
  9680. * @hidden
  9681. */
  9682. _actionManager: ActionManager;
  9683. /**
  9684. * Internal only
  9685. * @hidden
  9686. */
  9687. private _target;
  9688. /**
  9689. * Internal only
  9690. * @hidden
  9691. */
  9692. private _effectiveTarget;
  9693. /**
  9694. * Internal only
  9695. * @hidden
  9696. */
  9697. private _property;
  9698. /**
  9699. * Creates a new ValueCondition
  9700. * @param actionManager manager for the action the condition applies to
  9701. * @param target for the action
  9702. * @param propertyPath path to specify the property of the target the conditional operator uses
  9703. * @param value the value compared by the conditional operator against the current value of the property
  9704. * @param operator the conditional operator, default ValueCondition.IsEqual
  9705. */
  9706. constructor(actionManager: ActionManager, target: any,
  9707. /** path to specify the property of the target the conditional operator uses */
  9708. propertyPath: string,
  9709. /** the value compared by the conditional operator against the current value of the property */
  9710. value: any,
  9711. /** the conditional operator, default ValueCondition.IsEqual */
  9712. operator?: number);
  9713. /**
  9714. * Compares the given value with the property value for the specified conditional operator
  9715. * @returns the result of the comparison
  9716. */
  9717. isValid(): boolean;
  9718. /**
  9719. * Serialize the ValueCondition into a JSON compatible object
  9720. * @returns serialization object
  9721. */
  9722. serialize(): any;
  9723. /**
  9724. * Gets the name of the conditional operator for the ValueCondition
  9725. * @param operator the conditional operator
  9726. * @returns the name
  9727. */
  9728. static GetOperatorName(operator: number): string;
  9729. }
  9730. /**
  9731. * Defines a predicate condition as an extension of Condition
  9732. */
  9733. export class PredicateCondition extends Condition {
  9734. /** defines the predicate function used to validate the condition */
  9735. predicate: () => boolean;
  9736. /**
  9737. * Internal only - manager for action
  9738. * @hidden
  9739. */
  9740. _actionManager: ActionManager;
  9741. /**
  9742. * Creates a new PredicateCondition
  9743. * @param actionManager manager for the action the condition applies to
  9744. * @param predicate defines the predicate function used to validate the condition
  9745. */
  9746. constructor(actionManager: ActionManager,
  9747. /** defines the predicate function used to validate the condition */
  9748. predicate: () => boolean);
  9749. /**
  9750. * @returns the validity of the predicate condition
  9751. */
  9752. isValid(): boolean;
  9753. }
  9754. /**
  9755. * Defines a state condition as an extension of Condition
  9756. */
  9757. export class StateCondition extends Condition {
  9758. /** Value to compare with target state */
  9759. value: string;
  9760. /**
  9761. * Internal only - manager for action
  9762. * @hidden
  9763. */
  9764. _actionManager: ActionManager;
  9765. /**
  9766. * Internal only
  9767. * @hidden
  9768. */
  9769. private _target;
  9770. /**
  9771. * Creates a new StateCondition
  9772. * @param actionManager manager for the action the condition applies to
  9773. * @param target of the condition
  9774. * @param value to compare with target state
  9775. */
  9776. constructor(actionManager: ActionManager, target: any,
  9777. /** Value to compare with target state */
  9778. value: string);
  9779. /**
  9780. * Gets a boolean indicating if the current condition is met
  9781. * @returns the validity of the state
  9782. */
  9783. isValid(): boolean;
  9784. /**
  9785. * Serialize the StateCondition into a JSON compatible object
  9786. * @returns serialization object
  9787. */
  9788. serialize(): any;
  9789. }
  9790. }
  9791. declare module BABYLON {
  9792. /**
  9793. * This defines an action responsible to toggle a boolean once triggered.
  9794. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9795. */
  9796. export class SwitchBooleanAction extends Action {
  9797. /**
  9798. * The path to the boolean property in the target object
  9799. */
  9800. propertyPath: string;
  9801. private _target;
  9802. private _effectiveTarget;
  9803. private _property;
  9804. /**
  9805. * Instantiate the action
  9806. * @param triggerOptions defines the trigger options
  9807. * @param target defines the object containing the boolean
  9808. * @param propertyPath defines the path to the boolean property in the target object
  9809. * @param condition defines the trigger related conditions
  9810. */
  9811. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9812. /** @hidden */
  9813. _prepare(): void;
  9814. /**
  9815. * Execute the action toggle the boolean value.
  9816. */
  9817. execute(): void;
  9818. /**
  9819. * Serializes the actions and its related information.
  9820. * @param parent defines the object to serialize in
  9821. * @returns the serialized object
  9822. */
  9823. serialize(parent: any): any;
  9824. }
  9825. /**
  9826. * This defines an action responsible to set a the state field of the target
  9827. * to a desired value once triggered.
  9828. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9829. */
  9830. export class SetStateAction extends Action {
  9831. /**
  9832. * The value to store in the state field.
  9833. */
  9834. value: string;
  9835. private _target;
  9836. /**
  9837. * Instantiate the action
  9838. * @param triggerOptions defines the trigger options
  9839. * @param target defines the object containing the state property
  9840. * @param value defines the value to store in the state field
  9841. * @param condition defines the trigger related conditions
  9842. */
  9843. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9844. /**
  9845. * Execute the action and store the value on the target state property.
  9846. */
  9847. execute(): void;
  9848. /**
  9849. * Serializes the actions and its related information.
  9850. * @param parent defines the object to serialize in
  9851. * @returns the serialized object
  9852. */
  9853. serialize(parent: any): any;
  9854. }
  9855. /**
  9856. * This defines an action responsible to set a property of the target
  9857. * to a desired value once triggered.
  9858. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9859. */
  9860. export class SetValueAction extends Action {
  9861. /**
  9862. * The path of the property to set in the target.
  9863. */
  9864. propertyPath: string;
  9865. /**
  9866. * The value to set in the property
  9867. */
  9868. value: any;
  9869. private _target;
  9870. private _effectiveTarget;
  9871. private _property;
  9872. /**
  9873. * Instantiate the action
  9874. * @param triggerOptions defines the trigger options
  9875. * @param target defines the object containing the property
  9876. * @param propertyPath defines the path of the property to set in the target
  9877. * @param value defines the value to set in the property
  9878. * @param condition defines the trigger related conditions
  9879. */
  9880. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9881. /** @hidden */
  9882. _prepare(): void;
  9883. /**
  9884. * Execute the action and set the targetted property to the desired value.
  9885. */
  9886. execute(): void;
  9887. /**
  9888. * Serializes the actions and its related information.
  9889. * @param parent defines the object to serialize in
  9890. * @returns the serialized object
  9891. */
  9892. serialize(parent: any): any;
  9893. }
  9894. /**
  9895. * This defines an action responsible to increment the target value
  9896. * to a desired value once triggered.
  9897. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9898. */
  9899. export class IncrementValueAction extends Action {
  9900. /**
  9901. * The path of the property to increment in the target.
  9902. */
  9903. propertyPath: string;
  9904. /**
  9905. * The value we should increment the property by.
  9906. */
  9907. value: any;
  9908. private _target;
  9909. private _effectiveTarget;
  9910. private _property;
  9911. /**
  9912. * Instantiate the action
  9913. * @param triggerOptions defines the trigger options
  9914. * @param target defines the object containing the property
  9915. * @param propertyPath defines the path of the property to increment in the target
  9916. * @param value defines the value value we should increment the property by
  9917. * @param condition defines the trigger related conditions
  9918. */
  9919. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9920. /** @hidden */
  9921. _prepare(): void;
  9922. /**
  9923. * Execute the action and increment the target of the value amount.
  9924. */
  9925. execute(): void;
  9926. /**
  9927. * Serializes the actions and its related information.
  9928. * @param parent defines the object to serialize in
  9929. * @returns the serialized object
  9930. */
  9931. serialize(parent: any): any;
  9932. }
  9933. /**
  9934. * This defines an action responsible to start an animation once triggered.
  9935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9936. */
  9937. export class PlayAnimationAction extends Action {
  9938. /**
  9939. * Where the animation should start (animation frame)
  9940. */
  9941. from: number;
  9942. /**
  9943. * Where the animation should stop (animation frame)
  9944. */
  9945. to: number;
  9946. /**
  9947. * Define if the animation should loop or stop after the first play.
  9948. */
  9949. loop?: boolean;
  9950. private _target;
  9951. /**
  9952. * Instantiate the action
  9953. * @param triggerOptions defines the trigger options
  9954. * @param target defines the target animation or animation name
  9955. * @param from defines from where the animation should start (animation frame)
  9956. * @param end defines where the animation should stop (animation frame)
  9957. * @param loop defines if the animation should loop or stop after the first play
  9958. * @param condition defines the trigger related conditions
  9959. */
  9960. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9961. /** @hidden */
  9962. _prepare(): void;
  9963. /**
  9964. * Execute the action and play the animation.
  9965. */
  9966. execute(): void;
  9967. /**
  9968. * Serializes the actions and its related information.
  9969. * @param parent defines the object to serialize in
  9970. * @returns the serialized object
  9971. */
  9972. serialize(parent: any): any;
  9973. }
  9974. /**
  9975. * This defines an action responsible to stop an animation once triggered.
  9976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9977. */
  9978. export class StopAnimationAction extends Action {
  9979. private _target;
  9980. /**
  9981. * Instantiate the action
  9982. * @param triggerOptions defines the trigger options
  9983. * @param target defines the target animation or animation name
  9984. * @param condition defines the trigger related conditions
  9985. */
  9986. constructor(triggerOptions: any, target: any, condition?: Condition);
  9987. /** @hidden */
  9988. _prepare(): void;
  9989. /**
  9990. * Execute the action and stop the animation.
  9991. */
  9992. execute(): void;
  9993. /**
  9994. * Serializes the actions and its related information.
  9995. * @param parent defines the object to serialize in
  9996. * @returns the serialized object
  9997. */
  9998. serialize(parent: any): any;
  9999. }
  10000. /**
  10001. * This defines an action responsible that does nothing once triggered.
  10002. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10003. */
  10004. export class DoNothingAction extends Action {
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param condition defines the trigger related conditions
  10009. */
  10010. constructor(triggerOptions?: any, condition?: Condition);
  10011. /**
  10012. * Execute the action and do nothing.
  10013. */
  10014. execute(): void;
  10015. /**
  10016. * Serializes the actions and its related information.
  10017. * @param parent defines the object to serialize in
  10018. * @returns the serialized object
  10019. */
  10020. serialize(parent: any): any;
  10021. }
  10022. /**
  10023. * This defines an action responsible to trigger several actions once triggered.
  10024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class CombineAction extends Action {
  10027. /**
  10028. * The list of aggregated animations to run.
  10029. */
  10030. children: Action[];
  10031. /**
  10032. * Instantiate the action
  10033. * @param triggerOptions defines the trigger options
  10034. * @param children defines the list of aggregated animations to run
  10035. * @param condition defines the trigger related conditions
  10036. */
  10037. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10038. /** @hidden */
  10039. _prepare(): void;
  10040. /**
  10041. * Execute the action and executes all the aggregated actions.
  10042. */
  10043. execute(evt: ActionEvent): void;
  10044. /**
  10045. * Serializes the actions and its related information.
  10046. * @param parent defines the object to serialize in
  10047. * @returns the serialized object
  10048. */
  10049. serialize(parent: any): any;
  10050. }
  10051. /**
  10052. * This defines an action responsible to run code (external event) once triggered.
  10053. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10054. */
  10055. export class ExecuteCodeAction extends Action {
  10056. /**
  10057. * The callback function to run.
  10058. */
  10059. func: (evt: ActionEvent) => void;
  10060. /**
  10061. * Instantiate the action
  10062. * @param triggerOptions defines the trigger options
  10063. * @param func defines the callback function to run
  10064. * @param condition defines the trigger related conditions
  10065. */
  10066. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10067. /**
  10068. * Execute the action and run the attached code.
  10069. */
  10070. execute(evt: ActionEvent): void;
  10071. }
  10072. /**
  10073. * This defines an action responsible to set the parent property of the target once triggered.
  10074. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10075. */
  10076. export class SetParentAction extends Action {
  10077. private _parent;
  10078. private _target;
  10079. /**
  10080. * Instantiate the action
  10081. * @param triggerOptions defines the trigger options
  10082. * @param target defines the target containing the parent property
  10083. * @param parent defines from where the animation should start (animation frame)
  10084. * @param condition defines the trigger related conditions
  10085. */
  10086. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10087. /** @hidden */
  10088. _prepare(): void;
  10089. /**
  10090. * Execute the action and set the parent property.
  10091. */
  10092. execute(): void;
  10093. /**
  10094. * Serializes the actions and its related information.
  10095. * @param parent defines the object to serialize in
  10096. * @returns the serialized object
  10097. */
  10098. serialize(parent: any): any;
  10099. }
  10100. }
  10101. declare module BABYLON {
  10102. /**
  10103. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10104. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10105. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10106. */
  10107. export class ActionManager extends AbstractActionManager {
  10108. /**
  10109. * Nothing
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10111. */
  10112. static readonly NothingTrigger: number;
  10113. /**
  10114. * On pick
  10115. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10116. */
  10117. static readonly OnPickTrigger: number;
  10118. /**
  10119. * On left pick
  10120. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10121. */
  10122. static readonly OnLeftPickTrigger: number;
  10123. /**
  10124. * On right pick
  10125. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10126. */
  10127. static readonly OnRightPickTrigger: number;
  10128. /**
  10129. * On center pick
  10130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10131. */
  10132. static readonly OnCenterPickTrigger: number;
  10133. /**
  10134. * On pick down
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10136. */
  10137. static readonly OnPickDownTrigger: number;
  10138. /**
  10139. * On double pick
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly OnDoublePickTrigger: number;
  10143. /**
  10144. * On pick up
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnPickUpTrigger: number;
  10148. /**
  10149. * On pick out.
  10150. * This trigger will only be raised if you also declared a OnPickDown
  10151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10152. */
  10153. static readonly OnPickOutTrigger: number;
  10154. /**
  10155. * On long press
  10156. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10157. */
  10158. static readonly OnLongPressTrigger: number;
  10159. /**
  10160. * On pointer over
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10162. */
  10163. static readonly OnPointerOverTrigger: number;
  10164. /**
  10165. * On pointer out
  10166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10167. */
  10168. static readonly OnPointerOutTrigger: number;
  10169. /**
  10170. * On every frame
  10171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10172. */
  10173. static readonly OnEveryFrameTrigger: number;
  10174. /**
  10175. * On intersection enter
  10176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10177. */
  10178. static readonly OnIntersectionEnterTrigger: number;
  10179. /**
  10180. * On intersection exit
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnIntersectionExitTrigger: number;
  10184. /**
  10185. * On key down
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnKeyDownTrigger: number;
  10189. /**
  10190. * On key up
  10191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10192. */
  10193. static readonly OnKeyUpTrigger: number;
  10194. private _scene;
  10195. /**
  10196. * Creates a new action manager
  10197. * @param scene defines the hosting scene
  10198. */
  10199. constructor(scene: Scene);
  10200. /**
  10201. * Releases all associated resources
  10202. */
  10203. dispose(): void;
  10204. /**
  10205. * Gets hosting scene
  10206. * @returns the hosting scene
  10207. */
  10208. getScene(): Scene;
  10209. /**
  10210. * Does this action manager handles actions of any of the given triggers
  10211. * @param triggers defines the triggers to be tested
  10212. * @return a boolean indicating whether one (or more) of the triggers is handled
  10213. */
  10214. hasSpecificTriggers(triggers: number[]): boolean;
  10215. /**
  10216. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10217. * speed.
  10218. * @param triggerA defines the trigger to be tested
  10219. * @param triggerB defines the trigger to be tested
  10220. * @return a boolean indicating whether one (or more) of the triggers is handled
  10221. */
  10222. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10223. /**
  10224. * Does this action manager handles actions of a given trigger
  10225. * @param trigger defines the trigger to be tested
  10226. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10227. * @return whether the trigger is handled
  10228. */
  10229. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10230. /**
  10231. * Does this action manager has pointer triggers
  10232. */
  10233. get hasPointerTriggers(): boolean;
  10234. /**
  10235. * Does this action manager has pick triggers
  10236. */
  10237. get hasPickTriggers(): boolean;
  10238. /**
  10239. * Registers an action to this action manager
  10240. * @param action defines the action to be registered
  10241. * @return the action amended (prepared) after registration
  10242. */
  10243. registerAction(action: IAction): Nullable<IAction>;
  10244. /**
  10245. * Unregisters an action to this action manager
  10246. * @param action defines the action to be unregistered
  10247. * @return a boolean indicating whether the action has been unregistered
  10248. */
  10249. unregisterAction(action: IAction): Boolean;
  10250. /**
  10251. * Process a specific trigger
  10252. * @param trigger defines the trigger to process
  10253. * @param evt defines the event details to be processed
  10254. */
  10255. processTrigger(trigger: number, evt?: IActionEvent): void;
  10256. /** @hidden */
  10257. _getEffectiveTarget(target: any, propertyPath: string): any;
  10258. /** @hidden */
  10259. _getProperty(propertyPath: string): string;
  10260. /**
  10261. * Serialize this manager to a JSON object
  10262. * @param name defines the property name to store this manager
  10263. * @returns a JSON representation of this manager
  10264. */
  10265. serialize(name: string): any;
  10266. /**
  10267. * Creates a new ActionManager from a JSON data
  10268. * @param parsedActions defines the JSON data to read from
  10269. * @param object defines the hosting mesh
  10270. * @param scene defines the hosting scene
  10271. */
  10272. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10273. /**
  10274. * Get a trigger name by index
  10275. * @param trigger defines the trigger index
  10276. * @returns a trigger name
  10277. */
  10278. static GetTriggerName(trigger: number): string;
  10279. }
  10280. }
  10281. declare module BABYLON {
  10282. /**
  10283. * Class representing a ray with position and direction
  10284. */
  10285. export class Ray {
  10286. /** origin point */
  10287. origin: Vector3;
  10288. /** direction */
  10289. direction: Vector3;
  10290. /** length of the ray */
  10291. length: number;
  10292. private static readonly _TmpVector3;
  10293. private _tmpRay;
  10294. /**
  10295. * Creates a new ray
  10296. * @param origin origin point
  10297. * @param direction direction
  10298. * @param length length of the ray
  10299. */
  10300. constructor(
  10301. /** origin point */
  10302. origin: Vector3,
  10303. /** direction */
  10304. direction: Vector3,
  10305. /** length of the ray */
  10306. length?: number);
  10307. /**
  10308. * Checks if the ray intersects a box
  10309. * This does not account for the ray lenght by design to improve perfs.
  10310. * @param minimum bound of the box
  10311. * @param maximum bound of the box
  10312. * @param intersectionTreshold extra extend to be added to the box in all direction
  10313. * @returns if the box was hit
  10314. */
  10315. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10316. /**
  10317. * Checks if the ray intersects a box
  10318. * This does not account for the ray lenght by design to improve perfs.
  10319. * @param box the bounding box to check
  10320. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10321. * @returns if the box was hit
  10322. */
  10323. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10324. /**
  10325. * If the ray hits a sphere
  10326. * @param sphere the bounding sphere to check
  10327. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10328. * @returns true if it hits the sphere
  10329. */
  10330. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10331. /**
  10332. * If the ray hits a triange
  10333. * @param vertex0 triangle vertex
  10334. * @param vertex1 triangle vertex
  10335. * @param vertex2 triangle vertex
  10336. * @returns intersection information if hit
  10337. */
  10338. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10339. /**
  10340. * Checks if ray intersects a plane
  10341. * @param plane the plane to check
  10342. * @returns the distance away it was hit
  10343. */
  10344. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10345. /**
  10346. * Calculate the intercept of a ray on a given axis
  10347. * @param axis to check 'x' | 'y' | 'z'
  10348. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10349. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10350. */
  10351. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10352. /**
  10353. * Checks if ray intersects a mesh
  10354. * @param mesh the mesh to check
  10355. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10356. * @returns picking info of the intersecton
  10357. */
  10358. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10359. /**
  10360. * Checks if ray intersects a mesh
  10361. * @param meshes the meshes to check
  10362. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10363. * @param results array to store result in
  10364. * @returns Array of picking infos
  10365. */
  10366. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10367. private _comparePickingInfo;
  10368. private static smallnum;
  10369. private static rayl;
  10370. /**
  10371. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10372. * @param sega the first point of the segment to test the intersection against
  10373. * @param segb the second point of the segment to test the intersection against
  10374. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10375. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10376. */
  10377. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10378. /**
  10379. * Update the ray from viewport position
  10380. * @param x position
  10381. * @param y y position
  10382. * @param viewportWidth viewport width
  10383. * @param viewportHeight viewport height
  10384. * @param world world matrix
  10385. * @param view view matrix
  10386. * @param projection projection matrix
  10387. * @returns this ray updated
  10388. */
  10389. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10390. /**
  10391. * Creates a ray with origin and direction of 0,0,0
  10392. * @returns the new ray
  10393. */
  10394. static Zero(): Ray;
  10395. /**
  10396. * Creates a new ray from screen space and viewport
  10397. * @param x position
  10398. * @param y y position
  10399. * @param viewportWidth viewport width
  10400. * @param viewportHeight viewport height
  10401. * @param world world matrix
  10402. * @param view view matrix
  10403. * @param projection projection matrix
  10404. * @returns new ray
  10405. */
  10406. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10407. /**
  10408. * 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
  10409. * transformed to the given world matrix.
  10410. * @param origin The origin point
  10411. * @param end The end point
  10412. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10413. * @returns the new ray
  10414. */
  10415. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10416. /**
  10417. * Transforms a ray by a matrix
  10418. * @param ray ray to transform
  10419. * @param matrix matrix to apply
  10420. * @returns the resulting new ray
  10421. */
  10422. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10423. /**
  10424. * Transforms a ray by a matrix
  10425. * @param ray ray to transform
  10426. * @param matrix matrix to apply
  10427. * @param result ray to store result in
  10428. */
  10429. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10430. /**
  10431. * Unproject a ray from screen space to object space
  10432. * @param sourceX defines the screen space x coordinate to use
  10433. * @param sourceY defines the screen space y coordinate to use
  10434. * @param viewportWidth defines the current width of the viewport
  10435. * @param viewportHeight defines the current height of the viewport
  10436. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10437. * @param view defines the view matrix to use
  10438. * @param projection defines the projection matrix to use
  10439. */
  10440. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10441. }
  10442. /**
  10443. * Type used to define predicate used to select faces when a mesh intersection is detected
  10444. */
  10445. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10446. interface Scene {
  10447. /** @hidden */
  10448. _tempPickingRay: Nullable<Ray>;
  10449. /** @hidden */
  10450. _cachedRayForTransform: Ray;
  10451. /** @hidden */
  10452. _pickWithRayInverseMatrix: Matrix;
  10453. /** @hidden */
  10454. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10455. /** @hidden */
  10456. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10457. /** @hidden */
  10458. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10459. }
  10460. }
  10461. declare module BABYLON {
  10462. /**
  10463. * Groups all the scene component constants in one place to ease maintenance.
  10464. * @hidden
  10465. */
  10466. export class SceneComponentConstants {
  10467. static readonly NAME_EFFECTLAYER: string;
  10468. static readonly NAME_LAYER: string;
  10469. static readonly NAME_LENSFLARESYSTEM: string;
  10470. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10471. static readonly NAME_PARTICLESYSTEM: string;
  10472. static readonly NAME_GAMEPAD: string;
  10473. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10474. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10475. static readonly NAME_PREPASSRENDERER: string;
  10476. static readonly NAME_DEPTHRENDERER: string;
  10477. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10478. static readonly NAME_SPRITE: string;
  10479. static readonly NAME_SUBSURFACE: string;
  10480. static readonly NAME_OUTLINERENDERER: string;
  10481. static readonly NAME_PROCEDURALTEXTURE: string;
  10482. static readonly NAME_SHADOWGENERATOR: string;
  10483. static readonly NAME_OCTREE: string;
  10484. static readonly NAME_PHYSICSENGINE: string;
  10485. static readonly NAME_AUDIO: string;
  10486. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10487. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10488. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10489. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10490. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10491. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10492. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10493. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10494. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10495. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  10496. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10497. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  10498. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10499. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10500. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10501. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10502. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10503. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10504. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10505. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10506. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10507. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10508. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10509. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10510. static readonly STEP_AFTERRENDER_AUDIO: number;
  10511. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10512. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10513. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10514. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10515. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10516. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10517. static readonly STEP_POINTERMOVE_SPRITE: number;
  10518. static readonly STEP_POINTERDOWN_SPRITE: number;
  10519. static readonly STEP_POINTERUP_SPRITE: number;
  10520. }
  10521. /**
  10522. * This represents a scene component.
  10523. *
  10524. * This is used to decouple the dependency the scene is having on the different workloads like
  10525. * layers, post processes...
  10526. */
  10527. export interface ISceneComponent {
  10528. /**
  10529. * The name of the component. Each component must have a unique name.
  10530. */
  10531. name: string;
  10532. /**
  10533. * The scene the component belongs to.
  10534. */
  10535. scene: Scene;
  10536. /**
  10537. * Register the component to one instance of a scene.
  10538. */
  10539. register(): void;
  10540. /**
  10541. * Rebuilds the elements related to this component in case of
  10542. * context lost for instance.
  10543. */
  10544. rebuild(): void;
  10545. /**
  10546. * Disposes the component and the associated ressources.
  10547. */
  10548. dispose(): void;
  10549. }
  10550. /**
  10551. * This represents a SERIALIZABLE scene component.
  10552. *
  10553. * This extends Scene Component to add Serialization methods on top.
  10554. */
  10555. export interface ISceneSerializableComponent extends ISceneComponent {
  10556. /**
  10557. * Adds all the elements from the container to the scene
  10558. * @param container the container holding the elements
  10559. */
  10560. addFromContainer(container: AbstractScene): void;
  10561. /**
  10562. * Removes all the elements in the container from the scene
  10563. * @param container contains the elements to remove
  10564. * @param dispose if the removed element should be disposed (default: false)
  10565. */
  10566. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10567. /**
  10568. * Serializes the component data to the specified json object
  10569. * @param serializationObject The object to serialize to
  10570. */
  10571. serialize(serializationObject: any): void;
  10572. }
  10573. /**
  10574. * Strong typing of a Mesh related stage step action
  10575. */
  10576. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10577. /**
  10578. * Strong typing of a Evaluate Sub Mesh related stage step action
  10579. */
  10580. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10581. /**
  10582. * Strong typing of a pre active Mesh related stage step action
  10583. */
  10584. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10585. /**
  10586. * Strong typing of a Camera related stage step action
  10587. */
  10588. export type CameraStageAction = (camera: Camera) => void;
  10589. /**
  10590. * Strong typing of a Camera Frame buffer related stage step action
  10591. */
  10592. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10593. /**
  10594. * Strong typing of a Render Target related stage step action
  10595. */
  10596. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10597. /**
  10598. * Strong typing of a RenderingGroup related stage step action
  10599. */
  10600. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10601. /**
  10602. * Strong typing of a Mesh Render related stage step action
  10603. */
  10604. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  10605. /**
  10606. * Strong typing of a simple stage step action
  10607. */
  10608. export type SimpleStageAction = () => void;
  10609. /**
  10610. * Strong typing of a render target action.
  10611. */
  10612. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10613. /**
  10614. * Strong typing of a pointer move action.
  10615. */
  10616. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10617. /**
  10618. * Strong typing of a pointer up/down action.
  10619. */
  10620. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10621. /**
  10622. * Representation of a stage in the scene (Basically a list of ordered steps)
  10623. * @hidden
  10624. */
  10625. export class Stage<T extends Function> extends Array<{
  10626. index: number;
  10627. component: ISceneComponent;
  10628. action: T;
  10629. }> {
  10630. /**
  10631. * Hide ctor from the rest of the world.
  10632. * @param items The items to add.
  10633. */
  10634. private constructor();
  10635. /**
  10636. * Creates a new Stage.
  10637. * @returns A new instance of a Stage
  10638. */
  10639. static Create<T extends Function>(): Stage<T>;
  10640. /**
  10641. * Registers a step in an ordered way in the targeted stage.
  10642. * @param index Defines the position to register the step in
  10643. * @param component Defines the component attached to the step
  10644. * @param action Defines the action to launch during the step
  10645. */
  10646. registerStep(index: number, component: ISceneComponent, action: T): void;
  10647. /**
  10648. * Clears all the steps from the stage.
  10649. */
  10650. clear(): void;
  10651. }
  10652. }
  10653. declare module BABYLON {
  10654. interface Scene {
  10655. /** @hidden */
  10656. _pointerOverSprite: Nullable<Sprite>;
  10657. /** @hidden */
  10658. _pickedDownSprite: Nullable<Sprite>;
  10659. /** @hidden */
  10660. _tempSpritePickingRay: Nullable<Ray>;
  10661. /**
  10662. * All of the sprite managers added to this scene
  10663. * @see https://doc.babylonjs.com/babylon101/sprites
  10664. */
  10665. spriteManagers: Array<ISpriteManager>;
  10666. /**
  10667. * An event triggered when sprites rendering is about to start
  10668. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10669. */
  10670. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10671. /**
  10672. * An event triggered when sprites rendering is done
  10673. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10674. */
  10675. onAfterSpritesRenderingObservable: Observable<Scene>;
  10676. /** @hidden */
  10677. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10678. /** Launch a ray to try to pick a sprite in the scene
  10679. * @param x position on screen
  10680. * @param y position on screen
  10681. * @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
  10682. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10683. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10684. * @returns a PickingInfo
  10685. */
  10686. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10687. /** Use the given ray to pick a sprite in the scene
  10688. * @param ray The ray (in world space) to use to pick meshes
  10689. * @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
  10690. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10691. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10692. * @returns a PickingInfo
  10693. */
  10694. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10695. /** @hidden */
  10696. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10697. /** Launch a ray to try to pick sprites in the scene
  10698. * @param x position on screen
  10699. * @param y position on screen
  10700. * @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
  10701. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10702. * @returns a PickingInfo array
  10703. */
  10704. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10705. /** Use the given ray to pick sprites in the scene
  10706. * @param ray The ray (in world space) to use to pick meshes
  10707. * @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
  10708. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10709. * @returns a PickingInfo array
  10710. */
  10711. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10712. /**
  10713. * Force the sprite under the pointer
  10714. * @param sprite defines the sprite to use
  10715. */
  10716. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10717. /**
  10718. * Gets the sprite under the pointer
  10719. * @returns a Sprite or null if no sprite is under the pointer
  10720. */
  10721. getPointerOverSprite(): Nullable<Sprite>;
  10722. }
  10723. /**
  10724. * Defines the sprite scene component responsible to manage sprites
  10725. * in a given scene.
  10726. */
  10727. export class SpriteSceneComponent implements ISceneComponent {
  10728. /**
  10729. * The component name helpfull to identify the component in the list of scene components.
  10730. */
  10731. readonly name: string;
  10732. /**
  10733. * The scene the component belongs to.
  10734. */
  10735. scene: Scene;
  10736. /** @hidden */
  10737. private _spritePredicate;
  10738. /**
  10739. * Creates a new instance of the component for the given scene
  10740. * @param scene Defines the scene to register the component in
  10741. */
  10742. constructor(scene: Scene);
  10743. /**
  10744. * Registers the component in a given scene
  10745. */
  10746. register(): void;
  10747. /**
  10748. * Rebuilds the elements related to this component in case of
  10749. * context lost for instance.
  10750. */
  10751. rebuild(): void;
  10752. /**
  10753. * Disposes the component and the associated ressources.
  10754. */
  10755. dispose(): void;
  10756. private _pickSpriteButKeepRay;
  10757. private _pointerMove;
  10758. private _pointerDown;
  10759. private _pointerUp;
  10760. }
  10761. }
  10762. declare module BABYLON {
  10763. /**
  10764. * Class used to provide helper for timing
  10765. */
  10766. export class TimingTools {
  10767. /**
  10768. * Polyfill for setImmediate
  10769. * @param action defines the action to execute after the current execution block
  10770. */
  10771. static SetImmediate(action: () => void): void;
  10772. }
  10773. }
  10774. declare module BABYLON {
  10775. /**
  10776. * Class used to enable instatition of objects by class name
  10777. */
  10778. export class InstantiationTools {
  10779. /**
  10780. * Use this object to register external classes like custom textures or material
  10781. * to allow the laoders to instantiate them
  10782. */
  10783. static RegisteredExternalClasses: {
  10784. [key: string]: Object;
  10785. };
  10786. /**
  10787. * Tries to instantiate a new object from a given class name
  10788. * @param className defines the class name to instantiate
  10789. * @returns the new object or null if the system was not able to do the instantiation
  10790. */
  10791. static Instantiate(className: string): any;
  10792. }
  10793. }
  10794. declare module BABYLON {
  10795. /**
  10796. * Class used to host copy specific utilities
  10797. */
  10798. export class CopyTools {
  10799. /**
  10800. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10801. * @param texture defines the texture to read pixels from
  10802. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10803. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10804. * @returns The base64 encoded string or null
  10805. */
  10806. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10807. }
  10808. }
  10809. declare module BABYLON {
  10810. /**
  10811. * Define options used to create a depth texture
  10812. */
  10813. export class DepthTextureCreationOptions {
  10814. /** Specifies whether or not a stencil should be allocated in the texture */
  10815. generateStencil?: boolean;
  10816. /** Specifies whether or not bilinear filtering is enable on the texture */
  10817. bilinearFiltering?: boolean;
  10818. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10819. comparisonFunction?: number;
  10820. /** Specifies if the created texture is a cube texture */
  10821. isCube?: boolean;
  10822. }
  10823. }
  10824. declare module BABYLON {
  10825. interface ThinEngine {
  10826. /**
  10827. * Creates a depth stencil cube texture.
  10828. * This is only available in WebGL 2.
  10829. * @param size The size of face edge in the cube texture.
  10830. * @param options The options defining the cube texture.
  10831. * @returns The cube texture
  10832. */
  10833. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  10834. /**
  10835. * Creates a cube texture
  10836. * @param rootUrl defines the url where the files to load is located
  10837. * @param scene defines the current scene
  10838. * @param files defines the list of files to load (1 per face)
  10839. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10840. * @param onLoad defines an optional callback raised when the texture is loaded
  10841. * @param onError defines an optional callback raised if there is an issue to load the texture
  10842. * @param format defines the format of the data
  10843. * @param forcedExtension defines the extension to use to pick the right loader
  10844. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10845. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10846. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10847. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10848. * @param loaderOptions options to be passed to the loader
  10849. * @returns the cube texture as an InternalTexture
  10850. */
  10851. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  10852. /**
  10853. * Creates a cube texture
  10854. * @param rootUrl defines the url where the files to load is located
  10855. * @param scene defines the current scene
  10856. * @param files defines the list of files to load (1 per face)
  10857. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10858. * @param onLoad defines an optional callback raised when the texture is loaded
  10859. * @param onError defines an optional callback raised if there is an issue to load the texture
  10860. * @param format defines the format of the data
  10861. * @param forcedExtension defines the extension to use to pick the right loader
  10862. * @returns the cube texture as an InternalTexture
  10863. */
  10864. 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;
  10865. /**
  10866. * Creates a cube texture
  10867. * @param rootUrl defines the url where the files to load is located
  10868. * @param scene defines the current scene
  10869. * @param files defines the list of files to load (1 per face)
  10870. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10871. * @param onLoad defines an optional callback raised when the texture is loaded
  10872. * @param onError defines an optional callback raised if there is an issue to load the texture
  10873. * @param format defines the format of the data
  10874. * @param forcedExtension defines the extension to use to pick the right loader
  10875. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10876. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10877. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10878. * @returns the cube texture as an InternalTexture
  10879. */
  10880. 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;
  10881. /** @hidden */
  10882. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  10883. /** @hidden */
  10884. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  10885. /** @hidden */
  10886. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10887. /** @hidden */
  10888. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10889. /**
  10890. * @hidden
  10891. */
  10892. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  10893. }
  10894. }
  10895. declare module BABYLON {
  10896. /**
  10897. * Class for creating a cube texture
  10898. */
  10899. export class CubeTexture extends BaseTexture {
  10900. private _delayedOnLoad;
  10901. /**
  10902. * Observable triggered once the texture has been loaded.
  10903. */
  10904. onLoadObservable: Observable<CubeTexture>;
  10905. /**
  10906. * The url of the texture
  10907. */
  10908. url: string;
  10909. /**
  10910. * Gets or sets the center of the bounding box associated with the cube texture.
  10911. * It must define where the camera used to render the texture was set
  10912. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10913. */
  10914. boundingBoxPosition: Vector3;
  10915. private _boundingBoxSize;
  10916. /**
  10917. * Gets or sets the size of the bounding box associated with the cube texture
  10918. * When defined, the cubemap will switch to local mode
  10919. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  10920. * @example https://www.babylonjs-playground.com/#RNASML
  10921. */
  10922. set boundingBoxSize(value: Vector3);
  10923. /**
  10924. * Returns the bounding box size
  10925. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10926. */
  10927. get boundingBoxSize(): Vector3;
  10928. protected _rotationY: number;
  10929. /**
  10930. * Sets texture matrix rotation angle around Y axis in radians.
  10931. */
  10932. set rotationY(value: number);
  10933. /**
  10934. * Gets texture matrix rotation angle around Y axis radians.
  10935. */
  10936. get rotationY(): number;
  10937. /**
  10938. * Are mip maps generated for this texture or not.
  10939. */
  10940. get noMipmap(): boolean;
  10941. private _noMipmap;
  10942. private _files;
  10943. protected _forcedExtension: Nullable<string>;
  10944. private _extensions;
  10945. private _textureMatrix;
  10946. private _format;
  10947. private _createPolynomials;
  10948. private _loaderOptions;
  10949. /**
  10950. * Creates a cube texture from an array of image urls
  10951. * @param files defines an array of image urls
  10952. * @param scene defines the hosting scene
  10953. * @param noMipmap specifies if mip maps are not used
  10954. * @returns a cube texture
  10955. */
  10956. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  10957. /**
  10958. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  10959. * @param url defines the url of the prefiltered texture
  10960. * @param scene defines the scene the texture is attached to
  10961. * @param forcedExtension defines the extension of the file if different from the url
  10962. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10963. * @return the prefiltered texture
  10964. */
  10965. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  10966. /**
  10967. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  10968. * as prefiltered data.
  10969. * @param rootUrl defines the url of the texture or the root name of the six images
  10970. * @param null defines the scene or engine the texture is attached to
  10971. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  10972. * @param noMipmap defines if mipmaps should be created or not
  10973. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  10974. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  10975. * @param onError defines a callback triggered in case of error during load
  10976. * @param format defines the internal format to use for the texture once loaded
  10977. * @param prefiltered defines whether or not the texture is created from prefiltered data
  10978. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  10979. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10980. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10981. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10982. * @param loaderOptions options to be passed to the loader
  10983. * @return the cube texture
  10984. */
  10985. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  10986. /**
  10987. * Get the current class name of the texture useful for serialization or dynamic coding.
  10988. * @returns "CubeTexture"
  10989. */
  10990. getClassName(): string;
  10991. /**
  10992. * Update the url (and optional buffer) of this texture if url was null during construction.
  10993. * @param url the url of the texture
  10994. * @param forcedExtension defines the extension to use
  10995. * @param onLoad callback called when the texture is loaded (defaults to null)
  10996. * @param prefiltered Defines whether the updated texture is prefiltered or not
  10997. */
  10998. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  10999. /**
  11000. * Delays loading of the cube texture
  11001. * @param forcedExtension defines the extension to use
  11002. */
  11003. delayLoad(forcedExtension?: string): void;
  11004. /**
  11005. * Returns the reflection texture matrix
  11006. * @returns the reflection texture matrix
  11007. */
  11008. getReflectionTextureMatrix(): Matrix;
  11009. /**
  11010. * Sets the reflection texture matrix
  11011. * @param value Reflection texture matrix
  11012. */
  11013. setReflectionTextureMatrix(value: Matrix): void;
  11014. /**
  11015. * Parses text to create a cube texture
  11016. * @param parsedTexture define the serialized text to read from
  11017. * @param scene defines the hosting scene
  11018. * @param rootUrl defines the root url of the cube texture
  11019. * @returns a cube texture
  11020. */
  11021. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11022. /**
  11023. * Makes a clone, or deep copy, of the cube texture
  11024. * @returns a new cube texture
  11025. */
  11026. clone(): CubeTexture;
  11027. }
  11028. }
  11029. declare module BABYLON {
  11030. /**
  11031. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11032. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11033. * 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;
  11034. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11035. */
  11036. export class ColorCurves {
  11037. private _dirty;
  11038. private _tempColor;
  11039. private _globalCurve;
  11040. private _highlightsCurve;
  11041. private _midtonesCurve;
  11042. private _shadowsCurve;
  11043. private _positiveCurve;
  11044. private _negativeCurve;
  11045. private _globalHue;
  11046. private _globalDensity;
  11047. private _globalSaturation;
  11048. private _globalExposure;
  11049. /**
  11050. * Gets the global Hue value.
  11051. * 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).
  11052. */
  11053. get globalHue(): number;
  11054. /**
  11055. * Sets the global Hue value.
  11056. * 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).
  11057. */
  11058. set globalHue(value: number);
  11059. /**
  11060. * Gets the global Density value.
  11061. * 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.
  11062. * Values less than zero provide a filter of opposite hue.
  11063. */
  11064. get globalDensity(): number;
  11065. /**
  11066. * Sets the global Density value.
  11067. * 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.
  11068. * Values less than zero provide a filter of opposite hue.
  11069. */
  11070. set globalDensity(value: number);
  11071. /**
  11072. * Gets the global Saturation value.
  11073. * 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.
  11074. */
  11075. get globalSaturation(): number;
  11076. /**
  11077. * Sets the global Saturation value.
  11078. * 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.
  11079. */
  11080. set globalSaturation(value: number);
  11081. /**
  11082. * Gets the global Exposure value.
  11083. * 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.
  11084. */
  11085. get globalExposure(): number;
  11086. /**
  11087. * Sets the global Exposure value.
  11088. * 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.
  11089. */
  11090. set globalExposure(value: number);
  11091. private _highlightsHue;
  11092. private _highlightsDensity;
  11093. private _highlightsSaturation;
  11094. private _highlightsExposure;
  11095. /**
  11096. * Gets the highlights Hue value.
  11097. * 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).
  11098. */
  11099. get highlightsHue(): number;
  11100. /**
  11101. * Sets the highlights Hue value.
  11102. * 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).
  11103. */
  11104. set highlightsHue(value: number);
  11105. /**
  11106. * Gets the highlights Density value.
  11107. * 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.
  11108. * Values less than zero provide a filter of opposite hue.
  11109. */
  11110. get highlightsDensity(): number;
  11111. /**
  11112. * Sets the highlights Density value.
  11113. * 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.
  11114. * Values less than zero provide a filter of opposite hue.
  11115. */
  11116. set highlightsDensity(value: number);
  11117. /**
  11118. * Gets the highlights Saturation value.
  11119. * 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.
  11120. */
  11121. get highlightsSaturation(): number;
  11122. /**
  11123. * Sets the highlights Saturation value.
  11124. * 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.
  11125. */
  11126. set highlightsSaturation(value: number);
  11127. /**
  11128. * Gets the highlights Exposure value.
  11129. * 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.
  11130. */
  11131. get highlightsExposure(): number;
  11132. /**
  11133. * Sets the highlights Exposure value.
  11134. * 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.
  11135. */
  11136. set highlightsExposure(value: number);
  11137. private _midtonesHue;
  11138. private _midtonesDensity;
  11139. private _midtonesSaturation;
  11140. private _midtonesExposure;
  11141. /**
  11142. * Gets the midtones Hue value.
  11143. * 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).
  11144. */
  11145. get midtonesHue(): number;
  11146. /**
  11147. * Sets the midtones Hue value.
  11148. * 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).
  11149. */
  11150. set midtonesHue(value: number);
  11151. /**
  11152. * Gets the midtones Density value.
  11153. * 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.
  11154. * Values less than zero provide a filter of opposite hue.
  11155. */
  11156. get midtonesDensity(): number;
  11157. /**
  11158. * Sets the midtones Density value.
  11159. * 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.
  11160. * Values less than zero provide a filter of opposite hue.
  11161. */
  11162. set midtonesDensity(value: number);
  11163. /**
  11164. * Gets the midtones Saturation value.
  11165. * 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.
  11166. */
  11167. get midtonesSaturation(): number;
  11168. /**
  11169. * Sets the midtones Saturation value.
  11170. * 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.
  11171. */
  11172. set midtonesSaturation(value: number);
  11173. /**
  11174. * Gets the midtones Exposure value.
  11175. * 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.
  11176. */
  11177. get midtonesExposure(): number;
  11178. /**
  11179. * Sets the midtones Exposure value.
  11180. * 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.
  11181. */
  11182. set midtonesExposure(value: number);
  11183. private _shadowsHue;
  11184. private _shadowsDensity;
  11185. private _shadowsSaturation;
  11186. private _shadowsExposure;
  11187. /**
  11188. * Gets the shadows Hue value.
  11189. * 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).
  11190. */
  11191. get shadowsHue(): number;
  11192. /**
  11193. * Sets the shadows Hue value.
  11194. * 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).
  11195. */
  11196. set shadowsHue(value: number);
  11197. /**
  11198. * Gets the shadows Density value.
  11199. * 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.
  11200. * Values less than zero provide a filter of opposite hue.
  11201. */
  11202. get shadowsDensity(): number;
  11203. /**
  11204. * Sets the shadows Density value.
  11205. * 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.
  11206. * Values less than zero provide a filter of opposite hue.
  11207. */
  11208. set shadowsDensity(value: number);
  11209. /**
  11210. * Gets the shadows Saturation value.
  11211. * 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.
  11212. */
  11213. get shadowsSaturation(): number;
  11214. /**
  11215. * Sets the shadows Saturation value.
  11216. * 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.
  11217. */
  11218. set shadowsSaturation(value: number);
  11219. /**
  11220. * Gets the shadows Exposure value.
  11221. * 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.
  11222. */
  11223. get shadowsExposure(): number;
  11224. /**
  11225. * Sets the shadows Exposure value.
  11226. * 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.
  11227. */
  11228. set shadowsExposure(value: number);
  11229. /**
  11230. * Returns the class name
  11231. * @returns The class name
  11232. */
  11233. getClassName(): string;
  11234. /**
  11235. * Binds the color curves to the shader.
  11236. * @param colorCurves The color curve to bind
  11237. * @param effect The effect to bind to
  11238. * @param positiveUniform The positive uniform shader parameter
  11239. * @param neutralUniform The neutral uniform shader parameter
  11240. * @param negativeUniform The negative uniform shader parameter
  11241. */
  11242. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11243. /**
  11244. * Prepare the list of uniforms associated with the ColorCurves effects.
  11245. * @param uniformsList The list of uniforms used in the effect
  11246. */
  11247. static PrepareUniforms(uniformsList: string[]): void;
  11248. /**
  11249. * Returns color grading data based on a hue, density, saturation and exposure value.
  11250. * @param filterHue The hue of the color filter.
  11251. * @param filterDensity The density of the color filter.
  11252. * @param saturation The saturation.
  11253. * @param exposure The exposure.
  11254. * @param result The result data container.
  11255. */
  11256. private getColorGradingDataToRef;
  11257. /**
  11258. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11259. * @param value The input slider value in range [-100,100].
  11260. * @returns Adjusted value.
  11261. */
  11262. private static applyColorGradingSliderNonlinear;
  11263. /**
  11264. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11265. * @param hue The hue (H) input.
  11266. * @param saturation The saturation (S) input.
  11267. * @param brightness The brightness (B) input.
  11268. * @result An RGBA color represented as Vector4.
  11269. */
  11270. private static fromHSBToRef;
  11271. /**
  11272. * Returns a value clamped between min and max
  11273. * @param value The value to clamp
  11274. * @param min The minimum of value
  11275. * @param max The maximum of value
  11276. * @returns The clamped value.
  11277. */
  11278. private static clamp;
  11279. /**
  11280. * Clones the current color curve instance.
  11281. * @return The cloned curves
  11282. */
  11283. clone(): ColorCurves;
  11284. /**
  11285. * Serializes the current color curve instance to a json representation.
  11286. * @return a JSON representation
  11287. */
  11288. serialize(): any;
  11289. /**
  11290. * Parses the color curve from a json representation.
  11291. * @param source the JSON source to parse
  11292. * @return The parsed curves
  11293. */
  11294. static Parse(source: any): ColorCurves;
  11295. }
  11296. }
  11297. declare module BABYLON {
  11298. /**
  11299. * Interface to follow in your material defines to integrate easily the
  11300. * Image proccessing functions.
  11301. * @hidden
  11302. */
  11303. export interface IImageProcessingConfigurationDefines {
  11304. IMAGEPROCESSING: boolean;
  11305. VIGNETTE: boolean;
  11306. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11307. VIGNETTEBLENDMODEOPAQUE: boolean;
  11308. TONEMAPPING: boolean;
  11309. TONEMAPPING_ACES: boolean;
  11310. CONTRAST: boolean;
  11311. EXPOSURE: boolean;
  11312. COLORCURVES: boolean;
  11313. COLORGRADING: boolean;
  11314. COLORGRADING3D: boolean;
  11315. SAMPLER3DGREENDEPTH: boolean;
  11316. SAMPLER3DBGRMAP: boolean;
  11317. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11318. }
  11319. /**
  11320. * @hidden
  11321. */
  11322. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11323. IMAGEPROCESSING: boolean;
  11324. VIGNETTE: boolean;
  11325. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11326. VIGNETTEBLENDMODEOPAQUE: boolean;
  11327. TONEMAPPING: boolean;
  11328. TONEMAPPING_ACES: boolean;
  11329. CONTRAST: boolean;
  11330. COLORCURVES: boolean;
  11331. COLORGRADING: boolean;
  11332. COLORGRADING3D: boolean;
  11333. SAMPLER3DGREENDEPTH: boolean;
  11334. SAMPLER3DBGRMAP: boolean;
  11335. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11336. EXPOSURE: boolean;
  11337. constructor();
  11338. }
  11339. /**
  11340. * This groups together the common properties used for image processing either in direct forward pass
  11341. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11342. * or not.
  11343. */
  11344. export class ImageProcessingConfiguration {
  11345. /**
  11346. * Default tone mapping applied in BabylonJS.
  11347. */
  11348. static readonly TONEMAPPING_STANDARD: number;
  11349. /**
  11350. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11351. * to other engines rendering to increase portability.
  11352. */
  11353. static readonly TONEMAPPING_ACES: number;
  11354. /**
  11355. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11356. */
  11357. colorCurves: Nullable<ColorCurves>;
  11358. private _colorCurvesEnabled;
  11359. /**
  11360. * Gets wether the color curves effect is enabled.
  11361. */
  11362. get colorCurvesEnabled(): boolean;
  11363. /**
  11364. * Sets wether the color curves effect is enabled.
  11365. */
  11366. set colorCurvesEnabled(value: boolean);
  11367. private _colorGradingTexture;
  11368. /**
  11369. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11370. */
  11371. get colorGradingTexture(): Nullable<BaseTexture>;
  11372. /**
  11373. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11374. */
  11375. set colorGradingTexture(value: Nullable<BaseTexture>);
  11376. private _colorGradingEnabled;
  11377. /**
  11378. * Gets wether the color grading effect is enabled.
  11379. */
  11380. get colorGradingEnabled(): boolean;
  11381. /**
  11382. * Sets wether the color grading effect is enabled.
  11383. */
  11384. set colorGradingEnabled(value: boolean);
  11385. private _colorGradingWithGreenDepth;
  11386. /**
  11387. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11388. */
  11389. get colorGradingWithGreenDepth(): boolean;
  11390. /**
  11391. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11392. */
  11393. set colorGradingWithGreenDepth(value: boolean);
  11394. private _colorGradingBGR;
  11395. /**
  11396. * Gets wether the color grading texture contains BGR values.
  11397. */
  11398. get colorGradingBGR(): boolean;
  11399. /**
  11400. * Sets wether the color grading texture contains BGR values.
  11401. */
  11402. set colorGradingBGR(value: boolean);
  11403. /** @hidden */
  11404. _exposure: number;
  11405. /**
  11406. * Gets the Exposure used in the effect.
  11407. */
  11408. get exposure(): number;
  11409. /**
  11410. * Sets the Exposure used in the effect.
  11411. */
  11412. set exposure(value: number);
  11413. private _toneMappingEnabled;
  11414. /**
  11415. * Gets wether the tone mapping effect is enabled.
  11416. */
  11417. get toneMappingEnabled(): boolean;
  11418. /**
  11419. * Sets wether the tone mapping effect is enabled.
  11420. */
  11421. set toneMappingEnabled(value: boolean);
  11422. private _toneMappingType;
  11423. /**
  11424. * Gets the type of tone mapping effect.
  11425. */
  11426. get toneMappingType(): number;
  11427. /**
  11428. * Sets the type of tone mapping effect used in BabylonJS.
  11429. */
  11430. set toneMappingType(value: number);
  11431. protected _contrast: number;
  11432. /**
  11433. * Gets the contrast used in the effect.
  11434. */
  11435. get contrast(): number;
  11436. /**
  11437. * Sets the contrast used in the effect.
  11438. */
  11439. set contrast(value: number);
  11440. /**
  11441. * Vignette stretch size.
  11442. */
  11443. vignetteStretch: number;
  11444. /**
  11445. * Vignette centre X Offset.
  11446. */
  11447. vignetteCentreX: number;
  11448. /**
  11449. * Vignette centre Y Offset.
  11450. */
  11451. vignetteCentreY: number;
  11452. /**
  11453. * Vignette weight or intensity of the vignette effect.
  11454. */
  11455. vignetteWeight: number;
  11456. /**
  11457. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11458. * if vignetteEnabled is set to true.
  11459. */
  11460. vignetteColor: Color4;
  11461. /**
  11462. * Camera field of view used by the Vignette effect.
  11463. */
  11464. vignetteCameraFov: number;
  11465. private _vignetteBlendMode;
  11466. /**
  11467. * Gets the vignette blend mode allowing different kind of effect.
  11468. */
  11469. get vignetteBlendMode(): number;
  11470. /**
  11471. * Sets the vignette blend mode allowing different kind of effect.
  11472. */
  11473. set vignetteBlendMode(value: number);
  11474. private _vignetteEnabled;
  11475. /**
  11476. * Gets wether the vignette effect is enabled.
  11477. */
  11478. get vignetteEnabled(): boolean;
  11479. /**
  11480. * Sets wether the vignette effect is enabled.
  11481. */
  11482. set vignetteEnabled(value: boolean);
  11483. private _applyByPostProcess;
  11484. /**
  11485. * Gets wether the image processing is applied through a post process or not.
  11486. */
  11487. get applyByPostProcess(): boolean;
  11488. /**
  11489. * Sets wether the image processing is applied through a post process or not.
  11490. */
  11491. set applyByPostProcess(value: boolean);
  11492. private _isEnabled;
  11493. /**
  11494. * Gets wether the image processing is enabled or not.
  11495. */
  11496. get isEnabled(): boolean;
  11497. /**
  11498. * Sets wether the image processing is enabled or not.
  11499. */
  11500. set isEnabled(value: boolean);
  11501. /**
  11502. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11503. */
  11504. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11505. /**
  11506. * Method called each time the image processing information changes requires to recompile the effect.
  11507. */
  11508. protected _updateParameters(): void;
  11509. /**
  11510. * Gets the current class name.
  11511. * @return "ImageProcessingConfiguration"
  11512. */
  11513. getClassName(): string;
  11514. /**
  11515. * Prepare the list of uniforms associated with the Image Processing effects.
  11516. * @param uniforms The list of uniforms used in the effect
  11517. * @param defines the list of defines currently in use
  11518. */
  11519. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11520. /**
  11521. * Prepare the list of samplers associated with the Image Processing effects.
  11522. * @param samplersList The list of uniforms used in the effect
  11523. * @param defines the list of defines currently in use
  11524. */
  11525. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11526. /**
  11527. * Prepare the list of defines associated to the shader.
  11528. * @param defines the list of defines to complete
  11529. * @param forPostProcess Define if we are currently in post process mode or not
  11530. */
  11531. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11532. /**
  11533. * Returns true if all the image processing information are ready.
  11534. * @returns True if ready, otherwise, false
  11535. */
  11536. isReady(): boolean;
  11537. /**
  11538. * Binds the image processing to the shader.
  11539. * @param effect The effect to bind to
  11540. * @param overrideAspectRatio Override the aspect ratio of the effect
  11541. */
  11542. bind(effect: Effect, overrideAspectRatio?: number): void;
  11543. /**
  11544. * Clones the current image processing instance.
  11545. * @return The cloned image processing
  11546. */
  11547. clone(): ImageProcessingConfiguration;
  11548. /**
  11549. * Serializes the current image processing instance to a json representation.
  11550. * @return a JSON representation
  11551. */
  11552. serialize(): any;
  11553. /**
  11554. * Parses the image processing from a json representation.
  11555. * @param source the JSON source to parse
  11556. * @return The parsed image processing
  11557. */
  11558. static Parse(source: any): ImageProcessingConfiguration;
  11559. private static _VIGNETTEMODE_MULTIPLY;
  11560. private static _VIGNETTEMODE_OPAQUE;
  11561. /**
  11562. * Used to apply the vignette as a mix with the pixel color.
  11563. */
  11564. static get VIGNETTEMODE_MULTIPLY(): number;
  11565. /**
  11566. * Used to apply the vignette as a replacement of the pixel color.
  11567. */
  11568. static get VIGNETTEMODE_OPAQUE(): number;
  11569. }
  11570. }
  11571. declare module BABYLON {
  11572. /** @hidden */
  11573. export var postprocessVertexShader: {
  11574. name: string;
  11575. shader: string;
  11576. };
  11577. }
  11578. declare module BABYLON {
  11579. /**
  11580. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11581. */
  11582. export type RenderTargetTextureSize = number | {
  11583. width: number;
  11584. height: number;
  11585. layers?: number;
  11586. };
  11587. interface ThinEngine {
  11588. /**
  11589. * Creates a new render target texture
  11590. * @param size defines the size of the texture
  11591. * @param options defines the options used to create the texture
  11592. * @returns a new render target texture stored in an InternalTexture
  11593. */
  11594. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11595. /**
  11596. * Creates a depth stencil texture.
  11597. * This is only available in WebGL 2 or with the depth texture extension available.
  11598. * @param size The size of face edge in the texture.
  11599. * @param options The options defining the texture.
  11600. * @returns The texture
  11601. */
  11602. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11603. /** @hidden */
  11604. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11605. }
  11606. }
  11607. declare module BABYLON {
  11608. /**
  11609. * Defines the kind of connection point for node based material
  11610. */
  11611. export enum NodeMaterialBlockConnectionPointTypes {
  11612. /** Float */
  11613. Float = 1,
  11614. /** Int */
  11615. Int = 2,
  11616. /** Vector2 */
  11617. Vector2 = 4,
  11618. /** Vector3 */
  11619. Vector3 = 8,
  11620. /** Vector4 */
  11621. Vector4 = 16,
  11622. /** Color3 */
  11623. Color3 = 32,
  11624. /** Color4 */
  11625. Color4 = 64,
  11626. /** Matrix */
  11627. Matrix = 128,
  11628. /** Custom object */
  11629. Object = 256,
  11630. /** Detect type based on connection */
  11631. AutoDetect = 1024,
  11632. /** Output type that will be defined by input type */
  11633. BasedOnInput = 2048
  11634. }
  11635. }
  11636. declare module BABYLON {
  11637. /**
  11638. * Enum used to define the target of a block
  11639. */
  11640. export enum NodeMaterialBlockTargets {
  11641. /** Vertex shader */
  11642. Vertex = 1,
  11643. /** Fragment shader */
  11644. Fragment = 2,
  11645. /** Neutral */
  11646. Neutral = 4,
  11647. /** Vertex and Fragment */
  11648. VertexAndFragment = 3
  11649. }
  11650. }
  11651. declare module BABYLON {
  11652. /**
  11653. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11654. */
  11655. export enum NodeMaterialBlockConnectionPointMode {
  11656. /** Value is an uniform */
  11657. Uniform = 0,
  11658. /** Value is a mesh attribute */
  11659. Attribute = 1,
  11660. /** Value is a varying between vertex and fragment shaders */
  11661. Varying = 2,
  11662. /** Mode is undefined */
  11663. Undefined = 3
  11664. }
  11665. }
  11666. declare module BABYLON {
  11667. /**
  11668. * Enum used to define system values e.g. values automatically provided by the system
  11669. */
  11670. export enum NodeMaterialSystemValues {
  11671. /** World */
  11672. World = 1,
  11673. /** View */
  11674. View = 2,
  11675. /** Projection */
  11676. Projection = 3,
  11677. /** ViewProjection */
  11678. ViewProjection = 4,
  11679. /** WorldView */
  11680. WorldView = 5,
  11681. /** WorldViewProjection */
  11682. WorldViewProjection = 6,
  11683. /** CameraPosition */
  11684. CameraPosition = 7,
  11685. /** Fog Color */
  11686. FogColor = 8,
  11687. /** Delta time */
  11688. DeltaTime = 9
  11689. }
  11690. }
  11691. declare module BABYLON {
  11692. /**
  11693. * Represents a camera frustum
  11694. */
  11695. export class Frustum {
  11696. /**
  11697. * Gets the planes representing the frustum
  11698. * @param transform matrix to be applied to the returned planes
  11699. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11700. */
  11701. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11702. /**
  11703. * Gets the near frustum plane transformed by the transform matrix
  11704. * @param transform transformation matrix to be applied to the resulting frustum plane
  11705. * @param frustumPlane the resuling frustum plane
  11706. */
  11707. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11708. /**
  11709. * Gets the far frustum plane transformed by the transform matrix
  11710. * @param transform transformation matrix to be applied to the resulting frustum plane
  11711. * @param frustumPlane the resuling frustum plane
  11712. */
  11713. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11714. /**
  11715. * Gets the left frustum plane transformed by the transform matrix
  11716. * @param transform transformation matrix to be applied to the resulting frustum plane
  11717. * @param frustumPlane the resuling frustum plane
  11718. */
  11719. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11720. /**
  11721. * Gets the right frustum plane transformed by the transform matrix
  11722. * @param transform transformation matrix to be applied to the resulting frustum plane
  11723. * @param frustumPlane the resuling frustum plane
  11724. */
  11725. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11726. /**
  11727. * Gets the top frustum plane transformed by the transform matrix
  11728. * @param transform transformation matrix to be applied to the resulting frustum plane
  11729. * @param frustumPlane the resuling frustum plane
  11730. */
  11731. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11732. /**
  11733. * Gets the bottom frustum plane transformed by the transform matrix
  11734. * @param transform transformation matrix to be applied to the resulting frustum plane
  11735. * @param frustumPlane the resuling frustum plane
  11736. */
  11737. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11738. /**
  11739. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11740. * @param transform transformation matrix to be applied to the resulting frustum planes
  11741. * @param frustumPlanes the resuling frustum planes
  11742. */
  11743. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11744. }
  11745. }
  11746. declare module BABYLON {
  11747. /**
  11748. * Contains position and normal vectors for a vertex
  11749. */
  11750. export class PositionNormalVertex {
  11751. /** the position of the vertex (defaut: 0,0,0) */
  11752. position: Vector3;
  11753. /** the normal of the vertex (defaut: 0,1,0) */
  11754. normal: Vector3;
  11755. /**
  11756. * Creates a PositionNormalVertex
  11757. * @param position the position of the vertex (defaut: 0,0,0)
  11758. * @param normal the normal of the vertex (defaut: 0,1,0)
  11759. */
  11760. constructor(
  11761. /** the position of the vertex (defaut: 0,0,0) */
  11762. position?: Vector3,
  11763. /** the normal of the vertex (defaut: 0,1,0) */
  11764. normal?: Vector3);
  11765. /**
  11766. * Clones the PositionNormalVertex
  11767. * @returns the cloned PositionNormalVertex
  11768. */
  11769. clone(): PositionNormalVertex;
  11770. }
  11771. /**
  11772. * Contains position, normal and uv vectors for a vertex
  11773. */
  11774. export class PositionNormalTextureVertex {
  11775. /** the position of the vertex (defaut: 0,0,0) */
  11776. position: Vector3;
  11777. /** the normal of the vertex (defaut: 0,1,0) */
  11778. normal: Vector3;
  11779. /** the uv of the vertex (default: 0,0) */
  11780. uv: Vector2;
  11781. /**
  11782. * Creates a PositionNormalTextureVertex
  11783. * @param position the position of the vertex (defaut: 0,0,0)
  11784. * @param normal the normal of the vertex (defaut: 0,1,0)
  11785. * @param uv the uv of the vertex (default: 0,0)
  11786. */
  11787. constructor(
  11788. /** the position of the vertex (defaut: 0,0,0) */
  11789. position?: Vector3,
  11790. /** the normal of the vertex (defaut: 0,1,0) */
  11791. normal?: Vector3,
  11792. /** the uv of the vertex (default: 0,0) */
  11793. uv?: Vector2);
  11794. /**
  11795. * Clones the PositionNormalTextureVertex
  11796. * @returns the cloned PositionNormalTextureVertex
  11797. */
  11798. clone(): PositionNormalTextureVertex;
  11799. }
  11800. }
  11801. declare module BABYLON {
  11802. /**
  11803. * Enum defining the type of animations supported by InputBlock
  11804. */
  11805. export enum AnimatedInputBlockTypes {
  11806. /** No animation */
  11807. None = 0,
  11808. /** Time based animation. Will only work for floats */
  11809. Time = 1
  11810. }
  11811. }
  11812. declare module BABYLON {
  11813. /**
  11814. * Block used to expose an input value
  11815. */
  11816. export class InputBlock extends NodeMaterialBlock {
  11817. private _mode;
  11818. private _associatedVariableName;
  11819. private _storedValue;
  11820. private _valueCallback;
  11821. private _type;
  11822. private _animationType;
  11823. /** Gets or set a value used to limit the range of float values */
  11824. min: number;
  11825. /** Gets or set a value used to limit the range of float values */
  11826. max: number;
  11827. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  11828. isBoolean: boolean;
  11829. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  11830. matrixMode: number;
  11831. /** @hidden */
  11832. _systemValue: Nullable<NodeMaterialSystemValues>;
  11833. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  11834. isConstant: boolean;
  11835. /** Gets or sets the group to use to display this block in the Inspector */
  11836. groupInInspector: string;
  11837. /** Gets an observable raised when the value is changed */
  11838. onValueChangedObservable: Observable<InputBlock>;
  11839. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  11840. convertToGammaSpace: boolean;
  11841. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  11842. convertToLinearSpace: boolean;
  11843. /**
  11844. * Gets or sets the connection point type (default is float)
  11845. */
  11846. get type(): NodeMaterialBlockConnectionPointTypes;
  11847. /**
  11848. * Creates a new InputBlock
  11849. * @param name defines the block name
  11850. * @param target defines the target of that block (Vertex by default)
  11851. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  11852. */
  11853. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  11854. /**
  11855. * Validates if a name is a reserve word.
  11856. * @param newName the new name to be given to the node.
  11857. * @returns false if the name is a reserve word, else true.
  11858. */
  11859. validateBlockName(newName: string): boolean;
  11860. /**
  11861. * Gets the output component
  11862. */
  11863. get output(): NodeMaterialConnectionPoint;
  11864. /**
  11865. * Set the source of this connection point to a vertex attribute
  11866. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  11867. * @returns the current connection point
  11868. */
  11869. setAsAttribute(attributeName?: string): InputBlock;
  11870. /**
  11871. * Set the source of this connection point to a system value
  11872. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  11873. * @returns the current connection point
  11874. */
  11875. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  11876. /**
  11877. * Gets or sets the value of that point.
  11878. * Please note that this value will be ignored if valueCallback is defined
  11879. */
  11880. get value(): any;
  11881. set value(value: any);
  11882. /**
  11883. * Gets or sets a callback used to get the value of that point.
  11884. * Please note that setting this value will force the connection point to ignore the value property
  11885. */
  11886. get valueCallback(): () => any;
  11887. set valueCallback(value: () => any);
  11888. /**
  11889. * Gets or sets the associated variable name in the shader
  11890. */
  11891. get associatedVariableName(): string;
  11892. set associatedVariableName(value: string);
  11893. /** Gets or sets the type of animation applied to the input */
  11894. get animationType(): AnimatedInputBlockTypes;
  11895. set animationType(value: AnimatedInputBlockTypes);
  11896. /**
  11897. * Gets a boolean indicating that this connection point not defined yet
  11898. */
  11899. get isUndefined(): boolean;
  11900. /**
  11901. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  11902. * In this case the connection point name must be the name of the uniform to use.
  11903. * Can only be set on inputs
  11904. */
  11905. get isUniform(): boolean;
  11906. set isUniform(value: boolean);
  11907. /**
  11908. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  11909. * In this case the connection point name must be the name of the attribute to use
  11910. * Can only be set on inputs
  11911. */
  11912. get isAttribute(): boolean;
  11913. set isAttribute(value: boolean);
  11914. /**
  11915. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  11916. * Can only be set on exit points
  11917. */
  11918. get isVarying(): boolean;
  11919. set isVarying(value: boolean);
  11920. /**
  11921. * Gets a boolean indicating that the current connection point is a system value
  11922. */
  11923. get isSystemValue(): boolean;
  11924. /**
  11925. * Gets or sets the current well known value or null if not defined as a system value
  11926. */
  11927. get systemValue(): Nullable<NodeMaterialSystemValues>;
  11928. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  11929. /**
  11930. * Gets the current class name
  11931. * @returns the class name
  11932. */
  11933. getClassName(): string;
  11934. /**
  11935. * Animate the input if animationType !== None
  11936. * @param scene defines the rendering scene
  11937. */
  11938. animate(scene: Scene): void;
  11939. private _emitDefine;
  11940. initialize(state: NodeMaterialBuildState): void;
  11941. /**
  11942. * Set the input block to its default value (based on its type)
  11943. */
  11944. setDefaultValue(): void;
  11945. private _emitConstant;
  11946. /** @hidden */
  11947. get _noContextSwitch(): boolean;
  11948. private _emit;
  11949. /** @hidden */
  11950. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  11951. /** @hidden */
  11952. _transmit(effect: Effect, scene: Scene): void;
  11953. protected _buildBlock(state: NodeMaterialBuildState): void;
  11954. protected _dumpPropertiesCode(): string;
  11955. dispose(): void;
  11956. serialize(): any;
  11957. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  11958. }
  11959. }
  11960. declare module BABYLON {
  11961. /**
  11962. * Enum used to define the compatibility state between two connection points
  11963. */
  11964. export enum NodeMaterialConnectionPointCompatibilityStates {
  11965. /** Points are compatibles */
  11966. Compatible = 0,
  11967. /** Points are incompatible because of their types */
  11968. TypeIncompatible = 1,
  11969. /** Points are incompatible because of their targets (vertex vs fragment) */
  11970. TargetIncompatible = 2
  11971. }
  11972. /**
  11973. * Defines the direction of a connection point
  11974. */
  11975. export enum NodeMaterialConnectionPointDirection {
  11976. /** Input */
  11977. Input = 0,
  11978. /** Output */
  11979. Output = 1
  11980. }
  11981. /**
  11982. * Defines a connection point for a block
  11983. */
  11984. export class NodeMaterialConnectionPoint {
  11985. /**
  11986. * Checks if two types are equivalent
  11987. * @param type1 type 1 to check
  11988. * @param type2 type 2 to check
  11989. * @returns true if both types are equivalent, else false
  11990. */
  11991. static AreEquivalentTypes(type1: number, type2: number): boolean;
  11992. /** @hidden */
  11993. _ownerBlock: NodeMaterialBlock;
  11994. /** @hidden */
  11995. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  11996. private _endpoints;
  11997. private _associatedVariableName;
  11998. private _direction;
  11999. /** @hidden */
  12000. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12001. /** @hidden */
  12002. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12003. /** @hidden */
  12004. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12005. private _type;
  12006. /** @hidden */
  12007. _enforceAssociatedVariableName: boolean;
  12008. /** Gets the direction of the point */
  12009. get direction(): NodeMaterialConnectionPointDirection;
  12010. /** Indicates that this connection point needs dual validation before being connected to another point */
  12011. needDualDirectionValidation: boolean;
  12012. /**
  12013. * Gets or sets the additional types supported by this connection point
  12014. */
  12015. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12016. /**
  12017. * Gets or sets the additional types excluded by this connection point
  12018. */
  12019. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12020. /**
  12021. * Observable triggered when this point is connected
  12022. */
  12023. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12024. /**
  12025. * Gets or sets the associated variable name in the shader
  12026. */
  12027. get associatedVariableName(): string;
  12028. set associatedVariableName(value: string);
  12029. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12030. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12031. /**
  12032. * Gets or sets the connection point type (default is float)
  12033. */
  12034. get type(): NodeMaterialBlockConnectionPointTypes;
  12035. set type(value: NodeMaterialBlockConnectionPointTypes);
  12036. /**
  12037. * Gets or sets the connection point name
  12038. */
  12039. name: string;
  12040. /**
  12041. * Gets or sets the connection point name
  12042. */
  12043. displayName: string;
  12044. /**
  12045. * Gets or sets a boolean indicating that this connection point can be omitted
  12046. */
  12047. isOptional: boolean;
  12048. /**
  12049. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12050. */
  12051. isExposedOnFrame: boolean;
  12052. /**
  12053. * Gets or sets number indicating the position that the port is exposed to on a frame
  12054. */
  12055. exposedPortPosition: number;
  12056. /**
  12057. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12058. */
  12059. define: string;
  12060. /** @hidden */
  12061. _prioritizeVertex: boolean;
  12062. private _target;
  12063. /** Gets or sets the target of that connection point */
  12064. get target(): NodeMaterialBlockTargets;
  12065. set target(value: NodeMaterialBlockTargets);
  12066. /**
  12067. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12068. */
  12069. get isConnected(): boolean;
  12070. /**
  12071. * Gets a boolean indicating that the current point is connected to an input block
  12072. */
  12073. get isConnectedToInputBlock(): boolean;
  12074. /**
  12075. * Gets a the connected input block (if any)
  12076. */
  12077. get connectInputBlock(): Nullable<InputBlock>;
  12078. /** Get the other side of the connection (if any) */
  12079. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12080. /** Get the block that owns this connection point */
  12081. get ownerBlock(): NodeMaterialBlock;
  12082. /** Get the block connected on the other side of this connection (if any) */
  12083. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12084. /** Get the block connected on the endpoints of this connection (if any) */
  12085. get connectedBlocks(): Array<NodeMaterialBlock>;
  12086. /** Gets the list of connected endpoints */
  12087. get endpoints(): NodeMaterialConnectionPoint[];
  12088. /** Gets a boolean indicating if that output point is connected to at least one input */
  12089. get hasEndpoints(): boolean;
  12090. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12091. get isConnectedInVertexShader(): boolean;
  12092. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12093. get isConnectedInFragmentShader(): boolean;
  12094. /**
  12095. * Creates a block suitable to be used as an input for this input point.
  12096. * If null is returned, a block based on the point type will be created.
  12097. * @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
  12098. */
  12099. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12100. /**
  12101. * Creates a new connection point
  12102. * @param name defines the connection point name
  12103. * @param ownerBlock defines the block hosting this connection point
  12104. * @param direction defines the direction of the connection point
  12105. */
  12106. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12107. /**
  12108. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12109. * @returns the class name
  12110. */
  12111. getClassName(): string;
  12112. /**
  12113. * Gets a boolean indicating if the current point can be connected to another point
  12114. * @param connectionPoint defines the other connection point
  12115. * @returns a boolean
  12116. */
  12117. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12118. /**
  12119. * Gets a number indicating if the current point can be connected to another point
  12120. * @param connectionPoint defines the other connection point
  12121. * @returns a number defining the compatibility state
  12122. */
  12123. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12124. /**
  12125. * Connect this point to another connection point
  12126. * @param connectionPoint defines the other connection point
  12127. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12128. * @returns the current connection point
  12129. */
  12130. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12131. /**
  12132. * Disconnect this point from one of his endpoint
  12133. * @param endpoint defines the other connection point
  12134. * @returns the current connection point
  12135. */
  12136. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12137. /**
  12138. * Serializes this point in a JSON representation
  12139. * @param isInput defines if the connection point is an input (default is true)
  12140. * @returns the serialized point object
  12141. */
  12142. serialize(isInput?: boolean): any;
  12143. /**
  12144. * Release resources
  12145. */
  12146. dispose(): void;
  12147. }
  12148. }
  12149. declare module BABYLON {
  12150. /**
  12151. * Enum used to define the material modes
  12152. */
  12153. export enum NodeMaterialModes {
  12154. /** Regular material */
  12155. Material = 0,
  12156. /** For post process */
  12157. PostProcess = 1,
  12158. /** For particle system */
  12159. Particle = 2,
  12160. /** For procedural texture */
  12161. ProceduralTexture = 3
  12162. }
  12163. }
  12164. declare module BABYLON {
  12165. /** @hidden */
  12166. export var helperFunctions: {
  12167. name: string;
  12168. shader: string;
  12169. };
  12170. }
  12171. declare module BABYLON {
  12172. /**
  12173. * Block used to read a texture from a sampler
  12174. */
  12175. export class TextureBlock extends NodeMaterialBlock {
  12176. private _defineName;
  12177. private _linearDefineName;
  12178. private _gammaDefineName;
  12179. private _tempTextureRead;
  12180. private _samplerName;
  12181. private _transformedUVName;
  12182. private _textureTransformName;
  12183. private _textureInfoName;
  12184. private _mainUVName;
  12185. private _mainUVDefineName;
  12186. private _fragmentOnly;
  12187. /**
  12188. * Gets or sets the texture associated with the node
  12189. */
  12190. texture: Nullable<Texture>;
  12191. /**
  12192. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12193. */
  12194. convertToGammaSpace: boolean;
  12195. /**
  12196. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12197. */
  12198. convertToLinearSpace: boolean;
  12199. /**
  12200. * Create a new TextureBlock
  12201. * @param name defines the block name
  12202. */
  12203. constructor(name: string, fragmentOnly?: boolean);
  12204. /**
  12205. * Gets the current class name
  12206. * @returns the class name
  12207. */
  12208. getClassName(): string;
  12209. /**
  12210. * Gets the uv input component
  12211. */
  12212. get uv(): NodeMaterialConnectionPoint;
  12213. /**
  12214. * Gets the rgba output component
  12215. */
  12216. get rgba(): NodeMaterialConnectionPoint;
  12217. /**
  12218. * Gets the rgb output component
  12219. */
  12220. get rgb(): NodeMaterialConnectionPoint;
  12221. /**
  12222. * Gets the r output component
  12223. */
  12224. get r(): NodeMaterialConnectionPoint;
  12225. /**
  12226. * Gets the g output component
  12227. */
  12228. get g(): NodeMaterialConnectionPoint;
  12229. /**
  12230. * Gets the b output component
  12231. */
  12232. get b(): NodeMaterialConnectionPoint;
  12233. /**
  12234. * Gets the a output component
  12235. */
  12236. get a(): NodeMaterialConnectionPoint;
  12237. get target(): NodeMaterialBlockTargets;
  12238. autoConfigure(material: NodeMaterial): void;
  12239. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12240. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12241. isReady(): boolean;
  12242. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12243. private get _isMixed();
  12244. private _injectVertexCode;
  12245. private _writeTextureRead;
  12246. private _writeOutput;
  12247. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12248. protected _dumpPropertiesCode(): string;
  12249. serialize(): any;
  12250. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12251. }
  12252. }
  12253. declare module BABYLON {
  12254. /** @hidden */
  12255. export var reflectionFunction: {
  12256. name: string;
  12257. shader: string;
  12258. };
  12259. }
  12260. declare module BABYLON {
  12261. /**
  12262. * Base block used to read a reflection texture from a sampler
  12263. */
  12264. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12265. /** @hidden */
  12266. _define3DName: string;
  12267. /** @hidden */
  12268. _defineCubicName: string;
  12269. /** @hidden */
  12270. _defineExplicitName: string;
  12271. /** @hidden */
  12272. _defineProjectionName: string;
  12273. /** @hidden */
  12274. _defineLocalCubicName: string;
  12275. /** @hidden */
  12276. _defineSphericalName: string;
  12277. /** @hidden */
  12278. _definePlanarName: string;
  12279. /** @hidden */
  12280. _defineEquirectangularName: string;
  12281. /** @hidden */
  12282. _defineMirroredEquirectangularFixedName: string;
  12283. /** @hidden */
  12284. _defineEquirectangularFixedName: string;
  12285. /** @hidden */
  12286. _defineSkyboxName: string;
  12287. /** @hidden */
  12288. _defineOppositeZ: string;
  12289. /** @hidden */
  12290. _cubeSamplerName: string;
  12291. /** @hidden */
  12292. _2DSamplerName: string;
  12293. protected _positionUVWName: string;
  12294. protected _directionWName: string;
  12295. protected _reflectionVectorName: string;
  12296. /** @hidden */
  12297. _reflectionCoordsName: string;
  12298. /** @hidden */
  12299. _reflectionMatrixName: string;
  12300. protected _reflectionColorName: string;
  12301. /**
  12302. * Gets or sets the texture associated with the node
  12303. */
  12304. texture: Nullable<BaseTexture>;
  12305. /**
  12306. * Create a new ReflectionTextureBaseBlock
  12307. * @param name defines the block name
  12308. */
  12309. constructor(name: string);
  12310. /**
  12311. * Gets the current class name
  12312. * @returns the class name
  12313. */
  12314. getClassName(): string;
  12315. /**
  12316. * Gets the world position input component
  12317. */
  12318. abstract get position(): NodeMaterialConnectionPoint;
  12319. /**
  12320. * Gets the world position input component
  12321. */
  12322. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12323. /**
  12324. * Gets the world normal input component
  12325. */
  12326. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12327. /**
  12328. * Gets the world input component
  12329. */
  12330. abstract get world(): NodeMaterialConnectionPoint;
  12331. /**
  12332. * Gets the camera (or eye) position component
  12333. */
  12334. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12335. /**
  12336. * Gets the view input component
  12337. */
  12338. abstract get view(): NodeMaterialConnectionPoint;
  12339. protected _getTexture(): Nullable<BaseTexture>;
  12340. autoConfigure(material: NodeMaterial): void;
  12341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12342. isReady(): boolean;
  12343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12344. /**
  12345. * Gets the code to inject in the vertex shader
  12346. * @param state current state of the node material building
  12347. * @returns the shader code
  12348. */
  12349. handleVertexSide(state: NodeMaterialBuildState): string;
  12350. /**
  12351. * Handles the inits for the fragment code path
  12352. * @param state node material build state
  12353. */
  12354. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12355. /**
  12356. * Generates the reflection coords code for the fragment code path
  12357. * @param worldNormalVarName name of the world normal variable
  12358. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12359. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12360. * @returns the shader code
  12361. */
  12362. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12363. /**
  12364. * Generates the reflection color code for the fragment code path
  12365. * @param lodVarName name of the lod variable
  12366. * @param swizzleLookupTexture swizzle to use for the final color variable
  12367. * @returns the shader code
  12368. */
  12369. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12370. /**
  12371. * Generates the code corresponding to the connected output points
  12372. * @param state node material build state
  12373. * @param varName name of the variable to output
  12374. * @returns the shader code
  12375. */
  12376. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12377. protected _buildBlock(state: NodeMaterialBuildState): this;
  12378. protected _dumpPropertiesCode(): string;
  12379. serialize(): any;
  12380. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12381. }
  12382. }
  12383. declare module BABYLON {
  12384. /**
  12385. * Defines a connection point to be used for points with a custom object type
  12386. */
  12387. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12388. private _blockType;
  12389. private _blockName;
  12390. private _nameForCheking?;
  12391. /**
  12392. * Creates a new connection point
  12393. * @param name defines the connection point name
  12394. * @param ownerBlock defines the block hosting this connection point
  12395. * @param direction defines the direction of the connection point
  12396. */
  12397. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12398. /**
  12399. * Gets a number indicating if the current point can be connected to another point
  12400. * @param connectionPoint defines the other connection point
  12401. * @returns a number defining the compatibility state
  12402. */
  12403. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12404. /**
  12405. * Creates a block suitable to be used as an input for this input point.
  12406. * If null is returned, a block based on the point type will be created.
  12407. * @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
  12408. */
  12409. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12410. }
  12411. }
  12412. declare module BABYLON {
  12413. /**
  12414. * Enum defining the type of properties that can be edited in the property pages in the NME
  12415. */
  12416. export enum PropertyTypeForEdition {
  12417. /** property is a boolean */
  12418. Boolean = 0,
  12419. /** property is a float */
  12420. Float = 1,
  12421. /** property is a Vector2 */
  12422. Vector2 = 2,
  12423. /** property is a list of values */
  12424. List = 3
  12425. }
  12426. /**
  12427. * Interface that defines an option in a variable of type list
  12428. */
  12429. export interface IEditablePropertyListOption {
  12430. /** label of the option */
  12431. "label": string;
  12432. /** value of the option */
  12433. "value": number;
  12434. }
  12435. /**
  12436. * Interface that defines the options available for an editable property
  12437. */
  12438. export interface IEditablePropertyOption {
  12439. /** min value */
  12440. "min"?: number;
  12441. /** max value */
  12442. "max"?: number;
  12443. /** notifiers: indicates which actions to take when the property is changed */
  12444. "notifiers"?: {
  12445. /** the material should be rebuilt */
  12446. "rebuild"?: boolean;
  12447. /** the preview should be updated */
  12448. "update"?: boolean;
  12449. };
  12450. /** list of the options for a variable of type list */
  12451. "options"?: IEditablePropertyListOption[];
  12452. }
  12453. /**
  12454. * Interface that describes an editable property
  12455. */
  12456. export interface IPropertyDescriptionForEdition {
  12457. /** name of the property */
  12458. "propertyName": string;
  12459. /** display name of the property */
  12460. "displayName": string;
  12461. /** type of the property */
  12462. "type": PropertyTypeForEdition;
  12463. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12464. "groupName": string;
  12465. /** options for the property */
  12466. "options": IEditablePropertyOption;
  12467. }
  12468. /**
  12469. * Decorator that flags a property in a node material block as being editable
  12470. */
  12471. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12472. }
  12473. declare module BABYLON {
  12474. /**
  12475. * Block used to implement the refraction part of the sub surface module of the PBR material
  12476. */
  12477. export class RefractionBlock extends NodeMaterialBlock {
  12478. /** @hidden */
  12479. _define3DName: string;
  12480. /** @hidden */
  12481. _refractionMatrixName: string;
  12482. /** @hidden */
  12483. _defineLODRefractionAlpha: string;
  12484. /** @hidden */
  12485. _defineLinearSpecularRefraction: string;
  12486. /** @hidden */
  12487. _defineOppositeZ: string;
  12488. /** @hidden */
  12489. _cubeSamplerName: string;
  12490. /** @hidden */
  12491. _2DSamplerName: string;
  12492. /** @hidden */
  12493. _vRefractionMicrosurfaceInfosName: string;
  12494. /** @hidden */
  12495. _vRefractionInfosName: string;
  12496. /** @hidden */
  12497. _vRefractionFilteringInfoName: string;
  12498. private _scene;
  12499. /**
  12500. * The properties below are set by the main PBR block prior to calling methods of this class.
  12501. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12502. * It's less burden on the user side in the editor part.
  12503. */
  12504. /** @hidden */
  12505. viewConnectionPoint: NodeMaterialConnectionPoint;
  12506. /** @hidden */
  12507. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12508. /**
  12509. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12510. * Materials half opaque for instance using refraction could benefit from this control.
  12511. */
  12512. linkRefractionWithTransparency: boolean;
  12513. /**
  12514. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12515. */
  12516. invertRefractionY: boolean;
  12517. /**
  12518. * Gets or sets the texture associated with the node
  12519. */
  12520. texture: Nullable<BaseTexture>;
  12521. /**
  12522. * Create a new RefractionBlock
  12523. * @param name defines the block name
  12524. */
  12525. constructor(name: string);
  12526. /**
  12527. * Gets the current class name
  12528. * @returns the class name
  12529. */
  12530. getClassName(): string;
  12531. /**
  12532. * Gets the intensity input component
  12533. */
  12534. get intensity(): NodeMaterialConnectionPoint;
  12535. /**
  12536. * Gets the tint at distance input component
  12537. */
  12538. get tintAtDistance(): NodeMaterialConnectionPoint;
  12539. /**
  12540. * Gets the view input component
  12541. */
  12542. get view(): NodeMaterialConnectionPoint;
  12543. /**
  12544. * Gets the refraction object output component
  12545. */
  12546. get refraction(): NodeMaterialConnectionPoint;
  12547. /**
  12548. * Returns true if the block has a texture
  12549. */
  12550. get hasTexture(): boolean;
  12551. protected _getTexture(): Nullable<BaseTexture>;
  12552. autoConfigure(material: NodeMaterial): void;
  12553. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12554. isReady(): boolean;
  12555. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12556. /**
  12557. * Gets the main code of the block (fragment side)
  12558. * @param state current state of the node material building
  12559. * @returns the shader code
  12560. */
  12561. getCode(state: NodeMaterialBuildState): string;
  12562. protected _buildBlock(state: NodeMaterialBuildState): this;
  12563. protected _dumpPropertiesCode(): string;
  12564. serialize(): any;
  12565. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12566. }
  12567. }
  12568. declare module BABYLON {
  12569. /**
  12570. * Base block used as input for post process
  12571. */
  12572. export class CurrentScreenBlock extends NodeMaterialBlock {
  12573. private _samplerName;
  12574. private _linearDefineName;
  12575. private _gammaDefineName;
  12576. private _mainUVName;
  12577. private _tempTextureRead;
  12578. /**
  12579. * Gets or sets the texture associated with the node
  12580. */
  12581. texture: Nullable<BaseTexture>;
  12582. /**
  12583. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12584. */
  12585. convertToGammaSpace: boolean;
  12586. /**
  12587. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12588. */
  12589. convertToLinearSpace: boolean;
  12590. /**
  12591. * Create a new CurrentScreenBlock
  12592. * @param name defines the block name
  12593. */
  12594. constructor(name: string);
  12595. /**
  12596. * Gets the current class name
  12597. * @returns the class name
  12598. */
  12599. getClassName(): string;
  12600. /**
  12601. * Gets the uv input component
  12602. */
  12603. get uv(): NodeMaterialConnectionPoint;
  12604. /**
  12605. * Gets the rgba output component
  12606. */
  12607. get rgba(): NodeMaterialConnectionPoint;
  12608. /**
  12609. * Gets the rgb output component
  12610. */
  12611. get rgb(): NodeMaterialConnectionPoint;
  12612. /**
  12613. * Gets the r output component
  12614. */
  12615. get r(): NodeMaterialConnectionPoint;
  12616. /**
  12617. * Gets the g output component
  12618. */
  12619. get g(): NodeMaterialConnectionPoint;
  12620. /**
  12621. * Gets the b output component
  12622. */
  12623. get b(): NodeMaterialConnectionPoint;
  12624. /**
  12625. * Gets the a output component
  12626. */
  12627. get a(): NodeMaterialConnectionPoint;
  12628. /**
  12629. * Initialize the block and prepare the context for build
  12630. * @param state defines the state that will be used for the build
  12631. */
  12632. initialize(state: NodeMaterialBuildState): void;
  12633. get target(): NodeMaterialBlockTargets;
  12634. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12635. isReady(): boolean;
  12636. private _injectVertexCode;
  12637. private _writeTextureRead;
  12638. private _writeOutput;
  12639. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12640. serialize(): any;
  12641. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12642. }
  12643. }
  12644. declare module BABYLON {
  12645. /**
  12646. * Base block used for the particle texture
  12647. */
  12648. export class ParticleTextureBlock extends NodeMaterialBlock {
  12649. private _samplerName;
  12650. private _linearDefineName;
  12651. private _gammaDefineName;
  12652. private _tempTextureRead;
  12653. /**
  12654. * Gets or sets the texture associated with the node
  12655. */
  12656. texture: Nullable<BaseTexture>;
  12657. /**
  12658. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12659. */
  12660. convertToGammaSpace: boolean;
  12661. /**
  12662. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12663. */
  12664. convertToLinearSpace: boolean;
  12665. /**
  12666. * Create a new ParticleTextureBlock
  12667. * @param name defines the block name
  12668. */
  12669. constructor(name: string);
  12670. /**
  12671. * Gets the current class name
  12672. * @returns the class name
  12673. */
  12674. getClassName(): string;
  12675. /**
  12676. * Gets the uv input component
  12677. */
  12678. get uv(): NodeMaterialConnectionPoint;
  12679. /**
  12680. * Gets the rgba output component
  12681. */
  12682. get rgba(): NodeMaterialConnectionPoint;
  12683. /**
  12684. * Gets the rgb output component
  12685. */
  12686. get rgb(): NodeMaterialConnectionPoint;
  12687. /**
  12688. * Gets the r output component
  12689. */
  12690. get r(): NodeMaterialConnectionPoint;
  12691. /**
  12692. * Gets the g output component
  12693. */
  12694. get g(): NodeMaterialConnectionPoint;
  12695. /**
  12696. * Gets the b output component
  12697. */
  12698. get b(): NodeMaterialConnectionPoint;
  12699. /**
  12700. * Gets the a output component
  12701. */
  12702. get a(): NodeMaterialConnectionPoint;
  12703. /**
  12704. * Initialize the block and prepare the context for build
  12705. * @param state defines the state that will be used for the build
  12706. */
  12707. initialize(state: NodeMaterialBuildState): void;
  12708. autoConfigure(material: NodeMaterial): void;
  12709. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12710. isReady(): boolean;
  12711. private _writeOutput;
  12712. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12713. serialize(): any;
  12714. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12715. }
  12716. }
  12717. declare module BABYLON {
  12718. /**
  12719. * Class used to store shared data between 2 NodeMaterialBuildState
  12720. */
  12721. export class NodeMaterialBuildStateSharedData {
  12722. /**
  12723. * Gets the list of emitted varyings
  12724. */
  12725. temps: string[];
  12726. /**
  12727. * Gets the list of emitted varyings
  12728. */
  12729. varyings: string[];
  12730. /**
  12731. * Gets the varying declaration string
  12732. */
  12733. varyingDeclaration: string;
  12734. /**
  12735. * Input blocks
  12736. */
  12737. inputBlocks: InputBlock[];
  12738. /**
  12739. * Input blocks
  12740. */
  12741. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  12742. /**
  12743. * Bindable blocks (Blocks that need to set data to the effect)
  12744. */
  12745. bindableBlocks: NodeMaterialBlock[];
  12746. /**
  12747. * List of blocks that can provide a compilation fallback
  12748. */
  12749. blocksWithFallbacks: NodeMaterialBlock[];
  12750. /**
  12751. * List of blocks that can provide a define update
  12752. */
  12753. blocksWithDefines: NodeMaterialBlock[];
  12754. /**
  12755. * List of blocks that can provide a repeatable content
  12756. */
  12757. repeatableContentBlocks: NodeMaterialBlock[];
  12758. /**
  12759. * List of blocks that can provide a dynamic list of uniforms
  12760. */
  12761. dynamicUniformBlocks: NodeMaterialBlock[];
  12762. /**
  12763. * List of blocks that can block the isReady function for the material
  12764. */
  12765. blockingBlocks: NodeMaterialBlock[];
  12766. /**
  12767. * Gets the list of animated inputs
  12768. */
  12769. animatedInputs: InputBlock[];
  12770. /**
  12771. * Build Id used to avoid multiple recompilations
  12772. */
  12773. buildId: number;
  12774. /** List of emitted variables */
  12775. variableNames: {
  12776. [key: string]: number;
  12777. };
  12778. /** List of emitted defines */
  12779. defineNames: {
  12780. [key: string]: number;
  12781. };
  12782. /** Should emit comments? */
  12783. emitComments: boolean;
  12784. /** Emit build activity */
  12785. verbose: boolean;
  12786. /** Gets or sets the hosting scene */
  12787. scene: Scene;
  12788. /**
  12789. * Gets the compilation hints emitted at compilation time
  12790. */
  12791. hints: {
  12792. needWorldViewMatrix: boolean;
  12793. needWorldViewProjectionMatrix: boolean;
  12794. needAlphaBlending: boolean;
  12795. needAlphaTesting: boolean;
  12796. };
  12797. /**
  12798. * List of compilation checks
  12799. */
  12800. checks: {
  12801. emitVertex: boolean;
  12802. emitFragment: boolean;
  12803. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  12804. };
  12805. /**
  12806. * Is vertex program allowed to be empty?
  12807. */
  12808. allowEmptyVertexProgram: boolean;
  12809. /** Creates a new shared data */
  12810. constructor();
  12811. /**
  12812. * Emits console errors and exceptions if there is a failing check
  12813. */
  12814. emitErrors(): void;
  12815. }
  12816. }
  12817. declare module BABYLON {
  12818. /**
  12819. * Class used to store node based material build state
  12820. */
  12821. export class NodeMaterialBuildState {
  12822. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  12823. supportUniformBuffers: boolean;
  12824. /**
  12825. * Gets the list of emitted attributes
  12826. */
  12827. attributes: string[];
  12828. /**
  12829. * Gets the list of emitted uniforms
  12830. */
  12831. uniforms: string[];
  12832. /**
  12833. * Gets the list of emitted constants
  12834. */
  12835. constants: string[];
  12836. /**
  12837. * Gets the list of emitted samplers
  12838. */
  12839. samplers: string[];
  12840. /**
  12841. * Gets the list of emitted functions
  12842. */
  12843. functions: {
  12844. [key: string]: string;
  12845. };
  12846. /**
  12847. * Gets the list of emitted extensions
  12848. */
  12849. extensions: {
  12850. [key: string]: string;
  12851. };
  12852. /**
  12853. * Gets the target of the compilation state
  12854. */
  12855. target: NodeMaterialBlockTargets;
  12856. /**
  12857. * Gets the list of emitted counters
  12858. */
  12859. counters: {
  12860. [key: string]: number;
  12861. };
  12862. /**
  12863. * Shared data between multiple NodeMaterialBuildState instances
  12864. */
  12865. sharedData: NodeMaterialBuildStateSharedData;
  12866. /** @hidden */
  12867. _vertexState: NodeMaterialBuildState;
  12868. /** @hidden */
  12869. _attributeDeclaration: string;
  12870. /** @hidden */
  12871. _uniformDeclaration: string;
  12872. /** @hidden */
  12873. _constantDeclaration: string;
  12874. /** @hidden */
  12875. _samplerDeclaration: string;
  12876. /** @hidden */
  12877. _varyingTransfer: string;
  12878. /** @hidden */
  12879. _injectAtEnd: string;
  12880. private _repeatableContentAnchorIndex;
  12881. /** @hidden */
  12882. _builtCompilationString: string;
  12883. /**
  12884. * Gets the emitted compilation strings
  12885. */
  12886. compilationString: string;
  12887. /**
  12888. * Finalize the compilation strings
  12889. * @param state defines the current compilation state
  12890. */
  12891. finalize(state: NodeMaterialBuildState): void;
  12892. /** @hidden */
  12893. get _repeatableContentAnchor(): string;
  12894. /** @hidden */
  12895. _getFreeVariableName(prefix: string): string;
  12896. /** @hidden */
  12897. _getFreeDefineName(prefix: string): string;
  12898. /** @hidden */
  12899. _excludeVariableName(name: string): void;
  12900. /** @hidden */
  12901. _emit2DSampler(name: string): void;
  12902. /** @hidden */
  12903. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  12904. /** @hidden */
  12905. _emitExtension(name: string, extension: string, define?: string): void;
  12906. /** @hidden */
  12907. _emitFunction(name: string, code: string, comments: string): void;
  12908. /** @hidden */
  12909. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  12910. replaceStrings?: {
  12911. search: RegExp;
  12912. replace: string;
  12913. }[];
  12914. repeatKey?: string;
  12915. }): string;
  12916. /** @hidden */
  12917. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  12918. repeatKey?: string;
  12919. removeAttributes?: boolean;
  12920. removeUniforms?: boolean;
  12921. removeVaryings?: boolean;
  12922. removeIfDef?: boolean;
  12923. replaceStrings?: {
  12924. search: RegExp;
  12925. replace: string;
  12926. }[];
  12927. }, storeKey?: string): void;
  12928. /** @hidden */
  12929. _registerTempVariable(name: string): boolean;
  12930. /** @hidden */
  12931. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  12932. /** @hidden */
  12933. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  12934. /** @hidden */
  12935. _emitFloat(value: number): string;
  12936. }
  12937. }
  12938. declare module BABYLON {
  12939. /**
  12940. * Helper class used to generate session unique ID
  12941. */
  12942. export class UniqueIdGenerator {
  12943. private static _UniqueIdCounter;
  12944. /**
  12945. * Gets an unique (relatively to the current scene) Id
  12946. */
  12947. static get UniqueId(): number;
  12948. }
  12949. }
  12950. declare module BABYLON {
  12951. /**
  12952. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12953. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12954. */
  12955. export class EffectFallbacks implements IEffectFallbacks {
  12956. private _defines;
  12957. private _currentRank;
  12958. private _maxRank;
  12959. private _mesh;
  12960. /**
  12961. * Removes the fallback from the bound mesh.
  12962. */
  12963. unBindMesh(): void;
  12964. /**
  12965. * Adds a fallback on the specified property.
  12966. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12967. * @param define The name of the define in the shader
  12968. */
  12969. addFallback(rank: number, define: string): void;
  12970. /**
  12971. * Sets the mesh to use CPU skinning when needing to fallback.
  12972. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12973. * @param mesh The mesh to use the fallbacks.
  12974. */
  12975. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12976. /**
  12977. * Checks to see if more fallbacks are still availible.
  12978. */
  12979. get hasMoreFallbacks(): boolean;
  12980. /**
  12981. * Removes the defines that should be removed when falling back.
  12982. * @param currentDefines defines the current define statements for the shader.
  12983. * @param effect defines the current effect we try to compile
  12984. * @returns The resulting defines with defines of the current rank removed.
  12985. */
  12986. reduce(currentDefines: string, effect: Effect): string;
  12987. }
  12988. }
  12989. declare module BABYLON {
  12990. /**
  12991. * Defines a block that can be used inside a node based material
  12992. */
  12993. export class NodeMaterialBlock {
  12994. private _buildId;
  12995. private _buildTarget;
  12996. private _target;
  12997. private _isFinalMerger;
  12998. private _isInput;
  12999. private _name;
  13000. protected _isUnique: boolean;
  13001. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13002. inputsAreExclusive: boolean;
  13003. /** @hidden */
  13004. _codeVariableName: string;
  13005. /** @hidden */
  13006. _inputs: NodeMaterialConnectionPoint[];
  13007. /** @hidden */
  13008. _outputs: NodeMaterialConnectionPoint[];
  13009. /** @hidden */
  13010. _preparationId: number;
  13011. /**
  13012. * Gets the name of the block
  13013. */
  13014. get name(): string;
  13015. /**
  13016. * Sets the name of the block. Will check if the name is valid.
  13017. */
  13018. set name(newName: string);
  13019. /**
  13020. * Gets or sets the unique id of the node
  13021. */
  13022. uniqueId: number;
  13023. /**
  13024. * Gets or sets the comments associated with this block
  13025. */
  13026. comments: string;
  13027. /**
  13028. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13029. */
  13030. get isUnique(): boolean;
  13031. /**
  13032. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13033. */
  13034. get isFinalMerger(): boolean;
  13035. /**
  13036. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13037. */
  13038. get isInput(): boolean;
  13039. /**
  13040. * Gets or sets the build Id
  13041. */
  13042. get buildId(): number;
  13043. set buildId(value: number);
  13044. /**
  13045. * Gets or sets the target of the block
  13046. */
  13047. get target(): NodeMaterialBlockTargets;
  13048. set target(value: NodeMaterialBlockTargets);
  13049. /**
  13050. * Gets the list of input points
  13051. */
  13052. get inputs(): NodeMaterialConnectionPoint[];
  13053. /** Gets the list of output points */
  13054. get outputs(): NodeMaterialConnectionPoint[];
  13055. /**
  13056. * Find an input by its name
  13057. * @param name defines the name of the input to look for
  13058. * @returns the input or null if not found
  13059. */
  13060. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13061. /**
  13062. * Find an output by its name
  13063. * @param name defines the name of the outputto look for
  13064. * @returns the output or null if not found
  13065. */
  13066. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13067. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13068. visibleInInspector: boolean;
  13069. /**
  13070. * Creates a new NodeMaterialBlock
  13071. * @param name defines the block name
  13072. * @param target defines the target of that block (Vertex by default)
  13073. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13074. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13075. */
  13076. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13077. /**
  13078. * Initialize the block and prepare the context for build
  13079. * @param state defines the state that will be used for the build
  13080. */
  13081. initialize(state: NodeMaterialBuildState): void;
  13082. /**
  13083. * Bind data to effect. Will only be called for blocks with isBindable === true
  13084. * @param effect defines the effect to bind data to
  13085. * @param nodeMaterial defines the hosting NodeMaterial
  13086. * @param mesh defines the mesh that will be rendered
  13087. * @param subMesh defines the submesh that will be rendered
  13088. */
  13089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13090. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13091. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13092. protected _writeFloat(value: number): string;
  13093. /**
  13094. * Gets the current class name e.g. "NodeMaterialBlock"
  13095. * @returns the class name
  13096. */
  13097. getClassName(): string;
  13098. /**
  13099. * Register a new input. Must be called inside a block constructor
  13100. * @param name defines the connection point name
  13101. * @param type defines the connection point type
  13102. * @param isOptional defines a boolean indicating that this input can be omitted
  13103. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13104. * @param point an already created connection point. If not provided, create a new one
  13105. * @returns the current block
  13106. */
  13107. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13108. /**
  13109. * Register a new output. Must be called inside a block constructor
  13110. * @param name defines the connection point name
  13111. * @param type defines the connection point type
  13112. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13113. * @param point an already created connection point. If not provided, create a new one
  13114. * @returns the current block
  13115. */
  13116. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13117. /**
  13118. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13119. * @param forOutput defines an optional connection point to check compatibility with
  13120. * @returns the first available input or null
  13121. */
  13122. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13123. /**
  13124. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13125. * @param forBlock defines an optional block to check compatibility with
  13126. * @returns the first available input or null
  13127. */
  13128. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13129. /**
  13130. * Gets the sibling of the given output
  13131. * @param current defines the current output
  13132. * @returns the next output in the list or null
  13133. */
  13134. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13135. /**
  13136. * Connect current block with another block
  13137. * @param other defines the block to connect with
  13138. * @param options define the various options to help pick the right connections
  13139. * @returns the current block
  13140. */
  13141. connectTo(other: NodeMaterialBlock, options?: {
  13142. input?: string;
  13143. output?: string;
  13144. outputSwizzle?: string;
  13145. }): this | undefined;
  13146. protected _buildBlock(state: NodeMaterialBuildState): void;
  13147. /**
  13148. * Add uniforms, samplers and uniform buffers at compilation time
  13149. * @param state defines the state to update
  13150. * @param nodeMaterial defines the node material requesting the update
  13151. * @param defines defines the material defines to update
  13152. * @param uniformBuffers defines the list of uniform buffer names
  13153. */
  13154. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13155. /**
  13156. * Add potential fallbacks if shader compilation fails
  13157. * @param mesh defines the mesh to be rendered
  13158. * @param fallbacks defines the current prioritized list of fallbacks
  13159. */
  13160. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13161. /**
  13162. * Initialize defines for shader compilation
  13163. * @param mesh defines the mesh to be rendered
  13164. * @param nodeMaterial defines the node material requesting the update
  13165. * @param defines defines the material defines to update
  13166. * @param useInstances specifies that instances should be used
  13167. */
  13168. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13169. /**
  13170. * Update defines for shader compilation
  13171. * @param mesh defines the mesh to be rendered
  13172. * @param nodeMaterial defines the node material requesting the update
  13173. * @param defines defines the material defines to update
  13174. * @param useInstances specifies that instances should be used
  13175. * @param subMesh defines which submesh to render
  13176. */
  13177. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13178. /**
  13179. * Lets the block try to connect some inputs automatically
  13180. * @param material defines the hosting NodeMaterial
  13181. */
  13182. autoConfigure(material: NodeMaterial): void;
  13183. /**
  13184. * Function called when a block is declared as repeatable content generator
  13185. * @param vertexShaderState defines the current compilation state for the vertex shader
  13186. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13187. * @param mesh defines the mesh to be rendered
  13188. * @param defines defines the material defines to update
  13189. */
  13190. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13191. /**
  13192. * Checks if the block is ready
  13193. * @param mesh defines the mesh to be rendered
  13194. * @param nodeMaterial defines the node material requesting the update
  13195. * @param defines defines the material defines to update
  13196. * @param useInstances specifies that instances should be used
  13197. * @returns true if the block is ready
  13198. */
  13199. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13200. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13201. private _processBuild;
  13202. /**
  13203. * Validates the new name for the block node.
  13204. * @param newName the new name to be given to the node.
  13205. * @returns false if the name is a reserve word, else true.
  13206. */
  13207. validateBlockName(newName: string): boolean;
  13208. /**
  13209. * Compile the current node and generate the shader code
  13210. * @param state defines the current compilation state (uniforms, samplers, current string)
  13211. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13212. * @returns true if already built
  13213. */
  13214. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13215. protected _inputRename(name: string): string;
  13216. protected _outputRename(name: string): string;
  13217. protected _dumpPropertiesCode(): string;
  13218. /** @hidden */
  13219. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13220. /** @hidden */
  13221. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13222. /**
  13223. * Clone the current block to a new identical block
  13224. * @param scene defines the hosting scene
  13225. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13226. * @returns a copy of the current block
  13227. */
  13228. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13229. /**
  13230. * Serializes this block in a JSON representation
  13231. * @returns the serialized block object
  13232. */
  13233. serialize(): any;
  13234. /** @hidden */
  13235. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13236. private _deserializePortDisplayNamesAndExposedOnFrame;
  13237. /**
  13238. * Release resources
  13239. */
  13240. dispose(): void;
  13241. }
  13242. }
  13243. declare module BABYLON {
  13244. /**
  13245. * Base class of materials working in push mode in babylon JS
  13246. * @hidden
  13247. */
  13248. export class PushMaterial extends Material {
  13249. protected _activeEffect: Effect;
  13250. protected _normalMatrix: Matrix;
  13251. constructor(name: string, scene: Scene);
  13252. getEffect(): Effect;
  13253. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13254. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13255. /**
  13256. * Binds the given world matrix to the active effect
  13257. *
  13258. * @param world the matrix to bind
  13259. */
  13260. bindOnlyWorldMatrix(world: Matrix): void;
  13261. /**
  13262. * Binds the given normal matrix to the active effect
  13263. *
  13264. * @param normalMatrix the matrix to bind
  13265. */
  13266. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13267. bind(world: Matrix, mesh?: Mesh): void;
  13268. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13269. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13270. }
  13271. }
  13272. declare module BABYLON {
  13273. /**
  13274. * Root class for all node material optimizers
  13275. */
  13276. export class NodeMaterialOptimizer {
  13277. /**
  13278. * Function used to optimize a NodeMaterial graph
  13279. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13280. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13281. */
  13282. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13283. }
  13284. }
  13285. declare module BABYLON {
  13286. /**
  13287. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13288. */
  13289. export class TransformBlock extends NodeMaterialBlock {
  13290. /**
  13291. * Defines the value to use to complement W value to transform it to a Vector4
  13292. */
  13293. complementW: number;
  13294. /**
  13295. * Defines the value to use to complement z value to transform it to a Vector4
  13296. */
  13297. complementZ: number;
  13298. /**
  13299. * Creates a new TransformBlock
  13300. * @param name defines the block name
  13301. */
  13302. constructor(name: string);
  13303. /**
  13304. * Gets the current class name
  13305. * @returns the class name
  13306. */
  13307. getClassName(): string;
  13308. /**
  13309. * Gets the vector input
  13310. */
  13311. get vector(): NodeMaterialConnectionPoint;
  13312. /**
  13313. * Gets the output component
  13314. */
  13315. get output(): NodeMaterialConnectionPoint;
  13316. /**
  13317. * Gets the xyz output component
  13318. */
  13319. get xyz(): NodeMaterialConnectionPoint;
  13320. /**
  13321. * Gets the matrix transform input
  13322. */
  13323. get transform(): NodeMaterialConnectionPoint;
  13324. protected _buildBlock(state: NodeMaterialBuildState): this;
  13325. /**
  13326. * Update defines for shader compilation
  13327. * @param mesh defines the mesh to be rendered
  13328. * @param nodeMaterial defines the node material requesting the update
  13329. * @param defines defines the material defines to update
  13330. * @param useInstances specifies that instances should be used
  13331. * @param subMesh defines which submesh to render
  13332. */
  13333. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13334. serialize(): any;
  13335. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13336. protected _dumpPropertiesCode(): string;
  13337. }
  13338. }
  13339. declare module BABYLON {
  13340. /**
  13341. * Block used to output the vertex position
  13342. */
  13343. export class VertexOutputBlock extends NodeMaterialBlock {
  13344. /**
  13345. * Creates a new VertexOutputBlock
  13346. * @param name defines the block name
  13347. */
  13348. constructor(name: string);
  13349. /**
  13350. * Gets the current class name
  13351. * @returns the class name
  13352. */
  13353. getClassName(): string;
  13354. /**
  13355. * Gets the vector input component
  13356. */
  13357. get vector(): NodeMaterialConnectionPoint;
  13358. protected _buildBlock(state: NodeMaterialBuildState): this;
  13359. }
  13360. }
  13361. declare module BABYLON {
  13362. /**
  13363. * Block used to output the final color
  13364. */
  13365. export class FragmentOutputBlock extends NodeMaterialBlock {
  13366. /**
  13367. * Create a new FragmentOutputBlock
  13368. * @param name defines the block name
  13369. */
  13370. constructor(name: string);
  13371. /**
  13372. * Gets the current class name
  13373. * @returns the class name
  13374. */
  13375. getClassName(): string;
  13376. /**
  13377. * Gets the rgba input component
  13378. */
  13379. get rgba(): NodeMaterialConnectionPoint;
  13380. /**
  13381. * Gets the rgb input component
  13382. */
  13383. get rgb(): NodeMaterialConnectionPoint;
  13384. /**
  13385. * Gets the a input component
  13386. */
  13387. get a(): NodeMaterialConnectionPoint;
  13388. protected _buildBlock(state: NodeMaterialBuildState): this;
  13389. }
  13390. }
  13391. declare module BABYLON {
  13392. /**
  13393. * Block used for the particle ramp gradient section
  13394. */
  13395. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13396. /**
  13397. * Create a new ParticleRampGradientBlock
  13398. * @param name defines the block name
  13399. */
  13400. constructor(name: string);
  13401. /**
  13402. * Gets the current class name
  13403. * @returns the class name
  13404. */
  13405. getClassName(): string;
  13406. /**
  13407. * Gets the color input component
  13408. */
  13409. get color(): NodeMaterialConnectionPoint;
  13410. /**
  13411. * Gets the rampColor output component
  13412. */
  13413. get rampColor(): NodeMaterialConnectionPoint;
  13414. /**
  13415. * Initialize the block and prepare the context for build
  13416. * @param state defines the state that will be used for the build
  13417. */
  13418. initialize(state: NodeMaterialBuildState): void;
  13419. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13420. }
  13421. }
  13422. declare module BABYLON {
  13423. /**
  13424. * Block used for the particle blend multiply section
  13425. */
  13426. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13427. /**
  13428. * Create a new ParticleBlendMultiplyBlock
  13429. * @param name defines the block name
  13430. */
  13431. constructor(name: string);
  13432. /**
  13433. * Gets the current class name
  13434. * @returns the class name
  13435. */
  13436. getClassName(): string;
  13437. /**
  13438. * Gets the color input component
  13439. */
  13440. get color(): NodeMaterialConnectionPoint;
  13441. /**
  13442. * Gets the alphaTexture input component
  13443. */
  13444. get alphaTexture(): NodeMaterialConnectionPoint;
  13445. /**
  13446. * Gets the alphaColor input component
  13447. */
  13448. get alphaColor(): NodeMaterialConnectionPoint;
  13449. /**
  13450. * Gets the blendColor output component
  13451. */
  13452. get blendColor(): NodeMaterialConnectionPoint;
  13453. /**
  13454. * Initialize the block and prepare the context for build
  13455. * @param state defines the state that will be used for the build
  13456. */
  13457. initialize(state: NodeMaterialBuildState): void;
  13458. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13459. }
  13460. }
  13461. declare module BABYLON {
  13462. /**
  13463. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13464. */
  13465. export class VectorMergerBlock extends NodeMaterialBlock {
  13466. /**
  13467. * Create a new VectorMergerBlock
  13468. * @param name defines the block name
  13469. */
  13470. constructor(name: string);
  13471. /**
  13472. * Gets the current class name
  13473. * @returns the class name
  13474. */
  13475. getClassName(): string;
  13476. /**
  13477. * Gets the xyz component (input)
  13478. */
  13479. get xyzIn(): NodeMaterialConnectionPoint;
  13480. /**
  13481. * Gets the xy component (input)
  13482. */
  13483. get xyIn(): NodeMaterialConnectionPoint;
  13484. /**
  13485. * Gets the x component (input)
  13486. */
  13487. get x(): NodeMaterialConnectionPoint;
  13488. /**
  13489. * Gets the y component (input)
  13490. */
  13491. get y(): NodeMaterialConnectionPoint;
  13492. /**
  13493. * Gets the z component (input)
  13494. */
  13495. get z(): NodeMaterialConnectionPoint;
  13496. /**
  13497. * Gets the w component (input)
  13498. */
  13499. get w(): NodeMaterialConnectionPoint;
  13500. /**
  13501. * Gets the xyzw component (output)
  13502. */
  13503. get xyzw(): NodeMaterialConnectionPoint;
  13504. /**
  13505. * Gets the xyz component (output)
  13506. */
  13507. get xyzOut(): NodeMaterialConnectionPoint;
  13508. /**
  13509. * Gets the xy component (output)
  13510. */
  13511. get xyOut(): NodeMaterialConnectionPoint;
  13512. /**
  13513. * Gets the xy component (output)
  13514. * @deprecated Please use xyOut instead.
  13515. */
  13516. get xy(): NodeMaterialConnectionPoint;
  13517. /**
  13518. * Gets the xyz component (output)
  13519. * @deprecated Please use xyzOut instead.
  13520. */
  13521. get xyz(): NodeMaterialConnectionPoint;
  13522. protected _buildBlock(state: NodeMaterialBuildState): this;
  13523. }
  13524. }
  13525. declare module BABYLON {
  13526. /**
  13527. * Block used to remap a float from a range to a new one
  13528. */
  13529. export class RemapBlock extends NodeMaterialBlock {
  13530. /**
  13531. * Gets or sets the source range
  13532. */
  13533. sourceRange: Vector2;
  13534. /**
  13535. * Gets or sets the target range
  13536. */
  13537. targetRange: Vector2;
  13538. /**
  13539. * Creates a new RemapBlock
  13540. * @param name defines the block name
  13541. */
  13542. constructor(name: string);
  13543. /**
  13544. * Gets the current class name
  13545. * @returns the class name
  13546. */
  13547. getClassName(): string;
  13548. /**
  13549. * Gets the input component
  13550. */
  13551. get input(): NodeMaterialConnectionPoint;
  13552. /**
  13553. * Gets the source min input component
  13554. */
  13555. get sourceMin(): NodeMaterialConnectionPoint;
  13556. /**
  13557. * Gets the source max input component
  13558. */
  13559. get sourceMax(): NodeMaterialConnectionPoint;
  13560. /**
  13561. * Gets the target min input component
  13562. */
  13563. get targetMin(): NodeMaterialConnectionPoint;
  13564. /**
  13565. * Gets the target max input component
  13566. */
  13567. get targetMax(): NodeMaterialConnectionPoint;
  13568. /**
  13569. * Gets the output component
  13570. */
  13571. get output(): NodeMaterialConnectionPoint;
  13572. protected _buildBlock(state: NodeMaterialBuildState): this;
  13573. protected _dumpPropertiesCode(): string;
  13574. serialize(): any;
  13575. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13576. }
  13577. }
  13578. declare module BABYLON {
  13579. /**
  13580. * Block used to multiply 2 values
  13581. */
  13582. export class MultiplyBlock extends NodeMaterialBlock {
  13583. /**
  13584. * Creates a new MultiplyBlock
  13585. * @param name defines the block name
  13586. */
  13587. constructor(name: string);
  13588. /**
  13589. * Gets the current class name
  13590. * @returns the class name
  13591. */
  13592. getClassName(): string;
  13593. /**
  13594. * Gets the left operand input component
  13595. */
  13596. get left(): NodeMaterialConnectionPoint;
  13597. /**
  13598. * Gets the right operand input component
  13599. */
  13600. get right(): NodeMaterialConnectionPoint;
  13601. /**
  13602. * Gets the output component
  13603. */
  13604. get output(): NodeMaterialConnectionPoint;
  13605. protected _buildBlock(state: NodeMaterialBuildState): this;
  13606. }
  13607. }
  13608. declare module BABYLON {
  13609. /** Interface used by value gradients (color, factor, ...) */
  13610. export interface IValueGradient {
  13611. /**
  13612. * Gets or sets the gradient value (between 0 and 1)
  13613. */
  13614. gradient: number;
  13615. }
  13616. /** Class used to store color4 gradient */
  13617. export class ColorGradient implements IValueGradient {
  13618. /**
  13619. * Gets or sets the gradient value (between 0 and 1)
  13620. */
  13621. gradient: number;
  13622. /**
  13623. * Gets or sets first associated color
  13624. */
  13625. color1: Color4;
  13626. /**
  13627. * Gets or sets second associated color
  13628. */
  13629. color2?: Color4 | undefined;
  13630. /**
  13631. * Creates a new color4 gradient
  13632. * @param gradient gets or sets the gradient value (between 0 and 1)
  13633. * @param color1 gets or sets first associated color
  13634. * @param color2 gets or sets first second color
  13635. */
  13636. constructor(
  13637. /**
  13638. * Gets or sets the gradient value (between 0 and 1)
  13639. */
  13640. gradient: number,
  13641. /**
  13642. * Gets or sets first associated color
  13643. */
  13644. color1: Color4,
  13645. /**
  13646. * Gets or sets second associated color
  13647. */
  13648. color2?: Color4 | undefined);
  13649. /**
  13650. * Will get a color picked randomly between color1 and color2.
  13651. * If color2 is undefined then color1 will be used
  13652. * @param result defines the target Color4 to store the result in
  13653. */
  13654. getColorToRef(result: Color4): void;
  13655. }
  13656. /** Class used to store color 3 gradient */
  13657. export class Color3Gradient implements IValueGradient {
  13658. /**
  13659. * Gets or sets the gradient value (between 0 and 1)
  13660. */
  13661. gradient: number;
  13662. /**
  13663. * Gets or sets the associated color
  13664. */
  13665. color: Color3;
  13666. /**
  13667. * Creates a new color3 gradient
  13668. * @param gradient gets or sets the gradient value (between 0 and 1)
  13669. * @param color gets or sets associated color
  13670. */
  13671. constructor(
  13672. /**
  13673. * Gets or sets the gradient value (between 0 and 1)
  13674. */
  13675. gradient: number,
  13676. /**
  13677. * Gets or sets the associated color
  13678. */
  13679. color: Color3);
  13680. }
  13681. /** Class used to store factor gradient */
  13682. export class FactorGradient implements IValueGradient {
  13683. /**
  13684. * Gets or sets the gradient value (between 0 and 1)
  13685. */
  13686. gradient: number;
  13687. /**
  13688. * Gets or sets first associated factor
  13689. */
  13690. factor1: number;
  13691. /**
  13692. * Gets or sets second associated factor
  13693. */
  13694. factor2?: number | undefined;
  13695. /**
  13696. * Creates a new factor gradient
  13697. * @param gradient gets or sets the gradient value (between 0 and 1)
  13698. * @param factor1 gets or sets first associated factor
  13699. * @param factor2 gets or sets second associated factor
  13700. */
  13701. constructor(
  13702. /**
  13703. * Gets or sets the gradient value (between 0 and 1)
  13704. */
  13705. gradient: number,
  13706. /**
  13707. * Gets or sets first associated factor
  13708. */
  13709. factor1: number,
  13710. /**
  13711. * Gets or sets second associated factor
  13712. */
  13713. factor2?: number | undefined);
  13714. /**
  13715. * Will get a number picked randomly between factor1 and factor2.
  13716. * If factor2 is undefined then factor1 will be used
  13717. * @returns the picked number
  13718. */
  13719. getFactor(): number;
  13720. }
  13721. /**
  13722. * Helper used to simplify some generic gradient tasks
  13723. */
  13724. export class GradientHelper {
  13725. /**
  13726. * Gets the current gradient from an array of IValueGradient
  13727. * @param ratio defines the current ratio to get
  13728. * @param gradients defines the array of IValueGradient
  13729. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  13730. */
  13731. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  13732. }
  13733. }
  13734. declare module BABYLON {
  13735. interface ThinEngine {
  13736. /**
  13737. * Creates a raw texture
  13738. * @param data defines the data to store in the texture
  13739. * @param width defines the width of the texture
  13740. * @param height defines the height of the texture
  13741. * @param format defines the format of the data
  13742. * @param generateMipMaps defines if the engine should generate the mip levels
  13743. * @param invertY defines if data must be stored with Y axis inverted
  13744. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  13745. * @param compression defines the compression used (null by default)
  13746. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13747. * @returns the raw texture inside an InternalTexture
  13748. */
  13749. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  13750. /**
  13751. * Update a raw texture
  13752. * @param texture defines the texture to update
  13753. * @param data defines the data to store in the texture
  13754. * @param format defines the format of the data
  13755. * @param invertY defines if data must be stored with Y axis inverted
  13756. */
  13757. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13758. /**
  13759. * Update a raw texture
  13760. * @param texture defines the texture to update
  13761. * @param data defines the data to store in the texture
  13762. * @param format defines the format of the data
  13763. * @param invertY defines if data must be stored with Y axis inverted
  13764. * @param compression defines the compression used (null by default)
  13765. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13766. */
  13767. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  13768. /**
  13769. * Creates a new raw cube texture
  13770. * @param data defines the array of data to use to create each face
  13771. * @param size defines the size of the textures
  13772. * @param format defines the format of the data
  13773. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13774. * @param generateMipMaps defines if the engine should generate the mip levels
  13775. * @param invertY defines if data must be stored with Y axis inverted
  13776. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13777. * @param compression defines the compression used (null by default)
  13778. * @returns the cube texture as an InternalTexture
  13779. */
  13780. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  13781. /**
  13782. * Update a raw cube texture
  13783. * @param texture defines the texture to udpdate
  13784. * @param data defines the data to store
  13785. * @param format defines the data format
  13786. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13787. * @param invertY defines if data must be stored with Y axis inverted
  13788. */
  13789. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  13790. /**
  13791. * Update a raw cube texture
  13792. * @param texture defines the texture to udpdate
  13793. * @param data defines the data to store
  13794. * @param format defines the data format
  13795. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13796. * @param invertY defines if data must be stored with Y axis inverted
  13797. * @param compression defines the compression used (null by default)
  13798. */
  13799. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  13800. /**
  13801. * Update a raw cube texture
  13802. * @param texture defines the texture to udpdate
  13803. * @param data defines the data to store
  13804. * @param format defines the data format
  13805. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13806. * @param invertY defines if data must be stored with Y axis inverted
  13807. * @param compression defines the compression used (null by default)
  13808. * @param level defines which level of the texture to update
  13809. */
  13810. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  13811. /**
  13812. * Creates a new raw cube texture from a specified url
  13813. * @param url defines the url where the data is located
  13814. * @param scene defines the current scene
  13815. * @param size defines the size of the textures
  13816. * @param format defines the format of the data
  13817. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13818. * @param noMipmap defines if the engine should avoid generating the mip levels
  13819. * @param callback defines a callback used to extract texture data from loaded data
  13820. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13821. * @param onLoad defines a callback called when texture is loaded
  13822. * @param onError defines a callback called if there is an error
  13823. * @returns the cube texture as an InternalTexture
  13824. */
  13825. 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;
  13826. /**
  13827. * Creates a new raw cube texture from a specified url
  13828. * @param url defines the url where the data is located
  13829. * @param scene defines the current scene
  13830. * @param size defines the size of the textures
  13831. * @param format defines the format of the data
  13832. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13833. * @param noMipmap defines if the engine should avoid generating the mip levels
  13834. * @param callback defines a callback used to extract texture data from loaded data
  13835. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13836. * @param onLoad defines a callback called when texture is loaded
  13837. * @param onError defines a callback called if there is an error
  13838. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13839. * @param invertY defines if data must be stored with Y axis inverted
  13840. * @returns the cube texture as an InternalTexture
  13841. */
  13842. 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;
  13843. /**
  13844. * Creates a new raw 3D texture
  13845. * @param data defines the data used to create the texture
  13846. * @param width defines the width of the texture
  13847. * @param height defines the height of the texture
  13848. * @param depth defines the depth of the texture
  13849. * @param format defines the format of the texture
  13850. * @param generateMipMaps defines if the engine must generate mip levels
  13851. * @param invertY defines if data must be stored with Y axis inverted
  13852. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13853. * @param compression defines the compressed used (can be null)
  13854. * @param textureType defines the compressed used (can be null)
  13855. * @returns a new raw 3D texture (stored in an InternalTexture)
  13856. */
  13857. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13858. /**
  13859. * Update a raw 3D texture
  13860. * @param texture defines the texture to update
  13861. * @param data defines the data to store
  13862. * @param format defines the data format
  13863. * @param invertY defines if data must be stored with Y axis inverted
  13864. */
  13865. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13866. /**
  13867. * Update a raw 3D texture
  13868. * @param texture defines the texture to update
  13869. * @param data defines the data to store
  13870. * @param format defines the data format
  13871. * @param invertY defines if data must be stored with Y axis inverted
  13872. * @param compression defines the used compression (can be null)
  13873. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13874. */
  13875. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13876. /**
  13877. * Creates a new raw 2D array texture
  13878. * @param data defines the data used to create the texture
  13879. * @param width defines the width of the texture
  13880. * @param height defines the height of the texture
  13881. * @param depth defines the number of layers of the texture
  13882. * @param format defines the format of the texture
  13883. * @param generateMipMaps defines if the engine must generate mip levels
  13884. * @param invertY defines if data must be stored with Y axis inverted
  13885. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13886. * @param compression defines the compressed used (can be null)
  13887. * @param textureType defines the compressed used (can be null)
  13888. * @returns a new raw 2D array texture (stored in an InternalTexture)
  13889. */
  13890. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13891. /**
  13892. * Update a raw 2D array texture
  13893. * @param texture defines the texture to update
  13894. * @param data defines the data to store
  13895. * @param format defines the data format
  13896. * @param invertY defines if data must be stored with Y axis inverted
  13897. */
  13898. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13899. /**
  13900. * Update a raw 2D array texture
  13901. * @param texture defines the texture to update
  13902. * @param data defines the data to store
  13903. * @param format defines the data format
  13904. * @param invertY defines if data must be stored with Y axis inverted
  13905. * @param compression defines the used compression (can be null)
  13906. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13907. */
  13908. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13909. }
  13910. }
  13911. declare module BABYLON {
  13912. /**
  13913. * Raw texture can help creating a texture directly from an array of data.
  13914. * This can be super useful if you either get the data from an uncompressed source or
  13915. * if you wish to create your texture pixel by pixel.
  13916. */
  13917. export class RawTexture extends Texture {
  13918. /**
  13919. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13920. */
  13921. format: number;
  13922. /**
  13923. * Instantiates a new RawTexture.
  13924. * Raw texture can help creating a texture directly from an array of data.
  13925. * This can be super useful if you either get the data from an uncompressed source or
  13926. * if you wish to create your texture pixel by pixel.
  13927. * @param data define the array of data to use to create the texture
  13928. * @param width define the width of the texture
  13929. * @param height define the height of the texture
  13930. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13931. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13932. * @param generateMipMaps define whether mip maps should be generated or not
  13933. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13934. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13935. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13936. */
  13937. constructor(data: ArrayBufferView, width: number, height: number,
  13938. /**
  13939. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13940. */
  13941. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13942. /**
  13943. * Updates the texture underlying data.
  13944. * @param data Define the new data of the texture
  13945. */
  13946. update(data: ArrayBufferView): void;
  13947. /**
  13948. * Creates a luminance texture from some data.
  13949. * @param data Define the texture data
  13950. * @param width Define the width of the texture
  13951. * @param height Define the height of the texture
  13952. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13953. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13954. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13955. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13956. * @returns the luminance texture
  13957. */
  13958. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13959. /**
  13960. * Creates a luminance alpha texture from some data.
  13961. * @param data Define the texture data
  13962. * @param width Define the width of the texture
  13963. * @param height Define the height of the texture
  13964. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13965. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13966. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13967. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13968. * @returns the luminance alpha texture
  13969. */
  13970. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13971. /**
  13972. * Creates an alpha texture from some data.
  13973. * @param data Define the texture data
  13974. * @param width Define the width of the texture
  13975. * @param height Define the height of the texture
  13976. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13977. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13978. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13979. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13980. * @returns the alpha texture
  13981. */
  13982. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13983. /**
  13984. * Creates a RGB texture from some data.
  13985. * @param data Define the texture data
  13986. * @param width Define the width of the texture
  13987. * @param height Define the height of the texture
  13988. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13989. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13990. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13991. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13992. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13993. * @returns the RGB alpha texture
  13994. */
  13995. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13996. /**
  13997. * Creates a RGBA texture from some data.
  13998. * @param data Define the texture data
  13999. * @param width Define the width of the texture
  14000. * @param height Define the height of the texture
  14001. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14002. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14003. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14004. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14005. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14006. * @returns the RGBA texture
  14007. */
  14008. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14009. /**
  14010. * Creates a R texture from some data.
  14011. * @param data Define the texture data
  14012. * @param width Define the width of the texture
  14013. * @param height Define the height of the texture
  14014. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14015. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14016. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14017. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14018. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14019. * @returns the R texture
  14020. */
  14021. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14022. }
  14023. }
  14024. declare module BABYLON {
  14025. interface ThinEngine {
  14026. /**
  14027. * Update a dynamic index buffer
  14028. * @param indexBuffer defines the target index buffer
  14029. * @param indices defines the data to update
  14030. * @param offset defines the offset in the target index buffer where update should start
  14031. */
  14032. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14033. /**
  14034. * Updates a dynamic vertex buffer.
  14035. * @param vertexBuffer the vertex buffer to update
  14036. * @param data the data used to update the vertex buffer
  14037. * @param byteOffset the byte offset of the data
  14038. * @param byteLength the byte length of the data
  14039. */
  14040. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14041. }
  14042. }
  14043. declare module BABYLON {
  14044. interface AbstractScene {
  14045. /**
  14046. * The list of procedural textures added to the scene
  14047. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14048. */
  14049. proceduralTextures: Array<ProceduralTexture>;
  14050. }
  14051. /**
  14052. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14053. * in a given scene.
  14054. */
  14055. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14056. /**
  14057. * The component name helpfull to identify the component in the list of scene components.
  14058. */
  14059. readonly name: string;
  14060. /**
  14061. * The scene the component belongs to.
  14062. */
  14063. scene: Scene;
  14064. /**
  14065. * Creates a new instance of the component for the given scene
  14066. * @param scene Defines the scene to register the component in
  14067. */
  14068. constructor(scene: Scene);
  14069. /**
  14070. * Registers the component in a given scene
  14071. */
  14072. register(): void;
  14073. /**
  14074. * Rebuilds the elements related to this component in case of
  14075. * context lost for instance.
  14076. */
  14077. rebuild(): void;
  14078. /**
  14079. * Disposes the component and the associated ressources.
  14080. */
  14081. dispose(): void;
  14082. private _beforeClear;
  14083. }
  14084. }
  14085. declare module BABYLON {
  14086. interface ThinEngine {
  14087. /**
  14088. * Creates a new render target cube texture
  14089. * @param size defines the size of the texture
  14090. * @param options defines the options used to create the texture
  14091. * @returns a new render target cube texture stored in an InternalTexture
  14092. */
  14093. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14094. }
  14095. }
  14096. declare module BABYLON {
  14097. /** @hidden */
  14098. export var proceduralVertexShader: {
  14099. name: string;
  14100. shader: string;
  14101. };
  14102. }
  14103. declare module BABYLON {
  14104. /**
  14105. * 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.
  14106. * This is the base class of any Procedural texture and contains most of the shareable code.
  14107. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14108. */
  14109. export class ProceduralTexture extends Texture {
  14110. /**
  14111. * Define if the texture is enabled or not (disabled texture will not render)
  14112. */
  14113. isEnabled: boolean;
  14114. /**
  14115. * Define if the texture must be cleared before rendering (default is true)
  14116. */
  14117. autoClear: boolean;
  14118. /**
  14119. * Callback called when the texture is generated
  14120. */
  14121. onGenerated: () => void;
  14122. /**
  14123. * Event raised when the texture is generated
  14124. */
  14125. onGeneratedObservable: Observable<ProceduralTexture>;
  14126. /**
  14127. * Event raised before the texture is generated
  14128. */
  14129. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14130. /**
  14131. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14132. */
  14133. nodeMaterialSource: Nullable<NodeMaterial>;
  14134. /** @hidden */
  14135. _generateMipMaps: boolean;
  14136. /** @hidden **/
  14137. _effect: Effect;
  14138. /** @hidden */
  14139. _textures: {
  14140. [key: string]: Texture;
  14141. };
  14142. /** @hidden */
  14143. protected _fallbackTexture: Nullable<Texture>;
  14144. private _size;
  14145. private _currentRefreshId;
  14146. private _frameId;
  14147. private _refreshRate;
  14148. private _vertexBuffers;
  14149. private _indexBuffer;
  14150. private _uniforms;
  14151. private _samplers;
  14152. private _fragment;
  14153. private _floats;
  14154. private _ints;
  14155. private _floatsArrays;
  14156. private _colors3;
  14157. private _colors4;
  14158. private _vectors2;
  14159. private _vectors3;
  14160. private _matrices;
  14161. private _fallbackTextureUsed;
  14162. private _fullEngine;
  14163. private _cachedDefines;
  14164. private _contentUpdateId;
  14165. private _contentData;
  14166. /**
  14167. * Instantiates a new procedural texture.
  14168. * 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.
  14169. * This is the base class of any Procedural texture and contains most of the shareable code.
  14170. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14171. * @param name Define the name of the texture
  14172. * @param size Define the size of the texture to create
  14173. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14174. * @param scene Define the scene the texture belongs to
  14175. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14176. * @param generateMipMaps Define if the texture should creates mip maps or not
  14177. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14178. * @param textureType The FBO internal texture type
  14179. */
  14180. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14181. /**
  14182. * The effect that is created when initializing the post process.
  14183. * @returns The created effect corresponding the the postprocess.
  14184. */
  14185. getEffect(): Effect;
  14186. /**
  14187. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14188. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14189. */
  14190. getContent(): Nullable<ArrayBufferView>;
  14191. private _createIndexBuffer;
  14192. /** @hidden */
  14193. _rebuild(): void;
  14194. /**
  14195. * Resets the texture in order to recreate its associated resources.
  14196. * This can be called in case of context loss
  14197. */
  14198. reset(): void;
  14199. protected _getDefines(): string;
  14200. /**
  14201. * Is the texture ready to be used ? (rendered at least once)
  14202. * @returns true if ready, otherwise, false.
  14203. */
  14204. isReady(): boolean;
  14205. /**
  14206. * Resets the refresh counter of the texture and start bak from scratch.
  14207. * Could be useful to regenerate the texture if it is setup to render only once.
  14208. */
  14209. resetRefreshCounter(): void;
  14210. /**
  14211. * Set the fragment shader to use in order to render the texture.
  14212. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14213. */
  14214. setFragment(fragment: any): void;
  14215. /**
  14216. * Define the refresh rate of the texture or the rendering frequency.
  14217. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14218. */
  14219. get refreshRate(): number;
  14220. set refreshRate(value: number);
  14221. /** @hidden */
  14222. _shouldRender(): boolean;
  14223. /**
  14224. * Get the size the texture is rendering at.
  14225. * @returns the size (on cube texture it is always squared)
  14226. */
  14227. getRenderSize(): RenderTargetTextureSize;
  14228. /**
  14229. * Resize the texture to new value.
  14230. * @param size Define the new size the texture should have
  14231. * @param generateMipMaps Define whether the new texture should create mip maps
  14232. */
  14233. resize(size: number, generateMipMaps: boolean): void;
  14234. private _checkUniform;
  14235. /**
  14236. * Set a texture in the shader program used to render.
  14237. * @param name Define the name of the uniform samplers as defined in the shader
  14238. * @param texture Define the texture to bind to this sampler
  14239. * @return the texture itself allowing "fluent" like uniform updates
  14240. */
  14241. setTexture(name: string, texture: Texture): ProceduralTexture;
  14242. /**
  14243. * Set a float in the shader.
  14244. * @param name Define the name of the uniform as defined in the shader
  14245. * @param value Define the value to give to the uniform
  14246. * @return the texture itself allowing "fluent" like uniform updates
  14247. */
  14248. setFloat(name: string, value: number): ProceduralTexture;
  14249. /**
  14250. * Set a int in the shader.
  14251. * @param name Define the name of the uniform as defined in the shader
  14252. * @param value Define the value to give to the uniform
  14253. * @return the texture itself allowing "fluent" like uniform updates
  14254. */
  14255. setInt(name: string, value: number): ProceduralTexture;
  14256. /**
  14257. * Set an array of floats in the shader.
  14258. * @param name Define the name of the uniform as defined in the shader
  14259. * @param value Define the value to give to the uniform
  14260. * @return the texture itself allowing "fluent" like uniform updates
  14261. */
  14262. setFloats(name: string, value: number[]): ProceduralTexture;
  14263. /**
  14264. * Set a vec3 in the shader from a Color3.
  14265. * @param name Define the name of the uniform as defined in the shader
  14266. * @param value Define the value to give to the uniform
  14267. * @return the texture itself allowing "fluent" like uniform updates
  14268. */
  14269. setColor3(name: string, value: Color3): ProceduralTexture;
  14270. /**
  14271. * Set a vec4 in the shader from a Color4.
  14272. * @param name Define the name of the uniform as defined in the shader
  14273. * @param value Define the value to give to the uniform
  14274. * @return the texture itself allowing "fluent" like uniform updates
  14275. */
  14276. setColor4(name: string, value: Color4): ProceduralTexture;
  14277. /**
  14278. * Set a vec2 in the shader from a Vector2.
  14279. * @param name Define the name of the uniform as defined in the shader
  14280. * @param value Define the value to give to the uniform
  14281. * @return the texture itself allowing "fluent" like uniform updates
  14282. */
  14283. setVector2(name: string, value: Vector2): ProceduralTexture;
  14284. /**
  14285. * Set a vec3 in the shader from a Vector3.
  14286. * @param name Define the name of the uniform as defined in the shader
  14287. * @param value Define the value to give to the uniform
  14288. * @return the texture itself allowing "fluent" like uniform updates
  14289. */
  14290. setVector3(name: string, value: Vector3): ProceduralTexture;
  14291. /**
  14292. * Set a mat4 in the shader from a MAtrix.
  14293. * @param name Define the name of the uniform as defined in the shader
  14294. * @param value Define the value to give to the uniform
  14295. * @return the texture itself allowing "fluent" like uniform updates
  14296. */
  14297. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14298. /**
  14299. * Render the texture to its associated render target.
  14300. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14301. */
  14302. render(useCameraPostProcess?: boolean): void;
  14303. /**
  14304. * Clone the texture.
  14305. * @returns the cloned texture
  14306. */
  14307. clone(): ProceduralTexture;
  14308. /**
  14309. * Dispose the texture and release its asoociated resources.
  14310. */
  14311. dispose(): void;
  14312. }
  14313. }
  14314. declare module BABYLON {
  14315. /**
  14316. * This represents the base class for particle system in Babylon.
  14317. * 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.
  14318. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14319. * @example https://doc.babylonjs.com/babylon101/particles
  14320. */
  14321. export class BaseParticleSystem {
  14322. /**
  14323. * Source color is added to the destination color without alpha affecting the result
  14324. */
  14325. static BLENDMODE_ONEONE: number;
  14326. /**
  14327. * Blend current color and particle color using particle’s alpha
  14328. */
  14329. static BLENDMODE_STANDARD: number;
  14330. /**
  14331. * Add current color and particle color multiplied by particle’s alpha
  14332. */
  14333. static BLENDMODE_ADD: number;
  14334. /**
  14335. * Multiply current color with particle color
  14336. */
  14337. static BLENDMODE_MULTIPLY: number;
  14338. /**
  14339. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14340. */
  14341. static BLENDMODE_MULTIPLYADD: number;
  14342. /**
  14343. * List of animations used by the particle system.
  14344. */
  14345. animations: Animation[];
  14346. /**
  14347. * Gets or sets the unique id of the particle system
  14348. */
  14349. uniqueId: number;
  14350. /**
  14351. * The id of the Particle system.
  14352. */
  14353. id: string;
  14354. /**
  14355. * The friendly name of the Particle system.
  14356. */
  14357. name: string;
  14358. /**
  14359. * Snippet ID if the particle system was created from the snippet server
  14360. */
  14361. snippetId: string;
  14362. /**
  14363. * The rendering group used by the Particle system to chose when to render.
  14364. */
  14365. renderingGroupId: number;
  14366. /**
  14367. * The emitter represents the Mesh or position we are attaching the particle system to.
  14368. */
  14369. emitter: Nullable<AbstractMesh | Vector3>;
  14370. /**
  14371. * The maximum number of particles to emit per frame
  14372. */
  14373. emitRate: number;
  14374. /**
  14375. * If you want to launch only a few particles at once, that can be done, as well.
  14376. */
  14377. manualEmitCount: number;
  14378. /**
  14379. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14380. */
  14381. updateSpeed: number;
  14382. /**
  14383. * The amount of time the particle system is running (depends of the overall update speed).
  14384. */
  14385. targetStopDuration: number;
  14386. /**
  14387. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14388. */
  14389. disposeOnStop: boolean;
  14390. /**
  14391. * Minimum power of emitting particles.
  14392. */
  14393. minEmitPower: number;
  14394. /**
  14395. * Maximum power of emitting particles.
  14396. */
  14397. maxEmitPower: number;
  14398. /**
  14399. * Minimum life time of emitting particles.
  14400. */
  14401. minLifeTime: number;
  14402. /**
  14403. * Maximum life time of emitting particles.
  14404. */
  14405. maxLifeTime: number;
  14406. /**
  14407. * Minimum Size of emitting particles.
  14408. */
  14409. minSize: number;
  14410. /**
  14411. * Maximum Size of emitting particles.
  14412. */
  14413. maxSize: number;
  14414. /**
  14415. * Minimum scale of emitting particles on X axis.
  14416. */
  14417. minScaleX: number;
  14418. /**
  14419. * Maximum scale of emitting particles on X axis.
  14420. */
  14421. maxScaleX: number;
  14422. /**
  14423. * Minimum scale of emitting particles on Y axis.
  14424. */
  14425. minScaleY: number;
  14426. /**
  14427. * Maximum scale of emitting particles on Y axis.
  14428. */
  14429. maxScaleY: number;
  14430. /**
  14431. * Gets or sets the minimal initial rotation in radians.
  14432. */
  14433. minInitialRotation: number;
  14434. /**
  14435. * Gets or sets the maximal initial rotation in radians.
  14436. */
  14437. maxInitialRotation: number;
  14438. /**
  14439. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14440. */
  14441. minAngularSpeed: number;
  14442. /**
  14443. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14444. */
  14445. maxAngularSpeed: number;
  14446. /**
  14447. * The texture used to render each particle. (this can be a spritesheet)
  14448. */
  14449. particleTexture: Nullable<BaseTexture>;
  14450. /**
  14451. * The layer mask we are rendering the particles through.
  14452. */
  14453. layerMask: number;
  14454. /**
  14455. * This can help using your own shader to render the particle system.
  14456. * The according effect will be created
  14457. */
  14458. customShader: any;
  14459. /**
  14460. * By default particle system starts as soon as they are created. This prevents the
  14461. * automatic start to happen and let you decide when to start emitting particles.
  14462. */
  14463. preventAutoStart: boolean;
  14464. private _noiseTexture;
  14465. /**
  14466. * Gets or sets a texture used to add random noise to particle positions
  14467. */
  14468. get noiseTexture(): Nullable<ProceduralTexture>;
  14469. set noiseTexture(value: Nullable<ProceduralTexture>);
  14470. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14471. noiseStrength: Vector3;
  14472. /**
  14473. * Callback triggered when the particle animation is ending.
  14474. */
  14475. onAnimationEnd: Nullable<() => void>;
  14476. /**
  14477. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14478. */
  14479. blendMode: number;
  14480. /**
  14481. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14482. * to override the particles.
  14483. */
  14484. forceDepthWrite: boolean;
  14485. /** 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 */
  14486. preWarmCycles: number;
  14487. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14488. preWarmStepOffset: number;
  14489. /**
  14490. * 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)
  14491. */
  14492. spriteCellChangeSpeed: number;
  14493. /**
  14494. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14495. */
  14496. startSpriteCellID: number;
  14497. /**
  14498. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14499. */
  14500. endSpriteCellID: number;
  14501. /**
  14502. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14503. */
  14504. spriteCellWidth: number;
  14505. /**
  14506. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14507. */
  14508. spriteCellHeight: number;
  14509. /**
  14510. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14511. */
  14512. spriteRandomStartCell: boolean;
  14513. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14514. translationPivot: Vector2;
  14515. /** @hidden */
  14516. protected _isAnimationSheetEnabled: boolean;
  14517. /**
  14518. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14519. */
  14520. beginAnimationOnStart: boolean;
  14521. /**
  14522. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14523. */
  14524. beginAnimationFrom: number;
  14525. /**
  14526. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14527. */
  14528. beginAnimationTo: number;
  14529. /**
  14530. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14531. */
  14532. beginAnimationLoop: boolean;
  14533. /**
  14534. * Gets or sets a world offset applied to all particles
  14535. */
  14536. worldOffset: Vector3;
  14537. /**
  14538. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14539. */
  14540. get isAnimationSheetEnabled(): boolean;
  14541. set isAnimationSheetEnabled(value: boolean);
  14542. /**
  14543. * Get hosting scene
  14544. * @returns the scene
  14545. */
  14546. getScene(): Nullable<Scene>;
  14547. /**
  14548. * You can use gravity if you want to give an orientation to your particles.
  14549. */
  14550. gravity: Vector3;
  14551. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14552. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14553. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14554. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14555. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14556. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14557. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14558. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14559. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14560. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14561. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14562. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14563. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14564. /**
  14565. * Defines the delay in milliseconds before starting the system (0 by default)
  14566. */
  14567. startDelay: number;
  14568. /**
  14569. * Gets the current list of drag gradients.
  14570. * You must use addDragGradient and removeDragGradient to udpate this list
  14571. * @returns the list of drag gradients
  14572. */
  14573. getDragGradients(): Nullable<Array<FactorGradient>>;
  14574. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14575. limitVelocityDamping: number;
  14576. /**
  14577. * Gets the current list of limit velocity gradients.
  14578. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14579. * @returns the list of limit velocity gradients
  14580. */
  14581. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14582. /**
  14583. * Gets the current list of color gradients.
  14584. * You must use addColorGradient and removeColorGradient to udpate this list
  14585. * @returns the list of color gradients
  14586. */
  14587. getColorGradients(): Nullable<Array<ColorGradient>>;
  14588. /**
  14589. * Gets the current list of size gradients.
  14590. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14591. * @returns the list of size gradients
  14592. */
  14593. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14594. /**
  14595. * Gets the current list of color remap gradients.
  14596. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14597. * @returns the list of color remap gradients
  14598. */
  14599. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14600. /**
  14601. * Gets the current list of alpha remap gradients.
  14602. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14603. * @returns the list of alpha remap gradients
  14604. */
  14605. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14606. /**
  14607. * Gets the current list of life time gradients.
  14608. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14609. * @returns the list of life time gradients
  14610. */
  14611. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14612. /**
  14613. * Gets the current list of angular speed gradients.
  14614. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14615. * @returns the list of angular speed gradients
  14616. */
  14617. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14618. /**
  14619. * Gets the current list of velocity gradients.
  14620. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14621. * @returns the list of velocity gradients
  14622. */
  14623. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14624. /**
  14625. * Gets the current list of start size gradients.
  14626. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14627. * @returns the list of start size gradients
  14628. */
  14629. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14630. /**
  14631. * Gets the current list of emit rate gradients.
  14632. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14633. * @returns the list of emit rate gradients
  14634. */
  14635. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14636. /**
  14637. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14638. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14639. */
  14640. get direction1(): Vector3;
  14641. set direction1(value: Vector3);
  14642. /**
  14643. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14644. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14645. */
  14646. get direction2(): Vector3;
  14647. set direction2(value: Vector3);
  14648. /**
  14649. * 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.
  14650. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14651. */
  14652. get minEmitBox(): Vector3;
  14653. set minEmitBox(value: Vector3);
  14654. /**
  14655. * 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.
  14656. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14657. */
  14658. get maxEmitBox(): Vector3;
  14659. set maxEmitBox(value: Vector3);
  14660. /**
  14661. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14662. */
  14663. color1: Color4;
  14664. /**
  14665. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14666. */
  14667. color2: Color4;
  14668. /**
  14669. * Color the particle will have at the end of its lifetime
  14670. */
  14671. colorDead: Color4;
  14672. /**
  14673. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14674. */
  14675. textureMask: Color4;
  14676. /**
  14677. * The particle emitter type defines the emitter used by the particle system.
  14678. * It can be for example box, sphere, or cone...
  14679. */
  14680. particleEmitterType: IParticleEmitterType;
  14681. /** @hidden */
  14682. _isSubEmitter: boolean;
  14683. /**
  14684. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14685. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14686. */
  14687. billboardMode: number;
  14688. protected _isBillboardBased: boolean;
  14689. /**
  14690. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14691. */
  14692. get isBillboardBased(): boolean;
  14693. set isBillboardBased(value: boolean);
  14694. /**
  14695. * The scene the particle system belongs to.
  14696. */
  14697. protected _scene: Nullable<Scene>;
  14698. /**
  14699. * The engine the particle system belongs to.
  14700. */
  14701. protected _engine: ThinEngine;
  14702. /**
  14703. * Local cache of defines for image processing.
  14704. */
  14705. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14706. /**
  14707. * Default configuration related to image processing available in the standard Material.
  14708. */
  14709. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  14710. /**
  14711. * Gets the image processing configuration used either in this material.
  14712. */
  14713. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  14714. /**
  14715. * Sets the Default image processing configuration used either in the this material.
  14716. *
  14717. * If sets to null, the scene one is in use.
  14718. */
  14719. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  14720. /**
  14721. * Attaches a new image processing configuration to the Standard Material.
  14722. * @param configuration
  14723. */
  14724. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14725. /** @hidden */
  14726. protected _reset(): void;
  14727. /** @hidden */
  14728. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14729. /**
  14730. * Instantiates a particle system.
  14731. * 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.
  14732. * @param name The name of the particle system
  14733. */
  14734. constructor(name: string);
  14735. /**
  14736. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14737. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14738. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14739. * @returns the emitter
  14740. */
  14741. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14742. /**
  14743. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14744. * @param radius The radius of the hemisphere to emit from
  14745. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14746. * @returns the emitter
  14747. */
  14748. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14749. /**
  14750. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14751. * @param radius The radius of the sphere to emit from
  14752. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14753. * @returns the emitter
  14754. */
  14755. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14756. /**
  14757. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14758. * @param radius The radius of the sphere to emit from
  14759. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14760. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14761. * @returns the emitter
  14762. */
  14763. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14764. /**
  14765. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14766. * @param radius The radius of the emission cylinder
  14767. * @param height The height of the emission cylinder
  14768. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14769. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14770. * @returns the emitter
  14771. */
  14772. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14773. /**
  14774. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14775. * @param radius The radius of the cylinder to emit from
  14776. * @param height The height of the emission cylinder
  14777. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14778. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14779. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14780. * @returns the emitter
  14781. */
  14782. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14783. /**
  14784. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14785. * @param radius The radius of the cone to emit from
  14786. * @param angle The base angle of the cone
  14787. * @returns the emitter
  14788. */
  14789. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14790. /**
  14791. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14792. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14793. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14794. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14795. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14796. * @returns the emitter
  14797. */
  14798. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14799. }
  14800. }
  14801. declare module BABYLON {
  14802. /**
  14803. * Type of sub emitter
  14804. */
  14805. export enum SubEmitterType {
  14806. /**
  14807. * Attached to the particle over it's lifetime
  14808. */
  14809. ATTACHED = 0,
  14810. /**
  14811. * Created when the particle dies
  14812. */
  14813. END = 1
  14814. }
  14815. /**
  14816. * Sub emitter class used to emit particles from an existing particle
  14817. */
  14818. export class SubEmitter {
  14819. /**
  14820. * the particle system to be used by the sub emitter
  14821. */
  14822. particleSystem: ParticleSystem;
  14823. /**
  14824. * Type of the submitter (Default: END)
  14825. */
  14826. type: SubEmitterType;
  14827. /**
  14828. * 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)
  14829. * Note: This only is supported when using an emitter of type Mesh
  14830. */
  14831. inheritDirection: boolean;
  14832. /**
  14833. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14834. */
  14835. inheritedVelocityAmount: number;
  14836. /**
  14837. * Creates a sub emitter
  14838. * @param particleSystem the particle system to be used by the sub emitter
  14839. */
  14840. constructor(
  14841. /**
  14842. * the particle system to be used by the sub emitter
  14843. */
  14844. particleSystem: ParticleSystem);
  14845. /**
  14846. * Clones the sub emitter
  14847. * @returns the cloned sub emitter
  14848. */
  14849. clone(): SubEmitter;
  14850. /**
  14851. * Serialize current object to a JSON object
  14852. * @returns the serialized object
  14853. */
  14854. serialize(): any;
  14855. /** @hidden */
  14856. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  14857. /**
  14858. * Creates a new SubEmitter from a serialized JSON version
  14859. * @param serializationObject defines the JSON object to read from
  14860. * @param sceneOrEngine defines the hosting scene or the hosting engine
  14861. * @param rootUrl defines the rootUrl for data loading
  14862. * @returns a new SubEmitter
  14863. */
  14864. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  14865. /** Release associated resources */
  14866. dispose(): void;
  14867. }
  14868. }
  14869. declare module BABYLON {
  14870. /** @hidden */
  14871. export var clipPlaneFragmentDeclaration: {
  14872. name: string;
  14873. shader: string;
  14874. };
  14875. }
  14876. declare module BABYLON {
  14877. /** @hidden */
  14878. export var imageProcessingDeclaration: {
  14879. name: string;
  14880. shader: string;
  14881. };
  14882. }
  14883. declare module BABYLON {
  14884. /** @hidden */
  14885. export var imageProcessingFunctions: {
  14886. name: string;
  14887. shader: string;
  14888. };
  14889. }
  14890. declare module BABYLON {
  14891. /** @hidden */
  14892. export var clipPlaneFragment: {
  14893. name: string;
  14894. shader: string;
  14895. };
  14896. }
  14897. declare module BABYLON {
  14898. /** @hidden */
  14899. export var particlesPixelShader: {
  14900. name: string;
  14901. shader: string;
  14902. };
  14903. }
  14904. declare module BABYLON {
  14905. /** @hidden */
  14906. export var clipPlaneVertexDeclaration: {
  14907. name: string;
  14908. shader: string;
  14909. };
  14910. }
  14911. declare module BABYLON {
  14912. /** @hidden */
  14913. export var clipPlaneVertex: {
  14914. name: string;
  14915. shader: string;
  14916. };
  14917. }
  14918. declare module BABYLON {
  14919. /** @hidden */
  14920. export var particlesVertexShader: {
  14921. name: string;
  14922. shader: string;
  14923. };
  14924. }
  14925. declare module BABYLON {
  14926. /**
  14927. * Interface used to define entities containing multiple clip planes
  14928. */
  14929. export interface IClipPlanesHolder {
  14930. /**
  14931. * Gets or sets the active clipplane 1
  14932. */
  14933. clipPlane: Nullable<Plane>;
  14934. /**
  14935. * Gets or sets the active clipplane 2
  14936. */
  14937. clipPlane2: Nullable<Plane>;
  14938. /**
  14939. * Gets or sets the active clipplane 3
  14940. */
  14941. clipPlane3: Nullable<Plane>;
  14942. /**
  14943. * Gets or sets the active clipplane 4
  14944. */
  14945. clipPlane4: Nullable<Plane>;
  14946. /**
  14947. * Gets or sets the active clipplane 5
  14948. */
  14949. clipPlane5: Nullable<Plane>;
  14950. /**
  14951. * Gets or sets the active clipplane 6
  14952. */
  14953. clipPlane6: Nullable<Plane>;
  14954. }
  14955. }
  14956. declare module BABYLON {
  14957. /**
  14958. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  14959. *
  14960. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  14961. *
  14962. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14963. */
  14964. export class ThinMaterialHelper {
  14965. /**
  14966. * Binds the clip plane information from the holder to the effect.
  14967. * @param effect The effect we are binding the data to
  14968. * @param holder The entity containing the clip plane information
  14969. */
  14970. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  14971. }
  14972. }
  14973. declare module BABYLON {
  14974. interface ThinEngine {
  14975. /**
  14976. * Sets alpha constants used by some alpha blending modes
  14977. * @param r defines the red component
  14978. * @param g defines the green component
  14979. * @param b defines the blue component
  14980. * @param a defines the alpha component
  14981. */
  14982. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  14983. /**
  14984. * Sets the current alpha mode
  14985. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  14986. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  14987. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14988. */
  14989. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  14990. /**
  14991. * Gets the current alpha mode
  14992. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14993. * @returns the current alpha mode
  14994. */
  14995. getAlphaMode(): number;
  14996. /**
  14997. * Sets the current alpha equation
  14998. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  14999. */
  15000. setAlphaEquation(equation: number): void;
  15001. /**
  15002. * Gets the current alpha equation.
  15003. * @returns the current alpha equation
  15004. */
  15005. getAlphaEquation(): number;
  15006. }
  15007. }
  15008. declare module BABYLON {
  15009. /**
  15010. * This represents a particle system in Babylon.
  15011. * 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.
  15012. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15013. * @example https://doc.babylonjs.com/babylon101/particles
  15014. */
  15015. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15016. /**
  15017. * Billboard mode will only apply to Y axis
  15018. */
  15019. static readonly BILLBOARDMODE_Y: number;
  15020. /**
  15021. * Billboard mode will apply to all axes
  15022. */
  15023. static readonly BILLBOARDMODE_ALL: number;
  15024. /**
  15025. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15026. */
  15027. static readonly BILLBOARDMODE_STRETCHED: number;
  15028. /**
  15029. * This function can be defined to provide custom update for active particles.
  15030. * This function will be called instead of regular update (age, position, color, etc.).
  15031. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15032. */
  15033. updateFunction: (particles: Particle[]) => void;
  15034. private _emitterWorldMatrix;
  15035. /**
  15036. * This function can be defined to specify initial direction for every new particle.
  15037. * It by default use the emitterType defined function
  15038. */
  15039. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15040. /**
  15041. * This function can be defined to specify initial position for every new particle.
  15042. * It by default use the emitterType defined function
  15043. */
  15044. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15045. /**
  15046. * @hidden
  15047. */
  15048. _inheritedVelocityOffset: Vector3;
  15049. /**
  15050. * An event triggered when the system is disposed
  15051. */
  15052. onDisposeObservable: Observable<IParticleSystem>;
  15053. /**
  15054. * An event triggered when the system is stopped
  15055. */
  15056. onStoppedObservable: Observable<IParticleSystem>;
  15057. private _onDisposeObserver;
  15058. /**
  15059. * Sets a callback that will be triggered when the system is disposed
  15060. */
  15061. set onDispose(callback: () => void);
  15062. private _particles;
  15063. private _epsilon;
  15064. private _capacity;
  15065. private _stockParticles;
  15066. private _newPartsExcess;
  15067. private _vertexData;
  15068. private _vertexBuffer;
  15069. private _vertexBuffers;
  15070. private _spriteBuffer;
  15071. private _indexBuffer;
  15072. private _effect;
  15073. private _customEffect;
  15074. private _cachedDefines;
  15075. private _scaledColorStep;
  15076. private _colorDiff;
  15077. private _scaledDirection;
  15078. private _scaledGravity;
  15079. private _currentRenderId;
  15080. private _alive;
  15081. private _useInstancing;
  15082. private _vertexArrayObject;
  15083. private _started;
  15084. private _stopped;
  15085. private _actualFrame;
  15086. private _scaledUpdateSpeed;
  15087. private _vertexBufferSize;
  15088. /** @hidden */
  15089. _currentEmitRateGradient: Nullable<FactorGradient>;
  15090. /** @hidden */
  15091. _currentEmitRate1: number;
  15092. /** @hidden */
  15093. _currentEmitRate2: number;
  15094. /** @hidden */
  15095. _currentStartSizeGradient: Nullable<FactorGradient>;
  15096. /** @hidden */
  15097. _currentStartSize1: number;
  15098. /** @hidden */
  15099. _currentStartSize2: number;
  15100. private readonly _rawTextureWidth;
  15101. private _rampGradientsTexture;
  15102. private _useRampGradients;
  15103. /** Gets or sets a matrix to use to compute projection */
  15104. defaultProjectionMatrix: Matrix;
  15105. /** Gets or sets a matrix to use to compute view */
  15106. defaultViewMatrix: Matrix;
  15107. /** Gets or sets a boolean indicating that ramp gradients must be used
  15108. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15109. */
  15110. get useRampGradients(): boolean;
  15111. set useRampGradients(value: boolean);
  15112. /**
  15113. * 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.
  15114. * 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: [])
  15115. */
  15116. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15117. private _subEmitters;
  15118. /**
  15119. * @hidden
  15120. * If the particle systems emitter should be disposed when the particle system is disposed
  15121. */
  15122. _disposeEmitterOnDispose: boolean;
  15123. /**
  15124. * The current active Sub-systems, this property is used by the root particle system only.
  15125. */
  15126. activeSubSystems: Array<ParticleSystem>;
  15127. /**
  15128. * Specifies if the particles are updated in emitter local space or world space
  15129. */
  15130. isLocal: boolean;
  15131. private _rootParticleSystem;
  15132. /**
  15133. * Gets the current list of active particles
  15134. */
  15135. get particles(): Particle[];
  15136. /**
  15137. * Gets the number of particles active at the same time.
  15138. * @returns The number of active particles.
  15139. */
  15140. getActiveCount(): number;
  15141. /**
  15142. * Returns the string "ParticleSystem"
  15143. * @returns a string containing the class name
  15144. */
  15145. getClassName(): string;
  15146. /**
  15147. * Gets a boolean indicating that the system is stopping
  15148. * @returns true if the system is currently stopping
  15149. */
  15150. isStopping(): boolean;
  15151. /**
  15152. * Gets the custom effect used to render the particles
  15153. * @param blendMode Blend mode for which the effect should be retrieved
  15154. * @returns The effect
  15155. */
  15156. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15157. /**
  15158. * Sets the custom effect used to render the particles
  15159. * @param effect The effect to set
  15160. * @param blendMode Blend mode for which the effect should be set
  15161. */
  15162. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15163. /** @hidden */
  15164. private _onBeforeDrawParticlesObservable;
  15165. /**
  15166. * Observable that will be called just before the particles are drawn
  15167. */
  15168. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15169. /**
  15170. * Gets the name of the particle vertex shader
  15171. */
  15172. get vertexShaderName(): string;
  15173. /**
  15174. * Instantiates a particle system.
  15175. * 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.
  15176. * @param name The name of the particle system
  15177. * @param capacity The max number of particles alive at the same time
  15178. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15179. * @param customEffect a custom effect used to change the way particles are rendered by default
  15180. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15181. * @param epsilon Offset used to render the particles
  15182. */
  15183. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15184. private _addFactorGradient;
  15185. private _removeFactorGradient;
  15186. /**
  15187. * Adds a new life time gradient
  15188. * @param gradient defines the gradient to use (between 0 and 1)
  15189. * @param factor defines the life time factor to affect to the specified gradient
  15190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15191. * @returns the current particle system
  15192. */
  15193. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15194. /**
  15195. * Remove a specific life time gradient
  15196. * @param gradient defines the gradient to remove
  15197. * @returns the current particle system
  15198. */
  15199. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15200. /**
  15201. * Adds a new size gradient
  15202. * @param gradient defines the gradient to use (between 0 and 1)
  15203. * @param factor defines the size factor to affect to the specified gradient
  15204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15205. * @returns the current particle system
  15206. */
  15207. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15208. /**
  15209. * Remove a specific size gradient
  15210. * @param gradient defines the gradient to remove
  15211. * @returns the current particle system
  15212. */
  15213. removeSizeGradient(gradient: number): IParticleSystem;
  15214. /**
  15215. * Adds a new color remap gradient
  15216. * @param gradient defines the gradient to use (between 0 and 1)
  15217. * @param min defines the color remap minimal range
  15218. * @param max defines the color remap maximal range
  15219. * @returns the current particle system
  15220. */
  15221. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15222. /**
  15223. * Remove a specific color remap gradient
  15224. * @param gradient defines the gradient to remove
  15225. * @returns the current particle system
  15226. */
  15227. removeColorRemapGradient(gradient: number): IParticleSystem;
  15228. /**
  15229. * Adds a new alpha remap gradient
  15230. * @param gradient defines the gradient to use (between 0 and 1)
  15231. * @param min defines the alpha remap minimal range
  15232. * @param max defines the alpha remap maximal range
  15233. * @returns the current particle system
  15234. */
  15235. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15236. /**
  15237. * Remove a specific alpha remap gradient
  15238. * @param gradient defines the gradient to remove
  15239. * @returns the current particle system
  15240. */
  15241. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15242. /**
  15243. * Adds a new angular speed gradient
  15244. * @param gradient defines the gradient to use (between 0 and 1)
  15245. * @param factor defines the angular speed to affect to the specified gradient
  15246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15247. * @returns the current particle system
  15248. */
  15249. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15250. /**
  15251. * Remove a specific angular speed gradient
  15252. * @param gradient defines the gradient to remove
  15253. * @returns the current particle system
  15254. */
  15255. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15256. /**
  15257. * Adds a new velocity gradient
  15258. * @param gradient defines the gradient to use (between 0 and 1)
  15259. * @param factor defines the velocity to affect to the specified gradient
  15260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15261. * @returns the current particle system
  15262. */
  15263. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15264. /**
  15265. * Remove a specific velocity gradient
  15266. * @param gradient defines the gradient to remove
  15267. * @returns the current particle system
  15268. */
  15269. removeVelocityGradient(gradient: number): IParticleSystem;
  15270. /**
  15271. * Adds a new limit velocity gradient
  15272. * @param gradient defines the gradient to use (between 0 and 1)
  15273. * @param factor defines the limit velocity value to affect to the specified gradient
  15274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15275. * @returns the current particle system
  15276. */
  15277. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15278. /**
  15279. * Remove a specific limit velocity gradient
  15280. * @param gradient defines the gradient to remove
  15281. * @returns the current particle system
  15282. */
  15283. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15284. /**
  15285. * Adds a new drag gradient
  15286. * @param gradient defines the gradient to use (between 0 and 1)
  15287. * @param factor defines the drag value to affect to the specified gradient
  15288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15289. * @returns the current particle system
  15290. */
  15291. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15292. /**
  15293. * Remove a specific drag gradient
  15294. * @param gradient defines the gradient to remove
  15295. * @returns the current particle system
  15296. */
  15297. removeDragGradient(gradient: number): IParticleSystem;
  15298. /**
  15299. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15300. * @param gradient defines the gradient to use (between 0 and 1)
  15301. * @param factor defines the emit rate value to affect to the specified gradient
  15302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15303. * @returns the current particle system
  15304. */
  15305. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15306. /**
  15307. * Remove a specific emit rate gradient
  15308. * @param gradient defines the gradient to remove
  15309. * @returns the current particle system
  15310. */
  15311. removeEmitRateGradient(gradient: number): IParticleSystem;
  15312. /**
  15313. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15314. * @param gradient defines the gradient to use (between 0 and 1)
  15315. * @param factor defines the start size value to affect to the specified gradient
  15316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15317. * @returns the current particle system
  15318. */
  15319. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15320. /**
  15321. * Remove a specific start size gradient
  15322. * @param gradient defines the gradient to remove
  15323. * @returns the current particle system
  15324. */
  15325. removeStartSizeGradient(gradient: number): IParticleSystem;
  15326. private _createRampGradientTexture;
  15327. /**
  15328. * Gets the current list of ramp gradients.
  15329. * You must use addRampGradient and removeRampGradient to udpate this list
  15330. * @returns the list of ramp gradients
  15331. */
  15332. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15333. /** Force the system to rebuild all gradients that need to be resync */
  15334. forceRefreshGradients(): void;
  15335. private _syncRampGradientTexture;
  15336. /**
  15337. * Adds a new ramp gradient used to remap particle colors
  15338. * @param gradient defines the gradient to use (between 0 and 1)
  15339. * @param color defines the color to affect to the specified gradient
  15340. * @returns the current particle system
  15341. */
  15342. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15343. /**
  15344. * Remove a specific ramp gradient
  15345. * @param gradient defines the gradient to remove
  15346. * @returns the current particle system
  15347. */
  15348. removeRampGradient(gradient: number): ParticleSystem;
  15349. /**
  15350. * Adds a new color gradient
  15351. * @param gradient defines the gradient to use (between 0 and 1)
  15352. * @param color1 defines the color to affect to the specified gradient
  15353. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15354. * @returns this particle system
  15355. */
  15356. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15357. /**
  15358. * Remove a specific color gradient
  15359. * @param gradient defines the gradient to remove
  15360. * @returns this particle system
  15361. */
  15362. removeColorGradient(gradient: number): IParticleSystem;
  15363. private _fetchR;
  15364. protected _reset(): void;
  15365. private _resetEffect;
  15366. private _createVertexBuffers;
  15367. private _createIndexBuffer;
  15368. /**
  15369. * Gets the maximum number of particles active at the same time.
  15370. * @returns The max number of active particles.
  15371. */
  15372. getCapacity(): number;
  15373. /**
  15374. * Gets whether there are still active particles in the system.
  15375. * @returns True if it is alive, otherwise false.
  15376. */
  15377. isAlive(): boolean;
  15378. /**
  15379. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15380. * @returns True if it has been started, otherwise false.
  15381. */
  15382. isStarted(): boolean;
  15383. private _prepareSubEmitterInternalArray;
  15384. /**
  15385. * Starts the particle system and begins to emit
  15386. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15387. */
  15388. start(delay?: number): void;
  15389. /**
  15390. * Stops the particle system.
  15391. * @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.
  15392. */
  15393. stop(stopSubEmitters?: boolean): void;
  15394. /**
  15395. * Remove all active particles
  15396. */
  15397. reset(): void;
  15398. /**
  15399. * @hidden (for internal use only)
  15400. */
  15401. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15402. /**
  15403. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15404. * Its lifetime will start back at 0.
  15405. */
  15406. recycleParticle: (particle: Particle) => void;
  15407. private _stopSubEmitters;
  15408. private _createParticle;
  15409. private _removeFromRoot;
  15410. private _emitFromParticle;
  15411. private _update;
  15412. /** @hidden */
  15413. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15414. /** @hidden */
  15415. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15416. /**
  15417. * Fill the defines array according to the current settings of the particle system
  15418. * @param defines Array to be updated
  15419. * @param blendMode blend mode to take into account when updating the array
  15420. */
  15421. fillDefines(defines: Array<string>, blendMode: number): void;
  15422. /**
  15423. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15424. * @param uniforms Uniforms array to fill
  15425. * @param attributes Attributes array to fill
  15426. * @param samplers Samplers array to fill
  15427. */
  15428. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15429. /** @hidden */
  15430. private _getEffect;
  15431. /**
  15432. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15433. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15434. */
  15435. animate(preWarmOnly?: boolean): void;
  15436. private _appendParticleVertices;
  15437. /**
  15438. * Rebuilds the particle system.
  15439. */
  15440. rebuild(): void;
  15441. /**
  15442. * Is this system ready to be used/rendered
  15443. * @return true if the system is ready
  15444. */
  15445. isReady(): boolean;
  15446. private _render;
  15447. /**
  15448. * Renders the particle system in its current state.
  15449. * @returns the current number of particles
  15450. */
  15451. render(): number;
  15452. /**
  15453. * Disposes the particle system and free the associated resources
  15454. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15455. */
  15456. dispose(disposeTexture?: boolean): void;
  15457. /**
  15458. * Clones the particle system.
  15459. * @param name The name of the cloned object
  15460. * @param newEmitter The new emitter to use
  15461. * @returns the cloned particle system
  15462. */
  15463. clone(name: string, newEmitter: any): ParticleSystem;
  15464. /**
  15465. * Serializes the particle system to a JSON object
  15466. * @param serializeTexture defines if the texture must be serialized as well
  15467. * @returns the JSON object
  15468. */
  15469. serialize(serializeTexture?: boolean): any;
  15470. /** @hidden */
  15471. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15472. /** @hidden */
  15473. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15474. /**
  15475. * Parses a JSON object to create a particle system.
  15476. * @param parsedParticleSystem The JSON object to parse
  15477. * @param sceneOrEngine The scene or the engine to create the particle system in
  15478. * @param rootUrl The root url to use to load external dependencies like texture
  15479. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15480. * @returns the Parsed particle system
  15481. */
  15482. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15483. }
  15484. }
  15485. declare module BABYLON {
  15486. /**
  15487. * A particle represents one of the element emitted by a particle system.
  15488. * This is mainly define by its coordinates, direction, velocity and age.
  15489. */
  15490. export class Particle {
  15491. /**
  15492. * The particle system the particle belongs to.
  15493. */
  15494. particleSystem: ParticleSystem;
  15495. private static _Count;
  15496. /**
  15497. * Unique ID of the particle
  15498. */
  15499. id: number;
  15500. /**
  15501. * The world position of the particle in the scene.
  15502. */
  15503. position: Vector3;
  15504. /**
  15505. * The world direction of the particle in the scene.
  15506. */
  15507. direction: Vector3;
  15508. /**
  15509. * The color of the particle.
  15510. */
  15511. color: Color4;
  15512. /**
  15513. * The color change of the particle per step.
  15514. */
  15515. colorStep: Color4;
  15516. /**
  15517. * Defines how long will the life of the particle be.
  15518. */
  15519. lifeTime: number;
  15520. /**
  15521. * The current age of the particle.
  15522. */
  15523. age: number;
  15524. /**
  15525. * The current size of the particle.
  15526. */
  15527. size: number;
  15528. /**
  15529. * The current scale of the particle.
  15530. */
  15531. scale: Vector2;
  15532. /**
  15533. * The current angle of the particle.
  15534. */
  15535. angle: number;
  15536. /**
  15537. * Defines how fast is the angle changing.
  15538. */
  15539. angularSpeed: number;
  15540. /**
  15541. * Defines the cell index used by the particle to be rendered from a sprite.
  15542. */
  15543. cellIndex: number;
  15544. /**
  15545. * The information required to support color remapping
  15546. */
  15547. remapData: Vector4;
  15548. /** @hidden */
  15549. _randomCellOffset?: number;
  15550. /** @hidden */
  15551. _initialDirection: Nullable<Vector3>;
  15552. /** @hidden */
  15553. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15554. /** @hidden */
  15555. _initialStartSpriteCellID: number;
  15556. /** @hidden */
  15557. _initialEndSpriteCellID: number;
  15558. /** @hidden */
  15559. _currentColorGradient: Nullable<ColorGradient>;
  15560. /** @hidden */
  15561. _currentColor1: Color4;
  15562. /** @hidden */
  15563. _currentColor2: Color4;
  15564. /** @hidden */
  15565. _currentSizeGradient: Nullable<FactorGradient>;
  15566. /** @hidden */
  15567. _currentSize1: number;
  15568. /** @hidden */
  15569. _currentSize2: number;
  15570. /** @hidden */
  15571. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15572. /** @hidden */
  15573. _currentAngularSpeed1: number;
  15574. /** @hidden */
  15575. _currentAngularSpeed2: number;
  15576. /** @hidden */
  15577. _currentVelocityGradient: Nullable<FactorGradient>;
  15578. /** @hidden */
  15579. _currentVelocity1: number;
  15580. /** @hidden */
  15581. _currentVelocity2: number;
  15582. /** @hidden */
  15583. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15584. /** @hidden */
  15585. _currentLimitVelocity1: number;
  15586. /** @hidden */
  15587. _currentLimitVelocity2: number;
  15588. /** @hidden */
  15589. _currentDragGradient: Nullable<FactorGradient>;
  15590. /** @hidden */
  15591. _currentDrag1: number;
  15592. /** @hidden */
  15593. _currentDrag2: number;
  15594. /** @hidden */
  15595. _randomNoiseCoordinates1: Vector3;
  15596. /** @hidden */
  15597. _randomNoiseCoordinates2: Vector3;
  15598. /** @hidden */
  15599. _localPosition?: Vector3;
  15600. /**
  15601. * Creates a new instance Particle
  15602. * @param particleSystem the particle system the particle belongs to
  15603. */
  15604. constructor(
  15605. /**
  15606. * The particle system the particle belongs to.
  15607. */
  15608. particleSystem: ParticleSystem);
  15609. private updateCellInfoFromSystem;
  15610. /**
  15611. * Defines how the sprite cell index is updated for the particle
  15612. */
  15613. updateCellIndex(): void;
  15614. /** @hidden */
  15615. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15616. /** @hidden */
  15617. _inheritParticleInfoToSubEmitters(): void;
  15618. /** @hidden */
  15619. _reset(): void;
  15620. /**
  15621. * Copy the properties of particle to another one.
  15622. * @param other the particle to copy the information to.
  15623. */
  15624. copyTo(other: Particle): void;
  15625. }
  15626. }
  15627. declare module BABYLON {
  15628. /**
  15629. * Particle emitter represents a volume emitting particles.
  15630. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15631. */
  15632. export interface IParticleEmitterType {
  15633. /**
  15634. * Called by the particle System when the direction is computed for the created particle.
  15635. * @param worldMatrix is the world matrix of the particle system
  15636. * @param directionToUpdate is the direction vector to update with the result
  15637. * @param particle is the particle we are computed the direction for
  15638. * @param isLocal defines if the direction should be set in local space
  15639. */
  15640. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15641. /**
  15642. * Called by the particle System when the position is computed for the created particle.
  15643. * @param worldMatrix is the world matrix of the particle system
  15644. * @param positionToUpdate is the position vector to update with the result
  15645. * @param particle is the particle we are computed the position for
  15646. * @param isLocal defines if the position should be set in local space
  15647. */
  15648. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15649. /**
  15650. * Clones the current emitter and returns a copy of it
  15651. * @returns the new emitter
  15652. */
  15653. clone(): IParticleEmitterType;
  15654. /**
  15655. * Called by the GPUParticleSystem to setup the update shader
  15656. * @param effect defines the update shader
  15657. */
  15658. applyToShader(effect: Effect): void;
  15659. /**
  15660. * Returns a string to use to update the GPU particles update shader
  15661. * @returns the effect defines string
  15662. */
  15663. getEffectDefines(): string;
  15664. /**
  15665. * Returns a string representing the class name
  15666. * @returns a string containing the class name
  15667. */
  15668. getClassName(): string;
  15669. /**
  15670. * Serializes the particle system to a JSON object.
  15671. * @returns the JSON object
  15672. */
  15673. serialize(): any;
  15674. /**
  15675. * Parse properties from a JSON object
  15676. * @param serializationObject defines the JSON object
  15677. * @param scene defines the hosting scene
  15678. */
  15679. parse(serializationObject: any, scene: Nullable<Scene>): void;
  15680. }
  15681. }
  15682. declare module BABYLON {
  15683. /**
  15684. * Particle emitter emitting particles from the inside of a box.
  15685. * It emits the particles randomly between 2 given directions.
  15686. */
  15687. export class BoxParticleEmitter implements IParticleEmitterType {
  15688. /**
  15689. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15690. */
  15691. direction1: Vector3;
  15692. /**
  15693. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15694. */
  15695. direction2: Vector3;
  15696. /**
  15697. * 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.
  15698. */
  15699. minEmitBox: Vector3;
  15700. /**
  15701. * 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.
  15702. */
  15703. maxEmitBox: Vector3;
  15704. /**
  15705. * Creates a new instance BoxParticleEmitter
  15706. */
  15707. constructor();
  15708. /**
  15709. * Called by the particle System when the direction is computed for the created particle.
  15710. * @param worldMatrix is the world matrix of the particle system
  15711. * @param directionToUpdate is the direction vector to update with the result
  15712. * @param particle is the particle we are computed the direction for
  15713. * @param isLocal defines if the direction should be set in local space
  15714. */
  15715. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15716. /**
  15717. * Called by the particle System when the position is computed for the created particle.
  15718. * @param worldMatrix is the world matrix of the particle system
  15719. * @param positionToUpdate is the position vector to update with the result
  15720. * @param particle is the particle we are computed the position for
  15721. * @param isLocal defines if the position should be set in local space
  15722. */
  15723. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15724. /**
  15725. * Clones the current emitter and returns a copy of it
  15726. * @returns the new emitter
  15727. */
  15728. clone(): BoxParticleEmitter;
  15729. /**
  15730. * Called by the GPUParticleSystem to setup the update shader
  15731. * @param effect defines the update shader
  15732. */
  15733. applyToShader(effect: Effect): void;
  15734. /**
  15735. * Returns a string to use to update the GPU particles update shader
  15736. * @returns a string containng the defines string
  15737. */
  15738. getEffectDefines(): string;
  15739. /**
  15740. * Returns the string "BoxParticleEmitter"
  15741. * @returns a string containing the class name
  15742. */
  15743. getClassName(): string;
  15744. /**
  15745. * Serializes the particle system to a JSON object.
  15746. * @returns the JSON object
  15747. */
  15748. serialize(): any;
  15749. /**
  15750. * Parse properties from a JSON object
  15751. * @param serializationObject defines the JSON object
  15752. */
  15753. parse(serializationObject: any): void;
  15754. }
  15755. }
  15756. declare module BABYLON {
  15757. /**
  15758. * Particle emitter emitting particles from the inside of a cone.
  15759. * It emits the particles alongside the cone volume from the base to the particle.
  15760. * The emission direction might be randomized.
  15761. */
  15762. export class ConeParticleEmitter implements IParticleEmitterType {
  15763. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15764. directionRandomizer: number;
  15765. private _radius;
  15766. private _angle;
  15767. private _height;
  15768. /**
  15769. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15770. */
  15771. radiusRange: number;
  15772. /**
  15773. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15774. */
  15775. heightRange: number;
  15776. /**
  15777. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15778. */
  15779. emitFromSpawnPointOnly: boolean;
  15780. /**
  15781. * Gets or sets the radius of the emission cone
  15782. */
  15783. get radius(): number;
  15784. set radius(value: number);
  15785. /**
  15786. * Gets or sets the angle of the emission cone
  15787. */
  15788. get angle(): number;
  15789. set angle(value: number);
  15790. private _buildHeight;
  15791. /**
  15792. * Creates a new instance ConeParticleEmitter
  15793. * @param radius the radius of the emission cone (1 by default)
  15794. * @param angle the cone base angle (PI by default)
  15795. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15796. */
  15797. constructor(radius?: number, angle?: number,
  15798. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15799. directionRandomizer?: number);
  15800. /**
  15801. * Called by the particle System when the direction is computed for the created particle.
  15802. * @param worldMatrix is the world matrix of the particle system
  15803. * @param directionToUpdate is the direction vector to update with the result
  15804. * @param particle is the particle we are computed the direction for
  15805. * @param isLocal defines if the direction should be set in local space
  15806. */
  15807. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15808. /**
  15809. * Called by the particle System when the position is computed for the created particle.
  15810. * @param worldMatrix is the world matrix of the particle system
  15811. * @param positionToUpdate is the position vector to update with the result
  15812. * @param particle is the particle we are computed the position for
  15813. * @param isLocal defines if the position should be set in local space
  15814. */
  15815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15816. /**
  15817. * Clones the current emitter and returns a copy of it
  15818. * @returns the new emitter
  15819. */
  15820. clone(): ConeParticleEmitter;
  15821. /**
  15822. * Called by the GPUParticleSystem to setup the update shader
  15823. * @param effect defines the update shader
  15824. */
  15825. applyToShader(effect: Effect): void;
  15826. /**
  15827. * Returns a string to use to update the GPU particles update shader
  15828. * @returns a string containng the defines string
  15829. */
  15830. getEffectDefines(): string;
  15831. /**
  15832. * Returns the string "ConeParticleEmitter"
  15833. * @returns a string containing the class name
  15834. */
  15835. getClassName(): string;
  15836. /**
  15837. * Serializes the particle system to a JSON object.
  15838. * @returns the JSON object
  15839. */
  15840. serialize(): any;
  15841. /**
  15842. * Parse properties from a JSON object
  15843. * @param serializationObject defines the JSON object
  15844. */
  15845. parse(serializationObject: any): void;
  15846. }
  15847. }
  15848. declare module BABYLON {
  15849. /**
  15850. * Particle emitter emitting particles from the inside of a cylinder.
  15851. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15852. */
  15853. export class CylinderParticleEmitter implements IParticleEmitterType {
  15854. /**
  15855. * The radius of the emission cylinder.
  15856. */
  15857. radius: number;
  15858. /**
  15859. * The height of the emission cylinder.
  15860. */
  15861. height: number;
  15862. /**
  15863. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15864. */
  15865. radiusRange: number;
  15866. /**
  15867. * How much to randomize the particle direction [0-1].
  15868. */
  15869. directionRandomizer: number;
  15870. /**
  15871. * Creates a new instance CylinderParticleEmitter
  15872. * @param radius the radius of the emission cylinder (1 by default)
  15873. * @param height the height of the emission cylinder (1 by default)
  15874. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15875. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15876. */
  15877. constructor(
  15878. /**
  15879. * The radius of the emission cylinder.
  15880. */
  15881. radius?: number,
  15882. /**
  15883. * The height of the emission cylinder.
  15884. */
  15885. height?: number,
  15886. /**
  15887. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15888. */
  15889. radiusRange?: number,
  15890. /**
  15891. * How much to randomize the particle direction [0-1].
  15892. */
  15893. directionRandomizer?: number);
  15894. /**
  15895. * Called by the particle System when the direction is computed for the created particle.
  15896. * @param worldMatrix is the world matrix of the particle system
  15897. * @param directionToUpdate is the direction vector to update with the result
  15898. * @param particle is the particle we are computed the direction for
  15899. * @param isLocal defines if the direction should be set in local space
  15900. */
  15901. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15902. /**
  15903. * Called by the particle System when the position is computed for the created particle.
  15904. * @param worldMatrix is the world matrix of the particle system
  15905. * @param positionToUpdate is the position vector to update with the result
  15906. * @param particle is the particle we are computed the position for
  15907. * @param isLocal defines if the position should be set in local space
  15908. */
  15909. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15910. /**
  15911. * Clones the current emitter and returns a copy of it
  15912. * @returns the new emitter
  15913. */
  15914. clone(): CylinderParticleEmitter;
  15915. /**
  15916. * Called by the GPUParticleSystem to setup the update shader
  15917. * @param effect defines the update shader
  15918. */
  15919. applyToShader(effect: Effect): void;
  15920. /**
  15921. * Returns a string to use to update the GPU particles update shader
  15922. * @returns a string containng the defines string
  15923. */
  15924. getEffectDefines(): string;
  15925. /**
  15926. * Returns the string "CylinderParticleEmitter"
  15927. * @returns a string containing the class name
  15928. */
  15929. getClassName(): string;
  15930. /**
  15931. * Serializes the particle system to a JSON object.
  15932. * @returns the JSON object
  15933. */
  15934. serialize(): any;
  15935. /**
  15936. * Parse properties from a JSON object
  15937. * @param serializationObject defines the JSON object
  15938. */
  15939. parse(serializationObject: any): void;
  15940. }
  15941. /**
  15942. * Particle emitter emitting particles from the inside of a cylinder.
  15943. * It emits the particles randomly between two vectors.
  15944. */
  15945. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15946. /**
  15947. * The min limit of the emission direction.
  15948. */
  15949. direction1: Vector3;
  15950. /**
  15951. * The max limit of the emission direction.
  15952. */
  15953. direction2: Vector3;
  15954. /**
  15955. * Creates a new instance CylinderDirectedParticleEmitter
  15956. * @param radius the radius of the emission cylinder (1 by default)
  15957. * @param height the height of the emission cylinder (1 by default)
  15958. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15959. * @param direction1 the min limit of the emission direction (up vector by default)
  15960. * @param direction2 the max limit of the emission direction (up vector by default)
  15961. */
  15962. constructor(radius?: number, height?: number, radiusRange?: number,
  15963. /**
  15964. * The min limit of the emission direction.
  15965. */
  15966. direction1?: Vector3,
  15967. /**
  15968. * The max limit of the emission direction.
  15969. */
  15970. direction2?: Vector3);
  15971. /**
  15972. * Called by the particle System when the direction is computed for the created particle.
  15973. * @param worldMatrix is the world matrix of the particle system
  15974. * @param directionToUpdate is the direction vector to update with the result
  15975. * @param particle is the particle we are computed the direction for
  15976. */
  15977. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15978. /**
  15979. * Clones the current emitter and returns a copy of it
  15980. * @returns the new emitter
  15981. */
  15982. clone(): CylinderDirectedParticleEmitter;
  15983. /**
  15984. * Called by the GPUParticleSystem to setup the update shader
  15985. * @param effect defines the update shader
  15986. */
  15987. applyToShader(effect: Effect): void;
  15988. /**
  15989. * Returns a string to use to update the GPU particles update shader
  15990. * @returns a string containng the defines string
  15991. */
  15992. getEffectDefines(): string;
  15993. /**
  15994. * Returns the string "CylinderDirectedParticleEmitter"
  15995. * @returns a string containing the class name
  15996. */
  15997. getClassName(): string;
  15998. /**
  15999. * Serializes the particle system to a JSON object.
  16000. * @returns the JSON object
  16001. */
  16002. serialize(): any;
  16003. /**
  16004. * Parse properties from a JSON object
  16005. * @param serializationObject defines the JSON object
  16006. */
  16007. parse(serializationObject: any): void;
  16008. }
  16009. }
  16010. declare module BABYLON {
  16011. /**
  16012. * Particle emitter emitting particles from the inside of a hemisphere.
  16013. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16014. */
  16015. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16016. /**
  16017. * The radius of the emission hemisphere.
  16018. */
  16019. radius: number;
  16020. /**
  16021. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16022. */
  16023. radiusRange: number;
  16024. /**
  16025. * How much to randomize the particle direction [0-1].
  16026. */
  16027. directionRandomizer: number;
  16028. /**
  16029. * Creates a new instance HemisphericParticleEmitter
  16030. * @param radius the radius of the emission hemisphere (1 by default)
  16031. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16032. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16033. */
  16034. constructor(
  16035. /**
  16036. * The radius of the emission hemisphere.
  16037. */
  16038. radius?: number,
  16039. /**
  16040. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16041. */
  16042. radiusRange?: number,
  16043. /**
  16044. * How much to randomize the particle direction [0-1].
  16045. */
  16046. directionRandomizer?: number);
  16047. /**
  16048. * Called by the particle System when the direction is computed for the created particle.
  16049. * @param worldMatrix is the world matrix of the particle system
  16050. * @param directionToUpdate is the direction vector to update with the result
  16051. * @param particle is the particle we are computed the direction for
  16052. * @param isLocal defines if the direction should be set in local space
  16053. */
  16054. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16055. /**
  16056. * Called by the particle System when the position is computed for the created particle.
  16057. * @param worldMatrix is the world matrix of the particle system
  16058. * @param positionToUpdate is the position vector to update with the result
  16059. * @param particle is the particle we are computed the position for
  16060. * @param isLocal defines if the position should be set in local space
  16061. */
  16062. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16063. /**
  16064. * Clones the current emitter and returns a copy of it
  16065. * @returns the new emitter
  16066. */
  16067. clone(): HemisphericParticleEmitter;
  16068. /**
  16069. * Called by the GPUParticleSystem to setup the update shader
  16070. * @param effect defines the update shader
  16071. */
  16072. applyToShader(effect: Effect): void;
  16073. /**
  16074. * Returns a string to use to update the GPU particles update shader
  16075. * @returns a string containng the defines string
  16076. */
  16077. getEffectDefines(): string;
  16078. /**
  16079. * Returns the string "HemisphericParticleEmitter"
  16080. * @returns a string containing the class name
  16081. */
  16082. getClassName(): string;
  16083. /**
  16084. * Serializes the particle system to a JSON object.
  16085. * @returns the JSON object
  16086. */
  16087. serialize(): any;
  16088. /**
  16089. * Parse properties from a JSON object
  16090. * @param serializationObject defines the JSON object
  16091. */
  16092. parse(serializationObject: any): void;
  16093. }
  16094. }
  16095. declare module BABYLON {
  16096. /**
  16097. * Particle emitter emitting particles from a point.
  16098. * It emits the particles randomly between 2 given directions.
  16099. */
  16100. export class PointParticleEmitter implements IParticleEmitterType {
  16101. /**
  16102. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16103. */
  16104. direction1: Vector3;
  16105. /**
  16106. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16107. */
  16108. direction2: Vector3;
  16109. /**
  16110. * Creates a new instance PointParticleEmitter
  16111. */
  16112. constructor();
  16113. /**
  16114. * Called by the particle System when the direction is computed for the created particle.
  16115. * @param worldMatrix is the world matrix of the particle system
  16116. * @param directionToUpdate is the direction vector to update with the result
  16117. * @param particle is the particle we are computed the direction for
  16118. * @param isLocal defines if the direction should be set in local space
  16119. */
  16120. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16121. /**
  16122. * Called by the particle System when the position is computed for the created particle.
  16123. * @param worldMatrix is the world matrix of the particle system
  16124. * @param positionToUpdate is the position vector to update with the result
  16125. * @param particle is the particle we are computed the position for
  16126. * @param isLocal defines if the position should be set in local space
  16127. */
  16128. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16129. /**
  16130. * Clones the current emitter and returns a copy of it
  16131. * @returns the new emitter
  16132. */
  16133. clone(): PointParticleEmitter;
  16134. /**
  16135. * Called by the GPUParticleSystem to setup the update shader
  16136. * @param effect defines the update shader
  16137. */
  16138. applyToShader(effect: Effect): void;
  16139. /**
  16140. * Returns a string to use to update the GPU particles update shader
  16141. * @returns a string containng the defines string
  16142. */
  16143. getEffectDefines(): string;
  16144. /**
  16145. * Returns the string "PointParticleEmitter"
  16146. * @returns a string containing the class name
  16147. */
  16148. getClassName(): string;
  16149. /**
  16150. * Serializes the particle system to a JSON object.
  16151. * @returns the JSON object
  16152. */
  16153. serialize(): any;
  16154. /**
  16155. * Parse properties from a JSON object
  16156. * @param serializationObject defines the JSON object
  16157. */
  16158. parse(serializationObject: any): void;
  16159. }
  16160. }
  16161. declare module BABYLON {
  16162. /**
  16163. * Particle emitter emitting particles from the inside of a sphere.
  16164. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16165. */
  16166. export class SphereParticleEmitter implements IParticleEmitterType {
  16167. /**
  16168. * The radius of the emission sphere.
  16169. */
  16170. radius: number;
  16171. /**
  16172. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16173. */
  16174. radiusRange: number;
  16175. /**
  16176. * How much to randomize the particle direction [0-1].
  16177. */
  16178. directionRandomizer: number;
  16179. /**
  16180. * Creates a new instance SphereParticleEmitter
  16181. * @param radius the radius of the emission sphere (1 by default)
  16182. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16183. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16184. */
  16185. constructor(
  16186. /**
  16187. * The radius of the emission sphere.
  16188. */
  16189. radius?: number,
  16190. /**
  16191. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16192. */
  16193. radiusRange?: number,
  16194. /**
  16195. * How much to randomize the particle direction [0-1].
  16196. */
  16197. directionRandomizer?: number);
  16198. /**
  16199. * Called by the particle System when the direction is computed for the created particle.
  16200. * @param worldMatrix is the world matrix of the particle system
  16201. * @param directionToUpdate is the direction vector to update with the result
  16202. * @param particle is the particle we are computed the direction for
  16203. * @param isLocal defines if the direction should be set in local space
  16204. */
  16205. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16206. /**
  16207. * Called by the particle System when the position is computed for the created particle.
  16208. * @param worldMatrix is the world matrix of the particle system
  16209. * @param positionToUpdate is the position vector to update with the result
  16210. * @param particle is the particle we are computed the position for
  16211. * @param isLocal defines if the position should be set in local space
  16212. */
  16213. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16214. /**
  16215. * Clones the current emitter and returns a copy of it
  16216. * @returns the new emitter
  16217. */
  16218. clone(): SphereParticleEmitter;
  16219. /**
  16220. * Called by the GPUParticleSystem to setup the update shader
  16221. * @param effect defines the update shader
  16222. */
  16223. applyToShader(effect: Effect): void;
  16224. /**
  16225. * Returns a string to use to update the GPU particles update shader
  16226. * @returns a string containng the defines string
  16227. */
  16228. getEffectDefines(): string;
  16229. /**
  16230. * Returns the string "SphereParticleEmitter"
  16231. * @returns a string containing the class name
  16232. */
  16233. getClassName(): string;
  16234. /**
  16235. * Serializes the particle system to a JSON object.
  16236. * @returns the JSON object
  16237. */
  16238. serialize(): any;
  16239. /**
  16240. * Parse properties from a JSON object
  16241. * @param serializationObject defines the JSON object
  16242. */
  16243. parse(serializationObject: any): void;
  16244. }
  16245. /**
  16246. * Particle emitter emitting particles from the inside of a sphere.
  16247. * It emits the particles randomly between two vectors.
  16248. */
  16249. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16250. /**
  16251. * The min limit of the emission direction.
  16252. */
  16253. direction1: Vector3;
  16254. /**
  16255. * The max limit of the emission direction.
  16256. */
  16257. direction2: Vector3;
  16258. /**
  16259. * Creates a new instance SphereDirectedParticleEmitter
  16260. * @param radius the radius of the emission sphere (1 by default)
  16261. * @param direction1 the min limit of the emission direction (up vector by default)
  16262. * @param direction2 the max limit of the emission direction (up vector by default)
  16263. */
  16264. constructor(radius?: number,
  16265. /**
  16266. * The min limit of the emission direction.
  16267. */
  16268. direction1?: Vector3,
  16269. /**
  16270. * The max limit of the emission direction.
  16271. */
  16272. direction2?: Vector3);
  16273. /**
  16274. * Called by the particle System when the direction is computed for the created particle.
  16275. * @param worldMatrix is the world matrix of the particle system
  16276. * @param directionToUpdate is the direction vector to update with the result
  16277. * @param particle is the particle we are computed the direction for
  16278. */
  16279. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16280. /**
  16281. * Clones the current emitter and returns a copy of it
  16282. * @returns the new emitter
  16283. */
  16284. clone(): SphereDirectedParticleEmitter;
  16285. /**
  16286. * Called by the GPUParticleSystem to setup the update shader
  16287. * @param effect defines the update shader
  16288. */
  16289. applyToShader(effect: Effect): void;
  16290. /**
  16291. * Returns a string to use to update the GPU particles update shader
  16292. * @returns a string containng the defines string
  16293. */
  16294. getEffectDefines(): string;
  16295. /**
  16296. * Returns the string "SphereDirectedParticleEmitter"
  16297. * @returns a string containing the class name
  16298. */
  16299. getClassName(): string;
  16300. /**
  16301. * Serializes the particle system to a JSON object.
  16302. * @returns the JSON object
  16303. */
  16304. serialize(): any;
  16305. /**
  16306. * Parse properties from a JSON object
  16307. * @param serializationObject defines the JSON object
  16308. */
  16309. parse(serializationObject: any): void;
  16310. }
  16311. }
  16312. declare module BABYLON {
  16313. /**
  16314. * Particle emitter emitting particles from a custom list of positions.
  16315. */
  16316. export class CustomParticleEmitter implements IParticleEmitterType {
  16317. /**
  16318. * Gets or sets the position generator that will create the inital position of each particle.
  16319. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16320. */
  16321. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16322. /**
  16323. * Gets or sets the destination generator that will create the final destination of each particle.
  16324. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16325. */
  16326. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16327. /**
  16328. * Creates a new instance CustomParticleEmitter
  16329. */
  16330. constructor();
  16331. /**
  16332. * Called by the particle System when the direction is computed for the created particle.
  16333. * @param worldMatrix is the world matrix of the particle system
  16334. * @param directionToUpdate is the direction vector to update with the result
  16335. * @param particle is the particle we are computed the direction for
  16336. * @param isLocal defines if the direction should be set in local space
  16337. */
  16338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16339. /**
  16340. * Called by the particle System when the position is computed for the created particle.
  16341. * @param worldMatrix is the world matrix of the particle system
  16342. * @param positionToUpdate is the position vector to update with the result
  16343. * @param particle is the particle we are computed the position for
  16344. * @param isLocal defines if the position should be set in local space
  16345. */
  16346. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16347. /**
  16348. * Clones the current emitter and returns a copy of it
  16349. * @returns the new emitter
  16350. */
  16351. clone(): CustomParticleEmitter;
  16352. /**
  16353. * Called by the GPUParticleSystem to setup the update shader
  16354. * @param effect defines the update shader
  16355. */
  16356. applyToShader(effect: Effect): void;
  16357. /**
  16358. * Returns a string to use to update the GPU particles update shader
  16359. * @returns a string containng the defines string
  16360. */
  16361. getEffectDefines(): string;
  16362. /**
  16363. * Returns the string "PointParticleEmitter"
  16364. * @returns a string containing the class name
  16365. */
  16366. getClassName(): string;
  16367. /**
  16368. * Serializes the particle system to a JSON object.
  16369. * @returns the JSON object
  16370. */
  16371. serialize(): any;
  16372. /**
  16373. * Parse properties from a JSON object
  16374. * @param serializationObject defines the JSON object
  16375. */
  16376. parse(serializationObject: any): void;
  16377. }
  16378. }
  16379. declare module BABYLON {
  16380. /**
  16381. * Particle emitter emitting particles from the inside of a box.
  16382. * It emits the particles randomly between 2 given directions.
  16383. */
  16384. export class MeshParticleEmitter implements IParticleEmitterType {
  16385. private _indices;
  16386. private _positions;
  16387. private _normals;
  16388. private _storedNormal;
  16389. private _mesh;
  16390. /**
  16391. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16392. */
  16393. direction1: Vector3;
  16394. /**
  16395. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16396. */
  16397. direction2: Vector3;
  16398. /**
  16399. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16400. */
  16401. useMeshNormalsForDirection: boolean;
  16402. /** Defines the mesh to use as source */
  16403. get mesh(): Nullable<AbstractMesh>;
  16404. set mesh(value: Nullable<AbstractMesh>);
  16405. /**
  16406. * Creates a new instance MeshParticleEmitter
  16407. * @param mesh defines the mesh to use as source
  16408. */
  16409. constructor(mesh?: Nullable<AbstractMesh>);
  16410. /**
  16411. * Called by the particle System when the direction is computed for the created particle.
  16412. * @param worldMatrix is the world matrix of the particle system
  16413. * @param directionToUpdate is the direction vector to update with the result
  16414. * @param particle is the particle we are computed the direction for
  16415. * @param isLocal defines if the direction should be set in local space
  16416. */
  16417. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16418. /**
  16419. * Called by the particle System when the position is computed for the created particle.
  16420. * @param worldMatrix is the world matrix of the particle system
  16421. * @param positionToUpdate is the position vector to update with the result
  16422. * @param particle is the particle we are computed the position for
  16423. * @param isLocal defines if the position should be set in local space
  16424. */
  16425. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16426. /**
  16427. * Clones the current emitter and returns a copy of it
  16428. * @returns the new emitter
  16429. */
  16430. clone(): MeshParticleEmitter;
  16431. /**
  16432. * Called by the GPUParticleSystem to setup the update shader
  16433. * @param effect defines the update shader
  16434. */
  16435. applyToShader(effect: Effect): void;
  16436. /**
  16437. * Returns a string to use to update the GPU particles update shader
  16438. * @returns a string containng the defines string
  16439. */
  16440. getEffectDefines(): string;
  16441. /**
  16442. * Returns the string "BoxParticleEmitter"
  16443. * @returns a string containing the class name
  16444. */
  16445. getClassName(): string;
  16446. /**
  16447. * Serializes the particle system to a JSON object.
  16448. * @returns the JSON object
  16449. */
  16450. serialize(): any;
  16451. /**
  16452. * Parse properties from a JSON object
  16453. * @param serializationObject defines the JSON object
  16454. * @param scene defines the hosting scene
  16455. */
  16456. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16457. }
  16458. }
  16459. declare module BABYLON {
  16460. /**
  16461. * Interface representing a particle system in Babylon.js.
  16462. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16463. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16464. */
  16465. export interface IParticleSystem {
  16466. /**
  16467. * List of animations used by the particle system.
  16468. */
  16469. animations: Animation[];
  16470. /**
  16471. * The id of the Particle system.
  16472. */
  16473. id: string;
  16474. /**
  16475. * The name of the Particle system.
  16476. */
  16477. name: string;
  16478. /**
  16479. * The emitter represents the Mesh or position we are attaching the particle system to.
  16480. */
  16481. emitter: Nullable<AbstractMesh | Vector3>;
  16482. /**
  16483. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16484. */
  16485. isBillboardBased: boolean;
  16486. /**
  16487. * The rendering group used by the Particle system to chose when to render.
  16488. */
  16489. renderingGroupId: number;
  16490. /**
  16491. * The layer mask we are rendering the particles through.
  16492. */
  16493. layerMask: number;
  16494. /**
  16495. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16496. */
  16497. updateSpeed: number;
  16498. /**
  16499. * The amount of time the particle system is running (depends of the overall update speed).
  16500. */
  16501. targetStopDuration: number;
  16502. /**
  16503. * The texture used to render each particle. (this can be a spritesheet)
  16504. */
  16505. particleTexture: Nullable<BaseTexture>;
  16506. /**
  16507. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16508. */
  16509. blendMode: number;
  16510. /**
  16511. * Minimum life time of emitting particles.
  16512. */
  16513. minLifeTime: number;
  16514. /**
  16515. * Maximum life time of emitting particles.
  16516. */
  16517. maxLifeTime: number;
  16518. /**
  16519. * Minimum Size of emitting particles.
  16520. */
  16521. minSize: number;
  16522. /**
  16523. * Maximum Size of emitting particles.
  16524. */
  16525. maxSize: number;
  16526. /**
  16527. * Minimum scale of emitting particles on X axis.
  16528. */
  16529. minScaleX: number;
  16530. /**
  16531. * Maximum scale of emitting particles on X axis.
  16532. */
  16533. maxScaleX: number;
  16534. /**
  16535. * Minimum scale of emitting particles on Y axis.
  16536. */
  16537. minScaleY: number;
  16538. /**
  16539. * Maximum scale of emitting particles on Y axis.
  16540. */
  16541. maxScaleY: number;
  16542. /**
  16543. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16544. */
  16545. color1: Color4;
  16546. /**
  16547. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16548. */
  16549. color2: Color4;
  16550. /**
  16551. * Color the particle will have at the end of its lifetime.
  16552. */
  16553. colorDead: Color4;
  16554. /**
  16555. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16556. */
  16557. emitRate: number;
  16558. /**
  16559. * You can use gravity if you want to give an orientation to your particles.
  16560. */
  16561. gravity: Vector3;
  16562. /**
  16563. * Minimum power of emitting particles.
  16564. */
  16565. minEmitPower: number;
  16566. /**
  16567. * Maximum power of emitting particles.
  16568. */
  16569. maxEmitPower: number;
  16570. /**
  16571. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16572. */
  16573. minAngularSpeed: number;
  16574. /**
  16575. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16576. */
  16577. maxAngularSpeed: number;
  16578. /**
  16579. * Gets or sets the minimal initial rotation in radians.
  16580. */
  16581. minInitialRotation: number;
  16582. /**
  16583. * Gets or sets the maximal initial rotation in radians.
  16584. */
  16585. maxInitialRotation: number;
  16586. /**
  16587. * The particle emitter type defines the emitter used by the particle system.
  16588. * It can be for example box, sphere, or cone...
  16589. */
  16590. particleEmitterType: Nullable<IParticleEmitterType>;
  16591. /**
  16592. * Defines the delay in milliseconds before starting the system (0 by default)
  16593. */
  16594. startDelay: number;
  16595. /**
  16596. * 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
  16597. */
  16598. preWarmCycles: number;
  16599. /**
  16600. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16601. */
  16602. preWarmStepOffset: number;
  16603. /**
  16604. * 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)
  16605. */
  16606. spriteCellChangeSpeed: number;
  16607. /**
  16608. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16609. */
  16610. startSpriteCellID: number;
  16611. /**
  16612. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16613. */
  16614. endSpriteCellID: number;
  16615. /**
  16616. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16617. */
  16618. spriteCellWidth: number;
  16619. /**
  16620. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16621. */
  16622. spriteCellHeight: number;
  16623. /**
  16624. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16625. */
  16626. spriteRandomStartCell: boolean;
  16627. /**
  16628. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16629. */
  16630. isAnimationSheetEnabled: boolean;
  16631. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16632. translationPivot: Vector2;
  16633. /**
  16634. * Gets or sets a texture used to add random noise to particle positions
  16635. */
  16636. noiseTexture: Nullable<BaseTexture>;
  16637. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16638. noiseStrength: Vector3;
  16639. /**
  16640. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16641. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16642. */
  16643. billboardMode: number;
  16644. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16645. limitVelocityDamping: number;
  16646. /**
  16647. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16648. */
  16649. beginAnimationOnStart: boolean;
  16650. /**
  16651. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16652. */
  16653. beginAnimationFrom: number;
  16654. /**
  16655. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16656. */
  16657. beginAnimationTo: number;
  16658. /**
  16659. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16660. */
  16661. beginAnimationLoop: boolean;
  16662. /**
  16663. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16664. */
  16665. disposeOnStop: boolean;
  16666. /**
  16667. * Specifies if the particles are updated in emitter local space or world space
  16668. */
  16669. isLocal: boolean;
  16670. /** Snippet ID if the particle system was created from the snippet server */
  16671. snippetId: string;
  16672. /** Gets or sets a matrix to use to compute projection */
  16673. defaultProjectionMatrix: Matrix;
  16674. /**
  16675. * Gets the maximum number of particles active at the same time.
  16676. * @returns The max number of active particles.
  16677. */
  16678. getCapacity(): number;
  16679. /**
  16680. * Gets the number of particles active at the same time.
  16681. * @returns The number of active particles.
  16682. */
  16683. getActiveCount(): number;
  16684. /**
  16685. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16686. * @returns True if it has been started, otherwise false.
  16687. */
  16688. isStarted(): boolean;
  16689. /**
  16690. * Animates the particle system for this frame.
  16691. */
  16692. animate(): void;
  16693. /**
  16694. * Renders the particle system in its current state.
  16695. * @returns the current number of particles
  16696. */
  16697. render(): number;
  16698. /**
  16699. * Dispose the particle system and frees its associated resources.
  16700. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16701. */
  16702. dispose(disposeTexture?: boolean): void;
  16703. /**
  16704. * An event triggered when the system is disposed
  16705. */
  16706. onDisposeObservable: Observable<IParticleSystem>;
  16707. /**
  16708. * An event triggered when the system is stopped
  16709. */
  16710. onStoppedObservable: Observable<IParticleSystem>;
  16711. /**
  16712. * Clones the particle system.
  16713. * @param name The name of the cloned object
  16714. * @param newEmitter The new emitter to use
  16715. * @returns the cloned particle system
  16716. */
  16717. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16718. /**
  16719. * Serializes the particle system to a JSON object
  16720. * @param serializeTexture defines if the texture must be serialized as well
  16721. * @returns the JSON object
  16722. */
  16723. serialize(serializeTexture: boolean): any;
  16724. /**
  16725. * Rebuild the particle system
  16726. */
  16727. rebuild(): void;
  16728. /** Force the system to rebuild all gradients that need to be resync */
  16729. forceRefreshGradients(): void;
  16730. /**
  16731. * Starts the particle system and begins to emit
  16732. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16733. */
  16734. start(delay?: number): void;
  16735. /**
  16736. * Stops the particle system.
  16737. */
  16738. stop(): void;
  16739. /**
  16740. * Remove all active particles
  16741. */
  16742. reset(): void;
  16743. /**
  16744. * Gets a boolean indicating that the system is stopping
  16745. * @returns true if the system is currently stopping
  16746. */
  16747. isStopping(): boolean;
  16748. /**
  16749. * Is this system ready to be used/rendered
  16750. * @return true if the system is ready
  16751. */
  16752. isReady(): boolean;
  16753. /**
  16754. * Returns the string "ParticleSystem"
  16755. * @returns a string containing the class name
  16756. */
  16757. getClassName(): string;
  16758. /**
  16759. * Gets the custom effect used to render the particles
  16760. * @param blendMode Blend mode for which the effect should be retrieved
  16761. * @returns The effect
  16762. */
  16763. getCustomEffect(blendMode: number): Nullable<Effect>;
  16764. /**
  16765. * Sets the custom effect used to render the particles
  16766. * @param effect The effect to set
  16767. * @param blendMode Blend mode for which the effect should be set
  16768. */
  16769. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  16770. /**
  16771. * Fill the defines array according to the current settings of the particle system
  16772. * @param defines Array to be updated
  16773. * @param blendMode blend mode to take into account when updating the array
  16774. */
  16775. fillDefines(defines: Array<string>, blendMode: number): void;
  16776. /**
  16777. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16778. * @param uniforms Uniforms array to fill
  16779. * @param attributes Attributes array to fill
  16780. * @param samplers Samplers array to fill
  16781. */
  16782. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16783. /**
  16784. * Observable that will be called just before the particles are drawn
  16785. */
  16786. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  16787. /**
  16788. * Gets the name of the particle vertex shader
  16789. */
  16790. vertexShaderName: string;
  16791. /**
  16792. * Adds a new color gradient
  16793. * @param gradient defines the gradient to use (between 0 and 1)
  16794. * @param color1 defines the color to affect to the specified gradient
  16795. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16796. * @returns the current particle system
  16797. */
  16798. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16799. /**
  16800. * Remove a specific color gradient
  16801. * @param gradient defines the gradient to remove
  16802. * @returns the current particle system
  16803. */
  16804. removeColorGradient(gradient: number): IParticleSystem;
  16805. /**
  16806. * Adds a new size gradient
  16807. * @param gradient defines the gradient to use (between 0 and 1)
  16808. * @param factor defines the size factor to affect to the specified gradient
  16809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16810. * @returns the current particle system
  16811. */
  16812. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16813. /**
  16814. * Remove a specific size gradient
  16815. * @param gradient defines the gradient to remove
  16816. * @returns the current particle system
  16817. */
  16818. removeSizeGradient(gradient: number): IParticleSystem;
  16819. /**
  16820. * Gets the current list of color gradients.
  16821. * You must use addColorGradient and removeColorGradient to udpate this list
  16822. * @returns the list of color gradients
  16823. */
  16824. getColorGradients(): Nullable<Array<ColorGradient>>;
  16825. /**
  16826. * Gets the current list of size gradients.
  16827. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16828. * @returns the list of size gradients
  16829. */
  16830. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16831. /**
  16832. * Gets the current list of angular speed gradients.
  16833. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16834. * @returns the list of angular speed gradients
  16835. */
  16836. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16837. /**
  16838. * Adds a new angular speed gradient
  16839. * @param gradient defines the gradient to use (between 0 and 1)
  16840. * @param factor defines the angular speed to affect to the specified gradient
  16841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16842. * @returns the current particle system
  16843. */
  16844. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16845. /**
  16846. * Remove a specific angular speed gradient
  16847. * @param gradient defines the gradient to remove
  16848. * @returns the current particle system
  16849. */
  16850. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16851. /**
  16852. * Gets the current list of velocity gradients.
  16853. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16854. * @returns the list of velocity gradients
  16855. */
  16856. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16857. /**
  16858. * Adds a new velocity gradient
  16859. * @param gradient defines the gradient to use (between 0 and 1)
  16860. * @param factor defines the velocity to affect to the specified gradient
  16861. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16862. * @returns the current particle system
  16863. */
  16864. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16865. /**
  16866. * Remove a specific velocity gradient
  16867. * @param gradient defines the gradient to remove
  16868. * @returns the current particle system
  16869. */
  16870. removeVelocityGradient(gradient: number): IParticleSystem;
  16871. /**
  16872. * Gets the current list of limit velocity gradients.
  16873. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16874. * @returns the list of limit velocity gradients
  16875. */
  16876. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16877. /**
  16878. * Adds a new limit velocity gradient
  16879. * @param gradient defines the gradient to use (between 0 and 1)
  16880. * @param factor defines the limit velocity to affect to the specified gradient
  16881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16882. * @returns the current particle system
  16883. */
  16884. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16885. /**
  16886. * Remove a specific limit velocity gradient
  16887. * @param gradient defines the gradient to remove
  16888. * @returns the current particle system
  16889. */
  16890. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16891. /**
  16892. * Adds a new drag gradient
  16893. * @param gradient defines the gradient to use (between 0 and 1)
  16894. * @param factor defines the drag to affect to the specified gradient
  16895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16896. * @returns the current particle system
  16897. */
  16898. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16899. /**
  16900. * Remove a specific drag gradient
  16901. * @param gradient defines the gradient to remove
  16902. * @returns the current particle system
  16903. */
  16904. removeDragGradient(gradient: number): IParticleSystem;
  16905. /**
  16906. * Gets the current list of drag gradients.
  16907. * You must use addDragGradient and removeDragGradient to udpate this list
  16908. * @returns the list of drag gradients
  16909. */
  16910. getDragGradients(): Nullable<Array<FactorGradient>>;
  16911. /**
  16912. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16913. * @param gradient defines the gradient to use (between 0 and 1)
  16914. * @param factor defines the emit rate to affect to the specified gradient
  16915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16916. * @returns the current particle system
  16917. */
  16918. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16919. /**
  16920. * Remove a specific emit rate gradient
  16921. * @param gradient defines the gradient to remove
  16922. * @returns the current particle system
  16923. */
  16924. removeEmitRateGradient(gradient: number): IParticleSystem;
  16925. /**
  16926. * Gets the current list of emit rate gradients.
  16927. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16928. * @returns the list of emit rate gradients
  16929. */
  16930. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16931. /**
  16932. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16933. * @param gradient defines the gradient to use (between 0 and 1)
  16934. * @param factor defines the start size to affect to the specified gradient
  16935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16936. * @returns the current particle system
  16937. */
  16938. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16939. /**
  16940. * Remove a specific start size gradient
  16941. * @param gradient defines the gradient to remove
  16942. * @returns the current particle system
  16943. */
  16944. removeStartSizeGradient(gradient: number): IParticleSystem;
  16945. /**
  16946. * Gets the current list of start size gradients.
  16947. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16948. * @returns the list of start size gradients
  16949. */
  16950. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16951. /**
  16952. * Adds a new life time gradient
  16953. * @param gradient defines the gradient to use (between 0 and 1)
  16954. * @param factor defines the life time factor to affect to the specified gradient
  16955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16956. * @returns the current particle system
  16957. */
  16958. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16959. /**
  16960. * Remove a specific life time gradient
  16961. * @param gradient defines the gradient to remove
  16962. * @returns the current particle system
  16963. */
  16964. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16965. /**
  16966. * Gets the current list of life time gradients.
  16967. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16968. * @returns the list of life time gradients
  16969. */
  16970. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16971. /**
  16972. * Gets the current list of color gradients.
  16973. * You must use addColorGradient and removeColorGradient to udpate this list
  16974. * @returns the list of color gradients
  16975. */
  16976. getColorGradients(): Nullable<Array<ColorGradient>>;
  16977. /**
  16978. * Adds a new ramp gradient used to remap particle colors
  16979. * @param gradient defines the gradient to use (between 0 and 1)
  16980. * @param color defines the color to affect to the specified gradient
  16981. * @returns the current particle system
  16982. */
  16983. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16984. /**
  16985. * Gets the current list of ramp gradients.
  16986. * You must use addRampGradient and removeRampGradient to udpate this list
  16987. * @returns the list of ramp gradients
  16988. */
  16989. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16990. /** Gets or sets a boolean indicating that ramp gradients must be used
  16991. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16992. */
  16993. useRampGradients: boolean;
  16994. /**
  16995. * Adds a new color remap gradient
  16996. * @param gradient defines the gradient to use (between 0 and 1)
  16997. * @param min defines the color remap minimal range
  16998. * @param max defines the color remap maximal range
  16999. * @returns the current particle system
  17000. */
  17001. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17002. /**
  17003. * Gets the current list of color remap gradients.
  17004. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17005. * @returns the list of color remap gradients
  17006. */
  17007. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17008. /**
  17009. * Adds a new alpha remap gradient
  17010. * @param gradient defines the gradient to use (between 0 and 1)
  17011. * @param min defines the alpha remap minimal range
  17012. * @param max defines the alpha remap maximal range
  17013. * @returns the current particle system
  17014. */
  17015. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17016. /**
  17017. * Gets the current list of alpha remap gradients.
  17018. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17019. * @returns the list of alpha remap gradients
  17020. */
  17021. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17022. /**
  17023. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17024. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17025. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17026. * @returns the emitter
  17027. */
  17028. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17029. /**
  17030. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17031. * @param radius The radius of the hemisphere to emit from
  17032. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17033. * @returns the emitter
  17034. */
  17035. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17036. /**
  17037. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17038. * @param radius The radius of the sphere to emit from
  17039. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17040. * @returns the emitter
  17041. */
  17042. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17043. /**
  17044. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17045. * @param radius The radius of the sphere to emit from
  17046. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17047. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17048. * @returns the emitter
  17049. */
  17050. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17051. /**
  17052. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17053. * @param radius The radius of the emission cylinder
  17054. * @param height The height of the emission cylinder
  17055. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17056. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17057. * @returns the emitter
  17058. */
  17059. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17060. /**
  17061. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17062. * @param radius The radius of the cylinder to emit from
  17063. * @param height The height of the emission cylinder
  17064. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17065. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17066. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17067. * @returns the emitter
  17068. */
  17069. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17070. /**
  17071. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17072. * @param radius The radius of the cone to emit from
  17073. * @param angle The base angle of the cone
  17074. * @returns the emitter
  17075. */
  17076. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17077. /**
  17078. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17079. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17080. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17082. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17083. * @returns the emitter
  17084. */
  17085. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17086. /**
  17087. * Get hosting scene
  17088. * @returns the scene
  17089. */
  17090. getScene(): Nullable<Scene>;
  17091. }
  17092. }
  17093. declare module BABYLON {
  17094. /**
  17095. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17096. */
  17097. export class ColorSplitterBlock extends NodeMaterialBlock {
  17098. /**
  17099. * Create a new ColorSplitterBlock
  17100. * @param name defines the block name
  17101. */
  17102. constructor(name: string);
  17103. /**
  17104. * Gets the current class name
  17105. * @returns the class name
  17106. */
  17107. getClassName(): string;
  17108. /**
  17109. * Gets the rgba component (input)
  17110. */
  17111. get rgba(): NodeMaterialConnectionPoint;
  17112. /**
  17113. * Gets the rgb component (input)
  17114. */
  17115. get rgbIn(): NodeMaterialConnectionPoint;
  17116. /**
  17117. * Gets the rgb component (output)
  17118. */
  17119. get rgbOut(): NodeMaterialConnectionPoint;
  17120. /**
  17121. * Gets the r component (output)
  17122. */
  17123. get r(): NodeMaterialConnectionPoint;
  17124. /**
  17125. * Gets the g component (output)
  17126. */
  17127. get g(): NodeMaterialConnectionPoint;
  17128. /**
  17129. * Gets the b component (output)
  17130. */
  17131. get b(): NodeMaterialConnectionPoint;
  17132. /**
  17133. * Gets the a component (output)
  17134. */
  17135. get a(): NodeMaterialConnectionPoint;
  17136. protected _inputRename(name: string): string;
  17137. protected _outputRename(name: string): string;
  17138. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17139. }
  17140. }
  17141. declare module BABYLON {
  17142. /**
  17143. * Operations supported by the Trigonometry block
  17144. */
  17145. export enum TrigonometryBlockOperations {
  17146. /** Cos */
  17147. Cos = 0,
  17148. /** Sin */
  17149. Sin = 1,
  17150. /** Abs */
  17151. Abs = 2,
  17152. /** Exp */
  17153. Exp = 3,
  17154. /** Exp2 */
  17155. Exp2 = 4,
  17156. /** Round */
  17157. Round = 5,
  17158. /** Floor */
  17159. Floor = 6,
  17160. /** Ceiling */
  17161. Ceiling = 7,
  17162. /** Square root */
  17163. Sqrt = 8,
  17164. /** Log */
  17165. Log = 9,
  17166. /** Tangent */
  17167. Tan = 10,
  17168. /** Arc tangent */
  17169. ArcTan = 11,
  17170. /** Arc cosinus */
  17171. ArcCos = 12,
  17172. /** Arc sinus */
  17173. ArcSin = 13,
  17174. /** Fraction */
  17175. Fract = 14,
  17176. /** Sign */
  17177. Sign = 15,
  17178. /** To radians (from degrees) */
  17179. Radians = 16,
  17180. /** To degrees (from radians) */
  17181. Degrees = 17
  17182. }
  17183. /**
  17184. * Block used to apply trigonometry operation to floats
  17185. */
  17186. export class TrigonometryBlock extends NodeMaterialBlock {
  17187. /**
  17188. * Gets or sets the operation applied by the block
  17189. */
  17190. operation: TrigonometryBlockOperations;
  17191. /**
  17192. * Creates a new TrigonometryBlock
  17193. * @param name defines the block name
  17194. */
  17195. constructor(name: string);
  17196. /**
  17197. * Gets the current class name
  17198. * @returns the class name
  17199. */
  17200. getClassName(): string;
  17201. /**
  17202. * Gets the input component
  17203. */
  17204. get input(): NodeMaterialConnectionPoint;
  17205. /**
  17206. * Gets the output component
  17207. */
  17208. get output(): NodeMaterialConnectionPoint;
  17209. protected _buildBlock(state: NodeMaterialBuildState): this;
  17210. serialize(): any;
  17211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17212. protected _dumpPropertiesCode(): string;
  17213. }
  17214. }
  17215. declare module BABYLON {
  17216. /**
  17217. * Interface used to configure the node material editor
  17218. */
  17219. export interface INodeMaterialEditorOptions {
  17220. /** Define the URl to load node editor script */
  17221. editorURL?: string;
  17222. }
  17223. /** @hidden */
  17224. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17225. NORMAL: boolean;
  17226. TANGENT: boolean;
  17227. UV1: boolean;
  17228. /** BONES */
  17229. NUM_BONE_INFLUENCERS: number;
  17230. BonesPerMesh: number;
  17231. BONETEXTURE: boolean;
  17232. /** MORPH TARGETS */
  17233. MORPHTARGETS: boolean;
  17234. MORPHTARGETS_NORMAL: boolean;
  17235. MORPHTARGETS_TANGENT: boolean;
  17236. MORPHTARGETS_UV: boolean;
  17237. NUM_MORPH_INFLUENCERS: number;
  17238. /** IMAGE PROCESSING */
  17239. IMAGEPROCESSING: boolean;
  17240. VIGNETTE: boolean;
  17241. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17242. VIGNETTEBLENDMODEOPAQUE: boolean;
  17243. TONEMAPPING: boolean;
  17244. TONEMAPPING_ACES: boolean;
  17245. CONTRAST: boolean;
  17246. EXPOSURE: boolean;
  17247. COLORCURVES: boolean;
  17248. COLORGRADING: boolean;
  17249. COLORGRADING3D: boolean;
  17250. SAMPLER3DGREENDEPTH: boolean;
  17251. SAMPLER3DBGRMAP: boolean;
  17252. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17253. /** MISC. */
  17254. BUMPDIRECTUV: number;
  17255. constructor();
  17256. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17257. }
  17258. /**
  17259. * Class used to configure NodeMaterial
  17260. */
  17261. export interface INodeMaterialOptions {
  17262. /**
  17263. * Defines if blocks should emit comments
  17264. */
  17265. emitComments: boolean;
  17266. }
  17267. /**
  17268. * Class used to create a node based material built by assembling shader blocks
  17269. */
  17270. export class NodeMaterial extends PushMaterial {
  17271. private static _BuildIdGenerator;
  17272. private _options;
  17273. private _vertexCompilationState;
  17274. private _fragmentCompilationState;
  17275. private _sharedData;
  17276. private _buildId;
  17277. private _buildWasSuccessful;
  17278. private _cachedWorldViewMatrix;
  17279. private _cachedWorldViewProjectionMatrix;
  17280. private _optimizers;
  17281. private _animationFrame;
  17282. /** Define the Url to load node editor script */
  17283. static EditorURL: string;
  17284. /** Define the Url to load snippets */
  17285. static SnippetUrl: string;
  17286. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17287. static IgnoreTexturesAtLoadTime: boolean;
  17288. private BJSNODEMATERIALEDITOR;
  17289. /** Get the inspector from bundle or global */
  17290. private _getGlobalNodeMaterialEditor;
  17291. /**
  17292. * Snippet ID if the material was created from the snippet server
  17293. */
  17294. snippetId: string;
  17295. /**
  17296. * Gets or sets data used by visual editor
  17297. * @see https://nme.babylonjs.com
  17298. */
  17299. editorData: any;
  17300. /**
  17301. * 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)
  17302. */
  17303. ignoreAlpha: boolean;
  17304. /**
  17305. * Defines the maximum number of lights that can be used in the material
  17306. */
  17307. maxSimultaneousLights: number;
  17308. /**
  17309. * Observable raised when the material is built
  17310. */
  17311. onBuildObservable: Observable<NodeMaterial>;
  17312. /**
  17313. * Gets or sets the root nodes of the material vertex shader
  17314. */
  17315. _vertexOutputNodes: NodeMaterialBlock[];
  17316. /**
  17317. * Gets or sets the root nodes of the material fragment (pixel) shader
  17318. */
  17319. _fragmentOutputNodes: NodeMaterialBlock[];
  17320. /** Gets or sets options to control the node material overall behavior */
  17321. get options(): INodeMaterialOptions;
  17322. set options(options: INodeMaterialOptions);
  17323. /**
  17324. * Default configuration related to image processing available in the standard Material.
  17325. */
  17326. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17327. /**
  17328. * Gets the image processing configuration used either in this material.
  17329. */
  17330. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17331. /**
  17332. * Sets the Default image processing configuration used either in the this material.
  17333. *
  17334. * If sets to null, the scene one is in use.
  17335. */
  17336. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17337. /**
  17338. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17339. */
  17340. attachedBlocks: NodeMaterialBlock[];
  17341. /**
  17342. * Specifies the mode of the node material
  17343. * @hidden
  17344. */
  17345. _mode: NodeMaterialModes;
  17346. /**
  17347. * Gets the mode property
  17348. */
  17349. get mode(): NodeMaterialModes;
  17350. /**
  17351. * A free comment about the material
  17352. */
  17353. comment: string;
  17354. /**
  17355. * Create a new node based material
  17356. * @param name defines the material name
  17357. * @param scene defines the hosting scene
  17358. * @param options defines creation option
  17359. */
  17360. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17361. /**
  17362. * Gets the current class name of the material e.g. "NodeMaterial"
  17363. * @returns the class name
  17364. */
  17365. getClassName(): string;
  17366. /**
  17367. * Keep track of the image processing observer to allow dispose and replace.
  17368. */
  17369. private _imageProcessingObserver;
  17370. /**
  17371. * Attaches a new image processing configuration to the Standard Material.
  17372. * @param configuration
  17373. */
  17374. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17375. /**
  17376. * Get a block by its name
  17377. * @param name defines the name of the block to retrieve
  17378. * @returns the required block or null if not found
  17379. */
  17380. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17381. /**
  17382. * Get a block by its name
  17383. * @param predicate defines the predicate used to find the good candidate
  17384. * @returns the required block or null if not found
  17385. */
  17386. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17387. /**
  17388. * Get an input block by its name
  17389. * @param predicate defines the predicate used to find the good candidate
  17390. * @returns the required input block or null if not found
  17391. */
  17392. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17393. /**
  17394. * Gets the list of input blocks attached to this material
  17395. * @returns an array of InputBlocks
  17396. */
  17397. getInputBlocks(): InputBlock[];
  17398. /**
  17399. * Adds a new optimizer to the list of optimizers
  17400. * @param optimizer defines the optimizers to add
  17401. * @returns the current material
  17402. */
  17403. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17404. /**
  17405. * Remove an optimizer from the list of optimizers
  17406. * @param optimizer defines the optimizers to remove
  17407. * @returns the current material
  17408. */
  17409. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17410. /**
  17411. * Add a new block to the list of output nodes
  17412. * @param node defines the node to add
  17413. * @returns the current material
  17414. */
  17415. addOutputNode(node: NodeMaterialBlock): this;
  17416. /**
  17417. * Remove a block from the list of root nodes
  17418. * @param node defines the node to remove
  17419. * @returns the current material
  17420. */
  17421. removeOutputNode(node: NodeMaterialBlock): this;
  17422. private _addVertexOutputNode;
  17423. private _removeVertexOutputNode;
  17424. private _addFragmentOutputNode;
  17425. private _removeFragmentOutputNode;
  17426. /**
  17427. * Specifies if the material will require alpha blending
  17428. * @returns a boolean specifying if alpha blending is needed
  17429. */
  17430. needAlphaBlending(): boolean;
  17431. /**
  17432. * Specifies if this material should be rendered in alpha test mode
  17433. * @returns a boolean specifying if an alpha test is needed.
  17434. */
  17435. needAlphaTesting(): boolean;
  17436. private _initializeBlock;
  17437. private _resetDualBlocks;
  17438. /**
  17439. * Remove a block from the current node material
  17440. * @param block defines the block to remove
  17441. */
  17442. removeBlock(block: NodeMaterialBlock): void;
  17443. /**
  17444. * Build the material and generates the inner effect
  17445. * @param verbose defines if the build should log activity
  17446. */
  17447. build(verbose?: boolean): void;
  17448. /**
  17449. * Runs an otpimization phase to try to improve the shader code
  17450. */
  17451. optimize(): void;
  17452. private _prepareDefinesForAttributes;
  17453. /**
  17454. * Create a post process from the material
  17455. * @param camera The camera to apply the render pass to.
  17456. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17457. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17458. * @param engine The engine which the post process will be applied. (default: current engine)
  17459. * @param reusable If the post process can be reused on the same frame. (default: false)
  17460. * @param textureType Type of textures used when performing the post process. (default: 0)
  17461. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17462. * @returns the post process created
  17463. */
  17464. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17465. /**
  17466. * Create the post process effect from the material
  17467. * @param postProcess The post process to create the effect for
  17468. */
  17469. createEffectForPostProcess(postProcess: PostProcess): void;
  17470. private _createEffectForPostProcess;
  17471. /**
  17472. * Create a new procedural texture based on this node material
  17473. * @param size defines the size of the texture
  17474. * @param scene defines the hosting scene
  17475. * @returns the new procedural texture attached to this node material
  17476. */
  17477. createProceduralTexture(size: number | {
  17478. width: number;
  17479. height: number;
  17480. layers?: number;
  17481. }, scene: Scene): Nullable<ProceduralTexture>;
  17482. private _createEffectForParticles;
  17483. private _checkInternals;
  17484. /**
  17485. * Create the effect to be used as the custom effect for a particle system
  17486. * @param particleSystem Particle system to create the effect for
  17487. * @param onCompiled defines a function to call when the effect creation is successful
  17488. * @param onError defines a function to call when the effect creation has failed
  17489. */
  17490. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17491. private _processDefines;
  17492. /**
  17493. * Get if the submesh is ready to be used and all its information available.
  17494. * Child classes can use it to update shaders
  17495. * @param mesh defines the mesh to check
  17496. * @param subMesh defines which submesh to check
  17497. * @param useInstances specifies that instances should be used
  17498. * @returns a boolean indicating that the submesh is ready or not
  17499. */
  17500. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17501. /**
  17502. * Get a string representing the shaders built by the current node graph
  17503. */
  17504. get compiledShaders(): string;
  17505. /**
  17506. * Binds the world matrix to the material
  17507. * @param world defines the world transformation matrix
  17508. */
  17509. bindOnlyWorldMatrix(world: Matrix): void;
  17510. /**
  17511. * Binds the submesh to this material by preparing the effect and shader to draw
  17512. * @param world defines the world transformation matrix
  17513. * @param mesh defines the mesh containing the submesh
  17514. * @param subMesh defines the submesh to bind the material to
  17515. */
  17516. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17517. /**
  17518. * Gets the active textures from the material
  17519. * @returns an array of textures
  17520. */
  17521. getActiveTextures(): BaseTexture[];
  17522. /**
  17523. * Gets the list of texture blocks
  17524. * @returns an array of texture blocks
  17525. */
  17526. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  17527. /**
  17528. * Specifies if the material uses a texture
  17529. * @param texture defines the texture to check against the material
  17530. * @returns a boolean specifying if the material uses the texture
  17531. */
  17532. hasTexture(texture: BaseTexture): boolean;
  17533. /**
  17534. * Disposes the material
  17535. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17536. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17537. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17538. */
  17539. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17540. /** Creates the node editor window. */
  17541. private _createNodeEditor;
  17542. /**
  17543. * Launch the node material editor
  17544. * @param config Define the configuration of the editor
  17545. * @return a promise fulfilled when the node editor is visible
  17546. */
  17547. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  17548. /**
  17549. * Clear the current material
  17550. */
  17551. clear(): void;
  17552. /**
  17553. * Clear the current material and set it to a default state
  17554. */
  17555. setToDefault(): void;
  17556. /**
  17557. * Clear the current material and set it to a default state for post process
  17558. */
  17559. setToDefaultPostProcess(): void;
  17560. /**
  17561. * Clear the current material and set it to a default state for procedural texture
  17562. */
  17563. setToDefaultProceduralTexture(): void;
  17564. /**
  17565. * Clear the current material and set it to a default state for particle
  17566. */
  17567. setToDefaultParticle(): void;
  17568. /**
  17569. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  17570. * @param url defines the url to load from
  17571. * @returns a promise that will fullfil when the material is fully loaded
  17572. */
  17573. loadAsync(url: string): Promise<void>;
  17574. private _gatherBlocks;
  17575. /**
  17576. * Generate a string containing the code declaration required to create an equivalent of this material
  17577. * @returns a string
  17578. */
  17579. generateCode(): string;
  17580. /**
  17581. * Serializes this material in a JSON representation
  17582. * @returns the serialized material object
  17583. */
  17584. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  17585. private _restoreConnections;
  17586. /**
  17587. * Clear the current graph and load a new one from a serialization object
  17588. * @param source defines the JSON representation of the material
  17589. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17590. * @param merge defines whether or not the source must be merged or replace the current content
  17591. */
  17592. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  17593. /**
  17594. * Makes a duplicate of the current material.
  17595. * @param name - name to use for the new material.
  17596. */
  17597. clone(name: string): NodeMaterial;
  17598. /**
  17599. * Creates a node material from parsed material data
  17600. * @param source defines the JSON representation of the material
  17601. * @param scene defines the hosting scene
  17602. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17603. * @returns a new node material
  17604. */
  17605. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  17606. /**
  17607. * Creates a node material from a snippet saved in a remote file
  17608. * @param name defines the name of the material to create
  17609. * @param url defines the url to load from
  17610. * @param scene defines the hosting scene
  17611. * @returns a promise that will resolve to the new node material
  17612. */
  17613. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  17614. /**
  17615. * Creates a node material from a snippet saved by the node material editor
  17616. * @param snippetId defines the snippet to load
  17617. * @param scene defines the hosting scene
  17618. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17619. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  17620. * @returns a promise that will resolve to the new node material
  17621. */
  17622. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  17623. /**
  17624. * Creates a new node material set to default basic configuration
  17625. * @param name defines the name of the material
  17626. * @param scene defines the hosting scene
  17627. * @returns a new NodeMaterial
  17628. */
  17629. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  17630. }
  17631. }
  17632. declare module BABYLON {
  17633. interface ThinEngine {
  17634. /**
  17635. * Unbind a list of render target textures from the webGL context
  17636. * This is used only when drawBuffer extension or webGL2 are active
  17637. * @param textures defines the render target textures to unbind
  17638. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  17639. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  17640. */
  17641. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  17642. /**
  17643. * Create a multi render target texture
  17644. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  17645. * @param size defines the size of the texture
  17646. * @param options defines the creation options
  17647. * @returns the cube texture as an InternalTexture
  17648. */
  17649. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  17650. /**
  17651. * Update the sample count for a given multiple render target texture
  17652. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  17653. * @param textures defines the textures to update
  17654. * @param samples defines the sample count to set
  17655. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  17656. */
  17657. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  17658. /**
  17659. * Select a subsets of attachments to draw to.
  17660. * @param attachments gl attachments
  17661. */
  17662. bindAttachments(attachments: number[]): void;
  17663. /**
  17664. * Creates a layout object to draw/clear on specific textures in a MRT
  17665. * @param textureStatus textureStatus[i] indicates if the i-th is active
  17666. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  17667. */
  17668. buildTextureLayout(textureStatus: boolean[]): number[];
  17669. /**
  17670. * Restores the webgl state to only draw on the main color attachment
  17671. */
  17672. restoreSingleAttachment(): void;
  17673. }
  17674. }
  17675. declare module BABYLON {
  17676. /**
  17677. * Creation options of the multi render target texture.
  17678. */
  17679. export interface IMultiRenderTargetOptions {
  17680. /**
  17681. * Define if the texture needs to create mip maps after render.
  17682. */
  17683. generateMipMaps?: boolean;
  17684. /**
  17685. * Define the types of all the draw buffers we want to create
  17686. */
  17687. types?: number[];
  17688. /**
  17689. * Define the sampling modes of all the draw buffers we want to create
  17690. */
  17691. samplingModes?: number[];
  17692. /**
  17693. * Define if a depth buffer is required
  17694. */
  17695. generateDepthBuffer?: boolean;
  17696. /**
  17697. * Define if a stencil buffer is required
  17698. */
  17699. generateStencilBuffer?: boolean;
  17700. /**
  17701. * Define if a depth texture is required instead of a depth buffer
  17702. */
  17703. generateDepthTexture?: boolean;
  17704. /**
  17705. * Define the number of desired draw buffers
  17706. */
  17707. textureCount?: number;
  17708. /**
  17709. * Define if aspect ratio should be adapted to the texture or stay the scene one
  17710. */
  17711. doNotChangeAspectRatio?: boolean;
  17712. /**
  17713. * Define the default type of the buffers we are creating
  17714. */
  17715. defaultType?: number;
  17716. }
  17717. /**
  17718. * A multi render target, like a render target provides the ability to render to a texture.
  17719. * Unlike the render target, it can render to several draw buffers in one draw.
  17720. * This is specially interesting in deferred rendering or for any effects requiring more than
  17721. * just one color from a single pass.
  17722. */
  17723. export class MultiRenderTarget extends RenderTargetTexture {
  17724. private _internalTextures;
  17725. private _textures;
  17726. private _multiRenderTargetOptions;
  17727. private _count;
  17728. /**
  17729. * Get if draw buffers are currently supported by the used hardware and browser.
  17730. */
  17731. get isSupported(): boolean;
  17732. /**
  17733. * Get the list of textures generated by the multi render target.
  17734. */
  17735. get textures(): Texture[];
  17736. /**
  17737. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  17738. */
  17739. get count(): number;
  17740. /**
  17741. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  17742. */
  17743. get depthTexture(): Texture;
  17744. /**
  17745. * Set the wrapping mode on U of all the textures we are rendering to.
  17746. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17747. */
  17748. set wrapU(wrap: number);
  17749. /**
  17750. * Set the wrapping mode on V of all the textures we are rendering to.
  17751. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17752. */
  17753. set wrapV(wrap: number);
  17754. /**
  17755. * Instantiate a new multi render target texture.
  17756. * A multi render target, like a render target provides the ability to render to a texture.
  17757. * Unlike the render target, it can render to several draw buffers in one draw.
  17758. * This is specially interesting in deferred rendering or for any effects requiring more than
  17759. * just one color from a single pass.
  17760. * @param name Define the name of the texture
  17761. * @param size Define the size of the buffers to render to
  17762. * @param count Define the number of target we are rendering into
  17763. * @param scene Define the scene the texture belongs to
  17764. * @param options Define the options used to create the multi render target
  17765. */
  17766. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  17767. private _initTypes;
  17768. /** @hidden */
  17769. _rebuild(forceFullRebuild?: boolean): void;
  17770. private _createInternalTextures;
  17771. private _createTextures;
  17772. /**
  17773. * Replaces a texture within the MRT.
  17774. * @param texture The new texture to insert in the MRT
  17775. * @param index The index of the texture to replace
  17776. */
  17777. replaceTexture(texture: Texture, index: number): void;
  17778. /**
  17779. * Define the number of samples used if MSAA is enabled.
  17780. */
  17781. get samples(): number;
  17782. set samples(value: number);
  17783. /**
  17784. * Resize all the textures in the multi render target.
  17785. * Be careful as it will recreate all the data in the new texture.
  17786. * @param size Define the new size
  17787. */
  17788. resize(size: any): void;
  17789. /**
  17790. * Changes the number of render targets in this MRT
  17791. * Be careful as it will recreate all the data in the new texture.
  17792. * @param count new texture count
  17793. * @param options Specifies texture types and sampling modes for new textures
  17794. */
  17795. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  17796. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17797. /**
  17798. * Dispose the render targets and their associated resources
  17799. */
  17800. dispose(): void;
  17801. /**
  17802. * Release all the underlying texture used as draw buffers.
  17803. */
  17804. releaseInternalTextures(): void;
  17805. }
  17806. }
  17807. declare module BABYLON {
  17808. /** @hidden */
  17809. export var imageProcessingPixelShader: {
  17810. name: string;
  17811. shader: string;
  17812. };
  17813. }
  17814. declare module BABYLON {
  17815. /**
  17816. * ImageProcessingPostProcess
  17817. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  17818. */
  17819. export class ImageProcessingPostProcess extends PostProcess {
  17820. /**
  17821. * Default configuration related to image processing available in the PBR Material.
  17822. */
  17823. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17824. /**
  17825. * Gets the image processing configuration used either in this material.
  17826. */
  17827. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17828. /**
  17829. * Sets the Default image processing configuration used either in the this material.
  17830. *
  17831. * If sets to null, the scene one is in use.
  17832. */
  17833. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17834. /**
  17835. * Keep track of the image processing observer to allow dispose and replace.
  17836. */
  17837. private _imageProcessingObserver;
  17838. /**
  17839. * Attaches a new image processing configuration to the PBR Material.
  17840. * @param configuration
  17841. */
  17842. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  17843. /**
  17844. * If the post process is supported.
  17845. */
  17846. get isSupported(): boolean;
  17847. /**
  17848. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17849. */
  17850. get colorCurves(): Nullable<ColorCurves>;
  17851. /**
  17852. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17853. */
  17854. set colorCurves(value: Nullable<ColorCurves>);
  17855. /**
  17856. * Gets wether the color curves effect is enabled.
  17857. */
  17858. get colorCurvesEnabled(): boolean;
  17859. /**
  17860. * Sets wether the color curves effect is enabled.
  17861. */
  17862. set colorCurvesEnabled(value: boolean);
  17863. /**
  17864. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17865. */
  17866. get colorGradingTexture(): Nullable<BaseTexture>;
  17867. /**
  17868. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17869. */
  17870. set colorGradingTexture(value: Nullable<BaseTexture>);
  17871. /**
  17872. * Gets wether the color grading effect is enabled.
  17873. */
  17874. get colorGradingEnabled(): boolean;
  17875. /**
  17876. * Gets wether the color grading effect is enabled.
  17877. */
  17878. set colorGradingEnabled(value: boolean);
  17879. /**
  17880. * Gets exposure used in the effect.
  17881. */
  17882. get exposure(): number;
  17883. /**
  17884. * Sets exposure used in the effect.
  17885. */
  17886. set exposure(value: number);
  17887. /**
  17888. * Gets wether tonemapping is enabled or not.
  17889. */
  17890. get toneMappingEnabled(): boolean;
  17891. /**
  17892. * Sets wether tonemapping is enabled or not
  17893. */
  17894. set toneMappingEnabled(value: boolean);
  17895. /**
  17896. * Gets the type of tone mapping effect.
  17897. */
  17898. get toneMappingType(): number;
  17899. /**
  17900. * Sets the type of tone mapping effect.
  17901. */
  17902. set toneMappingType(value: number);
  17903. /**
  17904. * Gets contrast used in the effect.
  17905. */
  17906. get contrast(): number;
  17907. /**
  17908. * Sets contrast used in the effect.
  17909. */
  17910. set contrast(value: number);
  17911. /**
  17912. * Gets Vignette stretch size.
  17913. */
  17914. get vignetteStretch(): number;
  17915. /**
  17916. * Sets Vignette stretch size.
  17917. */
  17918. set vignetteStretch(value: number);
  17919. /**
  17920. * Gets Vignette centre X Offset.
  17921. */
  17922. get vignetteCentreX(): number;
  17923. /**
  17924. * Sets Vignette centre X Offset.
  17925. */
  17926. set vignetteCentreX(value: number);
  17927. /**
  17928. * Gets Vignette centre Y Offset.
  17929. */
  17930. get vignetteCentreY(): number;
  17931. /**
  17932. * Sets Vignette centre Y Offset.
  17933. */
  17934. set vignetteCentreY(value: number);
  17935. /**
  17936. * Gets Vignette weight or intensity of the vignette effect.
  17937. */
  17938. get vignetteWeight(): number;
  17939. /**
  17940. * Sets Vignette weight or intensity of the vignette effect.
  17941. */
  17942. set vignetteWeight(value: number);
  17943. /**
  17944. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17945. * if vignetteEnabled is set to true.
  17946. */
  17947. get vignetteColor(): Color4;
  17948. /**
  17949. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17950. * if vignetteEnabled is set to true.
  17951. */
  17952. set vignetteColor(value: Color4);
  17953. /**
  17954. * Gets Camera field of view used by the Vignette effect.
  17955. */
  17956. get vignetteCameraFov(): number;
  17957. /**
  17958. * Sets Camera field of view used by the Vignette effect.
  17959. */
  17960. set vignetteCameraFov(value: number);
  17961. /**
  17962. * Gets the vignette blend mode allowing different kind of effect.
  17963. */
  17964. get vignetteBlendMode(): number;
  17965. /**
  17966. * Sets the vignette blend mode allowing different kind of effect.
  17967. */
  17968. set vignetteBlendMode(value: number);
  17969. /**
  17970. * Gets wether the vignette effect is enabled.
  17971. */
  17972. get vignetteEnabled(): boolean;
  17973. /**
  17974. * Sets wether the vignette effect is enabled.
  17975. */
  17976. set vignetteEnabled(value: boolean);
  17977. private _fromLinearSpace;
  17978. /**
  17979. * Gets wether the input of the processing is in Gamma or Linear Space.
  17980. */
  17981. get fromLinearSpace(): boolean;
  17982. /**
  17983. * Sets wether the input of the processing is in Gamma or Linear Space.
  17984. */
  17985. set fromLinearSpace(value: boolean);
  17986. /**
  17987. * Defines cache preventing GC.
  17988. */
  17989. private _defines;
  17990. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  17991. /**
  17992. * "ImageProcessingPostProcess"
  17993. * @returns "ImageProcessingPostProcess"
  17994. */
  17995. getClassName(): string;
  17996. /**
  17997. * @hidden
  17998. */
  17999. _updateParameters(): void;
  18000. dispose(camera?: Camera): void;
  18001. }
  18002. }
  18003. declare module BABYLON {
  18004. /**
  18005. * Interface for defining prepass effects in the prepass post-process pipeline
  18006. */
  18007. export interface PrePassEffectConfiguration {
  18008. /**
  18009. * Name of the effect
  18010. */
  18011. name: string;
  18012. /**
  18013. * Post process to attach for this effect
  18014. */
  18015. postProcess?: PostProcess;
  18016. /**
  18017. * Textures required in the MRT
  18018. */
  18019. texturesRequired: number[];
  18020. /**
  18021. * Is the effect enabled
  18022. */
  18023. enabled: boolean;
  18024. /**
  18025. * Disposes the effect configuration
  18026. */
  18027. dispose?: () => void;
  18028. /**
  18029. * Creates the associated post process
  18030. */
  18031. createPostProcess?: () => PostProcess;
  18032. }
  18033. }
  18034. declare module BABYLON {
  18035. /**
  18036. * Options to be used when creating a FresnelParameters.
  18037. */
  18038. export type IFresnelParametersCreationOptions = {
  18039. /**
  18040. * Define the color used on edges (grazing angle)
  18041. */
  18042. leftColor?: Color3;
  18043. /**
  18044. * Define the color used on center
  18045. */
  18046. rightColor?: Color3;
  18047. /**
  18048. * Define bias applied to computed fresnel term
  18049. */
  18050. bias?: number;
  18051. /**
  18052. * Defined the power exponent applied to fresnel term
  18053. */
  18054. power?: number;
  18055. /**
  18056. * Define if the fresnel effect is enable or not.
  18057. */
  18058. isEnabled?: boolean;
  18059. };
  18060. /**
  18061. * Serialized format for FresnelParameters.
  18062. */
  18063. export type IFresnelParametersSerialized = {
  18064. /**
  18065. * Define the color used on edges (grazing angle) [as an array]
  18066. */
  18067. leftColor: number[];
  18068. /**
  18069. * Define the color used on center [as an array]
  18070. */
  18071. rightColor: number[];
  18072. /**
  18073. * Define bias applied to computed fresnel term
  18074. */
  18075. bias: number;
  18076. /**
  18077. * Defined the power exponent applied to fresnel term
  18078. */
  18079. power?: number;
  18080. /**
  18081. * Define if the fresnel effect is enable or not.
  18082. */
  18083. isEnabled: boolean;
  18084. };
  18085. /**
  18086. * This represents all the required information to add a fresnel effect on a material:
  18087. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18088. */
  18089. export class FresnelParameters {
  18090. private _isEnabled;
  18091. /**
  18092. * Define if the fresnel effect is enable or not.
  18093. */
  18094. get isEnabled(): boolean;
  18095. set isEnabled(value: boolean);
  18096. /**
  18097. * Define the color used on edges (grazing angle)
  18098. */
  18099. leftColor: Color3;
  18100. /**
  18101. * Define the color used on center
  18102. */
  18103. rightColor: Color3;
  18104. /**
  18105. * Define bias applied to computed fresnel term
  18106. */
  18107. bias: number;
  18108. /**
  18109. * Defined the power exponent applied to fresnel term
  18110. */
  18111. power: number;
  18112. /**
  18113. * Creates a new FresnelParameters object.
  18114. *
  18115. * @param options provide your own settings to optionally to override defaults
  18116. */
  18117. constructor(options?: IFresnelParametersCreationOptions);
  18118. /**
  18119. * Clones the current fresnel and its valuues
  18120. * @returns a clone fresnel configuration
  18121. */
  18122. clone(): FresnelParameters;
  18123. /**
  18124. * Determines equality between FresnelParameters objects
  18125. * @param otherFresnelParameters defines the second operand
  18126. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18127. */
  18128. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18129. /**
  18130. * Serializes the current fresnel parameters to a JSON representation.
  18131. * @return the JSON serialization
  18132. */
  18133. serialize(): IFresnelParametersSerialized;
  18134. /**
  18135. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18136. * @param parsedFresnelParameters Define the JSON representation
  18137. * @returns the parsed parameters
  18138. */
  18139. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18140. }
  18141. }
  18142. declare module BABYLON {
  18143. /**
  18144. * This groups all the flags used to control the materials channel.
  18145. */
  18146. export class MaterialFlags {
  18147. private static _DiffuseTextureEnabled;
  18148. /**
  18149. * Are diffuse textures enabled in the application.
  18150. */
  18151. static get DiffuseTextureEnabled(): boolean;
  18152. static set DiffuseTextureEnabled(value: boolean);
  18153. private static _DetailTextureEnabled;
  18154. /**
  18155. * Are detail textures enabled in the application.
  18156. */
  18157. static get DetailTextureEnabled(): boolean;
  18158. static set DetailTextureEnabled(value: boolean);
  18159. private static _AmbientTextureEnabled;
  18160. /**
  18161. * Are ambient textures enabled in the application.
  18162. */
  18163. static get AmbientTextureEnabled(): boolean;
  18164. static set AmbientTextureEnabled(value: boolean);
  18165. private static _OpacityTextureEnabled;
  18166. /**
  18167. * Are opacity textures enabled in the application.
  18168. */
  18169. static get OpacityTextureEnabled(): boolean;
  18170. static set OpacityTextureEnabled(value: boolean);
  18171. private static _ReflectionTextureEnabled;
  18172. /**
  18173. * Are reflection textures enabled in the application.
  18174. */
  18175. static get ReflectionTextureEnabled(): boolean;
  18176. static set ReflectionTextureEnabled(value: boolean);
  18177. private static _EmissiveTextureEnabled;
  18178. /**
  18179. * Are emissive textures enabled in the application.
  18180. */
  18181. static get EmissiveTextureEnabled(): boolean;
  18182. static set EmissiveTextureEnabled(value: boolean);
  18183. private static _SpecularTextureEnabled;
  18184. /**
  18185. * Are specular textures enabled in the application.
  18186. */
  18187. static get SpecularTextureEnabled(): boolean;
  18188. static set SpecularTextureEnabled(value: boolean);
  18189. private static _BumpTextureEnabled;
  18190. /**
  18191. * Are bump textures enabled in the application.
  18192. */
  18193. static get BumpTextureEnabled(): boolean;
  18194. static set BumpTextureEnabled(value: boolean);
  18195. private static _LightmapTextureEnabled;
  18196. /**
  18197. * Are lightmap textures enabled in the application.
  18198. */
  18199. static get LightmapTextureEnabled(): boolean;
  18200. static set LightmapTextureEnabled(value: boolean);
  18201. private static _RefractionTextureEnabled;
  18202. /**
  18203. * Are refraction textures enabled in the application.
  18204. */
  18205. static get RefractionTextureEnabled(): boolean;
  18206. static set RefractionTextureEnabled(value: boolean);
  18207. private static _ColorGradingTextureEnabled;
  18208. /**
  18209. * Are color grading textures enabled in the application.
  18210. */
  18211. static get ColorGradingTextureEnabled(): boolean;
  18212. static set ColorGradingTextureEnabled(value: boolean);
  18213. private static _FresnelEnabled;
  18214. /**
  18215. * Are fresnels enabled in the application.
  18216. */
  18217. static get FresnelEnabled(): boolean;
  18218. static set FresnelEnabled(value: boolean);
  18219. private static _ClearCoatTextureEnabled;
  18220. /**
  18221. * Are clear coat textures enabled in the application.
  18222. */
  18223. static get ClearCoatTextureEnabled(): boolean;
  18224. static set ClearCoatTextureEnabled(value: boolean);
  18225. private static _ClearCoatBumpTextureEnabled;
  18226. /**
  18227. * Are clear coat bump textures enabled in the application.
  18228. */
  18229. static get ClearCoatBumpTextureEnabled(): boolean;
  18230. static set ClearCoatBumpTextureEnabled(value: boolean);
  18231. private static _ClearCoatTintTextureEnabled;
  18232. /**
  18233. * Are clear coat tint textures enabled in the application.
  18234. */
  18235. static get ClearCoatTintTextureEnabled(): boolean;
  18236. static set ClearCoatTintTextureEnabled(value: boolean);
  18237. private static _SheenTextureEnabled;
  18238. /**
  18239. * Are sheen textures enabled in the application.
  18240. */
  18241. static get SheenTextureEnabled(): boolean;
  18242. static set SheenTextureEnabled(value: boolean);
  18243. private static _AnisotropicTextureEnabled;
  18244. /**
  18245. * Are anisotropic textures enabled in the application.
  18246. */
  18247. static get AnisotropicTextureEnabled(): boolean;
  18248. static set AnisotropicTextureEnabled(value: boolean);
  18249. private static _ThicknessTextureEnabled;
  18250. /**
  18251. * Are thickness textures enabled in the application.
  18252. */
  18253. static get ThicknessTextureEnabled(): boolean;
  18254. static set ThicknessTextureEnabled(value: boolean);
  18255. }
  18256. }
  18257. declare module BABYLON {
  18258. /** @hidden */
  18259. export var defaultFragmentDeclaration: {
  18260. name: string;
  18261. shader: string;
  18262. };
  18263. }
  18264. declare module BABYLON {
  18265. /** @hidden */
  18266. export var defaultUboDeclaration: {
  18267. name: string;
  18268. shader: string;
  18269. };
  18270. }
  18271. declare module BABYLON {
  18272. /** @hidden */
  18273. export var prePassDeclaration: {
  18274. name: string;
  18275. shader: string;
  18276. };
  18277. }
  18278. declare module BABYLON {
  18279. /** @hidden */
  18280. export var lightFragmentDeclaration: {
  18281. name: string;
  18282. shader: string;
  18283. };
  18284. }
  18285. declare module BABYLON {
  18286. /** @hidden */
  18287. export var lightUboDeclaration: {
  18288. name: string;
  18289. shader: string;
  18290. };
  18291. }
  18292. declare module BABYLON {
  18293. /** @hidden */
  18294. export var lightsFragmentFunctions: {
  18295. name: string;
  18296. shader: string;
  18297. };
  18298. }
  18299. declare module BABYLON {
  18300. /** @hidden */
  18301. export var shadowsFragmentFunctions: {
  18302. name: string;
  18303. shader: string;
  18304. };
  18305. }
  18306. declare module BABYLON {
  18307. /** @hidden */
  18308. export var fresnelFunction: {
  18309. name: string;
  18310. shader: string;
  18311. };
  18312. }
  18313. declare module BABYLON {
  18314. /** @hidden */
  18315. export var bumpFragmentMainFunctions: {
  18316. name: string;
  18317. shader: string;
  18318. };
  18319. }
  18320. declare module BABYLON {
  18321. /** @hidden */
  18322. export var bumpFragmentFunctions: {
  18323. name: string;
  18324. shader: string;
  18325. };
  18326. }
  18327. declare module BABYLON {
  18328. /** @hidden */
  18329. export var logDepthDeclaration: {
  18330. name: string;
  18331. shader: string;
  18332. };
  18333. }
  18334. declare module BABYLON {
  18335. /** @hidden */
  18336. export var fogFragmentDeclaration: {
  18337. name: string;
  18338. shader: string;
  18339. };
  18340. }
  18341. declare module BABYLON {
  18342. /** @hidden */
  18343. export var bumpFragment: {
  18344. name: string;
  18345. shader: string;
  18346. };
  18347. }
  18348. declare module BABYLON {
  18349. /** @hidden */
  18350. export var depthPrePass: {
  18351. name: string;
  18352. shader: string;
  18353. };
  18354. }
  18355. declare module BABYLON {
  18356. /** @hidden */
  18357. export var lightFragment: {
  18358. name: string;
  18359. shader: string;
  18360. };
  18361. }
  18362. declare module BABYLON {
  18363. /** @hidden */
  18364. export var logDepthFragment: {
  18365. name: string;
  18366. shader: string;
  18367. };
  18368. }
  18369. declare module BABYLON {
  18370. /** @hidden */
  18371. export var fogFragment: {
  18372. name: string;
  18373. shader: string;
  18374. };
  18375. }
  18376. declare module BABYLON {
  18377. /** @hidden */
  18378. export var defaultPixelShader: {
  18379. name: string;
  18380. shader: string;
  18381. };
  18382. }
  18383. declare module BABYLON {
  18384. /** @hidden */
  18385. export var defaultVertexDeclaration: {
  18386. name: string;
  18387. shader: string;
  18388. };
  18389. }
  18390. declare module BABYLON {
  18391. /** @hidden */
  18392. export var bonesDeclaration: {
  18393. name: string;
  18394. shader: string;
  18395. };
  18396. }
  18397. declare module BABYLON {
  18398. /** @hidden */
  18399. export var instancesDeclaration: {
  18400. name: string;
  18401. shader: string;
  18402. };
  18403. }
  18404. declare module BABYLON {
  18405. /** @hidden */
  18406. export var prePassVertexDeclaration: {
  18407. name: string;
  18408. shader: string;
  18409. };
  18410. }
  18411. declare module BABYLON {
  18412. /** @hidden */
  18413. export var bumpVertexDeclaration: {
  18414. name: string;
  18415. shader: string;
  18416. };
  18417. }
  18418. declare module BABYLON {
  18419. /** @hidden */
  18420. export var fogVertexDeclaration: {
  18421. name: string;
  18422. shader: string;
  18423. };
  18424. }
  18425. declare module BABYLON {
  18426. /** @hidden */
  18427. export var morphTargetsVertexGlobalDeclaration: {
  18428. name: string;
  18429. shader: string;
  18430. };
  18431. }
  18432. declare module BABYLON {
  18433. /** @hidden */
  18434. export var morphTargetsVertexDeclaration: {
  18435. name: string;
  18436. shader: string;
  18437. };
  18438. }
  18439. declare module BABYLON {
  18440. /** @hidden */
  18441. export var morphTargetsVertex: {
  18442. name: string;
  18443. shader: string;
  18444. };
  18445. }
  18446. declare module BABYLON {
  18447. /** @hidden */
  18448. export var instancesVertex: {
  18449. name: string;
  18450. shader: string;
  18451. };
  18452. }
  18453. declare module BABYLON {
  18454. /** @hidden */
  18455. export var bonesVertex: {
  18456. name: string;
  18457. shader: string;
  18458. };
  18459. }
  18460. declare module BABYLON {
  18461. /** @hidden */
  18462. export var prePassVertex: {
  18463. name: string;
  18464. shader: string;
  18465. };
  18466. }
  18467. declare module BABYLON {
  18468. /** @hidden */
  18469. export var bumpVertex: {
  18470. name: string;
  18471. shader: string;
  18472. };
  18473. }
  18474. declare module BABYLON {
  18475. /** @hidden */
  18476. export var fogVertex: {
  18477. name: string;
  18478. shader: string;
  18479. };
  18480. }
  18481. declare module BABYLON {
  18482. /** @hidden */
  18483. export var shadowsVertex: {
  18484. name: string;
  18485. shader: string;
  18486. };
  18487. }
  18488. declare module BABYLON {
  18489. /** @hidden */
  18490. export var pointCloudVertex: {
  18491. name: string;
  18492. shader: string;
  18493. };
  18494. }
  18495. declare module BABYLON {
  18496. /** @hidden */
  18497. export var logDepthVertex: {
  18498. name: string;
  18499. shader: string;
  18500. };
  18501. }
  18502. declare module BABYLON {
  18503. /** @hidden */
  18504. export var defaultVertexShader: {
  18505. name: string;
  18506. shader: string;
  18507. };
  18508. }
  18509. declare module BABYLON {
  18510. /**
  18511. * @hidden
  18512. */
  18513. export interface IMaterialDetailMapDefines {
  18514. DETAIL: boolean;
  18515. DETAILDIRECTUV: number;
  18516. DETAIL_NORMALBLENDMETHOD: number;
  18517. /** @hidden */
  18518. _areTexturesDirty: boolean;
  18519. }
  18520. /**
  18521. * Define the code related to the detail map parameters of a material
  18522. *
  18523. * Inspired from:
  18524. * 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
  18525. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  18526. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  18527. */
  18528. export class DetailMapConfiguration {
  18529. private _texture;
  18530. /**
  18531. * The detail texture of the material.
  18532. */
  18533. texture: Nullable<BaseTexture>;
  18534. /**
  18535. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  18536. * Bigger values mean stronger blending
  18537. */
  18538. diffuseBlendLevel: number;
  18539. /**
  18540. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  18541. * Bigger values mean stronger blending. Only used with PBR materials
  18542. */
  18543. roughnessBlendLevel: number;
  18544. /**
  18545. * Defines how strong the bump effect from the detail map is
  18546. * Bigger values mean stronger effect
  18547. */
  18548. bumpLevel: number;
  18549. private _normalBlendMethod;
  18550. /**
  18551. * The method used to blend the bump and detail normals together
  18552. */
  18553. normalBlendMethod: number;
  18554. private _isEnabled;
  18555. /**
  18556. * Enable or disable the detail map on this material
  18557. */
  18558. isEnabled: boolean;
  18559. /** @hidden */
  18560. private _internalMarkAllSubMeshesAsTexturesDirty;
  18561. /** @hidden */
  18562. _markAllSubMeshesAsTexturesDirty(): void;
  18563. /**
  18564. * Instantiate a new detail map
  18565. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  18566. */
  18567. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  18568. /**
  18569. * Gets whether the submesh is ready to be used or not.
  18570. * @param defines the list of "defines" to update.
  18571. * @param scene defines the scene the material belongs to.
  18572. * @returns - boolean indicating that the submesh is ready or not.
  18573. */
  18574. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  18575. /**
  18576. * Update the defines for detail map usage
  18577. * @param defines the list of "defines" to update.
  18578. * @param scene defines the scene the material belongs to.
  18579. */
  18580. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  18581. /**
  18582. * Binds the material data.
  18583. * @param uniformBuffer defines the Uniform buffer to fill in.
  18584. * @param scene defines the scene the material belongs to.
  18585. * @param isFrozen defines whether the material is frozen or not.
  18586. */
  18587. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  18588. /**
  18589. * Checks to see if a texture is used in the material.
  18590. * @param texture - Base texture to use.
  18591. * @returns - Boolean specifying if a texture is used in the material.
  18592. */
  18593. hasTexture(texture: BaseTexture): boolean;
  18594. /**
  18595. * Returns an array of the actively used textures.
  18596. * @param activeTextures Array of BaseTextures
  18597. */
  18598. getActiveTextures(activeTextures: BaseTexture[]): void;
  18599. /**
  18600. * Returns the animatable textures.
  18601. * @param animatables Array of animatable textures.
  18602. */
  18603. getAnimatables(animatables: IAnimatable[]): void;
  18604. /**
  18605. * Disposes the resources of the material.
  18606. * @param forceDisposeTextures - Forces the disposal of all textures.
  18607. */
  18608. dispose(forceDisposeTextures?: boolean): void;
  18609. /**
  18610. * Get the current class name useful for serialization or dynamic coding.
  18611. * @returns "DetailMap"
  18612. */
  18613. getClassName(): string;
  18614. /**
  18615. * Add the required uniforms to the current list.
  18616. * @param uniforms defines the current uniform list.
  18617. */
  18618. static AddUniforms(uniforms: string[]): void;
  18619. /**
  18620. * Add the required samplers to the current list.
  18621. * @param samplers defines the current sampler list.
  18622. */
  18623. static AddSamplers(samplers: string[]): void;
  18624. /**
  18625. * Add the required uniforms to the current buffer.
  18626. * @param uniformBuffer defines the current uniform buffer.
  18627. */
  18628. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  18629. /**
  18630. * Makes a duplicate of the current instance into another one.
  18631. * @param detailMap define the instance where to copy the info
  18632. */
  18633. copyTo(detailMap: DetailMapConfiguration): void;
  18634. /**
  18635. * Serializes this detail map instance
  18636. * @returns - An object with the serialized instance.
  18637. */
  18638. serialize(): any;
  18639. /**
  18640. * Parses a detail map setting from a serialized object.
  18641. * @param source - Serialized object.
  18642. * @param scene Defines the scene we are parsing for
  18643. * @param rootUrl Defines the rootUrl to load from
  18644. */
  18645. parse(source: any, scene: Scene, rootUrl: string): void;
  18646. }
  18647. }
  18648. declare module BABYLON {
  18649. /** @hidden */
  18650. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  18651. MAINUV1: boolean;
  18652. MAINUV2: boolean;
  18653. DIFFUSE: boolean;
  18654. DIFFUSEDIRECTUV: number;
  18655. DETAIL: boolean;
  18656. DETAILDIRECTUV: number;
  18657. DETAIL_NORMALBLENDMETHOD: number;
  18658. AMBIENT: boolean;
  18659. AMBIENTDIRECTUV: number;
  18660. OPACITY: boolean;
  18661. OPACITYDIRECTUV: number;
  18662. OPACITYRGB: boolean;
  18663. REFLECTION: boolean;
  18664. EMISSIVE: boolean;
  18665. EMISSIVEDIRECTUV: number;
  18666. SPECULAR: boolean;
  18667. SPECULARDIRECTUV: number;
  18668. BUMP: boolean;
  18669. BUMPDIRECTUV: number;
  18670. PARALLAX: boolean;
  18671. PARALLAXOCCLUSION: boolean;
  18672. SPECULAROVERALPHA: boolean;
  18673. CLIPPLANE: boolean;
  18674. CLIPPLANE2: boolean;
  18675. CLIPPLANE3: boolean;
  18676. CLIPPLANE4: boolean;
  18677. CLIPPLANE5: boolean;
  18678. CLIPPLANE6: boolean;
  18679. ALPHATEST: boolean;
  18680. DEPTHPREPASS: boolean;
  18681. ALPHAFROMDIFFUSE: boolean;
  18682. POINTSIZE: boolean;
  18683. FOG: boolean;
  18684. SPECULARTERM: boolean;
  18685. DIFFUSEFRESNEL: boolean;
  18686. OPACITYFRESNEL: boolean;
  18687. REFLECTIONFRESNEL: boolean;
  18688. REFRACTIONFRESNEL: boolean;
  18689. EMISSIVEFRESNEL: boolean;
  18690. FRESNEL: boolean;
  18691. NORMAL: boolean;
  18692. UV1: boolean;
  18693. UV2: boolean;
  18694. VERTEXCOLOR: boolean;
  18695. VERTEXALPHA: boolean;
  18696. NUM_BONE_INFLUENCERS: number;
  18697. BonesPerMesh: number;
  18698. BONETEXTURE: boolean;
  18699. BONES_VELOCITY_ENABLED: boolean;
  18700. INSTANCES: boolean;
  18701. THIN_INSTANCES: boolean;
  18702. GLOSSINESS: boolean;
  18703. ROUGHNESS: boolean;
  18704. EMISSIVEASILLUMINATION: boolean;
  18705. LINKEMISSIVEWITHDIFFUSE: boolean;
  18706. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18707. LIGHTMAP: boolean;
  18708. LIGHTMAPDIRECTUV: number;
  18709. OBJECTSPACE_NORMALMAP: boolean;
  18710. USELIGHTMAPASSHADOWMAP: boolean;
  18711. REFLECTIONMAP_3D: boolean;
  18712. REFLECTIONMAP_SPHERICAL: boolean;
  18713. REFLECTIONMAP_PLANAR: boolean;
  18714. REFLECTIONMAP_CUBIC: boolean;
  18715. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18716. REFLECTIONMAP_PROJECTION: boolean;
  18717. REFLECTIONMAP_SKYBOX: boolean;
  18718. REFLECTIONMAP_EXPLICIT: boolean;
  18719. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18720. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18721. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18722. INVERTCUBICMAP: boolean;
  18723. LOGARITHMICDEPTH: boolean;
  18724. REFRACTION: boolean;
  18725. REFRACTIONMAP_3D: boolean;
  18726. REFLECTIONOVERALPHA: boolean;
  18727. TWOSIDEDLIGHTING: boolean;
  18728. SHADOWFLOAT: boolean;
  18729. MORPHTARGETS: boolean;
  18730. MORPHTARGETS_NORMAL: boolean;
  18731. MORPHTARGETS_TANGENT: boolean;
  18732. MORPHTARGETS_UV: boolean;
  18733. NUM_MORPH_INFLUENCERS: number;
  18734. NONUNIFORMSCALING: boolean;
  18735. PREMULTIPLYALPHA: boolean;
  18736. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  18737. ALPHABLEND: boolean;
  18738. PREPASS: boolean;
  18739. PREPASS_IRRADIANCE: boolean;
  18740. PREPASS_IRRADIANCE_INDEX: number;
  18741. PREPASS_ALBEDO: boolean;
  18742. PREPASS_ALBEDO_INDEX: number;
  18743. PREPASS_DEPTHNORMAL: boolean;
  18744. PREPASS_DEPTHNORMAL_INDEX: number;
  18745. PREPASS_POSITION: boolean;
  18746. PREPASS_POSITION_INDEX: number;
  18747. PREPASS_VELOCITY: boolean;
  18748. PREPASS_VELOCITY_INDEX: number;
  18749. PREPASS_REFLECTIVITY: boolean;
  18750. PREPASS_REFLECTIVITY_INDEX: number;
  18751. SCENE_MRT_COUNT: number;
  18752. RGBDLIGHTMAP: boolean;
  18753. RGBDREFLECTION: boolean;
  18754. RGBDREFRACTION: boolean;
  18755. IMAGEPROCESSING: boolean;
  18756. VIGNETTE: boolean;
  18757. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18758. VIGNETTEBLENDMODEOPAQUE: boolean;
  18759. TONEMAPPING: boolean;
  18760. TONEMAPPING_ACES: boolean;
  18761. CONTRAST: boolean;
  18762. COLORCURVES: boolean;
  18763. COLORGRADING: boolean;
  18764. COLORGRADING3D: boolean;
  18765. SAMPLER3DGREENDEPTH: boolean;
  18766. SAMPLER3DBGRMAP: boolean;
  18767. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18768. MULTIVIEW: boolean;
  18769. /**
  18770. * If the reflection texture on this material is in linear color space
  18771. * @hidden
  18772. */
  18773. IS_REFLECTION_LINEAR: boolean;
  18774. /**
  18775. * If the refraction texture on this material is in linear color space
  18776. * @hidden
  18777. */
  18778. IS_REFRACTION_LINEAR: boolean;
  18779. EXPOSURE: boolean;
  18780. constructor();
  18781. setReflectionMode(modeToEnable: string): void;
  18782. }
  18783. /**
  18784. * This is the default material used in Babylon. It is the best trade off between quality
  18785. * and performances.
  18786. * @see https://doc.babylonjs.com/babylon101/materials
  18787. */
  18788. export class StandardMaterial extends PushMaterial {
  18789. private _diffuseTexture;
  18790. /**
  18791. * The basic texture of the material as viewed under a light.
  18792. */
  18793. diffuseTexture: Nullable<BaseTexture>;
  18794. private _ambientTexture;
  18795. /**
  18796. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18797. */
  18798. ambientTexture: Nullable<BaseTexture>;
  18799. private _opacityTexture;
  18800. /**
  18801. * Define the transparency of the material from a texture.
  18802. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18803. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18804. */
  18805. opacityTexture: Nullable<BaseTexture>;
  18806. private _reflectionTexture;
  18807. /**
  18808. * Define the texture used to display the reflection.
  18809. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18810. */
  18811. reflectionTexture: Nullable<BaseTexture>;
  18812. private _emissiveTexture;
  18813. /**
  18814. * Define texture of the material as if self lit.
  18815. * This will be mixed in the final result even in the absence of light.
  18816. */
  18817. emissiveTexture: Nullable<BaseTexture>;
  18818. private _specularTexture;
  18819. /**
  18820. * Define how the color and intensity of the highlight given by the light in the material.
  18821. */
  18822. specularTexture: Nullable<BaseTexture>;
  18823. private _bumpTexture;
  18824. /**
  18825. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  18826. * 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.
  18827. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  18828. */
  18829. bumpTexture: Nullable<BaseTexture>;
  18830. private _lightmapTexture;
  18831. /**
  18832. * Complex lighting can be computationally expensive to compute at runtime.
  18833. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  18834. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  18835. */
  18836. lightmapTexture: Nullable<BaseTexture>;
  18837. private _refractionTexture;
  18838. /**
  18839. * Define the texture used to display the refraction.
  18840. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18841. */
  18842. refractionTexture: Nullable<BaseTexture>;
  18843. /**
  18844. * The color of the material lit by the environmental background lighting.
  18845. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  18846. */
  18847. ambientColor: Color3;
  18848. /**
  18849. * The basic color of the material as viewed under a light.
  18850. */
  18851. diffuseColor: Color3;
  18852. /**
  18853. * Define how the color and intensity of the highlight given by the light in the material.
  18854. */
  18855. specularColor: Color3;
  18856. /**
  18857. * Define the color of the material as if self lit.
  18858. * This will be mixed in the final result even in the absence of light.
  18859. */
  18860. emissiveColor: Color3;
  18861. /**
  18862. * Defines how sharp are the highlights in the material.
  18863. * The bigger the value the sharper giving a more glossy feeling to the result.
  18864. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  18865. */
  18866. specularPower: number;
  18867. private _useAlphaFromDiffuseTexture;
  18868. /**
  18869. * Does the transparency come from the diffuse texture alpha channel.
  18870. */
  18871. useAlphaFromDiffuseTexture: boolean;
  18872. private _useEmissiveAsIllumination;
  18873. /**
  18874. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  18875. */
  18876. useEmissiveAsIllumination: boolean;
  18877. private _linkEmissiveWithDiffuse;
  18878. /**
  18879. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  18880. * the emissive level when the final color is close to one.
  18881. */
  18882. linkEmissiveWithDiffuse: boolean;
  18883. private _useSpecularOverAlpha;
  18884. /**
  18885. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  18886. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  18887. */
  18888. useSpecularOverAlpha: boolean;
  18889. private _useReflectionOverAlpha;
  18890. /**
  18891. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  18892. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  18893. */
  18894. useReflectionOverAlpha: boolean;
  18895. private _disableLighting;
  18896. /**
  18897. * Does lights from the scene impacts this material.
  18898. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  18899. */
  18900. disableLighting: boolean;
  18901. private _useObjectSpaceNormalMap;
  18902. /**
  18903. * Allows using an object space normal map (instead of tangent space).
  18904. */
  18905. useObjectSpaceNormalMap: boolean;
  18906. private _useParallax;
  18907. /**
  18908. * Is parallax enabled or not.
  18909. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18910. */
  18911. useParallax: boolean;
  18912. private _useParallaxOcclusion;
  18913. /**
  18914. * Is parallax occlusion enabled or not.
  18915. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  18916. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18917. */
  18918. useParallaxOcclusion: boolean;
  18919. /**
  18920. * 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.
  18921. */
  18922. parallaxScaleBias: number;
  18923. private _roughness;
  18924. /**
  18925. * Helps to define how blurry the reflections should appears in the material.
  18926. */
  18927. roughness: number;
  18928. /**
  18929. * In case of refraction, define the value of the index of refraction.
  18930. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18931. */
  18932. indexOfRefraction: number;
  18933. /**
  18934. * Invert the refraction texture alongside the y axis.
  18935. * It can be useful with procedural textures or probe for instance.
  18936. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18937. */
  18938. invertRefractionY: boolean;
  18939. /**
  18940. * Defines the alpha limits in alpha test mode.
  18941. */
  18942. alphaCutOff: number;
  18943. private _useLightmapAsShadowmap;
  18944. /**
  18945. * In case of light mapping, define whether the map contains light or shadow informations.
  18946. */
  18947. useLightmapAsShadowmap: boolean;
  18948. private _diffuseFresnelParameters;
  18949. /**
  18950. * Define the diffuse fresnel parameters of the material.
  18951. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18952. */
  18953. diffuseFresnelParameters: FresnelParameters;
  18954. private _opacityFresnelParameters;
  18955. /**
  18956. * Define the opacity fresnel parameters of the material.
  18957. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18958. */
  18959. opacityFresnelParameters: FresnelParameters;
  18960. private _reflectionFresnelParameters;
  18961. /**
  18962. * Define the reflection fresnel parameters of the material.
  18963. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18964. */
  18965. reflectionFresnelParameters: FresnelParameters;
  18966. private _refractionFresnelParameters;
  18967. /**
  18968. * Define the refraction fresnel parameters of the material.
  18969. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18970. */
  18971. refractionFresnelParameters: FresnelParameters;
  18972. private _emissiveFresnelParameters;
  18973. /**
  18974. * Define the emissive fresnel parameters of the material.
  18975. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18976. */
  18977. emissiveFresnelParameters: FresnelParameters;
  18978. private _useReflectionFresnelFromSpecular;
  18979. /**
  18980. * If true automatically deducts the fresnels values from the material specularity.
  18981. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18982. */
  18983. useReflectionFresnelFromSpecular: boolean;
  18984. private _useGlossinessFromSpecularMapAlpha;
  18985. /**
  18986. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  18987. */
  18988. useGlossinessFromSpecularMapAlpha: boolean;
  18989. private _maxSimultaneousLights;
  18990. /**
  18991. * Defines the maximum number of lights that can be used in the material
  18992. */
  18993. maxSimultaneousLights: number;
  18994. private _invertNormalMapX;
  18995. /**
  18996. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18997. */
  18998. invertNormalMapX: boolean;
  18999. private _invertNormalMapY;
  19000. /**
  19001. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19002. */
  19003. invertNormalMapY: boolean;
  19004. private _twoSidedLighting;
  19005. /**
  19006. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19007. */
  19008. twoSidedLighting: boolean;
  19009. /**
  19010. * Default configuration related to image processing available in the standard Material.
  19011. */
  19012. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19013. /**
  19014. * Gets the image processing configuration used either in this material.
  19015. */
  19016. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19017. /**
  19018. * Sets the Default image processing configuration used either in the this material.
  19019. *
  19020. * If sets to null, the scene one is in use.
  19021. */
  19022. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19023. /**
  19024. * Keep track of the image processing observer to allow dispose and replace.
  19025. */
  19026. private _imageProcessingObserver;
  19027. /**
  19028. * Attaches a new image processing configuration to the Standard Material.
  19029. * @param configuration
  19030. */
  19031. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19032. /**
  19033. * Defines additionnal PrePass parameters for the material.
  19034. */
  19035. readonly prePassConfiguration: PrePassConfiguration;
  19036. /**
  19037. * Gets wether the color curves effect is enabled.
  19038. */
  19039. get cameraColorCurvesEnabled(): boolean;
  19040. /**
  19041. * Sets wether the color curves effect is enabled.
  19042. */
  19043. set cameraColorCurvesEnabled(value: boolean);
  19044. /**
  19045. * Gets wether the color grading effect is enabled.
  19046. */
  19047. get cameraColorGradingEnabled(): boolean;
  19048. /**
  19049. * Gets wether the color grading effect is enabled.
  19050. */
  19051. set cameraColorGradingEnabled(value: boolean);
  19052. /**
  19053. * Gets wether tonemapping is enabled or not.
  19054. */
  19055. get cameraToneMappingEnabled(): boolean;
  19056. /**
  19057. * Sets wether tonemapping is enabled or not
  19058. */
  19059. set cameraToneMappingEnabled(value: boolean);
  19060. /**
  19061. * The camera exposure used on this material.
  19062. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19063. * This corresponds to a photographic exposure.
  19064. */
  19065. get cameraExposure(): number;
  19066. /**
  19067. * The camera exposure used on this material.
  19068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19069. * This corresponds to a photographic exposure.
  19070. */
  19071. set cameraExposure(value: number);
  19072. /**
  19073. * Gets The camera contrast used on this material.
  19074. */
  19075. get cameraContrast(): number;
  19076. /**
  19077. * Sets The camera contrast used on this material.
  19078. */
  19079. set cameraContrast(value: number);
  19080. /**
  19081. * Gets the Color Grading 2D Lookup Texture.
  19082. */
  19083. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19084. /**
  19085. * Sets the Color Grading 2D Lookup Texture.
  19086. */
  19087. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19088. /**
  19089. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19090. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19091. * 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;
  19092. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19093. */
  19094. get cameraColorCurves(): Nullable<ColorCurves>;
  19095. /**
  19096. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19097. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19098. * 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;
  19099. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19100. */
  19101. set cameraColorCurves(value: Nullable<ColorCurves>);
  19102. /**
  19103. * Can this material render to several textures at once
  19104. */
  19105. get canRenderToMRT(): boolean;
  19106. /**
  19107. * Defines the detail map parameters for the material.
  19108. */
  19109. readonly detailMap: DetailMapConfiguration;
  19110. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19111. protected _worldViewProjectionMatrix: Matrix;
  19112. protected _globalAmbientColor: Color3;
  19113. protected _useLogarithmicDepth: boolean;
  19114. protected _rebuildInParallel: boolean;
  19115. /**
  19116. * Instantiates a new standard material.
  19117. * This is the default material used in Babylon. It is the best trade off between quality
  19118. * and performances.
  19119. * @see https://doc.babylonjs.com/babylon101/materials
  19120. * @param name Define the name of the material in the scene
  19121. * @param scene Define the scene the material belong to
  19122. */
  19123. constructor(name: string, scene: Scene);
  19124. /**
  19125. * Gets a boolean indicating that current material needs to register RTT
  19126. */
  19127. get hasRenderTargetTextures(): boolean;
  19128. /**
  19129. * Gets the current class name of the material e.g. "StandardMaterial"
  19130. * Mainly use in serialization.
  19131. * @returns the class name
  19132. */
  19133. getClassName(): string;
  19134. /**
  19135. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19136. * You can try switching to logarithmic depth.
  19137. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19138. */
  19139. get useLogarithmicDepth(): boolean;
  19140. set useLogarithmicDepth(value: boolean);
  19141. /**
  19142. * Specifies if the material will require alpha blending
  19143. * @returns a boolean specifying if alpha blending is needed
  19144. */
  19145. needAlphaBlending(): boolean;
  19146. /**
  19147. * Specifies if this material should be rendered in alpha test mode
  19148. * @returns a boolean specifying if an alpha test is needed.
  19149. */
  19150. needAlphaTesting(): boolean;
  19151. /**
  19152. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19153. */
  19154. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19155. /**
  19156. * Specifies whether or not there is a usable alpha channel for transparency.
  19157. */
  19158. protected _hasAlphaChannel(): boolean;
  19159. /**
  19160. * Get the texture used for alpha test purpose.
  19161. * @returns the diffuse texture in case of the standard material.
  19162. */
  19163. getAlphaTestTexture(): Nullable<BaseTexture>;
  19164. /**
  19165. * Get if the submesh is ready to be used and all its information available.
  19166. * Child classes can use it to update shaders
  19167. * @param mesh defines the mesh to check
  19168. * @param subMesh defines which submesh to check
  19169. * @param useInstances specifies that instances should be used
  19170. * @returns a boolean indicating that the submesh is ready or not
  19171. */
  19172. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19173. /**
  19174. * Builds the material UBO layouts.
  19175. * Used internally during the effect preparation.
  19176. */
  19177. buildUniformLayout(): void;
  19178. /**
  19179. * Unbinds the material from the mesh
  19180. */
  19181. unbind(): void;
  19182. /**
  19183. * Binds the submesh to this material by preparing the effect and shader to draw
  19184. * @param world defines the world transformation matrix
  19185. * @param mesh defines the mesh containing the submesh
  19186. * @param subMesh defines the submesh to bind the material to
  19187. */
  19188. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19189. /**
  19190. * Get the list of animatables in the material.
  19191. * @returns the list of animatables object used in the material
  19192. */
  19193. getAnimatables(): IAnimatable[];
  19194. /**
  19195. * Gets the active textures from the material
  19196. * @returns an array of textures
  19197. */
  19198. getActiveTextures(): BaseTexture[];
  19199. /**
  19200. * Specifies if the material uses a texture
  19201. * @param texture defines the texture to check against the material
  19202. * @returns a boolean specifying if the material uses the texture
  19203. */
  19204. hasTexture(texture: BaseTexture): boolean;
  19205. /**
  19206. * Disposes the material
  19207. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19208. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19209. */
  19210. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19211. /**
  19212. * Makes a duplicate of the material, and gives it a new name
  19213. * @param name defines the new name for the duplicated material
  19214. * @returns the cloned material
  19215. */
  19216. clone(name: string): StandardMaterial;
  19217. /**
  19218. * Serializes this material in a JSON representation
  19219. * @returns the serialized material object
  19220. */
  19221. serialize(): any;
  19222. /**
  19223. * Creates a standard material from parsed material data
  19224. * @param source defines the JSON representation of the material
  19225. * @param scene defines the hosting scene
  19226. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19227. * @returns a new standard material
  19228. */
  19229. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19230. /**
  19231. * Are diffuse textures enabled in the application.
  19232. */
  19233. static get DiffuseTextureEnabled(): boolean;
  19234. static set DiffuseTextureEnabled(value: boolean);
  19235. /**
  19236. * Are detail textures enabled in the application.
  19237. */
  19238. static get DetailTextureEnabled(): boolean;
  19239. static set DetailTextureEnabled(value: boolean);
  19240. /**
  19241. * Are ambient textures enabled in the application.
  19242. */
  19243. static get AmbientTextureEnabled(): boolean;
  19244. static set AmbientTextureEnabled(value: boolean);
  19245. /**
  19246. * Are opacity textures enabled in the application.
  19247. */
  19248. static get OpacityTextureEnabled(): boolean;
  19249. static set OpacityTextureEnabled(value: boolean);
  19250. /**
  19251. * Are reflection textures enabled in the application.
  19252. */
  19253. static get ReflectionTextureEnabled(): boolean;
  19254. static set ReflectionTextureEnabled(value: boolean);
  19255. /**
  19256. * Are emissive textures enabled in the application.
  19257. */
  19258. static get EmissiveTextureEnabled(): boolean;
  19259. static set EmissiveTextureEnabled(value: boolean);
  19260. /**
  19261. * Are specular textures enabled in the application.
  19262. */
  19263. static get SpecularTextureEnabled(): boolean;
  19264. static set SpecularTextureEnabled(value: boolean);
  19265. /**
  19266. * Are bump textures enabled in the application.
  19267. */
  19268. static get BumpTextureEnabled(): boolean;
  19269. static set BumpTextureEnabled(value: boolean);
  19270. /**
  19271. * Are lightmap textures enabled in the application.
  19272. */
  19273. static get LightmapTextureEnabled(): boolean;
  19274. static set LightmapTextureEnabled(value: boolean);
  19275. /**
  19276. * Are refraction textures enabled in the application.
  19277. */
  19278. static get RefractionTextureEnabled(): boolean;
  19279. static set RefractionTextureEnabled(value: boolean);
  19280. /**
  19281. * Are color grading textures enabled in the application.
  19282. */
  19283. static get ColorGradingTextureEnabled(): boolean;
  19284. static set ColorGradingTextureEnabled(value: boolean);
  19285. /**
  19286. * Are fresnels enabled in the application.
  19287. */
  19288. static get FresnelEnabled(): boolean;
  19289. static set FresnelEnabled(value: boolean);
  19290. }
  19291. }
  19292. declare module BABYLON {
  19293. /** @hidden */
  19294. export var rgbdDecodePixelShader: {
  19295. name: string;
  19296. shader: string;
  19297. };
  19298. }
  19299. declare module BABYLON {
  19300. /**
  19301. * Class used to host RGBD texture specific utilities
  19302. */
  19303. export class RGBDTextureTools {
  19304. /**
  19305. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19306. * @param texture the texture to expand.
  19307. */
  19308. static ExpandRGBDTexture(texture: Texture): void;
  19309. }
  19310. }
  19311. declare module BABYLON {
  19312. /**
  19313. * Class used to host texture specific utilities
  19314. */
  19315. export class BRDFTextureTools {
  19316. /**
  19317. * Prevents texture cache collision
  19318. */
  19319. private static _instanceNumber;
  19320. /**
  19321. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19322. * @param scene defines the hosting scene
  19323. * @returns the environment BRDF texture
  19324. */
  19325. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19326. private static _environmentBRDFBase64Texture;
  19327. }
  19328. }
  19329. declare module BABYLON {
  19330. /**
  19331. * @hidden
  19332. */
  19333. export interface IMaterialClearCoatDefines {
  19334. CLEARCOAT: boolean;
  19335. CLEARCOAT_DEFAULTIOR: boolean;
  19336. CLEARCOAT_TEXTURE: boolean;
  19337. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19338. CLEARCOAT_TEXTUREDIRECTUV: number;
  19339. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19340. CLEARCOAT_BUMP: boolean;
  19341. CLEARCOAT_BUMPDIRECTUV: number;
  19342. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19343. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19344. CLEARCOAT_REMAP_F0: boolean;
  19345. CLEARCOAT_TINT: boolean;
  19346. CLEARCOAT_TINT_TEXTURE: boolean;
  19347. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19348. /** @hidden */
  19349. _areTexturesDirty: boolean;
  19350. }
  19351. /**
  19352. * Define the code related to the clear coat parameters of the pbr material.
  19353. */
  19354. export class PBRClearCoatConfiguration {
  19355. /**
  19356. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19357. * The default fits with a polyurethane material.
  19358. * @hidden
  19359. */
  19360. static readonly _DefaultIndexOfRefraction: number;
  19361. private _isEnabled;
  19362. /**
  19363. * Defines if the clear coat is enabled in the material.
  19364. */
  19365. isEnabled: boolean;
  19366. /**
  19367. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19368. */
  19369. intensity: number;
  19370. /**
  19371. * Defines the clear coat layer roughness.
  19372. */
  19373. roughness: number;
  19374. private _indexOfRefraction;
  19375. /**
  19376. * Defines the index of refraction of the clear coat.
  19377. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19378. * The default fits with a polyurethane material.
  19379. * Changing the default value is more performance intensive.
  19380. */
  19381. indexOfRefraction: number;
  19382. private _texture;
  19383. /**
  19384. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  19385. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  19386. * if textureRoughness is not empty, else no texture roughness is used
  19387. */
  19388. texture: Nullable<BaseTexture>;
  19389. private _useRoughnessFromMainTexture;
  19390. /**
  19391. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  19392. * If false, the green channel from textureRoughness is used for roughness
  19393. */
  19394. useRoughnessFromMainTexture: boolean;
  19395. private _textureRoughness;
  19396. /**
  19397. * Stores the clear coat roughness in a texture (green channel)
  19398. * Not used if useRoughnessFromMainTexture is true
  19399. */
  19400. textureRoughness: Nullable<BaseTexture>;
  19401. private _remapF0OnInterfaceChange;
  19402. /**
  19403. * Defines if the F0 value should be remapped to account for the interface change in the material.
  19404. */
  19405. remapF0OnInterfaceChange: boolean;
  19406. private _bumpTexture;
  19407. /**
  19408. * Define the clear coat specific bump texture.
  19409. */
  19410. bumpTexture: Nullable<BaseTexture>;
  19411. private _isTintEnabled;
  19412. /**
  19413. * Defines if the clear coat tint is enabled in the material.
  19414. */
  19415. isTintEnabled: boolean;
  19416. /**
  19417. * Defines the clear coat tint of the material.
  19418. * This is only use if tint is enabled
  19419. */
  19420. tintColor: Color3;
  19421. /**
  19422. * Defines the distance at which the tint color should be found in the
  19423. * clear coat media.
  19424. * This is only use if tint is enabled
  19425. */
  19426. tintColorAtDistance: number;
  19427. /**
  19428. * Defines the clear coat layer thickness.
  19429. * This is only use if tint is enabled
  19430. */
  19431. tintThickness: number;
  19432. private _tintTexture;
  19433. /**
  19434. * Stores the clear tint values in a texture.
  19435. * rgb is tint
  19436. * a is a thickness factor
  19437. */
  19438. tintTexture: Nullable<BaseTexture>;
  19439. /** @hidden */
  19440. private _internalMarkAllSubMeshesAsTexturesDirty;
  19441. /** @hidden */
  19442. _markAllSubMeshesAsTexturesDirty(): void;
  19443. /**
  19444. * Instantiate a new istance of clear coat configuration.
  19445. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19446. */
  19447. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19448. /**
  19449. * Gets wehter the submesh is ready to be used or not.
  19450. * @param defines the list of "defines" to update.
  19451. * @param scene defines the scene the material belongs to.
  19452. * @param engine defines the engine the material belongs to.
  19453. * @param disableBumpMap defines wether the material disables bump or not.
  19454. * @returns - boolean indicating that the submesh is ready or not.
  19455. */
  19456. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  19457. /**
  19458. * Checks to see if a texture is used in the material.
  19459. * @param defines the list of "defines" to update.
  19460. * @param scene defines the scene to the material belongs to.
  19461. */
  19462. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  19463. /**
  19464. * Binds the material data.
  19465. * @param uniformBuffer defines the Uniform buffer to fill in.
  19466. * @param scene defines the scene the material belongs to.
  19467. * @param engine defines the engine the material belongs to.
  19468. * @param disableBumpMap defines wether the material disables bump or not.
  19469. * @param isFrozen defines wether the material is frozen or not.
  19470. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  19471. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  19472. * @param subMesh the submesh to bind data for
  19473. */
  19474. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  19475. /**
  19476. * Checks to see if a texture is used in the material.
  19477. * @param texture - Base texture to use.
  19478. * @returns - Boolean specifying if a texture is used in the material.
  19479. */
  19480. hasTexture(texture: BaseTexture): boolean;
  19481. /**
  19482. * Returns an array of the actively used textures.
  19483. * @param activeTextures Array of BaseTextures
  19484. */
  19485. getActiveTextures(activeTextures: BaseTexture[]): void;
  19486. /**
  19487. * Returns the animatable textures.
  19488. * @param animatables Array of animatable textures.
  19489. */
  19490. getAnimatables(animatables: IAnimatable[]): void;
  19491. /**
  19492. * Disposes the resources of the material.
  19493. * @param forceDisposeTextures - Forces the disposal of all textures.
  19494. */
  19495. dispose(forceDisposeTextures?: boolean): void;
  19496. /**
  19497. * Get the current class name of the texture useful for serialization or dynamic coding.
  19498. * @returns "PBRClearCoatConfiguration"
  19499. */
  19500. getClassName(): string;
  19501. /**
  19502. * Add fallbacks to the effect fallbacks list.
  19503. * @param defines defines the Base texture to use.
  19504. * @param fallbacks defines the current fallback list.
  19505. * @param currentRank defines the current fallback rank.
  19506. * @returns the new fallback rank.
  19507. */
  19508. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19509. /**
  19510. * Add the required uniforms to the current list.
  19511. * @param uniforms defines the current uniform list.
  19512. */
  19513. static AddUniforms(uniforms: string[]): void;
  19514. /**
  19515. * Add the required samplers to the current list.
  19516. * @param samplers defines the current sampler list.
  19517. */
  19518. static AddSamplers(samplers: string[]): void;
  19519. /**
  19520. * Add the required uniforms to the current buffer.
  19521. * @param uniformBuffer defines the current uniform buffer.
  19522. */
  19523. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19524. /**
  19525. * Makes a duplicate of the current configuration into another one.
  19526. * @param clearCoatConfiguration define the config where to copy the info
  19527. */
  19528. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  19529. /**
  19530. * Serializes this clear coat configuration.
  19531. * @returns - An object with the serialized config.
  19532. */
  19533. serialize(): any;
  19534. /**
  19535. * Parses a anisotropy Configuration from a serialized object.
  19536. * @param source - Serialized object.
  19537. * @param scene Defines the scene we are parsing for
  19538. * @param rootUrl Defines the rootUrl to load from
  19539. */
  19540. parse(source: any, scene: Scene, rootUrl: string): void;
  19541. }
  19542. }
  19543. declare module BABYLON {
  19544. /**
  19545. * @hidden
  19546. */
  19547. export interface IMaterialAnisotropicDefines {
  19548. ANISOTROPIC: boolean;
  19549. ANISOTROPIC_TEXTURE: boolean;
  19550. ANISOTROPIC_TEXTUREDIRECTUV: number;
  19551. MAINUV1: boolean;
  19552. _areTexturesDirty: boolean;
  19553. _needUVs: boolean;
  19554. }
  19555. /**
  19556. * Define the code related to the anisotropic parameters of the pbr material.
  19557. */
  19558. export class PBRAnisotropicConfiguration {
  19559. private _isEnabled;
  19560. /**
  19561. * Defines if the anisotropy is enabled in the material.
  19562. */
  19563. isEnabled: boolean;
  19564. /**
  19565. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  19566. */
  19567. intensity: number;
  19568. /**
  19569. * Defines if the effect is along the tangents, bitangents or in between.
  19570. * By default, the effect is "strectching" the highlights along the tangents.
  19571. */
  19572. direction: Vector2;
  19573. private _texture;
  19574. /**
  19575. * Stores the anisotropy values in a texture.
  19576. * rg is direction (like normal from -1 to 1)
  19577. * b is a intensity
  19578. */
  19579. texture: Nullable<BaseTexture>;
  19580. /** @hidden */
  19581. private _internalMarkAllSubMeshesAsTexturesDirty;
  19582. /** @hidden */
  19583. _markAllSubMeshesAsTexturesDirty(): void;
  19584. /**
  19585. * Instantiate a new istance of anisotropy configuration.
  19586. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19587. */
  19588. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19589. /**
  19590. * Specifies that the submesh is ready to be used.
  19591. * @param defines the list of "defines" to update.
  19592. * @param scene defines the scene the material belongs to.
  19593. * @returns - boolean indicating that the submesh is ready or not.
  19594. */
  19595. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  19596. /**
  19597. * Checks to see if a texture is used in the material.
  19598. * @param defines the list of "defines" to update.
  19599. * @param mesh the mesh we are preparing the defines for.
  19600. * @param scene defines the scene the material belongs to.
  19601. */
  19602. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  19603. /**
  19604. * Binds the material data.
  19605. * @param uniformBuffer defines the Uniform buffer to fill in.
  19606. * @param scene defines the scene the material belongs to.
  19607. * @param isFrozen defines wether the material is frozen or not.
  19608. */
  19609. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19610. /**
  19611. * Checks to see if a texture is used in the material.
  19612. * @param texture - Base texture to use.
  19613. * @returns - Boolean specifying if a texture is used in the material.
  19614. */
  19615. hasTexture(texture: BaseTexture): boolean;
  19616. /**
  19617. * Returns an array of the actively used textures.
  19618. * @param activeTextures Array of BaseTextures
  19619. */
  19620. getActiveTextures(activeTextures: BaseTexture[]): void;
  19621. /**
  19622. * Returns the animatable textures.
  19623. * @param animatables Array of animatable textures.
  19624. */
  19625. getAnimatables(animatables: IAnimatable[]): void;
  19626. /**
  19627. * Disposes the resources of the material.
  19628. * @param forceDisposeTextures - Forces the disposal of all textures.
  19629. */
  19630. dispose(forceDisposeTextures?: boolean): void;
  19631. /**
  19632. * Get the current class name of the texture useful for serialization or dynamic coding.
  19633. * @returns "PBRAnisotropicConfiguration"
  19634. */
  19635. getClassName(): string;
  19636. /**
  19637. * Add fallbacks to the effect fallbacks list.
  19638. * @param defines defines the Base texture to use.
  19639. * @param fallbacks defines the current fallback list.
  19640. * @param currentRank defines the current fallback rank.
  19641. * @returns the new fallback rank.
  19642. */
  19643. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19644. /**
  19645. * Add the required uniforms to the current list.
  19646. * @param uniforms defines the current uniform list.
  19647. */
  19648. static AddUniforms(uniforms: string[]): void;
  19649. /**
  19650. * Add the required uniforms to the current buffer.
  19651. * @param uniformBuffer defines the current uniform buffer.
  19652. */
  19653. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19654. /**
  19655. * Add the required samplers to the current list.
  19656. * @param samplers defines the current sampler list.
  19657. */
  19658. static AddSamplers(samplers: string[]): void;
  19659. /**
  19660. * Makes a duplicate of the current configuration into another one.
  19661. * @param anisotropicConfiguration define the config where to copy the info
  19662. */
  19663. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  19664. /**
  19665. * Serializes this anisotropy configuration.
  19666. * @returns - An object with the serialized config.
  19667. */
  19668. serialize(): any;
  19669. /**
  19670. * Parses a anisotropy Configuration from a serialized object.
  19671. * @param source - Serialized object.
  19672. * @param scene Defines the scene we are parsing for
  19673. * @param rootUrl Defines the rootUrl to load from
  19674. */
  19675. parse(source: any, scene: Scene, rootUrl: string): void;
  19676. }
  19677. }
  19678. declare module BABYLON {
  19679. /**
  19680. * @hidden
  19681. */
  19682. export interface IMaterialBRDFDefines {
  19683. BRDF_V_HEIGHT_CORRELATED: boolean;
  19684. MS_BRDF_ENERGY_CONSERVATION: boolean;
  19685. SPHERICAL_HARMONICS: boolean;
  19686. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  19687. /** @hidden */
  19688. _areMiscDirty: boolean;
  19689. }
  19690. /**
  19691. * Define the code related to the BRDF parameters of the pbr material.
  19692. */
  19693. export class PBRBRDFConfiguration {
  19694. /**
  19695. * Default value used for the energy conservation.
  19696. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19697. */
  19698. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  19699. /**
  19700. * Default value used for the Smith Visibility Height Correlated mode.
  19701. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19702. */
  19703. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  19704. /**
  19705. * Default value used for the IBL diffuse part.
  19706. * This can help switching back to the polynomials mode globally which is a tiny bit
  19707. * less GPU intensive at the drawback of a lower quality.
  19708. */
  19709. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  19710. /**
  19711. * Default value used for activating energy conservation for the specular workflow.
  19712. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19713. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19714. */
  19715. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  19716. private _useEnergyConservation;
  19717. /**
  19718. * Defines if the material uses energy conservation.
  19719. */
  19720. useEnergyConservation: boolean;
  19721. private _useSmithVisibilityHeightCorrelated;
  19722. /**
  19723. * LEGACY Mode set to false
  19724. * Defines if the material uses height smith correlated visibility term.
  19725. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  19726. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  19727. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  19728. * Not relying on height correlated will also disable energy conservation.
  19729. */
  19730. useSmithVisibilityHeightCorrelated: boolean;
  19731. private _useSphericalHarmonics;
  19732. /**
  19733. * LEGACY Mode set to false
  19734. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  19735. * diffuse part of the IBL.
  19736. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  19737. * to the ground truth.
  19738. */
  19739. useSphericalHarmonics: boolean;
  19740. private _useSpecularGlossinessInputEnergyConservation;
  19741. /**
  19742. * Defines if the material uses energy conservation, when the specular workflow is active.
  19743. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19744. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19745. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  19746. */
  19747. useSpecularGlossinessInputEnergyConservation: boolean;
  19748. /** @hidden */
  19749. private _internalMarkAllSubMeshesAsMiscDirty;
  19750. /** @hidden */
  19751. _markAllSubMeshesAsMiscDirty(): void;
  19752. /**
  19753. * Instantiate a new istance of clear coat configuration.
  19754. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  19755. */
  19756. constructor(markAllSubMeshesAsMiscDirty: () => void);
  19757. /**
  19758. * Checks to see if a texture is used in the material.
  19759. * @param defines the list of "defines" to update.
  19760. */
  19761. prepareDefines(defines: IMaterialBRDFDefines): void;
  19762. /**
  19763. * Get the current class name of the texture useful for serialization or dynamic coding.
  19764. * @returns "PBRClearCoatConfiguration"
  19765. */
  19766. getClassName(): string;
  19767. /**
  19768. * Makes a duplicate of the current configuration into another one.
  19769. * @param brdfConfiguration define the config where to copy the info
  19770. */
  19771. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  19772. /**
  19773. * Serializes this BRDF configuration.
  19774. * @returns - An object with the serialized config.
  19775. */
  19776. serialize(): any;
  19777. /**
  19778. * Parses a anisotropy Configuration from a serialized object.
  19779. * @param source - Serialized object.
  19780. * @param scene Defines the scene we are parsing for
  19781. * @param rootUrl Defines the rootUrl to load from
  19782. */
  19783. parse(source: any, scene: Scene, rootUrl: string): void;
  19784. }
  19785. }
  19786. declare module BABYLON {
  19787. /**
  19788. * @hidden
  19789. */
  19790. export interface IMaterialSheenDefines {
  19791. SHEEN: boolean;
  19792. SHEEN_TEXTURE: boolean;
  19793. SHEEN_TEXTURE_ROUGHNESS: boolean;
  19794. SHEEN_TEXTUREDIRECTUV: number;
  19795. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  19796. SHEEN_LINKWITHALBEDO: boolean;
  19797. SHEEN_ROUGHNESS: boolean;
  19798. SHEEN_ALBEDOSCALING: boolean;
  19799. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19800. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19801. /** @hidden */
  19802. _areTexturesDirty: boolean;
  19803. }
  19804. /**
  19805. * Define the code related to the Sheen parameters of the pbr material.
  19806. */
  19807. export class PBRSheenConfiguration {
  19808. private _isEnabled;
  19809. /**
  19810. * Defines if the material uses sheen.
  19811. */
  19812. isEnabled: boolean;
  19813. private _linkSheenWithAlbedo;
  19814. /**
  19815. * Defines if the sheen is linked to the sheen color.
  19816. */
  19817. linkSheenWithAlbedo: boolean;
  19818. /**
  19819. * Defines the sheen intensity.
  19820. */
  19821. intensity: number;
  19822. /**
  19823. * Defines the sheen color.
  19824. */
  19825. color: Color3;
  19826. private _texture;
  19827. /**
  19828. * Stores the sheen tint values in a texture.
  19829. * rgb is tint
  19830. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  19831. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  19832. */
  19833. texture: Nullable<BaseTexture>;
  19834. private _useRoughnessFromMainTexture;
  19835. /**
  19836. * Indicates that the alpha channel of the texture property will be used for roughness.
  19837. * Has no effect if the roughness (and texture!) property is not defined
  19838. */
  19839. useRoughnessFromMainTexture: boolean;
  19840. private _roughness;
  19841. /**
  19842. * Defines the sheen roughness.
  19843. * It is not taken into account if linkSheenWithAlbedo is true.
  19844. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  19845. */
  19846. roughness: Nullable<number>;
  19847. private _textureRoughness;
  19848. /**
  19849. * Stores the sheen roughness in a texture.
  19850. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  19851. */
  19852. textureRoughness: Nullable<BaseTexture>;
  19853. private _albedoScaling;
  19854. /**
  19855. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  19856. * It allows the strength of the sheen effect to not depend on the base color of the material,
  19857. * making it easier to setup and tweak the effect
  19858. */
  19859. albedoScaling: boolean;
  19860. /** @hidden */
  19861. private _internalMarkAllSubMeshesAsTexturesDirty;
  19862. /** @hidden */
  19863. _markAllSubMeshesAsTexturesDirty(): void;
  19864. /**
  19865. * Instantiate a new istance of clear coat configuration.
  19866. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19867. */
  19868. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19869. /**
  19870. * Specifies that the submesh is ready to be used.
  19871. * @param defines the list of "defines" to update.
  19872. * @param scene defines the scene the material belongs to.
  19873. * @returns - boolean indicating that the submesh is ready or not.
  19874. */
  19875. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  19876. /**
  19877. * Checks to see if a texture is used in the material.
  19878. * @param defines the list of "defines" to update.
  19879. * @param scene defines the scene the material belongs to.
  19880. */
  19881. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  19882. /**
  19883. * Binds the material data.
  19884. * @param uniformBuffer defines the Uniform buffer to fill in.
  19885. * @param scene defines the scene the material belongs to.
  19886. * @param isFrozen defines wether the material is frozen or not.
  19887. * @param subMesh the submesh to bind data for
  19888. */
  19889. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  19890. /**
  19891. * Checks to see if a texture is used in the material.
  19892. * @param texture - Base texture to use.
  19893. * @returns - Boolean specifying if a texture is used in the material.
  19894. */
  19895. hasTexture(texture: BaseTexture): boolean;
  19896. /**
  19897. * Returns an array of the actively used textures.
  19898. * @param activeTextures Array of BaseTextures
  19899. */
  19900. getActiveTextures(activeTextures: BaseTexture[]): void;
  19901. /**
  19902. * Returns the animatable textures.
  19903. * @param animatables Array of animatable textures.
  19904. */
  19905. getAnimatables(animatables: IAnimatable[]): void;
  19906. /**
  19907. * Disposes the resources of the material.
  19908. * @param forceDisposeTextures - Forces the disposal of all textures.
  19909. */
  19910. dispose(forceDisposeTextures?: boolean): void;
  19911. /**
  19912. * Get the current class name of the texture useful for serialization or dynamic coding.
  19913. * @returns "PBRSheenConfiguration"
  19914. */
  19915. getClassName(): string;
  19916. /**
  19917. * Add fallbacks to the effect fallbacks list.
  19918. * @param defines defines the Base texture to use.
  19919. * @param fallbacks defines the current fallback list.
  19920. * @param currentRank defines the current fallback rank.
  19921. * @returns the new fallback rank.
  19922. */
  19923. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19924. /**
  19925. * Add the required uniforms to the current list.
  19926. * @param uniforms defines the current uniform list.
  19927. */
  19928. static AddUniforms(uniforms: string[]): void;
  19929. /**
  19930. * Add the required uniforms to the current buffer.
  19931. * @param uniformBuffer defines the current uniform buffer.
  19932. */
  19933. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19934. /**
  19935. * Add the required samplers to the current list.
  19936. * @param samplers defines the current sampler list.
  19937. */
  19938. static AddSamplers(samplers: string[]): void;
  19939. /**
  19940. * Makes a duplicate of the current configuration into another one.
  19941. * @param sheenConfiguration define the config where to copy the info
  19942. */
  19943. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  19944. /**
  19945. * Serializes this BRDF configuration.
  19946. * @returns - An object with the serialized config.
  19947. */
  19948. serialize(): any;
  19949. /**
  19950. * Parses a anisotropy Configuration from a serialized object.
  19951. * @param source - Serialized object.
  19952. * @param scene Defines the scene we are parsing for
  19953. * @param rootUrl Defines the rootUrl to load from
  19954. */
  19955. parse(source: any, scene: Scene, rootUrl: string): void;
  19956. }
  19957. }
  19958. declare module BABYLON {
  19959. /**
  19960. * @hidden
  19961. */
  19962. export interface IMaterialSubSurfaceDefines {
  19963. SUBSURFACE: boolean;
  19964. SS_REFRACTION: boolean;
  19965. SS_TRANSLUCENCY: boolean;
  19966. SS_SCATTERING: boolean;
  19967. SS_THICKNESSANDMASK_TEXTURE: boolean;
  19968. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  19969. SS_REFRACTIONMAP_3D: boolean;
  19970. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  19971. SS_LODINREFRACTIONALPHA: boolean;
  19972. SS_GAMMAREFRACTION: boolean;
  19973. SS_RGBDREFRACTION: boolean;
  19974. SS_LINEARSPECULARREFRACTION: boolean;
  19975. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  19976. SS_ALBEDOFORREFRACTIONTINT: boolean;
  19977. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  19978. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  19979. /** @hidden */
  19980. _areTexturesDirty: boolean;
  19981. }
  19982. /**
  19983. * Define the code related to the sub surface parameters of the pbr material.
  19984. */
  19985. export class PBRSubSurfaceConfiguration {
  19986. private _isRefractionEnabled;
  19987. /**
  19988. * Defines if the refraction is enabled in the material.
  19989. */
  19990. isRefractionEnabled: boolean;
  19991. private _isTranslucencyEnabled;
  19992. /**
  19993. * Defines if the translucency is enabled in the material.
  19994. */
  19995. isTranslucencyEnabled: boolean;
  19996. private _isScatteringEnabled;
  19997. /**
  19998. * Defines if the sub surface scattering is enabled in the material.
  19999. */
  20000. isScatteringEnabled: boolean;
  20001. private _scatteringDiffusionProfileIndex;
  20002. /**
  20003. * Diffusion profile for subsurface scattering.
  20004. * Useful for better scattering in the skins or foliages.
  20005. */
  20006. get scatteringDiffusionProfile(): Nullable<Color3>;
  20007. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20008. /**
  20009. * Defines the refraction intensity of the material.
  20010. * The refraction when enabled replaces the Diffuse part of the material.
  20011. * The intensity helps transitionning between diffuse and refraction.
  20012. */
  20013. refractionIntensity: number;
  20014. /**
  20015. * Defines the translucency intensity of the material.
  20016. * When translucency has been enabled, this defines how much of the "translucency"
  20017. * is addded to the diffuse part of the material.
  20018. */
  20019. translucencyIntensity: number;
  20020. /**
  20021. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20022. */
  20023. useAlbedoToTintRefraction: boolean;
  20024. private _thicknessTexture;
  20025. /**
  20026. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20027. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20028. * 0 would mean minimumThickness
  20029. * 1 would mean maximumThickness
  20030. * The other channels might be use as a mask to vary the different effects intensity.
  20031. */
  20032. thicknessTexture: Nullable<BaseTexture>;
  20033. private _refractionTexture;
  20034. /**
  20035. * Defines the texture to use for refraction.
  20036. */
  20037. refractionTexture: Nullable<BaseTexture>;
  20038. private _indexOfRefraction;
  20039. /**
  20040. * Index of refraction of the material base layer.
  20041. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20042. *
  20043. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20044. *
  20045. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20046. */
  20047. indexOfRefraction: number;
  20048. private _volumeIndexOfRefraction;
  20049. /**
  20050. * Index of refraction of the material's volume.
  20051. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20052. *
  20053. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20054. * the volume will use the same IOR as the surface.
  20055. */
  20056. get volumeIndexOfRefraction(): number;
  20057. set volumeIndexOfRefraction(value: number);
  20058. private _invertRefractionY;
  20059. /**
  20060. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20061. */
  20062. invertRefractionY: boolean;
  20063. private _linkRefractionWithTransparency;
  20064. /**
  20065. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20066. * Materials half opaque for instance using refraction could benefit from this control.
  20067. */
  20068. linkRefractionWithTransparency: boolean;
  20069. /**
  20070. * Defines the minimum thickness stored in the thickness map.
  20071. * If no thickness map is defined, this value will be used to simulate thickness.
  20072. */
  20073. minimumThickness: number;
  20074. /**
  20075. * Defines the maximum thickness stored in the thickness map.
  20076. */
  20077. maximumThickness: number;
  20078. /**
  20079. * Defines the volume tint of the material.
  20080. * This is used for both translucency and scattering.
  20081. */
  20082. tintColor: Color3;
  20083. /**
  20084. * Defines the distance at which the tint color should be found in the media.
  20085. * This is used for refraction only.
  20086. */
  20087. tintColorAtDistance: number;
  20088. /**
  20089. * Defines how far each channel transmit through the media.
  20090. * It is defined as a color to simplify it selection.
  20091. */
  20092. diffusionDistance: Color3;
  20093. private _useMaskFromThicknessTexture;
  20094. /**
  20095. * Stores the intensity of the different subsurface effects in the thickness texture.
  20096. * * the green channel is the translucency intensity.
  20097. * * the blue channel is the scattering intensity.
  20098. * * the alpha channel is the refraction intensity.
  20099. */
  20100. useMaskFromThicknessTexture: boolean;
  20101. private _scene;
  20102. private _useMaskFromThicknessTextureGltf;
  20103. /**
  20104. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20105. * matches the channel-packing that is used by glTF.
  20106. * * the red channel is the transmission/translucency intensity.
  20107. * * the green channel is the thickness.
  20108. */
  20109. useMaskFromThicknessTextureGltf: boolean;
  20110. /** @hidden */
  20111. private _internalMarkAllSubMeshesAsTexturesDirty;
  20112. private _internalMarkScenePrePassDirty;
  20113. /** @hidden */
  20114. _markAllSubMeshesAsTexturesDirty(): void;
  20115. /** @hidden */
  20116. _markScenePrePassDirty(): void;
  20117. /**
  20118. * Instantiate a new istance of sub surface configuration.
  20119. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20120. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20121. * @param scene The scene
  20122. */
  20123. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20124. /**
  20125. * Gets wehter the submesh is ready to be used or not.
  20126. * @param defines the list of "defines" to update.
  20127. * @param scene defines the scene the material belongs to.
  20128. * @returns - boolean indicating that the submesh is ready or not.
  20129. */
  20130. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20131. /**
  20132. * Checks to see if a texture is used in the material.
  20133. * @param defines the list of "defines" to update.
  20134. * @param scene defines the scene to the material belongs to.
  20135. */
  20136. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20137. /**
  20138. * Binds the material data.
  20139. * @param uniformBuffer defines the Uniform buffer to fill in.
  20140. * @param scene defines the scene the material belongs to.
  20141. * @param engine defines the engine the material belongs to.
  20142. * @param isFrozen defines whether the material is frozen or not.
  20143. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20144. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20145. */
  20146. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20147. /**
  20148. * Unbinds the material from the mesh.
  20149. * @param activeEffect defines the effect that should be unbound from.
  20150. * @returns true if unbound, otherwise false
  20151. */
  20152. unbind(activeEffect: Effect): boolean;
  20153. /**
  20154. * Returns the texture used for refraction or null if none is used.
  20155. * @param scene defines the scene the material belongs to.
  20156. * @returns - Refraction texture if present. If no refraction texture and refraction
  20157. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20158. */
  20159. private _getRefractionTexture;
  20160. /**
  20161. * Returns true if alpha blending should be disabled.
  20162. */
  20163. get disableAlphaBlending(): boolean;
  20164. /**
  20165. * Fills the list of render target textures.
  20166. * @param renderTargets the list of render targets to update
  20167. */
  20168. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20169. /**
  20170. * Checks to see if a texture is used in the material.
  20171. * @param texture - Base texture to use.
  20172. * @returns - Boolean specifying if a texture is used in the material.
  20173. */
  20174. hasTexture(texture: BaseTexture): boolean;
  20175. /**
  20176. * Gets a boolean indicating that current material needs to register RTT
  20177. * @returns true if this uses a render target otherwise false.
  20178. */
  20179. hasRenderTargetTextures(): boolean;
  20180. /**
  20181. * Returns an array of the actively used textures.
  20182. * @param activeTextures Array of BaseTextures
  20183. */
  20184. getActiveTextures(activeTextures: BaseTexture[]): void;
  20185. /**
  20186. * Returns the animatable textures.
  20187. * @param animatables Array of animatable textures.
  20188. */
  20189. getAnimatables(animatables: IAnimatable[]): void;
  20190. /**
  20191. * Disposes the resources of the material.
  20192. * @param forceDisposeTextures - Forces the disposal of all textures.
  20193. */
  20194. dispose(forceDisposeTextures?: boolean): void;
  20195. /**
  20196. * Get the current class name of the texture useful for serialization or dynamic coding.
  20197. * @returns "PBRSubSurfaceConfiguration"
  20198. */
  20199. getClassName(): string;
  20200. /**
  20201. * Add fallbacks to the effect fallbacks list.
  20202. * @param defines defines the Base texture to use.
  20203. * @param fallbacks defines the current fallback list.
  20204. * @param currentRank defines the current fallback rank.
  20205. * @returns the new fallback rank.
  20206. */
  20207. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20208. /**
  20209. * Add the required uniforms to the current list.
  20210. * @param uniforms defines the current uniform list.
  20211. */
  20212. static AddUniforms(uniforms: string[]): void;
  20213. /**
  20214. * Add the required samplers to the current list.
  20215. * @param samplers defines the current sampler list.
  20216. */
  20217. static AddSamplers(samplers: string[]): void;
  20218. /**
  20219. * Add the required uniforms to the current buffer.
  20220. * @param uniformBuffer defines the current uniform buffer.
  20221. */
  20222. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20223. /**
  20224. * Makes a duplicate of the current configuration into another one.
  20225. * @param configuration define the config where to copy the info
  20226. */
  20227. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20228. /**
  20229. * Serializes this Sub Surface configuration.
  20230. * @returns - An object with the serialized config.
  20231. */
  20232. serialize(): any;
  20233. /**
  20234. * Parses a anisotropy Configuration from a serialized object.
  20235. * @param source - Serialized object.
  20236. * @param scene Defines the scene we are parsing for
  20237. * @param rootUrl Defines the rootUrl to load from
  20238. */
  20239. parse(source: any, scene: Scene, rootUrl: string): void;
  20240. }
  20241. }
  20242. declare module BABYLON {
  20243. /**
  20244. * Class representing spherical harmonics coefficients to the 3rd degree
  20245. */
  20246. export class SphericalHarmonics {
  20247. /**
  20248. * Defines whether or not the harmonics have been prescaled for rendering.
  20249. */
  20250. preScaled: boolean;
  20251. /**
  20252. * The l0,0 coefficients of the spherical harmonics
  20253. */
  20254. l00: Vector3;
  20255. /**
  20256. * The l1,-1 coefficients of the spherical harmonics
  20257. */
  20258. l1_1: Vector3;
  20259. /**
  20260. * The l1,0 coefficients of the spherical harmonics
  20261. */
  20262. l10: Vector3;
  20263. /**
  20264. * The l1,1 coefficients of the spherical harmonics
  20265. */
  20266. l11: Vector3;
  20267. /**
  20268. * The l2,-2 coefficients of the spherical harmonics
  20269. */
  20270. l2_2: Vector3;
  20271. /**
  20272. * The l2,-1 coefficients of the spherical harmonics
  20273. */
  20274. l2_1: Vector3;
  20275. /**
  20276. * The l2,0 coefficients of the spherical harmonics
  20277. */
  20278. l20: Vector3;
  20279. /**
  20280. * The l2,1 coefficients of the spherical harmonics
  20281. */
  20282. l21: Vector3;
  20283. /**
  20284. * The l2,2 coefficients of the spherical harmonics
  20285. */
  20286. l22: Vector3;
  20287. /**
  20288. * Adds a light to the spherical harmonics
  20289. * @param direction the direction of the light
  20290. * @param color the color of the light
  20291. * @param deltaSolidAngle the delta solid angle of the light
  20292. */
  20293. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20294. /**
  20295. * Scales the spherical harmonics by the given amount
  20296. * @param scale the amount to scale
  20297. */
  20298. scaleInPlace(scale: number): void;
  20299. /**
  20300. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20301. *
  20302. * ```
  20303. * E_lm = A_l * L_lm
  20304. * ```
  20305. *
  20306. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20307. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20308. * the scaling factors are given in equation 9.
  20309. */
  20310. convertIncidentRadianceToIrradiance(): void;
  20311. /**
  20312. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20313. *
  20314. * ```
  20315. * L = (1/pi) * E * rho
  20316. * ```
  20317. *
  20318. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20319. */
  20320. convertIrradianceToLambertianRadiance(): void;
  20321. /**
  20322. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20323. * required operations at run time.
  20324. *
  20325. * This is simply done by scaling back the SH with Ylm constants parameter.
  20326. * The trigonometric part being applied by the shader at run time.
  20327. */
  20328. preScaleForRendering(): void;
  20329. /**
  20330. * Constructs a spherical harmonics from an array.
  20331. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20332. * @returns the spherical harmonics
  20333. */
  20334. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20335. /**
  20336. * Gets the spherical harmonics from polynomial
  20337. * @param polynomial the spherical polynomial
  20338. * @returns the spherical harmonics
  20339. */
  20340. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20341. }
  20342. /**
  20343. * Class representing spherical polynomial coefficients to the 3rd degree
  20344. */
  20345. export class SphericalPolynomial {
  20346. private _harmonics;
  20347. /**
  20348. * The spherical harmonics used to create the polynomials.
  20349. */
  20350. get preScaledHarmonics(): SphericalHarmonics;
  20351. /**
  20352. * The x coefficients of the spherical polynomial
  20353. */
  20354. x: Vector3;
  20355. /**
  20356. * The y coefficients of the spherical polynomial
  20357. */
  20358. y: Vector3;
  20359. /**
  20360. * The z coefficients of the spherical polynomial
  20361. */
  20362. z: Vector3;
  20363. /**
  20364. * The xx coefficients of the spherical polynomial
  20365. */
  20366. xx: Vector3;
  20367. /**
  20368. * The yy coefficients of the spherical polynomial
  20369. */
  20370. yy: Vector3;
  20371. /**
  20372. * The zz coefficients of the spherical polynomial
  20373. */
  20374. zz: Vector3;
  20375. /**
  20376. * The xy coefficients of the spherical polynomial
  20377. */
  20378. xy: Vector3;
  20379. /**
  20380. * The yz coefficients of the spherical polynomial
  20381. */
  20382. yz: Vector3;
  20383. /**
  20384. * The zx coefficients of the spherical polynomial
  20385. */
  20386. zx: Vector3;
  20387. /**
  20388. * Adds an ambient color to the spherical polynomial
  20389. * @param color the color to add
  20390. */
  20391. addAmbient(color: Color3): void;
  20392. /**
  20393. * Scales the spherical polynomial by the given amount
  20394. * @param scale the amount to scale
  20395. */
  20396. scaleInPlace(scale: number): void;
  20397. /**
  20398. * Gets the spherical polynomial from harmonics
  20399. * @param harmonics the spherical harmonics
  20400. * @returns the spherical polynomial
  20401. */
  20402. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  20403. /**
  20404. * Constructs a spherical polynomial from an array.
  20405. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  20406. * @returns the spherical polynomial
  20407. */
  20408. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  20409. }
  20410. }
  20411. declare module BABYLON {
  20412. /**
  20413. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  20414. */
  20415. export interface CubeMapInfo {
  20416. /**
  20417. * The pixel array for the front face.
  20418. * This is stored in format, left to right, up to down format.
  20419. */
  20420. front: Nullable<ArrayBufferView>;
  20421. /**
  20422. * The pixel array for the back face.
  20423. * This is stored in format, left to right, up to down format.
  20424. */
  20425. back: Nullable<ArrayBufferView>;
  20426. /**
  20427. * The pixel array for the left face.
  20428. * This is stored in format, left to right, up to down format.
  20429. */
  20430. left: Nullable<ArrayBufferView>;
  20431. /**
  20432. * The pixel array for the right face.
  20433. * This is stored in format, left to right, up to down format.
  20434. */
  20435. right: Nullable<ArrayBufferView>;
  20436. /**
  20437. * The pixel array for the up face.
  20438. * This is stored in format, left to right, up to down format.
  20439. */
  20440. up: Nullable<ArrayBufferView>;
  20441. /**
  20442. * The pixel array for the down face.
  20443. * This is stored in format, left to right, up to down format.
  20444. */
  20445. down: Nullable<ArrayBufferView>;
  20446. /**
  20447. * The size of the cubemap stored.
  20448. *
  20449. * Each faces will be size * size pixels.
  20450. */
  20451. size: number;
  20452. /**
  20453. * The format of the texture.
  20454. *
  20455. * RGBA, RGB.
  20456. */
  20457. format: number;
  20458. /**
  20459. * The type of the texture data.
  20460. *
  20461. * UNSIGNED_INT, FLOAT.
  20462. */
  20463. type: number;
  20464. /**
  20465. * Specifies whether the texture is in gamma space.
  20466. */
  20467. gammaSpace: boolean;
  20468. }
  20469. /**
  20470. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  20471. */
  20472. export class PanoramaToCubeMapTools {
  20473. private static FACE_LEFT;
  20474. private static FACE_RIGHT;
  20475. private static FACE_FRONT;
  20476. private static FACE_BACK;
  20477. private static FACE_DOWN;
  20478. private static FACE_UP;
  20479. /**
  20480. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  20481. *
  20482. * @param float32Array The source data.
  20483. * @param inputWidth The width of the input panorama.
  20484. * @param inputHeight The height of the input panorama.
  20485. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  20486. * @return The cubemap data
  20487. */
  20488. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  20489. private static CreateCubemapTexture;
  20490. private static CalcProjectionSpherical;
  20491. }
  20492. }
  20493. declare module BABYLON {
  20494. /**
  20495. * Helper class dealing with the extraction of spherical polynomial dataArray
  20496. * from a cube map.
  20497. */
  20498. export class CubeMapToSphericalPolynomialTools {
  20499. private static FileFaces;
  20500. /**
  20501. * Converts a texture to the according Spherical Polynomial data.
  20502. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20503. *
  20504. * @param texture The texture to extract the information from.
  20505. * @return The Spherical Polynomial data.
  20506. */
  20507. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  20508. /**
  20509. * Converts a cubemap to the according Spherical Polynomial data.
  20510. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20511. *
  20512. * @param cubeInfo The Cube map to extract the information from.
  20513. * @return The Spherical Polynomial data.
  20514. */
  20515. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  20516. }
  20517. }
  20518. declare module BABYLON {
  20519. interface BaseTexture {
  20520. /**
  20521. * Get the polynomial representation of the texture data.
  20522. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  20523. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  20524. */
  20525. sphericalPolynomial: Nullable<SphericalPolynomial>;
  20526. }
  20527. }
  20528. declare module BABYLON {
  20529. /** @hidden */
  20530. export var pbrFragmentDeclaration: {
  20531. name: string;
  20532. shader: string;
  20533. };
  20534. }
  20535. declare module BABYLON {
  20536. /** @hidden */
  20537. export var pbrUboDeclaration: {
  20538. name: string;
  20539. shader: string;
  20540. };
  20541. }
  20542. declare module BABYLON {
  20543. /** @hidden */
  20544. export var pbrFragmentExtraDeclaration: {
  20545. name: string;
  20546. shader: string;
  20547. };
  20548. }
  20549. declare module BABYLON {
  20550. /** @hidden */
  20551. export var pbrFragmentSamplersDeclaration: {
  20552. name: string;
  20553. shader: string;
  20554. };
  20555. }
  20556. declare module BABYLON {
  20557. /** @hidden */
  20558. export var subSurfaceScatteringFunctions: {
  20559. name: string;
  20560. shader: string;
  20561. };
  20562. }
  20563. declare module BABYLON {
  20564. /** @hidden */
  20565. export var importanceSampling: {
  20566. name: string;
  20567. shader: string;
  20568. };
  20569. }
  20570. declare module BABYLON {
  20571. /** @hidden */
  20572. export var pbrHelperFunctions: {
  20573. name: string;
  20574. shader: string;
  20575. };
  20576. }
  20577. declare module BABYLON {
  20578. /** @hidden */
  20579. export var harmonicsFunctions: {
  20580. name: string;
  20581. shader: string;
  20582. };
  20583. }
  20584. declare module BABYLON {
  20585. /** @hidden */
  20586. export var pbrDirectLightingSetupFunctions: {
  20587. name: string;
  20588. shader: string;
  20589. };
  20590. }
  20591. declare module BABYLON {
  20592. /** @hidden */
  20593. export var pbrDirectLightingFalloffFunctions: {
  20594. name: string;
  20595. shader: string;
  20596. };
  20597. }
  20598. declare module BABYLON {
  20599. /** @hidden */
  20600. export var pbrBRDFFunctions: {
  20601. name: string;
  20602. shader: string;
  20603. };
  20604. }
  20605. declare module BABYLON {
  20606. /** @hidden */
  20607. export var hdrFilteringFunctions: {
  20608. name: string;
  20609. shader: string;
  20610. };
  20611. }
  20612. declare module BABYLON {
  20613. /** @hidden */
  20614. export var pbrDirectLightingFunctions: {
  20615. name: string;
  20616. shader: string;
  20617. };
  20618. }
  20619. declare module BABYLON {
  20620. /** @hidden */
  20621. export var pbrIBLFunctions: {
  20622. name: string;
  20623. shader: string;
  20624. };
  20625. }
  20626. declare module BABYLON {
  20627. /** @hidden */
  20628. export var pbrBlockAlbedoOpacity: {
  20629. name: string;
  20630. shader: string;
  20631. };
  20632. }
  20633. declare module BABYLON {
  20634. /** @hidden */
  20635. export var pbrBlockReflectivity: {
  20636. name: string;
  20637. shader: string;
  20638. };
  20639. }
  20640. declare module BABYLON {
  20641. /** @hidden */
  20642. export var pbrBlockAmbientOcclusion: {
  20643. name: string;
  20644. shader: string;
  20645. };
  20646. }
  20647. declare module BABYLON {
  20648. /** @hidden */
  20649. export var pbrBlockAlphaFresnel: {
  20650. name: string;
  20651. shader: string;
  20652. };
  20653. }
  20654. declare module BABYLON {
  20655. /** @hidden */
  20656. export var pbrBlockAnisotropic: {
  20657. name: string;
  20658. shader: string;
  20659. };
  20660. }
  20661. declare module BABYLON {
  20662. /** @hidden */
  20663. export var pbrBlockReflection: {
  20664. name: string;
  20665. shader: string;
  20666. };
  20667. }
  20668. declare module BABYLON {
  20669. /** @hidden */
  20670. export var pbrBlockSheen: {
  20671. name: string;
  20672. shader: string;
  20673. };
  20674. }
  20675. declare module BABYLON {
  20676. /** @hidden */
  20677. export var pbrBlockClearcoat: {
  20678. name: string;
  20679. shader: string;
  20680. };
  20681. }
  20682. declare module BABYLON {
  20683. /** @hidden */
  20684. export var pbrBlockSubSurface: {
  20685. name: string;
  20686. shader: string;
  20687. };
  20688. }
  20689. declare module BABYLON {
  20690. /** @hidden */
  20691. export var pbrBlockNormalGeometric: {
  20692. name: string;
  20693. shader: string;
  20694. };
  20695. }
  20696. declare module BABYLON {
  20697. /** @hidden */
  20698. export var pbrBlockNormalFinal: {
  20699. name: string;
  20700. shader: string;
  20701. };
  20702. }
  20703. declare module BABYLON {
  20704. /** @hidden */
  20705. export var pbrBlockLightmapInit: {
  20706. name: string;
  20707. shader: string;
  20708. };
  20709. }
  20710. declare module BABYLON {
  20711. /** @hidden */
  20712. export var pbrBlockGeometryInfo: {
  20713. name: string;
  20714. shader: string;
  20715. };
  20716. }
  20717. declare module BABYLON {
  20718. /** @hidden */
  20719. export var pbrBlockReflectance0: {
  20720. name: string;
  20721. shader: string;
  20722. };
  20723. }
  20724. declare module BABYLON {
  20725. /** @hidden */
  20726. export var pbrBlockReflectance: {
  20727. name: string;
  20728. shader: string;
  20729. };
  20730. }
  20731. declare module BABYLON {
  20732. /** @hidden */
  20733. export var pbrBlockDirectLighting: {
  20734. name: string;
  20735. shader: string;
  20736. };
  20737. }
  20738. declare module BABYLON {
  20739. /** @hidden */
  20740. export var pbrBlockFinalLitComponents: {
  20741. name: string;
  20742. shader: string;
  20743. };
  20744. }
  20745. declare module BABYLON {
  20746. /** @hidden */
  20747. export var pbrBlockFinalUnlitComponents: {
  20748. name: string;
  20749. shader: string;
  20750. };
  20751. }
  20752. declare module BABYLON {
  20753. /** @hidden */
  20754. export var pbrBlockFinalColorComposition: {
  20755. name: string;
  20756. shader: string;
  20757. };
  20758. }
  20759. declare module BABYLON {
  20760. /** @hidden */
  20761. export var pbrBlockImageProcessing: {
  20762. name: string;
  20763. shader: string;
  20764. };
  20765. }
  20766. declare module BABYLON {
  20767. /** @hidden */
  20768. export var pbrDebug: {
  20769. name: string;
  20770. shader: string;
  20771. };
  20772. }
  20773. declare module BABYLON {
  20774. /** @hidden */
  20775. export var pbrPixelShader: {
  20776. name: string;
  20777. shader: string;
  20778. };
  20779. }
  20780. declare module BABYLON {
  20781. /** @hidden */
  20782. export var pbrVertexDeclaration: {
  20783. name: string;
  20784. shader: string;
  20785. };
  20786. }
  20787. declare module BABYLON {
  20788. /** @hidden */
  20789. export var pbrVertexShader: {
  20790. name: string;
  20791. shader: string;
  20792. };
  20793. }
  20794. declare module BABYLON {
  20795. /**
  20796. * Manages the defines for the PBR Material.
  20797. * @hidden
  20798. */
  20799. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  20800. PBR: boolean;
  20801. NUM_SAMPLES: string;
  20802. REALTIME_FILTERING: boolean;
  20803. MAINUV1: boolean;
  20804. MAINUV2: boolean;
  20805. UV1: boolean;
  20806. UV2: boolean;
  20807. ALBEDO: boolean;
  20808. GAMMAALBEDO: boolean;
  20809. ALBEDODIRECTUV: number;
  20810. VERTEXCOLOR: boolean;
  20811. DETAIL: boolean;
  20812. DETAILDIRECTUV: number;
  20813. DETAIL_NORMALBLENDMETHOD: number;
  20814. AMBIENT: boolean;
  20815. AMBIENTDIRECTUV: number;
  20816. AMBIENTINGRAYSCALE: boolean;
  20817. OPACITY: boolean;
  20818. VERTEXALPHA: boolean;
  20819. OPACITYDIRECTUV: number;
  20820. OPACITYRGB: boolean;
  20821. ALPHATEST: boolean;
  20822. DEPTHPREPASS: boolean;
  20823. ALPHABLEND: boolean;
  20824. ALPHAFROMALBEDO: boolean;
  20825. ALPHATESTVALUE: string;
  20826. SPECULAROVERALPHA: boolean;
  20827. RADIANCEOVERALPHA: boolean;
  20828. ALPHAFRESNEL: boolean;
  20829. LINEARALPHAFRESNEL: boolean;
  20830. PREMULTIPLYALPHA: boolean;
  20831. EMISSIVE: boolean;
  20832. EMISSIVEDIRECTUV: number;
  20833. REFLECTIVITY: boolean;
  20834. REFLECTIVITYDIRECTUV: number;
  20835. SPECULARTERM: boolean;
  20836. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  20837. MICROSURFACEAUTOMATIC: boolean;
  20838. LODBASEDMICROSFURACE: boolean;
  20839. MICROSURFACEMAP: boolean;
  20840. MICROSURFACEMAPDIRECTUV: number;
  20841. METALLICWORKFLOW: boolean;
  20842. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  20843. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  20844. METALLNESSSTOREINMETALMAPBLUE: boolean;
  20845. AOSTOREINMETALMAPRED: boolean;
  20846. METALLIC_REFLECTANCE: boolean;
  20847. METALLIC_REFLECTANCEDIRECTUV: number;
  20848. ENVIRONMENTBRDF: boolean;
  20849. ENVIRONMENTBRDF_RGBD: boolean;
  20850. NORMAL: boolean;
  20851. TANGENT: boolean;
  20852. BUMP: boolean;
  20853. BUMPDIRECTUV: number;
  20854. OBJECTSPACE_NORMALMAP: boolean;
  20855. PARALLAX: boolean;
  20856. PARALLAXOCCLUSION: boolean;
  20857. NORMALXYSCALE: boolean;
  20858. LIGHTMAP: boolean;
  20859. LIGHTMAPDIRECTUV: number;
  20860. USELIGHTMAPASSHADOWMAP: boolean;
  20861. GAMMALIGHTMAP: boolean;
  20862. RGBDLIGHTMAP: boolean;
  20863. REFLECTION: boolean;
  20864. REFLECTIONMAP_3D: boolean;
  20865. REFLECTIONMAP_SPHERICAL: boolean;
  20866. REFLECTIONMAP_PLANAR: boolean;
  20867. REFLECTIONMAP_CUBIC: boolean;
  20868. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  20869. REFLECTIONMAP_PROJECTION: boolean;
  20870. REFLECTIONMAP_SKYBOX: boolean;
  20871. REFLECTIONMAP_EXPLICIT: boolean;
  20872. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  20873. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  20874. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  20875. INVERTCUBICMAP: boolean;
  20876. USESPHERICALFROMREFLECTIONMAP: boolean;
  20877. USEIRRADIANCEMAP: boolean;
  20878. SPHERICAL_HARMONICS: boolean;
  20879. USESPHERICALINVERTEX: boolean;
  20880. REFLECTIONMAP_OPPOSITEZ: boolean;
  20881. LODINREFLECTIONALPHA: boolean;
  20882. GAMMAREFLECTION: boolean;
  20883. RGBDREFLECTION: boolean;
  20884. LINEARSPECULARREFLECTION: boolean;
  20885. RADIANCEOCCLUSION: boolean;
  20886. HORIZONOCCLUSION: boolean;
  20887. INSTANCES: boolean;
  20888. THIN_INSTANCES: boolean;
  20889. PREPASS: boolean;
  20890. PREPASS_IRRADIANCE: boolean;
  20891. PREPASS_IRRADIANCE_INDEX: number;
  20892. PREPASS_ALBEDO: boolean;
  20893. PREPASS_ALBEDO_INDEX: number;
  20894. PREPASS_DEPTHNORMAL: boolean;
  20895. PREPASS_DEPTHNORMAL_INDEX: number;
  20896. PREPASS_POSITION: boolean;
  20897. PREPASS_POSITION_INDEX: number;
  20898. PREPASS_VELOCITY: boolean;
  20899. PREPASS_VELOCITY_INDEX: number;
  20900. PREPASS_REFLECTIVITY: boolean;
  20901. PREPASS_REFLECTIVITY_INDEX: number;
  20902. SCENE_MRT_COUNT: number;
  20903. NUM_BONE_INFLUENCERS: number;
  20904. BonesPerMesh: number;
  20905. BONETEXTURE: boolean;
  20906. BONES_VELOCITY_ENABLED: boolean;
  20907. NONUNIFORMSCALING: boolean;
  20908. MORPHTARGETS: boolean;
  20909. MORPHTARGETS_NORMAL: boolean;
  20910. MORPHTARGETS_TANGENT: boolean;
  20911. MORPHTARGETS_UV: boolean;
  20912. NUM_MORPH_INFLUENCERS: number;
  20913. IMAGEPROCESSING: boolean;
  20914. VIGNETTE: boolean;
  20915. VIGNETTEBLENDMODEMULTIPLY: boolean;
  20916. VIGNETTEBLENDMODEOPAQUE: boolean;
  20917. TONEMAPPING: boolean;
  20918. TONEMAPPING_ACES: boolean;
  20919. CONTRAST: boolean;
  20920. COLORCURVES: boolean;
  20921. COLORGRADING: boolean;
  20922. COLORGRADING3D: boolean;
  20923. SAMPLER3DGREENDEPTH: boolean;
  20924. SAMPLER3DBGRMAP: boolean;
  20925. IMAGEPROCESSINGPOSTPROCESS: boolean;
  20926. EXPOSURE: boolean;
  20927. MULTIVIEW: boolean;
  20928. USEPHYSICALLIGHTFALLOFF: boolean;
  20929. USEGLTFLIGHTFALLOFF: boolean;
  20930. TWOSIDEDLIGHTING: boolean;
  20931. SHADOWFLOAT: boolean;
  20932. CLIPPLANE: boolean;
  20933. CLIPPLANE2: boolean;
  20934. CLIPPLANE3: boolean;
  20935. CLIPPLANE4: boolean;
  20936. CLIPPLANE5: boolean;
  20937. CLIPPLANE6: boolean;
  20938. POINTSIZE: boolean;
  20939. FOG: boolean;
  20940. LOGARITHMICDEPTH: boolean;
  20941. FORCENORMALFORWARD: boolean;
  20942. SPECULARAA: boolean;
  20943. CLEARCOAT: boolean;
  20944. CLEARCOAT_DEFAULTIOR: boolean;
  20945. CLEARCOAT_TEXTURE: boolean;
  20946. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20947. CLEARCOAT_TEXTUREDIRECTUV: number;
  20948. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20949. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20950. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20951. CLEARCOAT_BUMP: boolean;
  20952. CLEARCOAT_BUMPDIRECTUV: number;
  20953. CLEARCOAT_REMAP_F0: boolean;
  20954. CLEARCOAT_TINT: boolean;
  20955. CLEARCOAT_TINT_TEXTURE: boolean;
  20956. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20957. ANISOTROPIC: boolean;
  20958. ANISOTROPIC_TEXTURE: boolean;
  20959. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20960. BRDF_V_HEIGHT_CORRELATED: boolean;
  20961. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20962. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20963. SHEEN: boolean;
  20964. SHEEN_TEXTURE: boolean;
  20965. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20966. SHEEN_TEXTUREDIRECTUV: number;
  20967. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20968. SHEEN_LINKWITHALBEDO: boolean;
  20969. SHEEN_ROUGHNESS: boolean;
  20970. SHEEN_ALBEDOSCALING: boolean;
  20971. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20972. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20973. SUBSURFACE: boolean;
  20974. SS_REFRACTION: boolean;
  20975. SS_TRANSLUCENCY: boolean;
  20976. SS_SCATTERING: boolean;
  20977. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20978. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20979. SS_REFRACTIONMAP_3D: boolean;
  20980. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20981. SS_LODINREFRACTIONALPHA: boolean;
  20982. SS_GAMMAREFRACTION: boolean;
  20983. SS_RGBDREFRACTION: boolean;
  20984. SS_LINEARSPECULARREFRACTION: boolean;
  20985. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20986. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20987. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20988. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20989. UNLIT: boolean;
  20990. DEBUGMODE: number;
  20991. /**
  20992. * Initializes the PBR Material defines.
  20993. */
  20994. constructor();
  20995. /**
  20996. * Resets the PBR Material defines.
  20997. */
  20998. reset(): void;
  20999. }
  21000. /**
  21001. * The Physically based material base class of BJS.
  21002. *
  21003. * This offers the main features of a standard PBR material.
  21004. * For more information, please refer to the documentation :
  21005. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21006. */
  21007. export abstract class PBRBaseMaterial extends PushMaterial {
  21008. /**
  21009. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21010. */
  21011. static readonly PBRMATERIAL_OPAQUE: number;
  21012. /**
  21013. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21014. */
  21015. static readonly PBRMATERIAL_ALPHATEST: number;
  21016. /**
  21017. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21018. */
  21019. static readonly PBRMATERIAL_ALPHABLEND: number;
  21020. /**
  21021. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21022. * They are also discarded below the alpha cutoff threshold to improve performances.
  21023. */
  21024. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21025. /**
  21026. * Defines the default value of how much AO map is occluding the analytical lights
  21027. * (point spot...).
  21028. */
  21029. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21030. /**
  21031. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21032. */
  21033. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21034. /**
  21035. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21036. * to enhance interoperability with other engines.
  21037. */
  21038. static readonly LIGHTFALLOFF_GLTF: number;
  21039. /**
  21040. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21041. * to enhance interoperability with other materials.
  21042. */
  21043. static readonly LIGHTFALLOFF_STANDARD: number;
  21044. /**
  21045. * Intensity of the direct lights e.g. the four lights available in your scene.
  21046. * This impacts both the direct diffuse and specular highlights.
  21047. */
  21048. protected _directIntensity: number;
  21049. /**
  21050. * Intensity of the emissive part of the material.
  21051. * This helps controlling the emissive effect without modifying the emissive color.
  21052. */
  21053. protected _emissiveIntensity: number;
  21054. /**
  21055. * Intensity of the environment e.g. how much the environment will light the object
  21056. * either through harmonics for rough material or through the refelction for shiny ones.
  21057. */
  21058. protected _environmentIntensity: number;
  21059. /**
  21060. * This is a special control allowing the reduction of the specular highlights coming from the
  21061. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21062. */
  21063. protected _specularIntensity: number;
  21064. /**
  21065. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21066. */
  21067. private _lightingInfos;
  21068. /**
  21069. * Debug Control allowing disabling the bump map on this material.
  21070. */
  21071. protected _disableBumpMap: boolean;
  21072. /**
  21073. * AKA Diffuse Texture in standard nomenclature.
  21074. */
  21075. protected _albedoTexture: Nullable<BaseTexture>;
  21076. /**
  21077. * AKA Occlusion Texture in other nomenclature.
  21078. */
  21079. protected _ambientTexture: Nullable<BaseTexture>;
  21080. /**
  21081. * AKA Occlusion Texture Intensity in other nomenclature.
  21082. */
  21083. protected _ambientTextureStrength: number;
  21084. /**
  21085. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21086. * 1 means it completely occludes it
  21087. * 0 mean it has no impact
  21088. */
  21089. protected _ambientTextureImpactOnAnalyticalLights: number;
  21090. /**
  21091. * Stores the alpha values in a texture.
  21092. */
  21093. protected _opacityTexture: Nullable<BaseTexture>;
  21094. /**
  21095. * Stores the reflection values in a texture.
  21096. */
  21097. protected _reflectionTexture: Nullable<BaseTexture>;
  21098. /**
  21099. * Stores the emissive values in a texture.
  21100. */
  21101. protected _emissiveTexture: Nullable<BaseTexture>;
  21102. /**
  21103. * AKA Specular texture in other nomenclature.
  21104. */
  21105. protected _reflectivityTexture: Nullable<BaseTexture>;
  21106. /**
  21107. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21108. */
  21109. protected _metallicTexture: Nullable<BaseTexture>;
  21110. /**
  21111. * Specifies the metallic scalar of the metallic/roughness workflow.
  21112. * Can also be used to scale the metalness values of the metallic texture.
  21113. */
  21114. protected _metallic: Nullable<number>;
  21115. /**
  21116. * Specifies the roughness scalar of the metallic/roughness workflow.
  21117. * Can also be used to scale the roughness values of the metallic texture.
  21118. */
  21119. protected _roughness: Nullable<number>;
  21120. /**
  21121. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21122. * By default the indexOfrefraction is used to compute F0;
  21123. *
  21124. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21125. *
  21126. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21127. * F90 = metallicReflectanceColor;
  21128. */
  21129. protected _metallicF0Factor: number;
  21130. /**
  21131. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21132. * By default the F90 is always 1;
  21133. *
  21134. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21135. *
  21136. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21137. * F90 = metallicReflectanceColor;
  21138. */
  21139. protected _metallicReflectanceColor: Color3;
  21140. /**
  21141. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21142. * This is multiply against the scalar values defined in the material.
  21143. */
  21144. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21145. /**
  21146. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21147. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21148. */
  21149. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21150. /**
  21151. * Stores surface normal data used to displace a mesh in a texture.
  21152. */
  21153. protected _bumpTexture: Nullable<BaseTexture>;
  21154. /**
  21155. * Stores the pre-calculated light information of a mesh in a texture.
  21156. */
  21157. protected _lightmapTexture: Nullable<BaseTexture>;
  21158. /**
  21159. * The color of a material in ambient lighting.
  21160. */
  21161. protected _ambientColor: Color3;
  21162. /**
  21163. * AKA Diffuse Color in other nomenclature.
  21164. */
  21165. protected _albedoColor: Color3;
  21166. /**
  21167. * AKA Specular Color in other nomenclature.
  21168. */
  21169. protected _reflectivityColor: Color3;
  21170. /**
  21171. * The color applied when light is reflected from a material.
  21172. */
  21173. protected _reflectionColor: Color3;
  21174. /**
  21175. * The color applied when light is emitted from a material.
  21176. */
  21177. protected _emissiveColor: Color3;
  21178. /**
  21179. * AKA Glossiness in other nomenclature.
  21180. */
  21181. protected _microSurface: number;
  21182. /**
  21183. * Specifies that the material will use the light map as a show map.
  21184. */
  21185. protected _useLightmapAsShadowmap: boolean;
  21186. /**
  21187. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21188. * makes the reflect vector face the model (under horizon).
  21189. */
  21190. protected _useHorizonOcclusion: boolean;
  21191. /**
  21192. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21193. * too much the area relying on ambient texture to define their ambient occlusion.
  21194. */
  21195. protected _useRadianceOcclusion: boolean;
  21196. /**
  21197. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21198. */
  21199. protected _useAlphaFromAlbedoTexture: boolean;
  21200. /**
  21201. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21202. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21203. */
  21204. protected _useSpecularOverAlpha: boolean;
  21205. /**
  21206. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21207. */
  21208. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21209. /**
  21210. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21211. */
  21212. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21213. /**
  21214. * Specifies if the metallic texture contains the roughness information in its green channel.
  21215. */
  21216. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21217. /**
  21218. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21219. */
  21220. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21221. /**
  21222. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21223. */
  21224. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21225. /**
  21226. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21227. */
  21228. protected _useAmbientInGrayScale: boolean;
  21229. /**
  21230. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21231. * The material will try to infer what glossiness each pixel should be.
  21232. */
  21233. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21234. /**
  21235. * Defines the falloff type used in this material.
  21236. * It by default is Physical.
  21237. */
  21238. protected _lightFalloff: number;
  21239. /**
  21240. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21241. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21242. */
  21243. protected _useRadianceOverAlpha: boolean;
  21244. /**
  21245. * Allows using an object space normal map (instead of tangent space).
  21246. */
  21247. protected _useObjectSpaceNormalMap: boolean;
  21248. /**
  21249. * Allows using the bump map in parallax mode.
  21250. */
  21251. protected _useParallax: boolean;
  21252. /**
  21253. * Allows using the bump map in parallax occlusion mode.
  21254. */
  21255. protected _useParallaxOcclusion: boolean;
  21256. /**
  21257. * Controls the scale bias of the parallax mode.
  21258. */
  21259. protected _parallaxScaleBias: number;
  21260. /**
  21261. * If sets to true, disables all the lights affecting the material.
  21262. */
  21263. protected _disableLighting: boolean;
  21264. /**
  21265. * Number of Simultaneous lights allowed on the material.
  21266. */
  21267. protected _maxSimultaneousLights: number;
  21268. /**
  21269. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21270. */
  21271. protected _invertNormalMapX: boolean;
  21272. /**
  21273. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21274. */
  21275. protected _invertNormalMapY: boolean;
  21276. /**
  21277. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21278. */
  21279. protected _twoSidedLighting: boolean;
  21280. /**
  21281. * Defines the alpha limits in alpha test mode.
  21282. */
  21283. protected _alphaCutOff: number;
  21284. /**
  21285. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21286. */
  21287. protected _forceAlphaTest: boolean;
  21288. /**
  21289. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21290. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21291. */
  21292. protected _useAlphaFresnel: boolean;
  21293. /**
  21294. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21295. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21296. */
  21297. protected _useLinearAlphaFresnel: boolean;
  21298. /**
  21299. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  21300. * from cos thetav and roughness:
  21301. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  21302. */
  21303. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  21304. /**
  21305. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21306. */
  21307. protected _forceIrradianceInFragment: boolean;
  21308. private _realTimeFiltering;
  21309. /**
  21310. * Enables realtime filtering on the texture.
  21311. */
  21312. get realTimeFiltering(): boolean;
  21313. set realTimeFiltering(b: boolean);
  21314. private _realTimeFilteringQuality;
  21315. /**
  21316. * Quality switch for realtime filtering
  21317. */
  21318. get realTimeFilteringQuality(): number;
  21319. set realTimeFilteringQuality(n: number);
  21320. /**
  21321. * Can this material render to several textures at once
  21322. */
  21323. get canRenderToMRT(): boolean;
  21324. /**
  21325. * Force normal to face away from face.
  21326. */
  21327. protected _forceNormalForward: boolean;
  21328. /**
  21329. * Enables specular anti aliasing in the PBR shader.
  21330. * It will both interacts on the Geometry for analytical and IBL lighting.
  21331. * It also prefilter the roughness map based on the bump values.
  21332. */
  21333. protected _enableSpecularAntiAliasing: boolean;
  21334. /**
  21335. * Default configuration related to image processing available in the PBR Material.
  21336. */
  21337. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21338. /**
  21339. * Keep track of the image processing observer to allow dispose and replace.
  21340. */
  21341. private _imageProcessingObserver;
  21342. /**
  21343. * Attaches a new image processing configuration to the PBR Material.
  21344. * @param configuration
  21345. */
  21346. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  21347. /**
  21348. * Stores the available render targets.
  21349. */
  21350. private _renderTargets;
  21351. /**
  21352. * Sets the global ambient color for the material used in lighting calculations.
  21353. */
  21354. private _globalAmbientColor;
  21355. /**
  21356. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  21357. */
  21358. private _useLogarithmicDepth;
  21359. /**
  21360. * If set to true, no lighting calculations will be applied.
  21361. */
  21362. private _unlit;
  21363. private _debugMode;
  21364. /**
  21365. * @hidden
  21366. * This is reserved for the inspector.
  21367. * Defines the material debug mode.
  21368. * It helps seeing only some components of the material while troubleshooting.
  21369. */
  21370. debugMode: number;
  21371. /**
  21372. * @hidden
  21373. * This is reserved for the inspector.
  21374. * Specify from where on screen the debug mode should start.
  21375. * The value goes from -1 (full screen) to 1 (not visible)
  21376. * It helps with side by side comparison against the final render
  21377. * This defaults to -1
  21378. */
  21379. private debugLimit;
  21380. /**
  21381. * @hidden
  21382. * This is reserved for the inspector.
  21383. * As the default viewing range might not be enough (if the ambient is really small for instance)
  21384. * You can use the factor to better multiply the final value.
  21385. */
  21386. private debugFactor;
  21387. /**
  21388. * Defines the clear coat layer parameters for the material.
  21389. */
  21390. readonly clearCoat: PBRClearCoatConfiguration;
  21391. /**
  21392. * Defines the anisotropic parameters for the material.
  21393. */
  21394. readonly anisotropy: PBRAnisotropicConfiguration;
  21395. /**
  21396. * Defines the BRDF parameters for the material.
  21397. */
  21398. readonly brdf: PBRBRDFConfiguration;
  21399. /**
  21400. * Defines the Sheen parameters for the material.
  21401. */
  21402. readonly sheen: PBRSheenConfiguration;
  21403. /**
  21404. * Defines the SubSurface parameters for the material.
  21405. */
  21406. readonly subSurface: PBRSubSurfaceConfiguration;
  21407. /**
  21408. * Defines additionnal PrePass parameters for the material.
  21409. */
  21410. readonly prePassConfiguration: PrePassConfiguration;
  21411. /**
  21412. * Defines the detail map parameters for the material.
  21413. */
  21414. readonly detailMap: DetailMapConfiguration;
  21415. protected _rebuildInParallel: boolean;
  21416. /**
  21417. * Instantiates a new PBRMaterial instance.
  21418. *
  21419. * @param name The material name
  21420. * @param scene The scene the material will be use in.
  21421. */
  21422. constructor(name: string, scene: Scene);
  21423. /**
  21424. * Gets a boolean indicating that current material needs to register RTT
  21425. */
  21426. get hasRenderTargetTextures(): boolean;
  21427. /**
  21428. * Gets the name of the material class.
  21429. */
  21430. getClassName(): string;
  21431. /**
  21432. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21433. */
  21434. get useLogarithmicDepth(): boolean;
  21435. /**
  21436. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21437. */
  21438. set useLogarithmicDepth(value: boolean);
  21439. /**
  21440. * Returns true if alpha blending should be disabled.
  21441. */
  21442. protected get _disableAlphaBlending(): boolean;
  21443. /**
  21444. * Specifies whether or not this material should be rendered in alpha blend mode.
  21445. */
  21446. needAlphaBlending(): boolean;
  21447. /**
  21448. * Specifies whether or not this material should be rendered in alpha test mode.
  21449. */
  21450. needAlphaTesting(): boolean;
  21451. /**
  21452. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  21453. */
  21454. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  21455. /**
  21456. * Specifies whether or not there is a usable alpha channel for transparency.
  21457. */
  21458. protected _hasAlphaChannel(): boolean;
  21459. /**
  21460. * Gets the texture used for the alpha test.
  21461. */
  21462. getAlphaTestTexture(): Nullable<BaseTexture>;
  21463. /**
  21464. * Specifies that the submesh is ready to be used.
  21465. * @param mesh - BJS mesh.
  21466. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  21467. * @param useInstances - Specifies that instances should be used.
  21468. * @returns - boolean indicating that the submesh is ready or not.
  21469. */
  21470. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  21471. /**
  21472. * Specifies if the material uses metallic roughness workflow.
  21473. * @returns boolean specifiying if the material uses metallic roughness workflow.
  21474. */
  21475. isMetallicWorkflow(): boolean;
  21476. private _prepareEffect;
  21477. private _prepareDefines;
  21478. /**
  21479. * Force shader compilation
  21480. */
  21481. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  21482. /**
  21483. * Initializes the uniform buffer layout for the shader.
  21484. */
  21485. buildUniformLayout(): void;
  21486. /**
  21487. * Unbinds the material from the mesh
  21488. */
  21489. unbind(): void;
  21490. /**
  21491. * Binds the submesh data.
  21492. * @param world - The world matrix.
  21493. * @param mesh - The BJS mesh.
  21494. * @param subMesh - A submesh of the BJS mesh.
  21495. */
  21496. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21497. /**
  21498. * Returns the animatable textures.
  21499. * @returns - Array of animatable textures.
  21500. */
  21501. getAnimatables(): IAnimatable[];
  21502. /**
  21503. * Returns the texture used for reflections.
  21504. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  21505. */
  21506. private _getReflectionTexture;
  21507. /**
  21508. * Returns an array of the actively used textures.
  21509. * @returns - Array of BaseTextures
  21510. */
  21511. getActiveTextures(): BaseTexture[];
  21512. /**
  21513. * Checks to see if a texture is used in the material.
  21514. * @param texture - Base texture to use.
  21515. * @returns - Boolean specifying if a texture is used in the material.
  21516. */
  21517. hasTexture(texture: BaseTexture): boolean;
  21518. /**
  21519. * Sets the required values to the prepass renderer.
  21520. * @param prePassRenderer defines the prepass renderer to setup
  21521. */
  21522. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  21523. /**
  21524. * Disposes the resources of the material.
  21525. * @param forceDisposeEffect - Forces the disposal of effects.
  21526. * @param forceDisposeTextures - Forces the disposal of all textures.
  21527. */
  21528. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  21529. }
  21530. }
  21531. declare module BABYLON {
  21532. /**
  21533. * The Physically based material of BJS.
  21534. *
  21535. * This offers the main features of a standard PBR material.
  21536. * For more information, please refer to the documentation :
  21537. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21538. */
  21539. export class PBRMaterial extends PBRBaseMaterial {
  21540. /**
  21541. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21542. */
  21543. static readonly PBRMATERIAL_OPAQUE: number;
  21544. /**
  21545. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21546. */
  21547. static readonly PBRMATERIAL_ALPHATEST: number;
  21548. /**
  21549. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21550. */
  21551. static readonly PBRMATERIAL_ALPHABLEND: number;
  21552. /**
  21553. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21554. * They are also discarded below the alpha cutoff threshold to improve performances.
  21555. */
  21556. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21557. /**
  21558. * Defines the default value of how much AO map is occluding the analytical lights
  21559. * (point spot...).
  21560. */
  21561. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21562. /**
  21563. * Intensity of the direct lights e.g. the four lights available in your scene.
  21564. * This impacts both the direct diffuse and specular highlights.
  21565. */
  21566. directIntensity: number;
  21567. /**
  21568. * Intensity of the emissive part of the material.
  21569. * This helps controlling the emissive effect without modifying the emissive color.
  21570. */
  21571. emissiveIntensity: number;
  21572. /**
  21573. * Intensity of the environment e.g. how much the environment will light the object
  21574. * either through harmonics for rough material or through the refelction for shiny ones.
  21575. */
  21576. environmentIntensity: number;
  21577. /**
  21578. * This is a special control allowing the reduction of the specular highlights coming from the
  21579. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21580. */
  21581. specularIntensity: number;
  21582. /**
  21583. * Debug Control allowing disabling the bump map on this material.
  21584. */
  21585. disableBumpMap: boolean;
  21586. /**
  21587. * AKA Diffuse Texture in standard nomenclature.
  21588. */
  21589. albedoTexture: BaseTexture;
  21590. /**
  21591. * AKA Occlusion Texture in other nomenclature.
  21592. */
  21593. ambientTexture: BaseTexture;
  21594. /**
  21595. * AKA Occlusion Texture Intensity in other nomenclature.
  21596. */
  21597. ambientTextureStrength: number;
  21598. /**
  21599. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21600. * 1 means it completely occludes it
  21601. * 0 mean it has no impact
  21602. */
  21603. ambientTextureImpactOnAnalyticalLights: number;
  21604. /**
  21605. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  21606. */
  21607. opacityTexture: BaseTexture;
  21608. /**
  21609. * Stores the reflection values in a texture.
  21610. */
  21611. reflectionTexture: Nullable<BaseTexture>;
  21612. /**
  21613. * Stores the emissive values in a texture.
  21614. */
  21615. emissiveTexture: BaseTexture;
  21616. /**
  21617. * AKA Specular texture in other nomenclature.
  21618. */
  21619. reflectivityTexture: BaseTexture;
  21620. /**
  21621. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21622. */
  21623. metallicTexture: BaseTexture;
  21624. /**
  21625. * Specifies the metallic scalar of the metallic/roughness workflow.
  21626. * Can also be used to scale the metalness values of the metallic texture.
  21627. */
  21628. metallic: Nullable<number>;
  21629. /**
  21630. * Specifies the roughness scalar of the metallic/roughness workflow.
  21631. * Can also be used to scale the roughness values of the metallic texture.
  21632. */
  21633. roughness: Nullable<number>;
  21634. /**
  21635. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21636. * By default the indexOfrefraction is used to compute F0;
  21637. *
  21638. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21639. *
  21640. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21641. * F90 = metallicReflectanceColor;
  21642. */
  21643. metallicF0Factor: number;
  21644. /**
  21645. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21646. * By default the F90 is always 1;
  21647. *
  21648. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21649. *
  21650. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21651. * F90 = metallicReflectanceColor;
  21652. */
  21653. metallicReflectanceColor: Color3;
  21654. /**
  21655. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21656. * This is multiply against the scalar values defined in the material.
  21657. */
  21658. metallicReflectanceTexture: Nullable<BaseTexture>;
  21659. /**
  21660. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21661. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21662. */
  21663. microSurfaceTexture: BaseTexture;
  21664. /**
  21665. * Stores surface normal data used to displace a mesh in a texture.
  21666. */
  21667. bumpTexture: BaseTexture;
  21668. /**
  21669. * Stores the pre-calculated light information of a mesh in a texture.
  21670. */
  21671. lightmapTexture: BaseTexture;
  21672. /**
  21673. * Stores the refracted light information in a texture.
  21674. */
  21675. get refractionTexture(): Nullable<BaseTexture>;
  21676. set refractionTexture(value: Nullable<BaseTexture>);
  21677. /**
  21678. * The color of a material in ambient lighting.
  21679. */
  21680. ambientColor: Color3;
  21681. /**
  21682. * AKA Diffuse Color in other nomenclature.
  21683. */
  21684. albedoColor: Color3;
  21685. /**
  21686. * AKA Specular Color in other nomenclature.
  21687. */
  21688. reflectivityColor: Color3;
  21689. /**
  21690. * The color reflected from the material.
  21691. */
  21692. reflectionColor: Color3;
  21693. /**
  21694. * The color emitted from the material.
  21695. */
  21696. emissiveColor: Color3;
  21697. /**
  21698. * AKA Glossiness in other nomenclature.
  21699. */
  21700. microSurface: number;
  21701. /**
  21702. * Index of refraction of the material base layer.
  21703. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21704. *
  21705. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21706. *
  21707. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21708. */
  21709. get indexOfRefraction(): number;
  21710. set indexOfRefraction(value: number);
  21711. /**
  21712. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21713. */
  21714. get invertRefractionY(): boolean;
  21715. set invertRefractionY(value: boolean);
  21716. /**
  21717. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21718. * Materials half opaque for instance using refraction could benefit from this control.
  21719. */
  21720. get linkRefractionWithTransparency(): boolean;
  21721. set linkRefractionWithTransparency(value: boolean);
  21722. /**
  21723. * If true, the light map contains occlusion information instead of lighting info.
  21724. */
  21725. useLightmapAsShadowmap: boolean;
  21726. /**
  21727. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21728. */
  21729. useAlphaFromAlbedoTexture: boolean;
  21730. /**
  21731. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21732. */
  21733. forceAlphaTest: boolean;
  21734. /**
  21735. * Defines the alpha limits in alpha test mode.
  21736. */
  21737. alphaCutOff: number;
  21738. /**
  21739. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  21740. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21741. */
  21742. useSpecularOverAlpha: boolean;
  21743. /**
  21744. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21745. */
  21746. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21747. /**
  21748. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21749. */
  21750. useRoughnessFromMetallicTextureAlpha: boolean;
  21751. /**
  21752. * Specifies if the metallic texture contains the roughness information in its green channel.
  21753. */
  21754. useRoughnessFromMetallicTextureGreen: boolean;
  21755. /**
  21756. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21757. */
  21758. useMetallnessFromMetallicTextureBlue: boolean;
  21759. /**
  21760. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21761. */
  21762. useAmbientOcclusionFromMetallicTextureRed: boolean;
  21763. /**
  21764. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21765. */
  21766. useAmbientInGrayScale: boolean;
  21767. /**
  21768. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21769. * The material will try to infer what glossiness each pixel should be.
  21770. */
  21771. useAutoMicroSurfaceFromReflectivityMap: boolean;
  21772. /**
  21773. * BJS is using an harcoded light falloff based on a manually sets up range.
  21774. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21775. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21776. */
  21777. get usePhysicalLightFalloff(): boolean;
  21778. /**
  21779. * BJS is using an harcoded light falloff based on a manually sets up range.
  21780. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21781. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21782. */
  21783. set usePhysicalLightFalloff(value: boolean);
  21784. /**
  21785. * In order to support the falloff compatibility with gltf, a special mode has been added
  21786. * to reproduce the gltf light falloff.
  21787. */
  21788. get useGLTFLightFalloff(): boolean;
  21789. /**
  21790. * In order to support the falloff compatibility with gltf, a special mode has been added
  21791. * to reproduce the gltf light falloff.
  21792. */
  21793. set useGLTFLightFalloff(value: boolean);
  21794. /**
  21795. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21796. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21797. */
  21798. useRadianceOverAlpha: boolean;
  21799. /**
  21800. * Allows using an object space normal map (instead of tangent space).
  21801. */
  21802. useObjectSpaceNormalMap: boolean;
  21803. /**
  21804. * Allows using the bump map in parallax mode.
  21805. */
  21806. useParallax: boolean;
  21807. /**
  21808. * Allows using the bump map in parallax occlusion mode.
  21809. */
  21810. useParallaxOcclusion: boolean;
  21811. /**
  21812. * Controls the scale bias of the parallax mode.
  21813. */
  21814. parallaxScaleBias: number;
  21815. /**
  21816. * If sets to true, disables all the lights affecting the material.
  21817. */
  21818. disableLighting: boolean;
  21819. /**
  21820. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21821. */
  21822. forceIrradianceInFragment: boolean;
  21823. /**
  21824. * Number of Simultaneous lights allowed on the material.
  21825. */
  21826. maxSimultaneousLights: number;
  21827. /**
  21828. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  21829. */
  21830. invertNormalMapX: boolean;
  21831. /**
  21832. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  21833. */
  21834. invertNormalMapY: boolean;
  21835. /**
  21836. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21837. */
  21838. twoSidedLighting: boolean;
  21839. /**
  21840. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21841. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21842. */
  21843. useAlphaFresnel: boolean;
  21844. /**
  21845. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21846. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21847. */
  21848. useLinearAlphaFresnel: boolean;
  21849. /**
  21850. * Let user defines the brdf lookup texture used for IBL.
  21851. * A default 8bit version is embedded but you could point at :
  21852. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  21853. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  21854. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  21855. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  21856. */
  21857. environmentBRDFTexture: Nullable<BaseTexture>;
  21858. /**
  21859. * Force normal to face away from face.
  21860. */
  21861. forceNormalForward: boolean;
  21862. /**
  21863. * Enables specular anti aliasing in the PBR shader.
  21864. * It will both interacts on the Geometry for analytical and IBL lighting.
  21865. * It also prefilter the roughness map based on the bump values.
  21866. */
  21867. enableSpecularAntiAliasing: boolean;
  21868. /**
  21869. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21870. * makes the reflect vector face the model (under horizon).
  21871. */
  21872. useHorizonOcclusion: boolean;
  21873. /**
  21874. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21875. * too much the area relying on ambient texture to define their ambient occlusion.
  21876. */
  21877. useRadianceOcclusion: boolean;
  21878. /**
  21879. * If set to true, no lighting calculations will be applied.
  21880. */
  21881. unlit: boolean;
  21882. /**
  21883. * Gets the image processing configuration used either in this material.
  21884. */
  21885. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  21886. /**
  21887. * Sets the Default image processing configuration used either in the this material.
  21888. *
  21889. * If sets to null, the scene one is in use.
  21890. */
  21891. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  21892. /**
  21893. * Gets wether the color curves effect is enabled.
  21894. */
  21895. get cameraColorCurvesEnabled(): boolean;
  21896. /**
  21897. * Sets wether the color curves effect is enabled.
  21898. */
  21899. set cameraColorCurvesEnabled(value: boolean);
  21900. /**
  21901. * Gets wether the color grading effect is enabled.
  21902. */
  21903. get cameraColorGradingEnabled(): boolean;
  21904. /**
  21905. * Gets wether the color grading effect is enabled.
  21906. */
  21907. set cameraColorGradingEnabled(value: boolean);
  21908. /**
  21909. * Gets wether tonemapping is enabled or not.
  21910. */
  21911. get cameraToneMappingEnabled(): boolean;
  21912. /**
  21913. * Sets wether tonemapping is enabled or not
  21914. */
  21915. set cameraToneMappingEnabled(value: boolean);
  21916. /**
  21917. * The camera exposure used on this material.
  21918. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21919. * This corresponds to a photographic exposure.
  21920. */
  21921. get cameraExposure(): number;
  21922. /**
  21923. * The camera exposure used on this material.
  21924. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21925. * This corresponds to a photographic exposure.
  21926. */
  21927. set cameraExposure(value: number);
  21928. /**
  21929. * Gets The camera contrast used on this material.
  21930. */
  21931. get cameraContrast(): number;
  21932. /**
  21933. * Sets The camera contrast used on this material.
  21934. */
  21935. set cameraContrast(value: number);
  21936. /**
  21937. * Gets the Color Grading 2D Lookup Texture.
  21938. */
  21939. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  21940. /**
  21941. * Sets the Color Grading 2D Lookup Texture.
  21942. */
  21943. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  21944. /**
  21945. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21946. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21947. * 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;
  21948. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21949. */
  21950. get cameraColorCurves(): Nullable<ColorCurves>;
  21951. /**
  21952. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21953. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21954. * 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;
  21955. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21956. */
  21957. set cameraColorCurves(value: Nullable<ColorCurves>);
  21958. /**
  21959. * Instantiates a new PBRMaterial instance.
  21960. *
  21961. * @param name The material name
  21962. * @param scene The scene the material will be use in.
  21963. */
  21964. constructor(name: string, scene: Scene);
  21965. /**
  21966. * Returns the name of this material class.
  21967. */
  21968. getClassName(): string;
  21969. /**
  21970. * Makes a duplicate of the current material.
  21971. * @param name - name to use for the new material.
  21972. */
  21973. clone(name: string): PBRMaterial;
  21974. /**
  21975. * Serializes this PBR Material.
  21976. * @returns - An object with the serialized material.
  21977. */
  21978. serialize(): any;
  21979. /**
  21980. * Parses a PBR Material from a serialized object.
  21981. * @param source - Serialized object.
  21982. * @param scene - BJS scene instance.
  21983. * @param rootUrl - url for the scene object
  21984. * @returns - PBRMaterial
  21985. */
  21986. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  21987. }
  21988. }
  21989. declare module BABYLON {
  21990. /** @hidden */
  21991. export var mrtFragmentDeclaration: {
  21992. name: string;
  21993. shader: string;
  21994. };
  21995. }
  21996. declare module BABYLON {
  21997. /** @hidden */
  21998. export var geometryPixelShader: {
  21999. name: string;
  22000. shader: string;
  22001. };
  22002. }
  22003. declare module BABYLON {
  22004. /** @hidden */
  22005. export var geometryVertexShader: {
  22006. name: string;
  22007. shader: string;
  22008. };
  22009. }
  22010. declare module BABYLON {
  22011. /** @hidden */
  22012. interface ISavedTransformationMatrix {
  22013. world: Matrix;
  22014. viewProjection: Matrix;
  22015. }
  22016. /**
  22017. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22018. */
  22019. export class GeometryBufferRenderer {
  22020. /**
  22021. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22022. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22023. */
  22024. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22025. /**
  22026. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22027. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22028. */
  22029. static readonly POSITION_TEXTURE_TYPE: number;
  22030. /**
  22031. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22032. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22033. */
  22034. static readonly VELOCITY_TEXTURE_TYPE: number;
  22035. /**
  22036. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22037. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22038. */
  22039. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22040. /**
  22041. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22042. * in order to compute objects velocities when enableVelocity is set to "true"
  22043. * @hidden
  22044. */
  22045. _previousTransformationMatrices: {
  22046. [index: number]: ISavedTransformationMatrix;
  22047. };
  22048. /**
  22049. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22050. * in order to compute objects velocities when enableVelocity is set to "true"
  22051. * @hidden
  22052. */
  22053. _previousBonesTransformationMatrices: {
  22054. [index: number]: Float32Array;
  22055. };
  22056. /**
  22057. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22058. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22059. */
  22060. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22061. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22062. renderTransparentMeshes: boolean;
  22063. private _scene;
  22064. private _resizeObserver;
  22065. private _multiRenderTarget;
  22066. private _ratio;
  22067. private _enablePosition;
  22068. private _enableVelocity;
  22069. private _enableReflectivity;
  22070. private _positionIndex;
  22071. private _velocityIndex;
  22072. private _reflectivityIndex;
  22073. private _depthNormalIndex;
  22074. private _linkedWithPrePass;
  22075. private _prePassRenderer;
  22076. private _attachments;
  22077. protected _effect: Effect;
  22078. protected _cachedDefines: string;
  22079. /**
  22080. * @hidden
  22081. * Sets up internal structures to share outputs with PrePassRenderer
  22082. * This method should only be called by the PrePassRenderer itself
  22083. */
  22084. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22085. /**
  22086. * @hidden
  22087. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22088. * This method should only be called by the PrePassRenderer itself
  22089. */
  22090. _unlinkPrePassRenderer(): void;
  22091. /**
  22092. * @hidden
  22093. * Resets the geometry buffer layout
  22094. */
  22095. _resetLayout(): void;
  22096. /**
  22097. * @hidden
  22098. * Replaces a texture in the geometry buffer renderer
  22099. * Useful when linking textures of the prepass renderer
  22100. */
  22101. _forceTextureType(geometryBufferType: number, index: number): void;
  22102. /**
  22103. * @hidden
  22104. * Sets texture attachments
  22105. * Useful when linking textures of the prepass renderer
  22106. */
  22107. _setAttachments(attachments: number[]): void;
  22108. /**
  22109. * @hidden
  22110. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22111. * Useful when linking textures of the prepass renderer
  22112. */
  22113. _linkInternalTexture(internalTexture: InternalTexture): void;
  22114. /**
  22115. * Gets the render list (meshes to be rendered) used in the G buffer.
  22116. */
  22117. get renderList(): Nullable<AbstractMesh[]>;
  22118. /**
  22119. * Set the render list (meshes to be rendered) used in the G buffer.
  22120. */
  22121. set renderList(meshes: Nullable<AbstractMesh[]>);
  22122. /**
  22123. * Gets wether or not G buffer are supported by the running hardware.
  22124. * This requires draw buffer supports
  22125. */
  22126. get isSupported(): boolean;
  22127. /**
  22128. * Returns the index of the given texture type in the G-Buffer textures array
  22129. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22130. * @returns the index of the given texture type in the G-Buffer textures array
  22131. */
  22132. getTextureIndex(textureType: number): number;
  22133. /**
  22134. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22135. */
  22136. get enablePosition(): boolean;
  22137. /**
  22138. * Sets whether or not objects positions are enabled for the G buffer.
  22139. */
  22140. set enablePosition(enable: boolean);
  22141. /**
  22142. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22143. */
  22144. get enableVelocity(): boolean;
  22145. /**
  22146. * Sets wether or not objects velocities are enabled for the G buffer.
  22147. */
  22148. set enableVelocity(enable: boolean);
  22149. /**
  22150. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22151. */
  22152. get enableReflectivity(): boolean;
  22153. /**
  22154. * Sets wether or not objects roughness are enabled for the G buffer.
  22155. */
  22156. set enableReflectivity(enable: boolean);
  22157. /**
  22158. * Gets the scene associated with the buffer.
  22159. */
  22160. get scene(): Scene;
  22161. /**
  22162. * Gets the ratio used by the buffer during its creation.
  22163. * How big is the buffer related to the main canvas.
  22164. */
  22165. get ratio(): number;
  22166. /** @hidden */
  22167. static _SceneComponentInitialization: (scene: Scene) => void;
  22168. /**
  22169. * Creates a new G Buffer for the scene
  22170. * @param scene The scene the buffer belongs to
  22171. * @param ratio How big is the buffer related to the main canvas.
  22172. */
  22173. constructor(scene: Scene, ratio?: number);
  22174. /**
  22175. * Checks wether everything is ready to render a submesh to the G buffer.
  22176. * @param subMesh the submesh to check readiness for
  22177. * @param useInstances is the mesh drawn using instance or not
  22178. * @returns true if ready otherwise false
  22179. */
  22180. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22181. /**
  22182. * Gets the current underlying G Buffer.
  22183. * @returns the buffer
  22184. */
  22185. getGBuffer(): MultiRenderTarget;
  22186. /**
  22187. * Gets the number of samples used to render the buffer (anti aliasing).
  22188. */
  22189. get samples(): number;
  22190. /**
  22191. * Sets the number of samples used to render the buffer (anti aliasing).
  22192. */
  22193. set samples(value: number);
  22194. /**
  22195. * Disposes the renderer and frees up associated resources.
  22196. */
  22197. dispose(): void;
  22198. private _assignRenderTargetIndices;
  22199. protected _createRenderTargets(): void;
  22200. private _copyBonesTransformationMatrices;
  22201. }
  22202. }
  22203. declare module BABYLON {
  22204. /**
  22205. * Renders a pre pass of the scene
  22206. * This means every mesh in the scene will be rendered to a render target texture
  22207. * And then this texture will be composited to the rendering canvas with post processes
  22208. * It is necessary for effects like subsurface scattering or deferred shading
  22209. */
  22210. export class PrePassRenderer {
  22211. /** @hidden */
  22212. static _SceneComponentInitialization: (scene: Scene) => void;
  22213. private _textureFormats;
  22214. /**
  22215. * To save performance, we can excluded skinned meshes from the prepass
  22216. */
  22217. excludedSkinnedMesh: AbstractMesh[];
  22218. /**
  22219. * Force material to be excluded from the prepass
  22220. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22221. * and you don't want a material to show in the effect.
  22222. */
  22223. excludedMaterials: Material[];
  22224. private _textureIndices;
  22225. private _scene;
  22226. private _engine;
  22227. private _isDirty;
  22228. /**
  22229. * Number of textures in the multi render target texture where the scene is directly rendered
  22230. */
  22231. mrtCount: number;
  22232. /**
  22233. * The render target where the scene is directly rendered
  22234. */
  22235. prePassRT: MultiRenderTarget;
  22236. private _multiRenderAttachments;
  22237. private _defaultAttachments;
  22238. private _clearAttachments;
  22239. private _postProcesses;
  22240. private readonly _clearColor;
  22241. /**
  22242. * Image processing post process for composition
  22243. */
  22244. imageProcessingPostProcess: ImageProcessingPostProcess;
  22245. /**
  22246. * Configuration for prepass effects
  22247. */
  22248. private _effectConfigurations;
  22249. private _mrtFormats;
  22250. private _mrtLayout;
  22251. private _enabled;
  22252. /**
  22253. * Indicates if the prepass is enabled
  22254. */
  22255. get enabled(): boolean;
  22256. /**
  22257. * How many samples are used for MSAA of the scene render target
  22258. */
  22259. get samples(): number;
  22260. set samples(n: number);
  22261. private _geometryBuffer;
  22262. private _useGeometryBufferFallback;
  22263. /**
  22264. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22265. */
  22266. get useGeometryBufferFallback(): boolean;
  22267. set useGeometryBufferFallback(value: boolean);
  22268. /**
  22269. * Set to true to disable gamma transform in PrePass.
  22270. * Can be useful in case you already proceed to gamma transform on a material level
  22271. * and your post processes don't need to be in linear color space.
  22272. */
  22273. disableGammaTransform: boolean;
  22274. /**
  22275. * Instanciates a prepass renderer
  22276. * @param scene The scene
  22277. */
  22278. constructor(scene: Scene);
  22279. private _initializeAttachments;
  22280. private _createCompositionEffect;
  22281. /**
  22282. * Indicates if rendering a prepass is supported
  22283. */
  22284. get isSupported(): boolean;
  22285. /**
  22286. * Sets the proper output textures to draw in the engine.
  22287. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  22288. * @param subMesh Submesh on which the effect is applied
  22289. */
  22290. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  22291. /**
  22292. * Restores attachments for single texture draw.
  22293. */
  22294. restoreAttachments(): void;
  22295. /**
  22296. * @hidden
  22297. */
  22298. _beforeCameraDraw(): void;
  22299. /**
  22300. * @hidden
  22301. */
  22302. _afterCameraDraw(): void;
  22303. private _checkRTSize;
  22304. private _bindFrameBuffer;
  22305. /**
  22306. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  22307. */
  22308. clear(): void;
  22309. private _setState;
  22310. private _updateGeometryBufferLayout;
  22311. /**
  22312. * Adds an effect configuration to the prepass.
  22313. * If an effect has already been added, it won't add it twice and will return the configuration
  22314. * already present.
  22315. * @param cfg the effect configuration
  22316. * @return the effect configuration now used by the prepass
  22317. */
  22318. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  22319. /**
  22320. * Returns the index of a texture in the multi render target texture array.
  22321. * @param type Texture type
  22322. * @return The index
  22323. */
  22324. getIndex(type: number): number;
  22325. private _enable;
  22326. private _disable;
  22327. private _resetLayout;
  22328. private _resetPostProcessChain;
  22329. private _bindPostProcessChain;
  22330. /**
  22331. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  22332. */
  22333. markAsDirty(): void;
  22334. /**
  22335. * Enables a texture on the MultiRenderTarget for prepass
  22336. */
  22337. private _enableTextures;
  22338. private _update;
  22339. private _markAllMaterialsAsPrePassDirty;
  22340. /**
  22341. * Disposes the prepass renderer.
  22342. */
  22343. dispose(): void;
  22344. }
  22345. }
  22346. declare module BABYLON {
  22347. /**
  22348. * Size options for a post process
  22349. */
  22350. export type PostProcessOptions = {
  22351. width: number;
  22352. height: number;
  22353. };
  22354. /**
  22355. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22356. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22357. */
  22358. export class PostProcess {
  22359. /**
  22360. * Gets or sets the unique id of the post process
  22361. */
  22362. uniqueId: number;
  22363. /** Name of the PostProcess. */
  22364. name: string;
  22365. /**
  22366. * Width of the texture to apply the post process on
  22367. */
  22368. width: number;
  22369. /**
  22370. * Height of the texture to apply the post process on
  22371. */
  22372. height: number;
  22373. /**
  22374. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22375. */
  22376. nodeMaterialSource: Nullable<NodeMaterial>;
  22377. /**
  22378. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22379. * @hidden
  22380. */
  22381. _outputTexture: Nullable<InternalTexture>;
  22382. /**
  22383. * Sampling mode used by the shader
  22384. * See https://doc.babylonjs.com/classes/3.1/texture
  22385. */
  22386. renderTargetSamplingMode: number;
  22387. /**
  22388. * Clear color to use when screen clearing
  22389. */
  22390. clearColor: Color4;
  22391. /**
  22392. * If the buffer needs to be cleared before applying the post process. (default: true)
  22393. * Should be set to false if shader will overwrite all previous pixels.
  22394. */
  22395. autoClear: boolean;
  22396. /**
  22397. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22398. */
  22399. alphaMode: number;
  22400. /**
  22401. * Sets the setAlphaBlendConstants of the babylon engine
  22402. */
  22403. alphaConstants: Color4;
  22404. /**
  22405. * Animations to be used for the post processing
  22406. */
  22407. animations: Animation[];
  22408. /**
  22409. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22410. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22411. */
  22412. enablePixelPerfectMode: boolean;
  22413. /**
  22414. * Force the postprocess to be applied without taking in account viewport
  22415. */
  22416. forceFullscreenViewport: boolean;
  22417. /**
  22418. * List of inspectable custom properties (used by the Inspector)
  22419. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22420. */
  22421. inspectableCustomProperties: IInspectable[];
  22422. /**
  22423. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22424. *
  22425. * | Value | Type | Description |
  22426. * | ----- | ----------------------------------- | ----------- |
  22427. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22428. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22429. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22430. *
  22431. */
  22432. scaleMode: number;
  22433. /**
  22434. * Force textures to be a power of two (default: false)
  22435. */
  22436. alwaysForcePOT: boolean;
  22437. private _samples;
  22438. /**
  22439. * Number of sample textures (default: 1)
  22440. */
  22441. get samples(): number;
  22442. set samples(n: number);
  22443. /**
  22444. * Modify the scale of the post process to be the same as the viewport (default: false)
  22445. */
  22446. adaptScaleToCurrentViewport: boolean;
  22447. private _camera;
  22448. protected _scene: Scene;
  22449. private _engine;
  22450. private _options;
  22451. private _reusable;
  22452. private _textureType;
  22453. private _textureFormat;
  22454. /**
  22455. * Smart array of input and output textures for the post process.
  22456. * @hidden
  22457. */
  22458. _textures: SmartArray<InternalTexture>;
  22459. /**
  22460. * The index in _textures that corresponds to the output texture.
  22461. * @hidden
  22462. */
  22463. _currentRenderTextureInd: number;
  22464. private _effect;
  22465. private _samplers;
  22466. private _fragmentUrl;
  22467. private _vertexUrl;
  22468. private _parameters;
  22469. private _scaleRatio;
  22470. protected _indexParameters: any;
  22471. private _shareOutputWithPostProcess;
  22472. private _texelSize;
  22473. private _forcedOutputTexture;
  22474. /**
  22475. * Prepass configuration in case this post process needs a texture from prepass
  22476. * @hidden
  22477. */
  22478. _prePassEffectConfiguration: PrePassEffectConfiguration;
  22479. /**
  22480. * Returns the fragment url or shader name used in the post process.
  22481. * @returns the fragment url or name in the shader store.
  22482. */
  22483. getEffectName(): string;
  22484. /**
  22485. * An event triggered when the postprocess is activated.
  22486. */
  22487. onActivateObservable: Observable<Camera>;
  22488. private _onActivateObserver;
  22489. /**
  22490. * A function that is added to the onActivateObservable
  22491. */
  22492. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22493. /**
  22494. * An event triggered when the postprocess changes its size.
  22495. */
  22496. onSizeChangedObservable: Observable<PostProcess>;
  22497. private _onSizeChangedObserver;
  22498. /**
  22499. * A function that is added to the onSizeChangedObservable
  22500. */
  22501. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22502. /**
  22503. * An event triggered when the postprocess applies its effect.
  22504. */
  22505. onApplyObservable: Observable<Effect>;
  22506. private _onApplyObserver;
  22507. /**
  22508. * A function that is added to the onApplyObservable
  22509. */
  22510. set onApply(callback: (effect: Effect) => void);
  22511. /**
  22512. * An event triggered before rendering the postprocess
  22513. */
  22514. onBeforeRenderObservable: Observable<Effect>;
  22515. private _onBeforeRenderObserver;
  22516. /**
  22517. * A function that is added to the onBeforeRenderObservable
  22518. */
  22519. set onBeforeRender(callback: (effect: Effect) => void);
  22520. /**
  22521. * An event triggered after rendering the postprocess
  22522. */
  22523. onAfterRenderObservable: Observable<Effect>;
  22524. private _onAfterRenderObserver;
  22525. /**
  22526. * A function that is added to the onAfterRenderObservable
  22527. */
  22528. set onAfterRender(callback: (efect: Effect) => void);
  22529. /**
  22530. * 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
  22531. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22532. */
  22533. get inputTexture(): InternalTexture;
  22534. set inputTexture(value: InternalTexture);
  22535. /**
  22536. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22537. * the only way to unset it is to use this function to restore its internal state
  22538. */
  22539. restoreDefaultInputTexture(): void;
  22540. /**
  22541. * Gets the camera which post process is applied to.
  22542. * @returns The camera the post process is applied to.
  22543. */
  22544. getCamera(): Camera;
  22545. /**
  22546. * Gets the texel size of the postprocess.
  22547. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22548. */
  22549. get texelSize(): Vector2;
  22550. /**
  22551. * Creates a new instance PostProcess
  22552. * @param name The name of the PostProcess.
  22553. * @param fragmentUrl The url of the fragment shader to be used.
  22554. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22555. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22556. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22557. * @param camera The camera to apply the render pass to.
  22558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22559. * @param engine The engine which the post process will be applied. (default: current engine)
  22560. * @param reusable If the post process can be reused on the same frame. (default: false)
  22561. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22562. * @param textureType Type of textures used when performing the post process. (default: 0)
  22563. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22564. * @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
  22565. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22566. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22567. */
  22568. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  22569. /**
  22570. * Gets a string identifying the name of the class
  22571. * @returns "PostProcess" string
  22572. */
  22573. getClassName(): string;
  22574. /**
  22575. * Gets the engine which this post process belongs to.
  22576. * @returns The engine the post process was enabled with.
  22577. */
  22578. getEngine(): Engine;
  22579. /**
  22580. * The effect that is created when initializing the post process.
  22581. * @returns The created effect corresponding the the postprocess.
  22582. */
  22583. getEffect(): Effect;
  22584. /**
  22585. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22586. * @param postProcess The post process to share the output with.
  22587. * @returns This post process.
  22588. */
  22589. shareOutputWith(postProcess: PostProcess): PostProcess;
  22590. /**
  22591. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22592. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22593. */
  22594. useOwnOutput(): void;
  22595. /**
  22596. * Updates the effect with the current post process compile time values and recompiles the shader.
  22597. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22598. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22599. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22600. * @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
  22601. * @param onCompiled Called when the shader has been compiled.
  22602. * @param onError Called if there is an error when compiling a shader.
  22603. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22604. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22605. */
  22606. 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;
  22607. /**
  22608. * The post process is reusable if it can be used multiple times within one frame.
  22609. * @returns If the post process is reusable
  22610. */
  22611. isReusable(): boolean;
  22612. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22613. markTextureDirty(): void;
  22614. /**
  22615. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22616. * 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.
  22617. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22618. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22619. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22620. * @returns The target texture that was bound to be written to.
  22621. */
  22622. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22623. /**
  22624. * If the post process is supported.
  22625. */
  22626. get isSupported(): boolean;
  22627. /**
  22628. * The aspect ratio of the output texture.
  22629. */
  22630. get aspectRatio(): number;
  22631. /**
  22632. * Get a value indicating if the post-process is ready to be used
  22633. * @returns true if the post-process is ready (shader is compiled)
  22634. */
  22635. isReady(): boolean;
  22636. /**
  22637. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22638. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22639. */
  22640. apply(): Nullable<Effect>;
  22641. private _disposeTextures;
  22642. /**
  22643. * Sets the required values to the prepass renderer.
  22644. * @param prePassRenderer defines the prepass renderer to setup.
  22645. * @returns true if the pre pass is needed.
  22646. */
  22647. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22648. /**
  22649. * Disposes the post process.
  22650. * @param camera The camera to dispose the post process on.
  22651. */
  22652. dispose(camera?: Camera): void;
  22653. /**
  22654. * Serializes the particle system to a JSON object
  22655. * @returns the JSON object
  22656. */
  22657. serialize(): any;
  22658. /**
  22659. * Creates a material from parsed material data
  22660. * @param parsedPostProcess defines parsed post process data
  22661. * @param scene defines the hosting scene
  22662. * @param rootUrl defines the root URL to use to load textures
  22663. * @returns a new post process
  22664. */
  22665. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22666. }
  22667. }
  22668. declare module BABYLON {
  22669. /** @hidden */
  22670. export var kernelBlurVaryingDeclaration: {
  22671. name: string;
  22672. shader: string;
  22673. };
  22674. }
  22675. declare module BABYLON {
  22676. /** @hidden */
  22677. export var packingFunctions: {
  22678. name: string;
  22679. shader: string;
  22680. };
  22681. }
  22682. declare module BABYLON {
  22683. /** @hidden */
  22684. export var kernelBlurFragment: {
  22685. name: string;
  22686. shader: string;
  22687. };
  22688. }
  22689. declare module BABYLON {
  22690. /** @hidden */
  22691. export var kernelBlurFragment2: {
  22692. name: string;
  22693. shader: string;
  22694. };
  22695. }
  22696. declare module BABYLON {
  22697. /** @hidden */
  22698. export var kernelBlurPixelShader: {
  22699. name: string;
  22700. shader: string;
  22701. };
  22702. }
  22703. declare module BABYLON {
  22704. /** @hidden */
  22705. export var kernelBlurVertex: {
  22706. name: string;
  22707. shader: string;
  22708. };
  22709. }
  22710. declare module BABYLON {
  22711. /** @hidden */
  22712. export var kernelBlurVertexShader: {
  22713. name: string;
  22714. shader: string;
  22715. };
  22716. }
  22717. declare module BABYLON {
  22718. /**
  22719. * The Blur Post Process which blurs an image based on a kernel and direction.
  22720. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22721. */
  22722. export class BlurPostProcess extends PostProcess {
  22723. private blockCompilation;
  22724. protected _kernel: number;
  22725. protected _idealKernel: number;
  22726. protected _packedFloat: boolean;
  22727. private _staticDefines;
  22728. /** The direction in which to blur the image. */
  22729. direction: Vector2;
  22730. /**
  22731. * Sets the length in pixels of the blur sample region
  22732. */
  22733. set kernel(v: number);
  22734. /**
  22735. * Gets the length in pixels of the blur sample region
  22736. */
  22737. get kernel(): number;
  22738. /**
  22739. * Sets wether or not the blur needs to unpack/repack floats
  22740. */
  22741. set packedFloat(v: boolean);
  22742. /**
  22743. * Gets wether or not the blur is unpacking/repacking floats
  22744. */
  22745. get packedFloat(): boolean;
  22746. /**
  22747. * Gets a string identifying the name of the class
  22748. * @returns "BlurPostProcess" string
  22749. */
  22750. getClassName(): string;
  22751. /**
  22752. * Creates a new instance BlurPostProcess
  22753. * @param name The name of the effect.
  22754. * @param direction The direction in which to blur the image.
  22755. * @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.
  22756. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22757. * @param camera The camera to apply the render pass to.
  22758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22759. * @param engine The engine which the post process will be applied. (default: current engine)
  22760. * @param reusable If the post process can be reused on the same frame. (default: false)
  22761. * @param textureType Type of textures used when performing the post process. (default: 0)
  22762. * @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)
  22763. */
  22764. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22765. /**
  22766. * Updates the effect with the current post process compile time values and recompiles the shader.
  22767. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22768. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22769. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22770. * @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
  22771. * @param onCompiled Called when the shader has been compiled.
  22772. * @param onError Called if there is an error when compiling a shader.
  22773. */
  22774. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22775. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22776. /**
  22777. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22778. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22779. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22780. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22781. * The gaps between physical kernels are compensated for in the weighting of the samples
  22782. * @param idealKernel Ideal blur kernel.
  22783. * @return Nearest best kernel.
  22784. */
  22785. protected _nearestBestKernel(idealKernel: number): number;
  22786. /**
  22787. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22788. * @param x The point on the Gaussian distribution to sample.
  22789. * @return the value of the Gaussian function at x.
  22790. */
  22791. protected _gaussianWeight(x: number): number;
  22792. /**
  22793. * Generates a string that can be used as a floating point number in GLSL.
  22794. * @param x Value to print.
  22795. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22796. * @return GLSL float string.
  22797. */
  22798. protected _glslFloat(x: number, decimalFigures?: number): string;
  22799. /** @hidden */
  22800. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  22801. }
  22802. }
  22803. declare module BABYLON {
  22804. /**
  22805. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22806. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22807. * You can then easily use it as a reflectionTexture on a flat surface.
  22808. * In case the surface is not a plane, please consider relying on reflection probes.
  22809. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22810. */
  22811. export class MirrorTexture extends RenderTargetTexture {
  22812. private scene;
  22813. /**
  22814. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22815. * 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.
  22816. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22817. */
  22818. mirrorPlane: Plane;
  22819. /**
  22820. * Define the blur ratio used to blur the reflection if needed.
  22821. */
  22822. set blurRatio(value: number);
  22823. get blurRatio(): number;
  22824. /**
  22825. * Define the adaptive blur kernel used to blur the reflection if needed.
  22826. * This will autocompute the closest best match for the `blurKernel`
  22827. */
  22828. set adaptiveBlurKernel(value: number);
  22829. /**
  22830. * Define the blur kernel used to blur the reflection if needed.
  22831. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22832. */
  22833. set blurKernel(value: number);
  22834. /**
  22835. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22836. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22837. */
  22838. set blurKernelX(value: number);
  22839. get blurKernelX(): number;
  22840. /**
  22841. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22842. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22843. */
  22844. set blurKernelY(value: number);
  22845. get blurKernelY(): number;
  22846. private _autoComputeBlurKernel;
  22847. protected _onRatioRescale(): void;
  22848. private _updateGammaSpace;
  22849. private _imageProcessingConfigChangeObserver;
  22850. private _transformMatrix;
  22851. private _mirrorMatrix;
  22852. private _savedViewMatrix;
  22853. private _blurX;
  22854. private _blurY;
  22855. private _adaptiveBlurKernel;
  22856. private _blurKernelX;
  22857. private _blurKernelY;
  22858. private _blurRatio;
  22859. /**
  22860. * Instantiates a Mirror Texture.
  22861. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22862. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22863. * You can then easily use it as a reflectionTexture on a flat surface.
  22864. * In case the surface is not a plane, please consider relying on reflection probes.
  22865. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22866. * @param name
  22867. * @param size
  22868. * @param scene
  22869. * @param generateMipMaps
  22870. * @param type
  22871. * @param samplingMode
  22872. * @param generateDepthBuffer
  22873. */
  22874. constructor(name: string, size: number | {
  22875. width: number;
  22876. height: number;
  22877. } | {
  22878. ratio: number;
  22879. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22880. private _preparePostProcesses;
  22881. /**
  22882. * Clone the mirror texture.
  22883. * @returns the cloned texture
  22884. */
  22885. clone(): MirrorTexture;
  22886. /**
  22887. * Serialize the texture to a JSON representation you could use in Parse later on
  22888. * @returns the serialized JSON representation
  22889. */
  22890. serialize(): any;
  22891. /**
  22892. * Dispose the texture and release its associated resources.
  22893. */
  22894. dispose(): void;
  22895. }
  22896. }
  22897. declare module BABYLON {
  22898. /**
  22899. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22900. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22901. */
  22902. export class Texture extends BaseTexture {
  22903. /**
  22904. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22905. */
  22906. static SerializeBuffers: boolean;
  22907. /**
  22908. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  22909. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  22910. */
  22911. static ForceSerializeBuffers: boolean;
  22912. /** @hidden */
  22913. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22914. /** @hidden */
  22915. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22916. /** @hidden */
  22917. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22918. /** nearest is mag = nearest and min = nearest and mip = linear */
  22919. static readonly NEAREST_SAMPLINGMODE: number;
  22920. /** nearest is mag = nearest and min = nearest and mip = linear */
  22921. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22922. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22923. static readonly BILINEAR_SAMPLINGMODE: number;
  22924. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22925. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22926. /** Trilinear is mag = linear and min = linear and mip = linear */
  22927. static readonly TRILINEAR_SAMPLINGMODE: number;
  22928. /** Trilinear is mag = linear and min = linear and mip = linear */
  22929. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22930. /** mag = nearest and min = nearest and mip = nearest */
  22931. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22932. /** mag = nearest and min = linear and mip = nearest */
  22933. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22934. /** mag = nearest and min = linear and mip = linear */
  22935. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22936. /** mag = nearest and min = linear and mip = none */
  22937. static readonly NEAREST_LINEAR: number;
  22938. /** mag = nearest and min = nearest and mip = none */
  22939. static readonly NEAREST_NEAREST: number;
  22940. /** mag = linear and min = nearest and mip = nearest */
  22941. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22942. /** mag = linear and min = nearest and mip = linear */
  22943. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22944. /** mag = linear and min = linear and mip = none */
  22945. static readonly LINEAR_LINEAR: number;
  22946. /** mag = linear and min = nearest and mip = none */
  22947. static readonly LINEAR_NEAREST: number;
  22948. /** Explicit coordinates mode */
  22949. static readonly EXPLICIT_MODE: number;
  22950. /** Spherical coordinates mode */
  22951. static readonly SPHERICAL_MODE: number;
  22952. /** Planar coordinates mode */
  22953. static readonly PLANAR_MODE: number;
  22954. /** Cubic coordinates mode */
  22955. static readonly CUBIC_MODE: number;
  22956. /** Projection coordinates mode */
  22957. static readonly PROJECTION_MODE: number;
  22958. /** Inverse Cubic coordinates mode */
  22959. static readonly SKYBOX_MODE: number;
  22960. /** Inverse Cubic coordinates mode */
  22961. static readonly INVCUBIC_MODE: number;
  22962. /** Equirectangular coordinates mode */
  22963. static readonly EQUIRECTANGULAR_MODE: number;
  22964. /** Equirectangular Fixed coordinates mode */
  22965. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22966. /** Equirectangular Fixed Mirrored coordinates mode */
  22967. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22968. /** Texture is not repeating outside of 0..1 UVs */
  22969. static readonly CLAMP_ADDRESSMODE: number;
  22970. /** Texture is repeating outside of 0..1 UVs */
  22971. static readonly WRAP_ADDRESSMODE: number;
  22972. /** Texture is repeating and mirrored */
  22973. static readonly MIRROR_ADDRESSMODE: number;
  22974. /**
  22975. * 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
  22976. */
  22977. static UseSerializedUrlIfAny: boolean;
  22978. /**
  22979. * Define the url of the texture.
  22980. */
  22981. url: Nullable<string>;
  22982. /**
  22983. * Define an offset on the texture to offset the u coordinates of the UVs
  22984. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22985. */
  22986. uOffset: number;
  22987. /**
  22988. * Define an offset on the texture to offset the v coordinates of the UVs
  22989. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22990. */
  22991. vOffset: number;
  22992. /**
  22993. * Define an offset on the texture to scale the u coordinates of the UVs
  22994. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22995. */
  22996. uScale: number;
  22997. /**
  22998. * Define an offset on the texture to scale the v coordinates of the UVs
  22999. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23000. */
  23001. vScale: number;
  23002. /**
  23003. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23004. * @see https://doc.babylonjs.com/how_to/more_materials
  23005. */
  23006. uAng: number;
  23007. /**
  23008. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23009. * @see https://doc.babylonjs.com/how_to/more_materials
  23010. */
  23011. vAng: number;
  23012. /**
  23013. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23014. * @see https://doc.babylonjs.com/how_to/more_materials
  23015. */
  23016. wAng: number;
  23017. /**
  23018. * Defines the center of rotation (U)
  23019. */
  23020. uRotationCenter: number;
  23021. /**
  23022. * Defines the center of rotation (V)
  23023. */
  23024. vRotationCenter: number;
  23025. /**
  23026. * Defines the center of rotation (W)
  23027. */
  23028. wRotationCenter: number;
  23029. /**
  23030. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23031. */
  23032. homogeneousRotationInUVTransform: boolean;
  23033. /**
  23034. * Are mip maps generated for this texture or not.
  23035. */
  23036. get noMipmap(): boolean;
  23037. /**
  23038. * List of inspectable custom properties (used by the Inspector)
  23039. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23040. */
  23041. inspectableCustomProperties: Nullable<IInspectable[]>;
  23042. private _noMipmap;
  23043. /** @hidden */
  23044. _invertY: boolean;
  23045. private _rowGenerationMatrix;
  23046. private _cachedTextureMatrix;
  23047. private _projectionModeMatrix;
  23048. private _t0;
  23049. private _t1;
  23050. private _t2;
  23051. private _cachedUOffset;
  23052. private _cachedVOffset;
  23053. private _cachedUScale;
  23054. private _cachedVScale;
  23055. private _cachedUAng;
  23056. private _cachedVAng;
  23057. private _cachedWAng;
  23058. private _cachedProjectionMatrixId;
  23059. private _cachedURotationCenter;
  23060. private _cachedVRotationCenter;
  23061. private _cachedWRotationCenter;
  23062. private _cachedHomogeneousRotationInUVTransform;
  23063. private _cachedCoordinatesMode;
  23064. /** @hidden */
  23065. protected _initialSamplingMode: number;
  23066. /** @hidden */
  23067. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23068. private _deleteBuffer;
  23069. protected _format: Nullable<number>;
  23070. private _delayedOnLoad;
  23071. private _delayedOnError;
  23072. private _mimeType?;
  23073. private _loaderOptions?;
  23074. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23075. get mimeType(): string | undefined;
  23076. /**
  23077. * Observable triggered once the texture has been loaded.
  23078. */
  23079. onLoadObservable: Observable<Texture>;
  23080. protected _isBlocking: boolean;
  23081. /**
  23082. * Is the texture preventing material to render while loading.
  23083. * If false, a default texture will be used instead of the loading one during the preparation step.
  23084. */
  23085. set isBlocking(value: boolean);
  23086. get isBlocking(): boolean;
  23087. /**
  23088. * Get the current sampling mode associated with the texture.
  23089. */
  23090. get samplingMode(): number;
  23091. /**
  23092. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23093. */
  23094. get invertY(): boolean;
  23095. /**
  23096. * Instantiates a new texture.
  23097. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23098. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23099. * @param url defines the url of the picture to load as a texture
  23100. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23101. * @param noMipmap defines if the texture will require mip maps or not
  23102. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23103. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23104. * @param onLoad defines a callback triggered when the texture has been loaded
  23105. * @param onError defines a callback triggered when an error occurred during the loading session
  23106. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23107. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23108. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23109. * @param mimeType defines an optional mime type information
  23110. * @param loaderOptions options to be passed to the loader
  23111. */
  23112. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  23113. /**
  23114. * Update the url (and optional buffer) of this texture if url was null during construction.
  23115. * @param url the url of the texture
  23116. * @param buffer the buffer of the texture (defaults to null)
  23117. * @param onLoad callback called when the texture is loaded (defaults to null)
  23118. */
  23119. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23120. /**
  23121. * Finish the loading sequence of a texture flagged as delayed load.
  23122. * @hidden
  23123. */
  23124. delayLoad(): void;
  23125. private _prepareRowForTextureGeneration;
  23126. /**
  23127. * Checks if the texture has the same transform matrix than another texture
  23128. * @param texture texture to check against
  23129. * @returns true if the transforms are the same, else false
  23130. */
  23131. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23132. /**
  23133. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23134. * @returns the transform matrix of the texture.
  23135. */
  23136. getTextureMatrix(uBase?: number): Matrix;
  23137. /**
  23138. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23139. * @returns The reflection texture transform
  23140. */
  23141. getReflectionTextureMatrix(): Matrix;
  23142. /**
  23143. * Clones the texture.
  23144. * @returns the cloned texture
  23145. */
  23146. clone(): Texture;
  23147. /**
  23148. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23149. * @returns The JSON representation of the texture
  23150. */
  23151. serialize(): any;
  23152. /**
  23153. * Get the current class name of the texture useful for serialization or dynamic coding.
  23154. * @returns "Texture"
  23155. */
  23156. getClassName(): string;
  23157. /**
  23158. * Dispose the texture and release its associated resources.
  23159. */
  23160. dispose(): void;
  23161. /**
  23162. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23163. * @param parsedTexture Define the JSON representation of the texture
  23164. * @param scene Define the scene the parsed texture should be instantiated in
  23165. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23166. * @returns The parsed texture if successful
  23167. */
  23168. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23169. /**
  23170. * Creates a texture from its base 64 representation.
  23171. * @param data Define the base64 payload without the data: prefix
  23172. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23173. * @param scene Define the scene the texture should belong to
  23174. * @param noMipmap Forces the texture to not create mip map information if true
  23175. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23176. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23177. * @param onLoad define a callback triggered when the texture has been loaded
  23178. * @param onError define a callback triggered when an error occurred during the loading session
  23179. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23180. * @returns the created texture
  23181. */
  23182. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23183. /**
  23184. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23185. * @param data Define the base64 payload without the data: prefix
  23186. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23187. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23188. * @param scene Define the scene the texture should belong to
  23189. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23190. * @param noMipmap Forces the texture to not create mip map information if true
  23191. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23192. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23193. * @param onLoad define a callback triggered when the texture has been loaded
  23194. * @param onError define a callback triggered when an error occurred during the loading session
  23195. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23196. * @returns the created texture
  23197. */
  23198. 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;
  23199. }
  23200. }
  23201. declare module BABYLON {
  23202. /**
  23203. * ThinSprite Class used to represent a thin sprite
  23204. * This is the base class for sprites but can also directly be used with ThinEngine
  23205. * @see https://doc.babylonjs.com/babylon101/sprites
  23206. */
  23207. export class ThinSprite {
  23208. /** Gets or sets the cell index in the sprite sheet */
  23209. cellIndex: number;
  23210. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23211. cellRef: string;
  23212. /** Gets or sets the current world position */
  23213. position: IVector3Like;
  23214. /** Gets or sets the main color */
  23215. color: IColor4Like;
  23216. /** Gets or sets the width */
  23217. width: number;
  23218. /** Gets or sets the height */
  23219. height: number;
  23220. /** Gets or sets rotation angle */
  23221. angle: number;
  23222. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23223. invertU: boolean;
  23224. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23225. invertV: boolean;
  23226. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23227. isVisible: boolean;
  23228. /**
  23229. * Returns a boolean indicating if the animation is started
  23230. */
  23231. get animationStarted(): boolean;
  23232. /** Gets the initial key for the animation (setting it will restart the animation) */
  23233. get fromIndex(): number;
  23234. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23235. get toIndex(): number;
  23236. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23237. get loopAnimation(): boolean;
  23238. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23239. get delay(): number;
  23240. /** @hidden */
  23241. _xOffset: number;
  23242. /** @hidden */
  23243. _yOffset: number;
  23244. /** @hidden */
  23245. _xSize: number;
  23246. /** @hidden */
  23247. _ySize: number;
  23248. private _animationStarted;
  23249. protected _loopAnimation: boolean;
  23250. protected _fromIndex: number;
  23251. protected _toIndex: number;
  23252. protected _delay: number;
  23253. private _direction;
  23254. private _time;
  23255. private _onBaseAnimationEnd;
  23256. /**
  23257. * Creates a new Thin Sprite
  23258. */
  23259. constructor();
  23260. /**
  23261. * Starts an animation
  23262. * @param from defines the initial key
  23263. * @param to defines the end key
  23264. * @param loop defines if the animation must loop
  23265. * @param delay defines the start delay (in ms)
  23266. * @param onAnimationEnd defines a callback for when the animation ends
  23267. */
  23268. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  23269. /** Stops current animation (if any) */
  23270. stopAnimation(): void;
  23271. /** @hidden */
  23272. _animate(deltaTime: number): void;
  23273. }
  23274. }
  23275. declare module BABYLON {
  23276. /** @hidden */
  23277. export var imageProcessingCompatibility: {
  23278. name: string;
  23279. shader: string;
  23280. };
  23281. }
  23282. declare module BABYLON {
  23283. /** @hidden */
  23284. export var spritesPixelShader: {
  23285. name: string;
  23286. shader: string;
  23287. };
  23288. }
  23289. declare module BABYLON {
  23290. /** @hidden */
  23291. export var spritesVertexShader: {
  23292. name: string;
  23293. shader: string;
  23294. };
  23295. }
  23296. declare module BABYLON {
  23297. /**
  23298. * Class used to render sprites.
  23299. *
  23300. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  23301. */
  23302. export class SpriteRenderer {
  23303. /**
  23304. * Defines the texture of the spritesheet
  23305. */
  23306. texture: Nullable<ThinTexture>;
  23307. /**
  23308. * Defines the default width of a cell in the spritesheet
  23309. */
  23310. cellWidth: number;
  23311. /**
  23312. * Defines the default height of a cell in the spritesheet
  23313. */
  23314. cellHeight: number;
  23315. /**
  23316. * Blend mode use to render the particle, it can be any of
  23317. * the static Constants.ALPHA_x properties provided in this class.
  23318. * Default value is Constants.ALPHA_COMBINE
  23319. */
  23320. blendMode: number;
  23321. /**
  23322. * Gets or sets a boolean indicating if alpha mode is automatically
  23323. * reset.
  23324. */
  23325. autoResetAlpha: boolean;
  23326. /**
  23327. * Disables writing to the depth buffer when rendering the sprites.
  23328. * It can be handy to disable depth writing when using textures without alpha channel
  23329. * and setting some specific blend modes.
  23330. */
  23331. disableDepthWrite: boolean;
  23332. /**
  23333. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  23334. */
  23335. fogEnabled: boolean;
  23336. /**
  23337. * Gets the capacity of the manager
  23338. */
  23339. get capacity(): number;
  23340. private readonly _engine;
  23341. private readonly _useVAO;
  23342. private readonly _useInstancing;
  23343. private readonly _scene;
  23344. private readonly _capacity;
  23345. private readonly _epsilon;
  23346. private _vertexBufferSize;
  23347. private _vertexData;
  23348. private _buffer;
  23349. private _vertexBuffers;
  23350. private _spriteBuffer;
  23351. private _indexBuffer;
  23352. private _effectBase;
  23353. private _effectFog;
  23354. private _vertexArrayObject;
  23355. /**
  23356. * Creates a new sprite Renderer
  23357. * @param engine defines the engine the renderer works with
  23358. * @param capacity defines the maximum allowed number of sprites
  23359. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23360. * @param scene defines the hosting scene
  23361. */
  23362. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  23363. /**
  23364. * Render all child sprites
  23365. * @param sprites defines the list of sprites to render
  23366. * @param deltaTime defines the time since last frame
  23367. * @param viewMatrix defines the viewMatrix to use to render the sprites
  23368. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  23369. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  23370. */
  23371. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  23372. private _appendSpriteVertex;
  23373. /**
  23374. * Release associated resources
  23375. */
  23376. dispose(): void;
  23377. }
  23378. }
  23379. declare module BABYLON {
  23380. /**
  23381. * Defines the minimum interface to fullfil in order to be a sprite manager.
  23382. */
  23383. export interface ISpriteManager extends IDisposable {
  23384. /**
  23385. * Gets manager's name
  23386. */
  23387. name: string;
  23388. /**
  23389. * Restricts the camera to viewing objects with the same layerMask.
  23390. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  23391. */
  23392. layerMask: number;
  23393. /**
  23394. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23395. */
  23396. isPickable: boolean;
  23397. /**
  23398. * Gets the hosting scene
  23399. */
  23400. scene: Scene;
  23401. /**
  23402. * Specifies the rendering group id for this mesh (0 by default)
  23403. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23404. */
  23405. renderingGroupId: number;
  23406. /**
  23407. * Defines the list of sprites managed by the manager.
  23408. */
  23409. sprites: Array<Sprite>;
  23410. /**
  23411. * Gets or sets the spritesheet texture
  23412. */
  23413. texture: Texture;
  23414. /** Defines the default width of a cell in the spritesheet */
  23415. cellWidth: number;
  23416. /** Defines the default height of a cell in the spritesheet */
  23417. cellHeight: number;
  23418. /**
  23419. * Tests the intersection of a sprite with a specific ray.
  23420. * @param ray The ray we are sending to test the collision
  23421. * @param camera The camera space we are sending rays in
  23422. * @param predicate A predicate allowing excluding sprites from the list of object to test
  23423. * @param fastCheck defines if the first intersection will be used (and not the closest)
  23424. * @returns picking info or null.
  23425. */
  23426. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23427. /**
  23428. * Intersects the sprites with a ray
  23429. * @param ray defines the ray to intersect with
  23430. * @param camera defines the current active camera
  23431. * @param predicate defines a predicate used to select candidate sprites
  23432. * @returns null if no hit or a PickingInfo array
  23433. */
  23434. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23435. /**
  23436. * Renders the list of sprites on screen.
  23437. */
  23438. render(): void;
  23439. }
  23440. /**
  23441. * Class used to manage multiple sprites on the same spritesheet
  23442. * @see https://doc.babylonjs.com/babylon101/sprites
  23443. */
  23444. export class SpriteManager implements ISpriteManager {
  23445. /** defines the manager's name */
  23446. name: string;
  23447. /** Define the Url to load snippets */
  23448. static SnippetUrl: string;
  23449. /** Snippet ID if the manager was created from the snippet server */
  23450. snippetId: string;
  23451. /** Gets the list of sprites */
  23452. sprites: Sprite[];
  23453. /** Gets or sets the rendering group id (0 by default) */
  23454. renderingGroupId: number;
  23455. /** Gets or sets camera layer mask */
  23456. layerMask: number;
  23457. /** Gets or sets a boolean indicating if the sprites are pickable */
  23458. isPickable: boolean;
  23459. /**
  23460. * An event triggered when the manager is disposed.
  23461. */
  23462. onDisposeObservable: Observable<SpriteManager>;
  23463. /**
  23464. * Callback called when the manager is disposed
  23465. */
  23466. set onDispose(callback: () => void);
  23467. /**
  23468. * Gets or sets the unique id of the sprite
  23469. */
  23470. uniqueId: number;
  23471. /**
  23472. * Gets the array of sprites
  23473. */
  23474. get children(): Sprite[];
  23475. /**
  23476. * Gets the hosting scene
  23477. */
  23478. get scene(): Scene;
  23479. /**
  23480. * Gets the capacity of the manager
  23481. */
  23482. get capacity(): number;
  23483. /**
  23484. * Gets or sets the spritesheet texture
  23485. */
  23486. get texture(): Texture;
  23487. set texture(value: Texture);
  23488. /** Defines the default width of a cell in the spritesheet */
  23489. get cellWidth(): number;
  23490. set cellWidth(value: number);
  23491. /** Defines the default height of a cell in the spritesheet */
  23492. get cellHeight(): number;
  23493. set cellHeight(value: number);
  23494. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  23495. get fogEnabled(): boolean;
  23496. set fogEnabled(value: boolean);
  23497. /**
  23498. * Blend mode use to render the particle, it can be any of
  23499. * the static Constants.ALPHA_x properties provided in this class.
  23500. * Default value is Constants.ALPHA_COMBINE
  23501. */
  23502. get blendMode(): number;
  23503. set blendMode(blendMode: number);
  23504. /** Disables writing to the depth buffer when rendering the sprites.
  23505. * It can be handy to disable depth writing when using textures without alpha channel
  23506. * and setting some specific blend modes.
  23507. */
  23508. disableDepthWrite: boolean;
  23509. private _spriteRenderer;
  23510. /** Associative array from JSON sprite data file */
  23511. private _cellData;
  23512. /** Array of sprite names from JSON sprite data file */
  23513. private _spriteMap;
  23514. /** True when packed cell data from JSON file is ready*/
  23515. private _packedAndReady;
  23516. private _textureContent;
  23517. private _onDisposeObserver;
  23518. private _fromPacked;
  23519. private _scene;
  23520. /**
  23521. * Creates a new sprite manager
  23522. * @param name defines the manager's name
  23523. * @param imgUrl defines the sprite sheet url
  23524. * @param capacity defines the maximum allowed number of sprites
  23525. * @param cellSize defines the size of a sprite cell
  23526. * @param scene defines the hosting scene
  23527. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23528. * @param samplingMode defines the smapling mode to use with spritesheet
  23529. * @param fromPacked set to false; do not alter
  23530. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  23531. */
  23532. constructor(
  23533. /** defines the manager's name */
  23534. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  23535. /**
  23536. * Returns the string "SpriteManager"
  23537. * @returns "SpriteManager"
  23538. */
  23539. getClassName(): string;
  23540. private _makePacked;
  23541. private _checkTextureAlpha;
  23542. /**
  23543. * Intersects the sprites with a ray
  23544. * @param ray defines the ray to intersect with
  23545. * @param camera defines the current active camera
  23546. * @param predicate defines a predicate used to select candidate sprites
  23547. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  23548. * @returns null if no hit or a PickingInfo
  23549. */
  23550. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23551. /**
  23552. * Intersects the sprites with a ray
  23553. * @param ray defines the ray to intersect with
  23554. * @param camera defines the current active camera
  23555. * @param predicate defines a predicate used to select candidate sprites
  23556. * @returns null if no hit or a PickingInfo array
  23557. */
  23558. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23559. /**
  23560. * Render all child sprites
  23561. */
  23562. render(): void;
  23563. private _customUpdate;
  23564. /**
  23565. * Release associated resources
  23566. */
  23567. dispose(): void;
  23568. /**
  23569. * Serializes the sprite manager to a JSON object
  23570. * @param serializeTexture defines if the texture must be serialized as well
  23571. * @returns the JSON object
  23572. */
  23573. serialize(serializeTexture?: boolean): any;
  23574. /**
  23575. * Parses a JSON object to create a new sprite manager.
  23576. * @param parsedManager The JSON object to parse
  23577. * @param scene The scene to create the sprite managerin
  23578. * @param rootUrl The root url to use to load external dependencies like texture
  23579. * @returns the new sprite manager
  23580. */
  23581. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  23582. /**
  23583. * Creates a sprite manager from a snippet saved in a remote file
  23584. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  23585. * @param url defines the url to load from
  23586. * @param scene defines the hosting scene
  23587. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23588. * @returns a promise that will resolve to the new sprite manager
  23589. */
  23590. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23591. /**
  23592. * Creates a sprite manager from a snippet saved by the sprite editor
  23593. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  23594. * @param scene defines the hosting scene
  23595. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23596. * @returns a promise that will resolve to the new sprite manager
  23597. */
  23598. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23599. }
  23600. }
  23601. declare module BABYLON {
  23602. /**
  23603. * Class used to represent a sprite
  23604. * @see https://doc.babylonjs.com/babylon101/sprites
  23605. */
  23606. export class Sprite extends ThinSprite implements IAnimatable {
  23607. /** defines the name */
  23608. name: string;
  23609. /** Gets or sets the current world position */
  23610. position: Vector3;
  23611. /** Gets or sets the main color */
  23612. color: Color4;
  23613. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  23614. disposeWhenFinishedAnimating: boolean;
  23615. /** Gets the list of attached animations */
  23616. animations: Nullable<Array<Animation>>;
  23617. /** Gets or sets a boolean indicating if the sprite can be picked */
  23618. isPickable: boolean;
  23619. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  23620. useAlphaForPicking: boolean;
  23621. /**
  23622. * Gets or sets the associated action manager
  23623. */
  23624. actionManager: Nullable<ActionManager>;
  23625. /**
  23626. * An event triggered when the control has been disposed
  23627. */
  23628. onDisposeObservable: Observable<Sprite>;
  23629. private _manager;
  23630. private _onAnimationEnd;
  23631. /**
  23632. * Gets or sets the sprite size
  23633. */
  23634. get size(): number;
  23635. set size(value: number);
  23636. /**
  23637. * Gets or sets the unique id of the sprite
  23638. */
  23639. uniqueId: number;
  23640. /**
  23641. * Gets the manager of this sprite
  23642. */
  23643. get manager(): ISpriteManager;
  23644. /**
  23645. * Creates a new Sprite
  23646. * @param name defines the name
  23647. * @param manager defines the manager
  23648. */
  23649. constructor(
  23650. /** defines the name */
  23651. name: string, manager: ISpriteManager);
  23652. /**
  23653. * Returns the string "Sprite"
  23654. * @returns "Sprite"
  23655. */
  23656. getClassName(): string;
  23657. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  23658. get fromIndex(): number;
  23659. set fromIndex(value: number);
  23660. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23661. get toIndex(): number;
  23662. set toIndex(value: number);
  23663. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23664. get loopAnimation(): boolean;
  23665. set loopAnimation(value: boolean);
  23666. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23667. get delay(): number;
  23668. set delay(value: number);
  23669. /**
  23670. * Starts an animation
  23671. * @param from defines the initial key
  23672. * @param to defines the end key
  23673. * @param loop defines if the animation must loop
  23674. * @param delay defines the start delay (in ms)
  23675. * @param onAnimationEnd defines a callback to call when animation ends
  23676. */
  23677. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  23678. private _endAnimation;
  23679. /** Release associated resources */
  23680. dispose(): void;
  23681. /**
  23682. * Serializes the sprite to a JSON object
  23683. * @returns the JSON object
  23684. */
  23685. serialize(): any;
  23686. /**
  23687. * Parses a JSON object to create a new sprite
  23688. * @param parsedSprite The JSON object to parse
  23689. * @param manager defines the hosting manager
  23690. * @returns the new sprite
  23691. */
  23692. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  23693. }
  23694. }
  23695. declare module BABYLON {
  23696. /**
  23697. * Information about the result of picking within a scene
  23698. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23699. */
  23700. export class PickingInfo {
  23701. /** @hidden */
  23702. _pickingUnavailable: boolean;
  23703. /**
  23704. * If the pick collided with an object
  23705. */
  23706. hit: boolean;
  23707. /**
  23708. * Distance away where the pick collided
  23709. */
  23710. distance: number;
  23711. /**
  23712. * The location of pick collision
  23713. */
  23714. pickedPoint: Nullable<Vector3>;
  23715. /**
  23716. * The mesh corresponding the the pick collision
  23717. */
  23718. pickedMesh: Nullable<AbstractMesh>;
  23719. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  23720. bu: number;
  23721. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  23722. bv: number;
  23723. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23724. faceId: number;
  23725. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23726. subMeshFaceId: number;
  23727. /** Id of the the submesh that was picked */
  23728. subMeshId: number;
  23729. /** If a sprite was picked, this will be the sprite the pick collided with */
  23730. pickedSprite: Nullable<Sprite>;
  23731. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  23732. thinInstanceIndex: number;
  23733. /**
  23734. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23735. */
  23736. originMesh: Nullable<AbstractMesh>;
  23737. /**
  23738. * The ray that was used to perform the picking.
  23739. */
  23740. ray: Nullable<Ray>;
  23741. /**
  23742. * Gets the normal correspodning to the face the pick collided with
  23743. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23744. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23745. * @returns The normal correspodning to the face the pick collided with
  23746. */
  23747. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  23748. /**
  23749. * Gets the texture coordinates of where the pick occured
  23750. * @returns the vector containing the coordnates of the texture
  23751. */
  23752. getTextureCoordinates(): Nullable<Vector2>;
  23753. }
  23754. }
  23755. declare module BABYLON {
  23756. /**
  23757. * Gather the list of pointer event types as constants.
  23758. */
  23759. export class PointerEventTypes {
  23760. /**
  23761. * 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.
  23762. */
  23763. static readonly POINTERDOWN: number;
  23764. /**
  23765. * The pointerup event is fired when a pointer is no longer active.
  23766. */
  23767. static readonly POINTERUP: number;
  23768. /**
  23769. * The pointermove event is fired when a pointer changes coordinates.
  23770. */
  23771. static readonly POINTERMOVE: number;
  23772. /**
  23773. * The pointerwheel event is fired when a mouse wheel has been rotated.
  23774. */
  23775. static readonly POINTERWHEEL: number;
  23776. /**
  23777. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  23778. */
  23779. static readonly POINTERPICK: number;
  23780. /**
  23781. * The pointertap event is fired when a the object has been touched and released without drag.
  23782. */
  23783. static readonly POINTERTAP: number;
  23784. /**
  23785. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  23786. */
  23787. static readonly POINTERDOUBLETAP: number;
  23788. }
  23789. /**
  23790. * Base class of pointer info types.
  23791. */
  23792. export class PointerInfoBase {
  23793. /**
  23794. * Defines the type of event (PointerEventTypes)
  23795. */
  23796. type: number;
  23797. /**
  23798. * Defines the related dom event
  23799. */
  23800. event: PointerEvent | MouseWheelEvent;
  23801. /**
  23802. * Instantiates the base class of pointers info.
  23803. * @param type Defines the type of event (PointerEventTypes)
  23804. * @param event Defines the related dom event
  23805. */
  23806. constructor(
  23807. /**
  23808. * Defines the type of event (PointerEventTypes)
  23809. */
  23810. type: number,
  23811. /**
  23812. * Defines the related dom event
  23813. */
  23814. event: PointerEvent | MouseWheelEvent);
  23815. }
  23816. /**
  23817. * This class is used to store pointer related info for the onPrePointerObservable event.
  23818. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  23819. */
  23820. export class PointerInfoPre extends PointerInfoBase {
  23821. /**
  23822. * Ray from a pointer if availible (eg. 6dof controller)
  23823. */
  23824. ray: Nullable<Ray>;
  23825. /**
  23826. * Defines the local position of the pointer on the canvas.
  23827. */
  23828. localPosition: Vector2;
  23829. /**
  23830. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  23831. */
  23832. skipOnPointerObservable: boolean;
  23833. /**
  23834. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  23835. * @param type Defines the type of event (PointerEventTypes)
  23836. * @param event Defines the related dom event
  23837. * @param localX Defines the local x coordinates of the pointer when the event occured
  23838. * @param localY Defines the local y coordinates of the pointer when the event occured
  23839. */
  23840. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  23841. }
  23842. /**
  23843. * This type contains all the data related to a pointer event in Babylon.js.
  23844. * 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.
  23845. */
  23846. export class PointerInfo extends PointerInfoBase {
  23847. /**
  23848. * Defines the picking info associated to the info (if any)\
  23849. */
  23850. pickInfo: Nullable<PickingInfo>;
  23851. /**
  23852. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  23853. * @param type Defines the type of event (PointerEventTypes)
  23854. * @param event Defines the related dom event
  23855. * @param pickInfo Defines the picking info associated to the info (if any)\
  23856. */
  23857. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  23858. /**
  23859. * Defines the picking info associated to the info (if any)\
  23860. */
  23861. pickInfo: Nullable<PickingInfo>);
  23862. }
  23863. /**
  23864. * Data relating to a touch event on the screen.
  23865. */
  23866. export interface PointerTouch {
  23867. /**
  23868. * X coordinate of touch.
  23869. */
  23870. x: number;
  23871. /**
  23872. * Y coordinate of touch.
  23873. */
  23874. y: number;
  23875. /**
  23876. * Id of touch. Unique for each finger.
  23877. */
  23878. pointerId: number;
  23879. /**
  23880. * Event type passed from DOM.
  23881. */
  23882. type: any;
  23883. }
  23884. }
  23885. declare module BABYLON {
  23886. /**
  23887. * Manage the mouse inputs to control the movement of a free camera.
  23888. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23889. */
  23890. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  23891. /**
  23892. * Define if touch is enabled in the mouse input
  23893. */
  23894. touchEnabled: boolean;
  23895. /**
  23896. * Defines the camera the input is attached to.
  23897. */
  23898. camera: FreeCamera;
  23899. /**
  23900. * Defines the buttons associated with the input to handle camera move.
  23901. */
  23902. buttons: number[];
  23903. /**
  23904. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  23905. */
  23906. angularSensibility: number;
  23907. private _pointerInput;
  23908. private _onMouseMove;
  23909. private _observer;
  23910. private previousPosition;
  23911. /**
  23912. * Observable for when a pointer move event occurs containing the move offset
  23913. */
  23914. onPointerMovedObservable: Observable<{
  23915. offsetX: number;
  23916. offsetY: number;
  23917. }>;
  23918. /**
  23919. * @hidden
  23920. * If the camera should be rotated automatically based on pointer movement
  23921. */
  23922. _allowCameraRotation: boolean;
  23923. /**
  23924. * Manage the mouse inputs to control the movement of a free camera.
  23925. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23926. * @param touchEnabled Defines if touch is enabled or not
  23927. */
  23928. constructor(
  23929. /**
  23930. * Define if touch is enabled in the mouse input
  23931. */
  23932. touchEnabled?: boolean);
  23933. /**
  23934. * Attach the input controls to a specific dom element to get the input from.
  23935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23936. */
  23937. attachControl(noPreventDefault?: boolean): void;
  23938. /**
  23939. * Called on JS contextmenu event.
  23940. * Override this method to provide functionality.
  23941. */
  23942. protected onContextMenu(evt: PointerEvent): void;
  23943. /**
  23944. * Detach the current controls from the specified dom element.
  23945. */
  23946. detachControl(): void;
  23947. /**
  23948. * Gets the class name of the current intput.
  23949. * @returns the class name
  23950. */
  23951. getClassName(): string;
  23952. /**
  23953. * Get the friendly name associated with the input class.
  23954. * @returns the input friendly name
  23955. */
  23956. getSimpleName(): string;
  23957. }
  23958. }
  23959. declare module BABYLON {
  23960. /**
  23961. * Base class for mouse wheel input..
  23962. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  23963. * for example usage.
  23964. */
  23965. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  23966. /**
  23967. * Defines the camera the input is attached to.
  23968. */
  23969. abstract camera: Camera;
  23970. /**
  23971. * How fast is the camera moves in relation to X axis mouseWheel events.
  23972. * Use negative value to reverse direction.
  23973. */
  23974. wheelPrecisionX: number;
  23975. /**
  23976. * How fast is the camera moves in relation to Y axis mouseWheel events.
  23977. * Use negative value to reverse direction.
  23978. */
  23979. wheelPrecisionY: number;
  23980. /**
  23981. * How fast is the camera moves in relation to Z axis mouseWheel events.
  23982. * Use negative value to reverse direction.
  23983. */
  23984. wheelPrecisionZ: number;
  23985. /**
  23986. * Observable for when a mouse wheel move event occurs.
  23987. */
  23988. onChangedObservable: Observable<{
  23989. wheelDeltaX: number;
  23990. wheelDeltaY: number;
  23991. wheelDeltaZ: number;
  23992. }>;
  23993. private _wheel;
  23994. private _observer;
  23995. /**
  23996. * Attach the input controls to a specific dom element to get the input from.
  23997. * @param noPreventDefault Defines whether event caught by the controls
  23998. * should call preventdefault().
  23999. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24000. */
  24001. attachControl(noPreventDefault?: boolean): void;
  24002. /**
  24003. * Detach the current controls from the specified dom element.
  24004. */
  24005. detachControl(): void;
  24006. /**
  24007. * Called for each rendered frame.
  24008. */
  24009. checkInputs(): void;
  24010. /**
  24011. * Gets the class name of the current intput.
  24012. * @returns the class name
  24013. */
  24014. getClassName(): string;
  24015. /**
  24016. * Get the friendly name associated with the input class.
  24017. * @returns the input friendly name
  24018. */
  24019. getSimpleName(): string;
  24020. /**
  24021. * Incremental value of multiple mouse wheel movements of the X axis.
  24022. * Should be zero-ed when read.
  24023. */
  24024. protected _wheelDeltaX: number;
  24025. /**
  24026. * Incremental value of multiple mouse wheel movements of the Y axis.
  24027. * Should be zero-ed when read.
  24028. */
  24029. protected _wheelDeltaY: number;
  24030. /**
  24031. * Incremental value of multiple mouse wheel movements of the Z axis.
  24032. * Should be zero-ed when read.
  24033. */
  24034. protected _wheelDeltaZ: number;
  24035. /**
  24036. * Firefox uses a different scheme to report scroll distances to other
  24037. * browsers. Rather than use complicated methods to calculate the exact
  24038. * multiple we need to apply, let's just cheat and use a constant.
  24039. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24040. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24041. */
  24042. private readonly _ffMultiplier;
  24043. /**
  24044. * Different event attributes for wheel data fall into a few set ranges.
  24045. * Some relevant but dated date here:
  24046. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24047. */
  24048. private readonly _normalize;
  24049. }
  24050. }
  24051. declare module BABYLON {
  24052. /**
  24053. * Manage the mouse wheel inputs to control a free camera.
  24054. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24055. */
  24056. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24057. /**
  24058. * Defines the camera the input is attached to.
  24059. */
  24060. camera: FreeCamera;
  24061. /**
  24062. * Gets the class name of the current input.
  24063. * @returns the class name
  24064. */
  24065. getClassName(): string;
  24066. /**
  24067. * Set which movement axis (relative to camera's orientation) the mouse
  24068. * wheel's X axis controls.
  24069. * @param axis The axis to be moved. Set null to clear.
  24070. */
  24071. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24072. /**
  24073. * Get the configured movement axis (relative to camera's orientation) the
  24074. * mouse wheel's X axis controls.
  24075. * @returns The configured axis or null if none.
  24076. */
  24077. get wheelXMoveRelative(): Nullable<Coordinate>;
  24078. /**
  24079. * Set which movement axis (relative to camera's orientation) the mouse
  24080. * wheel's Y axis controls.
  24081. * @param axis The axis to be moved. Set null to clear.
  24082. */
  24083. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24084. /**
  24085. * Get the configured movement axis (relative to camera's orientation) the
  24086. * mouse wheel's Y axis controls.
  24087. * @returns The configured axis or null if none.
  24088. */
  24089. get wheelYMoveRelative(): Nullable<Coordinate>;
  24090. /**
  24091. * Set which movement axis (relative to camera's orientation) the mouse
  24092. * wheel's Z axis controls.
  24093. * @param axis The axis to be moved. Set null to clear.
  24094. */
  24095. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24096. /**
  24097. * Get the configured movement axis (relative to camera's orientation) the
  24098. * mouse wheel's Z axis controls.
  24099. * @returns The configured axis or null if none.
  24100. */
  24101. get wheelZMoveRelative(): Nullable<Coordinate>;
  24102. /**
  24103. * Set which rotation axis (relative to camera's orientation) the mouse
  24104. * wheel's X axis controls.
  24105. * @param axis The axis to be moved. Set null to clear.
  24106. */
  24107. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24108. /**
  24109. * Get the configured rotation axis (relative to camera's orientation) the
  24110. * mouse wheel's X axis controls.
  24111. * @returns The configured axis or null if none.
  24112. */
  24113. get wheelXRotateRelative(): Nullable<Coordinate>;
  24114. /**
  24115. * Set which rotation axis (relative to camera's orientation) the mouse
  24116. * wheel's Y axis controls.
  24117. * @param axis The axis to be moved. Set null to clear.
  24118. */
  24119. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24120. /**
  24121. * Get the configured rotation axis (relative to camera's orientation) the
  24122. * mouse wheel's Y axis controls.
  24123. * @returns The configured axis or null if none.
  24124. */
  24125. get wheelYRotateRelative(): Nullable<Coordinate>;
  24126. /**
  24127. * Set which rotation axis (relative to camera's orientation) the mouse
  24128. * wheel's Z axis controls.
  24129. * @param axis The axis to be moved. Set null to clear.
  24130. */
  24131. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24132. /**
  24133. * Get the configured rotation axis (relative to camera's orientation) the
  24134. * mouse wheel's Z axis controls.
  24135. * @returns The configured axis or null if none.
  24136. */
  24137. get wheelZRotateRelative(): Nullable<Coordinate>;
  24138. /**
  24139. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24140. * controls.
  24141. * @param axis The axis to be moved. Set null to clear.
  24142. */
  24143. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24144. /**
  24145. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24146. * X axis controls.
  24147. * @returns The configured axis or null if none.
  24148. */
  24149. get wheelXMoveScene(): Nullable<Coordinate>;
  24150. /**
  24151. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24152. * controls.
  24153. * @param axis The axis to be moved. Set null to clear.
  24154. */
  24155. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24156. /**
  24157. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24158. * Y axis controls.
  24159. * @returns The configured axis or null if none.
  24160. */
  24161. get wheelYMoveScene(): Nullable<Coordinate>;
  24162. /**
  24163. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24164. * controls.
  24165. * @param axis The axis to be moved. Set null to clear.
  24166. */
  24167. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24168. /**
  24169. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24170. * Z axis controls.
  24171. * @returns The configured axis or null if none.
  24172. */
  24173. get wheelZMoveScene(): Nullable<Coordinate>;
  24174. /**
  24175. * Called for each rendered frame.
  24176. */
  24177. checkInputs(): void;
  24178. private _moveRelative;
  24179. private _rotateRelative;
  24180. private _moveScene;
  24181. /**
  24182. * These are set to the desired default behaviour.
  24183. */
  24184. private _wheelXAction;
  24185. private _wheelXActionCoordinate;
  24186. private _wheelYAction;
  24187. private _wheelYActionCoordinate;
  24188. private _wheelZAction;
  24189. private _wheelZActionCoordinate;
  24190. /**
  24191. * Update the camera according to any configured properties for the 3
  24192. * mouse-wheel axis.
  24193. */
  24194. private _updateCamera;
  24195. }
  24196. }
  24197. declare module BABYLON {
  24198. /**
  24199. * Manage the touch inputs to control the movement of a free camera.
  24200. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24201. */
  24202. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24203. /**
  24204. * Define if mouse events can be treated as touch events
  24205. */
  24206. allowMouse: boolean;
  24207. /**
  24208. * Defines the camera the input is attached to.
  24209. */
  24210. camera: FreeCamera;
  24211. /**
  24212. * Defines the touch sensibility for rotation.
  24213. * The higher the faster.
  24214. */
  24215. touchAngularSensibility: number;
  24216. /**
  24217. * Defines the touch sensibility for move.
  24218. * The higher the faster.
  24219. */
  24220. touchMoveSensibility: number;
  24221. private _offsetX;
  24222. private _offsetY;
  24223. private _pointerPressed;
  24224. private _pointerInput?;
  24225. private _observer;
  24226. private _onLostFocus;
  24227. /**
  24228. * Manage the touch inputs to control the movement of a free camera.
  24229. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24230. * @param allowMouse Defines if mouse events can be treated as touch events
  24231. */
  24232. constructor(
  24233. /**
  24234. * Define if mouse events can be treated as touch events
  24235. */
  24236. allowMouse?: boolean);
  24237. /**
  24238. * Attach the input controls to a specific dom element to get the input from.
  24239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24240. */
  24241. attachControl(noPreventDefault?: boolean): void;
  24242. /**
  24243. * Detach the current controls from the specified dom element.
  24244. */
  24245. detachControl(): void;
  24246. /**
  24247. * Update the current camera state depending on the inputs that have been used this frame.
  24248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24249. */
  24250. checkInputs(): void;
  24251. /**
  24252. * Gets the class name of the current intput.
  24253. * @returns the class name
  24254. */
  24255. getClassName(): string;
  24256. /**
  24257. * Get the friendly name associated with the input class.
  24258. * @returns the input friendly name
  24259. */
  24260. getSimpleName(): string;
  24261. }
  24262. }
  24263. declare module BABYLON {
  24264. /**
  24265. * Default Inputs manager for the FreeCamera.
  24266. * It groups all the default supported inputs for ease of use.
  24267. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24268. */
  24269. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24270. /**
  24271. * @hidden
  24272. */
  24273. _mouseInput: Nullable<FreeCameraMouseInput>;
  24274. /**
  24275. * @hidden
  24276. */
  24277. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24278. /**
  24279. * Instantiates a new FreeCameraInputsManager.
  24280. * @param camera Defines the camera the inputs belong to
  24281. */
  24282. constructor(camera: FreeCamera);
  24283. /**
  24284. * Add keyboard input support to the input manager.
  24285. * @returns the current input manager
  24286. */
  24287. addKeyboard(): FreeCameraInputsManager;
  24288. /**
  24289. * Add mouse input support to the input manager.
  24290. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  24291. * @returns the current input manager
  24292. */
  24293. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  24294. /**
  24295. * Removes the mouse input support from the manager
  24296. * @returns the current input manager
  24297. */
  24298. removeMouse(): FreeCameraInputsManager;
  24299. /**
  24300. * Add mouse wheel input support to the input manager.
  24301. * @returns the current input manager
  24302. */
  24303. addMouseWheel(): FreeCameraInputsManager;
  24304. /**
  24305. * Removes the mouse wheel input support from the manager
  24306. * @returns the current input manager
  24307. */
  24308. removeMouseWheel(): FreeCameraInputsManager;
  24309. /**
  24310. * Add touch input support to the input manager.
  24311. * @returns the current input manager
  24312. */
  24313. addTouch(): FreeCameraInputsManager;
  24314. /**
  24315. * Remove all attached input methods from a camera
  24316. */
  24317. clear(): void;
  24318. }
  24319. }
  24320. declare module BABYLON {
  24321. /**
  24322. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24323. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  24324. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24325. */
  24326. export class FreeCamera extends TargetCamera {
  24327. /**
  24328. * Define the collision ellipsoid of the camera.
  24329. * This is helpful to simulate a camera body like the player body around the camera
  24330. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  24331. */
  24332. ellipsoid: Vector3;
  24333. /**
  24334. * Define an offset for the position of the ellipsoid around the camera.
  24335. * This can be helpful to determine the center of the body near the gravity center of the body
  24336. * instead of its head.
  24337. */
  24338. ellipsoidOffset: Vector3;
  24339. /**
  24340. * Enable or disable collisions of the camera with the rest of the scene objects.
  24341. */
  24342. checkCollisions: boolean;
  24343. /**
  24344. * Enable or disable gravity on the camera.
  24345. */
  24346. applyGravity: boolean;
  24347. /**
  24348. * Define the input manager associated to the camera.
  24349. */
  24350. inputs: FreeCameraInputsManager;
  24351. /**
  24352. * Gets the input sensibility for a mouse input. (default is 2000.0)
  24353. * Higher values reduce sensitivity.
  24354. */
  24355. get angularSensibility(): number;
  24356. /**
  24357. * Sets the input sensibility for a mouse input. (default is 2000.0)
  24358. * Higher values reduce sensitivity.
  24359. */
  24360. set angularSensibility(value: number);
  24361. /**
  24362. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  24363. */
  24364. get keysUp(): number[];
  24365. set keysUp(value: number[]);
  24366. /**
  24367. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  24368. */
  24369. get keysUpward(): number[];
  24370. set keysUpward(value: number[]);
  24371. /**
  24372. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  24373. */
  24374. get keysDown(): number[];
  24375. set keysDown(value: number[]);
  24376. /**
  24377. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  24378. */
  24379. get keysDownward(): number[];
  24380. set keysDownward(value: number[]);
  24381. /**
  24382. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  24383. */
  24384. get keysLeft(): number[];
  24385. set keysLeft(value: number[]);
  24386. /**
  24387. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  24388. */
  24389. get keysRight(): number[];
  24390. set keysRight(value: number[]);
  24391. /**
  24392. * Event raised when the camera collide with a mesh in the scene.
  24393. */
  24394. onCollide: (collidedMesh: AbstractMesh) => void;
  24395. private _collider;
  24396. private _needMoveForGravity;
  24397. private _oldPosition;
  24398. private _diffPosition;
  24399. private _newPosition;
  24400. /** @hidden */
  24401. _localDirection: Vector3;
  24402. /** @hidden */
  24403. _transformedDirection: Vector3;
  24404. /**
  24405. * Instantiates a Free Camera.
  24406. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24407. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  24408. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24409. * @param name Define the name of the camera in the scene
  24410. * @param position Define the start position of the camera in the scene
  24411. * @param scene Define the scene the camera belongs to
  24412. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  24413. */
  24414. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24415. /**
  24416. * Attach the input controls to a specific dom element to get the input from.
  24417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24418. */
  24419. attachControl(noPreventDefault?: boolean): void;
  24420. /**
  24421. * Attach the input controls to a specific dom element to get the input from.
  24422. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  24423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24424. * BACK COMPAT SIGNATURE ONLY.
  24425. */
  24426. attachControl(ignored: any, noPreventDefault?: boolean): void;
  24427. /**
  24428. * Detach the current controls from the specified dom element.
  24429. */
  24430. detachControl(): void;
  24431. /**
  24432. * Detach the current controls from the specified dom element.
  24433. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  24434. */
  24435. detachControl(ignored: any): void;
  24436. private _collisionMask;
  24437. /**
  24438. * Define a collision mask to limit the list of object the camera can collide with
  24439. */
  24440. get collisionMask(): number;
  24441. set collisionMask(mask: number);
  24442. /** @hidden */
  24443. _collideWithWorld(displacement: Vector3): void;
  24444. private _onCollisionPositionChange;
  24445. /** @hidden */
  24446. _checkInputs(): void;
  24447. /** @hidden */
  24448. _decideIfNeedsToMove(): boolean;
  24449. /** @hidden */
  24450. _updatePosition(): void;
  24451. /**
  24452. * Destroy the camera and release the current resources hold by it.
  24453. */
  24454. dispose(): void;
  24455. /**
  24456. * Gets the current object class name.
  24457. * @return the class name
  24458. */
  24459. getClassName(): string;
  24460. }
  24461. }
  24462. declare module BABYLON {
  24463. /**
  24464. * Represents a gamepad control stick position
  24465. */
  24466. export class StickValues {
  24467. /**
  24468. * The x component of the control stick
  24469. */
  24470. x: number;
  24471. /**
  24472. * The y component of the control stick
  24473. */
  24474. y: number;
  24475. /**
  24476. * Initializes the gamepad x and y control stick values
  24477. * @param x The x component of the gamepad control stick value
  24478. * @param y The y component of the gamepad control stick value
  24479. */
  24480. constructor(
  24481. /**
  24482. * The x component of the control stick
  24483. */
  24484. x: number,
  24485. /**
  24486. * The y component of the control stick
  24487. */
  24488. y: number);
  24489. }
  24490. /**
  24491. * An interface which manages callbacks for gamepad button changes
  24492. */
  24493. export interface GamepadButtonChanges {
  24494. /**
  24495. * Called when a gamepad has been changed
  24496. */
  24497. changed: boolean;
  24498. /**
  24499. * Called when a gamepad press event has been triggered
  24500. */
  24501. pressChanged: boolean;
  24502. /**
  24503. * Called when a touch event has been triggered
  24504. */
  24505. touchChanged: boolean;
  24506. /**
  24507. * Called when a value has changed
  24508. */
  24509. valueChanged: boolean;
  24510. }
  24511. /**
  24512. * Represents a gamepad
  24513. */
  24514. export class Gamepad {
  24515. /**
  24516. * The id of the gamepad
  24517. */
  24518. id: string;
  24519. /**
  24520. * The index of the gamepad
  24521. */
  24522. index: number;
  24523. /**
  24524. * The browser gamepad
  24525. */
  24526. browserGamepad: any;
  24527. /**
  24528. * Specifies what type of gamepad this represents
  24529. */
  24530. type: number;
  24531. private _leftStick;
  24532. private _rightStick;
  24533. /** @hidden */
  24534. _isConnected: boolean;
  24535. private _leftStickAxisX;
  24536. private _leftStickAxisY;
  24537. private _rightStickAxisX;
  24538. private _rightStickAxisY;
  24539. /**
  24540. * Triggered when the left control stick has been changed
  24541. */
  24542. private _onleftstickchanged;
  24543. /**
  24544. * Triggered when the right control stick has been changed
  24545. */
  24546. private _onrightstickchanged;
  24547. /**
  24548. * Represents a gamepad controller
  24549. */
  24550. static GAMEPAD: number;
  24551. /**
  24552. * Represents a generic controller
  24553. */
  24554. static GENERIC: number;
  24555. /**
  24556. * Represents an XBox controller
  24557. */
  24558. static XBOX: number;
  24559. /**
  24560. * Represents a pose-enabled controller
  24561. */
  24562. static POSE_ENABLED: number;
  24563. /**
  24564. * Represents an Dual Shock controller
  24565. */
  24566. static DUALSHOCK: number;
  24567. /**
  24568. * Specifies whether the left control stick should be Y-inverted
  24569. */
  24570. protected _invertLeftStickY: boolean;
  24571. /**
  24572. * Specifies if the gamepad has been connected
  24573. */
  24574. get isConnected(): boolean;
  24575. /**
  24576. * Initializes the gamepad
  24577. * @param id The id of the gamepad
  24578. * @param index The index of the gamepad
  24579. * @param browserGamepad The browser gamepad
  24580. * @param leftStickX The x component of the left joystick
  24581. * @param leftStickY The y component of the left joystick
  24582. * @param rightStickX The x component of the right joystick
  24583. * @param rightStickY The y component of the right joystick
  24584. */
  24585. constructor(
  24586. /**
  24587. * The id of the gamepad
  24588. */
  24589. id: string,
  24590. /**
  24591. * The index of the gamepad
  24592. */
  24593. index: number,
  24594. /**
  24595. * The browser gamepad
  24596. */
  24597. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  24598. /**
  24599. * Callback triggered when the left joystick has changed
  24600. * @param callback
  24601. */
  24602. onleftstickchanged(callback: (values: StickValues) => void): void;
  24603. /**
  24604. * Callback triggered when the right joystick has changed
  24605. * @param callback
  24606. */
  24607. onrightstickchanged(callback: (values: StickValues) => void): void;
  24608. /**
  24609. * Gets the left joystick
  24610. */
  24611. get leftStick(): StickValues;
  24612. /**
  24613. * Sets the left joystick values
  24614. */
  24615. set leftStick(newValues: StickValues);
  24616. /**
  24617. * Gets the right joystick
  24618. */
  24619. get rightStick(): StickValues;
  24620. /**
  24621. * Sets the right joystick value
  24622. */
  24623. set rightStick(newValues: StickValues);
  24624. /**
  24625. * Updates the gamepad joystick positions
  24626. */
  24627. update(): void;
  24628. /**
  24629. * Disposes the gamepad
  24630. */
  24631. dispose(): void;
  24632. }
  24633. /**
  24634. * Represents a generic gamepad
  24635. */
  24636. export class GenericPad extends Gamepad {
  24637. private _buttons;
  24638. private _onbuttondown;
  24639. private _onbuttonup;
  24640. /**
  24641. * Observable triggered when a button has been pressed
  24642. */
  24643. onButtonDownObservable: Observable<number>;
  24644. /**
  24645. * Observable triggered when a button has been released
  24646. */
  24647. onButtonUpObservable: Observable<number>;
  24648. /**
  24649. * Callback triggered when a button has been pressed
  24650. * @param callback Called when a button has been pressed
  24651. */
  24652. onbuttondown(callback: (buttonPressed: number) => void): void;
  24653. /**
  24654. * Callback triggered when a button has been released
  24655. * @param callback Called when a button has been released
  24656. */
  24657. onbuttonup(callback: (buttonReleased: number) => void): void;
  24658. /**
  24659. * Initializes the generic gamepad
  24660. * @param id The id of the generic gamepad
  24661. * @param index The index of the generic gamepad
  24662. * @param browserGamepad The browser gamepad
  24663. */
  24664. constructor(id: string, index: number, browserGamepad: any);
  24665. private _setButtonValue;
  24666. /**
  24667. * Updates the generic gamepad
  24668. */
  24669. update(): void;
  24670. /**
  24671. * Disposes the generic gamepad
  24672. */
  24673. dispose(): void;
  24674. }
  24675. }
  24676. declare module BABYLON {
  24677. /**
  24678. * Defines a runtime animation
  24679. */
  24680. export class RuntimeAnimation {
  24681. private _events;
  24682. /**
  24683. * The current frame of the runtime animation
  24684. */
  24685. private _currentFrame;
  24686. /**
  24687. * The animation used by the runtime animation
  24688. */
  24689. private _animation;
  24690. /**
  24691. * The target of the runtime animation
  24692. */
  24693. private _target;
  24694. /**
  24695. * The initiating animatable
  24696. */
  24697. private _host;
  24698. /**
  24699. * The original value of the runtime animation
  24700. */
  24701. private _originalValue;
  24702. /**
  24703. * The original blend value of the runtime animation
  24704. */
  24705. private _originalBlendValue;
  24706. /**
  24707. * The offsets cache of the runtime animation
  24708. */
  24709. private _offsetsCache;
  24710. /**
  24711. * The high limits cache of the runtime animation
  24712. */
  24713. private _highLimitsCache;
  24714. /**
  24715. * Specifies if the runtime animation has been stopped
  24716. */
  24717. private _stopped;
  24718. /**
  24719. * The blending factor of the runtime animation
  24720. */
  24721. private _blendingFactor;
  24722. /**
  24723. * The BabylonJS scene
  24724. */
  24725. private _scene;
  24726. /**
  24727. * The current value of the runtime animation
  24728. */
  24729. private _currentValue;
  24730. /** @hidden */
  24731. _animationState: _IAnimationState;
  24732. /**
  24733. * The active target of the runtime animation
  24734. */
  24735. private _activeTargets;
  24736. private _currentActiveTarget;
  24737. private _directTarget;
  24738. /**
  24739. * The target path of the runtime animation
  24740. */
  24741. private _targetPath;
  24742. /**
  24743. * The weight of the runtime animation
  24744. */
  24745. private _weight;
  24746. /**
  24747. * The ratio offset of the runtime animation
  24748. */
  24749. private _ratioOffset;
  24750. /**
  24751. * The previous delay of the runtime animation
  24752. */
  24753. private _previousDelay;
  24754. /**
  24755. * The previous ratio of the runtime animation
  24756. */
  24757. private _previousRatio;
  24758. private _enableBlending;
  24759. private _keys;
  24760. private _minFrame;
  24761. private _maxFrame;
  24762. private _minValue;
  24763. private _maxValue;
  24764. private _targetIsArray;
  24765. /**
  24766. * Gets the current frame of the runtime animation
  24767. */
  24768. get currentFrame(): number;
  24769. /**
  24770. * Gets the weight of the runtime animation
  24771. */
  24772. get weight(): number;
  24773. /**
  24774. * Gets the current value of the runtime animation
  24775. */
  24776. get currentValue(): any;
  24777. /**
  24778. * Gets the target path of the runtime animation
  24779. */
  24780. get targetPath(): string;
  24781. /**
  24782. * Gets the actual target of the runtime animation
  24783. */
  24784. get target(): any;
  24785. /**
  24786. * Gets the additive state of the runtime animation
  24787. */
  24788. get isAdditive(): boolean;
  24789. /** @hidden */
  24790. _onLoop: () => void;
  24791. /**
  24792. * Create a new RuntimeAnimation object
  24793. * @param target defines the target of the animation
  24794. * @param animation defines the source animation object
  24795. * @param scene defines the hosting scene
  24796. * @param host defines the initiating Animatable
  24797. */
  24798. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  24799. private _preparePath;
  24800. /**
  24801. * Gets the animation from the runtime animation
  24802. */
  24803. get animation(): Animation;
  24804. /**
  24805. * Resets the runtime animation to the beginning
  24806. * @param restoreOriginal defines whether to restore the target property to the original value
  24807. */
  24808. reset(restoreOriginal?: boolean): void;
  24809. /**
  24810. * Specifies if the runtime animation is stopped
  24811. * @returns Boolean specifying if the runtime animation is stopped
  24812. */
  24813. isStopped(): boolean;
  24814. /**
  24815. * Disposes of the runtime animation
  24816. */
  24817. dispose(): void;
  24818. /**
  24819. * Apply the interpolated value to the target
  24820. * @param currentValue defines the value computed by the animation
  24821. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  24822. */
  24823. setValue(currentValue: any, weight: number): void;
  24824. private _getOriginalValues;
  24825. private _setValue;
  24826. /**
  24827. * Gets the loop pmode of the runtime animation
  24828. * @returns Loop Mode
  24829. */
  24830. private _getCorrectLoopMode;
  24831. /**
  24832. * Move the current animation to a given frame
  24833. * @param frame defines the frame to move to
  24834. */
  24835. goToFrame(frame: number): void;
  24836. /**
  24837. * @hidden Internal use only
  24838. */
  24839. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  24840. /**
  24841. * Execute the current animation
  24842. * @param delay defines the delay to add to the current frame
  24843. * @param from defines the lower bound of the animation range
  24844. * @param to defines the upper bound of the animation range
  24845. * @param loop defines if the current animation must loop
  24846. * @param speedRatio defines the current speed ratio
  24847. * @param weight defines the weight of the animation (default is -1 so no weight)
  24848. * @param onLoop optional callback called when animation loops
  24849. * @returns a boolean indicating if the animation is running
  24850. */
  24851. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  24852. }
  24853. }
  24854. declare module BABYLON {
  24855. /**
  24856. * Class used to store an actual running animation
  24857. */
  24858. export class Animatable {
  24859. /** defines the target object */
  24860. target: any;
  24861. /** defines the starting frame number (default is 0) */
  24862. fromFrame: number;
  24863. /** defines the ending frame number (default is 100) */
  24864. toFrame: number;
  24865. /** defines if the animation must loop (default is false) */
  24866. loopAnimation: boolean;
  24867. /** defines a callback to call when animation ends if it is not looping */
  24868. onAnimationEnd?: (() => void) | null | undefined;
  24869. /** defines a callback to call when animation loops */
  24870. onAnimationLoop?: (() => void) | null | undefined;
  24871. /** defines whether the animation should be evaluated additively */
  24872. isAdditive: boolean;
  24873. private _localDelayOffset;
  24874. private _pausedDelay;
  24875. private _runtimeAnimations;
  24876. private _paused;
  24877. private _scene;
  24878. private _speedRatio;
  24879. private _weight;
  24880. private _syncRoot;
  24881. /**
  24882. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24883. * This will only apply for non looping animation (default is true)
  24884. */
  24885. disposeOnEnd: boolean;
  24886. /**
  24887. * Gets a boolean indicating if the animation has started
  24888. */
  24889. animationStarted: boolean;
  24890. /**
  24891. * Observer raised when the animation ends
  24892. */
  24893. onAnimationEndObservable: Observable<Animatable>;
  24894. /**
  24895. * Observer raised when the animation loops
  24896. */
  24897. onAnimationLoopObservable: Observable<Animatable>;
  24898. /**
  24899. * Gets the root Animatable used to synchronize and normalize animations
  24900. */
  24901. get syncRoot(): Nullable<Animatable>;
  24902. /**
  24903. * Gets the current frame of the first RuntimeAnimation
  24904. * Used to synchronize Animatables
  24905. */
  24906. get masterFrame(): number;
  24907. /**
  24908. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24909. */
  24910. get weight(): number;
  24911. set weight(value: number);
  24912. /**
  24913. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24914. */
  24915. get speedRatio(): number;
  24916. set speedRatio(value: number);
  24917. /**
  24918. * Creates a new Animatable
  24919. * @param scene defines the hosting scene
  24920. * @param target defines the target object
  24921. * @param fromFrame defines the starting frame number (default is 0)
  24922. * @param toFrame defines the ending frame number (default is 100)
  24923. * @param loopAnimation defines if the animation must loop (default is false)
  24924. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24925. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24926. * @param animations defines a group of animation to add to the new Animatable
  24927. * @param onAnimationLoop defines a callback to call when animation loops
  24928. * @param isAdditive defines whether the animation should be evaluated additively
  24929. */
  24930. constructor(scene: Scene,
  24931. /** defines the target object */
  24932. target: any,
  24933. /** defines the starting frame number (default is 0) */
  24934. fromFrame?: number,
  24935. /** defines the ending frame number (default is 100) */
  24936. toFrame?: number,
  24937. /** defines if the animation must loop (default is false) */
  24938. loopAnimation?: boolean, speedRatio?: number,
  24939. /** defines a callback to call when animation ends if it is not looping */
  24940. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24941. /** defines a callback to call when animation loops */
  24942. onAnimationLoop?: (() => void) | null | undefined,
  24943. /** defines whether the animation should be evaluated additively */
  24944. isAdditive?: boolean);
  24945. /**
  24946. * Synchronize and normalize current Animatable with a source Animatable
  24947. * This is useful when using animation weights and when animations are not of the same length
  24948. * @param root defines the root Animatable to synchronize with
  24949. * @returns the current Animatable
  24950. */
  24951. syncWith(root: Animatable): Animatable;
  24952. /**
  24953. * Gets the list of runtime animations
  24954. * @returns an array of RuntimeAnimation
  24955. */
  24956. getAnimations(): RuntimeAnimation[];
  24957. /**
  24958. * Adds more animations to the current animatable
  24959. * @param target defines the target of the animations
  24960. * @param animations defines the new animations to add
  24961. */
  24962. appendAnimations(target: any, animations: Animation[]): void;
  24963. /**
  24964. * Gets the source animation for a specific property
  24965. * @param property defines the propertyu to look for
  24966. * @returns null or the source animation for the given property
  24967. */
  24968. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24969. /**
  24970. * Gets the runtime animation for a specific property
  24971. * @param property defines the propertyu to look for
  24972. * @returns null or the runtime animation for the given property
  24973. */
  24974. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24975. /**
  24976. * Resets the animatable to its original state
  24977. */
  24978. reset(): void;
  24979. /**
  24980. * Allows the animatable to blend with current running animations
  24981. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24982. * @param blendingSpeed defines the blending speed to use
  24983. */
  24984. enableBlending(blendingSpeed: number): void;
  24985. /**
  24986. * Disable animation blending
  24987. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24988. */
  24989. disableBlending(): void;
  24990. /**
  24991. * Jump directly to a given frame
  24992. * @param frame defines the frame to jump to
  24993. */
  24994. goToFrame(frame: number): void;
  24995. /**
  24996. * Pause the animation
  24997. */
  24998. pause(): void;
  24999. /**
  25000. * Restart the animation
  25001. */
  25002. restart(): void;
  25003. private _raiseOnAnimationEnd;
  25004. /**
  25005. * Stop and delete the current animation
  25006. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25007. * @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)
  25008. */
  25009. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25010. /**
  25011. * Wait asynchronously for the animation to end
  25012. * @returns a promise which will be fullfilled when the animation ends
  25013. */
  25014. waitAsync(): Promise<Animatable>;
  25015. /** @hidden */
  25016. _animate(delay: number): boolean;
  25017. }
  25018. interface Scene {
  25019. /** @hidden */
  25020. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25021. /** @hidden */
  25022. _processLateAnimationBindingsForMatrices(holder: {
  25023. totalWeight: number;
  25024. totalAdditiveWeight: number;
  25025. animations: RuntimeAnimation[];
  25026. additiveAnimations: RuntimeAnimation[];
  25027. originalValue: Matrix;
  25028. }): any;
  25029. /** @hidden */
  25030. _processLateAnimationBindingsForQuaternions(holder: {
  25031. totalWeight: number;
  25032. totalAdditiveWeight: number;
  25033. animations: RuntimeAnimation[];
  25034. additiveAnimations: RuntimeAnimation[];
  25035. originalValue: Quaternion;
  25036. }, refQuaternion: Quaternion): Quaternion;
  25037. /** @hidden */
  25038. _processLateAnimationBindings(): void;
  25039. /**
  25040. * Will start the animation sequence of a given target
  25041. * @param target defines the target
  25042. * @param from defines from which frame should animation start
  25043. * @param to defines until which frame should animation run.
  25044. * @param weight defines the weight to apply to the animation (1.0 by default)
  25045. * @param loop defines if the animation loops
  25046. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25047. * @param onAnimationEnd defines the function to be executed when the animation ends
  25048. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25049. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25050. * @param onAnimationLoop defines the callback to call when an animation loops
  25051. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25052. * @returns the animatable object created for this animation
  25053. */
  25054. 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;
  25055. /**
  25056. * Will start the animation sequence of a given target
  25057. * @param target defines the target
  25058. * @param from defines from which frame should animation start
  25059. * @param to defines until which frame should animation run.
  25060. * @param loop defines if the animation loops
  25061. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25062. * @param onAnimationEnd defines the function to be executed when the animation ends
  25063. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25064. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25065. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25066. * @param onAnimationLoop defines the callback to call when an animation loops
  25067. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25068. * @returns the animatable object created for this animation
  25069. */
  25070. 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;
  25071. /**
  25072. * Will start the animation sequence of a given target and its hierarchy
  25073. * @param target defines the target
  25074. * @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.
  25075. * @param from defines from which frame should animation start
  25076. * @param to defines until which frame should animation run.
  25077. * @param loop defines if the animation loops
  25078. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25079. * @param onAnimationEnd defines the function to be executed when the animation ends
  25080. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25081. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25082. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25083. * @param onAnimationLoop defines the callback to call when an animation loops
  25084. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25085. * @returns the list of created animatables
  25086. */
  25087. 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[];
  25088. /**
  25089. * Begin a new animation on a given node
  25090. * @param target defines the target where the animation will take place
  25091. * @param animations defines the list of animations to start
  25092. * @param from defines the initial value
  25093. * @param to defines the final value
  25094. * @param loop defines if you want animation to loop (off by default)
  25095. * @param speedRatio defines the speed ratio to apply to all animations
  25096. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25097. * @param onAnimationLoop defines the callback to call when an animation loops
  25098. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25099. * @returns the list of created animatables
  25100. */
  25101. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25102. /**
  25103. * Begin a new animation on a given node and its hierarchy
  25104. * @param target defines the root node where the animation will take place
  25105. * @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.
  25106. * @param animations defines the list of animations to start
  25107. * @param from defines the initial value
  25108. * @param to defines the final value
  25109. * @param loop defines if you want animation to loop (off by default)
  25110. * @param speedRatio defines the speed ratio to apply to all animations
  25111. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25112. * @param onAnimationLoop defines the callback to call when an animation loops
  25113. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25114. * @returns the list of animatables created for all nodes
  25115. */
  25116. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25117. /**
  25118. * Gets the animatable associated with a specific target
  25119. * @param target defines the target of the animatable
  25120. * @returns the required animatable if found
  25121. */
  25122. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25123. /**
  25124. * Gets all animatables associated with a given target
  25125. * @param target defines the target to look animatables for
  25126. * @returns an array of Animatables
  25127. */
  25128. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25129. /**
  25130. * Stops and removes all animations that have been applied to the scene
  25131. */
  25132. stopAllAnimations(): void;
  25133. /**
  25134. * Gets the current delta time used by animation engine
  25135. */
  25136. deltaTime: number;
  25137. }
  25138. interface Bone {
  25139. /**
  25140. * Copy an animation range from another bone
  25141. * @param source defines the source bone
  25142. * @param rangeName defines the range name to copy
  25143. * @param frameOffset defines the frame offset
  25144. * @param rescaleAsRequired defines if rescaling must be applied if required
  25145. * @param skelDimensionsRatio defines the scaling ratio
  25146. * @returns true if operation was successful
  25147. */
  25148. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25149. }
  25150. }
  25151. declare module BABYLON {
  25152. /**
  25153. * Class used to override all child animations of a given target
  25154. */
  25155. export class AnimationPropertiesOverride {
  25156. /**
  25157. * Gets or sets a value indicating if animation blending must be used
  25158. */
  25159. enableBlending: boolean;
  25160. /**
  25161. * Gets or sets the blending speed to use when enableBlending is true
  25162. */
  25163. blendingSpeed: number;
  25164. /**
  25165. * Gets or sets the default loop mode to use
  25166. */
  25167. loopMode: number;
  25168. }
  25169. }
  25170. declare module BABYLON {
  25171. /**
  25172. * Class used to handle skinning animations
  25173. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25174. */
  25175. export class Skeleton implements IAnimatable {
  25176. /** defines the skeleton name */
  25177. name: string;
  25178. /** defines the skeleton Id */
  25179. id: string;
  25180. /**
  25181. * Defines the list of child bones
  25182. */
  25183. bones: Bone[];
  25184. /**
  25185. * Defines an estimate of the dimension of the skeleton at rest
  25186. */
  25187. dimensionsAtRest: Vector3;
  25188. /**
  25189. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25190. */
  25191. needInitialSkinMatrix: boolean;
  25192. /**
  25193. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25194. */
  25195. overrideMesh: Nullable<AbstractMesh>;
  25196. /**
  25197. * Gets the list of animations attached to this skeleton
  25198. */
  25199. animations: Array<Animation>;
  25200. private _scene;
  25201. private _isDirty;
  25202. private _transformMatrices;
  25203. private _transformMatrixTexture;
  25204. private _meshesWithPoseMatrix;
  25205. private _animatables;
  25206. private _identity;
  25207. private _synchronizedWithMesh;
  25208. private _ranges;
  25209. private _lastAbsoluteTransformsUpdateId;
  25210. private _canUseTextureForBones;
  25211. private _uniqueId;
  25212. /** @hidden */
  25213. _numBonesWithLinkedTransformNode: number;
  25214. /** @hidden */
  25215. _hasWaitingData: Nullable<boolean>;
  25216. /** @hidden */
  25217. _waitingOverrideMeshId: Nullable<string>;
  25218. /**
  25219. * Specifies if the skeleton should be serialized
  25220. */
  25221. doNotSerialize: boolean;
  25222. private _useTextureToStoreBoneMatrices;
  25223. /**
  25224. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25225. * Please note that this option is not available if the hardware does not support it
  25226. */
  25227. get useTextureToStoreBoneMatrices(): boolean;
  25228. set useTextureToStoreBoneMatrices(value: boolean);
  25229. private _animationPropertiesOverride;
  25230. /**
  25231. * Gets or sets the animation properties override
  25232. */
  25233. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25234. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25235. /**
  25236. * List of inspectable custom properties (used by the Inspector)
  25237. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25238. */
  25239. inspectableCustomProperties: IInspectable[];
  25240. /**
  25241. * An observable triggered before computing the skeleton's matrices
  25242. */
  25243. onBeforeComputeObservable: Observable<Skeleton>;
  25244. /**
  25245. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25246. */
  25247. get isUsingTextureForMatrices(): boolean;
  25248. /**
  25249. * Gets the unique ID of this skeleton
  25250. */
  25251. get uniqueId(): number;
  25252. /**
  25253. * Creates a new skeleton
  25254. * @param name defines the skeleton name
  25255. * @param id defines the skeleton Id
  25256. * @param scene defines the hosting scene
  25257. */
  25258. constructor(
  25259. /** defines the skeleton name */
  25260. name: string,
  25261. /** defines the skeleton Id */
  25262. id: string, scene: Scene);
  25263. /**
  25264. * Gets the current object class name.
  25265. * @return the class name
  25266. */
  25267. getClassName(): string;
  25268. /**
  25269. * Returns an array containing the root bones
  25270. * @returns an array containing the root bones
  25271. */
  25272. getChildren(): Array<Bone>;
  25273. /**
  25274. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25275. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25276. * @returns a Float32Array containing matrices data
  25277. */
  25278. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25279. /**
  25280. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25281. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25282. * @returns a raw texture containing the data
  25283. */
  25284. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25285. /**
  25286. * Gets the current hosting scene
  25287. * @returns a scene object
  25288. */
  25289. getScene(): Scene;
  25290. /**
  25291. * Gets a string representing the current skeleton data
  25292. * @param fullDetails defines a boolean indicating if we want a verbose version
  25293. * @returns a string representing the current skeleton data
  25294. */
  25295. toString(fullDetails?: boolean): string;
  25296. /**
  25297. * Get bone's index searching by name
  25298. * @param name defines bone's name to search for
  25299. * @return the indice of the bone. Returns -1 if not found
  25300. */
  25301. getBoneIndexByName(name: string): number;
  25302. /**
  25303. * Creater a new animation range
  25304. * @param name defines the name of the range
  25305. * @param from defines the start key
  25306. * @param to defines the end key
  25307. */
  25308. createAnimationRange(name: string, from: number, to: number): void;
  25309. /**
  25310. * Delete a specific animation range
  25311. * @param name defines the name of the range
  25312. * @param deleteFrames defines if frames must be removed as well
  25313. */
  25314. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25315. /**
  25316. * Gets a specific animation range
  25317. * @param name defines the name of the range to look for
  25318. * @returns the requested animation range or null if not found
  25319. */
  25320. getAnimationRange(name: string): Nullable<AnimationRange>;
  25321. /**
  25322. * Gets the list of all animation ranges defined on this skeleton
  25323. * @returns an array
  25324. */
  25325. getAnimationRanges(): Nullable<AnimationRange>[];
  25326. /**
  25327. * Copy animation range from a source skeleton.
  25328. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  25329. * @param source defines the source skeleton
  25330. * @param name defines the name of the range to copy
  25331. * @param rescaleAsRequired defines if rescaling must be applied if required
  25332. * @returns true if operation was successful
  25333. */
  25334. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  25335. /**
  25336. * Forces the skeleton to go to rest pose
  25337. */
  25338. returnToRest(): void;
  25339. private _getHighestAnimationFrame;
  25340. /**
  25341. * Begin a specific animation range
  25342. * @param name defines the name of the range to start
  25343. * @param loop defines if looping must be turned on (false by default)
  25344. * @param speedRatio defines the speed ratio to apply (1 by default)
  25345. * @param onAnimationEnd defines a callback which will be called when animation will end
  25346. * @returns a new animatable
  25347. */
  25348. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25349. /**
  25350. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  25351. * @param skeleton defines the Skeleton containing the animation range to convert
  25352. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  25353. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  25354. * @returns the original skeleton
  25355. */
  25356. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  25357. /** @hidden */
  25358. _markAsDirty(): void;
  25359. /** @hidden */
  25360. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25361. /** @hidden */
  25362. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25363. private _computeTransformMatrices;
  25364. /**
  25365. * Build all resources required to render a skeleton
  25366. */
  25367. prepare(): void;
  25368. /**
  25369. * Gets the list of animatables currently running for this skeleton
  25370. * @returns an array of animatables
  25371. */
  25372. getAnimatables(): IAnimatable[];
  25373. /**
  25374. * Clone the current skeleton
  25375. * @param name defines the name of the new skeleton
  25376. * @param id defines the id of the new skeleton
  25377. * @returns the new skeleton
  25378. */
  25379. clone(name: string, id?: string): Skeleton;
  25380. /**
  25381. * Enable animation blending for this skeleton
  25382. * @param blendingSpeed defines the blending speed to apply
  25383. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25384. */
  25385. enableBlending(blendingSpeed?: number): void;
  25386. /**
  25387. * Releases all resources associated with the current skeleton
  25388. */
  25389. dispose(): void;
  25390. /**
  25391. * Serialize the skeleton in a JSON object
  25392. * @returns a JSON object
  25393. */
  25394. serialize(): any;
  25395. /**
  25396. * Creates a new skeleton from serialized data
  25397. * @param parsedSkeleton defines the serialized data
  25398. * @param scene defines the hosting scene
  25399. * @returns a new skeleton
  25400. */
  25401. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  25402. /**
  25403. * Compute all node absolute transforms
  25404. * @param forceUpdate defines if computation must be done even if cache is up to date
  25405. */
  25406. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  25407. /**
  25408. * Gets the root pose matrix
  25409. * @returns a matrix
  25410. */
  25411. getPoseMatrix(): Nullable<Matrix>;
  25412. /**
  25413. * Sorts bones per internal index
  25414. */
  25415. sortBones(): void;
  25416. private _sortBones;
  25417. /**
  25418. * Set the current local matrix as the restPose for all bones in the skeleton.
  25419. */
  25420. setCurrentPoseAsRest(): void;
  25421. }
  25422. }
  25423. declare module BABYLON {
  25424. /**
  25425. * Class used to store bone information
  25426. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25427. */
  25428. export class Bone extends Node {
  25429. /**
  25430. * defines the bone name
  25431. */
  25432. name: string;
  25433. private static _tmpVecs;
  25434. private static _tmpQuat;
  25435. private static _tmpMats;
  25436. /**
  25437. * Gets the list of child bones
  25438. */
  25439. children: Bone[];
  25440. /** Gets the animations associated with this bone */
  25441. animations: Animation[];
  25442. /**
  25443. * Gets or sets bone length
  25444. */
  25445. length: number;
  25446. /**
  25447. * @hidden Internal only
  25448. * Set this value to map this bone to a different index in the transform matrices
  25449. * Set this value to -1 to exclude the bone from the transform matrices
  25450. */
  25451. _index: Nullable<number>;
  25452. private _skeleton;
  25453. private _localMatrix;
  25454. private _restPose;
  25455. private _bindPose;
  25456. private _baseMatrix;
  25457. private _absoluteTransform;
  25458. private _invertedAbsoluteTransform;
  25459. private _parent;
  25460. private _scalingDeterminant;
  25461. private _worldTransform;
  25462. private _localScaling;
  25463. private _localRotation;
  25464. private _localPosition;
  25465. private _needToDecompose;
  25466. private _needToCompose;
  25467. /** @hidden */
  25468. _linkedTransformNode: Nullable<TransformNode>;
  25469. /** @hidden */
  25470. _waitingTransformNodeId: Nullable<string>;
  25471. /** @hidden */
  25472. get _matrix(): Matrix;
  25473. /** @hidden */
  25474. set _matrix(value: Matrix);
  25475. /**
  25476. * Create a new bone
  25477. * @param name defines the bone name
  25478. * @param skeleton defines the parent skeleton
  25479. * @param parentBone defines the parent (can be null if the bone is the root)
  25480. * @param localMatrix defines the local matrix
  25481. * @param restPose defines the rest pose matrix
  25482. * @param baseMatrix defines the base matrix
  25483. * @param index defines index of the bone in the hiearchy
  25484. */
  25485. constructor(
  25486. /**
  25487. * defines the bone name
  25488. */
  25489. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  25490. /**
  25491. * Gets the current object class name.
  25492. * @return the class name
  25493. */
  25494. getClassName(): string;
  25495. /**
  25496. * Gets the parent skeleton
  25497. * @returns a skeleton
  25498. */
  25499. getSkeleton(): Skeleton;
  25500. /**
  25501. * Gets parent bone
  25502. * @returns a bone or null if the bone is the root of the bone hierarchy
  25503. */
  25504. getParent(): Nullable<Bone>;
  25505. /**
  25506. * Returns an array containing the root bones
  25507. * @returns an array containing the root bones
  25508. */
  25509. getChildren(): Array<Bone>;
  25510. /**
  25511. * Gets the node index in matrix array generated for rendering
  25512. * @returns the node index
  25513. */
  25514. getIndex(): number;
  25515. /**
  25516. * Sets the parent bone
  25517. * @param parent defines the parent (can be null if the bone is the root)
  25518. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25519. */
  25520. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  25521. /**
  25522. * Gets the local matrix
  25523. * @returns a matrix
  25524. */
  25525. getLocalMatrix(): Matrix;
  25526. /**
  25527. * Gets the base matrix (initial matrix which remains unchanged)
  25528. * @returns a matrix
  25529. */
  25530. getBaseMatrix(): Matrix;
  25531. /**
  25532. * Gets the rest pose matrix
  25533. * @returns a matrix
  25534. */
  25535. getRestPose(): Matrix;
  25536. /**
  25537. * Sets the rest pose matrix
  25538. * @param matrix the local-space rest pose to set for this bone
  25539. */
  25540. setRestPose(matrix: Matrix): void;
  25541. /**
  25542. * Gets the bind pose matrix
  25543. * @returns the bind pose matrix
  25544. */
  25545. getBindPose(): Matrix;
  25546. /**
  25547. * Sets the bind pose matrix
  25548. * @param matrix the local-space bind pose to set for this bone
  25549. */
  25550. setBindPose(matrix: Matrix): void;
  25551. /**
  25552. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  25553. */
  25554. getWorldMatrix(): Matrix;
  25555. /**
  25556. * Sets the local matrix to rest pose matrix
  25557. */
  25558. returnToRest(): void;
  25559. /**
  25560. * Gets the inverse of the absolute transform matrix.
  25561. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  25562. * @returns a matrix
  25563. */
  25564. getInvertedAbsoluteTransform(): Matrix;
  25565. /**
  25566. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  25567. * @returns a matrix
  25568. */
  25569. getAbsoluteTransform(): Matrix;
  25570. /**
  25571. * Links with the given transform node.
  25572. * The local matrix of this bone is copied from the transform node every frame.
  25573. * @param transformNode defines the transform node to link to
  25574. */
  25575. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  25576. /**
  25577. * Gets the node used to drive the bone's transformation
  25578. * @returns a transform node or null
  25579. */
  25580. getTransformNode(): Nullable<TransformNode>;
  25581. /** Gets or sets current position (in local space) */
  25582. get position(): Vector3;
  25583. set position(newPosition: Vector3);
  25584. /** Gets or sets current rotation (in local space) */
  25585. get rotation(): Vector3;
  25586. set rotation(newRotation: Vector3);
  25587. /** Gets or sets current rotation quaternion (in local space) */
  25588. get rotationQuaternion(): Quaternion;
  25589. set rotationQuaternion(newRotation: Quaternion);
  25590. /** Gets or sets current scaling (in local space) */
  25591. get scaling(): Vector3;
  25592. set scaling(newScaling: Vector3);
  25593. /**
  25594. * Gets the animation properties override
  25595. */
  25596. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25597. private _decompose;
  25598. private _compose;
  25599. /**
  25600. * Update the base and local matrices
  25601. * @param matrix defines the new base or local matrix
  25602. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25603. * @param updateLocalMatrix defines if the local matrix should be updated
  25604. */
  25605. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  25606. /** @hidden */
  25607. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  25608. /**
  25609. * Flag the bone as dirty (Forcing it to update everything)
  25610. */
  25611. markAsDirty(): void;
  25612. /** @hidden */
  25613. _markAsDirtyAndCompose(): void;
  25614. private _markAsDirtyAndDecompose;
  25615. /**
  25616. * Translate the bone in local or world space
  25617. * @param vec The amount to translate the bone
  25618. * @param space The space that the translation is in
  25619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25620. */
  25621. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25622. /**
  25623. * Set the postion of the bone in local or world space
  25624. * @param position The position to set the bone
  25625. * @param space The space that the position is in
  25626. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25627. */
  25628. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25629. /**
  25630. * Set the absolute position of the bone (world space)
  25631. * @param position The position to set the bone
  25632. * @param mesh The mesh that this bone is attached to
  25633. */
  25634. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  25635. /**
  25636. * Scale the bone on the x, y and z axes (in local space)
  25637. * @param x The amount to scale the bone on the x axis
  25638. * @param y The amount to scale the bone on the y axis
  25639. * @param z The amount to scale the bone on the z axis
  25640. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  25641. */
  25642. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  25643. /**
  25644. * Set the bone scaling in local space
  25645. * @param scale defines the scaling vector
  25646. */
  25647. setScale(scale: Vector3): void;
  25648. /**
  25649. * Gets the current scaling in local space
  25650. * @returns the current scaling vector
  25651. */
  25652. getScale(): Vector3;
  25653. /**
  25654. * Gets the current scaling in local space and stores it in a target vector
  25655. * @param result defines the target vector
  25656. */
  25657. getScaleToRef(result: Vector3): void;
  25658. /**
  25659. * Set the yaw, pitch, and roll of the bone in local or world space
  25660. * @param yaw The rotation of the bone on the y axis
  25661. * @param pitch The rotation of the bone on the x axis
  25662. * @param roll The rotation of the bone on the z axis
  25663. * @param space The space that the axes of rotation are in
  25664. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25665. */
  25666. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  25667. /**
  25668. * Add a rotation to the bone on an axis in local or world space
  25669. * @param axis The axis to rotate the bone on
  25670. * @param amount The amount to rotate the bone
  25671. * @param space The space that the axis is in
  25672. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25673. */
  25674. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  25675. /**
  25676. * Set the rotation of the bone to a particular axis angle in local or world space
  25677. * @param axis The axis to rotate the bone on
  25678. * @param angle The angle that the bone should be rotated to
  25679. * @param space The space that the axis is in
  25680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25681. */
  25682. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  25683. /**
  25684. * Set the euler rotation of the bone in local or world space
  25685. * @param rotation The euler rotation that the bone should be set to
  25686. * @param space The space that the rotation is in
  25687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25688. */
  25689. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25690. /**
  25691. * Set the quaternion rotation of the bone in local or world space
  25692. * @param quat The quaternion rotation that the bone should be set to
  25693. * @param space The space that the rotation is in
  25694. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25695. */
  25696. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  25697. /**
  25698. * Set the rotation matrix of the bone in local or world space
  25699. * @param rotMat The rotation matrix that the bone should be set to
  25700. * @param space The space that the rotation is in
  25701. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25702. */
  25703. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  25704. private _rotateWithMatrix;
  25705. private _getNegativeRotationToRef;
  25706. /**
  25707. * Get the position of the bone in local or world space
  25708. * @param space The space that the returned position is in
  25709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25710. * @returns The position of the bone
  25711. */
  25712. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25713. /**
  25714. * Copy the position of the bone to a vector3 in local or world space
  25715. * @param space The space that the returned position is in
  25716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25717. * @param result The vector3 to copy the position to
  25718. */
  25719. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  25720. /**
  25721. * Get the absolute position of the bone (world space)
  25722. * @param mesh The mesh that this bone is attached to
  25723. * @returns The absolute position of the bone
  25724. */
  25725. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  25726. /**
  25727. * Copy the absolute position of the bone (world space) to the result param
  25728. * @param mesh The mesh that this bone is attached to
  25729. * @param result The vector3 to copy the absolute position to
  25730. */
  25731. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  25732. /**
  25733. * Compute the absolute transforms of this bone and its children
  25734. */
  25735. computeAbsoluteTransforms(): void;
  25736. /**
  25737. * Get the world direction from an axis that is in the local space of the bone
  25738. * @param localAxis The local direction that is used to compute the world direction
  25739. * @param mesh The mesh that this bone is attached to
  25740. * @returns The world direction
  25741. */
  25742. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25743. /**
  25744. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  25745. * @param localAxis The local direction that is used to compute the world direction
  25746. * @param mesh The mesh that this bone is attached to
  25747. * @param result The vector3 that the world direction will be copied to
  25748. */
  25749. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25750. /**
  25751. * Get the euler rotation of the bone in local or world space
  25752. * @param space The space that the rotation should be in
  25753. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25754. * @returns The euler rotation
  25755. */
  25756. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25757. /**
  25758. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  25759. * @param space The space that the rotation should be in
  25760. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25761. * @param result The vector3 that the rotation should be copied to
  25762. */
  25763. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25764. /**
  25765. * Get the quaternion rotation of the bone in either local or world space
  25766. * @param space The space that the rotation should be in
  25767. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25768. * @returns The quaternion rotation
  25769. */
  25770. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  25771. /**
  25772. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  25773. * @param space The space that the rotation should be in
  25774. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25775. * @param result The quaternion that the rotation should be copied to
  25776. */
  25777. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  25778. /**
  25779. * Get the rotation matrix of the bone in local or world space
  25780. * @param space The space that the rotation should be in
  25781. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25782. * @returns The rotation matrix
  25783. */
  25784. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  25785. /**
  25786. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  25787. * @param space The space that the rotation should be in
  25788. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25789. * @param result The quaternion that the rotation should be copied to
  25790. */
  25791. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  25792. /**
  25793. * Get the world position of a point that is in the local space of the bone
  25794. * @param position The local position
  25795. * @param mesh The mesh that this bone is attached to
  25796. * @returns The world position
  25797. */
  25798. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25799. /**
  25800. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  25801. * @param position The local position
  25802. * @param mesh The mesh that this bone is attached to
  25803. * @param result The vector3 that the world position should be copied to
  25804. */
  25805. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25806. /**
  25807. * Get the local position of a point that is in world space
  25808. * @param position The world position
  25809. * @param mesh The mesh that this bone is attached to
  25810. * @returns The local position
  25811. */
  25812. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25813. /**
  25814. * Get the local position of a point that is in world space and copy it to the result param
  25815. * @param position The world position
  25816. * @param mesh The mesh that this bone is attached to
  25817. * @param result The vector3 that the local position should be copied to
  25818. */
  25819. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25820. /**
  25821. * Set the current local matrix as the restPose for this bone.
  25822. */
  25823. setCurrentPoseAsRest(): void;
  25824. }
  25825. }
  25826. declare module BABYLON {
  25827. /**
  25828. * 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.
  25829. * @see https://doc.babylonjs.com/how_to/transformnode
  25830. */
  25831. export class TransformNode extends Node {
  25832. /**
  25833. * Object will not rotate to face the camera
  25834. */
  25835. static BILLBOARDMODE_NONE: number;
  25836. /**
  25837. * Object will rotate to face the camera but only on the x axis
  25838. */
  25839. static BILLBOARDMODE_X: number;
  25840. /**
  25841. * Object will rotate to face the camera but only on the y axis
  25842. */
  25843. static BILLBOARDMODE_Y: number;
  25844. /**
  25845. * Object will rotate to face the camera but only on the z axis
  25846. */
  25847. static BILLBOARDMODE_Z: number;
  25848. /**
  25849. * Object will rotate to face the camera
  25850. */
  25851. static BILLBOARDMODE_ALL: number;
  25852. /**
  25853. * Object will rotate to face the camera's position instead of orientation
  25854. */
  25855. static BILLBOARDMODE_USE_POSITION: number;
  25856. private static _TmpRotation;
  25857. private static _TmpScaling;
  25858. private static _TmpTranslation;
  25859. private _forward;
  25860. private _forwardInverted;
  25861. private _up;
  25862. private _right;
  25863. private _rightInverted;
  25864. private _position;
  25865. private _rotation;
  25866. private _rotationQuaternion;
  25867. protected _scaling: Vector3;
  25868. protected _isDirty: boolean;
  25869. private _transformToBoneReferal;
  25870. private _isAbsoluteSynced;
  25871. private _billboardMode;
  25872. /**
  25873. * Gets or sets the billboard mode. Default is 0.
  25874. *
  25875. * | Value | Type | Description |
  25876. * | --- | --- | --- |
  25877. * | 0 | BILLBOARDMODE_NONE | |
  25878. * | 1 | BILLBOARDMODE_X | |
  25879. * | 2 | BILLBOARDMODE_Y | |
  25880. * | 4 | BILLBOARDMODE_Z | |
  25881. * | 7 | BILLBOARDMODE_ALL | |
  25882. *
  25883. */
  25884. get billboardMode(): number;
  25885. set billboardMode(value: number);
  25886. private _preserveParentRotationForBillboard;
  25887. /**
  25888. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  25889. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  25890. */
  25891. get preserveParentRotationForBillboard(): boolean;
  25892. set preserveParentRotationForBillboard(value: boolean);
  25893. /**
  25894. * 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
  25895. */
  25896. scalingDeterminant: number;
  25897. private _infiniteDistance;
  25898. /**
  25899. * Gets or sets the distance of the object to max, often used by skybox
  25900. */
  25901. get infiniteDistance(): boolean;
  25902. set infiniteDistance(value: boolean);
  25903. /**
  25904. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  25905. * By default the system will update normals to compensate
  25906. */
  25907. ignoreNonUniformScaling: boolean;
  25908. /**
  25909. * 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
  25910. */
  25911. reIntegrateRotationIntoRotationQuaternion: boolean;
  25912. /** @hidden */
  25913. _poseMatrix: Nullable<Matrix>;
  25914. /** @hidden */
  25915. _localMatrix: Matrix;
  25916. private _usePivotMatrix;
  25917. private _absolutePosition;
  25918. private _absoluteScaling;
  25919. private _absoluteRotationQuaternion;
  25920. private _pivotMatrix;
  25921. private _pivotMatrixInverse;
  25922. /** @hidden */
  25923. _postMultiplyPivotMatrix: boolean;
  25924. protected _isWorldMatrixFrozen: boolean;
  25925. /** @hidden */
  25926. _indexInSceneTransformNodesArray: number;
  25927. /**
  25928. * An event triggered after the world matrix is updated
  25929. */
  25930. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  25931. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  25932. /**
  25933. * Gets a string identifying the name of the class
  25934. * @returns "TransformNode" string
  25935. */
  25936. getClassName(): string;
  25937. /**
  25938. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  25939. */
  25940. get position(): Vector3;
  25941. set position(newPosition: Vector3);
  25942. /**
  25943. * 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)).
  25944. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  25945. */
  25946. get rotation(): Vector3;
  25947. set rotation(newRotation: Vector3);
  25948. /**
  25949. * 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)).
  25950. */
  25951. get scaling(): Vector3;
  25952. set scaling(newScaling: Vector3);
  25953. /**
  25954. * 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).
  25955. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  25956. */
  25957. get rotationQuaternion(): Nullable<Quaternion>;
  25958. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  25959. /**
  25960. * The forward direction of that transform in world space.
  25961. */
  25962. get forward(): Vector3;
  25963. /**
  25964. * The up direction of that transform in world space.
  25965. */
  25966. get up(): Vector3;
  25967. /**
  25968. * The right direction of that transform in world space.
  25969. */
  25970. get right(): Vector3;
  25971. /**
  25972. * Copies the parameter passed Matrix into the mesh Pose matrix.
  25973. * @param matrix the matrix to copy the pose from
  25974. * @returns this TransformNode.
  25975. */
  25976. updatePoseMatrix(matrix: Matrix): TransformNode;
  25977. /**
  25978. * Returns the mesh Pose matrix.
  25979. * @returns the pose matrix
  25980. */
  25981. getPoseMatrix(): Matrix;
  25982. /** @hidden */
  25983. _isSynchronized(): boolean;
  25984. /** @hidden */
  25985. _initCache(): void;
  25986. /**
  25987. * Flag the transform node as dirty (Forcing it to update everything)
  25988. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  25989. * @returns this transform node
  25990. */
  25991. markAsDirty(property: string): TransformNode;
  25992. /**
  25993. * Returns the current mesh absolute position.
  25994. * Returns a Vector3.
  25995. */
  25996. get absolutePosition(): Vector3;
  25997. /**
  25998. * Returns the current mesh absolute scaling.
  25999. * Returns a Vector3.
  26000. */
  26001. get absoluteScaling(): Vector3;
  26002. /**
  26003. * Returns the current mesh absolute rotation.
  26004. * Returns a Quaternion.
  26005. */
  26006. get absoluteRotationQuaternion(): Quaternion;
  26007. /**
  26008. * Sets a new matrix to apply before all other transformation
  26009. * @param matrix defines the transform matrix
  26010. * @returns the current TransformNode
  26011. */
  26012. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26013. /**
  26014. * Sets a new pivot matrix to the current node
  26015. * @param matrix defines the new pivot matrix to use
  26016. * @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
  26017. * @returns the current TransformNode
  26018. */
  26019. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26020. /**
  26021. * Returns the mesh pivot matrix.
  26022. * Default : Identity.
  26023. * @returns the matrix
  26024. */
  26025. getPivotMatrix(): Matrix;
  26026. /**
  26027. * Instantiate (when possible) or clone that node with its hierarchy
  26028. * @param newParent defines the new parent to use for the instance (or clone)
  26029. * @param options defines options to configure how copy is done
  26030. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26031. * @returns an instance (or a clone) of the current node with its hiearchy
  26032. */
  26033. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26034. doNotInstantiate: boolean;
  26035. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26036. /**
  26037. * Prevents the World matrix to be computed any longer
  26038. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26039. * @returns the TransformNode.
  26040. */
  26041. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26042. /**
  26043. * Allows back the World matrix computation.
  26044. * @returns the TransformNode.
  26045. */
  26046. unfreezeWorldMatrix(): this;
  26047. /**
  26048. * True if the World matrix has been frozen.
  26049. */
  26050. get isWorldMatrixFrozen(): boolean;
  26051. /**
  26052. * Retuns the mesh absolute position in the World.
  26053. * @returns a Vector3.
  26054. */
  26055. getAbsolutePosition(): Vector3;
  26056. /**
  26057. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26058. * @param absolutePosition the absolute position to set
  26059. * @returns the TransformNode.
  26060. */
  26061. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26062. /**
  26063. * Sets the mesh position in its local space.
  26064. * @param vector3 the position to set in localspace
  26065. * @returns the TransformNode.
  26066. */
  26067. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26068. /**
  26069. * Returns the mesh position in the local space from the current World matrix values.
  26070. * @returns a new Vector3.
  26071. */
  26072. getPositionExpressedInLocalSpace(): Vector3;
  26073. /**
  26074. * Translates the mesh along the passed Vector3 in its local space.
  26075. * @param vector3 the distance to translate in localspace
  26076. * @returns the TransformNode.
  26077. */
  26078. locallyTranslate(vector3: Vector3): TransformNode;
  26079. private static _lookAtVectorCache;
  26080. /**
  26081. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26082. * @param targetPoint the position (must be in same space as current mesh) to look at
  26083. * @param yawCor optional yaw (y-axis) correction in radians
  26084. * @param pitchCor optional pitch (x-axis) correction in radians
  26085. * @param rollCor optional roll (z-axis) correction in radians
  26086. * @param space the choosen space of the target
  26087. * @returns the TransformNode.
  26088. */
  26089. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26090. /**
  26091. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26092. * This Vector3 is expressed in the World space.
  26093. * @param localAxis axis to rotate
  26094. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26095. */
  26096. getDirection(localAxis: Vector3): Vector3;
  26097. /**
  26098. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26099. * localAxis is expressed in the mesh local space.
  26100. * result is computed in the Wordl space from the mesh World matrix.
  26101. * @param localAxis axis to rotate
  26102. * @param result the resulting transformnode
  26103. * @returns this TransformNode.
  26104. */
  26105. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26106. /**
  26107. * Sets this transform node rotation to the given local axis.
  26108. * @param localAxis the axis in local space
  26109. * @param yawCor optional yaw (y-axis) correction in radians
  26110. * @param pitchCor optional pitch (x-axis) correction in radians
  26111. * @param rollCor optional roll (z-axis) correction in radians
  26112. * @returns this TransformNode
  26113. */
  26114. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26115. /**
  26116. * Sets a new pivot point to the current node
  26117. * @param point defines the new pivot point to use
  26118. * @param space defines if the point is in world or local space (local by default)
  26119. * @returns the current TransformNode
  26120. */
  26121. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26122. /**
  26123. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26124. * @returns the pivot point
  26125. */
  26126. getPivotPoint(): Vector3;
  26127. /**
  26128. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26129. * @param result the vector3 to store the result
  26130. * @returns this TransformNode.
  26131. */
  26132. getPivotPointToRef(result: Vector3): TransformNode;
  26133. /**
  26134. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26135. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26136. */
  26137. getAbsolutePivotPoint(): Vector3;
  26138. /**
  26139. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26140. * @param result vector3 to store the result
  26141. * @returns this TransformNode.
  26142. */
  26143. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26144. /**
  26145. * Defines the passed node as the parent of the current node.
  26146. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26147. * @see https://doc.babylonjs.com/how_to/parenting
  26148. * @param node the node ot set as the parent
  26149. * @returns this TransformNode.
  26150. */
  26151. setParent(node: Nullable<Node>): TransformNode;
  26152. private _nonUniformScaling;
  26153. /**
  26154. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26155. */
  26156. get nonUniformScaling(): boolean;
  26157. /** @hidden */
  26158. _updateNonUniformScalingState(value: boolean): boolean;
  26159. /**
  26160. * Attach the current TransformNode to another TransformNode associated with a bone
  26161. * @param bone Bone affecting the TransformNode
  26162. * @param affectedTransformNode TransformNode associated with the bone
  26163. * @returns this object
  26164. */
  26165. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26166. /**
  26167. * Detach the transform node if its associated with a bone
  26168. * @returns this object
  26169. */
  26170. detachFromBone(): TransformNode;
  26171. private static _rotationAxisCache;
  26172. /**
  26173. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26174. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26175. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26176. * The passed axis is also normalized.
  26177. * @param axis the axis to rotate around
  26178. * @param amount the amount to rotate in radians
  26179. * @param space Space to rotate in (Default: local)
  26180. * @returns the TransformNode.
  26181. */
  26182. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26183. /**
  26184. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26185. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26186. * The passed axis is also normalized. .
  26187. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26188. * @param point the point to rotate around
  26189. * @param axis the axis to rotate around
  26190. * @param amount the amount to rotate in radians
  26191. * @returns the TransformNode
  26192. */
  26193. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26194. /**
  26195. * Translates the mesh along the axis vector for the passed distance in the given space.
  26196. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26197. * @param axis the axis to translate in
  26198. * @param distance the distance to translate
  26199. * @param space Space to rotate in (Default: local)
  26200. * @returns the TransformNode.
  26201. */
  26202. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26203. /**
  26204. * Adds a rotation step to the mesh current rotation.
  26205. * x, y, z are Euler angles expressed in radians.
  26206. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26207. * This means this rotation is made in the mesh local space only.
  26208. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26209. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26210. * ```javascript
  26211. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26212. * ```
  26213. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26214. * 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.
  26215. * @param x Rotation to add
  26216. * @param y Rotation to add
  26217. * @param z Rotation to add
  26218. * @returns the TransformNode.
  26219. */
  26220. addRotation(x: number, y: number, z: number): TransformNode;
  26221. /**
  26222. * @hidden
  26223. */
  26224. protected _getEffectiveParent(): Nullable<Node>;
  26225. /**
  26226. * Computes the world matrix of the node
  26227. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26228. * @returns the world matrix
  26229. */
  26230. computeWorldMatrix(force?: boolean): Matrix;
  26231. /**
  26232. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26233. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26234. */
  26235. resetLocalMatrix(independentOfChildren?: boolean): void;
  26236. protected _afterComputeWorldMatrix(): void;
  26237. /**
  26238. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26239. * @param func callback function to add
  26240. *
  26241. * @returns the TransformNode.
  26242. */
  26243. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26244. /**
  26245. * Removes a registered callback function.
  26246. * @param func callback function to remove
  26247. * @returns the TransformNode.
  26248. */
  26249. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26250. /**
  26251. * Gets the position of the current mesh in camera space
  26252. * @param camera defines the camera to use
  26253. * @returns a position
  26254. */
  26255. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26256. /**
  26257. * Returns the distance from the mesh to the active camera
  26258. * @param camera defines the camera to use
  26259. * @returns the distance
  26260. */
  26261. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26262. /**
  26263. * Clone the current transform node
  26264. * @param name Name of the new clone
  26265. * @param newParent New parent for the clone
  26266. * @param doNotCloneChildren Do not clone children hierarchy
  26267. * @returns the new transform node
  26268. */
  26269. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26270. /**
  26271. * Serializes the objects information.
  26272. * @param currentSerializationObject defines the object to serialize in
  26273. * @returns the serialized object
  26274. */
  26275. serialize(currentSerializationObject?: any): any;
  26276. /**
  26277. * Returns a new TransformNode object parsed from the source provided.
  26278. * @param parsedTransformNode is the source.
  26279. * @param scene the scne the object belongs to
  26280. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26281. * @returns a new TransformNode object parsed from the source provided.
  26282. */
  26283. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26284. /**
  26285. * Get all child-transformNodes of this node
  26286. * @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
  26287. * @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
  26288. * @returns an array of TransformNode
  26289. */
  26290. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26291. /**
  26292. * Releases resources associated with this transform node.
  26293. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26294. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26295. */
  26296. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26297. /**
  26298. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26299. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26300. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26301. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26302. * @returns the current mesh
  26303. */
  26304. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  26305. private _syncAbsoluteScalingAndRotation;
  26306. }
  26307. }
  26308. declare module BABYLON {
  26309. /**
  26310. * Defines the types of pose enabled controllers that are supported
  26311. */
  26312. export enum PoseEnabledControllerType {
  26313. /**
  26314. * HTC Vive
  26315. */
  26316. VIVE = 0,
  26317. /**
  26318. * Oculus Rift
  26319. */
  26320. OCULUS = 1,
  26321. /**
  26322. * Windows mixed reality
  26323. */
  26324. WINDOWS = 2,
  26325. /**
  26326. * Samsung gear VR
  26327. */
  26328. GEAR_VR = 3,
  26329. /**
  26330. * Google Daydream
  26331. */
  26332. DAYDREAM = 4,
  26333. /**
  26334. * Generic
  26335. */
  26336. GENERIC = 5
  26337. }
  26338. /**
  26339. * Defines the MutableGamepadButton interface for the state of a gamepad button
  26340. */
  26341. export interface MutableGamepadButton {
  26342. /**
  26343. * Value of the button/trigger
  26344. */
  26345. value: number;
  26346. /**
  26347. * If the button/trigger is currently touched
  26348. */
  26349. touched: boolean;
  26350. /**
  26351. * If the button/trigger is currently pressed
  26352. */
  26353. pressed: boolean;
  26354. }
  26355. /**
  26356. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  26357. * @hidden
  26358. */
  26359. export interface ExtendedGamepadButton extends GamepadButton {
  26360. /**
  26361. * If the button/trigger is currently pressed
  26362. */
  26363. readonly pressed: boolean;
  26364. /**
  26365. * If the button/trigger is currently touched
  26366. */
  26367. readonly touched: boolean;
  26368. /**
  26369. * Value of the button/trigger
  26370. */
  26371. readonly value: number;
  26372. }
  26373. /** @hidden */
  26374. export interface _GamePadFactory {
  26375. /**
  26376. * Returns whether or not the current gamepad can be created for this type of controller.
  26377. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26378. * @returns true if it can be created, otherwise false
  26379. */
  26380. canCreate(gamepadInfo: any): boolean;
  26381. /**
  26382. * Creates a new instance of the Gamepad.
  26383. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26384. * @returns the new gamepad instance
  26385. */
  26386. create(gamepadInfo: any): Gamepad;
  26387. }
  26388. /**
  26389. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26390. */
  26391. export class PoseEnabledControllerHelper {
  26392. /** @hidden */
  26393. static _ControllerFactories: _GamePadFactory[];
  26394. /** @hidden */
  26395. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  26396. /**
  26397. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26398. * @param vrGamepad the gamepad to initialized
  26399. * @returns a vr controller of the type the gamepad identified as
  26400. */
  26401. static InitiateController(vrGamepad: any): Gamepad;
  26402. }
  26403. /**
  26404. * Defines the PoseEnabledController object that contains state of a vr capable controller
  26405. */
  26406. export class PoseEnabledController extends Gamepad implements PoseControlled {
  26407. /**
  26408. * If the controller is used in a webXR session
  26409. */
  26410. isXR: boolean;
  26411. private _deviceRoomPosition;
  26412. private _deviceRoomRotationQuaternion;
  26413. /**
  26414. * The device position in babylon space
  26415. */
  26416. devicePosition: Vector3;
  26417. /**
  26418. * The device rotation in babylon space
  26419. */
  26420. deviceRotationQuaternion: Quaternion;
  26421. /**
  26422. * The scale factor of the device in babylon space
  26423. */
  26424. deviceScaleFactor: number;
  26425. /**
  26426. * (Likely devicePosition should be used instead) The device position in its room space
  26427. */
  26428. position: Vector3;
  26429. /**
  26430. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  26431. */
  26432. rotationQuaternion: Quaternion;
  26433. /**
  26434. * The type of controller (Eg. Windows mixed reality)
  26435. */
  26436. controllerType: PoseEnabledControllerType;
  26437. protected _calculatedPosition: Vector3;
  26438. private _calculatedRotation;
  26439. /**
  26440. * The raw pose from the device
  26441. */
  26442. rawPose: DevicePose;
  26443. private _trackPosition;
  26444. private _maxRotationDistFromHeadset;
  26445. private _draggedRoomRotation;
  26446. /**
  26447. * @hidden
  26448. */
  26449. _disableTrackPosition(fixedPosition: Vector3): void;
  26450. /**
  26451. * Internal, the mesh attached to the controller
  26452. * @hidden
  26453. */
  26454. _mesh: Nullable<AbstractMesh>;
  26455. private _poseControlledCamera;
  26456. private _leftHandSystemQuaternion;
  26457. /**
  26458. * Internal, matrix used to convert room space to babylon space
  26459. * @hidden
  26460. */
  26461. _deviceToWorld: Matrix;
  26462. /**
  26463. * Node to be used when casting a ray from the controller
  26464. * @hidden
  26465. */
  26466. _pointingPoseNode: Nullable<TransformNode>;
  26467. /**
  26468. * Name of the child mesh that can be used to cast a ray from the controller
  26469. */
  26470. static readonly POINTING_POSE: string;
  26471. /**
  26472. * Creates a new PoseEnabledController from a gamepad
  26473. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  26474. */
  26475. constructor(browserGamepad: any);
  26476. private _workingMatrix;
  26477. /**
  26478. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  26479. */
  26480. update(): void;
  26481. /**
  26482. * Updates only the pose device and mesh without doing any button event checking
  26483. */
  26484. protected _updatePoseAndMesh(): void;
  26485. /**
  26486. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  26487. * @param poseData raw pose fromthe device
  26488. */
  26489. updateFromDevice(poseData: DevicePose): void;
  26490. /**
  26491. * @hidden
  26492. */
  26493. _meshAttachedObservable: Observable<AbstractMesh>;
  26494. /**
  26495. * Attaches a mesh to the controller
  26496. * @param mesh the mesh to be attached
  26497. */
  26498. attachToMesh(mesh: AbstractMesh): void;
  26499. /**
  26500. * Attaches the controllers mesh to a camera
  26501. * @param camera the camera the mesh should be attached to
  26502. */
  26503. attachToPoseControlledCamera(camera: TargetCamera): void;
  26504. /**
  26505. * Disposes of the controller
  26506. */
  26507. dispose(): void;
  26508. /**
  26509. * The mesh that is attached to the controller
  26510. */
  26511. get mesh(): Nullable<AbstractMesh>;
  26512. /**
  26513. * Gets the ray of the controller in the direction the controller is pointing
  26514. * @param length the length the resulting ray should be
  26515. * @returns a ray in the direction the controller is pointing
  26516. */
  26517. getForwardRay(length?: number): Ray;
  26518. }
  26519. }
  26520. declare module BABYLON {
  26521. /**
  26522. * Defines the WebVRController object that represents controllers tracked in 3D space
  26523. */
  26524. export abstract class WebVRController extends PoseEnabledController {
  26525. /**
  26526. * Internal, the default controller model for the controller
  26527. */
  26528. protected _defaultModel: Nullable<AbstractMesh>;
  26529. /**
  26530. * Fired when the trigger state has changed
  26531. */
  26532. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  26533. /**
  26534. * Fired when the main button state has changed
  26535. */
  26536. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26537. /**
  26538. * Fired when the secondary button state has changed
  26539. */
  26540. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26541. /**
  26542. * Fired when the pad state has changed
  26543. */
  26544. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  26545. /**
  26546. * Fired when controllers stick values have changed
  26547. */
  26548. onPadValuesChangedObservable: Observable<StickValues>;
  26549. /**
  26550. * Array of button availible on the controller
  26551. */
  26552. protected _buttons: Array<MutableGamepadButton>;
  26553. private _onButtonStateChange;
  26554. /**
  26555. * Fired when a controller button's state has changed
  26556. * @param callback the callback containing the button that was modified
  26557. */
  26558. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  26559. /**
  26560. * X and Y axis corresponding to the controllers joystick
  26561. */
  26562. pad: StickValues;
  26563. /**
  26564. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  26565. */
  26566. hand: string;
  26567. /**
  26568. * The default controller model for the controller
  26569. */
  26570. get defaultModel(): Nullable<AbstractMesh>;
  26571. /**
  26572. * Creates a new WebVRController from a gamepad
  26573. * @param vrGamepad the gamepad that the WebVRController should be created from
  26574. */
  26575. constructor(vrGamepad: any);
  26576. /**
  26577. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  26578. */
  26579. update(): void;
  26580. /**
  26581. * Function to be called when a button is modified
  26582. */
  26583. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26584. /**
  26585. * Loads a mesh and attaches it to the controller
  26586. * @param scene the scene the mesh should be added to
  26587. * @param meshLoaded callback for when the mesh has been loaded
  26588. */
  26589. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26590. private _setButtonValue;
  26591. private _changes;
  26592. private _checkChanges;
  26593. /**
  26594. * Disposes of th webVRCOntroller
  26595. */
  26596. dispose(): void;
  26597. }
  26598. }
  26599. declare module BABYLON {
  26600. /**
  26601. * The HemisphericLight simulates the ambient environment light,
  26602. * so the passed direction is the light reflection direction, not the incoming direction.
  26603. */
  26604. export class HemisphericLight extends Light {
  26605. /**
  26606. * The groundColor is the light in the opposite direction to the one specified during creation.
  26607. * 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.
  26608. */
  26609. groundColor: Color3;
  26610. /**
  26611. * The light reflection direction, not the incoming direction.
  26612. */
  26613. direction: Vector3;
  26614. /**
  26615. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  26616. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  26617. * The HemisphericLight can't cast shadows.
  26618. * Documentation : https://doc.babylonjs.com/babylon101/lights
  26619. * @param name The friendly name of the light
  26620. * @param direction The direction of the light reflection
  26621. * @param scene The scene the light belongs to
  26622. */
  26623. constructor(name: string, direction: Vector3, scene: Scene);
  26624. protected _buildUniformLayout(): void;
  26625. /**
  26626. * Returns the string "HemisphericLight".
  26627. * @return The class name
  26628. */
  26629. getClassName(): string;
  26630. /**
  26631. * Sets the HemisphericLight direction towards the passed target (Vector3).
  26632. * Returns the updated direction.
  26633. * @param target The target the direction should point to
  26634. * @return The computed direction
  26635. */
  26636. setDirectionToTarget(target: Vector3): Vector3;
  26637. /**
  26638. * Returns the shadow generator associated to the light.
  26639. * @returns Always null for hemispheric lights because it does not support shadows.
  26640. */
  26641. getShadowGenerator(): Nullable<IShadowGenerator>;
  26642. /**
  26643. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  26644. * @param effect The effect to update
  26645. * @param lightIndex The index of the light in the effect to update
  26646. * @returns The hemispheric light
  26647. */
  26648. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  26649. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  26650. /**
  26651. * Computes the world matrix of the node
  26652. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26653. * @param useWasUpdatedFlag defines a reserved property
  26654. * @returns the world matrix
  26655. */
  26656. computeWorldMatrix(): Matrix;
  26657. /**
  26658. * Returns the integer 3.
  26659. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  26660. */
  26661. getTypeID(): number;
  26662. /**
  26663. * Prepares the list of defines specific to the light type.
  26664. * @param defines the list of defines
  26665. * @param lightIndex defines the index of the light for the effect
  26666. */
  26667. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  26668. }
  26669. }
  26670. declare module BABYLON {
  26671. /** @hidden */
  26672. export var vrMultiviewToSingleviewPixelShader: {
  26673. name: string;
  26674. shader: string;
  26675. };
  26676. }
  26677. declare module BABYLON {
  26678. /**
  26679. * Renders to multiple views with a single draw call
  26680. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  26681. */
  26682. export class MultiviewRenderTarget extends RenderTargetTexture {
  26683. /**
  26684. * Creates a multiview render target
  26685. * @param scene scene used with the render target
  26686. * @param size the size of the render target (used for each view)
  26687. */
  26688. constructor(scene: Scene, size?: number | {
  26689. width: number;
  26690. height: number;
  26691. } | {
  26692. ratio: number;
  26693. });
  26694. /**
  26695. * @hidden
  26696. * @param faceIndex the face index, if its a cube texture
  26697. */
  26698. _bindFrameBuffer(faceIndex?: number): void;
  26699. /**
  26700. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  26701. * @returns the view count
  26702. */
  26703. getViewCount(): number;
  26704. }
  26705. }
  26706. declare module BABYLON {
  26707. interface Engine {
  26708. /**
  26709. * Creates a new multiview render target
  26710. * @param width defines the width of the texture
  26711. * @param height defines the height of the texture
  26712. * @returns the created multiview texture
  26713. */
  26714. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  26715. /**
  26716. * Binds a multiview framebuffer to be drawn to
  26717. * @param multiviewTexture texture to bind
  26718. */
  26719. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  26720. }
  26721. interface Camera {
  26722. /**
  26723. * @hidden
  26724. * 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)
  26725. */
  26726. _useMultiviewToSingleView: boolean;
  26727. /**
  26728. * @hidden
  26729. * 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)
  26730. */
  26731. _multiviewTexture: Nullable<RenderTargetTexture>;
  26732. /**
  26733. * @hidden
  26734. * ensures the multiview texture of the camera exists and has the specified width/height
  26735. * @param width height to set on the multiview texture
  26736. * @param height width to set on the multiview texture
  26737. */
  26738. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  26739. }
  26740. interface Scene {
  26741. /** @hidden */
  26742. _transformMatrixR: Matrix;
  26743. /** @hidden */
  26744. _multiviewSceneUbo: Nullable<UniformBuffer>;
  26745. /** @hidden */
  26746. _createMultiviewUbo(): void;
  26747. /** @hidden */
  26748. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  26749. /** @hidden */
  26750. _renderMultiviewToSingleView(camera: Camera): void;
  26751. }
  26752. }
  26753. declare module BABYLON {
  26754. /**
  26755. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  26756. * This will not be used for webXR as it supports displaying texture arrays directly
  26757. */
  26758. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  26759. /**
  26760. * Gets a string identifying the name of the class
  26761. * @returns "VRMultiviewToSingleviewPostProcess" string
  26762. */
  26763. getClassName(): string;
  26764. /**
  26765. * Initializes a VRMultiviewToSingleview
  26766. * @param name name of the post process
  26767. * @param camera camera to be applied to
  26768. * @param scaleFactor scaling factor to the size of the output texture
  26769. */
  26770. constructor(name: string, camera: Camera, scaleFactor: number);
  26771. }
  26772. }
  26773. declare module BABYLON {
  26774. /**
  26775. * Interface used to define additional presentation attributes
  26776. */
  26777. export interface IVRPresentationAttributes {
  26778. /**
  26779. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  26780. */
  26781. highRefreshRate: boolean;
  26782. /**
  26783. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  26784. */
  26785. foveationLevel: number;
  26786. }
  26787. interface Engine {
  26788. /** @hidden */
  26789. _vrDisplay: any;
  26790. /** @hidden */
  26791. _vrSupported: boolean;
  26792. /** @hidden */
  26793. _oldSize: Size;
  26794. /** @hidden */
  26795. _oldHardwareScaleFactor: number;
  26796. /** @hidden */
  26797. _vrExclusivePointerMode: boolean;
  26798. /** @hidden */
  26799. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  26800. /** @hidden */
  26801. _onVRDisplayPointerRestricted: () => void;
  26802. /** @hidden */
  26803. _onVRDisplayPointerUnrestricted: () => void;
  26804. /** @hidden */
  26805. _onVrDisplayConnect: Nullable<(display: any) => void>;
  26806. /** @hidden */
  26807. _onVrDisplayDisconnect: Nullable<() => void>;
  26808. /** @hidden */
  26809. _onVrDisplayPresentChange: Nullable<() => void>;
  26810. /**
  26811. * Observable signaled when VR display mode changes
  26812. */
  26813. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26814. /**
  26815. * Observable signaled when VR request present is complete
  26816. */
  26817. onVRRequestPresentComplete: Observable<boolean>;
  26818. /**
  26819. * Observable signaled when VR request present starts
  26820. */
  26821. onVRRequestPresentStart: Observable<Engine>;
  26822. /**
  26823. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26824. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26825. */
  26826. isInVRExclusivePointerMode: boolean;
  26827. /**
  26828. * Gets a boolean indicating if a webVR device was detected
  26829. * @returns true if a webVR device was detected
  26830. */
  26831. isVRDevicePresent(): boolean;
  26832. /**
  26833. * Gets the current webVR device
  26834. * @returns the current webVR device (or null)
  26835. */
  26836. getVRDevice(): any;
  26837. /**
  26838. * Initializes a webVR display and starts listening to display change events
  26839. * The onVRDisplayChangedObservable will be notified upon these changes
  26840. * @returns A promise containing a VRDisplay and if vr is supported
  26841. */
  26842. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  26843. /** @hidden */
  26844. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  26845. /**
  26846. * Gets or sets the presentation attributes used to configure VR rendering
  26847. */
  26848. vrPresentationAttributes?: IVRPresentationAttributes;
  26849. /**
  26850. * Call this function to switch to webVR mode
  26851. * Will do nothing if webVR is not supported or if there is no webVR device
  26852. * @param options the webvr options provided to the camera. mainly used for multiview
  26853. * @see https://doc.babylonjs.com/how_to/webvr_camera
  26854. */
  26855. enableVR(options: WebVROptions): void;
  26856. /** @hidden */
  26857. _onVRFullScreenTriggered(): void;
  26858. }
  26859. }
  26860. declare module BABYLON {
  26861. /**
  26862. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  26863. * IMPORTANT!! The data is right-hand data.
  26864. * @export
  26865. * @interface DevicePose
  26866. */
  26867. export interface DevicePose {
  26868. /**
  26869. * The position of the device, values in array are [x,y,z].
  26870. */
  26871. readonly position: Nullable<Float32Array>;
  26872. /**
  26873. * The linearVelocity of the device, values in array are [x,y,z].
  26874. */
  26875. readonly linearVelocity: Nullable<Float32Array>;
  26876. /**
  26877. * The linearAcceleration of the device, values in array are [x,y,z].
  26878. */
  26879. readonly linearAcceleration: Nullable<Float32Array>;
  26880. /**
  26881. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  26882. */
  26883. readonly orientation: Nullable<Float32Array>;
  26884. /**
  26885. * The angularVelocity of the device, values in array are [x,y,z].
  26886. */
  26887. readonly angularVelocity: Nullable<Float32Array>;
  26888. /**
  26889. * The angularAcceleration of the device, values in array are [x,y,z].
  26890. */
  26891. readonly angularAcceleration: Nullable<Float32Array>;
  26892. }
  26893. /**
  26894. * Interface representing a pose controlled object in Babylon.
  26895. * A pose controlled object has both regular pose values as well as pose values
  26896. * from an external device such as a VR head mounted display
  26897. */
  26898. export interface PoseControlled {
  26899. /**
  26900. * The position of the object in babylon space.
  26901. */
  26902. position: Vector3;
  26903. /**
  26904. * The rotation quaternion of the object in babylon space.
  26905. */
  26906. rotationQuaternion: Quaternion;
  26907. /**
  26908. * The position of the device in babylon space.
  26909. */
  26910. devicePosition?: Vector3;
  26911. /**
  26912. * The rotation quaternion of the device in babylon space.
  26913. */
  26914. deviceRotationQuaternion: Quaternion;
  26915. /**
  26916. * The raw pose coming from the device.
  26917. */
  26918. rawPose: Nullable<DevicePose>;
  26919. /**
  26920. * The scale of the device to be used when translating from device space to babylon space.
  26921. */
  26922. deviceScaleFactor: number;
  26923. /**
  26924. * Updates the poseControlled values based on the input device pose.
  26925. * @param poseData the pose data to update the object with
  26926. */
  26927. updateFromDevice(poseData: DevicePose): void;
  26928. }
  26929. /**
  26930. * Set of options to customize the webVRCamera
  26931. */
  26932. export interface WebVROptions {
  26933. /**
  26934. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  26935. */
  26936. trackPosition?: boolean;
  26937. /**
  26938. * Sets the scale of the vrDevice in babylon space. (default: 1)
  26939. */
  26940. positionScale?: number;
  26941. /**
  26942. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  26943. */
  26944. displayName?: string;
  26945. /**
  26946. * Should the native controller meshes be initialized. (default: true)
  26947. */
  26948. controllerMeshes?: boolean;
  26949. /**
  26950. * Creating a default HemiLight only on controllers. (default: true)
  26951. */
  26952. defaultLightingOnControllers?: boolean;
  26953. /**
  26954. * If you don't want to use the default VR button of the helper. (default: false)
  26955. */
  26956. useCustomVRButton?: boolean;
  26957. /**
  26958. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  26959. */
  26960. customVRButton?: HTMLButtonElement;
  26961. /**
  26962. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  26963. */
  26964. rayLength?: number;
  26965. /**
  26966. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  26967. */
  26968. defaultHeight?: number;
  26969. /**
  26970. * If multiview should be used if availible (default: false)
  26971. */
  26972. useMultiview?: boolean;
  26973. }
  26974. /**
  26975. * This represents a WebVR camera.
  26976. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  26977. * @example https://doc.babylonjs.com/how_to/webvr_camera
  26978. */
  26979. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  26980. private webVROptions;
  26981. /**
  26982. * @hidden
  26983. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  26984. */
  26985. _vrDevice: any;
  26986. /**
  26987. * The rawPose of the vrDevice.
  26988. */
  26989. rawPose: Nullable<DevicePose>;
  26990. private _onVREnabled;
  26991. private _specsVersion;
  26992. private _attached;
  26993. private _frameData;
  26994. protected _descendants: Array<Node>;
  26995. private _deviceRoomPosition;
  26996. /** @hidden */
  26997. _deviceRoomRotationQuaternion: Quaternion;
  26998. private _standingMatrix;
  26999. /**
  27000. * Represents device position in babylon space.
  27001. */
  27002. devicePosition: Vector3;
  27003. /**
  27004. * Represents device rotation in babylon space.
  27005. */
  27006. deviceRotationQuaternion: Quaternion;
  27007. /**
  27008. * The scale of the device to be used when translating from device space to babylon space.
  27009. */
  27010. deviceScaleFactor: number;
  27011. private _deviceToWorld;
  27012. private _worldToDevice;
  27013. /**
  27014. * References to the webVR controllers for the vrDevice.
  27015. */
  27016. controllers: Array<WebVRController>;
  27017. /**
  27018. * Emits an event when a controller is attached.
  27019. */
  27020. onControllersAttachedObservable: Observable<WebVRController[]>;
  27021. /**
  27022. * Emits an event when a controller's mesh has been loaded;
  27023. */
  27024. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27025. /**
  27026. * Emits an event when the HMD's pose has been updated.
  27027. */
  27028. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27029. private _poseSet;
  27030. /**
  27031. * If the rig cameras be used as parent instead of this camera.
  27032. */
  27033. rigParenting: boolean;
  27034. private _lightOnControllers;
  27035. private _defaultHeight?;
  27036. /**
  27037. * Instantiates a WebVRFreeCamera.
  27038. * @param name The name of the WebVRFreeCamera
  27039. * @param position The starting anchor position for the camera
  27040. * @param scene The scene the camera belongs to
  27041. * @param webVROptions a set of customizable options for the webVRCamera
  27042. */
  27043. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27044. /**
  27045. * Gets the device distance from the ground in meters.
  27046. * @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.
  27047. */
  27048. deviceDistanceToRoomGround(): number;
  27049. /**
  27050. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27051. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27052. */
  27053. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27054. /**
  27055. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27056. * @returns A promise with a boolean set to if the standing matrix is supported.
  27057. */
  27058. useStandingMatrixAsync(): Promise<boolean>;
  27059. /**
  27060. * Disposes the camera
  27061. */
  27062. dispose(): void;
  27063. /**
  27064. * Gets a vrController by name.
  27065. * @param name The name of the controller to retreive
  27066. * @returns the controller matching the name specified or null if not found
  27067. */
  27068. getControllerByName(name: string): Nullable<WebVRController>;
  27069. private _leftController;
  27070. /**
  27071. * The controller corresponding to the users left hand.
  27072. */
  27073. get leftController(): Nullable<WebVRController>;
  27074. private _rightController;
  27075. /**
  27076. * The controller corresponding to the users right hand.
  27077. */
  27078. get rightController(): Nullable<WebVRController>;
  27079. /**
  27080. * Casts a ray forward from the vrCamera's gaze.
  27081. * @param length Length of the ray (default: 100)
  27082. * @returns the ray corresponding to the gaze
  27083. */
  27084. getForwardRay(length?: number): Ray;
  27085. /**
  27086. * @hidden
  27087. * Updates the camera based on device's frame data
  27088. */
  27089. _checkInputs(): void;
  27090. /**
  27091. * Updates the poseControlled values based on the input device pose.
  27092. * @param poseData Pose coming from the device
  27093. */
  27094. updateFromDevice(poseData: DevicePose): void;
  27095. private _detachIfAttached;
  27096. /**
  27097. * WebVR's attach control will start broadcasting frames to the device.
  27098. * Note that in certain browsers (chrome for example) this function must be called
  27099. * within a user-interaction callback. Example:
  27100. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27101. *
  27102. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27103. */
  27104. attachControl(noPreventDefault?: boolean): void;
  27105. /**
  27106. * Detach the current controls from the specified dom element.
  27107. */
  27108. detachControl(): void;
  27109. /**
  27110. * @returns the name of this class
  27111. */
  27112. getClassName(): string;
  27113. /**
  27114. * Calls resetPose on the vrDisplay
  27115. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27116. */
  27117. resetToCurrentRotation(): void;
  27118. /**
  27119. * @hidden
  27120. * Updates the rig cameras (left and right eye)
  27121. */
  27122. _updateRigCameras(): void;
  27123. private _workingVector;
  27124. private _oneVector;
  27125. private _workingMatrix;
  27126. private updateCacheCalled;
  27127. private _correctPositionIfNotTrackPosition;
  27128. /**
  27129. * @hidden
  27130. * Updates the cached values of the camera
  27131. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27132. */
  27133. _updateCache(ignoreParentClass?: boolean): void;
  27134. /**
  27135. * @hidden
  27136. * Get current device position in babylon world
  27137. */
  27138. _computeDevicePosition(): void;
  27139. /**
  27140. * Updates the current device position and rotation in the babylon world
  27141. */
  27142. update(): void;
  27143. /**
  27144. * @hidden
  27145. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27146. * @returns an identity matrix
  27147. */
  27148. _getViewMatrix(): Matrix;
  27149. private _tmpMatrix;
  27150. /**
  27151. * This function is called by the two RIG cameras.
  27152. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27153. * @hidden
  27154. */
  27155. _getWebVRViewMatrix(): Matrix;
  27156. /** @hidden */
  27157. _getWebVRProjectionMatrix(): Matrix;
  27158. private _onGamepadConnectedObserver;
  27159. private _onGamepadDisconnectedObserver;
  27160. private _updateCacheWhenTrackingDisabledObserver;
  27161. /**
  27162. * Initializes the controllers and their meshes
  27163. */
  27164. initControllers(): void;
  27165. }
  27166. }
  27167. declare module BABYLON {
  27168. /**
  27169. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27170. *
  27171. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27172. *
  27173. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27174. */
  27175. export class MaterialHelper {
  27176. /**
  27177. * Bind the current view position to an effect.
  27178. * @param effect The effect to be bound
  27179. * @param scene The scene the eyes position is used from
  27180. * @param variableName name of the shader variable that will hold the eye position
  27181. */
  27182. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  27183. /**
  27184. * Helps preparing the defines values about the UVs in used in the effect.
  27185. * UVs are shared as much as we can accross channels in the shaders.
  27186. * @param texture The texture we are preparing the UVs for
  27187. * @param defines The defines to update
  27188. * @param key The channel key "diffuse", "specular"... used in the shader
  27189. */
  27190. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27191. /**
  27192. * Binds a texture matrix value to its corrsponding uniform
  27193. * @param texture The texture to bind the matrix for
  27194. * @param uniformBuffer The uniform buffer receivin the data
  27195. * @param key The channel key "diffuse", "specular"... used in the shader
  27196. */
  27197. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27198. /**
  27199. * Gets the current status of the fog (should it be enabled?)
  27200. * @param mesh defines the mesh to evaluate for fog support
  27201. * @param scene defines the hosting scene
  27202. * @returns true if fog must be enabled
  27203. */
  27204. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27205. /**
  27206. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27207. * @param mesh defines the current mesh
  27208. * @param scene defines the current scene
  27209. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27210. * @param pointsCloud defines if point cloud rendering has to be turned on
  27211. * @param fogEnabled defines if fog has to be turned on
  27212. * @param alphaTest defines if alpha testing has to be turned on
  27213. * @param defines defines the current list of defines
  27214. */
  27215. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27216. /**
  27217. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27218. * @param scene defines the current scene
  27219. * @param engine defines the current engine
  27220. * @param defines specifies the list of active defines
  27221. * @param useInstances defines if instances have to be turned on
  27222. * @param useClipPlane defines if clip plane have to be turned on
  27223. * @param useInstances defines if instances have to be turned on
  27224. * @param useThinInstances defines if thin instances have to be turned on
  27225. */
  27226. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27227. /**
  27228. * Prepares the defines for bones
  27229. * @param mesh The mesh containing the geometry data we will draw
  27230. * @param defines The defines to update
  27231. */
  27232. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27233. /**
  27234. * Prepares the defines for morph targets
  27235. * @param mesh The mesh containing the geometry data we will draw
  27236. * @param defines The defines to update
  27237. */
  27238. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27239. /**
  27240. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27241. * @param mesh The mesh containing the geometry data we will draw
  27242. * @param defines The defines to update
  27243. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27244. * @param useBones Precise whether bones should be used or not (override mesh info)
  27245. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27246. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27247. * @returns false if defines are considered not dirty and have not been checked
  27248. */
  27249. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27250. /**
  27251. * Prepares the defines related to multiview
  27252. * @param scene The scene we are intending to draw
  27253. * @param defines The defines to update
  27254. */
  27255. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27256. /**
  27257. * Prepares the defines related to the prepass
  27258. * @param scene The scene we are intending to draw
  27259. * @param defines The defines to update
  27260. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27261. */
  27262. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27263. /**
  27264. * Prepares the defines related to the light information passed in parameter
  27265. * @param scene The scene we are intending to draw
  27266. * @param mesh The mesh the effect is compiling for
  27267. * @param light The light the effect is compiling for
  27268. * @param lightIndex The index of the light
  27269. * @param defines The defines to update
  27270. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27271. * @param state Defines the current state regarding what is needed (normals, etc...)
  27272. */
  27273. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27274. needNormals: boolean;
  27275. needRebuild: boolean;
  27276. shadowEnabled: boolean;
  27277. specularEnabled: boolean;
  27278. lightmapMode: boolean;
  27279. }): void;
  27280. /**
  27281. * Prepares the defines related to the light information passed in parameter
  27282. * @param scene The scene we are intending to draw
  27283. * @param mesh The mesh the effect is compiling for
  27284. * @param defines The defines to update
  27285. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27286. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27287. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27288. * @returns true if normals will be required for the rest of the effect
  27289. */
  27290. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27291. /**
  27292. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27293. * @param lightIndex defines the light index
  27294. * @param uniformsList The uniform list
  27295. * @param samplersList The sampler list
  27296. * @param projectedLightTexture defines if projected texture must be used
  27297. * @param uniformBuffersList defines an optional list of uniform buffers
  27298. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  27299. */
  27300. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  27301. /**
  27302. * Prepares the uniforms and samplers list to be used in the effect
  27303. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  27304. * @param samplersList The sampler list
  27305. * @param defines The defines helping in the list generation
  27306. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  27307. */
  27308. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  27309. /**
  27310. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  27311. * @param defines The defines to update while falling back
  27312. * @param fallbacks The authorized effect fallbacks
  27313. * @param maxSimultaneousLights The maximum number of lights allowed
  27314. * @param rank the current rank of the Effect
  27315. * @returns The newly affected rank
  27316. */
  27317. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  27318. private static _TmpMorphInfluencers;
  27319. /**
  27320. * Prepares the list of attributes required for morph targets according to the effect defines.
  27321. * @param attribs The current list of supported attribs
  27322. * @param mesh The mesh to prepare the morph targets attributes for
  27323. * @param influencers The number of influencers
  27324. */
  27325. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  27326. /**
  27327. * Prepares the list of attributes required for morph targets according to the effect defines.
  27328. * @param attribs The current list of supported attribs
  27329. * @param mesh The mesh to prepare the morph targets attributes for
  27330. * @param defines The current Defines of the effect
  27331. */
  27332. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  27333. /**
  27334. * Prepares the list of attributes required for bones according to the effect defines.
  27335. * @param attribs The current list of supported attribs
  27336. * @param mesh The mesh to prepare the bones attributes for
  27337. * @param defines The current Defines of the effect
  27338. * @param fallbacks The current efffect fallback strategy
  27339. */
  27340. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  27341. /**
  27342. * Check and prepare the list of attributes required for instances according to the effect defines.
  27343. * @param attribs The current list of supported attribs
  27344. * @param defines The current MaterialDefines of the effect
  27345. */
  27346. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  27347. /**
  27348. * Add the list of attributes required for instances to the attribs array.
  27349. * @param attribs The current list of supported attribs
  27350. */
  27351. static PushAttributesForInstances(attribs: string[]): void;
  27352. /**
  27353. * Binds the light information to the effect.
  27354. * @param light The light containing the generator
  27355. * @param effect The effect we are binding the data to
  27356. * @param lightIndex The light index in the effect used to render
  27357. */
  27358. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  27359. /**
  27360. * Binds the lights information from the scene to the effect for the given mesh.
  27361. * @param light Light to bind
  27362. * @param lightIndex Light index
  27363. * @param scene The scene where the light belongs to
  27364. * @param effect The effect we are binding the data to
  27365. * @param useSpecular Defines if specular is supported
  27366. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27367. */
  27368. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  27369. /**
  27370. * Binds the lights information from the scene to the effect for the given mesh.
  27371. * @param scene The scene the lights belongs to
  27372. * @param mesh The mesh we are binding the information to render
  27373. * @param effect The effect we are binding the data to
  27374. * @param defines The generated defines for the effect
  27375. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  27376. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27377. */
  27378. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  27379. private static _tempFogColor;
  27380. /**
  27381. * Binds the fog information from the scene to the effect for the given mesh.
  27382. * @param scene The scene the lights belongs to
  27383. * @param mesh The mesh we are binding the information to render
  27384. * @param effect The effect we are binding the data to
  27385. * @param linearSpace Defines if the fog effect is applied in linear space
  27386. */
  27387. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  27388. /**
  27389. * Binds the bones information from the mesh to the effect.
  27390. * @param mesh The mesh we are binding the information to render
  27391. * @param effect The effect we are binding the data to
  27392. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  27393. */
  27394. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  27395. private static _CopyBonesTransformationMatrices;
  27396. /**
  27397. * Binds the morph targets information from the mesh to the effect.
  27398. * @param abstractMesh The mesh we are binding the information to render
  27399. * @param effect The effect we are binding the data to
  27400. */
  27401. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  27402. /**
  27403. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  27404. * @param defines The generated defines used in the effect
  27405. * @param effect The effect we are binding the data to
  27406. * @param scene The scene we are willing to render with logarithmic scale for
  27407. */
  27408. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  27409. /**
  27410. * Binds the clip plane information from the scene to the effect.
  27411. * @param scene The scene the clip plane information are extracted from
  27412. * @param effect The effect we are binding the data to
  27413. */
  27414. static BindClipPlane(effect: Effect, scene: Scene): void;
  27415. }
  27416. }
  27417. declare module BABYLON {
  27418. /** @hidden */
  27419. export var bayerDitherFunctions: {
  27420. name: string;
  27421. shader: string;
  27422. };
  27423. }
  27424. declare module BABYLON {
  27425. /** @hidden */
  27426. export var shadowMapFragmentDeclaration: {
  27427. name: string;
  27428. shader: string;
  27429. };
  27430. }
  27431. declare module BABYLON {
  27432. /** @hidden */
  27433. export var shadowMapFragment: {
  27434. name: string;
  27435. shader: string;
  27436. };
  27437. }
  27438. declare module BABYLON {
  27439. /** @hidden */
  27440. export var shadowMapPixelShader: {
  27441. name: string;
  27442. shader: string;
  27443. };
  27444. }
  27445. declare module BABYLON {
  27446. /** @hidden */
  27447. export var shadowMapVertexDeclaration: {
  27448. name: string;
  27449. shader: string;
  27450. };
  27451. }
  27452. declare module BABYLON {
  27453. /** @hidden */
  27454. export var shadowMapVertexNormalBias: {
  27455. name: string;
  27456. shader: string;
  27457. };
  27458. }
  27459. declare module BABYLON {
  27460. /** @hidden */
  27461. export var shadowMapVertexMetric: {
  27462. name: string;
  27463. shader: string;
  27464. };
  27465. }
  27466. declare module BABYLON {
  27467. /** @hidden */
  27468. export var shadowMapVertexShader: {
  27469. name: string;
  27470. shader: string;
  27471. };
  27472. }
  27473. declare module BABYLON {
  27474. /** @hidden */
  27475. export var depthBoxBlurPixelShader: {
  27476. name: string;
  27477. shader: string;
  27478. };
  27479. }
  27480. declare module BABYLON {
  27481. /** @hidden */
  27482. export var shadowMapFragmentSoftTransparentShadow: {
  27483. name: string;
  27484. shader: string;
  27485. };
  27486. }
  27487. declare module BABYLON {
  27488. /**
  27489. * Creates an instance based on a source mesh.
  27490. */
  27491. export class InstancedMesh extends AbstractMesh {
  27492. private _sourceMesh;
  27493. private _currentLOD;
  27494. /** @hidden */
  27495. _indexInSourceMeshInstanceArray: number;
  27496. constructor(name: string, source: Mesh);
  27497. /**
  27498. * Returns the string "InstancedMesh".
  27499. */
  27500. getClassName(): string;
  27501. /** Gets the list of lights affecting that mesh */
  27502. get lightSources(): Light[];
  27503. _resyncLightSources(): void;
  27504. _resyncLightSource(light: Light): void;
  27505. _removeLightSource(light: Light, dispose: boolean): void;
  27506. /**
  27507. * If the source mesh receives shadows
  27508. */
  27509. get receiveShadows(): boolean;
  27510. /**
  27511. * The material of the source mesh
  27512. */
  27513. get material(): Nullable<Material>;
  27514. /**
  27515. * Visibility of the source mesh
  27516. */
  27517. get visibility(): number;
  27518. /**
  27519. * Skeleton of the source mesh
  27520. */
  27521. get skeleton(): Nullable<Skeleton>;
  27522. /**
  27523. * Rendering ground id of the source mesh
  27524. */
  27525. get renderingGroupId(): number;
  27526. set renderingGroupId(value: number);
  27527. /**
  27528. * Returns the total number of vertices (integer).
  27529. */
  27530. getTotalVertices(): number;
  27531. /**
  27532. * Returns a positive integer : the total number of indices in this mesh geometry.
  27533. * @returns the numner of indices or zero if the mesh has no geometry.
  27534. */
  27535. getTotalIndices(): number;
  27536. /**
  27537. * The source mesh of the instance
  27538. */
  27539. get sourceMesh(): Mesh;
  27540. /**
  27541. * Creates a new InstancedMesh object from the mesh model.
  27542. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27543. * @param name defines the name of the new instance
  27544. * @returns a new InstancedMesh
  27545. */
  27546. createInstance(name: string): InstancedMesh;
  27547. /**
  27548. * Is this node ready to be used/rendered
  27549. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27550. * @return {boolean} is it ready
  27551. */
  27552. isReady(completeCheck?: boolean): boolean;
  27553. /**
  27554. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27555. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  27556. * @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.
  27557. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  27558. */
  27559. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  27560. /**
  27561. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27562. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27563. * The `data` are either a numeric array either a Float32Array.
  27564. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  27565. * 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).
  27566. * Note that a new underlying VertexBuffer object is created each call.
  27567. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27568. *
  27569. * Possible `kind` values :
  27570. * - VertexBuffer.PositionKind
  27571. * - VertexBuffer.UVKind
  27572. * - VertexBuffer.UV2Kind
  27573. * - VertexBuffer.UV3Kind
  27574. * - VertexBuffer.UV4Kind
  27575. * - VertexBuffer.UV5Kind
  27576. * - VertexBuffer.UV6Kind
  27577. * - VertexBuffer.ColorKind
  27578. * - VertexBuffer.MatricesIndicesKind
  27579. * - VertexBuffer.MatricesIndicesExtraKind
  27580. * - VertexBuffer.MatricesWeightsKind
  27581. * - VertexBuffer.MatricesWeightsExtraKind
  27582. *
  27583. * Returns the Mesh.
  27584. */
  27585. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27586. /**
  27587. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27588. * If the mesh has no geometry, it is simply returned as it is.
  27589. * The `data` are either a numeric array either a Float32Array.
  27590. * No new underlying VertexBuffer object is created.
  27591. * 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.
  27592. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  27593. *
  27594. * Possible `kind` values :
  27595. * - VertexBuffer.PositionKind
  27596. * - VertexBuffer.UVKind
  27597. * - VertexBuffer.UV2Kind
  27598. * - VertexBuffer.UV3Kind
  27599. * - VertexBuffer.UV4Kind
  27600. * - VertexBuffer.UV5Kind
  27601. * - VertexBuffer.UV6Kind
  27602. * - VertexBuffer.ColorKind
  27603. * - VertexBuffer.MatricesIndicesKind
  27604. * - VertexBuffer.MatricesIndicesExtraKind
  27605. * - VertexBuffer.MatricesWeightsKind
  27606. * - VertexBuffer.MatricesWeightsExtraKind
  27607. *
  27608. * Returns the Mesh.
  27609. */
  27610. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27611. /**
  27612. * Sets the mesh indices.
  27613. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  27614. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27615. * This method creates a new index buffer each call.
  27616. * Returns the Mesh.
  27617. */
  27618. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  27619. /**
  27620. * Boolean : True if the mesh owns the requested kind of data.
  27621. */
  27622. isVerticesDataPresent(kind: string): boolean;
  27623. /**
  27624. * Returns an array of indices (IndicesArray).
  27625. */
  27626. getIndices(): Nullable<IndicesArray>;
  27627. get _positions(): Nullable<Vector3[]>;
  27628. /**
  27629. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27630. * This means the mesh underlying bounding box and sphere are recomputed.
  27631. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27632. * @returns the current mesh
  27633. */
  27634. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  27635. /** @hidden */
  27636. _preActivate(): InstancedMesh;
  27637. /** @hidden */
  27638. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27639. /** @hidden */
  27640. _postActivate(): void;
  27641. getWorldMatrix(): Matrix;
  27642. get isAnInstance(): boolean;
  27643. /**
  27644. * Returns the current associated LOD AbstractMesh.
  27645. */
  27646. getLOD(camera: Camera): AbstractMesh;
  27647. /** @hidden */
  27648. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27649. /** @hidden */
  27650. _syncSubMeshes(): InstancedMesh;
  27651. /** @hidden */
  27652. _generatePointsArray(): boolean;
  27653. /** @hidden */
  27654. _updateBoundingInfo(): AbstractMesh;
  27655. /**
  27656. * Creates a new InstancedMesh from the current mesh.
  27657. * - name (string) : the cloned mesh name
  27658. * - newParent (optional Node) : the optional Node to parent the clone to.
  27659. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  27660. *
  27661. * Returns the clone.
  27662. */
  27663. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  27664. /**
  27665. * Disposes the InstancedMesh.
  27666. * Returns nothing.
  27667. */
  27668. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27669. }
  27670. interface Mesh {
  27671. /**
  27672. * Register a custom buffer that will be instanced
  27673. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27674. * @param kind defines the buffer kind
  27675. * @param stride defines the stride in floats
  27676. */
  27677. registerInstancedBuffer(kind: string, stride: number): void;
  27678. /**
  27679. * true to use the edge renderer for all instances of this mesh
  27680. */
  27681. edgesShareWithInstances: boolean;
  27682. /** @hidden */
  27683. _userInstancedBuffersStorage: {
  27684. data: {
  27685. [key: string]: Float32Array;
  27686. };
  27687. sizes: {
  27688. [key: string]: number;
  27689. };
  27690. vertexBuffers: {
  27691. [key: string]: Nullable<VertexBuffer>;
  27692. };
  27693. strides: {
  27694. [key: string]: number;
  27695. };
  27696. };
  27697. }
  27698. interface AbstractMesh {
  27699. /**
  27700. * Object used to store instanced buffers defined by user
  27701. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27702. */
  27703. instancedBuffers: {
  27704. [key: string]: any;
  27705. };
  27706. }
  27707. }
  27708. declare module BABYLON {
  27709. /**
  27710. * Defines the options associated with the creation of a shader material.
  27711. */
  27712. export interface IShaderMaterialOptions {
  27713. /**
  27714. * Does the material work in alpha blend mode
  27715. */
  27716. needAlphaBlending: boolean;
  27717. /**
  27718. * Does the material work in alpha test mode
  27719. */
  27720. needAlphaTesting: boolean;
  27721. /**
  27722. * The list of attribute names used in the shader
  27723. */
  27724. attributes: string[];
  27725. /**
  27726. * The list of unifrom names used in the shader
  27727. */
  27728. uniforms: string[];
  27729. /**
  27730. * The list of UBO names used in the shader
  27731. */
  27732. uniformBuffers: string[];
  27733. /**
  27734. * The list of sampler names used in the shader
  27735. */
  27736. samplers: string[];
  27737. /**
  27738. * The list of defines used in the shader
  27739. */
  27740. defines: string[];
  27741. }
  27742. /**
  27743. * 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.
  27744. *
  27745. * This returned material effects how the mesh will look based on the code in the shaders.
  27746. *
  27747. * @see https://doc.babylonjs.com/how_to/shader_material
  27748. */
  27749. export class ShaderMaterial extends Material {
  27750. private _shaderPath;
  27751. private _options;
  27752. private _textures;
  27753. private _textureArrays;
  27754. private _floats;
  27755. private _ints;
  27756. private _floatsArrays;
  27757. private _colors3;
  27758. private _colors3Arrays;
  27759. private _colors4;
  27760. private _colors4Arrays;
  27761. private _vectors2;
  27762. private _vectors3;
  27763. private _vectors4;
  27764. private _matrices;
  27765. private _matrixArrays;
  27766. private _matrices3x3;
  27767. private _matrices2x2;
  27768. private _vectors2Arrays;
  27769. private _vectors3Arrays;
  27770. private _vectors4Arrays;
  27771. private _cachedWorldViewMatrix;
  27772. private _cachedWorldViewProjectionMatrix;
  27773. private _renderId;
  27774. private _multiview;
  27775. private _cachedDefines;
  27776. /** Define the Url to load snippets */
  27777. static SnippetUrl: string;
  27778. /** Snippet ID if the material was created from the snippet server */
  27779. snippetId: string;
  27780. /**
  27781. * Instantiate a new shader material.
  27782. * 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.
  27783. * This returned material effects how the mesh will look based on the code in the shaders.
  27784. * @see https://doc.babylonjs.com/how_to/shader_material
  27785. * @param name Define the name of the material in the scene
  27786. * @param scene Define the scene the material belongs to
  27787. * @param shaderPath Defines the route to the shader code in one of three ways:
  27788. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  27789. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  27790. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  27791. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  27792. * @param options Define the options used to create the shader
  27793. */
  27794. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  27795. /**
  27796. * Gets the shader path used to define the shader code
  27797. * It can be modified to trigger a new compilation
  27798. */
  27799. get shaderPath(): any;
  27800. /**
  27801. * Sets the shader path used to define the shader code
  27802. * It can be modified to trigger a new compilation
  27803. */
  27804. set shaderPath(shaderPath: any);
  27805. /**
  27806. * Gets the options used to compile the shader.
  27807. * They can be modified to trigger a new compilation
  27808. */
  27809. get options(): IShaderMaterialOptions;
  27810. /**
  27811. * Gets the current class name of the material e.g. "ShaderMaterial"
  27812. * Mainly use in serialization.
  27813. * @returns the class name
  27814. */
  27815. getClassName(): string;
  27816. /**
  27817. * Specifies if the material will require alpha blending
  27818. * @returns a boolean specifying if alpha blending is needed
  27819. */
  27820. needAlphaBlending(): boolean;
  27821. /**
  27822. * Specifies if this material should be rendered in alpha test mode
  27823. * @returns a boolean specifying if an alpha test is needed.
  27824. */
  27825. needAlphaTesting(): boolean;
  27826. private _checkUniform;
  27827. /**
  27828. * Set a texture in the shader.
  27829. * @param name Define the name of the uniform samplers as defined in the shader
  27830. * @param texture Define the texture to bind to this sampler
  27831. * @return the material itself allowing "fluent" like uniform updates
  27832. */
  27833. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  27834. /**
  27835. * Set a texture array in the shader.
  27836. * @param name Define the name of the uniform sampler array as defined in the shader
  27837. * @param textures Define the list of textures to bind to this sampler
  27838. * @return the material itself allowing "fluent" like uniform updates
  27839. */
  27840. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  27841. /**
  27842. * Set a float in the shader.
  27843. * @param name Define the name of the uniform as defined in the shader
  27844. * @param value Define the value to give to the uniform
  27845. * @return the material itself allowing "fluent" like uniform updates
  27846. */
  27847. setFloat(name: string, value: number): ShaderMaterial;
  27848. /**
  27849. * Set a int in the shader.
  27850. * @param name Define the name of the uniform as defined in the shader
  27851. * @param value Define the value to give to the uniform
  27852. * @return the material itself allowing "fluent" like uniform updates
  27853. */
  27854. setInt(name: string, value: number): ShaderMaterial;
  27855. /**
  27856. * Set an array of floats in the shader.
  27857. * @param name Define the name of the uniform as defined in the shader
  27858. * @param value Define the value to give to the uniform
  27859. * @return the material itself allowing "fluent" like uniform updates
  27860. */
  27861. setFloats(name: string, value: number[]): ShaderMaterial;
  27862. /**
  27863. * Set a vec3 in the shader from a Color3.
  27864. * @param name Define the name of the uniform as defined in the shader
  27865. * @param value Define the value to give to the uniform
  27866. * @return the material itself allowing "fluent" like uniform updates
  27867. */
  27868. setColor3(name: string, value: Color3): ShaderMaterial;
  27869. /**
  27870. * Set a vec3 array in the shader from a Color3 array.
  27871. * @param name Define the name of the uniform as defined in the shader
  27872. * @param value Define the value to give to the uniform
  27873. * @return the material itself allowing "fluent" like uniform updates
  27874. */
  27875. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  27876. /**
  27877. * Set a vec4 in the shader from a Color4.
  27878. * @param name Define the name of the uniform as defined in the shader
  27879. * @param value Define the value to give to the uniform
  27880. * @return the material itself allowing "fluent" like uniform updates
  27881. */
  27882. setColor4(name: string, value: Color4): ShaderMaterial;
  27883. /**
  27884. * Set a vec4 array in the shader from a Color4 array.
  27885. * @param name Define the name of the uniform as defined in the shader
  27886. * @param value Define the value to give to the uniform
  27887. * @return the material itself allowing "fluent" like uniform updates
  27888. */
  27889. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  27890. /**
  27891. * Set a vec2 in the shader from a Vector2.
  27892. * @param name Define the name of the uniform as defined in the shader
  27893. * @param value Define the value to give to the uniform
  27894. * @return the material itself allowing "fluent" like uniform updates
  27895. */
  27896. setVector2(name: string, value: Vector2): ShaderMaterial;
  27897. /**
  27898. * Set a vec3 in the shader from a Vector3.
  27899. * @param name Define the name of the uniform as defined in the shader
  27900. * @param value Define the value to give to the uniform
  27901. * @return the material itself allowing "fluent" like uniform updates
  27902. */
  27903. setVector3(name: string, value: Vector3): ShaderMaterial;
  27904. /**
  27905. * Set a vec4 in the shader from a Vector4.
  27906. * @param name Define the name of the uniform as defined in the shader
  27907. * @param value Define the value to give to the uniform
  27908. * @return the material itself allowing "fluent" like uniform updates
  27909. */
  27910. setVector4(name: string, value: Vector4): ShaderMaterial;
  27911. /**
  27912. * Set a mat4 in the shader from a Matrix.
  27913. * @param name Define the name of the uniform as defined in the shader
  27914. * @param value Define the value to give to the uniform
  27915. * @return the material itself allowing "fluent" like uniform updates
  27916. */
  27917. setMatrix(name: string, value: Matrix): ShaderMaterial;
  27918. /**
  27919. * Set a float32Array in the shader from a matrix array.
  27920. * @param name Define the name of the uniform as defined in the shader
  27921. * @param value Define the value to give to the uniform
  27922. * @return the material itself allowing "fluent" like uniform updates
  27923. */
  27924. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  27925. /**
  27926. * Set a mat3 in the shader from a Float32Array.
  27927. * @param name Define the name of the uniform as defined in the shader
  27928. * @param value Define the value to give to the uniform
  27929. * @return the material itself allowing "fluent" like uniform updates
  27930. */
  27931. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27932. /**
  27933. * Set a mat2 in the shader from a Float32Array.
  27934. * @param name Define the name of the uniform as defined in the shader
  27935. * @param value Define the value to give to the uniform
  27936. * @return the material itself allowing "fluent" like uniform updates
  27937. */
  27938. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27939. /**
  27940. * Set a vec2 array in the shader from a number array.
  27941. * @param name Define the name of the uniform as defined in the shader
  27942. * @param value Define the value to give to the uniform
  27943. * @return the material itself allowing "fluent" like uniform updates
  27944. */
  27945. setArray2(name: string, value: number[]): ShaderMaterial;
  27946. /**
  27947. * Set a vec3 array in the shader from a number array.
  27948. * @param name Define the name of the uniform as defined in the shader
  27949. * @param value Define the value to give to the uniform
  27950. * @return the material itself allowing "fluent" like uniform updates
  27951. */
  27952. setArray3(name: string, value: number[]): ShaderMaterial;
  27953. /**
  27954. * Set a vec4 array in the shader from a number array.
  27955. * @param name Define the name of the uniform as defined in the shader
  27956. * @param value Define the value to give to the uniform
  27957. * @return the material itself allowing "fluent" like uniform updates
  27958. */
  27959. setArray4(name: string, value: number[]): ShaderMaterial;
  27960. private _checkCache;
  27961. /**
  27962. * Specifies that the submesh is ready to be used
  27963. * @param mesh defines the mesh to check
  27964. * @param subMesh defines which submesh to check
  27965. * @param useInstances specifies that instances should be used
  27966. * @returns a boolean indicating that the submesh is ready or not
  27967. */
  27968. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27969. /**
  27970. * Checks if the material is ready to render the requested mesh
  27971. * @param mesh Define the mesh to render
  27972. * @param useInstances Define whether or not the material is used with instances
  27973. * @returns true if ready, otherwise false
  27974. */
  27975. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27976. /**
  27977. * Binds the world matrix to the material
  27978. * @param world defines the world transformation matrix
  27979. * @param effectOverride - If provided, use this effect instead of internal effect
  27980. */
  27981. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  27982. /**
  27983. * Binds the submesh to this material by preparing the effect and shader to draw
  27984. * @param world defines the world transformation matrix
  27985. * @param mesh defines the mesh containing the submesh
  27986. * @param subMesh defines the submesh to bind the material to
  27987. */
  27988. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27989. /**
  27990. * Binds the material to the mesh
  27991. * @param world defines the world transformation matrix
  27992. * @param mesh defines the mesh to bind the material to
  27993. * @param effectOverride - If provided, use this effect instead of internal effect
  27994. */
  27995. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  27996. protected _afterBind(mesh?: Mesh): void;
  27997. /**
  27998. * Gets the active textures from the material
  27999. * @returns an array of textures
  28000. */
  28001. getActiveTextures(): BaseTexture[];
  28002. /**
  28003. * Specifies if the material uses a texture
  28004. * @param texture defines the texture to check against the material
  28005. * @returns a boolean specifying if the material uses the texture
  28006. */
  28007. hasTexture(texture: BaseTexture): boolean;
  28008. /**
  28009. * Makes a duplicate of the material, and gives it a new name
  28010. * @param name defines the new name for the duplicated material
  28011. * @returns the cloned material
  28012. */
  28013. clone(name: string): ShaderMaterial;
  28014. /**
  28015. * Disposes the material
  28016. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28017. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28018. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  28019. */
  28020. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  28021. /**
  28022. * Serializes this material in a JSON representation
  28023. * @returns the serialized material object
  28024. */
  28025. serialize(): any;
  28026. /**
  28027. * Creates a shader material from parsed shader material data
  28028. * @param source defines the JSON represnetation of the material
  28029. * @param scene defines the hosting scene
  28030. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28031. * @returns a new material
  28032. */
  28033. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28034. /**
  28035. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28036. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28037. * @param url defines the url to load from
  28038. * @param scene defines the hosting scene
  28039. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28040. * @returns a promise that will resolve to the new ShaderMaterial
  28041. */
  28042. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28043. /**
  28044. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28045. * @param snippetId defines the snippet to load
  28046. * @param scene defines the hosting scene
  28047. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28048. * @returns a promise that will resolve to the new ShaderMaterial
  28049. */
  28050. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28051. }
  28052. }
  28053. declare module BABYLON {
  28054. /** @hidden */
  28055. export var colorPixelShader: {
  28056. name: string;
  28057. shader: string;
  28058. };
  28059. }
  28060. declare module BABYLON {
  28061. /** @hidden */
  28062. export var colorVertexShader: {
  28063. name: string;
  28064. shader: string;
  28065. };
  28066. }
  28067. declare module BABYLON {
  28068. /**
  28069. * Line mesh
  28070. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28071. */
  28072. export class LinesMesh extends Mesh {
  28073. /**
  28074. * If vertex color should be applied to the mesh
  28075. */
  28076. readonly useVertexColor?: boolean | undefined;
  28077. /**
  28078. * If vertex alpha should be applied to the mesh
  28079. */
  28080. readonly useVertexAlpha?: boolean | undefined;
  28081. /**
  28082. * Color of the line (Default: White)
  28083. */
  28084. color: Color3;
  28085. /**
  28086. * Alpha of the line (Default: 1)
  28087. */
  28088. alpha: number;
  28089. /**
  28090. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28091. * This margin is expressed in world space coordinates, so its value may vary.
  28092. * Default value is 0.1
  28093. */
  28094. intersectionThreshold: number;
  28095. private _colorShader;
  28096. private color4;
  28097. /**
  28098. * Creates a new LinesMesh
  28099. * @param name defines the name
  28100. * @param scene defines the hosting scene
  28101. * @param parent defines the parent mesh if any
  28102. * @param source defines the optional source LinesMesh used to clone data from
  28103. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28104. * When false, achieved by calling a clone(), also passing False.
  28105. * This will make creation of children, recursive.
  28106. * @param useVertexColor defines if this LinesMesh supports vertex color
  28107. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28108. */
  28109. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28110. /**
  28111. * If vertex color should be applied to the mesh
  28112. */
  28113. useVertexColor?: boolean | undefined,
  28114. /**
  28115. * If vertex alpha should be applied to the mesh
  28116. */
  28117. useVertexAlpha?: boolean | undefined);
  28118. private _addClipPlaneDefine;
  28119. private _removeClipPlaneDefine;
  28120. isReady(): boolean;
  28121. /**
  28122. * Returns the string "LineMesh"
  28123. */
  28124. getClassName(): string;
  28125. /**
  28126. * @hidden
  28127. */
  28128. get material(): Material;
  28129. /**
  28130. * @hidden
  28131. */
  28132. set material(value: Material);
  28133. /**
  28134. * @hidden
  28135. */
  28136. get checkCollisions(): boolean;
  28137. set checkCollisions(value: boolean);
  28138. /** @hidden */
  28139. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28140. /** @hidden */
  28141. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28142. /**
  28143. * Disposes of the line mesh
  28144. * @param doNotRecurse If children should be disposed
  28145. */
  28146. dispose(doNotRecurse?: boolean): void;
  28147. /**
  28148. * Returns a new LineMesh object cloned from the current one.
  28149. */
  28150. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28151. /**
  28152. * Creates a new InstancedLinesMesh object from the mesh model.
  28153. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28154. * @param name defines the name of the new instance
  28155. * @returns a new InstancedLinesMesh
  28156. */
  28157. createInstance(name: string): InstancedLinesMesh;
  28158. }
  28159. /**
  28160. * Creates an instance based on a source LinesMesh
  28161. */
  28162. export class InstancedLinesMesh extends InstancedMesh {
  28163. /**
  28164. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28165. * This margin is expressed in world space coordinates, so its value may vary.
  28166. * Initilized with the intersectionThreshold value of the source LinesMesh
  28167. */
  28168. intersectionThreshold: number;
  28169. constructor(name: string, source: LinesMesh);
  28170. /**
  28171. * Returns the string "InstancedLinesMesh".
  28172. */
  28173. getClassName(): string;
  28174. }
  28175. }
  28176. declare module BABYLON {
  28177. /** @hidden */
  28178. export var linePixelShader: {
  28179. name: string;
  28180. shader: string;
  28181. };
  28182. }
  28183. declare module BABYLON {
  28184. /** @hidden */
  28185. export var lineVertexShader: {
  28186. name: string;
  28187. shader: string;
  28188. };
  28189. }
  28190. declare module BABYLON {
  28191. interface Scene {
  28192. /** @hidden */
  28193. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28194. }
  28195. interface AbstractMesh {
  28196. /**
  28197. * Gets the edgesRenderer associated with the mesh
  28198. */
  28199. edgesRenderer: Nullable<EdgesRenderer>;
  28200. }
  28201. interface LinesMesh {
  28202. /**
  28203. * Enables the edge rendering mode on the mesh.
  28204. * This mode makes the mesh edges visible
  28205. * @param epsilon defines the maximal distance between two angles to detect a face
  28206. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28207. * @returns the currentAbstractMesh
  28208. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28209. */
  28210. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28211. }
  28212. interface InstancedLinesMesh {
  28213. /**
  28214. * Enables the edge rendering mode on the mesh.
  28215. * This mode makes the mesh edges visible
  28216. * @param epsilon defines the maximal distance between two angles to detect a face
  28217. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28218. * @returns the current InstancedLinesMesh
  28219. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28220. */
  28221. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28222. }
  28223. /**
  28224. * Defines the minimum contract an Edges renderer should follow.
  28225. */
  28226. export interface IEdgesRenderer extends IDisposable {
  28227. /**
  28228. * Gets or sets a boolean indicating if the edgesRenderer is active
  28229. */
  28230. isEnabled: boolean;
  28231. /**
  28232. * Renders the edges of the attached mesh,
  28233. */
  28234. render(): void;
  28235. /**
  28236. * Checks wether or not the edges renderer is ready to render.
  28237. * @return true if ready, otherwise false.
  28238. */
  28239. isReady(): boolean;
  28240. /**
  28241. * List of instances to render in case the source mesh has instances
  28242. */
  28243. customInstances: SmartArray<Matrix>;
  28244. }
  28245. /**
  28246. * Defines the additional options of the edges renderer
  28247. */
  28248. export interface IEdgesRendererOptions {
  28249. /**
  28250. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28251. * If not defined, the default value is true
  28252. */
  28253. useAlternateEdgeFinder?: boolean;
  28254. /**
  28255. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28256. * If not defined, the default value is true.
  28257. * 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)
  28258. * This option is used only if useAlternateEdgeFinder = true
  28259. */
  28260. useFastVertexMerger?: boolean;
  28261. /**
  28262. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28263. * The default value is 1e-6
  28264. * This option is used only if useAlternateEdgeFinder = true
  28265. */
  28266. epsilonVertexMerge?: number;
  28267. /**
  28268. * 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
  28269. * 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.
  28270. * This option is used only if useAlternateEdgeFinder = true
  28271. */
  28272. applyTessellation?: boolean;
  28273. /**
  28274. * 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
  28275. * The default value is 1e-6
  28276. * This option is used only if useAlternateEdgeFinder = true
  28277. */
  28278. epsilonVertexAligned?: number;
  28279. }
  28280. /**
  28281. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28282. */
  28283. export class EdgesRenderer implements IEdgesRenderer {
  28284. /**
  28285. * Define the size of the edges with an orthographic camera
  28286. */
  28287. edgesWidthScalerForOrthographic: number;
  28288. /**
  28289. * Define the size of the edges with a perspective camera
  28290. */
  28291. edgesWidthScalerForPerspective: number;
  28292. protected _source: AbstractMesh;
  28293. protected _linesPositions: number[];
  28294. protected _linesNormals: number[];
  28295. protected _linesIndices: number[];
  28296. protected _epsilon: number;
  28297. protected _indicesCount: number;
  28298. protected _lineShader: ShaderMaterial;
  28299. protected _ib: DataBuffer;
  28300. protected _buffers: {
  28301. [key: string]: Nullable<VertexBuffer>;
  28302. };
  28303. protected _buffersForInstances: {
  28304. [key: string]: Nullable<VertexBuffer>;
  28305. };
  28306. protected _checkVerticesInsteadOfIndices: boolean;
  28307. protected _options: Nullable<IEdgesRendererOptions>;
  28308. private _meshRebuildObserver;
  28309. private _meshDisposeObserver;
  28310. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28311. isEnabled: boolean;
  28312. /** Gets the vertices generated by the edge renderer */
  28313. get linesPositions(): Immutable<Array<number>>;
  28314. /** Gets the normals generated by the edge renderer */
  28315. get linesNormals(): Immutable<Array<number>>;
  28316. /** Gets the indices generated by the edge renderer */
  28317. get linesIndices(): Immutable<Array<number>>;
  28318. /**
  28319. * List of instances to render in case the source mesh has instances
  28320. */
  28321. customInstances: SmartArray<Matrix>;
  28322. private static GetShader;
  28323. /**
  28324. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28325. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28326. * @param source Mesh used to create edges
  28327. * @param epsilon sum of angles in adjacency to check for edge
  28328. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  28329. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28330. * @param options The options to apply when generating the edges
  28331. */
  28332. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  28333. protected _prepareRessources(): void;
  28334. /** @hidden */
  28335. _rebuild(): void;
  28336. /**
  28337. * Releases the required resources for the edges renderer
  28338. */
  28339. dispose(): void;
  28340. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28341. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28342. /**
  28343. * Checks if the pair of p0 and p1 is en edge
  28344. * @param faceIndex
  28345. * @param edge
  28346. * @param faceNormals
  28347. * @param p0
  28348. * @param p1
  28349. * @private
  28350. */
  28351. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28352. /**
  28353. * push line into the position, normal and index buffer
  28354. * @protected
  28355. */
  28356. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  28357. /**
  28358. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  28359. */
  28360. private _tessellateTriangle;
  28361. private _generateEdgesLinesAlternate;
  28362. /**
  28363. * Generates lines edges from adjacencjes
  28364. * @private
  28365. */
  28366. _generateEdgesLines(): void;
  28367. /**
  28368. * Checks wether or not the edges renderer is ready to render.
  28369. * @return true if ready, otherwise false.
  28370. */
  28371. isReady(): boolean;
  28372. /**
  28373. * Renders the edges of the attached mesh,
  28374. */
  28375. render(): void;
  28376. }
  28377. /**
  28378. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28379. */
  28380. export class LineEdgesRenderer extends EdgesRenderer {
  28381. /**
  28382. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28383. * @param source LineMesh used to generate edges
  28384. * @param epsilon not important (specified angle for edge detection)
  28385. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28386. */
  28387. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28388. /**
  28389. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28390. */
  28391. _generateEdgesLines(): void;
  28392. }
  28393. }
  28394. declare module BABYLON {
  28395. /**
  28396. * This represents the object necessary to create a rendering group.
  28397. * This is exclusively used and created by the rendering manager.
  28398. * To modify the behavior, you use the available helpers in your scene or meshes.
  28399. * @hidden
  28400. */
  28401. export class RenderingGroup {
  28402. index: number;
  28403. private static _zeroVector;
  28404. private _scene;
  28405. private _opaqueSubMeshes;
  28406. private _transparentSubMeshes;
  28407. private _alphaTestSubMeshes;
  28408. private _depthOnlySubMeshes;
  28409. private _particleSystems;
  28410. private _spriteManagers;
  28411. private _opaqueSortCompareFn;
  28412. private _alphaTestSortCompareFn;
  28413. private _transparentSortCompareFn;
  28414. private _renderOpaque;
  28415. private _renderAlphaTest;
  28416. private _renderTransparent;
  28417. /** @hidden */
  28418. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  28419. onBeforeTransparentRendering: () => void;
  28420. /**
  28421. * Set the opaque sort comparison function.
  28422. * If null the sub meshes will be render in the order they were created
  28423. */
  28424. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28425. /**
  28426. * Set the alpha test sort comparison function.
  28427. * If null the sub meshes will be render in the order they were created
  28428. */
  28429. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28430. /**
  28431. * Set the transparent sort comparison function.
  28432. * If null the sub meshes will be render in the order they were created
  28433. */
  28434. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28435. /**
  28436. * Creates a new rendering group.
  28437. * @param index The rendering group index
  28438. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28439. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28440. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28441. */
  28442. 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>);
  28443. /**
  28444. * Render all the sub meshes contained in the group.
  28445. * @param customRenderFunction Used to override the default render behaviour of the group.
  28446. * @returns true if rendered some submeshes.
  28447. */
  28448. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28449. /**
  28450. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28451. * @param subMeshes The submeshes to render
  28452. */
  28453. private renderOpaqueSorted;
  28454. /**
  28455. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28456. * @param subMeshes The submeshes to render
  28457. */
  28458. private renderAlphaTestSorted;
  28459. /**
  28460. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28461. * @param subMeshes The submeshes to render
  28462. */
  28463. private renderTransparentSorted;
  28464. /**
  28465. * Renders the submeshes in a specified order.
  28466. * @param subMeshes The submeshes to sort before render
  28467. * @param sortCompareFn The comparison function use to sort
  28468. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28469. * @param transparent Specifies to activate blending if true
  28470. */
  28471. private static renderSorted;
  28472. /**
  28473. * Renders the submeshes in the order they were dispatched (no sort applied).
  28474. * @param subMeshes The submeshes to render
  28475. */
  28476. private static renderUnsorted;
  28477. /**
  28478. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28479. * are rendered back to front if in the same alpha index.
  28480. *
  28481. * @param a The first submesh
  28482. * @param b The second submesh
  28483. * @returns The result of the comparison
  28484. */
  28485. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28486. /**
  28487. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28488. * are rendered back to front.
  28489. *
  28490. * @param a The first submesh
  28491. * @param b The second submesh
  28492. * @returns The result of the comparison
  28493. */
  28494. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28495. /**
  28496. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28497. * are rendered front to back (prevent overdraw).
  28498. *
  28499. * @param a The first submesh
  28500. * @param b The second submesh
  28501. * @returns The result of the comparison
  28502. */
  28503. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28504. /**
  28505. * Resets the different lists of submeshes to prepare a new frame.
  28506. */
  28507. prepare(): void;
  28508. dispose(): void;
  28509. /**
  28510. * Inserts the submesh in its correct queue depending on its material.
  28511. * @param subMesh The submesh to dispatch
  28512. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28513. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28514. */
  28515. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28516. dispatchSprites(spriteManager: ISpriteManager): void;
  28517. dispatchParticles(particleSystem: IParticleSystem): void;
  28518. private _renderParticles;
  28519. private _renderSprites;
  28520. }
  28521. }
  28522. declare module BABYLON {
  28523. /**
  28524. * Interface describing the different options available in the rendering manager
  28525. * regarding Auto Clear between groups.
  28526. */
  28527. export interface IRenderingManagerAutoClearSetup {
  28528. /**
  28529. * Defines whether or not autoclear is enable.
  28530. */
  28531. autoClear: boolean;
  28532. /**
  28533. * Defines whether or not to autoclear the depth buffer.
  28534. */
  28535. depth: boolean;
  28536. /**
  28537. * Defines whether or not to autoclear the stencil buffer.
  28538. */
  28539. stencil: boolean;
  28540. }
  28541. /**
  28542. * This class is used by the onRenderingGroupObservable
  28543. */
  28544. export class RenderingGroupInfo {
  28545. /**
  28546. * The Scene that being rendered
  28547. */
  28548. scene: Scene;
  28549. /**
  28550. * The camera currently used for the rendering pass
  28551. */
  28552. camera: Nullable<Camera>;
  28553. /**
  28554. * The ID of the renderingGroup being processed
  28555. */
  28556. renderingGroupId: number;
  28557. }
  28558. /**
  28559. * This is the manager responsible of all the rendering for meshes sprites and particles.
  28560. * It is enable to manage the different groups as well as the different necessary sort functions.
  28561. * This should not be used directly aside of the few static configurations
  28562. */
  28563. export class RenderingManager {
  28564. /**
  28565. * The max id used for rendering groups (not included)
  28566. */
  28567. static MAX_RENDERINGGROUPS: number;
  28568. /**
  28569. * The min id used for rendering groups (included)
  28570. */
  28571. static MIN_RENDERINGGROUPS: number;
  28572. /**
  28573. * Used to globally prevent autoclearing scenes.
  28574. */
  28575. static AUTOCLEAR: boolean;
  28576. /**
  28577. * @hidden
  28578. */
  28579. _useSceneAutoClearSetup: boolean;
  28580. private _scene;
  28581. private _renderingGroups;
  28582. private _depthStencilBufferAlreadyCleaned;
  28583. private _autoClearDepthStencil;
  28584. private _customOpaqueSortCompareFn;
  28585. private _customAlphaTestSortCompareFn;
  28586. private _customTransparentSortCompareFn;
  28587. private _renderingGroupInfo;
  28588. /**
  28589. * Instantiates a new rendering group for a particular scene
  28590. * @param scene Defines the scene the groups belongs to
  28591. */
  28592. constructor(scene: Scene);
  28593. private _clearDepthStencilBuffer;
  28594. /**
  28595. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  28596. * @hidden
  28597. */
  28598. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28599. /**
  28600. * Resets the different information of the group to prepare a new frame
  28601. * @hidden
  28602. */
  28603. reset(): void;
  28604. /**
  28605. * Dispose and release the group and its associated resources.
  28606. * @hidden
  28607. */
  28608. dispose(): void;
  28609. /**
  28610. * Clear the info related to rendering groups preventing retention points during dispose.
  28611. */
  28612. freeRenderingGroups(): void;
  28613. private _prepareRenderingGroup;
  28614. /**
  28615. * Add a sprite manager to the rendering manager in order to render it this frame.
  28616. * @param spriteManager Define the sprite manager to render
  28617. */
  28618. dispatchSprites(spriteManager: ISpriteManager): void;
  28619. /**
  28620. * Add a particle system to the rendering manager in order to render it this frame.
  28621. * @param particleSystem Define the particle system to render
  28622. */
  28623. dispatchParticles(particleSystem: IParticleSystem): void;
  28624. /**
  28625. * Add a submesh to the manager in order to render it this frame
  28626. * @param subMesh The submesh to dispatch
  28627. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28628. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28629. */
  28630. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28631. /**
  28632. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28633. * This allowed control for front to back rendering or reversly depending of the special needs.
  28634. *
  28635. * @param renderingGroupId The rendering group id corresponding to its index
  28636. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28637. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28638. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28639. */
  28640. 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;
  28641. /**
  28642. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28643. *
  28644. * @param renderingGroupId The rendering group id corresponding to its index
  28645. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28646. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28647. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28648. */
  28649. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28650. /**
  28651. * Gets the current auto clear configuration for one rendering group of the rendering
  28652. * manager.
  28653. * @param index the rendering group index to get the information for
  28654. * @returns The auto clear setup for the requested rendering group
  28655. */
  28656. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28657. }
  28658. }
  28659. declare module BABYLON {
  28660. /**
  28661. * Defines the options associated with the creation of a custom shader for a shadow generator.
  28662. */
  28663. export interface ICustomShaderOptions {
  28664. /**
  28665. * Gets or sets the custom shader name to use
  28666. */
  28667. shaderName: string;
  28668. /**
  28669. * The list of attribute names used in the shader
  28670. */
  28671. attributes?: string[];
  28672. /**
  28673. * The list of unifrom names used in the shader
  28674. */
  28675. uniforms?: string[];
  28676. /**
  28677. * The list of sampler names used in the shader
  28678. */
  28679. samplers?: string[];
  28680. /**
  28681. * The list of defines used in the shader
  28682. */
  28683. defines?: string[];
  28684. }
  28685. /**
  28686. * Interface to implement to create a shadow generator compatible with BJS.
  28687. */
  28688. export interface IShadowGenerator {
  28689. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28690. id: string;
  28691. /**
  28692. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28693. * @returns The render target texture if present otherwise, null
  28694. */
  28695. getShadowMap(): Nullable<RenderTargetTexture>;
  28696. /**
  28697. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  28698. * @param subMesh The submesh we want to render in the shadow map
  28699. * @param useInstances Defines wether will draw in the map using instances
  28700. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  28701. * @returns true if ready otherwise, false
  28702. */
  28703. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  28704. /**
  28705. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  28706. * @param defines Defines of the material we want to update
  28707. * @param lightIndex Index of the light in the enabled light list of the material
  28708. */
  28709. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  28710. /**
  28711. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  28712. * defined in the generator but impacting the effect).
  28713. * It implies the unifroms available on the materials are the standard BJS ones.
  28714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  28715. * @param effect The effect we are binfing the information for
  28716. */
  28717. bindShadowLight(lightIndex: string, effect: Effect): void;
  28718. /**
  28719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  28720. * (eq to shadow prjection matrix * light transform matrix)
  28721. * @returns The transform matrix used to create the shadow map
  28722. */
  28723. getTransformMatrix(): Matrix;
  28724. /**
  28725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  28726. * Cube and 2D textures for instance.
  28727. */
  28728. recreateShadowMap(): void;
  28729. /**
  28730. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28731. * @param onCompiled Callback triggered at the and of the effects compilation
  28732. * @param options Sets of optional options forcing the compilation with different modes
  28733. */
  28734. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  28735. useInstances: boolean;
  28736. }>): void;
  28737. /**
  28738. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28739. * @param options Sets of optional options forcing the compilation with different modes
  28740. * @returns A promise that resolves when the compilation completes
  28741. */
  28742. forceCompilationAsync(options?: Partial<{
  28743. useInstances: boolean;
  28744. }>): Promise<void>;
  28745. /**
  28746. * Serializes the shadow generator setup to a json object.
  28747. * @returns The serialized JSON object
  28748. */
  28749. serialize(): any;
  28750. /**
  28751. * Disposes the Shadow map and related Textures and effects.
  28752. */
  28753. dispose(): void;
  28754. }
  28755. /**
  28756. * Default implementation IShadowGenerator.
  28757. * This is the main object responsible of generating shadows in the framework.
  28758. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  28759. */
  28760. export class ShadowGenerator implements IShadowGenerator {
  28761. /**
  28762. * Name of the shadow generator class
  28763. */
  28764. static CLASSNAME: string;
  28765. /**
  28766. * Shadow generator mode None: no filtering applied.
  28767. */
  28768. static readonly FILTER_NONE: number;
  28769. /**
  28770. * Shadow generator mode ESM: Exponential Shadow Mapping.
  28771. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28772. */
  28773. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  28774. /**
  28775. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  28776. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  28777. */
  28778. static readonly FILTER_POISSONSAMPLING: number;
  28779. /**
  28780. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  28781. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28782. */
  28783. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  28784. /**
  28785. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  28786. * edge artifacts on steep falloff.
  28787. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28788. */
  28789. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  28790. /**
  28791. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  28792. * edge artifacts on steep falloff.
  28793. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28794. */
  28795. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  28796. /**
  28797. * Shadow generator mode PCF: Percentage Closer Filtering
  28798. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28799. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  28800. */
  28801. static readonly FILTER_PCF: number;
  28802. /**
  28803. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  28804. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28805. * Contact Hardening
  28806. */
  28807. static readonly FILTER_PCSS: number;
  28808. /**
  28809. * Reserved for PCF and PCSS
  28810. * Highest Quality.
  28811. *
  28812. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  28813. *
  28814. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  28815. */
  28816. static readonly QUALITY_HIGH: number;
  28817. /**
  28818. * Reserved for PCF and PCSS
  28819. * Good tradeoff for quality/perf cross devices
  28820. *
  28821. * Execute PCF on a 3*3 kernel.
  28822. *
  28823. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  28824. */
  28825. static readonly QUALITY_MEDIUM: number;
  28826. /**
  28827. * Reserved for PCF and PCSS
  28828. * The lowest quality but the fastest.
  28829. *
  28830. * Execute PCF on a 1*1 kernel.
  28831. *
  28832. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  28833. */
  28834. static readonly QUALITY_LOW: number;
  28835. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28836. id: string;
  28837. /** Gets or sets the custom shader name to use */
  28838. customShaderOptions: ICustomShaderOptions;
  28839. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  28840. customAllowRendering: (subMesh: SubMesh) => boolean;
  28841. /**
  28842. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  28843. */
  28844. onBeforeShadowMapRenderObservable: Observable<Effect>;
  28845. /**
  28846. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  28847. */
  28848. onAfterShadowMapRenderObservable: Observable<Effect>;
  28849. /**
  28850. * Observable triggered before a mesh is rendered in the shadow map.
  28851. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  28852. */
  28853. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  28854. /**
  28855. * Observable triggered after a mesh is rendered in the shadow map.
  28856. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  28857. */
  28858. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  28859. protected _bias: number;
  28860. /**
  28861. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  28862. */
  28863. get bias(): number;
  28864. /**
  28865. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  28866. */
  28867. set bias(bias: number);
  28868. protected _normalBias: number;
  28869. /**
  28870. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28871. */
  28872. get normalBias(): number;
  28873. /**
  28874. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28875. */
  28876. set normalBias(normalBias: number);
  28877. protected _blurBoxOffset: number;
  28878. /**
  28879. * Gets the blur box offset: offset applied during the blur pass.
  28880. * Only useful if useKernelBlur = false
  28881. */
  28882. get blurBoxOffset(): number;
  28883. /**
  28884. * Sets the blur box offset: offset applied during the blur pass.
  28885. * Only useful if useKernelBlur = false
  28886. */
  28887. set blurBoxOffset(value: number);
  28888. protected _blurScale: number;
  28889. /**
  28890. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  28891. * 2 means half of the size.
  28892. */
  28893. get blurScale(): number;
  28894. /**
  28895. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  28896. * 2 means half of the size.
  28897. */
  28898. set blurScale(value: number);
  28899. protected _blurKernel: number;
  28900. /**
  28901. * Gets the blur kernel: kernel size of the blur pass.
  28902. * Only useful if useKernelBlur = true
  28903. */
  28904. get blurKernel(): number;
  28905. /**
  28906. * Sets the blur kernel: kernel size of the blur pass.
  28907. * Only useful if useKernelBlur = true
  28908. */
  28909. set blurKernel(value: number);
  28910. protected _useKernelBlur: boolean;
  28911. /**
  28912. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  28913. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28914. */
  28915. get useKernelBlur(): boolean;
  28916. /**
  28917. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  28918. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28919. */
  28920. set useKernelBlur(value: boolean);
  28921. protected _depthScale: number;
  28922. /**
  28923. * Gets the depth scale used in ESM mode.
  28924. */
  28925. get depthScale(): number;
  28926. /**
  28927. * Sets the depth scale used in ESM mode.
  28928. * This can override the scale stored on the light.
  28929. */
  28930. set depthScale(value: number);
  28931. protected _validateFilter(filter: number): number;
  28932. protected _filter: number;
  28933. /**
  28934. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  28935. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28936. */
  28937. get filter(): number;
  28938. /**
  28939. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  28940. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28941. */
  28942. set filter(value: number);
  28943. /**
  28944. * Gets if the current filter is set to Poisson Sampling.
  28945. */
  28946. get usePoissonSampling(): boolean;
  28947. /**
  28948. * Sets the current filter to Poisson Sampling.
  28949. */
  28950. set usePoissonSampling(value: boolean);
  28951. /**
  28952. * Gets if the current filter is set to ESM.
  28953. */
  28954. get useExponentialShadowMap(): boolean;
  28955. /**
  28956. * Sets the current filter is to ESM.
  28957. */
  28958. set useExponentialShadowMap(value: boolean);
  28959. /**
  28960. * Gets if the current filter is set to filtered ESM.
  28961. */
  28962. get useBlurExponentialShadowMap(): boolean;
  28963. /**
  28964. * Gets if the current filter is set to filtered ESM.
  28965. */
  28966. set useBlurExponentialShadowMap(value: boolean);
  28967. /**
  28968. * Gets if the current filter is set to "close ESM" (using the inverse of the
  28969. * exponential to prevent steep falloff artifacts).
  28970. */
  28971. get useCloseExponentialShadowMap(): boolean;
  28972. /**
  28973. * Sets the current filter to "close ESM" (using the inverse of the
  28974. * exponential to prevent steep falloff artifacts).
  28975. */
  28976. set useCloseExponentialShadowMap(value: boolean);
  28977. /**
  28978. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  28979. * exponential to prevent steep falloff artifacts).
  28980. */
  28981. get useBlurCloseExponentialShadowMap(): boolean;
  28982. /**
  28983. * Sets the current filter to filtered "close ESM" (using the inverse of the
  28984. * exponential to prevent steep falloff artifacts).
  28985. */
  28986. set useBlurCloseExponentialShadowMap(value: boolean);
  28987. /**
  28988. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  28989. */
  28990. get usePercentageCloserFiltering(): boolean;
  28991. /**
  28992. * Sets the current filter to "PCF" (percentage closer filtering).
  28993. */
  28994. set usePercentageCloserFiltering(value: boolean);
  28995. protected _filteringQuality: number;
  28996. /**
  28997. * Gets the PCF or PCSS Quality.
  28998. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28999. */
  29000. get filteringQuality(): number;
  29001. /**
  29002. * Sets the PCF or PCSS Quality.
  29003. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29004. */
  29005. set filteringQuality(filteringQuality: number);
  29006. /**
  29007. * Gets if the current filter is set to "PCSS" (contact hardening).
  29008. */
  29009. get useContactHardeningShadow(): boolean;
  29010. /**
  29011. * Sets the current filter to "PCSS" (contact hardening).
  29012. */
  29013. set useContactHardeningShadow(value: boolean);
  29014. protected _contactHardeningLightSizeUVRatio: number;
  29015. /**
  29016. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29017. * Using a ratio helps keeping shape stability independently of the map size.
  29018. *
  29019. * It does not account for the light projection as it was having too much
  29020. * instability during the light setup or during light position changes.
  29021. *
  29022. * Only valid if useContactHardeningShadow is true.
  29023. */
  29024. get contactHardeningLightSizeUVRatio(): number;
  29025. /**
  29026. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29027. * Using a ratio helps keeping shape stability independently of the map size.
  29028. *
  29029. * It does not account for the light projection as it was having too much
  29030. * instability during the light setup or during light position changes.
  29031. *
  29032. * Only valid if useContactHardeningShadow is true.
  29033. */
  29034. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29035. protected _darkness: number;
  29036. /** Gets or sets the actual darkness of a shadow */
  29037. get darkness(): number;
  29038. set darkness(value: number);
  29039. /**
  29040. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29041. * 0 means strongest and 1 would means no shadow.
  29042. * @returns the darkness.
  29043. */
  29044. getDarkness(): number;
  29045. /**
  29046. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29047. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29048. * @returns the shadow generator allowing fluent coding.
  29049. */
  29050. setDarkness(darkness: number): ShadowGenerator;
  29051. protected _transparencyShadow: boolean;
  29052. /** Gets or sets the ability to have transparent shadow */
  29053. get transparencyShadow(): boolean;
  29054. set transparencyShadow(value: boolean);
  29055. /**
  29056. * Sets the ability to have transparent shadow (boolean).
  29057. * @param transparent True if transparent else False
  29058. * @returns the shadow generator allowing fluent coding
  29059. */
  29060. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29061. /**
  29062. * Enables or disables shadows with varying strength based on the transparency
  29063. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29064. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29065. * mesh.visibility * alphaTexture.a
  29066. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29067. */
  29068. enableSoftTransparentShadow: boolean;
  29069. protected _shadowMap: Nullable<RenderTargetTexture>;
  29070. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29071. /**
  29072. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29073. * @returns The render target texture if present otherwise, null
  29074. */
  29075. getShadowMap(): Nullable<RenderTargetTexture>;
  29076. /**
  29077. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29078. * @returns The render target texture if the shadow map is present otherwise, null
  29079. */
  29080. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29081. /**
  29082. * Gets the class name of that object
  29083. * @returns "ShadowGenerator"
  29084. */
  29085. getClassName(): string;
  29086. /**
  29087. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29088. * @param mesh Mesh to add
  29089. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29090. * @returns the Shadow Generator itself
  29091. */
  29092. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29093. /**
  29094. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29095. * @param mesh Mesh to remove
  29096. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29097. * @returns the Shadow Generator itself
  29098. */
  29099. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29100. /**
  29101. * Controls the extent to which the shadows fade out at the edge of the frustum
  29102. */
  29103. frustumEdgeFalloff: number;
  29104. protected _light: IShadowLight;
  29105. /**
  29106. * Returns the associated light object.
  29107. * @returns the light generating the shadow
  29108. */
  29109. getLight(): IShadowLight;
  29110. /**
  29111. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29112. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29113. * It might on the other hand introduce peter panning.
  29114. */
  29115. forceBackFacesOnly: boolean;
  29116. protected _scene: Scene;
  29117. protected _lightDirection: Vector3;
  29118. protected _effect: Effect;
  29119. protected _viewMatrix: Matrix;
  29120. protected _projectionMatrix: Matrix;
  29121. protected _transformMatrix: Matrix;
  29122. protected _cachedPosition: Vector3;
  29123. protected _cachedDirection: Vector3;
  29124. protected _cachedDefines: string;
  29125. protected _currentRenderID: number;
  29126. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29127. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29128. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29129. protected _blurPostProcesses: PostProcess[];
  29130. protected _mapSize: number;
  29131. protected _currentFaceIndex: number;
  29132. protected _currentFaceIndexCache: number;
  29133. protected _textureType: number;
  29134. protected _defaultTextureMatrix: Matrix;
  29135. protected _storedUniqueId: Nullable<number>;
  29136. /** @hidden */
  29137. static _SceneComponentInitialization: (scene: Scene) => void;
  29138. /**
  29139. * Gets or sets the size of the texture what stores the shadows
  29140. */
  29141. get mapSize(): number;
  29142. set mapSize(size: number);
  29143. /**
  29144. * Creates a ShadowGenerator object.
  29145. * A ShadowGenerator is the required tool to use the shadows.
  29146. * Each light casting shadows needs to use its own ShadowGenerator.
  29147. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29148. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29149. * @param light The light object generating the shadows.
  29150. * @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.
  29151. */
  29152. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29153. protected _initializeGenerator(): void;
  29154. protected _createTargetRenderTexture(): void;
  29155. protected _initializeShadowMap(): void;
  29156. protected _initializeBlurRTTAndPostProcesses(): void;
  29157. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29158. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29159. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29160. protected _applyFilterValues(): void;
  29161. /**
  29162. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29163. * @param onCompiled Callback triggered at the and of the effects compilation
  29164. * @param options Sets of optional options forcing the compilation with different modes
  29165. */
  29166. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29167. useInstances: boolean;
  29168. }>): void;
  29169. /**
  29170. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29171. * @param options Sets of optional options forcing the compilation with different modes
  29172. * @returns A promise that resolves when the compilation completes
  29173. */
  29174. forceCompilationAsync(options?: Partial<{
  29175. useInstances: boolean;
  29176. }>): Promise<void>;
  29177. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29178. private _prepareShadowDefines;
  29179. /**
  29180. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29181. * @param subMesh The submesh we want to render in the shadow map
  29182. * @param useInstances Defines wether will draw in the map using instances
  29183. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29184. * @returns true if ready otherwise, false
  29185. */
  29186. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29187. /**
  29188. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29189. * @param defines Defines of the material we want to update
  29190. * @param lightIndex Index of the light in the enabled light list of the material
  29191. */
  29192. prepareDefines(defines: any, lightIndex: number): void;
  29193. /**
  29194. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29195. * defined in the generator but impacting the effect).
  29196. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29197. * @param effect The effect we are binfing the information for
  29198. */
  29199. bindShadowLight(lightIndex: string, effect: Effect): void;
  29200. /**
  29201. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29202. * (eq to shadow prjection matrix * light transform matrix)
  29203. * @returns The transform matrix used to create the shadow map
  29204. */
  29205. getTransformMatrix(): Matrix;
  29206. /**
  29207. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29208. * Cube and 2D textures for instance.
  29209. */
  29210. recreateShadowMap(): void;
  29211. protected _disposeBlurPostProcesses(): void;
  29212. protected _disposeRTTandPostProcesses(): void;
  29213. /**
  29214. * Disposes the ShadowGenerator.
  29215. * Returns nothing.
  29216. */
  29217. dispose(): void;
  29218. /**
  29219. * Serializes the shadow generator setup to a json object.
  29220. * @returns The serialized JSON object
  29221. */
  29222. serialize(): any;
  29223. /**
  29224. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29225. * @param parsedShadowGenerator The JSON object to parse
  29226. * @param scene The scene to create the shadow map for
  29227. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29228. * @returns The parsed shadow generator
  29229. */
  29230. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29231. }
  29232. }
  29233. declare module BABYLON {
  29234. /**
  29235. * Options to be used when creating a shadow depth material
  29236. */
  29237. export interface IIOptionShadowDepthMaterial {
  29238. /** Variables in the vertex shader code that need to have their names remapped.
  29239. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29240. * "var_name" should be either: worldPos or vNormalW
  29241. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29242. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29243. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29244. */
  29245. remappedVariables?: string[];
  29246. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29247. standalone?: boolean;
  29248. }
  29249. /**
  29250. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29251. */
  29252. export class ShadowDepthWrapper {
  29253. private _scene;
  29254. private _options?;
  29255. private _baseMaterial;
  29256. private _onEffectCreatedObserver;
  29257. private _subMeshToEffect;
  29258. private _subMeshToDepthEffect;
  29259. private _meshes;
  29260. /** @hidden */
  29261. _matriceNames: any;
  29262. /** Gets the standalone status of the wrapper */
  29263. get standalone(): boolean;
  29264. /** Gets the base material the wrapper is built upon */
  29265. get baseMaterial(): Material;
  29266. /**
  29267. * Instantiate a new shadow depth wrapper.
  29268. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29269. * generate the shadow depth map. For more information, please refer to the documentation:
  29270. * https://doc.babylonjs.com/babylon101/shadows
  29271. * @param baseMaterial Material to wrap
  29272. * @param scene Define the scene the material belongs to
  29273. * @param options Options used to create the wrapper
  29274. */
  29275. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29276. /**
  29277. * Gets the effect to use to generate the depth map
  29278. * @param subMesh subMesh to get the effect for
  29279. * @param shadowGenerator shadow generator to get the effect for
  29280. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29281. */
  29282. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29283. /**
  29284. * Specifies that the submesh is ready to be used for depth rendering
  29285. * @param subMesh submesh to check
  29286. * @param defines the list of defines to take into account when checking the effect
  29287. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29288. * @param useInstances specifies that instances should be used
  29289. * @returns a boolean indicating that the submesh is ready or not
  29290. */
  29291. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29292. /**
  29293. * Disposes the resources
  29294. */
  29295. dispose(): void;
  29296. private _makeEffect;
  29297. }
  29298. }
  29299. declare module BABYLON {
  29300. /**
  29301. * Options for compiling materials.
  29302. */
  29303. export interface IMaterialCompilationOptions {
  29304. /**
  29305. * Defines whether clip planes are enabled.
  29306. */
  29307. clipPlane: boolean;
  29308. /**
  29309. * Defines whether instances are enabled.
  29310. */
  29311. useInstances: boolean;
  29312. }
  29313. /**
  29314. * Options passed when calling customShaderNameResolve
  29315. */
  29316. export interface ICustomShaderNameResolveOptions {
  29317. /**
  29318. * 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
  29319. */
  29320. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29321. }
  29322. /**
  29323. * Base class for the main features of a material in Babylon.js
  29324. */
  29325. export class Material implements IAnimatable {
  29326. /**
  29327. * Returns the triangle fill mode
  29328. */
  29329. static readonly TriangleFillMode: number;
  29330. /**
  29331. * Returns the wireframe mode
  29332. */
  29333. static readonly WireFrameFillMode: number;
  29334. /**
  29335. * Returns the point fill mode
  29336. */
  29337. static readonly PointFillMode: number;
  29338. /**
  29339. * Returns the point list draw mode
  29340. */
  29341. static readonly PointListDrawMode: number;
  29342. /**
  29343. * Returns the line list draw mode
  29344. */
  29345. static readonly LineListDrawMode: number;
  29346. /**
  29347. * Returns the line loop draw mode
  29348. */
  29349. static readonly LineLoopDrawMode: number;
  29350. /**
  29351. * Returns the line strip draw mode
  29352. */
  29353. static readonly LineStripDrawMode: number;
  29354. /**
  29355. * Returns the triangle strip draw mode
  29356. */
  29357. static readonly TriangleStripDrawMode: number;
  29358. /**
  29359. * Returns the triangle fan draw mode
  29360. */
  29361. static readonly TriangleFanDrawMode: number;
  29362. /**
  29363. * Stores the clock-wise side orientation
  29364. */
  29365. static readonly ClockWiseSideOrientation: number;
  29366. /**
  29367. * Stores the counter clock-wise side orientation
  29368. */
  29369. static readonly CounterClockWiseSideOrientation: number;
  29370. /**
  29371. * The dirty texture flag value
  29372. */
  29373. static readonly TextureDirtyFlag: number;
  29374. /**
  29375. * The dirty light flag value
  29376. */
  29377. static readonly LightDirtyFlag: number;
  29378. /**
  29379. * The dirty fresnel flag value
  29380. */
  29381. static readonly FresnelDirtyFlag: number;
  29382. /**
  29383. * The dirty attribute flag value
  29384. */
  29385. static readonly AttributesDirtyFlag: number;
  29386. /**
  29387. * The dirty misc flag value
  29388. */
  29389. static readonly MiscDirtyFlag: number;
  29390. /**
  29391. * The dirty prepass flag value
  29392. */
  29393. static readonly PrePassDirtyFlag: number;
  29394. /**
  29395. * The all dirty flag value
  29396. */
  29397. static readonly AllDirtyFlag: number;
  29398. /**
  29399. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29400. */
  29401. static readonly MATERIAL_OPAQUE: number;
  29402. /**
  29403. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29404. */
  29405. static readonly MATERIAL_ALPHATEST: number;
  29406. /**
  29407. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29408. */
  29409. static readonly MATERIAL_ALPHABLEND: number;
  29410. /**
  29411. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29412. * They are also discarded below the alpha cutoff threshold to improve performances.
  29413. */
  29414. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29415. /**
  29416. * The Whiteout method is used to blend normals.
  29417. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29418. */
  29419. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29420. /**
  29421. * The Reoriented Normal Mapping method is used to blend normals.
  29422. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29423. */
  29424. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29425. /**
  29426. * Custom callback helping to override the default shader used in the material.
  29427. */
  29428. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29429. /**
  29430. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29431. */
  29432. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29433. /**
  29434. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29435. * This means that the material can keep using a previous shader while a new one is being compiled.
  29436. * This is mostly used when shader parallel compilation is supported (true by default)
  29437. */
  29438. allowShaderHotSwapping: boolean;
  29439. /**
  29440. * The ID of the material
  29441. */
  29442. id: string;
  29443. /**
  29444. * Gets or sets the unique id of the material
  29445. */
  29446. uniqueId: number;
  29447. /**
  29448. * The name of the material
  29449. */
  29450. name: string;
  29451. /**
  29452. * Gets or sets user defined metadata
  29453. */
  29454. metadata: any;
  29455. /**
  29456. * For internal use only. Please do not use.
  29457. */
  29458. reservedDataStore: any;
  29459. /**
  29460. * Specifies if the ready state should be checked on each call
  29461. */
  29462. checkReadyOnEveryCall: boolean;
  29463. /**
  29464. * Specifies if the ready state should be checked once
  29465. */
  29466. checkReadyOnlyOnce: boolean;
  29467. /**
  29468. * The state of the material
  29469. */
  29470. state: string;
  29471. /**
  29472. * If the material can be rendered to several textures with MRT extension
  29473. */
  29474. get canRenderToMRT(): boolean;
  29475. /**
  29476. * The alpha value of the material
  29477. */
  29478. protected _alpha: number;
  29479. /**
  29480. * List of inspectable custom properties (used by the Inspector)
  29481. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29482. */
  29483. inspectableCustomProperties: IInspectable[];
  29484. /**
  29485. * Sets the alpha value of the material
  29486. */
  29487. set alpha(value: number);
  29488. /**
  29489. * Gets the alpha value of the material
  29490. */
  29491. get alpha(): number;
  29492. /**
  29493. * Specifies if back face culling is enabled
  29494. */
  29495. protected _backFaceCulling: boolean;
  29496. /**
  29497. * Sets the back-face culling state
  29498. */
  29499. set backFaceCulling(value: boolean);
  29500. /**
  29501. * Gets the back-face culling state
  29502. */
  29503. get backFaceCulling(): boolean;
  29504. /**
  29505. * Stores the value for side orientation
  29506. */
  29507. sideOrientation: number;
  29508. /**
  29509. * Callback triggered when the material is compiled
  29510. */
  29511. onCompiled: Nullable<(effect: Effect) => void>;
  29512. /**
  29513. * Callback triggered when an error occurs
  29514. */
  29515. onError: Nullable<(effect: Effect, errors: string) => void>;
  29516. /**
  29517. * Callback triggered to get the render target textures
  29518. */
  29519. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29520. /**
  29521. * Gets a boolean indicating that current material needs to register RTT
  29522. */
  29523. get hasRenderTargetTextures(): boolean;
  29524. /**
  29525. * Specifies if the material should be serialized
  29526. */
  29527. doNotSerialize: boolean;
  29528. /**
  29529. * @hidden
  29530. */
  29531. _storeEffectOnSubMeshes: boolean;
  29532. /**
  29533. * Stores the animations for the material
  29534. */
  29535. animations: Nullable<Array<Animation>>;
  29536. /**
  29537. * An event triggered when the material is disposed
  29538. */
  29539. onDisposeObservable: Observable<Material>;
  29540. /**
  29541. * An observer which watches for dispose events
  29542. */
  29543. private _onDisposeObserver;
  29544. private _onUnBindObservable;
  29545. /**
  29546. * Called during a dispose event
  29547. */
  29548. set onDispose(callback: () => void);
  29549. private _onBindObservable;
  29550. /**
  29551. * An event triggered when the material is bound
  29552. */
  29553. get onBindObservable(): Observable<AbstractMesh>;
  29554. /**
  29555. * An observer which watches for bind events
  29556. */
  29557. private _onBindObserver;
  29558. /**
  29559. * Called during a bind event
  29560. */
  29561. set onBind(callback: (Mesh: AbstractMesh) => void);
  29562. /**
  29563. * An event triggered when the material is unbound
  29564. */
  29565. get onUnBindObservable(): Observable<Material>;
  29566. protected _onEffectCreatedObservable: Nullable<Observable<{
  29567. effect: Effect;
  29568. subMesh: Nullable<SubMesh>;
  29569. }>>;
  29570. /**
  29571. * An event triggered when the effect is (re)created
  29572. */
  29573. get onEffectCreatedObservable(): Observable<{
  29574. effect: Effect;
  29575. subMesh: Nullable<SubMesh>;
  29576. }>;
  29577. /**
  29578. * Stores the value of the alpha mode
  29579. */
  29580. private _alphaMode;
  29581. /**
  29582. * Sets the value of the alpha mode.
  29583. *
  29584. * | Value | Type | Description |
  29585. * | --- | --- | --- |
  29586. * | 0 | ALPHA_DISABLE | |
  29587. * | 1 | ALPHA_ADD | |
  29588. * | 2 | ALPHA_COMBINE | |
  29589. * | 3 | ALPHA_SUBTRACT | |
  29590. * | 4 | ALPHA_MULTIPLY | |
  29591. * | 5 | ALPHA_MAXIMIZED | |
  29592. * | 6 | ALPHA_ONEONE | |
  29593. * | 7 | ALPHA_PREMULTIPLIED | |
  29594. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29595. * | 9 | ALPHA_INTERPOLATE | |
  29596. * | 10 | ALPHA_SCREENMODE | |
  29597. *
  29598. */
  29599. set alphaMode(value: number);
  29600. /**
  29601. * Gets the value of the alpha mode
  29602. */
  29603. get alphaMode(): number;
  29604. /**
  29605. * Stores the state of the need depth pre-pass value
  29606. */
  29607. private _needDepthPrePass;
  29608. /**
  29609. * Sets the need depth pre-pass value
  29610. */
  29611. set needDepthPrePass(value: boolean);
  29612. /**
  29613. * Gets the depth pre-pass value
  29614. */
  29615. get needDepthPrePass(): boolean;
  29616. /**
  29617. * Specifies if depth writing should be disabled
  29618. */
  29619. disableDepthWrite: boolean;
  29620. /**
  29621. * Specifies if color writing should be disabled
  29622. */
  29623. disableColorWrite: boolean;
  29624. /**
  29625. * Specifies if depth writing should be forced
  29626. */
  29627. forceDepthWrite: boolean;
  29628. /**
  29629. * Specifies the depth function that should be used. 0 means the default engine function
  29630. */
  29631. depthFunction: number;
  29632. /**
  29633. * Specifies if there should be a separate pass for culling
  29634. */
  29635. separateCullingPass: boolean;
  29636. /**
  29637. * Stores the state specifing if fog should be enabled
  29638. */
  29639. private _fogEnabled;
  29640. /**
  29641. * Sets the state for enabling fog
  29642. */
  29643. set fogEnabled(value: boolean);
  29644. /**
  29645. * Gets the value of the fog enabled state
  29646. */
  29647. get fogEnabled(): boolean;
  29648. /**
  29649. * Stores the size of points
  29650. */
  29651. pointSize: number;
  29652. /**
  29653. * Stores the z offset value
  29654. */
  29655. zOffset: number;
  29656. get wireframe(): boolean;
  29657. /**
  29658. * Sets the state of wireframe mode
  29659. */
  29660. set wireframe(value: boolean);
  29661. /**
  29662. * Gets the value specifying if point clouds are enabled
  29663. */
  29664. get pointsCloud(): boolean;
  29665. /**
  29666. * Sets the state of point cloud mode
  29667. */
  29668. set pointsCloud(value: boolean);
  29669. /**
  29670. * Gets the material fill mode
  29671. */
  29672. get fillMode(): number;
  29673. /**
  29674. * Sets the material fill mode
  29675. */
  29676. set fillMode(value: number);
  29677. /**
  29678. * @hidden
  29679. * Stores the effects for the material
  29680. */
  29681. _effect: Nullable<Effect>;
  29682. /**
  29683. * Specifies if uniform buffers should be used
  29684. */
  29685. private _useUBO;
  29686. /**
  29687. * Stores a reference to the scene
  29688. */
  29689. private _scene;
  29690. /**
  29691. * Stores the fill mode state
  29692. */
  29693. private _fillMode;
  29694. /**
  29695. * Specifies if the depth write state should be cached
  29696. */
  29697. private _cachedDepthWriteState;
  29698. /**
  29699. * Specifies if the color write state should be cached
  29700. */
  29701. private _cachedColorWriteState;
  29702. /**
  29703. * Specifies if the depth function state should be cached
  29704. */
  29705. private _cachedDepthFunctionState;
  29706. /**
  29707. * Stores the uniform buffer
  29708. */
  29709. protected _uniformBuffer: UniformBuffer;
  29710. /** @hidden */
  29711. _indexInSceneMaterialArray: number;
  29712. /** @hidden */
  29713. meshMap: Nullable<{
  29714. [id: string]: AbstractMesh | undefined;
  29715. }>;
  29716. /**
  29717. * Creates a material instance
  29718. * @param name defines the name of the material
  29719. * @param scene defines the scene to reference
  29720. * @param doNotAdd specifies if the material should be added to the scene
  29721. */
  29722. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29723. /**
  29724. * Returns a string representation of the current material
  29725. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29726. * @returns a string with material information
  29727. */
  29728. toString(fullDetails?: boolean): string;
  29729. /**
  29730. * Gets the class name of the material
  29731. * @returns a string with the class name of the material
  29732. */
  29733. getClassName(): string;
  29734. /**
  29735. * Specifies if updates for the material been locked
  29736. */
  29737. get isFrozen(): boolean;
  29738. /**
  29739. * Locks updates for the material
  29740. */
  29741. freeze(): void;
  29742. /**
  29743. * Unlocks updates for the material
  29744. */
  29745. unfreeze(): void;
  29746. /**
  29747. * Specifies if the material is ready to be used
  29748. * @param mesh defines the mesh to check
  29749. * @param useInstances specifies if instances should be used
  29750. * @returns a boolean indicating if the material is ready to be used
  29751. */
  29752. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29753. /**
  29754. * Specifies that the submesh is ready to be used
  29755. * @param mesh defines the mesh to check
  29756. * @param subMesh defines which submesh to check
  29757. * @param useInstances specifies that instances should be used
  29758. * @returns a boolean indicating that the submesh is ready or not
  29759. */
  29760. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29761. /**
  29762. * Returns the material effect
  29763. * @returns the effect associated with the material
  29764. */
  29765. getEffect(): Nullable<Effect>;
  29766. /**
  29767. * Returns the current scene
  29768. * @returns a Scene
  29769. */
  29770. getScene(): Scene;
  29771. /**
  29772. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29773. */
  29774. protected _forceAlphaTest: boolean;
  29775. /**
  29776. * The transparency mode of the material.
  29777. */
  29778. protected _transparencyMode: Nullable<number>;
  29779. /**
  29780. * Gets the current transparency mode.
  29781. */
  29782. get transparencyMode(): Nullable<number>;
  29783. /**
  29784. * Sets the transparency mode of the material.
  29785. *
  29786. * | Value | Type | Description |
  29787. * | ----- | ----------------------------------- | ----------- |
  29788. * | 0 | OPAQUE | |
  29789. * | 1 | ALPHATEST | |
  29790. * | 2 | ALPHABLEND | |
  29791. * | 3 | ALPHATESTANDBLEND | |
  29792. *
  29793. */
  29794. set transparencyMode(value: Nullable<number>);
  29795. /**
  29796. * Returns true if alpha blending should be disabled.
  29797. */
  29798. protected get _disableAlphaBlending(): boolean;
  29799. /**
  29800. * Specifies whether or not this material should be rendered in alpha blend mode.
  29801. * @returns a boolean specifying if alpha blending is needed
  29802. */
  29803. needAlphaBlending(): boolean;
  29804. /**
  29805. * Specifies if the mesh will require alpha blending
  29806. * @param mesh defines the mesh to check
  29807. * @returns a boolean specifying if alpha blending is needed for the mesh
  29808. */
  29809. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29810. /**
  29811. * Specifies whether or not this material should be rendered in alpha test mode.
  29812. * @returns a boolean specifying if an alpha test is needed.
  29813. */
  29814. needAlphaTesting(): boolean;
  29815. /**
  29816. * Specifies if material alpha testing should be turned on for the mesh
  29817. * @param mesh defines the mesh to check
  29818. */
  29819. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29820. /**
  29821. * Gets the texture used for the alpha test
  29822. * @returns the texture to use for alpha testing
  29823. */
  29824. getAlphaTestTexture(): Nullable<BaseTexture>;
  29825. /**
  29826. * Marks the material to indicate that it needs to be re-calculated
  29827. */
  29828. markDirty(): void;
  29829. /** @hidden */
  29830. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29831. /**
  29832. * Binds the material to the mesh
  29833. * @param world defines the world transformation matrix
  29834. * @param mesh defines the mesh to bind the material to
  29835. */
  29836. bind(world: Matrix, mesh?: Mesh): void;
  29837. /**
  29838. * Binds the submesh to the material
  29839. * @param world defines the world transformation matrix
  29840. * @param mesh defines the mesh containing the submesh
  29841. * @param subMesh defines the submesh to bind the material to
  29842. */
  29843. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29844. /**
  29845. * Binds the world matrix to the material
  29846. * @param world defines the world transformation matrix
  29847. */
  29848. bindOnlyWorldMatrix(world: Matrix): void;
  29849. /**
  29850. * Binds the scene's uniform buffer to the effect.
  29851. * @param effect defines the effect to bind to the scene uniform buffer
  29852. * @param sceneUbo defines the uniform buffer storing scene data
  29853. */
  29854. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29855. /**
  29856. * Binds the view matrix to the effect
  29857. * @param effect defines the effect to bind the view matrix to
  29858. */
  29859. bindView(effect: Effect): void;
  29860. /**
  29861. * Binds the view projection matrix to the effect
  29862. * @param effect defines the effect to bind the view projection matrix to
  29863. */
  29864. bindViewProjection(effect: Effect): void;
  29865. /**
  29866. * Processes to execute after binding the material to a mesh
  29867. * @param mesh defines the rendered mesh
  29868. */
  29869. protected _afterBind(mesh?: Mesh): void;
  29870. /**
  29871. * Unbinds the material from the mesh
  29872. */
  29873. unbind(): void;
  29874. /**
  29875. * Gets the active textures from the material
  29876. * @returns an array of textures
  29877. */
  29878. getActiveTextures(): BaseTexture[];
  29879. /**
  29880. * Specifies if the material uses a texture
  29881. * @param texture defines the texture to check against the material
  29882. * @returns a boolean specifying if the material uses the texture
  29883. */
  29884. hasTexture(texture: BaseTexture): boolean;
  29885. /**
  29886. * Makes a duplicate of the material, and gives it a new name
  29887. * @param name defines the new name for the duplicated material
  29888. * @returns the cloned material
  29889. */
  29890. clone(name: string): Nullable<Material>;
  29891. /**
  29892. * Gets the meshes bound to the material
  29893. * @returns an array of meshes bound to the material
  29894. */
  29895. getBindedMeshes(): AbstractMesh[];
  29896. /**
  29897. * Force shader compilation
  29898. * @param mesh defines the mesh associated with this material
  29899. * @param onCompiled defines a function to execute once the material is compiled
  29900. * @param options defines the options to configure the compilation
  29901. * @param onError defines a function to execute if the material fails compiling
  29902. */
  29903. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29904. /**
  29905. * Force shader compilation
  29906. * @param mesh defines the mesh that will use this material
  29907. * @param options defines additional options for compiling the shaders
  29908. * @returns a promise that resolves when the compilation completes
  29909. */
  29910. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29911. private static readonly _AllDirtyCallBack;
  29912. private static readonly _ImageProcessingDirtyCallBack;
  29913. private static readonly _TextureDirtyCallBack;
  29914. private static readonly _FresnelDirtyCallBack;
  29915. private static readonly _MiscDirtyCallBack;
  29916. private static readonly _PrePassDirtyCallBack;
  29917. private static readonly _LightsDirtyCallBack;
  29918. private static readonly _AttributeDirtyCallBack;
  29919. private static _FresnelAndMiscDirtyCallBack;
  29920. private static _TextureAndMiscDirtyCallBack;
  29921. private static readonly _DirtyCallbackArray;
  29922. private static readonly _RunDirtyCallBacks;
  29923. /**
  29924. * Marks a define in the material to indicate that it needs to be re-computed
  29925. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29926. */
  29927. markAsDirty(flag: number): void;
  29928. /**
  29929. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29930. * @param func defines a function which checks material defines against the submeshes
  29931. */
  29932. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29933. /**
  29934. * Indicates that the scene should check if the rendering now needs a prepass
  29935. */
  29936. protected _markScenePrePassDirty(): void;
  29937. /**
  29938. * Indicates that we need to re-calculated for all submeshes
  29939. */
  29940. protected _markAllSubMeshesAsAllDirty(): void;
  29941. /**
  29942. * Indicates that image processing needs to be re-calculated for all submeshes
  29943. */
  29944. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29945. /**
  29946. * Indicates that textures need to be re-calculated for all submeshes
  29947. */
  29948. protected _markAllSubMeshesAsTexturesDirty(): void;
  29949. /**
  29950. * Indicates that fresnel needs to be re-calculated for all submeshes
  29951. */
  29952. protected _markAllSubMeshesAsFresnelDirty(): void;
  29953. /**
  29954. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29955. */
  29956. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29957. /**
  29958. * Indicates that lights need to be re-calculated for all submeshes
  29959. */
  29960. protected _markAllSubMeshesAsLightsDirty(): void;
  29961. /**
  29962. * Indicates that attributes need to be re-calculated for all submeshes
  29963. */
  29964. protected _markAllSubMeshesAsAttributesDirty(): void;
  29965. /**
  29966. * Indicates that misc needs to be re-calculated for all submeshes
  29967. */
  29968. protected _markAllSubMeshesAsMiscDirty(): void;
  29969. /**
  29970. * Indicates that prepass needs to be re-calculated for all submeshes
  29971. */
  29972. protected _markAllSubMeshesAsPrePassDirty(): void;
  29973. /**
  29974. * Indicates that textures and misc need to be re-calculated for all submeshes
  29975. */
  29976. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29977. /**
  29978. * Sets the required values to the prepass renderer.
  29979. * @param prePassRenderer defines the prepass renderer to setup.
  29980. * @returns true if the pre pass is needed.
  29981. */
  29982. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29983. /**
  29984. * Disposes the material
  29985. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29986. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29987. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29988. */
  29989. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29990. /** @hidden */
  29991. private releaseVertexArrayObject;
  29992. /**
  29993. * Serializes this material
  29994. * @returns the serialized material object
  29995. */
  29996. serialize(): any;
  29997. /**
  29998. * Creates a material from parsed material data
  29999. * @param parsedMaterial defines parsed material data
  30000. * @param scene defines the hosting scene
  30001. * @param rootUrl defines the root URL to use to load textures
  30002. * @returns a new material
  30003. */
  30004. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30005. }
  30006. }
  30007. declare module BABYLON {
  30008. /**
  30009. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30010. * separate meshes. This can be use to improve performances.
  30011. * @see https://doc.babylonjs.com/how_to/multi_materials
  30012. */
  30013. export class MultiMaterial extends Material {
  30014. private _subMaterials;
  30015. /**
  30016. * Gets or Sets the list of Materials used within the multi material.
  30017. * They need to be ordered according to the submeshes order in the associated mesh
  30018. */
  30019. get subMaterials(): Nullable<Material>[];
  30020. set subMaterials(value: Nullable<Material>[]);
  30021. /**
  30022. * Function used to align with Node.getChildren()
  30023. * @returns the list of Materials used within the multi material
  30024. */
  30025. getChildren(): Nullable<Material>[];
  30026. /**
  30027. * Instantiates a new Multi Material
  30028. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30029. * separate meshes. This can be use to improve performances.
  30030. * @see https://doc.babylonjs.com/how_to/multi_materials
  30031. * @param name Define the name in the scene
  30032. * @param scene Define the scene the material belongs to
  30033. */
  30034. constructor(name: string, scene: Scene);
  30035. private _hookArray;
  30036. /**
  30037. * Get one of the submaterial by its index in the submaterials array
  30038. * @param index The index to look the sub material at
  30039. * @returns The Material if the index has been defined
  30040. */
  30041. getSubMaterial(index: number): Nullable<Material>;
  30042. /**
  30043. * Get the list of active textures for the whole sub materials list.
  30044. * @returns All the textures that will be used during the rendering
  30045. */
  30046. getActiveTextures(): BaseTexture[];
  30047. /**
  30048. * Specifies if any sub-materials of this multi-material use a given texture.
  30049. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30050. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30051. */
  30052. hasTexture(texture: BaseTexture): boolean;
  30053. /**
  30054. * Gets the current class name of the material e.g. "MultiMaterial"
  30055. * Mainly use in serialization.
  30056. * @returns the class name
  30057. */
  30058. getClassName(): string;
  30059. /**
  30060. * Checks if the material is ready to render the requested sub mesh
  30061. * @param mesh Define the mesh the submesh belongs to
  30062. * @param subMesh Define the sub mesh to look readyness for
  30063. * @param useInstances Define whether or not the material is used with instances
  30064. * @returns true if ready, otherwise false
  30065. */
  30066. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30067. /**
  30068. * Clones the current material and its related sub materials
  30069. * @param name Define the name of the newly cloned material
  30070. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30071. * @returns the cloned material
  30072. */
  30073. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30074. /**
  30075. * Serializes the materials into a JSON representation.
  30076. * @returns the JSON representation
  30077. */
  30078. serialize(): any;
  30079. /**
  30080. * Dispose the material and release its associated resources
  30081. * @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)
  30082. * @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)
  30083. * @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)
  30084. */
  30085. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30086. /**
  30087. * Creates a MultiMaterial from parsed MultiMaterial data.
  30088. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30089. * @param scene defines the hosting scene
  30090. * @returns a new MultiMaterial
  30091. */
  30092. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30093. }
  30094. }
  30095. declare module BABYLON {
  30096. /**
  30097. * Defines a subdivision inside a mesh
  30098. */
  30099. export class SubMesh implements ICullable {
  30100. /** the material index to use */
  30101. materialIndex: number;
  30102. /** vertex index start */
  30103. verticesStart: number;
  30104. /** vertices count */
  30105. verticesCount: number;
  30106. /** index start */
  30107. indexStart: number;
  30108. /** indices count */
  30109. indexCount: number;
  30110. /** @hidden */
  30111. _materialDefines: Nullable<MaterialDefines>;
  30112. /** @hidden */
  30113. _materialEffect: Nullable<Effect>;
  30114. /** @hidden */
  30115. _effectOverride: Nullable<Effect>;
  30116. /**
  30117. * Gets material defines used by the effect associated to the sub mesh
  30118. */
  30119. get materialDefines(): Nullable<MaterialDefines>;
  30120. /**
  30121. * Sets material defines used by the effect associated to the sub mesh
  30122. */
  30123. set materialDefines(defines: Nullable<MaterialDefines>);
  30124. /**
  30125. * Gets associated effect
  30126. */
  30127. get effect(): Nullable<Effect>;
  30128. /**
  30129. * Sets associated effect (effect used to render this submesh)
  30130. * @param effect defines the effect to associate with
  30131. * @param defines defines the set of defines used to compile this effect
  30132. */
  30133. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30134. /** @hidden */
  30135. _linesIndexCount: number;
  30136. private _mesh;
  30137. private _renderingMesh;
  30138. private _boundingInfo;
  30139. private _linesIndexBuffer;
  30140. /** @hidden */
  30141. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30142. /** @hidden */
  30143. _trianglePlanes: Plane[];
  30144. /** @hidden */
  30145. _lastColliderTransformMatrix: Nullable<Matrix>;
  30146. /** @hidden */
  30147. _renderId: number;
  30148. /** @hidden */
  30149. _alphaIndex: number;
  30150. /** @hidden */
  30151. _distanceToCamera: number;
  30152. /** @hidden */
  30153. _id: number;
  30154. private _currentMaterial;
  30155. /**
  30156. * Add a new submesh to a mesh
  30157. * @param materialIndex defines the material index to use
  30158. * @param verticesStart defines vertex index start
  30159. * @param verticesCount defines vertices count
  30160. * @param indexStart defines index start
  30161. * @param indexCount defines indices count
  30162. * @param mesh defines the parent mesh
  30163. * @param renderingMesh defines an optional rendering mesh
  30164. * @param createBoundingBox defines if bounding box should be created for this submesh
  30165. * @returns the new submesh
  30166. */
  30167. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30168. /**
  30169. * Creates a new submesh
  30170. * @param materialIndex defines the material index to use
  30171. * @param verticesStart defines vertex index start
  30172. * @param verticesCount defines vertices count
  30173. * @param indexStart defines index start
  30174. * @param indexCount defines indices count
  30175. * @param mesh defines the parent mesh
  30176. * @param renderingMesh defines an optional rendering mesh
  30177. * @param createBoundingBox defines if bounding box should be created for this submesh
  30178. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30179. */
  30180. constructor(
  30181. /** the material index to use */
  30182. materialIndex: number,
  30183. /** vertex index start */
  30184. verticesStart: number,
  30185. /** vertices count */
  30186. verticesCount: number,
  30187. /** index start */
  30188. indexStart: number,
  30189. /** indices count */
  30190. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30191. /**
  30192. * Returns true if this submesh covers the entire parent mesh
  30193. * @ignorenaming
  30194. */
  30195. get IsGlobal(): boolean;
  30196. /**
  30197. * Returns the submesh BoudingInfo object
  30198. * @returns current bounding info (or mesh's one if the submesh is global)
  30199. */
  30200. getBoundingInfo(): BoundingInfo;
  30201. /**
  30202. * Sets the submesh BoundingInfo
  30203. * @param boundingInfo defines the new bounding info to use
  30204. * @returns the SubMesh
  30205. */
  30206. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30207. /**
  30208. * Returns the mesh of the current submesh
  30209. * @return the parent mesh
  30210. */
  30211. getMesh(): AbstractMesh;
  30212. /**
  30213. * Returns the rendering mesh of the submesh
  30214. * @returns the rendering mesh (could be different from parent mesh)
  30215. */
  30216. getRenderingMesh(): Mesh;
  30217. /**
  30218. * Returns the replacement mesh of the submesh
  30219. * @returns the replacement mesh (could be different from parent mesh)
  30220. */
  30221. getReplacementMesh(): Nullable<AbstractMesh>;
  30222. /**
  30223. * Returns the effective mesh of the submesh
  30224. * @returns the effective mesh (could be different from parent mesh)
  30225. */
  30226. getEffectiveMesh(): AbstractMesh;
  30227. /**
  30228. * Returns the submesh material
  30229. * @returns null or the current material
  30230. */
  30231. getMaterial(): Nullable<Material>;
  30232. private _IsMultiMaterial;
  30233. /**
  30234. * Sets a new updated BoundingInfo object to the submesh
  30235. * @param data defines an optional position array to use to determine the bounding info
  30236. * @returns the SubMesh
  30237. */
  30238. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30239. /** @hidden */
  30240. _checkCollision(collider: Collider): boolean;
  30241. /**
  30242. * Updates the submesh BoundingInfo
  30243. * @param world defines the world matrix to use to update the bounding info
  30244. * @returns the submesh
  30245. */
  30246. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30247. /**
  30248. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30249. * @param frustumPlanes defines the frustum planes
  30250. * @returns true if the submesh is intersecting with the frustum
  30251. */
  30252. isInFrustum(frustumPlanes: Plane[]): boolean;
  30253. /**
  30254. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30255. * @param frustumPlanes defines the frustum planes
  30256. * @returns true if the submesh is inside the frustum
  30257. */
  30258. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30259. /**
  30260. * Renders the submesh
  30261. * @param enableAlphaMode defines if alpha needs to be used
  30262. * @returns the submesh
  30263. */
  30264. render(enableAlphaMode: boolean): SubMesh;
  30265. /**
  30266. * @hidden
  30267. */
  30268. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30269. /**
  30270. * Checks if the submesh intersects with a ray
  30271. * @param ray defines the ray to test
  30272. * @returns true is the passed ray intersects the submesh bounding box
  30273. */
  30274. canIntersects(ray: Ray): boolean;
  30275. /**
  30276. * Intersects current submesh with a ray
  30277. * @param ray defines the ray to test
  30278. * @param positions defines mesh's positions array
  30279. * @param indices defines mesh's indices array
  30280. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30281. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30282. * @returns intersection info or null if no intersection
  30283. */
  30284. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30285. /** @hidden */
  30286. private _intersectLines;
  30287. /** @hidden */
  30288. private _intersectUnIndexedLines;
  30289. /** @hidden */
  30290. private _intersectTriangles;
  30291. /** @hidden */
  30292. private _intersectUnIndexedTriangles;
  30293. /** @hidden */
  30294. _rebuild(): void;
  30295. /**
  30296. * Creates a new submesh from the passed mesh
  30297. * @param newMesh defines the new hosting mesh
  30298. * @param newRenderingMesh defines an optional rendering mesh
  30299. * @returns the new submesh
  30300. */
  30301. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30302. /**
  30303. * Release associated resources
  30304. */
  30305. dispose(): void;
  30306. /**
  30307. * Gets the class name
  30308. * @returns the string "SubMesh".
  30309. */
  30310. getClassName(): string;
  30311. /**
  30312. * Creates a new submesh from indices data
  30313. * @param materialIndex the index of the main mesh material
  30314. * @param startIndex the index where to start the copy in the mesh indices array
  30315. * @param indexCount the number of indices to copy then from the startIndex
  30316. * @param mesh the main mesh to create the submesh from
  30317. * @param renderingMesh the optional rendering mesh
  30318. * @returns a new submesh
  30319. */
  30320. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30321. }
  30322. }
  30323. declare module BABYLON {
  30324. /**
  30325. * Class used to represent data loading progression
  30326. */
  30327. export class SceneLoaderFlags {
  30328. private static _ForceFullSceneLoadingForIncremental;
  30329. private static _ShowLoadingScreen;
  30330. private static _CleanBoneMatrixWeights;
  30331. private static _loggingLevel;
  30332. /**
  30333. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30334. */
  30335. static get ForceFullSceneLoadingForIncremental(): boolean;
  30336. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30337. /**
  30338. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30339. */
  30340. static get ShowLoadingScreen(): boolean;
  30341. static set ShowLoadingScreen(value: boolean);
  30342. /**
  30343. * Defines the current logging level (while loading the scene)
  30344. * @ignorenaming
  30345. */
  30346. static get loggingLevel(): number;
  30347. static set loggingLevel(value: number);
  30348. /**
  30349. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30350. */
  30351. static get CleanBoneMatrixWeights(): boolean;
  30352. static set CleanBoneMatrixWeights(value: boolean);
  30353. }
  30354. }
  30355. declare module BABYLON {
  30356. /**
  30357. * Class used to store geometry data (vertex buffers + index buffer)
  30358. */
  30359. export class Geometry implements IGetSetVerticesData {
  30360. /**
  30361. * Gets or sets the ID of the geometry
  30362. */
  30363. id: string;
  30364. /**
  30365. * Gets or sets the unique ID of the geometry
  30366. */
  30367. uniqueId: number;
  30368. /**
  30369. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30370. */
  30371. delayLoadState: number;
  30372. /**
  30373. * Gets the file containing the data to load when running in delay load state
  30374. */
  30375. delayLoadingFile: Nullable<string>;
  30376. /**
  30377. * Callback called when the geometry is updated
  30378. */
  30379. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30380. private _scene;
  30381. private _engine;
  30382. private _meshes;
  30383. private _totalVertices;
  30384. /** @hidden */
  30385. _indices: IndicesArray;
  30386. /** @hidden */
  30387. _vertexBuffers: {
  30388. [key: string]: VertexBuffer;
  30389. };
  30390. private _isDisposed;
  30391. private _extend;
  30392. private _boundingBias;
  30393. /** @hidden */
  30394. _delayInfo: Array<string>;
  30395. private _indexBuffer;
  30396. private _indexBufferIsUpdatable;
  30397. /** @hidden */
  30398. _boundingInfo: Nullable<BoundingInfo>;
  30399. /** @hidden */
  30400. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30401. /** @hidden */
  30402. _softwareSkinningFrameId: number;
  30403. private _vertexArrayObjects;
  30404. private _updatable;
  30405. /** @hidden */
  30406. _positions: Nullable<Vector3[]>;
  30407. private _positionsCache;
  30408. /**
  30409. * 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
  30410. */
  30411. get boundingBias(): Vector2;
  30412. /**
  30413. * 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
  30414. */
  30415. set boundingBias(value: Vector2);
  30416. /**
  30417. * Static function used to attach a new empty geometry to a mesh
  30418. * @param mesh defines the mesh to attach the geometry to
  30419. * @returns the new Geometry
  30420. */
  30421. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30422. /** Get the list of meshes using this geometry */
  30423. get meshes(): Mesh[];
  30424. /**
  30425. * 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
  30426. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30427. */
  30428. useBoundingInfoFromGeometry: boolean;
  30429. /**
  30430. * Creates a new geometry
  30431. * @param id defines the unique ID
  30432. * @param scene defines the hosting scene
  30433. * @param vertexData defines the VertexData used to get geometry data
  30434. * @param updatable defines if geometry must be updatable (false by default)
  30435. * @param mesh defines the mesh that will be associated with the geometry
  30436. */
  30437. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30438. /**
  30439. * Gets the current extend of the geometry
  30440. */
  30441. get extend(): {
  30442. minimum: Vector3;
  30443. maximum: Vector3;
  30444. };
  30445. /**
  30446. * Gets the hosting scene
  30447. * @returns the hosting Scene
  30448. */
  30449. getScene(): Scene;
  30450. /**
  30451. * Gets the hosting engine
  30452. * @returns the hosting Engine
  30453. */
  30454. getEngine(): Engine;
  30455. /**
  30456. * Defines if the geometry is ready to use
  30457. * @returns true if the geometry is ready to be used
  30458. */
  30459. isReady(): boolean;
  30460. /**
  30461. * Gets a value indicating that the geometry should not be serialized
  30462. */
  30463. get doNotSerialize(): boolean;
  30464. /** @hidden */
  30465. _rebuild(): void;
  30466. /**
  30467. * Affects all geometry data in one call
  30468. * @param vertexData defines the geometry data
  30469. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30470. */
  30471. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30472. /**
  30473. * Set specific vertex data
  30474. * @param kind defines the data kind (Position, normal, etc...)
  30475. * @param data defines the vertex data to use
  30476. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30477. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30478. */
  30479. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30480. /**
  30481. * Removes a specific vertex data
  30482. * @param kind defines the data kind (Position, normal, etc...)
  30483. */
  30484. removeVerticesData(kind: string): void;
  30485. /**
  30486. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30487. * @param buffer defines the vertex buffer to use
  30488. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30489. */
  30490. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30491. /**
  30492. * Update a specific vertex buffer
  30493. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30494. * It will do nothing if the buffer is not updatable
  30495. * @param kind defines the data kind (Position, normal, etc...)
  30496. * @param data defines the data to use
  30497. * @param offset defines the offset in the target buffer where to store the data
  30498. * @param useBytes set to true if the offset is in bytes
  30499. */
  30500. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30501. /**
  30502. * Update a specific vertex buffer
  30503. * This function will create a new buffer if the current one is not updatable
  30504. * @param kind defines the data kind (Position, normal, etc...)
  30505. * @param data defines the data to use
  30506. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30507. */
  30508. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30509. private _updateBoundingInfo;
  30510. /** @hidden */
  30511. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30512. /**
  30513. * Gets total number of vertices
  30514. * @returns the total number of vertices
  30515. */
  30516. getTotalVertices(): number;
  30517. /**
  30518. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30519. * @param kind defines the data kind (Position, normal, etc...)
  30520. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30521. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30522. * @returns a float array containing vertex data
  30523. */
  30524. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30525. /**
  30526. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30527. * @param kind defines the data kind (Position, normal, etc...)
  30528. * @returns true if the vertex buffer with the specified kind is updatable
  30529. */
  30530. isVertexBufferUpdatable(kind: string): boolean;
  30531. /**
  30532. * Gets a specific vertex buffer
  30533. * @param kind defines the data kind (Position, normal, etc...)
  30534. * @returns a VertexBuffer
  30535. */
  30536. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30537. /**
  30538. * Returns all vertex buffers
  30539. * @return an object holding all vertex buffers indexed by kind
  30540. */
  30541. getVertexBuffers(): Nullable<{
  30542. [key: string]: VertexBuffer;
  30543. }>;
  30544. /**
  30545. * Gets a boolean indicating if specific vertex buffer is present
  30546. * @param kind defines the data kind (Position, normal, etc...)
  30547. * @returns true if data is present
  30548. */
  30549. isVerticesDataPresent(kind: string): boolean;
  30550. /**
  30551. * Gets a list of all attached data kinds (Position, normal, etc...)
  30552. * @returns a list of string containing all kinds
  30553. */
  30554. getVerticesDataKinds(): string[];
  30555. /**
  30556. * Update index buffer
  30557. * @param indices defines the indices to store in the index buffer
  30558. * @param offset defines the offset in the target buffer where to store the data
  30559. * @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)
  30560. */
  30561. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30562. /**
  30563. * Creates a new index buffer
  30564. * @param indices defines the indices to store in the index buffer
  30565. * @param totalVertices defines the total number of vertices (could be null)
  30566. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30567. */
  30568. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30569. /**
  30570. * Return the total number of indices
  30571. * @returns the total number of indices
  30572. */
  30573. getTotalIndices(): number;
  30574. /**
  30575. * Gets the index buffer array
  30576. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30577. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30578. * @returns the index buffer array
  30579. */
  30580. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30581. /**
  30582. * Gets the index buffer
  30583. * @return the index buffer
  30584. */
  30585. getIndexBuffer(): Nullable<DataBuffer>;
  30586. /** @hidden */
  30587. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30588. /**
  30589. * Release the associated resources for a specific mesh
  30590. * @param mesh defines the source mesh
  30591. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30592. */
  30593. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30594. /**
  30595. * Apply current geometry to a given mesh
  30596. * @param mesh defines the mesh to apply geometry to
  30597. */
  30598. applyToMesh(mesh: Mesh): void;
  30599. private _updateExtend;
  30600. private _applyToMesh;
  30601. private notifyUpdate;
  30602. /**
  30603. * Load the geometry if it was flagged as delay loaded
  30604. * @param scene defines the hosting scene
  30605. * @param onLoaded defines a callback called when the geometry is loaded
  30606. */
  30607. load(scene: Scene, onLoaded?: () => void): void;
  30608. private _queueLoad;
  30609. /**
  30610. * Invert the geometry to move from a right handed system to a left handed one.
  30611. */
  30612. toLeftHanded(): void;
  30613. /** @hidden */
  30614. _resetPointsArrayCache(): void;
  30615. /** @hidden */
  30616. _generatePointsArray(): boolean;
  30617. /**
  30618. * Gets a value indicating if the geometry is disposed
  30619. * @returns true if the geometry was disposed
  30620. */
  30621. isDisposed(): boolean;
  30622. private _disposeVertexArrayObjects;
  30623. /**
  30624. * Free all associated resources
  30625. */
  30626. dispose(): void;
  30627. /**
  30628. * Clone the current geometry into a new geometry
  30629. * @param id defines the unique ID of the new geometry
  30630. * @returns a new geometry object
  30631. */
  30632. copy(id: string): Geometry;
  30633. /**
  30634. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30635. * @return a JSON representation of the current geometry data (without the vertices data)
  30636. */
  30637. serialize(): any;
  30638. private toNumberArray;
  30639. /**
  30640. * Serialize all vertices data into a JSON oject
  30641. * @returns a JSON representation of the current geometry data
  30642. */
  30643. serializeVerticeData(): any;
  30644. /**
  30645. * Extracts a clone of a mesh geometry
  30646. * @param mesh defines the source mesh
  30647. * @param id defines the unique ID of the new geometry object
  30648. * @returns the new geometry object
  30649. */
  30650. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30651. /**
  30652. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30653. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30654. * Be aware Math.random() could cause collisions, but:
  30655. * "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"
  30656. * @returns a string containing a new GUID
  30657. */
  30658. static RandomId(): string;
  30659. /** @hidden */
  30660. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30661. private static _CleanMatricesWeights;
  30662. /**
  30663. * Create a new geometry from persisted data (Using .babylon file format)
  30664. * @param parsedVertexData defines the persisted data
  30665. * @param scene defines the hosting scene
  30666. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30667. * @returns the new geometry object
  30668. */
  30669. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30670. }
  30671. }
  30672. declare module BABYLON {
  30673. /**
  30674. * Defines a target to use with MorphTargetManager
  30675. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30676. */
  30677. export class MorphTarget implements IAnimatable {
  30678. /** defines the name of the target */
  30679. name: string;
  30680. /**
  30681. * Gets or sets the list of animations
  30682. */
  30683. animations: Animation[];
  30684. private _scene;
  30685. private _positions;
  30686. private _normals;
  30687. private _tangents;
  30688. private _uvs;
  30689. private _influence;
  30690. private _uniqueId;
  30691. /**
  30692. * Observable raised when the influence changes
  30693. */
  30694. onInfluenceChanged: Observable<boolean>;
  30695. /** @hidden */
  30696. _onDataLayoutChanged: Observable<void>;
  30697. /**
  30698. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30699. */
  30700. get influence(): number;
  30701. set influence(influence: number);
  30702. /**
  30703. * Gets or sets the id of the morph Target
  30704. */
  30705. id: string;
  30706. private _animationPropertiesOverride;
  30707. /**
  30708. * Gets or sets the animation properties override
  30709. */
  30710. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30711. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30712. /**
  30713. * Creates a new MorphTarget
  30714. * @param name defines the name of the target
  30715. * @param influence defines the influence to use
  30716. * @param scene defines the scene the morphtarget belongs to
  30717. */
  30718. constructor(
  30719. /** defines the name of the target */
  30720. name: string, influence?: number, scene?: Nullable<Scene>);
  30721. /**
  30722. * Gets the unique ID of this manager
  30723. */
  30724. get uniqueId(): number;
  30725. /**
  30726. * Gets a boolean defining if the target contains position data
  30727. */
  30728. get hasPositions(): boolean;
  30729. /**
  30730. * Gets a boolean defining if the target contains normal data
  30731. */
  30732. get hasNormals(): boolean;
  30733. /**
  30734. * Gets a boolean defining if the target contains tangent data
  30735. */
  30736. get hasTangents(): boolean;
  30737. /**
  30738. * Gets a boolean defining if the target contains texture coordinates data
  30739. */
  30740. get hasUVs(): boolean;
  30741. /**
  30742. * Affects position data to this target
  30743. * @param data defines the position data to use
  30744. */
  30745. setPositions(data: Nullable<FloatArray>): void;
  30746. /**
  30747. * Gets the position data stored in this target
  30748. * @returns a FloatArray containing the position data (or null if not present)
  30749. */
  30750. getPositions(): Nullable<FloatArray>;
  30751. /**
  30752. * Affects normal data to this target
  30753. * @param data defines the normal data to use
  30754. */
  30755. setNormals(data: Nullable<FloatArray>): void;
  30756. /**
  30757. * Gets the normal data stored in this target
  30758. * @returns a FloatArray containing the normal data (or null if not present)
  30759. */
  30760. getNormals(): Nullable<FloatArray>;
  30761. /**
  30762. * Affects tangent data to this target
  30763. * @param data defines the tangent data to use
  30764. */
  30765. setTangents(data: Nullable<FloatArray>): void;
  30766. /**
  30767. * Gets the tangent data stored in this target
  30768. * @returns a FloatArray containing the tangent data (or null if not present)
  30769. */
  30770. getTangents(): Nullable<FloatArray>;
  30771. /**
  30772. * Affects texture coordinates data to this target
  30773. * @param data defines the texture coordinates data to use
  30774. */
  30775. setUVs(data: Nullable<FloatArray>): void;
  30776. /**
  30777. * Gets the texture coordinates data stored in this target
  30778. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30779. */
  30780. getUVs(): Nullable<FloatArray>;
  30781. /**
  30782. * Clone the current target
  30783. * @returns a new MorphTarget
  30784. */
  30785. clone(): MorphTarget;
  30786. /**
  30787. * Serializes the current target into a Serialization object
  30788. * @returns the serialized object
  30789. */
  30790. serialize(): any;
  30791. /**
  30792. * Returns the string "MorphTarget"
  30793. * @returns "MorphTarget"
  30794. */
  30795. getClassName(): string;
  30796. /**
  30797. * Creates a new target from serialized data
  30798. * @param serializationObject defines the serialized data to use
  30799. * @returns a new MorphTarget
  30800. */
  30801. static Parse(serializationObject: any): MorphTarget;
  30802. /**
  30803. * Creates a MorphTarget from mesh data
  30804. * @param mesh defines the source mesh
  30805. * @param name defines the name to use for the new target
  30806. * @param influence defines the influence to attach to the target
  30807. * @returns a new MorphTarget
  30808. */
  30809. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30810. }
  30811. }
  30812. declare module BABYLON {
  30813. /**
  30814. * This class is used to deform meshes using morphing between different targets
  30815. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30816. */
  30817. export class MorphTargetManager {
  30818. private _targets;
  30819. private _targetInfluenceChangedObservers;
  30820. private _targetDataLayoutChangedObservers;
  30821. private _activeTargets;
  30822. private _scene;
  30823. private _influences;
  30824. private _supportsNormals;
  30825. private _supportsTangents;
  30826. private _supportsUVs;
  30827. private _vertexCount;
  30828. private _uniqueId;
  30829. private _tempInfluences;
  30830. /**
  30831. * Gets or sets a boolean indicating if normals must be morphed
  30832. */
  30833. enableNormalMorphing: boolean;
  30834. /**
  30835. * Gets or sets a boolean indicating if tangents must be morphed
  30836. */
  30837. enableTangentMorphing: boolean;
  30838. /**
  30839. * Gets or sets a boolean indicating if UV must be morphed
  30840. */
  30841. enableUVMorphing: boolean;
  30842. /**
  30843. * Creates a new MorphTargetManager
  30844. * @param scene defines the current scene
  30845. */
  30846. constructor(scene?: Nullable<Scene>);
  30847. /**
  30848. * Gets the unique ID of this manager
  30849. */
  30850. get uniqueId(): number;
  30851. /**
  30852. * Gets the number of vertices handled by this manager
  30853. */
  30854. get vertexCount(): number;
  30855. /**
  30856. * Gets a boolean indicating if this manager supports morphing of normals
  30857. */
  30858. get supportsNormals(): boolean;
  30859. /**
  30860. * Gets a boolean indicating if this manager supports morphing of tangents
  30861. */
  30862. get supportsTangents(): boolean;
  30863. /**
  30864. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  30865. */
  30866. get supportsUVs(): boolean;
  30867. /**
  30868. * Gets the number of targets stored in this manager
  30869. */
  30870. get numTargets(): number;
  30871. /**
  30872. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30873. */
  30874. get numInfluencers(): number;
  30875. /**
  30876. * Gets the list of influences (one per target)
  30877. */
  30878. get influences(): Float32Array;
  30879. /**
  30880. * Gets the active target at specified index. An active target is a target with an influence > 0
  30881. * @param index defines the index to check
  30882. * @returns the requested target
  30883. */
  30884. getActiveTarget(index: number): MorphTarget;
  30885. /**
  30886. * Gets the target at specified index
  30887. * @param index defines the index to check
  30888. * @returns the requested target
  30889. */
  30890. getTarget(index: number): MorphTarget;
  30891. /**
  30892. * Add a new target to this manager
  30893. * @param target defines the target to add
  30894. */
  30895. addTarget(target: MorphTarget): void;
  30896. /**
  30897. * Removes a target from the manager
  30898. * @param target defines the target to remove
  30899. */
  30900. removeTarget(target: MorphTarget): void;
  30901. /**
  30902. * Clone the current manager
  30903. * @returns a new MorphTargetManager
  30904. */
  30905. clone(): MorphTargetManager;
  30906. /**
  30907. * Serializes the current manager into a Serialization object
  30908. * @returns the serialized object
  30909. */
  30910. serialize(): any;
  30911. private _syncActiveTargets;
  30912. /**
  30913. * Syncrhonize the targets with all the meshes using this morph target manager
  30914. */
  30915. synchronize(): void;
  30916. /**
  30917. * Creates a new MorphTargetManager from serialized data
  30918. * @param serializationObject defines the serialized data
  30919. * @param scene defines the hosting scene
  30920. * @returns the new MorphTargetManager
  30921. */
  30922. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30923. }
  30924. }
  30925. declare module BABYLON {
  30926. /**
  30927. * Class used to represent a specific level of detail of a mesh
  30928. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  30929. */
  30930. export class MeshLODLevel {
  30931. /** Defines the distance where this level should start being displayed */
  30932. distance: number;
  30933. /** Defines the mesh to use to render this level */
  30934. mesh: Nullable<Mesh>;
  30935. /**
  30936. * Creates a new LOD level
  30937. * @param distance defines the distance where this level should star being displayed
  30938. * @param mesh defines the mesh to use to render this level
  30939. */
  30940. constructor(
  30941. /** Defines the distance where this level should start being displayed */
  30942. distance: number,
  30943. /** Defines the mesh to use to render this level */
  30944. mesh: Nullable<Mesh>);
  30945. }
  30946. }
  30947. declare module BABYLON {
  30948. /**
  30949. * Helper class used to generate a canvas to manipulate images
  30950. */
  30951. export class CanvasGenerator {
  30952. /**
  30953. * Create a new canvas (or offscreen canvas depending on the context)
  30954. * @param width defines the expected width
  30955. * @param height defines the expected height
  30956. * @return a new canvas or offscreen canvas
  30957. */
  30958. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  30959. }
  30960. }
  30961. declare module BABYLON {
  30962. /**
  30963. * Mesh representing the gorund
  30964. */
  30965. export class GroundMesh extends Mesh {
  30966. /** If octree should be generated */
  30967. generateOctree: boolean;
  30968. private _heightQuads;
  30969. /** @hidden */
  30970. _subdivisionsX: number;
  30971. /** @hidden */
  30972. _subdivisionsY: number;
  30973. /** @hidden */
  30974. _width: number;
  30975. /** @hidden */
  30976. _height: number;
  30977. /** @hidden */
  30978. _minX: number;
  30979. /** @hidden */
  30980. _maxX: number;
  30981. /** @hidden */
  30982. _minZ: number;
  30983. /** @hidden */
  30984. _maxZ: number;
  30985. constructor(name: string, scene: Scene);
  30986. /**
  30987. * "GroundMesh"
  30988. * @returns "GroundMesh"
  30989. */
  30990. getClassName(): string;
  30991. /**
  30992. * The minimum of x and y subdivisions
  30993. */
  30994. get subdivisions(): number;
  30995. /**
  30996. * X subdivisions
  30997. */
  30998. get subdivisionsX(): number;
  30999. /**
  31000. * Y subdivisions
  31001. */
  31002. get subdivisionsY(): number;
  31003. /**
  31004. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31005. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31006. * @param chunksCount the number of subdivisions for x and y
  31007. * @param octreeBlocksSize (Default: 32)
  31008. */
  31009. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31010. /**
  31011. * Returns a height (y) value in the Worl system :
  31012. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31013. * @param x x coordinate
  31014. * @param z z coordinate
  31015. * @returns the ground y position if (x, z) are outside the ground surface.
  31016. */
  31017. getHeightAtCoordinates(x: number, z: number): number;
  31018. /**
  31019. * Returns a normalized vector (Vector3) orthogonal to the ground
  31020. * at the ground coordinates (x, z) expressed in the World system.
  31021. * @param x x coordinate
  31022. * @param z z coordinate
  31023. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31024. */
  31025. getNormalAtCoordinates(x: number, z: number): Vector3;
  31026. /**
  31027. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31028. * at the ground coordinates (x, z) expressed in the World system.
  31029. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31030. * @param x x coordinate
  31031. * @param z z coordinate
  31032. * @param ref vector to store the result
  31033. * @returns the GroundMesh.
  31034. */
  31035. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31036. /**
  31037. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31038. * if the ground has been updated.
  31039. * This can be used in the render loop.
  31040. * @returns the GroundMesh.
  31041. */
  31042. updateCoordinateHeights(): GroundMesh;
  31043. private _getFacetAt;
  31044. private _initHeightQuads;
  31045. private _computeHeightQuads;
  31046. /**
  31047. * Serializes this ground mesh
  31048. * @param serializationObject object to write serialization to
  31049. */
  31050. serialize(serializationObject: any): void;
  31051. /**
  31052. * Parses a serialized ground mesh
  31053. * @param parsedMesh the serialized mesh
  31054. * @param scene the scene to create the ground mesh in
  31055. * @returns the created ground mesh
  31056. */
  31057. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31058. }
  31059. }
  31060. declare module BABYLON {
  31061. /**
  31062. * Interface for Physics-Joint data
  31063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31064. */
  31065. export interface PhysicsJointData {
  31066. /**
  31067. * The main pivot of the joint
  31068. */
  31069. mainPivot?: Vector3;
  31070. /**
  31071. * The connected pivot of the joint
  31072. */
  31073. connectedPivot?: Vector3;
  31074. /**
  31075. * The main axis of the joint
  31076. */
  31077. mainAxis?: Vector3;
  31078. /**
  31079. * The connected axis of the joint
  31080. */
  31081. connectedAxis?: Vector3;
  31082. /**
  31083. * The collision of the joint
  31084. */
  31085. collision?: boolean;
  31086. /**
  31087. * Native Oimo/Cannon/Energy data
  31088. */
  31089. nativeParams?: any;
  31090. }
  31091. /**
  31092. * This is a holder class for the physics joint created by the physics plugin
  31093. * It holds a set of functions to control the underlying joint
  31094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31095. */
  31096. export class PhysicsJoint {
  31097. /**
  31098. * The type of the physics joint
  31099. */
  31100. type: number;
  31101. /**
  31102. * The data for the physics joint
  31103. */
  31104. jointData: PhysicsJointData;
  31105. private _physicsJoint;
  31106. protected _physicsPlugin: IPhysicsEnginePlugin;
  31107. /**
  31108. * Initializes the physics joint
  31109. * @param type The type of the physics joint
  31110. * @param jointData The data for the physics joint
  31111. */
  31112. constructor(
  31113. /**
  31114. * The type of the physics joint
  31115. */
  31116. type: number,
  31117. /**
  31118. * The data for the physics joint
  31119. */
  31120. jointData: PhysicsJointData);
  31121. /**
  31122. * Gets the physics joint
  31123. */
  31124. get physicsJoint(): any;
  31125. /**
  31126. * Sets the physics joint
  31127. */
  31128. set physicsJoint(newJoint: any);
  31129. /**
  31130. * Sets the physics plugin
  31131. */
  31132. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31133. /**
  31134. * Execute a function that is physics-plugin specific.
  31135. * @param {Function} func the function that will be executed.
  31136. * It accepts two parameters: the physics world and the physics joint
  31137. */
  31138. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31139. /**
  31140. * Distance-Joint type
  31141. */
  31142. static DistanceJoint: number;
  31143. /**
  31144. * Hinge-Joint type
  31145. */
  31146. static HingeJoint: number;
  31147. /**
  31148. * Ball-and-Socket joint type
  31149. */
  31150. static BallAndSocketJoint: number;
  31151. /**
  31152. * Wheel-Joint type
  31153. */
  31154. static WheelJoint: number;
  31155. /**
  31156. * Slider-Joint type
  31157. */
  31158. static SliderJoint: number;
  31159. /**
  31160. * Prismatic-Joint type
  31161. */
  31162. static PrismaticJoint: number;
  31163. /**
  31164. * Universal-Joint type
  31165. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31166. */
  31167. static UniversalJoint: number;
  31168. /**
  31169. * Hinge-Joint 2 type
  31170. */
  31171. static Hinge2Joint: number;
  31172. /**
  31173. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31174. */
  31175. static PointToPointJoint: number;
  31176. /**
  31177. * Spring-Joint type
  31178. */
  31179. static SpringJoint: number;
  31180. /**
  31181. * Lock-Joint type
  31182. */
  31183. static LockJoint: number;
  31184. }
  31185. /**
  31186. * A class representing a physics distance joint
  31187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31188. */
  31189. export class DistanceJoint extends PhysicsJoint {
  31190. /**
  31191. *
  31192. * @param jointData The data for the Distance-Joint
  31193. */
  31194. constructor(jointData: DistanceJointData);
  31195. /**
  31196. * Update the predefined distance.
  31197. * @param maxDistance The maximum preferred distance
  31198. * @param minDistance The minimum preferred distance
  31199. */
  31200. updateDistance(maxDistance: number, minDistance?: number): void;
  31201. }
  31202. /**
  31203. * Represents a Motor-Enabled Joint
  31204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31205. */
  31206. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31207. /**
  31208. * Initializes the Motor-Enabled Joint
  31209. * @param type The type of the joint
  31210. * @param jointData The physica joint data for the joint
  31211. */
  31212. constructor(type: number, jointData: PhysicsJointData);
  31213. /**
  31214. * Set the motor values.
  31215. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31216. * @param force the force to apply
  31217. * @param maxForce max force for this motor.
  31218. */
  31219. setMotor(force?: number, maxForce?: number): void;
  31220. /**
  31221. * Set the motor's limits.
  31222. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31223. * @param upperLimit The upper limit of the motor
  31224. * @param lowerLimit The lower limit of the motor
  31225. */
  31226. setLimit(upperLimit: number, lowerLimit?: number): void;
  31227. }
  31228. /**
  31229. * This class represents a single physics Hinge-Joint
  31230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31231. */
  31232. export class HingeJoint extends MotorEnabledJoint {
  31233. /**
  31234. * Initializes the Hinge-Joint
  31235. * @param jointData The joint data for the Hinge-Joint
  31236. */
  31237. constructor(jointData: PhysicsJointData);
  31238. /**
  31239. * Set the motor values.
  31240. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31241. * @param {number} force the force to apply
  31242. * @param {number} maxForce max force for this motor.
  31243. */
  31244. setMotor(force?: number, maxForce?: number): void;
  31245. /**
  31246. * Set the motor's limits.
  31247. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31248. * @param upperLimit The upper limit of the motor
  31249. * @param lowerLimit The lower limit of the motor
  31250. */
  31251. setLimit(upperLimit: number, lowerLimit?: number): void;
  31252. }
  31253. /**
  31254. * This class represents a dual hinge physics joint (same as wheel joint)
  31255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31256. */
  31257. export class Hinge2Joint extends MotorEnabledJoint {
  31258. /**
  31259. * Initializes the Hinge2-Joint
  31260. * @param jointData The joint data for the Hinge2-Joint
  31261. */
  31262. constructor(jointData: PhysicsJointData);
  31263. /**
  31264. * Set the motor values.
  31265. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31266. * @param {number} targetSpeed the speed the motor is to reach
  31267. * @param {number} maxForce max force for this motor.
  31268. * @param {motorIndex} the motor's index, 0 or 1.
  31269. */
  31270. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31271. /**
  31272. * Set the motor limits.
  31273. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31274. * @param {number} upperLimit the upper limit
  31275. * @param {number} lowerLimit lower limit
  31276. * @param {motorIndex} the motor's index, 0 or 1.
  31277. */
  31278. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31279. }
  31280. /**
  31281. * Interface for a motor enabled joint
  31282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31283. */
  31284. export interface IMotorEnabledJoint {
  31285. /**
  31286. * Physics joint
  31287. */
  31288. physicsJoint: any;
  31289. /**
  31290. * Sets the motor of the motor-enabled joint
  31291. * @param force The force of the motor
  31292. * @param maxForce The maximum force of the motor
  31293. * @param motorIndex The index of the motor
  31294. */
  31295. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31296. /**
  31297. * Sets the limit of the motor
  31298. * @param upperLimit The upper limit of the motor
  31299. * @param lowerLimit The lower limit of the motor
  31300. * @param motorIndex The index of the motor
  31301. */
  31302. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31303. }
  31304. /**
  31305. * Joint data for a Distance-Joint
  31306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31307. */
  31308. export interface DistanceJointData extends PhysicsJointData {
  31309. /**
  31310. * Max distance the 2 joint objects can be apart
  31311. */
  31312. maxDistance: number;
  31313. }
  31314. /**
  31315. * Joint data from a spring joint
  31316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31317. */
  31318. export interface SpringJointData extends PhysicsJointData {
  31319. /**
  31320. * Length of the spring
  31321. */
  31322. length: number;
  31323. /**
  31324. * Stiffness of the spring
  31325. */
  31326. stiffness: number;
  31327. /**
  31328. * Damping of the spring
  31329. */
  31330. damping: number;
  31331. /** this callback will be called when applying the force to the impostors. */
  31332. forceApplicationCallback: () => void;
  31333. }
  31334. }
  31335. declare module BABYLON {
  31336. /**
  31337. * Holds the data for the raycast result
  31338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31339. */
  31340. export class PhysicsRaycastResult {
  31341. private _hasHit;
  31342. private _hitDistance;
  31343. private _hitNormalWorld;
  31344. private _hitPointWorld;
  31345. private _rayFromWorld;
  31346. private _rayToWorld;
  31347. /**
  31348. * Gets if there was a hit
  31349. */
  31350. get hasHit(): boolean;
  31351. /**
  31352. * Gets the distance from the hit
  31353. */
  31354. get hitDistance(): number;
  31355. /**
  31356. * Gets the hit normal/direction in the world
  31357. */
  31358. get hitNormalWorld(): Vector3;
  31359. /**
  31360. * Gets the hit point in the world
  31361. */
  31362. get hitPointWorld(): Vector3;
  31363. /**
  31364. * Gets the ray "start point" of the ray in the world
  31365. */
  31366. get rayFromWorld(): Vector3;
  31367. /**
  31368. * Gets the ray "end point" of the ray in the world
  31369. */
  31370. get rayToWorld(): Vector3;
  31371. /**
  31372. * Sets the hit data (normal & point in world space)
  31373. * @param hitNormalWorld defines the normal in world space
  31374. * @param hitPointWorld defines the point in world space
  31375. */
  31376. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31377. /**
  31378. * Sets the distance from the start point to the hit point
  31379. * @param distance
  31380. */
  31381. setHitDistance(distance: number): void;
  31382. /**
  31383. * Calculates the distance manually
  31384. */
  31385. calculateHitDistance(): void;
  31386. /**
  31387. * Resets all the values to default
  31388. * @param from The from point on world space
  31389. * @param to The to point on world space
  31390. */
  31391. reset(from?: Vector3, to?: Vector3): void;
  31392. }
  31393. /**
  31394. * Interface for the size containing width and height
  31395. */
  31396. interface IXYZ {
  31397. /**
  31398. * X
  31399. */
  31400. x: number;
  31401. /**
  31402. * Y
  31403. */
  31404. y: number;
  31405. /**
  31406. * Z
  31407. */
  31408. z: number;
  31409. }
  31410. }
  31411. declare module BABYLON {
  31412. /**
  31413. * Interface used to describe a physics joint
  31414. */
  31415. export interface PhysicsImpostorJoint {
  31416. /** Defines the main impostor to which the joint is linked */
  31417. mainImpostor: PhysicsImpostor;
  31418. /** Defines the impostor that is connected to the main impostor using this joint */
  31419. connectedImpostor: PhysicsImpostor;
  31420. /** Defines the joint itself */
  31421. joint: PhysicsJoint;
  31422. }
  31423. /** @hidden */
  31424. export interface IPhysicsEnginePlugin {
  31425. world: any;
  31426. name: string;
  31427. setGravity(gravity: Vector3): void;
  31428. setTimeStep(timeStep: number): void;
  31429. getTimeStep(): number;
  31430. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31431. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31432. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31433. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31434. removePhysicsBody(impostor: PhysicsImpostor): void;
  31435. generateJoint(joint: PhysicsImpostorJoint): void;
  31436. removeJoint(joint: PhysicsImpostorJoint): void;
  31437. isSupported(): boolean;
  31438. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31439. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31440. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31441. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31442. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31443. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31444. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31445. getBodyMass(impostor: PhysicsImpostor): number;
  31446. getBodyFriction(impostor: PhysicsImpostor): number;
  31447. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31448. getBodyRestitution(impostor: PhysicsImpostor): number;
  31449. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31450. getBodyPressure?(impostor: PhysicsImpostor): number;
  31451. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31452. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31453. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31454. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31455. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31456. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31457. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31458. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31459. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31460. sleepBody(impostor: PhysicsImpostor): void;
  31461. wakeUpBody(impostor: PhysicsImpostor): void;
  31462. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31463. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31464. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31465. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31466. getRadius(impostor: PhysicsImpostor): number;
  31467. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31468. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31469. dispose(): void;
  31470. }
  31471. /**
  31472. * Interface used to define a physics engine
  31473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31474. */
  31475. export interface IPhysicsEngine {
  31476. /**
  31477. * Gets the gravity vector used by the simulation
  31478. */
  31479. gravity: Vector3;
  31480. /**
  31481. * Sets the gravity vector used by the simulation
  31482. * @param gravity defines the gravity vector to use
  31483. */
  31484. setGravity(gravity: Vector3): void;
  31485. /**
  31486. * Set the time step of the physics engine.
  31487. * Default is 1/60.
  31488. * To slow it down, enter 1/600 for example.
  31489. * To speed it up, 1/30
  31490. * @param newTimeStep the new timestep to apply to this world.
  31491. */
  31492. setTimeStep(newTimeStep: number): void;
  31493. /**
  31494. * Get the time step of the physics engine.
  31495. * @returns the current time step
  31496. */
  31497. getTimeStep(): number;
  31498. /**
  31499. * Set the sub time step of the physics engine.
  31500. * Default is 0 meaning there is no sub steps
  31501. * To increase physics resolution precision, set a small value (like 1 ms)
  31502. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31503. */
  31504. setSubTimeStep(subTimeStep: number): void;
  31505. /**
  31506. * Get the sub time step of the physics engine.
  31507. * @returns the current sub time step
  31508. */
  31509. getSubTimeStep(): number;
  31510. /**
  31511. * Release all resources
  31512. */
  31513. dispose(): void;
  31514. /**
  31515. * Gets the name of the current physics plugin
  31516. * @returns the name of the plugin
  31517. */
  31518. getPhysicsPluginName(): string;
  31519. /**
  31520. * Adding a new impostor for the impostor tracking.
  31521. * This will be done by the impostor itself.
  31522. * @param impostor the impostor to add
  31523. */
  31524. addImpostor(impostor: PhysicsImpostor): void;
  31525. /**
  31526. * Remove an impostor from the engine.
  31527. * This impostor and its mesh will not longer be updated by the physics engine.
  31528. * @param impostor the impostor to remove
  31529. */
  31530. removeImpostor(impostor: PhysicsImpostor): void;
  31531. /**
  31532. * Add a joint to the physics engine
  31533. * @param mainImpostor defines the main impostor to which the joint is added.
  31534. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31535. * @param joint defines the joint that will connect both impostors.
  31536. */
  31537. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31538. /**
  31539. * Removes a joint from the simulation
  31540. * @param mainImpostor defines the impostor used with the joint
  31541. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31542. * @param joint defines the joint to remove
  31543. */
  31544. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31545. /**
  31546. * Gets the current plugin used to run the simulation
  31547. * @returns current plugin
  31548. */
  31549. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31550. /**
  31551. * Gets the list of physic impostors
  31552. * @returns an array of PhysicsImpostor
  31553. */
  31554. getImpostors(): Array<PhysicsImpostor>;
  31555. /**
  31556. * Gets the impostor for a physics enabled object
  31557. * @param object defines the object impersonated by the impostor
  31558. * @returns the PhysicsImpostor or null if not found
  31559. */
  31560. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31561. /**
  31562. * Gets the impostor for a physics body object
  31563. * @param body defines physics body used by the impostor
  31564. * @returns the PhysicsImpostor or null if not found
  31565. */
  31566. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31567. /**
  31568. * Does a raycast in the physics world
  31569. * @param from when should the ray start?
  31570. * @param to when should the ray end?
  31571. * @returns PhysicsRaycastResult
  31572. */
  31573. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31574. /**
  31575. * Called by the scene. No need to call it.
  31576. * @param delta defines the timespam between frames
  31577. */
  31578. _step(delta: number): void;
  31579. }
  31580. }
  31581. declare module BABYLON {
  31582. /**
  31583. * The interface for the physics imposter parameters
  31584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31585. */
  31586. export interface PhysicsImpostorParameters {
  31587. /**
  31588. * The mass of the physics imposter
  31589. */
  31590. mass: number;
  31591. /**
  31592. * The friction of the physics imposter
  31593. */
  31594. friction?: number;
  31595. /**
  31596. * The coefficient of restitution of the physics imposter
  31597. */
  31598. restitution?: number;
  31599. /**
  31600. * The native options of the physics imposter
  31601. */
  31602. nativeOptions?: any;
  31603. /**
  31604. * Specifies if the parent should be ignored
  31605. */
  31606. ignoreParent?: boolean;
  31607. /**
  31608. * Specifies if bi-directional transformations should be disabled
  31609. */
  31610. disableBidirectionalTransformation?: boolean;
  31611. /**
  31612. * The pressure inside the physics imposter, soft object only
  31613. */
  31614. pressure?: number;
  31615. /**
  31616. * The stiffness the physics imposter, soft object only
  31617. */
  31618. stiffness?: number;
  31619. /**
  31620. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31621. */
  31622. velocityIterations?: number;
  31623. /**
  31624. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31625. */
  31626. positionIterations?: number;
  31627. /**
  31628. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31629. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31630. * Add to fix multiple points
  31631. */
  31632. fixedPoints?: number;
  31633. /**
  31634. * The collision margin around a soft object
  31635. */
  31636. margin?: number;
  31637. /**
  31638. * The collision margin around a soft object
  31639. */
  31640. damping?: number;
  31641. /**
  31642. * The path for a rope based on an extrusion
  31643. */
  31644. path?: any;
  31645. /**
  31646. * The shape of an extrusion used for a rope based on an extrusion
  31647. */
  31648. shape?: any;
  31649. }
  31650. /**
  31651. * Interface for a physics-enabled object
  31652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31653. */
  31654. export interface IPhysicsEnabledObject {
  31655. /**
  31656. * The position of the physics-enabled object
  31657. */
  31658. position: Vector3;
  31659. /**
  31660. * The rotation of the physics-enabled object
  31661. */
  31662. rotationQuaternion: Nullable<Quaternion>;
  31663. /**
  31664. * The scale of the physics-enabled object
  31665. */
  31666. scaling: Vector3;
  31667. /**
  31668. * The rotation of the physics-enabled object
  31669. */
  31670. rotation?: Vector3;
  31671. /**
  31672. * The parent of the physics-enabled object
  31673. */
  31674. parent?: any;
  31675. /**
  31676. * The bounding info of the physics-enabled object
  31677. * @returns The bounding info of the physics-enabled object
  31678. */
  31679. getBoundingInfo(): BoundingInfo;
  31680. /**
  31681. * Computes the world matrix
  31682. * @param force Specifies if the world matrix should be computed by force
  31683. * @returns A world matrix
  31684. */
  31685. computeWorldMatrix(force: boolean): Matrix;
  31686. /**
  31687. * Gets the world matrix
  31688. * @returns A world matrix
  31689. */
  31690. getWorldMatrix?(): Matrix;
  31691. /**
  31692. * Gets the child meshes
  31693. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31694. * @returns An array of abstract meshes
  31695. */
  31696. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31697. /**
  31698. * Gets the vertex data
  31699. * @param kind The type of vertex data
  31700. * @returns A nullable array of numbers, or a float32 array
  31701. */
  31702. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31703. /**
  31704. * Gets the indices from the mesh
  31705. * @returns A nullable array of index arrays
  31706. */
  31707. getIndices?(): Nullable<IndicesArray>;
  31708. /**
  31709. * Gets the scene from the mesh
  31710. * @returns the indices array or null
  31711. */
  31712. getScene?(): Scene;
  31713. /**
  31714. * Gets the absolute position from the mesh
  31715. * @returns the absolute position
  31716. */
  31717. getAbsolutePosition(): Vector3;
  31718. /**
  31719. * Gets the absolute pivot point from the mesh
  31720. * @returns the absolute pivot point
  31721. */
  31722. getAbsolutePivotPoint(): Vector3;
  31723. /**
  31724. * Rotates the mesh
  31725. * @param axis The axis of rotation
  31726. * @param amount The amount of rotation
  31727. * @param space The space of the rotation
  31728. * @returns The rotation transform node
  31729. */
  31730. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31731. /**
  31732. * Translates the mesh
  31733. * @param axis The axis of translation
  31734. * @param distance The distance of translation
  31735. * @param space The space of the translation
  31736. * @returns The transform node
  31737. */
  31738. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31739. /**
  31740. * Sets the absolute position of the mesh
  31741. * @param absolutePosition The absolute position of the mesh
  31742. * @returns The transform node
  31743. */
  31744. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31745. /**
  31746. * Gets the class name of the mesh
  31747. * @returns The class name
  31748. */
  31749. getClassName(): string;
  31750. }
  31751. /**
  31752. * Represents a physics imposter
  31753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31754. */
  31755. export class PhysicsImpostor {
  31756. /**
  31757. * The physics-enabled object used as the physics imposter
  31758. */
  31759. object: IPhysicsEnabledObject;
  31760. /**
  31761. * The type of the physics imposter
  31762. */
  31763. type: number;
  31764. private _options;
  31765. private _scene?;
  31766. /**
  31767. * The default object size of the imposter
  31768. */
  31769. static DEFAULT_OBJECT_SIZE: Vector3;
  31770. /**
  31771. * The identity quaternion of the imposter
  31772. */
  31773. static IDENTITY_QUATERNION: Quaternion;
  31774. /** @hidden */
  31775. _pluginData: any;
  31776. private _physicsEngine;
  31777. private _physicsBody;
  31778. private _bodyUpdateRequired;
  31779. private _onBeforePhysicsStepCallbacks;
  31780. private _onAfterPhysicsStepCallbacks;
  31781. /** @hidden */
  31782. _onPhysicsCollideCallbacks: Array<{
  31783. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31784. otherImpostors: Array<PhysicsImpostor>;
  31785. }>;
  31786. private _deltaPosition;
  31787. private _deltaRotation;
  31788. private _deltaRotationConjugated;
  31789. /** @hidden */
  31790. _isFromLine: boolean;
  31791. private _parent;
  31792. private _isDisposed;
  31793. private static _tmpVecs;
  31794. private static _tmpQuat;
  31795. /**
  31796. * Specifies if the physics imposter is disposed
  31797. */
  31798. get isDisposed(): boolean;
  31799. /**
  31800. * Gets the mass of the physics imposter
  31801. */
  31802. get mass(): number;
  31803. set mass(value: number);
  31804. /**
  31805. * Gets the coefficient of friction
  31806. */
  31807. get friction(): number;
  31808. /**
  31809. * Sets the coefficient of friction
  31810. */
  31811. set friction(value: number);
  31812. /**
  31813. * Gets the coefficient of restitution
  31814. */
  31815. get restitution(): number;
  31816. /**
  31817. * Sets the coefficient of restitution
  31818. */
  31819. set restitution(value: number);
  31820. /**
  31821. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31822. */
  31823. get pressure(): number;
  31824. /**
  31825. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31826. */
  31827. set pressure(value: number);
  31828. /**
  31829. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31830. */
  31831. get stiffness(): number;
  31832. /**
  31833. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31834. */
  31835. set stiffness(value: number);
  31836. /**
  31837. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31838. */
  31839. get velocityIterations(): number;
  31840. /**
  31841. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31842. */
  31843. set velocityIterations(value: number);
  31844. /**
  31845. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31846. */
  31847. get positionIterations(): number;
  31848. /**
  31849. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31850. */
  31851. set positionIterations(value: number);
  31852. /**
  31853. * The unique id of the physics imposter
  31854. * set by the physics engine when adding this impostor to the array
  31855. */
  31856. uniqueId: number;
  31857. /**
  31858. * @hidden
  31859. */
  31860. soft: boolean;
  31861. /**
  31862. * @hidden
  31863. */
  31864. segments: number;
  31865. private _joints;
  31866. /**
  31867. * Initializes the physics imposter
  31868. * @param object The physics-enabled object used as the physics imposter
  31869. * @param type The type of the physics imposter
  31870. * @param _options The options for the physics imposter
  31871. * @param _scene The Babylon scene
  31872. */
  31873. constructor(
  31874. /**
  31875. * The physics-enabled object used as the physics imposter
  31876. */
  31877. object: IPhysicsEnabledObject,
  31878. /**
  31879. * The type of the physics imposter
  31880. */
  31881. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31882. /**
  31883. * This function will completly initialize this impostor.
  31884. * It will create a new body - but only if this mesh has no parent.
  31885. * If it has, this impostor will not be used other than to define the impostor
  31886. * of the child mesh.
  31887. * @hidden
  31888. */
  31889. _init(): void;
  31890. private _getPhysicsParent;
  31891. /**
  31892. * Should a new body be generated.
  31893. * @returns boolean specifying if body initialization is required
  31894. */
  31895. isBodyInitRequired(): boolean;
  31896. /**
  31897. * Sets the updated scaling
  31898. * @param updated Specifies if the scaling is updated
  31899. */
  31900. setScalingUpdated(): void;
  31901. /**
  31902. * Force a regeneration of this or the parent's impostor's body.
  31903. * Use under cautious - This will remove all joints already implemented.
  31904. */
  31905. forceUpdate(): void;
  31906. /**
  31907. * Gets the body that holds this impostor. Either its own, or its parent.
  31908. */
  31909. get physicsBody(): any;
  31910. /**
  31911. * Get the parent of the physics imposter
  31912. * @returns Physics imposter or null
  31913. */
  31914. get parent(): Nullable<PhysicsImpostor>;
  31915. /**
  31916. * Sets the parent of the physics imposter
  31917. */
  31918. set parent(value: Nullable<PhysicsImpostor>);
  31919. /**
  31920. * Set the physics body. Used mainly by the physics engine/plugin
  31921. */
  31922. set physicsBody(physicsBody: any);
  31923. /**
  31924. * Resets the update flags
  31925. */
  31926. resetUpdateFlags(): void;
  31927. /**
  31928. * Gets the object extend size
  31929. * @returns the object extend size
  31930. */
  31931. getObjectExtendSize(): Vector3;
  31932. /**
  31933. * Gets the object center
  31934. * @returns The object center
  31935. */
  31936. getObjectCenter(): Vector3;
  31937. /**
  31938. * Get a specific parameter from the options parameters
  31939. * @param paramName The object parameter name
  31940. * @returns The object parameter
  31941. */
  31942. getParam(paramName: string): any;
  31943. /**
  31944. * Sets a specific parameter in the options given to the physics plugin
  31945. * @param paramName The parameter name
  31946. * @param value The value of the parameter
  31947. */
  31948. setParam(paramName: string, value: number): void;
  31949. /**
  31950. * Specifically change the body's mass option. Won't recreate the physics body object
  31951. * @param mass The mass of the physics imposter
  31952. */
  31953. setMass(mass: number): void;
  31954. /**
  31955. * Gets the linear velocity
  31956. * @returns linear velocity or null
  31957. */
  31958. getLinearVelocity(): Nullable<Vector3>;
  31959. /**
  31960. * Sets the linear velocity
  31961. * @param velocity linear velocity or null
  31962. */
  31963. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31964. /**
  31965. * Gets the angular velocity
  31966. * @returns angular velocity or null
  31967. */
  31968. getAngularVelocity(): Nullable<Vector3>;
  31969. /**
  31970. * Sets the angular velocity
  31971. * @param velocity The velocity or null
  31972. */
  31973. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31974. /**
  31975. * Execute a function with the physics plugin native code
  31976. * Provide a function the will have two variables - the world object and the physics body object
  31977. * @param func The function to execute with the physics plugin native code
  31978. */
  31979. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31980. /**
  31981. * Register a function that will be executed before the physics world is stepping forward
  31982. * @param func The function to execute before the physics world is stepped forward
  31983. */
  31984. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31985. /**
  31986. * Unregister a function that will be executed before the physics world is stepping forward
  31987. * @param func The function to execute before the physics world is stepped forward
  31988. */
  31989. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31990. /**
  31991. * Register a function that will be executed after the physics step
  31992. * @param func The function to execute after physics step
  31993. */
  31994. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31995. /**
  31996. * Unregisters a function that will be executed after the physics step
  31997. * @param func The function to execute after physics step
  31998. */
  31999. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32000. /**
  32001. * register a function that will be executed when this impostor collides against a different body
  32002. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32003. * @param func Callback that is executed on collision
  32004. */
  32005. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32006. /**
  32007. * Unregisters the physics imposter on contact
  32008. * @param collideAgainst The physics object to collide against
  32009. * @param func Callback to execute on collision
  32010. */
  32011. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32012. private _tmpQuat;
  32013. private _tmpQuat2;
  32014. /**
  32015. * Get the parent rotation
  32016. * @returns The parent rotation
  32017. */
  32018. getParentsRotation(): Quaternion;
  32019. /**
  32020. * this function is executed by the physics engine.
  32021. */
  32022. beforeStep: () => void;
  32023. /**
  32024. * this function is executed by the physics engine
  32025. */
  32026. afterStep: () => void;
  32027. /**
  32028. * Legacy collision detection event support
  32029. */
  32030. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32031. /**
  32032. * event and body object due to cannon's event-based architecture.
  32033. */
  32034. onCollide: (e: {
  32035. body: any;
  32036. point: Nullable<Vector3>;
  32037. }) => void;
  32038. /**
  32039. * Apply a force
  32040. * @param force The force to apply
  32041. * @param contactPoint The contact point for the force
  32042. * @returns The physics imposter
  32043. */
  32044. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32045. /**
  32046. * Apply an impulse
  32047. * @param force The impulse force
  32048. * @param contactPoint The contact point for the impulse force
  32049. * @returns The physics imposter
  32050. */
  32051. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32052. /**
  32053. * A help function to create a joint
  32054. * @param otherImpostor A physics imposter used to create a joint
  32055. * @param jointType The type of joint
  32056. * @param jointData The data for the joint
  32057. * @returns The physics imposter
  32058. */
  32059. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32060. /**
  32061. * Add a joint to this impostor with a different impostor
  32062. * @param otherImpostor A physics imposter used to add a joint
  32063. * @param joint The joint to add
  32064. * @returns The physics imposter
  32065. */
  32066. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32067. /**
  32068. * Add an anchor to a cloth impostor
  32069. * @param otherImpostor rigid impostor to anchor to
  32070. * @param width ratio across width from 0 to 1
  32071. * @param height ratio up height from 0 to 1
  32072. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32073. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32074. * @returns impostor the soft imposter
  32075. */
  32076. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32077. /**
  32078. * Add a hook to a rope impostor
  32079. * @param otherImpostor rigid impostor to anchor to
  32080. * @param length ratio across rope from 0 to 1
  32081. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32082. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32083. * @returns impostor the rope imposter
  32084. */
  32085. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32086. /**
  32087. * Will keep this body still, in a sleep mode.
  32088. * @returns the physics imposter
  32089. */
  32090. sleep(): PhysicsImpostor;
  32091. /**
  32092. * Wake the body up.
  32093. * @returns The physics imposter
  32094. */
  32095. wakeUp(): PhysicsImpostor;
  32096. /**
  32097. * Clones the physics imposter
  32098. * @param newObject The physics imposter clones to this physics-enabled object
  32099. * @returns A nullable physics imposter
  32100. */
  32101. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32102. /**
  32103. * Disposes the physics imposter
  32104. */
  32105. dispose(): void;
  32106. /**
  32107. * Sets the delta position
  32108. * @param position The delta position amount
  32109. */
  32110. setDeltaPosition(position: Vector3): void;
  32111. /**
  32112. * Sets the delta rotation
  32113. * @param rotation The delta rotation amount
  32114. */
  32115. setDeltaRotation(rotation: Quaternion): void;
  32116. /**
  32117. * Gets the box size of the physics imposter and stores the result in the input parameter
  32118. * @param result Stores the box size
  32119. * @returns The physics imposter
  32120. */
  32121. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32122. /**
  32123. * Gets the radius of the physics imposter
  32124. * @returns Radius of the physics imposter
  32125. */
  32126. getRadius(): number;
  32127. /**
  32128. * Sync a bone with this impostor
  32129. * @param bone The bone to sync to the impostor.
  32130. * @param boneMesh The mesh that the bone is influencing.
  32131. * @param jointPivot The pivot of the joint / bone in local space.
  32132. * @param distToJoint Optional distance from the impostor to the joint.
  32133. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32134. */
  32135. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32136. /**
  32137. * Sync impostor to a bone
  32138. * @param bone The bone that the impostor will be synced to.
  32139. * @param boneMesh The mesh that the bone is influencing.
  32140. * @param jointPivot The pivot of the joint / bone in local space.
  32141. * @param distToJoint Optional distance from the impostor to the joint.
  32142. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32143. * @param boneAxis Optional vector3 axis the bone is aligned with
  32144. */
  32145. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32146. /**
  32147. * No-Imposter type
  32148. */
  32149. static NoImpostor: number;
  32150. /**
  32151. * Sphere-Imposter type
  32152. */
  32153. static SphereImpostor: number;
  32154. /**
  32155. * Box-Imposter type
  32156. */
  32157. static BoxImpostor: number;
  32158. /**
  32159. * Plane-Imposter type
  32160. */
  32161. static PlaneImpostor: number;
  32162. /**
  32163. * Mesh-imposter type
  32164. */
  32165. static MeshImpostor: number;
  32166. /**
  32167. * Capsule-Impostor type (Ammo.js plugin only)
  32168. */
  32169. static CapsuleImpostor: number;
  32170. /**
  32171. * Cylinder-Imposter type
  32172. */
  32173. static CylinderImpostor: number;
  32174. /**
  32175. * Particle-Imposter type
  32176. */
  32177. static ParticleImpostor: number;
  32178. /**
  32179. * Heightmap-Imposter type
  32180. */
  32181. static HeightmapImpostor: number;
  32182. /**
  32183. * ConvexHull-Impostor type (Ammo.js plugin only)
  32184. */
  32185. static ConvexHullImpostor: number;
  32186. /**
  32187. * Custom-Imposter type (Ammo.js plugin only)
  32188. */
  32189. static CustomImpostor: number;
  32190. /**
  32191. * Rope-Imposter type
  32192. */
  32193. static RopeImpostor: number;
  32194. /**
  32195. * Cloth-Imposter type
  32196. */
  32197. static ClothImpostor: number;
  32198. /**
  32199. * Softbody-Imposter type
  32200. */
  32201. static SoftbodyImpostor: number;
  32202. }
  32203. }
  32204. declare module BABYLON {
  32205. /**
  32206. * @hidden
  32207. **/
  32208. export class _CreationDataStorage {
  32209. closePath?: boolean;
  32210. closeArray?: boolean;
  32211. idx: number[];
  32212. dashSize: number;
  32213. gapSize: number;
  32214. path3D: Path3D;
  32215. pathArray: Vector3[][];
  32216. arc: number;
  32217. radius: number;
  32218. cap: number;
  32219. tessellation: number;
  32220. }
  32221. /**
  32222. * @hidden
  32223. **/
  32224. class _InstanceDataStorage {
  32225. visibleInstances: any;
  32226. batchCache: _InstancesBatch;
  32227. instancesBufferSize: number;
  32228. instancesBuffer: Nullable<Buffer>;
  32229. instancesData: Float32Array;
  32230. overridenInstanceCount: number;
  32231. isFrozen: boolean;
  32232. previousBatch: Nullable<_InstancesBatch>;
  32233. hardwareInstancedRendering: boolean;
  32234. sideOrientation: number;
  32235. manualUpdate: boolean;
  32236. previousRenderId: number;
  32237. }
  32238. /**
  32239. * @hidden
  32240. **/
  32241. export class _InstancesBatch {
  32242. mustReturn: boolean;
  32243. visibleInstances: Nullable<InstancedMesh[]>[];
  32244. renderSelf: boolean[];
  32245. hardwareInstancedRendering: boolean[];
  32246. }
  32247. /**
  32248. * @hidden
  32249. **/
  32250. class _ThinInstanceDataStorage {
  32251. instancesCount: number;
  32252. matrixBuffer: Nullable<Buffer>;
  32253. matrixBufferSize: number;
  32254. matrixData: Nullable<Float32Array>;
  32255. boundingVectors: Array<Vector3>;
  32256. worldMatrices: Nullable<Matrix[]>;
  32257. }
  32258. /**
  32259. * Class used to represent renderable models
  32260. */
  32261. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32262. /**
  32263. * Mesh side orientation : usually the external or front surface
  32264. */
  32265. static readonly FRONTSIDE: number;
  32266. /**
  32267. * Mesh side orientation : usually the internal or back surface
  32268. */
  32269. static readonly BACKSIDE: number;
  32270. /**
  32271. * Mesh side orientation : both internal and external or front and back surfaces
  32272. */
  32273. static readonly DOUBLESIDE: number;
  32274. /**
  32275. * Mesh side orientation : by default, `FRONTSIDE`
  32276. */
  32277. static readonly DEFAULTSIDE: number;
  32278. /**
  32279. * Mesh cap setting : no cap
  32280. */
  32281. static readonly NO_CAP: number;
  32282. /**
  32283. * Mesh cap setting : one cap at the beginning of the mesh
  32284. */
  32285. static readonly CAP_START: number;
  32286. /**
  32287. * Mesh cap setting : one cap at the end of the mesh
  32288. */
  32289. static readonly CAP_END: number;
  32290. /**
  32291. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32292. */
  32293. static readonly CAP_ALL: number;
  32294. /**
  32295. * Mesh pattern setting : no flip or rotate
  32296. */
  32297. static readonly NO_FLIP: number;
  32298. /**
  32299. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32300. */
  32301. static readonly FLIP_TILE: number;
  32302. /**
  32303. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32304. */
  32305. static readonly ROTATE_TILE: number;
  32306. /**
  32307. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32308. */
  32309. static readonly FLIP_ROW: number;
  32310. /**
  32311. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32312. */
  32313. static readonly ROTATE_ROW: number;
  32314. /**
  32315. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32316. */
  32317. static readonly FLIP_N_ROTATE_TILE: number;
  32318. /**
  32319. * Mesh pattern setting : rotate pattern and rotate
  32320. */
  32321. static readonly FLIP_N_ROTATE_ROW: number;
  32322. /**
  32323. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32324. */
  32325. static readonly CENTER: number;
  32326. /**
  32327. * Mesh tile positioning : part tiles on left
  32328. */
  32329. static readonly LEFT: number;
  32330. /**
  32331. * Mesh tile positioning : part tiles on right
  32332. */
  32333. static readonly RIGHT: number;
  32334. /**
  32335. * Mesh tile positioning : part tiles on top
  32336. */
  32337. static readonly TOP: number;
  32338. /**
  32339. * Mesh tile positioning : part tiles on bottom
  32340. */
  32341. static readonly BOTTOM: number;
  32342. /**
  32343. * Gets the default side orientation.
  32344. * @param orientation the orientation to value to attempt to get
  32345. * @returns the default orientation
  32346. * @hidden
  32347. */
  32348. static _GetDefaultSideOrientation(orientation?: number): number;
  32349. private _internalMeshDataInfo;
  32350. get computeBonesUsingShaders(): boolean;
  32351. set computeBonesUsingShaders(value: boolean);
  32352. /**
  32353. * An event triggered before rendering the mesh
  32354. */
  32355. get onBeforeRenderObservable(): Observable<Mesh>;
  32356. /**
  32357. * An event triggered before binding the mesh
  32358. */
  32359. get onBeforeBindObservable(): Observable<Mesh>;
  32360. /**
  32361. * An event triggered after rendering the mesh
  32362. */
  32363. get onAfterRenderObservable(): Observable<Mesh>;
  32364. /**
  32365. * An event triggered before drawing the mesh
  32366. */
  32367. get onBeforeDrawObservable(): Observable<Mesh>;
  32368. private _onBeforeDrawObserver;
  32369. /**
  32370. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32371. */
  32372. set onBeforeDraw(callback: () => void);
  32373. get hasInstances(): boolean;
  32374. get hasThinInstances(): boolean;
  32375. /**
  32376. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32377. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32378. */
  32379. delayLoadState: number;
  32380. /**
  32381. * Gets the list of instances created from this mesh
  32382. * it is not supposed to be modified manually.
  32383. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32384. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32385. */
  32386. instances: InstancedMesh[];
  32387. /**
  32388. * Gets the file containing delay loading data for this mesh
  32389. */
  32390. delayLoadingFile: string;
  32391. /** @hidden */
  32392. _binaryInfo: any;
  32393. /**
  32394. * User defined function used to change how LOD level selection is done
  32395. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32396. */
  32397. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32398. /**
  32399. * Gets or sets the morph target manager
  32400. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32401. */
  32402. get morphTargetManager(): Nullable<MorphTargetManager>;
  32403. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32404. /** @hidden */
  32405. _creationDataStorage: Nullable<_CreationDataStorage>;
  32406. /** @hidden */
  32407. _geometry: Nullable<Geometry>;
  32408. /** @hidden */
  32409. _delayInfo: Array<string>;
  32410. /** @hidden */
  32411. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32412. /** @hidden */
  32413. _instanceDataStorage: _InstanceDataStorage;
  32414. /** @hidden */
  32415. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32416. private _effectiveMaterial;
  32417. /** @hidden */
  32418. _shouldGenerateFlatShading: boolean;
  32419. /** @hidden */
  32420. _originalBuilderSideOrientation: number;
  32421. /**
  32422. * Use this property to change the original side orientation defined at construction time
  32423. */
  32424. overrideMaterialSideOrientation: Nullable<number>;
  32425. /**
  32426. * Gets the source mesh (the one used to clone this one from)
  32427. */
  32428. get source(): Nullable<Mesh>;
  32429. /**
  32430. * Gets the list of clones of this mesh
  32431. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32432. * Note that useClonedMeshMap=true is the default setting
  32433. */
  32434. get cloneMeshMap(): Nullable<{
  32435. [id: string]: Mesh | undefined;
  32436. }>;
  32437. /**
  32438. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32439. */
  32440. get isUnIndexed(): boolean;
  32441. set isUnIndexed(value: boolean);
  32442. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32443. get worldMatrixInstancedBuffer(): Float32Array;
  32444. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32445. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32446. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32447. /**
  32448. * @constructor
  32449. * @param name The value used by scene.getMeshByName() to do a lookup.
  32450. * @param scene The scene to add this mesh to.
  32451. * @param parent The parent of this mesh, if it has one
  32452. * @param source An optional Mesh from which geometry is shared, cloned.
  32453. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32454. * When false, achieved by calling a clone(), also passing False.
  32455. * This will make creation of children, recursive.
  32456. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32457. */
  32458. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32459. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32460. doNotInstantiate: boolean;
  32461. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32462. /**
  32463. * Gets the class name
  32464. * @returns the string "Mesh".
  32465. */
  32466. getClassName(): string;
  32467. /** @hidden */
  32468. get _isMesh(): boolean;
  32469. /**
  32470. * Returns a description of this mesh
  32471. * @param fullDetails define if full details about this mesh must be used
  32472. * @returns a descriptive string representing this mesh
  32473. */
  32474. toString(fullDetails?: boolean): string;
  32475. /** @hidden */
  32476. _unBindEffect(): void;
  32477. /**
  32478. * Gets a boolean indicating if this mesh has LOD
  32479. */
  32480. get hasLODLevels(): boolean;
  32481. /**
  32482. * Gets the list of MeshLODLevel associated with the current mesh
  32483. * @returns an array of MeshLODLevel
  32484. */
  32485. getLODLevels(): MeshLODLevel[];
  32486. private _sortLODLevels;
  32487. /**
  32488. * Add a mesh as LOD level triggered at the given distance.
  32489. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32490. * @param distance The distance from the center of the object to show this level
  32491. * @param mesh The mesh to be added as LOD level (can be null)
  32492. * @return This mesh (for chaining)
  32493. */
  32494. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32495. /**
  32496. * Returns the LOD level mesh at the passed distance or null if not found.
  32497. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32498. * @param distance The distance from the center of the object to show this level
  32499. * @returns a Mesh or `null`
  32500. */
  32501. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32502. /**
  32503. * Remove a mesh from the LOD array
  32504. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32505. * @param mesh defines the mesh to be removed
  32506. * @return This mesh (for chaining)
  32507. */
  32508. removeLODLevel(mesh: Mesh): Mesh;
  32509. /**
  32510. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32511. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32512. * @param camera defines the camera to use to compute distance
  32513. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32514. * @return This mesh (for chaining)
  32515. */
  32516. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32517. /**
  32518. * Gets the mesh internal Geometry object
  32519. */
  32520. get geometry(): Nullable<Geometry>;
  32521. /**
  32522. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32523. * @returns the total number of vertices
  32524. */
  32525. getTotalVertices(): number;
  32526. /**
  32527. * Returns the content of an associated vertex buffer
  32528. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32529. * - VertexBuffer.PositionKind
  32530. * - VertexBuffer.UVKind
  32531. * - VertexBuffer.UV2Kind
  32532. * - VertexBuffer.UV3Kind
  32533. * - VertexBuffer.UV4Kind
  32534. * - VertexBuffer.UV5Kind
  32535. * - VertexBuffer.UV6Kind
  32536. * - VertexBuffer.ColorKind
  32537. * - VertexBuffer.MatricesIndicesKind
  32538. * - VertexBuffer.MatricesIndicesExtraKind
  32539. * - VertexBuffer.MatricesWeightsKind
  32540. * - VertexBuffer.MatricesWeightsExtraKind
  32541. * @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
  32542. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32543. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32544. */
  32545. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32546. /**
  32547. * Returns the mesh VertexBuffer object from the requested `kind`
  32548. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32549. * - VertexBuffer.PositionKind
  32550. * - VertexBuffer.NormalKind
  32551. * - VertexBuffer.UVKind
  32552. * - VertexBuffer.UV2Kind
  32553. * - VertexBuffer.UV3Kind
  32554. * - VertexBuffer.UV4Kind
  32555. * - VertexBuffer.UV5Kind
  32556. * - VertexBuffer.UV6Kind
  32557. * - VertexBuffer.ColorKind
  32558. * - VertexBuffer.MatricesIndicesKind
  32559. * - VertexBuffer.MatricesIndicesExtraKind
  32560. * - VertexBuffer.MatricesWeightsKind
  32561. * - VertexBuffer.MatricesWeightsExtraKind
  32562. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32563. */
  32564. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32565. /**
  32566. * Tests if a specific vertex buffer is associated with this mesh
  32567. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32568. * - VertexBuffer.PositionKind
  32569. * - VertexBuffer.NormalKind
  32570. * - VertexBuffer.UVKind
  32571. * - VertexBuffer.UV2Kind
  32572. * - VertexBuffer.UV3Kind
  32573. * - VertexBuffer.UV4Kind
  32574. * - VertexBuffer.UV5Kind
  32575. * - VertexBuffer.UV6Kind
  32576. * - VertexBuffer.ColorKind
  32577. * - VertexBuffer.MatricesIndicesKind
  32578. * - VertexBuffer.MatricesIndicesExtraKind
  32579. * - VertexBuffer.MatricesWeightsKind
  32580. * - VertexBuffer.MatricesWeightsExtraKind
  32581. * @returns a boolean
  32582. */
  32583. isVerticesDataPresent(kind: string): boolean;
  32584. /**
  32585. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32586. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32587. * - VertexBuffer.PositionKind
  32588. * - VertexBuffer.UVKind
  32589. * - VertexBuffer.UV2Kind
  32590. * - VertexBuffer.UV3Kind
  32591. * - VertexBuffer.UV4Kind
  32592. * - VertexBuffer.UV5Kind
  32593. * - VertexBuffer.UV6Kind
  32594. * - VertexBuffer.ColorKind
  32595. * - VertexBuffer.MatricesIndicesKind
  32596. * - VertexBuffer.MatricesIndicesExtraKind
  32597. * - VertexBuffer.MatricesWeightsKind
  32598. * - VertexBuffer.MatricesWeightsExtraKind
  32599. * @returns a boolean
  32600. */
  32601. isVertexBufferUpdatable(kind: string): boolean;
  32602. /**
  32603. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32604. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32605. * - VertexBuffer.PositionKind
  32606. * - VertexBuffer.NormalKind
  32607. * - VertexBuffer.UVKind
  32608. * - VertexBuffer.UV2Kind
  32609. * - VertexBuffer.UV3Kind
  32610. * - VertexBuffer.UV4Kind
  32611. * - VertexBuffer.UV5Kind
  32612. * - VertexBuffer.UV6Kind
  32613. * - VertexBuffer.ColorKind
  32614. * - VertexBuffer.MatricesIndicesKind
  32615. * - VertexBuffer.MatricesIndicesExtraKind
  32616. * - VertexBuffer.MatricesWeightsKind
  32617. * - VertexBuffer.MatricesWeightsExtraKind
  32618. * @returns an array of strings
  32619. */
  32620. getVerticesDataKinds(): string[];
  32621. /**
  32622. * Returns a positive integer : the total number of indices in this mesh geometry.
  32623. * @returns the numner of indices or zero if the mesh has no geometry.
  32624. */
  32625. getTotalIndices(): number;
  32626. /**
  32627. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32628. * @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.
  32629. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32630. * @returns the indices array or an empty array if the mesh has no geometry
  32631. */
  32632. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32633. get isBlocked(): boolean;
  32634. /**
  32635. * Determine if the current mesh is ready to be rendered
  32636. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32637. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32638. * @returns true if all associated assets are ready (material, textures, shaders)
  32639. */
  32640. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32641. /**
  32642. * 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.
  32643. */
  32644. get areNormalsFrozen(): boolean;
  32645. /**
  32646. * 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.
  32647. * @returns the current mesh
  32648. */
  32649. freezeNormals(): Mesh;
  32650. /**
  32651. * 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
  32652. * @returns the current mesh
  32653. */
  32654. unfreezeNormals(): Mesh;
  32655. /**
  32656. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32657. */
  32658. set overridenInstanceCount(count: number);
  32659. /** @hidden */
  32660. _preActivate(): Mesh;
  32661. /** @hidden */
  32662. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32663. /** @hidden */
  32664. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32665. protected _afterComputeWorldMatrix(): void;
  32666. /** @hidden */
  32667. _postActivate(): void;
  32668. /**
  32669. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32670. * This means the mesh underlying bounding box and sphere are recomputed.
  32671. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32672. * @returns the current mesh
  32673. */
  32674. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32675. /** @hidden */
  32676. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32677. /**
  32678. * This function will subdivide the mesh into multiple submeshes
  32679. * @param count defines the expected number of submeshes
  32680. */
  32681. subdivide(count: number): void;
  32682. /**
  32683. * Copy a FloatArray into a specific associated vertex buffer
  32684. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32685. * - VertexBuffer.PositionKind
  32686. * - VertexBuffer.UVKind
  32687. * - VertexBuffer.UV2Kind
  32688. * - VertexBuffer.UV3Kind
  32689. * - VertexBuffer.UV4Kind
  32690. * - VertexBuffer.UV5Kind
  32691. * - VertexBuffer.UV6Kind
  32692. * - VertexBuffer.ColorKind
  32693. * - VertexBuffer.MatricesIndicesKind
  32694. * - VertexBuffer.MatricesIndicesExtraKind
  32695. * - VertexBuffer.MatricesWeightsKind
  32696. * - VertexBuffer.MatricesWeightsExtraKind
  32697. * @param data defines the data source
  32698. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32699. * @param stride defines the data stride size (can be null)
  32700. * @returns the current mesh
  32701. */
  32702. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32703. /**
  32704. * Delete a vertex buffer associated with this mesh
  32705. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32706. * - VertexBuffer.PositionKind
  32707. * - VertexBuffer.UVKind
  32708. * - VertexBuffer.UV2Kind
  32709. * - VertexBuffer.UV3Kind
  32710. * - VertexBuffer.UV4Kind
  32711. * - VertexBuffer.UV5Kind
  32712. * - VertexBuffer.UV6Kind
  32713. * - VertexBuffer.ColorKind
  32714. * - VertexBuffer.MatricesIndicesKind
  32715. * - VertexBuffer.MatricesIndicesExtraKind
  32716. * - VertexBuffer.MatricesWeightsKind
  32717. * - VertexBuffer.MatricesWeightsExtraKind
  32718. */
  32719. removeVerticesData(kind: string): void;
  32720. /**
  32721. * Flags an associated vertex buffer as updatable
  32722. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32723. * - VertexBuffer.PositionKind
  32724. * - VertexBuffer.UVKind
  32725. * - VertexBuffer.UV2Kind
  32726. * - VertexBuffer.UV3Kind
  32727. * - VertexBuffer.UV4Kind
  32728. * - VertexBuffer.UV5Kind
  32729. * - VertexBuffer.UV6Kind
  32730. * - VertexBuffer.ColorKind
  32731. * - VertexBuffer.MatricesIndicesKind
  32732. * - VertexBuffer.MatricesIndicesExtraKind
  32733. * - VertexBuffer.MatricesWeightsKind
  32734. * - VertexBuffer.MatricesWeightsExtraKind
  32735. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32736. */
  32737. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32738. /**
  32739. * Sets the mesh global Vertex Buffer
  32740. * @param buffer defines the buffer to use
  32741. * @returns the current mesh
  32742. */
  32743. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32744. /**
  32745. * Update a specific associated vertex buffer
  32746. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32747. * - VertexBuffer.PositionKind
  32748. * - VertexBuffer.UVKind
  32749. * - VertexBuffer.UV2Kind
  32750. * - VertexBuffer.UV3Kind
  32751. * - VertexBuffer.UV4Kind
  32752. * - VertexBuffer.UV5Kind
  32753. * - VertexBuffer.UV6Kind
  32754. * - VertexBuffer.ColorKind
  32755. * - VertexBuffer.MatricesIndicesKind
  32756. * - VertexBuffer.MatricesIndicesExtraKind
  32757. * - VertexBuffer.MatricesWeightsKind
  32758. * - VertexBuffer.MatricesWeightsExtraKind
  32759. * @param data defines the data source
  32760. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32761. * @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)
  32762. * @returns the current mesh
  32763. */
  32764. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32765. /**
  32766. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32767. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32768. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32769. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32770. * @returns the current mesh
  32771. */
  32772. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32773. /**
  32774. * Creates a un-shared specific occurence of the geometry for the mesh.
  32775. * @returns the current mesh
  32776. */
  32777. makeGeometryUnique(): Mesh;
  32778. /**
  32779. * Set the index buffer of this mesh
  32780. * @param indices defines the source data
  32781. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32782. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32783. * @returns the current mesh
  32784. */
  32785. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32786. /**
  32787. * Update the current index buffer
  32788. * @param indices defines the source data
  32789. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32790. * @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)
  32791. * @returns the current mesh
  32792. */
  32793. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32794. /**
  32795. * Invert the geometry to move from a right handed system to a left handed one.
  32796. * @returns the current mesh
  32797. */
  32798. toLeftHanded(): Mesh;
  32799. /** @hidden */
  32800. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32801. /** @hidden */
  32802. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32803. /**
  32804. * Registers for this mesh a javascript function called just before the rendering process
  32805. * @param func defines the function to call before rendering this mesh
  32806. * @returns the current mesh
  32807. */
  32808. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32809. /**
  32810. * Disposes a previously registered javascript function called before the rendering
  32811. * @param func defines the function to remove
  32812. * @returns the current mesh
  32813. */
  32814. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32815. /**
  32816. * Registers for this mesh a javascript function called just after the rendering is complete
  32817. * @param func defines the function to call after rendering this mesh
  32818. * @returns the current mesh
  32819. */
  32820. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32821. /**
  32822. * Disposes a previously registered javascript function called after the rendering.
  32823. * @param func defines the function to remove
  32824. * @returns the current mesh
  32825. */
  32826. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32827. /** @hidden */
  32828. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32829. /** @hidden */
  32830. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32831. /** @hidden */
  32832. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32833. /** @hidden */
  32834. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32835. /** @hidden */
  32836. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32837. /** @hidden */
  32838. _rebuild(): void;
  32839. /** @hidden */
  32840. _freeze(): void;
  32841. /** @hidden */
  32842. _unFreeze(): void;
  32843. /**
  32844. * 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
  32845. * @param subMesh defines the subMesh to render
  32846. * @param enableAlphaMode defines if alpha mode can be changed
  32847. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  32848. * @returns the current mesh
  32849. */
  32850. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  32851. private _onBeforeDraw;
  32852. /**
  32853. * Renormalize the mesh and patch it up if there are no weights
  32854. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  32855. * However in the case of zero weights then we set just a single influence to 1.
  32856. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  32857. */
  32858. cleanMatrixWeights(): void;
  32859. private normalizeSkinFourWeights;
  32860. private normalizeSkinWeightsAndExtra;
  32861. /**
  32862. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  32863. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  32864. * the user know there was an issue with importing the mesh
  32865. * @returns a validation object with skinned, valid and report string
  32866. */
  32867. validateSkinning(): {
  32868. skinned: boolean;
  32869. valid: boolean;
  32870. report: string;
  32871. };
  32872. /** @hidden */
  32873. _checkDelayState(): Mesh;
  32874. private _queueLoad;
  32875. /**
  32876. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32877. * A mesh is in the frustum if its bounding box intersects the frustum
  32878. * @param frustumPlanes defines the frustum to test
  32879. * @returns true if the mesh is in the frustum planes
  32880. */
  32881. isInFrustum(frustumPlanes: Plane[]): boolean;
  32882. /**
  32883. * Sets the mesh material by the material or multiMaterial `id` property
  32884. * @param id is a string identifying the material or the multiMaterial
  32885. * @returns the current mesh
  32886. */
  32887. setMaterialByID(id: string): Mesh;
  32888. /**
  32889. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  32890. * @returns an array of IAnimatable
  32891. */
  32892. getAnimatables(): IAnimatable[];
  32893. /**
  32894. * Modifies the mesh geometry according to the passed transformation matrix.
  32895. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  32896. * The mesh normals are modified using the same transformation.
  32897. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32898. * @param transform defines the transform matrix to use
  32899. * @see https://doc.babylonjs.com/resources/baking_transformations
  32900. * @returns the current mesh
  32901. */
  32902. bakeTransformIntoVertices(transform: Matrix): Mesh;
  32903. /**
  32904. * Modifies the mesh geometry according to its own current World Matrix.
  32905. * The mesh World Matrix is then reset.
  32906. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  32907. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32908. * @see https://doc.babylonjs.com/resources/baking_transformations
  32909. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  32910. * @returns the current mesh
  32911. */
  32912. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  32913. /** @hidden */
  32914. get _positions(): Nullable<Vector3[]>;
  32915. /** @hidden */
  32916. _resetPointsArrayCache(): Mesh;
  32917. /** @hidden */
  32918. _generatePointsArray(): boolean;
  32919. /**
  32920. * Returns a new Mesh object generated from the current mesh properties.
  32921. * This method must not get confused with createInstance()
  32922. * @param name is a string, the name given to the new mesh
  32923. * @param newParent can be any Node object (default `null`)
  32924. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  32925. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  32926. * @returns a new mesh
  32927. */
  32928. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  32929. /**
  32930. * Releases resources associated with this mesh.
  32931. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32932. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32933. */
  32934. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32935. /** @hidden */
  32936. _disposeInstanceSpecificData(): void;
  32937. /** @hidden */
  32938. _disposeThinInstanceSpecificData(): void;
  32939. /**
  32940. * Modifies the mesh geometry according to a displacement map.
  32941. * 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.
  32942. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32943. * @param url is a string, the URL from the image file is to be downloaded.
  32944. * @param minHeight is the lower limit of the displacement.
  32945. * @param maxHeight is the upper limit of the displacement.
  32946. * @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.
  32947. * @param uvOffset is an optional vector2 used to offset UV.
  32948. * @param uvScale is an optional vector2 used to scale UV.
  32949. * @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.
  32950. * @returns the Mesh.
  32951. */
  32952. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32953. /**
  32954. * Modifies the mesh geometry according to a displacementMap buffer.
  32955. * 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.
  32956. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32957. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  32958. * @param heightMapWidth is the width of the buffer image.
  32959. * @param heightMapHeight is the height of the buffer image.
  32960. * @param minHeight is the lower limit of the displacement.
  32961. * @param maxHeight is the upper limit of the displacement.
  32962. * @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.
  32963. * @param uvOffset is an optional vector2 used to offset UV.
  32964. * @param uvScale is an optional vector2 used to scale UV.
  32965. * @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.
  32966. * @returns the Mesh.
  32967. */
  32968. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32969. /**
  32970. * Modify the mesh to get a flat shading rendering.
  32971. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  32972. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  32973. * @returns current mesh
  32974. */
  32975. convertToFlatShadedMesh(): Mesh;
  32976. /**
  32977. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  32978. * In other words, more vertices, no more indices and a single bigger VBO.
  32979. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  32980. * @returns current mesh
  32981. */
  32982. convertToUnIndexedMesh(): Mesh;
  32983. /**
  32984. * Inverses facet orientations.
  32985. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32986. * @param flipNormals will also inverts the normals
  32987. * @returns current mesh
  32988. */
  32989. flipFaces(flipNormals?: boolean): Mesh;
  32990. /**
  32991. * Increase the number of facets and hence vertices in a mesh
  32992. * Vertex normals are interpolated from existing vertex normals
  32993. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32994. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  32995. */
  32996. increaseVertices(numberPerEdge: number): void;
  32997. /**
  32998. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  32999. * This will undo any application of covertToFlatShadedMesh
  33000. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33001. */
  33002. forceSharedVertices(): void;
  33003. /** @hidden */
  33004. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33005. /** @hidden */
  33006. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33007. /**
  33008. * Creates a new InstancedMesh object from the mesh model.
  33009. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33010. * @param name defines the name of the new instance
  33011. * @returns a new InstancedMesh
  33012. */
  33013. createInstance(name: string): InstancedMesh;
  33014. /**
  33015. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33016. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33017. * @returns the current mesh
  33018. */
  33019. synchronizeInstances(): Mesh;
  33020. /**
  33021. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33022. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33023. * This should be used together with the simplification to avoid disappearing triangles.
  33024. * @param successCallback an optional success callback to be called after the optimization finished.
  33025. * @returns the current mesh
  33026. */
  33027. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33028. /**
  33029. * Serialize current mesh
  33030. * @param serializationObject defines the object which will receive the serialization data
  33031. */
  33032. serialize(serializationObject: any): void;
  33033. /** @hidden */
  33034. _syncGeometryWithMorphTargetManager(): void;
  33035. /** @hidden */
  33036. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33037. /**
  33038. * Returns a new Mesh object parsed from the source provided.
  33039. * @param parsedMesh is the source
  33040. * @param scene defines the hosting scene
  33041. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33042. * @returns a new Mesh
  33043. */
  33044. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33045. /**
  33046. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33047. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33048. * @param name defines the name of the mesh to create
  33049. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33050. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33051. * @param closePath creates a seam between the first and the last points of each path of the path array
  33052. * @param offset is taken in account only if the `pathArray` is containing a single path
  33053. * @param scene defines the hosting scene
  33054. * @param updatable defines if the mesh must be flagged as updatable
  33055. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33056. * @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)
  33057. * @returns a new Mesh
  33058. */
  33059. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33060. /**
  33061. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33062. * @param name defines the name of the mesh to create
  33063. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33064. * @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
  33065. * @param scene defines the hosting scene
  33066. * @param updatable defines if the mesh must be flagged as updatable
  33067. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33068. * @returns a new Mesh
  33069. */
  33070. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33071. /**
  33072. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33073. * @param name defines the name of the mesh to create
  33074. * @param size sets the size (float) of each box side (default 1)
  33075. * @param scene defines the hosting scene
  33076. * @param updatable defines if the mesh must be flagged as updatable
  33077. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33078. * @returns a new Mesh
  33079. */
  33080. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33081. /**
  33082. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33083. * @param name defines the name of the mesh to create
  33084. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33085. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33086. * @param scene defines the hosting scene
  33087. * @param updatable defines if the mesh must be flagged as updatable
  33088. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33089. * @returns a new Mesh
  33090. */
  33091. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33092. /**
  33093. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33094. * @param name defines the name of the mesh to create
  33095. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33096. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33097. * @param scene defines the hosting scene
  33098. * @returns a new Mesh
  33099. */
  33100. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33101. /**
  33102. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33103. * @param name defines the name of the mesh to create
  33104. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33105. * @param diameterTop set the top cap diameter (floats, default 1)
  33106. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33107. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33108. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33109. * @param scene defines the hosting scene
  33110. * @param updatable defines if the mesh must be flagged as updatable
  33111. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33112. * @returns a new Mesh
  33113. */
  33114. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33115. /**
  33116. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33117. * @param name defines the name of the mesh to create
  33118. * @param diameter sets the diameter size (float) of the torus (default 1)
  33119. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33120. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33121. * @param scene defines the hosting scene
  33122. * @param updatable defines if the mesh must be flagged as updatable
  33123. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33124. * @returns a new Mesh
  33125. */
  33126. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33127. /**
  33128. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33129. * @param name defines the name of the mesh to create
  33130. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33131. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33132. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33133. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33134. * @param p the number of windings on X axis (positive integers, default 2)
  33135. * @param q the number of windings on Y axis (positive integers, default 3)
  33136. * @param scene defines the hosting scene
  33137. * @param updatable defines if the mesh must be flagged as updatable
  33138. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33139. * @returns a new Mesh
  33140. */
  33141. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33142. /**
  33143. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33144. * @param name defines the name of the mesh to create
  33145. * @param points is an array successive Vector3
  33146. * @param scene defines the hosting scene
  33147. * @param updatable defines if the mesh must be flagged as updatable
  33148. * @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).
  33149. * @returns a new Mesh
  33150. */
  33151. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33152. /**
  33153. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33154. * @param name defines the name of the mesh to create
  33155. * @param points is an array successive Vector3
  33156. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33157. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33158. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33159. * @param scene defines the hosting scene
  33160. * @param updatable defines if the mesh must be flagged as updatable
  33161. * @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)
  33162. * @returns a new Mesh
  33163. */
  33164. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33165. /**
  33166. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33167. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33168. * 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.
  33169. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33170. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33171. * Remember you can only change the shape positions, not their number when updating a polygon.
  33172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33173. * @param name defines the name of the mesh to create
  33174. * @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
  33175. * @param scene defines the hosting scene
  33176. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33177. * @param updatable defines if the mesh must be flagged as updatable
  33178. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33179. * @param earcutInjection can be used to inject your own earcut reference
  33180. * @returns a new Mesh
  33181. */
  33182. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33183. /**
  33184. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33185. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33186. * @param name defines the name of the mesh to create
  33187. * @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
  33188. * @param depth defines the height of extrusion
  33189. * @param scene defines the hosting scene
  33190. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33191. * @param updatable defines if the mesh must be flagged as updatable
  33192. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33193. * @param earcutInjection can be used to inject your own earcut reference
  33194. * @returns a new Mesh
  33195. */
  33196. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33197. /**
  33198. * Creates an extruded shape mesh.
  33199. * 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
  33200. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33201. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33202. * @param name defines the name of the mesh to create
  33203. * @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
  33204. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33205. * @param scale is the value to scale the shape
  33206. * @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
  33207. * @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
  33208. * @param scene defines the hosting scene
  33209. * @param updatable defines if the mesh must be flagged as updatable
  33210. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33211. * @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)
  33212. * @returns a new Mesh
  33213. */
  33214. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33215. /**
  33216. * Creates an custom extruded shape mesh.
  33217. * The custom extrusion is a parametric shape.
  33218. * It has no predefined shape. Its final shape will depend on the input parameters.
  33219. * Please consider using the same method from the MeshBuilder class instead
  33220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33221. * @param name defines the name of the mesh to create
  33222. * @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
  33223. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33224. * @param scaleFunction is a custom Javascript function called on each path point
  33225. * @param rotationFunction is a custom Javascript function called on each path point
  33226. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33227. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33228. * @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
  33229. * @param scene defines the hosting scene
  33230. * @param updatable defines if the mesh must be flagged as updatable
  33231. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33232. * @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)
  33233. * @returns a new Mesh
  33234. */
  33235. 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;
  33236. /**
  33237. * Creates lathe mesh.
  33238. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33239. * Please consider using the same method from the MeshBuilder class instead
  33240. * @param name defines the name of the mesh to create
  33241. * @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
  33242. * @param radius is the radius value of the lathe
  33243. * @param tessellation is the side number of the lathe.
  33244. * @param scene defines the hosting scene
  33245. * @param updatable defines if the mesh must be flagged as updatable
  33246. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33247. * @returns a new Mesh
  33248. */
  33249. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33250. /**
  33251. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33252. * @param name defines the name of the mesh to create
  33253. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33254. * @param scene defines the hosting scene
  33255. * @param updatable defines if the mesh must be flagged as updatable
  33256. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33257. * @returns a new Mesh
  33258. */
  33259. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33260. /**
  33261. * Creates a ground mesh.
  33262. * Please consider using the same method from the MeshBuilder class instead
  33263. * @param name defines the name of the mesh to create
  33264. * @param width set the width of the ground
  33265. * @param height set the height of the ground
  33266. * @param subdivisions sets the number of subdivisions per side
  33267. * @param scene defines the hosting scene
  33268. * @param updatable defines if the mesh must be flagged as updatable
  33269. * @returns a new Mesh
  33270. */
  33271. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33272. /**
  33273. * Creates a tiled ground mesh.
  33274. * Please consider using the same method from the MeshBuilder class instead
  33275. * @param name defines the name of the mesh to create
  33276. * @param xmin set the ground minimum X coordinate
  33277. * @param zmin set the ground minimum Y coordinate
  33278. * @param xmax set the ground maximum X coordinate
  33279. * @param zmax set the ground maximum Z coordinate
  33280. * @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
  33281. * @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
  33282. * @param scene defines the hosting scene
  33283. * @param updatable defines if the mesh must be flagged as updatable
  33284. * @returns a new Mesh
  33285. */
  33286. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33287. w: number;
  33288. h: number;
  33289. }, precision: {
  33290. w: number;
  33291. h: number;
  33292. }, scene: Scene, updatable?: boolean): Mesh;
  33293. /**
  33294. * Creates a ground mesh from a height map.
  33295. * Please consider using the same method from the MeshBuilder class instead
  33296. * @see https://doc.babylonjs.com/babylon101/height_map
  33297. * @param name defines the name of the mesh to create
  33298. * @param url sets the URL of the height map image resource
  33299. * @param width set the ground width size
  33300. * @param height set the ground height size
  33301. * @param subdivisions sets the number of subdivision per side
  33302. * @param minHeight is the minimum altitude on the ground
  33303. * @param maxHeight is the maximum altitude on the ground
  33304. * @param scene defines the hosting scene
  33305. * @param updatable defines if the mesh must be flagged as updatable
  33306. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33307. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33308. * @returns a new Mesh
  33309. */
  33310. 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;
  33311. /**
  33312. * Creates a tube mesh.
  33313. * The tube is a parametric shape.
  33314. * It has no predefined shape. Its final shape will depend on the input parameters.
  33315. * Please consider using the same method from the MeshBuilder class instead
  33316. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33317. * @param name defines the name of the mesh to create
  33318. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33319. * @param radius sets the tube radius size
  33320. * @param tessellation is the number of sides on the tubular surface
  33321. * @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
  33322. * @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
  33323. * @param scene defines the hosting scene
  33324. * @param updatable defines if the mesh must be flagged as updatable
  33325. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33326. * @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)
  33327. * @returns a new Mesh
  33328. */
  33329. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33330. (i: number, distance: number): number;
  33331. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33332. /**
  33333. * Creates a polyhedron mesh.
  33334. * Please consider using the same method from the MeshBuilder class instead.
  33335. * * 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
  33336. * * The parameter `size` (positive float, default 1) sets the polygon size
  33337. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33338. * * 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`
  33339. * * 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
  33340. * * 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)`)
  33341. * * 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
  33342. * * 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
  33343. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33344. * * 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
  33345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33346. * @param name defines the name of the mesh to create
  33347. * @param options defines the options used to create the mesh
  33348. * @param scene defines the hosting scene
  33349. * @returns a new Mesh
  33350. */
  33351. static CreatePolyhedron(name: string, options: {
  33352. type?: number;
  33353. size?: number;
  33354. sizeX?: number;
  33355. sizeY?: number;
  33356. sizeZ?: number;
  33357. custom?: any;
  33358. faceUV?: Vector4[];
  33359. faceColors?: Color4[];
  33360. updatable?: boolean;
  33361. sideOrientation?: number;
  33362. }, scene: Scene): Mesh;
  33363. /**
  33364. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33365. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33366. * * 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`)
  33367. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33368. * * 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
  33369. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33370. * * 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
  33371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33372. * @param name defines the name of the mesh
  33373. * @param options defines the options used to create the mesh
  33374. * @param scene defines the hosting scene
  33375. * @returns a new Mesh
  33376. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33377. */
  33378. static CreateIcoSphere(name: string, options: {
  33379. radius?: number;
  33380. flat?: boolean;
  33381. subdivisions?: number;
  33382. sideOrientation?: number;
  33383. updatable?: boolean;
  33384. }, scene: Scene): Mesh;
  33385. /**
  33386. * Creates a decal mesh.
  33387. * Please consider using the same method from the MeshBuilder class instead.
  33388. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33389. * @param name defines the name of the mesh
  33390. * @param sourceMesh defines the mesh receiving the decal
  33391. * @param position sets the position of the decal in world coordinates
  33392. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33393. * @param size sets the decal scaling
  33394. * @param angle sets the angle to rotate the decal
  33395. * @returns a new Mesh
  33396. */
  33397. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33398. /** Creates a Capsule Mesh
  33399. * @param name defines the name of the mesh.
  33400. * @param options the constructors options used to shape the mesh.
  33401. * @param scene defines the scene the mesh is scoped to.
  33402. * @returns the capsule mesh
  33403. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33404. */
  33405. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33406. /**
  33407. * Prepare internal position array for software CPU skinning
  33408. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33409. */
  33410. setPositionsForCPUSkinning(): Float32Array;
  33411. /**
  33412. * Prepare internal normal array for software CPU skinning
  33413. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33414. */
  33415. setNormalsForCPUSkinning(): Float32Array;
  33416. /**
  33417. * Updates the vertex buffer by applying transformation from the bones
  33418. * @param skeleton defines the skeleton to apply to current mesh
  33419. * @returns the current mesh
  33420. */
  33421. applySkeleton(skeleton: Skeleton): Mesh;
  33422. /**
  33423. * 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
  33424. * @param meshes defines the list of meshes to scan
  33425. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33426. */
  33427. static MinMax(meshes: AbstractMesh[]): {
  33428. min: Vector3;
  33429. max: Vector3;
  33430. };
  33431. /**
  33432. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33433. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33434. * @returns a vector3
  33435. */
  33436. static Center(meshesOrMinMaxVector: {
  33437. min: Vector3;
  33438. max: Vector3;
  33439. } | AbstractMesh[]): Vector3;
  33440. /**
  33441. * Merge the array of meshes into a single mesh for performance reasons.
  33442. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33443. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33444. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33445. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33446. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33447. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33448. * @returns a new mesh
  33449. */
  33450. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33451. /** @hidden */
  33452. addInstance(instance: InstancedMesh): void;
  33453. /** @hidden */
  33454. removeInstance(instance: InstancedMesh): void;
  33455. }
  33456. }
  33457. declare module BABYLON {
  33458. /**
  33459. * The options Interface for creating a Capsule Mesh
  33460. */
  33461. export interface ICreateCapsuleOptions {
  33462. /** The Orientation of the capsule. Default : Vector3.Up() */
  33463. orientation?: Vector3;
  33464. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  33465. subdivisions: number;
  33466. /** Number of cylindrical segments on the capsule. */
  33467. tessellation: number;
  33468. /** Height or Length of the capsule. */
  33469. height: number;
  33470. /** Radius of the capsule. */
  33471. radius: number;
  33472. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  33473. capSubdivisions: number;
  33474. /** Overwrite for the top radius. */
  33475. radiusTop?: number;
  33476. /** Overwrite for the bottom radius. */
  33477. radiusBottom?: number;
  33478. /** Overwrite for the top capSubdivisions. */
  33479. topCapSubdivisions?: number;
  33480. /** Overwrite for the bottom capSubdivisions. */
  33481. bottomCapSubdivisions?: number;
  33482. }
  33483. /**
  33484. * Class containing static functions to help procedurally build meshes
  33485. */
  33486. export class CapsuleBuilder {
  33487. /**
  33488. * Creates a capsule or a pill mesh
  33489. * @param name defines the name of the mesh
  33490. * @param options The constructors options.
  33491. * @param scene The scene the mesh is scoped to.
  33492. * @returns Capsule Mesh
  33493. */
  33494. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  33495. }
  33496. }
  33497. declare module BABYLON {
  33498. /**
  33499. * Define an interface for all classes that will get and set the data on vertices
  33500. */
  33501. export interface IGetSetVerticesData {
  33502. /**
  33503. * Gets a boolean indicating if specific vertex data is present
  33504. * @param kind defines the vertex data kind to use
  33505. * @returns true is data kind is present
  33506. */
  33507. isVerticesDataPresent(kind: string): boolean;
  33508. /**
  33509. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  33510. * @param kind defines the data kind (Position, normal, etc...)
  33511. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  33512. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33513. * @returns a float array containing vertex data
  33514. */
  33515. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33516. /**
  33517. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33518. * @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.
  33519. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33520. * @returns the indices array or an empty array if the mesh has no geometry
  33521. */
  33522. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33523. /**
  33524. * Set specific vertex data
  33525. * @param kind defines the data kind (Position, normal, etc...)
  33526. * @param data defines the vertex data to use
  33527. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  33528. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  33529. */
  33530. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  33531. /**
  33532. * Update a specific associated vertex buffer
  33533. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33534. * - VertexBuffer.PositionKind
  33535. * - VertexBuffer.UVKind
  33536. * - VertexBuffer.UV2Kind
  33537. * - VertexBuffer.UV3Kind
  33538. * - VertexBuffer.UV4Kind
  33539. * - VertexBuffer.UV5Kind
  33540. * - VertexBuffer.UV6Kind
  33541. * - VertexBuffer.ColorKind
  33542. * - VertexBuffer.MatricesIndicesKind
  33543. * - VertexBuffer.MatricesIndicesExtraKind
  33544. * - VertexBuffer.MatricesWeightsKind
  33545. * - VertexBuffer.MatricesWeightsExtraKind
  33546. * @param data defines the data source
  33547. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33548. * @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)
  33549. */
  33550. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  33551. /**
  33552. * Creates a new index buffer
  33553. * @param indices defines the indices to store in the index buffer
  33554. * @param totalVertices defines the total number of vertices (could be null)
  33555. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  33556. */
  33557. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  33558. }
  33559. /**
  33560. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  33561. */
  33562. export class VertexData {
  33563. /**
  33564. * Mesh side orientation : usually the external or front surface
  33565. */
  33566. static readonly FRONTSIDE: number;
  33567. /**
  33568. * Mesh side orientation : usually the internal or back surface
  33569. */
  33570. static readonly BACKSIDE: number;
  33571. /**
  33572. * Mesh side orientation : both internal and external or front and back surfaces
  33573. */
  33574. static readonly DOUBLESIDE: number;
  33575. /**
  33576. * Mesh side orientation : by default, `FRONTSIDE`
  33577. */
  33578. static readonly DEFAULTSIDE: number;
  33579. /**
  33580. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  33581. */
  33582. positions: Nullable<FloatArray>;
  33583. /**
  33584. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  33585. */
  33586. normals: Nullable<FloatArray>;
  33587. /**
  33588. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  33589. */
  33590. tangents: Nullable<FloatArray>;
  33591. /**
  33592. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33593. */
  33594. uvs: Nullable<FloatArray>;
  33595. /**
  33596. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33597. */
  33598. uvs2: Nullable<FloatArray>;
  33599. /**
  33600. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33601. */
  33602. uvs3: Nullable<FloatArray>;
  33603. /**
  33604. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33605. */
  33606. uvs4: Nullable<FloatArray>;
  33607. /**
  33608. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33609. */
  33610. uvs5: Nullable<FloatArray>;
  33611. /**
  33612. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33613. */
  33614. uvs6: Nullable<FloatArray>;
  33615. /**
  33616. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  33617. */
  33618. colors: Nullable<FloatArray>;
  33619. /**
  33620. * 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).
  33621. */
  33622. matricesIndices: Nullable<FloatArray>;
  33623. /**
  33624. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  33625. */
  33626. matricesWeights: Nullable<FloatArray>;
  33627. /**
  33628. * An array extending the number of possible indices
  33629. */
  33630. matricesIndicesExtra: Nullable<FloatArray>;
  33631. /**
  33632. * An array extending the number of possible weights when the number of indices is extended
  33633. */
  33634. matricesWeightsExtra: Nullable<FloatArray>;
  33635. /**
  33636. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  33637. */
  33638. indices: Nullable<IndicesArray>;
  33639. /**
  33640. * Uses the passed data array to set the set the values for the specified kind of data
  33641. * @param data a linear array of floating numbers
  33642. * @param kind the type of data that is being set, eg positions, colors etc
  33643. */
  33644. set(data: FloatArray, kind: string): void;
  33645. /**
  33646. * Associates the vertexData to the passed Mesh.
  33647. * Sets it as updatable or not (default `false`)
  33648. * @param mesh the mesh the vertexData is applied to
  33649. * @param updatable when used and having the value true allows new data to update the vertexData
  33650. * @returns the VertexData
  33651. */
  33652. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  33653. /**
  33654. * Associates the vertexData to the passed Geometry.
  33655. * Sets it as updatable or not (default `false`)
  33656. * @param geometry the geometry the vertexData is applied to
  33657. * @param updatable when used and having the value true allows new data to update the vertexData
  33658. * @returns VertexData
  33659. */
  33660. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  33661. /**
  33662. * Updates the associated mesh
  33663. * @param mesh the mesh to be updated
  33664. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33665. * @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
  33666. * @returns VertexData
  33667. */
  33668. updateMesh(mesh: Mesh): VertexData;
  33669. /**
  33670. * Updates the associated geometry
  33671. * @param geometry the geometry to be updated
  33672. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33673. * @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
  33674. * @returns VertexData.
  33675. */
  33676. updateGeometry(geometry: Geometry): VertexData;
  33677. private _applyTo;
  33678. private _update;
  33679. /**
  33680. * Transforms each position and each normal of the vertexData according to the passed Matrix
  33681. * @param matrix the transforming matrix
  33682. * @returns the VertexData
  33683. */
  33684. transform(matrix: Matrix): VertexData;
  33685. /**
  33686. * Merges the passed VertexData into the current one
  33687. * @param other the VertexData to be merged into the current one
  33688. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  33689. * @returns the modified VertexData
  33690. */
  33691. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  33692. private _mergeElement;
  33693. private _validate;
  33694. /**
  33695. * Serializes the VertexData
  33696. * @returns a serialized object
  33697. */
  33698. serialize(): any;
  33699. /**
  33700. * Extracts the vertexData from a mesh
  33701. * @param mesh the mesh from which to extract the VertexData
  33702. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  33703. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33704. * @returns the object VertexData associated to the passed mesh
  33705. */
  33706. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33707. /**
  33708. * Extracts the vertexData from the geometry
  33709. * @param geometry the geometry from which to extract the VertexData
  33710. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  33711. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33712. * @returns the object VertexData associated to the passed mesh
  33713. */
  33714. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33715. private static _ExtractFrom;
  33716. /**
  33717. * Creates the VertexData for a Ribbon
  33718. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  33719. * * pathArray array of paths, each of which an array of successive Vector3
  33720. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  33721. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  33722. * * 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
  33723. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33724. * * 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)
  33725. * * 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)
  33726. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  33727. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  33728. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  33729. * @returns the VertexData of the ribbon
  33730. */
  33731. static CreateRibbon(options: {
  33732. pathArray: Vector3[][];
  33733. closeArray?: boolean;
  33734. closePath?: boolean;
  33735. offset?: number;
  33736. sideOrientation?: number;
  33737. frontUVs?: Vector4;
  33738. backUVs?: Vector4;
  33739. invertUV?: boolean;
  33740. uvs?: Vector2[];
  33741. colors?: Color4[];
  33742. }): VertexData;
  33743. /**
  33744. * Creates the VertexData for a box
  33745. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33746. * * size sets the width, height and depth of the box to the value of size, optional default 1
  33747. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  33748. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  33749. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  33750. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33751. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33752. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33753. * * 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)
  33754. * * 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)
  33755. * @returns the VertexData of the box
  33756. */
  33757. static CreateBox(options: {
  33758. size?: number;
  33759. width?: number;
  33760. height?: number;
  33761. depth?: number;
  33762. faceUV?: Vector4[];
  33763. faceColors?: Color4[];
  33764. sideOrientation?: number;
  33765. frontUVs?: Vector4;
  33766. backUVs?: Vector4;
  33767. }): VertexData;
  33768. /**
  33769. * Creates the VertexData for a tiled box
  33770. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33771. * * faceTiles sets the pattern, tile size and number of tiles for a face
  33772. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33773. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33774. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33775. * @returns the VertexData of the box
  33776. */
  33777. static CreateTiledBox(options: {
  33778. pattern?: number;
  33779. width?: number;
  33780. height?: number;
  33781. depth?: number;
  33782. tileSize?: number;
  33783. tileWidth?: number;
  33784. tileHeight?: number;
  33785. alignHorizontal?: number;
  33786. alignVertical?: number;
  33787. faceUV?: Vector4[];
  33788. faceColors?: Color4[];
  33789. sideOrientation?: number;
  33790. }): VertexData;
  33791. /**
  33792. * Creates the VertexData for a tiled plane
  33793. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33794. * * pattern a limited pattern arrangement depending on the number
  33795. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  33796. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  33797. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  33798. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33799. * * 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)
  33800. * * 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)
  33801. * @returns the VertexData of the tiled plane
  33802. */
  33803. static CreateTiledPlane(options: {
  33804. pattern?: number;
  33805. tileSize?: number;
  33806. tileWidth?: number;
  33807. tileHeight?: number;
  33808. size?: number;
  33809. width?: number;
  33810. height?: number;
  33811. alignHorizontal?: number;
  33812. alignVertical?: number;
  33813. sideOrientation?: number;
  33814. frontUVs?: Vector4;
  33815. backUVs?: Vector4;
  33816. }): VertexData;
  33817. /**
  33818. * Creates the VertexData for an ellipsoid, defaults to a sphere
  33819. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33820. * * segments sets the number of horizontal strips optional, default 32
  33821. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  33822. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  33823. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  33824. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  33825. * * 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
  33826. * * 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
  33827. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33828. * * 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)
  33829. * * 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)
  33830. * @returns the VertexData of the ellipsoid
  33831. */
  33832. static CreateSphere(options: {
  33833. segments?: number;
  33834. diameter?: number;
  33835. diameterX?: number;
  33836. diameterY?: number;
  33837. diameterZ?: number;
  33838. arc?: number;
  33839. slice?: number;
  33840. sideOrientation?: number;
  33841. frontUVs?: Vector4;
  33842. backUVs?: Vector4;
  33843. }): VertexData;
  33844. /**
  33845. * Creates the VertexData for a cylinder, cone or prism
  33846. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33847. * * height sets the height (y direction) of the cylinder, optional, default 2
  33848. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  33849. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  33850. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  33851. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33852. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  33853. * * 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
  33854. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33855. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33856. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  33857. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  33858. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33859. * * 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)
  33860. * * 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)
  33861. * @returns the VertexData of the cylinder, cone or prism
  33862. */
  33863. static CreateCylinder(options: {
  33864. height?: number;
  33865. diameterTop?: number;
  33866. diameterBottom?: number;
  33867. diameter?: number;
  33868. tessellation?: number;
  33869. subdivisions?: number;
  33870. arc?: number;
  33871. faceColors?: Color4[];
  33872. faceUV?: Vector4[];
  33873. hasRings?: boolean;
  33874. enclose?: boolean;
  33875. sideOrientation?: number;
  33876. frontUVs?: Vector4;
  33877. backUVs?: Vector4;
  33878. }): VertexData;
  33879. /**
  33880. * Creates the VertexData for a torus
  33881. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33882. * * diameter the diameter of the torus, optional default 1
  33883. * * thickness the diameter of the tube forming the torus, optional default 0.5
  33884. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33885. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33886. * * 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)
  33887. * * 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)
  33888. * @returns the VertexData of the torus
  33889. */
  33890. static CreateTorus(options: {
  33891. diameter?: number;
  33892. thickness?: number;
  33893. tessellation?: number;
  33894. sideOrientation?: number;
  33895. frontUVs?: Vector4;
  33896. backUVs?: Vector4;
  33897. }): VertexData;
  33898. /**
  33899. * Creates the VertexData of the LineSystem
  33900. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  33901. * - lines an array of lines, each line being an array of successive Vector3
  33902. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  33903. * @returns the VertexData of the LineSystem
  33904. */
  33905. static CreateLineSystem(options: {
  33906. lines: Vector3[][];
  33907. colors?: Nullable<Color4[][]>;
  33908. }): VertexData;
  33909. /**
  33910. * Create the VertexData for a DashedLines
  33911. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  33912. * - points an array successive Vector3
  33913. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  33914. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  33915. * - dashNb the intended total number of dashes, optional, default 200
  33916. * @returns the VertexData for the DashedLines
  33917. */
  33918. static CreateDashedLines(options: {
  33919. points: Vector3[];
  33920. dashSize?: number;
  33921. gapSize?: number;
  33922. dashNb?: number;
  33923. }): VertexData;
  33924. /**
  33925. * Creates the VertexData for a Ground
  33926. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33927. * - width the width (x direction) of the ground, optional, default 1
  33928. * - height the height (z direction) of the ground, optional, default 1
  33929. * - subdivisions the number of subdivisions per side, optional, default 1
  33930. * @returns the VertexData of the Ground
  33931. */
  33932. static CreateGround(options: {
  33933. width?: number;
  33934. height?: number;
  33935. subdivisions?: number;
  33936. subdivisionsX?: number;
  33937. subdivisionsY?: number;
  33938. }): VertexData;
  33939. /**
  33940. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  33941. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33942. * * xmin the ground minimum X coordinate, optional, default -1
  33943. * * zmin the ground minimum Z coordinate, optional, default -1
  33944. * * xmax the ground maximum X coordinate, optional, default 1
  33945. * * zmax the ground maximum Z coordinate, optional, default 1
  33946. * * 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}
  33947. * * 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}
  33948. * @returns the VertexData of the TiledGround
  33949. */
  33950. static CreateTiledGround(options: {
  33951. xmin: number;
  33952. zmin: number;
  33953. xmax: number;
  33954. zmax: number;
  33955. subdivisions?: {
  33956. w: number;
  33957. h: number;
  33958. };
  33959. precision?: {
  33960. w: number;
  33961. h: number;
  33962. };
  33963. }): VertexData;
  33964. /**
  33965. * Creates the VertexData of the Ground designed from a heightmap
  33966. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  33967. * * width the width (x direction) of the ground
  33968. * * height the height (z direction) of the ground
  33969. * * subdivisions the number of subdivisions per side
  33970. * * minHeight the minimum altitude on the ground, optional, default 0
  33971. * * maxHeight the maximum altitude on the ground, optional default 1
  33972. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  33973. * * buffer the array holding the image color data
  33974. * * bufferWidth the width of image
  33975. * * bufferHeight the height of image
  33976. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  33977. * @returns the VertexData of the Ground designed from a heightmap
  33978. */
  33979. static CreateGroundFromHeightMap(options: {
  33980. width: number;
  33981. height: number;
  33982. subdivisions: number;
  33983. minHeight: number;
  33984. maxHeight: number;
  33985. colorFilter: Color3;
  33986. buffer: Uint8Array;
  33987. bufferWidth: number;
  33988. bufferHeight: number;
  33989. alphaFilter: number;
  33990. }): VertexData;
  33991. /**
  33992. * Creates the VertexData for a Plane
  33993. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  33994. * * size sets the width and height of the plane to the value of size, optional default 1
  33995. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  33996. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  33997. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33998. * * 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)
  33999. * * 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)
  34000. * @returns the VertexData of the box
  34001. */
  34002. static CreatePlane(options: {
  34003. size?: number;
  34004. width?: number;
  34005. height?: number;
  34006. sideOrientation?: number;
  34007. frontUVs?: Vector4;
  34008. backUVs?: Vector4;
  34009. }): VertexData;
  34010. /**
  34011. * Creates the VertexData of the Disc or regular Polygon
  34012. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  34013. * * radius the radius of the disc, optional default 0.5
  34014. * * tessellation the number of polygon sides, optional, default 64
  34015. * * 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
  34016. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34017. * * 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)
  34018. * * 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)
  34019. * @returns the VertexData of the box
  34020. */
  34021. static CreateDisc(options: {
  34022. radius?: number;
  34023. tessellation?: number;
  34024. arc?: number;
  34025. sideOrientation?: number;
  34026. frontUVs?: Vector4;
  34027. backUVs?: Vector4;
  34028. }): VertexData;
  34029. /**
  34030. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34031. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34032. * @param polygon a mesh built from polygonTriangulation.build()
  34033. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34034. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34035. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34036. * @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)
  34037. * @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)
  34038. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34039. * @returns the VertexData of the Polygon
  34040. */
  34041. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34042. /**
  34043. * Creates the VertexData of the IcoSphere
  34044. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34045. * * radius the radius of the IcoSphere, optional default 1
  34046. * * radiusX allows stretching in the x direction, optional, default radius
  34047. * * radiusY allows stretching in the y direction, optional, default radius
  34048. * * radiusZ allows stretching in the z direction, optional, default radius
  34049. * * flat when true creates a flat shaded mesh, optional, default true
  34050. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34052. * * 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)
  34053. * * 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)
  34054. * @returns the VertexData of the IcoSphere
  34055. */
  34056. static CreateIcoSphere(options: {
  34057. radius?: number;
  34058. radiusX?: number;
  34059. radiusY?: number;
  34060. radiusZ?: number;
  34061. flat?: boolean;
  34062. subdivisions?: number;
  34063. sideOrientation?: number;
  34064. frontUVs?: Vector4;
  34065. backUVs?: Vector4;
  34066. }): VertexData;
  34067. /**
  34068. * Creates the VertexData for a Polyhedron
  34069. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34070. * * type provided types are:
  34071. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34072. * * 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)
  34073. * * size the size of the IcoSphere, optional default 1
  34074. * * sizeX allows stretching in the x direction, optional, default size
  34075. * * sizeY allows stretching in the y direction, optional, default size
  34076. * * sizeZ allows stretching in the z direction, optional, default size
  34077. * * 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
  34078. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34079. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34080. * * flat when true creates a flat shaded mesh, optional, default true
  34081. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34082. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34083. * * 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)
  34084. * * 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)
  34085. * @returns the VertexData of the Polyhedron
  34086. */
  34087. static CreatePolyhedron(options: {
  34088. type?: number;
  34089. size?: number;
  34090. sizeX?: number;
  34091. sizeY?: number;
  34092. sizeZ?: number;
  34093. custom?: any;
  34094. faceUV?: Vector4[];
  34095. faceColors?: Color4[];
  34096. flat?: boolean;
  34097. sideOrientation?: number;
  34098. frontUVs?: Vector4;
  34099. backUVs?: Vector4;
  34100. }): VertexData;
  34101. /**
  34102. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34103. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34104. * @returns the VertexData of the Capsule
  34105. */
  34106. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34107. /**
  34108. * Creates the VertexData for a TorusKnot
  34109. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34110. * * radius the radius of the torus knot, optional, default 2
  34111. * * tube the thickness of the tube, optional, default 0.5
  34112. * * radialSegments the number of sides on each tube segments, optional, default 32
  34113. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34114. * * p the number of windings around the z axis, optional, default 2
  34115. * * q the number of windings around the x axis, optional, default 3
  34116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34117. * * 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)
  34118. * * 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)
  34119. * @returns the VertexData of the Torus Knot
  34120. */
  34121. static CreateTorusKnot(options: {
  34122. radius?: number;
  34123. tube?: number;
  34124. radialSegments?: number;
  34125. tubularSegments?: number;
  34126. p?: number;
  34127. q?: number;
  34128. sideOrientation?: number;
  34129. frontUVs?: Vector4;
  34130. backUVs?: Vector4;
  34131. }): VertexData;
  34132. /**
  34133. * Compute normals for given positions and indices
  34134. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34135. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34136. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34137. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34138. * * facetNormals : optional array of facet normals (vector3)
  34139. * * facetPositions : optional array of facet positions (vector3)
  34140. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34141. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34142. * * bInfo : optional bounding info, required for facetPartitioning computation
  34143. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34144. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34145. * * useRightHandedSystem: optional boolean to for right handed system computation
  34146. * * depthSort : optional boolean to enable the facet depth sort computation
  34147. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34148. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34149. */
  34150. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34151. facetNormals?: any;
  34152. facetPositions?: any;
  34153. facetPartitioning?: any;
  34154. ratio?: number;
  34155. bInfo?: any;
  34156. bbSize?: Vector3;
  34157. subDiv?: any;
  34158. useRightHandedSystem?: boolean;
  34159. depthSort?: boolean;
  34160. distanceTo?: Vector3;
  34161. depthSortedFacets?: any;
  34162. }): void;
  34163. /** @hidden */
  34164. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34165. /**
  34166. * Applies VertexData created from the imported parameters to the geometry
  34167. * @param parsedVertexData the parsed data from an imported file
  34168. * @param geometry the geometry to apply the VertexData to
  34169. */
  34170. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34171. }
  34172. }
  34173. declare module BABYLON {
  34174. /**
  34175. * Class containing static functions to help procedurally build meshes
  34176. */
  34177. export class DiscBuilder {
  34178. /**
  34179. * Creates a plane polygonal mesh. By default, this is a disc
  34180. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34181. * * 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
  34182. * * 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
  34183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34184. * * 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
  34185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34186. * @param name defines the name of the mesh
  34187. * @param options defines the options used to create the mesh
  34188. * @param scene defines the hosting scene
  34189. * @returns the plane polygonal mesh
  34190. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34191. */
  34192. static CreateDisc(name: string, options: {
  34193. radius?: number;
  34194. tessellation?: number;
  34195. arc?: number;
  34196. updatable?: boolean;
  34197. sideOrientation?: number;
  34198. frontUVs?: Vector4;
  34199. backUVs?: Vector4;
  34200. }, scene?: Nullable<Scene>): Mesh;
  34201. }
  34202. }
  34203. declare module BABYLON {
  34204. /**
  34205. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34206. *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.
  34207. * The SPS is also a particle system. It provides some methods to manage the particles.
  34208. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34209. *
  34210. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34211. */
  34212. export class SolidParticleSystem implements IDisposable {
  34213. /**
  34214. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34215. * Example : var p = SPS.particles[i];
  34216. */
  34217. particles: SolidParticle[];
  34218. /**
  34219. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34220. */
  34221. nbParticles: number;
  34222. /**
  34223. * If the particles must ever face the camera (default false). Useful for planar particles.
  34224. */
  34225. billboard: boolean;
  34226. /**
  34227. * Recompute normals when adding a shape
  34228. */
  34229. recomputeNormals: boolean;
  34230. /**
  34231. * This a counter ofr your own usage. It's not set by any SPS functions.
  34232. */
  34233. counter: number;
  34234. /**
  34235. * The SPS name. This name is also given to the underlying mesh.
  34236. */
  34237. name: string;
  34238. /**
  34239. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34240. */
  34241. mesh: Mesh;
  34242. /**
  34243. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34244. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34245. */
  34246. vars: any;
  34247. /**
  34248. * This array is populated when the SPS is set as 'pickable'.
  34249. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34250. * Each element of this array is an object `{idx: int, faceId: int}`.
  34251. * `idx` is the picked particle index in the `SPS.particles` array
  34252. * `faceId` is the picked face index counted within this particle.
  34253. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34254. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34255. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34256. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34257. */
  34258. pickedParticles: {
  34259. idx: number;
  34260. faceId: number;
  34261. }[];
  34262. /**
  34263. * This array is populated when the SPS is set as 'pickable'
  34264. * Each key of this array is a submesh index.
  34265. * Each element of this array is a second array defined like this :
  34266. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34267. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34268. * `idx` is the picked particle index in the `SPS.particles` array
  34269. * `faceId` is the picked face index counted within this particle.
  34270. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34271. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34272. */
  34273. pickedBySubMesh: {
  34274. idx: number;
  34275. faceId: number;
  34276. }[][];
  34277. /**
  34278. * This array is populated when `enableDepthSort` is set to true.
  34279. * Each element of this array is an instance of the class DepthSortedParticle.
  34280. */
  34281. depthSortedParticles: DepthSortedParticle[];
  34282. /**
  34283. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34284. * @hidden
  34285. */
  34286. _bSphereOnly: boolean;
  34287. /**
  34288. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34289. * @hidden
  34290. */
  34291. _bSphereRadiusFactor: number;
  34292. private _scene;
  34293. private _positions;
  34294. private _indices;
  34295. private _normals;
  34296. private _colors;
  34297. private _uvs;
  34298. private _indices32;
  34299. private _positions32;
  34300. private _normals32;
  34301. private _fixedNormal32;
  34302. private _colors32;
  34303. private _uvs32;
  34304. private _index;
  34305. private _updatable;
  34306. private _pickable;
  34307. private _isVisibilityBoxLocked;
  34308. private _alwaysVisible;
  34309. private _depthSort;
  34310. private _expandable;
  34311. private _shapeCounter;
  34312. private _copy;
  34313. private _color;
  34314. private _computeParticleColor;
  34315. private _computeParticleTexture;
  34316. private _computeParticleRotation;
  34317. private _computeParticleVertex;
  34318. private _computeBoundingBox;
  34319. private _depthSortParticles;
  34320. private _camera;
  34321. private _mustUnrotateFixedNormals;
  34322. private _particlesIntersect;
  34323. private _needs32Bits;
  34324. private _isNotBuilt;
  34325. private _lastParticleId;
  34326. private _idxOfId;
  34327. private _multimaterialEnabled;
  34328. private _useModelMaterial;
  34329. private _indicesByMaterial;
  34330. private _materialIndexes;
  34331. private _depthSortFunction;
  34332. private _materialSortFunction;
  34333. private _materials;
  34334. private _multimaterial;
  34335. private _materialIndexesById;
  34336. private _defaultMaterial;
  34337. private _autoUpdateSubMeshes;
  34338. private _tmpVertex;
  34339. /**
  34340. * Creates a SPS (Solid Particle System) object.
  34341. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34342. * @param scene (Scene) is the scene in which the SPS is added.
  34343. * @param options defines the options of the sps e.g.
  34344. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34345. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34346. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34347. * * 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.
  34348. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34349. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34350. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34351. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34352. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34353. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34354. */
  34355. constructor(name: string, scene: Scene, options?: {
  34356. updatable?: boolean;
  34357. isPickable?: boolean;
  34358. enableDepthSort?: boolean;
  34359. particleIntersection?: boolean;
  34360. boundingSphereOnly?: boolean;
  34361. bSphereRadiusFactor?: number;
  34362. expandable?: boolean;
  34363. useModelMaterial?: boolean;
  34364. enableMultiMaterial?: boolean;
  34365. });
  34366. /**
  34367. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34368. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34369. * @returns the created mesh
  34370. */
  34371. buildMesh(): Mesh;
  34372. /**
  34373. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34374. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34375. * Thus the particles generated from `digest()` have their property `position` set yet.
  34376. * @param mesh ( Mesh ) is the mesh to be digested
  34377. * @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
  34378. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34379. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34380. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34381. * @returns the current SPS
  34382. */
  34383. digest(mesh: Mesh, options?: {
  34384. facetNb?: number;
  34385. number?: number;
  34386. delta?: number;
  34387. storage?: [];
  34388. }): SolidParticleSystem;
  34389. /**
  34390. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34391. * @hidden
  34392. */
  34393. private _unrotateFixedNormals;
  34394. /**
  34395. * Resets the temporary working copy particle
  34396. * @hidden
  34397. */
  34398. private _resetCopy;
  34399. /**
  34400. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34401. * @param p the current index in the positions array to be updated
  34402. * @param ind the current index in the indices array
  34403. * @param shape a Vector3 array, the shape geometry
  34404. * @param positions the positions array to be updated
  34405. * @param meshInd the shape indices array
  34406. * @param indices the indices array to be updated
  34407. * @param meshUV the shape uv array
  34408. * @param uvs the uv array to be updated
  34409. * @param meshCol the shape color array
  34410. * @param colors the color array to be updated
  34411. * @param meshNor the shape normals array
  34412. * @param normals the normals array to be updated
  34413. * @param idx the particle index
  34414. * @param idxInShape the particle index in its shape
  34415. * @param options the addShape() method passed options
  34416. * @model the particle model
  34417. * @hidden
  34418. */
  34419. private _meshBuilder;
  34420. /**
  34421. * Returns a shape Vector3 array from positions float array
  34422. * @param positions float array
  34423. * @returns a vector3 array
  34424. * @hidden
  34425. */
  34426. private _posToShape;
  34427. /**
  34428. * Returns a shapeUV array from a float uvs (array deep copy)
  34429. * @param uvs as a float array
  34430. * @returns a shapeUV array
  34431. * @hidden
  34432. */
  34433. private _uvsToShapeUV;
  34434. /**
  34435. * Adds a new particle object in the particles array
  34436. * @param idx particle index in particles array
  34437. * @param id particle id
  34438. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34439. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34440. * @param model particle ModelShape object
  34441. * @param shapeId model shape identifier
  34442. * @param idxInShape index of the particle in the current model
  34443. * @param bInfo model bounding info object
  34444. * @param storage target storage array, if any
  34445. * @hidden
  34446. */
  34447. private _addParticle;
  34448. /**
  34449. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34450. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34451. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34452. * @param nb (positive integer) the number of particles to be created from this model
  34453. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34454. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34455. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34456. * @returns the number of shapes in the system
  34457. */
  34458. addShape(mesh: Mesh, nb: number, options?: {
  34459. positionFunction?: any;
  34460. vertexFunction?: any;
  34461. storage?: [];
  34462. }): number;
  34463. /**
  34464. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34465. * @hidden
  34466. */
  34467. private _rebuildParticle;
  34468. /**
  34469. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34470. * @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.
  34471. * @returns the SPS.
  34472. */
  34473. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34474. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34475. * Returns an array with the removed particles.
  34476. * 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.
  34477. * The SPS can't be empty so at least one particle needs to remain in place.
  34478. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34479. * @param start index of the first particle to remove
  34480. * @param end index of the last particle to remove (included)
  34481. * @returns an array populated with the removed particles
  34482. */
  34483. removeParticles(start: number, end: number): SolidParticle[];
  34484. /**
  34485. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34486. * @param solidParticleArray an array populated with Solid Particles objects
  34487. * @returns the SPS
  34488. */
  34489. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34490. /**
  34491. * Creates a new particle and modifies the SPS mesh geometry :
  34492. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34493. * - calls _addParticle() to populate the particle array
  34494. * factorized code from addShape() and insertParticlesFromArray()
  34495. * @param idx particle index in the particles array
  34496. * @param i particle index in its shape
  34497. * @param modelShape particle ModelShape object
  34498. * @param shape shape vertex array
  34499. * @param meshInd shape indices array
  34500. * @param meshUV shape uv array
  34501. * @param meshCol shape color array
  34502. * @param meshNor shape normals array
  34503. * @param bbInfo shape bounding info
  34504. * @param storage target particle storage
  34505. * @options addShape() passed options
  34506. * @hidden
  34507. */
  34508. private _insertNewParticle;
  34509. /**
  34510. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34511. * This method calls `updateParticle()` for each particle of the SPS.
  34512. * For an animated SPS, it is usually called within the render loop.
  34513. * 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.
  34514. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34515. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34516. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34517. * @returns the SPS.
  34518. */
  34519. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34520. /**
  34521. * Disposes the SPS.
  34522. */
  34523. dispose(): void;
  34524. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34525. * idx is the particle index in the SPS
  34526. * faceId is the picked face index counted within this particle.
  34527. * Returns null if the pickInfo can't identify a picked particle.
  34528. * @param pickingInfo (PickingInfo object)
  34529. * @returns {idx: number, faceId: number} or null
  34530. */
  34531. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34532. idx: number;
  34533. faceId: number;
  34534. }>;
  34535. /**
  34536. * Returns a SolidParticle object from its identifier : particle.id
  34537. * @param id (integer) the particle Id
  34538. * @returns the searched particle or null if not found in the SPS.
  34539. */
  34540. getParticleById(id: number): Nullable<SolidParticle>;
  34541. /**
  34542. * Returns a new array populated with the particles having the passed shapeId.
  34543. * @param shapeId (integer) the shape identifier
  34544. * @returns a new solid particle array
  34545. */
  34546. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34547. /**
  34548. * Populates the passed array "ref" with the particles having the passed shapeId.
  34549. * @param shapeId the shape identifier
  34550. * @returns the SPS
  34551. * @param ref
  34552. */
  34553. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34554. /**
  34555. * Computes the required SubMeshes according the materials assigned to the particles.
  34556. * @returns the solid particle system.
  34557. * Does nothing if called before the SPS mesh is built.
  34558. */
  34559. computeSubMeshes(): SolidParticleSystem;
  34560. /**
  34561. * Sorts the solid particles by material when MultiMaterial is enabled.
  34562. * Updates the indices32 array.
  34563. * Updates the indicesByMaterial array.
  34564. * Updates the mesh indices array.
  34565. * @returns the SPS
  34566. * @hidden
  34567. */
  34568. private _sortParticlesByMaterial;
  34569. /**
  34570. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34571. * @hidden
  34572. */
  34573. private _setMaterialIndexesById;
  34574. /**
  34575. * Returns an array with unique values of Materials from the passed array
  34576. * @param array the material array to be checked and filtered
  34577. * @hidden
  34578. */
  34579. private _filterUniqueMaterialId;
  34580. /**
  34581. * Sets a new Standard Material as _defaultMaterial if not already set.
  34582. * @hidden
  34583. */
  34584. private _setDefaultMaterial;
  34585. /**
  34586. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34587. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34588. * @returns the SPS.
  34589. */
  34590. refreshVisibleSize(): SolidParticleSystem;
  34591. /**
  34592. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34593. * @param size the size (float) of the visibility box
  34594. * note : this doesn't lock the SPS mesh bounding box.
  34595. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34596. */
  34597. setVisibilityBox(size: number): void;
  34598. /**
  34599. * Gets whether the SPS as always visible or not
  34600. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34601. */
  34602. get isAlwaysVisible(): boolean;
  34603. /**
  34604. * Sets the SPS as always visible or not
  34605. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34606. */
  34607. set isAlwaysVisible(val: boolean);
  34608. /**
  34609. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34610. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34611. */
  34612. set isVisibilityBoxLocked(val: boolean);
  34613. /**
  34614. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34615. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34616. */
  34617. get isVisibilityBoxLocked(): boolean;
  34618. /**
  34619. * Tells to `setParticles()` to compute the particle rotations or not.
  34620. * Default value : true. The SPS is faster when it's set to false.
  34621. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34622. */
  34623. set computeParticleRotation(val: boolean);
  34624. /**
  34625. * Tells to `setParticles()` to compute the particle colors or not.
  34626. * Default value : true. The SPS is faster when it's set to false.
  34627. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34628. */
  34629. set computeParticleColor(val: boolean);
  34630. set computeParticleTexture(val: boolean);
  34631. /**
  34632. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34633. * Default value : false. The SPS is faster when it's set to false.
  34634. * Note : the particle custom vertex positions aren't stored values.
  34635. */
  34636. set computeParticleVertex(val: boolean);
  34637. /**
  34638. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34639. */
  34640. set computeBoundingBox(val: boolean);
  34641. /**
  34642. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34643. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34644. * Default : `true`
  34645. */
  34646. set depthSortParticles(val: boolean);
  34647. /**
  34648. * Gets if `setParticles()` computes the particle rotations or not.
  34649. * Default value : true. The SPS is faster when it's set to false.
  34650. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34651. */
  34652. get computeParticleRotation(): boolean;
  34653. /**
  34654. * Gets if `setParticles()` computes the particle colors or not.
  34655. * Default value : true. The SPS is faster when it's set to false.
  34656. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34657. */
  34658. get computeParticleColor(): boolean;
  34659. /**
  34660. * Gets if `setParticles()` computes the particle textures or not.
  34661. * Default value : true. The SPS is faster when it's set to false.
  34662. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34663. */
  34664. get computeParticleTexture(): boolean;
  34665. /**
  34666. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34667. * Default value : false. The SPS is faster when it's set to false.
  34668. * Note : the particle custom vertex positions aren't stored values.
  34669. */
  34670. get computeParticleVertex(): boolean;
  34671. /**
  34672. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34673. */
  34674. get computeBoundingBox(): boolean;
  34675. /**
  34676. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34677. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34678. * Default : `true`
  34679. */
  34680. get depthSortParticles(): boolean;
  34681. /**
  34682. * Gets if the SPS is created as expandable at construction time.
  34683. * Default : `false`
  34684. */
  34685. get expandable(): boolean;
  34686. /**
  34687. * Gets if the SPS supports the Multi Materials
  34688. */
  34689. get multimaterialEnabled(): boolean;
  34690. /**
  34691. * Gets if the SPS uses the model materials for its own multimaterial.
  34692. */
  34693. get useModelMaterial(): boolean;
  34694. /**
  34695. * The SPS used material array.
  34696. */
  34697. get materials(): Material[];
  34698. /**
  34699. * Sets the SPS MultiMaterial from the passed materials.
  34700. * Note : the passed array is internally copied and not used then by reference.
  34701. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34702. */
  34703. setMultiMaterial(materials: Material[]): void;
  34704. /**
  34705. * The SPS computed multimaterial object
  34706. */
  34707. get multimaterial(): MultiMaterial;
  34708. set multimaterial(mm: MultiMaterial);
  34709. /**
  34710. * If the subMeshes must be updated on the next call to setParticles()
  34711. */
  34712. get autoUpdateSubMeshes(): boolean;
  34713. set autoUpdateSubMeshes(val: boolean);
  34714. /**
  34715. * This function does nothing. It may be overwritten to set all the particle first values.
  34716. * The SPS doesn't call this function, you may have to call it by your own.
  34717. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34718. */
  34719. initParticles(): void;
  34720. /**
  34721. * This function does nothing. It may be overwritten to recycle a particle.
  34722. * The SPS doesn't call this function, you may have to call it by your own.
  34723. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34724. * @param particle The particle to recycle
  34725. * @returns the recycled particle
  34726. */
  34727. recycleParticle(particle: SolidParticle): SolidParticle;
  34728. /**
  34729. * Updates a particle : this function should be overwritten by the user.
  34730. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34731. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34732. * @example : just set a particle position or velocity and recycle conditions
  34733. * @param particle The particle to update
  34734. * @returns the updated particle
  34735. */
  34736. updateParticle(particle: SolidParticle): SolidParticle;
  34737. /**
  34738. * Updates a vertex of a particle : it can be overwritten by the user.
  34739. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34740. * @param particle the current particle
  34741. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34742. * @param pt the index of the current vertex in the particle shape
  34743. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34744. * @example : just set a vertex particle position or color
  34745. * @returns the sps
  34746. */
  34747. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34748. /**
  34749. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34750. * This does nothing and may be overwritten by the user.
  34751. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34752. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34753. * @param update the boolean update value actually passed to setParticles()
  34754. */
  34755. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34756. /**
  34757. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34758. * This will be passed three parameters.
  34759. * This does nothing and may be overwritten by the user.
  34760. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34761. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34762. * @param update the boolean update value actually passed to setParticles()
  34763. */
  34764. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34765. }
  34766. }
  34767. declare module BABYLON {
  34768. /**
  34769. * Represents one particle of a solid particle system.
  34770. */
  34771. export class SolidParticle {
  34772. /**
  34773. * particle global index
  34774. */
  34775. idx: number;
  34776. /**
  34777. * particle identifier
  34778. */
  34779. id: number;
  34780. /**
  34781. * The color of the particle
  34782. */
  34783. color: Nullable<Color4>;
  34784. /**
  34785. * The world space position of the particle.
  34786. */
  34787. position: Vector3;
  34788. /**
  34789. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34790. */
  34791. rotation: Vector3;
  34792. /**
  34793. * The world space rotation quaternion of the particle.
  34794. */
  34795. rotationQuaternion: Nullable<Quaternion>;
  34796. /**
  34797. * The scaling of the particle.
  34798. */
  34799. scaling: Vector3;
  34800. /**
  34801. * The uvs of the particle.
  34802. */
  34803. uvs: Vector4;
  34804. /**
  34805. * The current speed of the particle.
  34806. */
  34807. velocity: Vector3;
  34808. /**
  34809. * The pivot point in the particle local space.
  34810. */
  34811. pivot: Vector3;
  34812. /**
  34813. * Must the particle be translated from its pivot point in its local space ?
  34814. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34815. * Default : false
  34816. */
  34817. translateFromPivot: boolean;
  34818. /**
  34819. * Is the particle active or not ?
  34820. */
  34821. alive: boolean;
  34822. /**
  34823. * Is the particle visible or not ?
  34824. */
  34825. isVisible: boolean;
  34826. /**
  34827. * Index of this particle in the global "positions" array (Internal use)
  34828. * @hidden
  34829. */
  34830. _pos: number;
  34831. /**
  34832. * @hidden Index of this particle in the global "indices" array (Internal use)
  34833. */
  34834. _ind: number;
  34835. /**
  34836. * @hidden ModelShape of this particle (Internal use)
  34837. */
  34838. _model: ModelShape;
  34839. /**
  34840. * ModelShape id of this particle
  34841. */
  34842. shapeId: number;
  34843. /**
  34844. * Index of the particle in its shape id
  34845. */
  34846. idxInShape: number;
  34847. /**
  34848. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34849. */
  34850. _modelBoundingInfo: BoundingInfo;
  34851. /**
  34852. * @hidden Particle BoundingInfo object (Internal use)
  34853. */
  34854. _boundingInfo: BoundingInfo;
  34855. /**
  34856. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34857. */
  34858. _sps: SolidParticleSystem;
  34859. /**
  34860. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34861. */
  34862. _stillInvisible: boolean;
  34863. /**
  34864. * @hidden Last computed particle rotation matrix
  34865. */
  34866. _rotationMatrix: number[];
  34867. /**
  34868. * Parent particle Id, if any.
  34869. * Default null.
  34870. */
  34871. parentId: Nullable<number>;
  34872. /**
  34873. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34874. */
  34875. materialIndex: Nullable<number>;
  34876. /**
  34877. * Custom object or properties.
  34878. */
  34879. props: Nullable<any>;
  34880. /**
  34881. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34882. * The possible values are :
  34883. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34884. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34885. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34886. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34887. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34888. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34889. * */
  34890. cullingStrategy: number;
  34891. /**
  34892. * @hidden Internal global position in the SPS.
  34893. */
  34894. _globalPosition: Vector3;
  34895. /**
  34896. * Creates a Solid Particle object.
  34897. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34898. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34899. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34900. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34901. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34902. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34903. * @param shapeId (integer) is the model shape identifier in the SPS.
  34904. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34905. * @param sps defines the sps it is associated to
  34906. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34907. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34908. */
  34909. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34910. /**
  34911. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34912. * @param target the particle target
  34913. * @returns the current particle
  34914. */
  34915. copyToRef(target: SolidParticle): SolidParticle;
  34916. /**
  34917. * Legacy support, changed scale to scaling
  34918. */
  34919. get scale(): Vector3;
  34920. /**
  34921. * Legacy support, changed scale to scaling
  34922. */
  34923. set scale(scale: Vector3);
  34924. /**
  34925. * Legacy support, changed quaternion to rotationQuaternion
  34926. */
  34927. get quaternion(): Nullable<Quaternion>;
  34928. /**
  34929. * Legacy support, changed quaternion to rotationQuaternion
  34930. */
  34931. set quaternion(q: Nullable<Quaternion>);
  34932. /**
  34933. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34934. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34935. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34936. * @returns true if it intersects
  34937. */
  34938. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34939. /**
  34940. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34941. * A particle is in the frustum if its bounding box intersects the frustum
  34942. * @param frustumPlanes defines the frustum to test
  34943. * @returns true if the particle is in the frustum planes
  34944. */
  34945. isInFrustum(frustumPlanes: Plane[]): boolean;
  34946. /**
  34947. * get the rotation matrix of the particle
  34948. * @hidden
  34949. */
  34950. getRotationMatrix(m: Matrix): void;
  34951. }
  34952. /**
  34953. * Represents the shape of the model used by one particle of a solid particle system.
  34954. * SPS internal tool, don't use it manually.
  34955. */
  34956. export class ModelShape {
  34957. /**
  34958. * The shape id
  34959. * @hidden
  34960. */
  34961. shapeID: number;
  34962. /**
  34963. * flat array of model positions (internal use)
  34964. * @hidden
  34965. */
  34966. _shape: Vector3[];
  34967. /**
  34968. * flat array of model UVs (internal use)
  34969. * @hidden
  34970. */
  34971. _shapeUV: number[];
  34972. /**
  34973. * color array of the model
  34974. * @hidden
  34975. */
  34976. _shapeColors: number[];
  34977. /**
  34978. * indices array of the model
  34979. * @hidden
  34980. */
  34981. _indices: number[];
  34982. /**
  34983. * normals array of the model
  34984. * @hidden
  34985. */
  34986. _normals: number[];
  34987. /**
  34988. * length of the shape in the model indices array (internal use)
  34989. * @hidden
  34990. */
  34991. _indicesLength: number;
  34992. /**
  34993. * Custom position function (internal use)
  34994. * @hidden
  34995. */
  34996. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34997. /**
  34998. * Custom vertex function (internal use)
  34999. * @hidden
  35000. */
  35001. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35002. /**
  35003. * Model material (internal use)
  35004. * @hidden
  35005. */
  35006. _material: Nullable<Material>;
  35007. /**
  35008. * 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.
  35009. * SPS internal tool, don't use it manually.
  35010. * @hidden
  35011. */
  35012. 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>);
  35013. }
  35014. /**
  35015. * Represents a Depth Sorted Particle in the solid particle system.
  35016. * @hidden
  35017. */
  35018. export class DepthSortedParticle {
  35019. /**
  35020. * Particle index
  35021. */
  35022. idx: number;
  35023. /**
  35024. * Index of the particle in the "indices" array
  35025. */
  35026. ind: number;
  35027. /**
  35028. * Length of the particle shape in the "indices" array
  35029. */
  35030. indicesLength: number;
  35031. /**
  35032. * Squared distance from the particle to the camera
  35033. */
  35034. sqDistance: number;
  35035. /**
  35036. * Material index when used with MultiMaterials
  35037. */
  35038. materialIndex: number;
  35039. /**
  35040. * Creates a new sorted particle
  35041. * @param materialIndex
  35042. */
  35043. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35044. }
  35045. /**
  35046. * Represents a solid particle vertex
  35047. */
  35048. export class SolidParticleVertex {
  35049. /**
  35050. * Vertex position
  35051. */
  35052. position: Vector3;
  35053. /**
  35054. * Vertex color
  35055. */
  35056. color: Color4;
  35057. /**
  35058. * Vertex UV
  35059. */
  35060. uv: Vector2;
  35061. /**
  35062. * Creates a new solid particle vertex
  35063. */
  35064. constructor();
  35065. /** Vertex x coordinate */
  35066. get x(): number;
  35067. set x(val: number);
  35068. /** Vertex y coordinate */
  35069. get y(): number;
  35070. set y(val: number);
  35071. /** Vertex z coordinate */
  35072. get z(): number;
  35073. set z(val: number);
  35074. }
  35075. }
  35076. declare module BABYLON {
  35077. /**
  35078. * @hidden
  35079. */
  35080. export class _MeshCollisionData {
  35081. _checkCollisions: boolean;
  35082. _collisionMask: number;
  35083. _collisionGroup: number;
  35084. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35085. _collider: Nullable<Collider>;
  35086. _oldPositionForCollisions: Vector3;
  35087. _diffPositionForCollisions: Vector3;
  35088. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35089. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35090. _collisionResponse: boolean;
  35091. }
  35092. }
  35093. declare module BABYLON {
  35094. /** @hidden */
  35095. class _FacetDataStorage {
  35096. facetPositions: Vector3[];
  35097. facetNormals: Vector3[];
  35098. facetPartitioning: number[][];
  35099. facetNb: number;
  35100. partitioningSubdivisions: number;
  35101. partitioningBBoxRatio: number;
  35102. facetDataEnabled: boolean;
  35103. facetParameters: any;
  35104. bbSize: Vector3;
  35105. subDiv: {
  35106. max: number;
  35107. X: number;
  35108. Y: number;
  35109. Z: number;
  35110. };
  35111. facetDepthSort: boolean;
  35112. facetDepthSortEnabled: boolean;
  35113. depthSortedIndices: IndicesArray;
  35114. depthSortedFacets: {
  35115. ind: number;
  35116. sqDistance: number;
  35117. }[];
  35118. facetDepthSortFunction: (f1: {
  35119. ind: number;
  35120. sqDistance: number;
  35121. }, f2: {
  35122. ind: number;
  35123. sqDistance: number;
  35124. }) => number;
  35125. facetDepthSortFrom: Vector3;
  35126. facetDepthSortOrigin: Vector3;
  35127. invertedMatrix: Matrix;
  35128. }
  35129. /**
  35130. * @hidden
  35131. **/
  35132. class _InternalAbstractMeshDataInfo {
  35133. _hasVertexAlpha: boolean;
  35134. _useVertexColors: boolean;
  35135. _numBoneInfluencers: number;
  35136. _applyFog: boolean;
  35137. _receiveShadows: boolean;
  35138. _facetData: _FacetDataStorage;
  35139. _visibility: number;
  35140. _skeleton: Nullable<Skeleton>;
  35141. _layerMask: number;
  35142. _computeBonesUsingShaders: boolean;
  35143. _isActive: boolean;
  35144. _onlyForInstances: boolean;
  35145. _isActiveIntermediate: boolean;
  35146. _onlyForInstancesIntermediate: boolean;
  35147. _actAsRegularMesh: boolean;
  35148. _currentLOD: Nullable<AbstractMesh>;
  35149. _currentLODIsUpToDate: boolean;
  35150. }
  35151. /**
  35152. * Class used to store all common mesh properties
  35153. */
  35154. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35155. /** No occlusion */
  35156. static OCCLUSION_TYPE_NONE: number;
  35157. /** Occlusion set to optimisitic */
  35158. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35159. /** Occlusion set to strict */
  35160. static OCCLUSION_TYPE_STRICT: number;
  35161. /** Use an accurante occlusion algorithm */
  35162. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35163. /** Use a conservative occlusion algorithm */
  35164. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35165. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35166. * Test order :
  35167. * Is the bounding sphere outside the frustum ?
  35168. * If not, are the bounding box vertices outside the frustum ?
  35169. * It not, then the cullable object is in the frustum.
  35170. */
  35171. static readonly CULLINGSTRATEGY_STANDARD: number;
  35172. /** Culling strategy : Bounding Sphere Only.
  35173. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35174. * It's also less accurate than the standard because some not visible objects can still be selected.
  35175. * Test : is the bounding sphere outside the frustum ?
  35176. * If not, then the cullable object is in the frustum.
  35177. */
  35178. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35179. /** Culling strategy : Optimistic Inclusion.
  35180. * This in an inclusion test first, then the standard exclusion test.
  35181. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35182. * 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.
  35183. * Anyway, it's as accurate as the standard strategy.
  35184. * Test :
  35185. * Is the cullable object bounding sphere center in the frustum ?
  35186. * If not, apply the default culling strategy.
  35187. */
  35188. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35189. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35190. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35191. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35192. * 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.
  35193. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35194. * Test :
  35195. * Is the cullable object bounding sphere center in the frustum ?
  35196. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35197. */
  35198. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35199. /**
  35200. * No billboard
  35201. */
  35202. static get BILLBOARDMODE_NONE(): number;
  35203. /** Billboard on X axis */
  35204. static get BILLBOARDMODE_X(): number;
  35205. /** Billboard on Y axis */
  35206. static get BILLBOARDMODE_Y(): number;
  35207. /** Billboard on Z axis */
  35208. static get BILLBOARDMODE_Z(): number;
  35209. /** Billboard on all axes */
  35210. static get BILLBOARDMODE_ALL(): number;
  35211. /** Billboard on using position instead of orientation */
  35212. static get BILLBOARDMODE_USE_POSITION(): number;
  35213. /** @hidden */
  35214. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35215. /**
  35216. * The culling strategy to use to check whether the mesh must be rendered or not.
  35217. * This value can be changed at any time and will be used on the next render mesh selection.
  35218. * The possible values are :
  35219. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35220. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35221. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35222. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35223. * Please read each static variable documentation to get details about the culling process.
  35224. * */
  35225. cullingStrategy: number;
  35226. /**
  35227. * Gets the number of facets in the mesh
  35228. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35229. */
  35230. get facetNb(): number;
  35231. /**
  35232. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35233. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35234. */
  35235. get partitioningSubdivisions(): number;
  35236. set partitioningSubdivisions(nb: number);
  35237. /**
  35238. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35239. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35240. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35241. */
  35242. get partitioningBBoxRatio(): number;
  35243. set partitioningBBoxRatio(ratio: number);
  35244. /**
  35245. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35246. * Works only for updatable meshes.
  35247. * Doesn't work with multi-materials
  35248. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35249. */
  35250. get mustDepthSortFacets(): boolean;
  35251. set mustDepthSortFacets(sort: boolean);
  35252. /**
  35253. * The location (Vector3) where the facet depth sort must be computed from.
  35254. * By default, the active camera position.
  35255. * Used only when facet depth sort is enabled
  35256. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35257. */
  35258. get facetDepthSortFrom(): Vector3;
  35259. set facetDepthSortFrom(location: Vector3);
  35260. /**
  35261. * gets a boolean indicating if facetData is enabled
  35262. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35263. */
  35264. get isFacetDataEnabled(): boolean;
  35265. /** @hidden */
  35266. _updateNonUniformScalingState(value: boolean): boolean;
  35267. /**
  35268. * An event triggered when this mesh collides with another one
  35269. */
  35270. onCollideObservable: Observable<AbstractMesh>;
  35271. /** Set a function to call when this mesh collides with another one */
  35272. set onCollide(callback: () => void);
  35273. /**
  35274. * An event triggered when the collision's position changes
  35275. */
  35276. onCollisionPositionChangeObservable: Observable<Vector3>;
  35277. /** Set a function to call when the collision's position changes */
  35278. set onCollisionPositionChange(callback: () => void);
  35279. /**
  35280. * An event triggered when material is changed
  35281. */
  35282. onMaterialChangedObservable: Observable<AbstractMesh>;
  35283. /**
  35284. * Gets or sets the orientation for POV movement & rotation
  35285. */
  35286. definedFacingForward: boolean;
  35287. /** @hidden */
  35288. _occlusionQuery: Nullable<WebGLQuery>;
  35289. /** @hidden */
  35290. _renderingGroup: Nullable<RenderingGroup>;
  35291. /**
  35292. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35293. */
  35294. get visibility(): number;
  35295. /**
  35296. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35297. */
  35298. set visibility(value: number);
  35299. /** Gets or sets the alpha index used to sort transparent meshes
  35300. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35301. */
  35302. alphaIndex: number;
  35303. /**
  35304. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35305. */
  35306. isVisible: boolean;
  35307. /**
  35308. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35309. */
  35310. isPickable: boolean;
  35311. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35312. showSubMeshesBoundingBox: boolean;
  35313. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35314. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35315. */
  35316. isBlocker: boolean;
  35317. /**
  35318. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35319. */
  35320. enablePointerMoveEvents: boolean;
  35321. private _renderingGroupId;
  35322. /**
  35323. * Specifies the rendering group id for this mesh (0 by default)
  35324. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35325. */
  35326. get renderingGroupId(): number;
  35327. set renderingGroupId(value: number);
  35328. private _material;
  35329. /** Gets or sets current material */
  35330. get material(): Nullable<Material>;
  35331. set material(value: Nullable<Material>);
  35332. /**
  35333. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35334. * @see https://doc.babylonjs.com/babylon101/shadows
  35335. */
  35336. get receiveShadows(): boolean;
  35337. set receiveShadows(value: boolean);
  35338. /** Defines color to use when rendering outline */
  35339. outlineColor: Color3;
  35340. /** Define width to use when rendering outline */
  35341. outlineWidth: number;
  35342. /** Defines color to use when rendering overlay */
  35343. overlayColor: Color3;
  35344. /** Defines alpha to use when rendering overlay */
  35345. overlayAlpha: number;
  35346. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35347. get hasVertexAlpha(): boolean;
  35348. set hasVertexAlpha(value: boolean);
  35349. /** 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) */
  35350. get useVertexColors(): boolean;
  35351. set useVertexColors(value: boolean);
  35352. /**
  35353. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35354. */
  35355. get computeBonesUsingShaders(): boolean;
  35356. set computeBonesUsingShaders(value: boolean);
  35357. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35358. get numBoneInfluencers(): number;
  35359. set numBoneInfluencers(value: number);
  35360. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35361. get applyFog(): boolean;
  35362. set applyFog(value: boolean);
  35363. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35364. useOctreeForRenderingSelection: boolean;
  35365. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35366. useOctreeForPicking: boolean;
  35367. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35368. useOctreeForCollisions: boolean;
  35369. /**
  35370. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35371. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35372. */
  35373. get layerMask(): number;
  35374. set layerMask(value: number);
  35375. /**
  35376. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35377. */
  35378. alwaysSelectAsActiveMesh: boolean;
  35379. /**
  35380. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35381. */
  35382. doNotSyncBoundingInfo: boolean;
  35383. /**
  35384. * Gets or sets the current action manager
  35385. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35386. */
  35387. actionManager: Nullable<AbstractActionManager>;
  35388. private _meshCollisionData;
  35389. /**
  35390. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35391. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35392. */
  35393. ellipsoid: Vector3;
  35394. /**
  35395. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35396. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35397. */
  35398. ellipsoidOffset: Vector3;
  35399. /**
  35400. * Gets or sets a collision mask used to mask collisions (default is -1).
  35401. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35402. */
  35403. get collisionMask(): number;
  35404. set collisionMask(mask: number);
  35405. /**
  35406. * Gets or sets a collision response flag (default is true).
  35407. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35408. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35409. * to respond to the collision.
  35410. */
  35411. get collisionResponse(): boolean;
  35412. set collisionResponse(response: boolean);
  35413. /**
  35414. * Gets or sets the current collision group mask (-1 by default).
  35415. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35416. */
  35417. get collisionGroup(): number;
  35418. set collisionGroup(mask: number);
  35419. /**
  35420. * Gets or sets current surrounding meshes (null by default).
  35421. *
  35422. * By default collision detection is tested against every mesh in the scene.
  35423. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35424. * meshes will be tested for the collision.
  35425. *
  35426. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35427. */
  35428. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35429. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35430. /**
  35431. * Defines edge width used when edgesRenderer is enabled
  35432. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35433. */
  35434. edgesWidth: number;
  35435. /**
  35436. * Defines edge color used when edgesRenderer is enabled
  35437. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35438. */
  35439. edgesColor: Color4;
  35440. /** @hidden */
  35441. _edgesRenderer: Nullable<IEdgesRenderer>;
  35442. /** @hidden */
  35443. _masterMesh: Nullable<AbstractMesh>;
  35444. /** @hidden */
  35445. _boundingInfo: Nullable<BoundingInfo>;
  35446. /** @hidden */
  35447. _renderId: number;
  35448. /**
  35449. * Gets or sets the list of subMeshes
  35450. * @see https://doc.babylonjs.com/how_to/multi_materials
  35451. */
  35452. subMeshes: SubMesh[];
  35453. /** @hidden */
  35454. _intersectionsInProgress: AbstractMesh[];
  35455. /** @hidden */
  35456. _unIndexed: boolean;
  35457. /** @hidden */
  35458. _lightSources: Light[];
  35459. /** Gets the list of lights affecting that mesh */
  35460. get lightSources(): Light[];
  35461. /** @hidden */
  35462. get _positions(): Nullable<Vector3[]>;
  35463. /** @hidden */
  35464. _waitingData: {
  35465. lods: Nullable<any>;
  35466. actions: Nullable<any>;
  35467. freezeWorldMatrix: Nullable<boolean>;
  35468. };
  35469. /** @hidden */
  35470. _bonesTransformMatrices: Nullable<Float32Array>;
  35471. /** @hidden */
  35472. _transformMatrixTexture: Nullable<RawTexture>;
  35473. /**
  35474. * Gets or sets a skeleton to apply skining transformations
  35475. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35476. */
  35477. set skeleton(value: Nullable<Skeleton>);
  35478. get skeleton(): Nullable<Skeleton>;
  35479. /**
  35480. * An event triggered when the mesh is rebuilt.
  35481. */
  35482. onRebuildObservable: Observable<AbstractMesh>;
  35483. /**
  35484. * Creates a new AbstractMesh
  35485. * @param name defines the name of the mesh
  35486. * @param scene defines the hosting scene
  35487. */
  35488. constructor(name: string, scene?: Nullable<Scene>);
  35489. /**
  35490. * Returns the string "AbstractMesh"
  35491. * @returns "AbstractMesh"
  35492. */
  35493. getClassName(): string;
  35494. /**
  35495. * Gets a string representation of the current mesh
  35496. * @param fullDetails defines a boolean indicating if full details must be included
  35497. * @returns a string representation of the current mesh
  35498. */
  35499. toString(fullDetails?: boolean): string;
  35500. /**
  35501. * @hidden
  35502. */
  35503. protected _getEffectiveParent(): Nullable<Node>;
  35504. /** @hidden */
  35505. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35506. /** @hidden */
  35507. _rebuild(): void;
  35508. /** @hidden */
  35509. _resyncLightSources(): void;
  35510. /** @hidden */
  35511. _resyncLightSource(light: Light): void;
  35512. /** @hidden */
  35513. _unBindEffect(): void;
  35514. /** @hidden */
  35515. _removeLightSource(light: Light, dispose: boolean): void;
  35516. private _markSubMeshesAsDirty;
  35517. /** @hidden */
  35518. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35519. /** @hidden */
  35520. _markSubMeshesAsAttributesDirty(): void;
  35521. /** @hidden */
  35522. _markSubMeshesAsMiscDirty(): void;
  35523. /**
  35524. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35525. */
  35526. get scaling(): Vector3;
  35527. set scaling(newScaling: Vector3);
  35528. /**
  35529. * Returns true if the mesh is blocked. Implemented by child classes
  35530. */
  35531. get isBlocked(): boolean;
  35532. /**
  35533. * Returns the mesh itself by default. Implemented by child classes
  35534. * @param camera defines the camera to use to pick the right LOD level
  35535. * @returns the currentAbstractMesh
  35536. */
  35537. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35538. /**
  35539. * Returns 0 by default. Implemented by child classes
  35540. * @returns an integer
  35541. */
  35542. getTotalVertices(): number;
  35543. /**
  35544. * Returns a positive integer : the total number of indices in this mesh geometry.
  35545. * @returns the numner of indices or zero if the mesh has no geometry.
  35546. */
  35547. getTotalIndices(): number;
  35548. /**
  35549. * Returns null by default. Implemented by child classes
  35550. * @returns null
  35551. */
  35552. getIndices(): Nullable<IndicesArray>;
  35553. /**
  35554. * Returns the array of the requested vertex data kind. Implemented by child classes
  35555. * @param kind defines the vertex data kind to use
  35556. * @returns null
  35557. */
  35558. getVerticesData(kind: string): Nullable<FloatArray>;
  35559. /**
  35560. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35561. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35562. * Note that a new underlying VertexBuffer object is created each call.
  35563. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35564. * @param kind defines vertex data kind:
  35565. * * VertexBuffer.PositionKind
  35566. * * VertexBuffer.UVKind
  35567. * * VertexBuffer.UV2Kind
  35568. * * VertexBuffer.UV3Kind
  35569. * * VertexBuffer.UV4Kind
  35570. * * VertexBuffer.UV5Kind
  35571. * * VertexBuffer.UV6Kind
  35572. * * VertexBuffer.ColorKind
  35573. * * VertexBuffer.MatricesIndicesKind
  35574. * * VertexBuffer.MatricesIndicesExtraKind
  35575. * * VertexBuffer.MatricesWeightsKind
  35576. * * VertexBuffer.MatricesWeightsExtraKind
  35577. * @param data defines the data source
  35578. * @param updatable defines if the data must be flagged as updatable (or static)
  35579. * @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
  35580. * @returns the current mesh
  35581. */
  35582. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35583. /**
  35584. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35585. * If the mesh has no geometry, it is simply returned as it is.
  35586. * @param kind defines vertex data kind:
  35587. * * VertexBuffer.PositionKind
  35588. * * VertexBuffer.UVKind
  35589. * * VertexBuffer.UV2Kind
  35590. * * VertexBuffer.UV3Kind
  35591. * * VertexBuffer.UV4Kind
  35592. * * VertexBuffer.UV5Kind
  35593. * * VertexBuffer.UV6Kind
  35594. * * VertexBuffer.ColorKind
  35595. * * VertexBuffer.MatricesIndicesKind
  35596. * * VertexBuffer.MatricesIndicesExtraKind
  35597. * * VertexBuffer.MatricesWeightsKind
  35598. * * VertexBuffer.MatricesWeightsExtraKind
  35599. * @param data defines the data source
  35600. * @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
  35601. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35602. * @returns the current mesh
  35603. */
  35604. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35605. /**
  35606. * Sets the mesh indices,
  35607. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35608. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35609. * @param totalVertices Defines the total number of vertices
  35610. * @returns the current mesh
  35611. */
  35612. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35613. /**
  35614. * Gets a boolean indicating if specific vertex data is present
  35615. * @param kind defines the vertex data kind to use
  35616. * @returns true is data kind is present
  35617. */
  35618. isVerticesDataPresent(kind: string): boolean;
  35619. /**
  35620. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35621. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35622. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35623. * @returns a BoundingInfo
  35624. */
  35625. getBoundingInfo(): BoundingInfo;
  35626. /**
  35627. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35628. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35629. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35630. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35631. * @returns the current mesh
  35632. */
  35633. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35634. /**
  35635. * Overwrite the current bounding info
  35636. * @param boundingInfo defines the new bounding info
  35637. * @returns the current mesh
  35638. */
  35639. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35640. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35641. get useBones(): boolean;
  35642. /** @hidden */
  35643. _preActivate(): void;
  35644. /** @hidden */
  35645. _preActivateForIntermediateRendering(renderId: number): void;
  35646. /** @hidden */
  35647. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35648. /** @hidden */
  35649. _postActivate(): void;
  35650. /** @hidden */
  35651. _freeze(): void;
  35652. /** @hidden */
  35653. _unFreeze(): void;
  35654. /**
  35655. * Gets the current world matrix
  35656. * @returns a Matrix
  35657. */
  35658. getWorldMatrix(): Matrix;
  35659. /** @hidden */
  35660. _getWorldMatrixDeterminant(): number;
  35661. /**
  35662. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35663. */
  35664. get isAnInstance(): boolean;
  35665. /**
  35666. * Gets a boolean indicating if this mesh has instances
  35667. */
  35668. get hasInstances(): boolean;
  35669. /**
  35670. * Gets a boolean indicating if this mesh has thin instances
  35671. */
  35672. get hasThinInstances(): boolean;
  35673. /**
  35674. * Perform relative position change from the point of view of behind the front of the mesh.
  35675. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35676. * Supports definition of mesh facing forward or backward
  35677. * @param amountRight defines the distance on the right axis
  35678. * @param amountUp defines the distance on the up axis
  35679. * @param amountForward defines the distance on the forward axis
  35680. * @returns the current mesh
  35681. */
  35682. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35683. /**
  35684. * Calculate relative position change from the point of view of behind the front of the mesh.
  35685. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35686. * Supports definition of mesh facing forward or backward
  35687. * @param amountRight defines the distance on the right axis
  35688. * @param amountUp defines the distance on the up axis
  35689. * @param amountForward defines the distance on the forward axis
  35690. * @returns the new displacement vector
  35691. */
  35692. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35693. /**
  35694. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35695. * Supports definition of mesh facing forward or backward
  35696. * @param flipBack defines the flip
  35697. * @param twirlClockwise defines the twirl
  35698. * @param tiltRight defines the tilt
  35699. * @returns the current mesh
  35700. */
  35701. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35702. /**
  35703. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35704. * Supports definition of mesh facing forward or backward.
  35705. * @param flipBack defines the flip
  35706. * @param twirlClockwise defines the twirl
  35707. * @param tiltRight defines the tilt
  35708. * @returns the new rotation vector
  35709. */
  35710. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35711. /**
  35712. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35713. * This means the mesh underlying bounding box and sphere are recomputed.
  35714. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35715. * @returns the current mesh
  35716. */
  35717. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35718. /** @hidden */
  35719. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35720. /** @hidden */
  35721. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35722. /** @hidden */
  35723. _updateBoundingInfo(): AbstractMesh;
  35724. /** @hidden */
  35725. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35726. /** @hidden */
  35727. protected _afterComputeWorldMatrix(): void;
  35728. /** @hidden */
  35729. get _effectiveMesh(): AbstractMesh;
  35730. /**
  35731. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35732. * A mesh is in the frustum if its bounding box intersects the frustum
  35733. * @param frustumPlanes defines the frustum to test
  35734. * @returns true if the mesh is in the frustum planes
  35735. */
  35736. isInFrustum(frustumPlanes: Plane[]): boolean;
  35737. /**
  35738. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35739. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35740. * @param frustumPlanes defines the frustum to test
  35741. * @returns true if the mesh is completely in the frustum planes
  35742. */
  35743. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35744. /**
  35745. * True if the mesh intersects another mesh or a SolidParticle object
  35746. * @param mesh defines a target mesh or SolidParticle to test
  35747. * @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)
  35748. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35749. * @returns true if there is an intersection
  35750. */
  35751. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35752. /**
  35753. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35754. * @param point defines the point to test
  35755. * @returns true if there is an intersection
  35756. */
  35757. intersectsPoint(point: Vector3): boolean;
  35758. /**
  35759. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35760. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35761. */
  35762. get checkCollisions(): boolean;
  35763. set checkCollisions(collisionEnabled: boolean);
  35764. /**
  35765. * Gets Collider object used to compute collisions (not physics)
  35766. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35767. */
  35768. get collider(): Nullable<Collider>;
  35769. /**
  35770. * Move the mesh using collision engine
  35771. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35772. * @param displacement defines the requested displacement vector
  35773. * @returns the current mesh
  35774. */
  35775. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35776. private _onCollisionPositionChange;
  35777. /** @hidden */
  35778. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35779. /** @hidden */
  35780. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35781. /** @hidden */
  35782. _checkCollision(collider: Collider): AbstractMesh;
  35783. /** @hidden */
  35784. _generatePointsArray(): boolean;
  35785. /**
  35786. * Checks if the passed Ray intersects with the mesh
  35787. * @param ray defines the ray to use
  35788. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35789. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35790. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35791. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35792. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  35793. * @returns the picking info
  35794. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35795. */
  35796. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  35797. /**
  35798. * Clones the current mesh
  35799. * @param name defines the mesh name
  35800. * @param newParent defines the new mesh parent
  35801. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35802. * @returns the new mesh
  35803. */
  35804. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35805. /**
  35806. * Disposes all the submeshes of the current meshnp
  35807. * @returns the current mesh
  35808. */
  35809. releaseSubMeshes(): AbstractMesh;
  35810. /**
  35811. * Releases resources associated with this abstract mesh.
  35812. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35813. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35814. */
  35815. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35816. /**
  35817. * Adds the passed mesh as a child to the current mesh
  35818. * @param mesh defines the child mesh
  35819. * @returns the current mesh
  35820. */
  35821. addChild(mesh: AbstractMesh): AbstractMesh;
  35822. /**
  35823. * Removes the passed mesh from the current mesh children list
  35824. * @param mesh defines the child mesh
  35825. * @returns the current mesh
  35826. */
  35827. removeChild(mesh: AbstractMesh): AbstractMesh;
  35828. /** @hidden */
  35829. private _initFacetData;
  35830. /**
  35831. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35832. * This method can be called within the render loop.
  35833. * 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
  35834. * @returns the current mesh
  35835. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35836. */
  35837. updateFacetData(): AbstractMesh;
  35838. /**
  35839. * Returns the facetLocalNormals array.
  35840. * The normals are expressed in the mesh local spac
  35841. * @returns an array of Vector3
  35842. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35843. */
  35844. getFacetLocalNormals(): Vector3[];
  35845. /**
  35846. * Returns the facetLocalPositions array.
  35847. * The facet positions are expressed in the mesh local space
  35848. * @returns an array of Vector3
  35849. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35850. */
  35851. getFacetLocalPositions(): Vector3[];
  35852. /**
  35853. * Returns the facetLocalPartioning array
  35854. * @returns an array of array of numbers
  35855. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35856. */
  35857. getFacetLocalPartitioning(): number[][];
  35858. /**
  35859. * Returns the i-th facet position in the world system.
  35860. * This method allocates a new Vector3 per call
  35861. * @param i defines the facet index
  35862. * @returns a new Vector3
  35863. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35864. */
  35865. getFacetPosition(i: number): Vector3;
  35866. /**
  35867. * Sets the reference Vector3 with the i-th facet position in the world system
  35868. * @param i defines the facet index
  35869. * @param ref defines the target vector
  35870. * @returns the current mesh
  35871. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35872. */
  35873. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35874. /**
  35875. * Returns the i-th facet normal in the world system.
  35876. * This method allocates a new Vector3 per call
  35877. * @param i defines the facet index
  35878. * @returns a new Vector3
  35879. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35880. */
  35881. getFacetNormal(i: number): Vector3;
  35882. /**
  35883. * Sets the reference Vector3 with the i-th facet normal in the world system
  35884. * @param i defines the facet index
  35885. * @param ref defines the target vector
  35886. * @returns the current mesh
  35887. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35888. */
  35889. getFacetNormalToRef(i: number, ref: Vector3): this;
  35890. /**
  35891. * 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)
  35892. * @param x defines x coordinate
  35893. * @param y defines y coordinate
  35894. * @param z defines z coordinate
  35895. * @returns the array of facet indexes
  35896. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35897. */
  35898. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35899. /**
  35900. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35901. * @param projected sets as the (x,y,z) world projection on the facet
  35902. * @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
  35903. * @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
  35904. * @param x defines x coordinate
  35905. * @param y defines y coordinate
  35906. * @param z defines z coordinate
  35907. * @returns the face index if found (or null instead)
  35908. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35909. */
  35910. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35911. /**
  35912. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35913. * @param projected sets as the (x,y,z) local projection on the facet
  35914. * @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
  35915. * @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
  35916. * @param x defines x coordinate
  35917. * @param y defines y coordinate
  35918. * @param z defines z coordinate
  35919. * @returns the face index if found (or null instead)
  35920. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35921. */
  35922. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35923. /**
  35924. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35925. * @returns the parameters
  35926. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35927. */
  35928. getFacetDataParameters(): any;
  35929. /**
  35930. * Disables the feature FacetData and frees the related memory
  35931. * @returns the current mesh
  35932. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35933. */
  35934. disableFacetData(): AbstractMesh;
  35935. /**
  35936. * Updates the AbstractMesh indices array
  35937. * @param indices defines the data source
  35938. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35939. * @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)
  35940. * @returns the current mesh
  35941. */
  35942. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35943. /**
  35944. * Creates new normals data for the mesh
  35945. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35946. * @returns the current mesh
  35947. */
  35948. createNormals(updatable: boolean): AbstractMesh;
  35949. /**
  35950. * Align the mesh with a normal
  35951. * @param normal defines the normal to use
  35952. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35953. * @returns the current mesh
  35954. */
  35955. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35956. /** @hidden */
  35957. _checkOcclusionQuery(): boolean;
  35958. /**
  35959. * Disables the mesh edge rendering mode
  35960. * @returns the currentAbstractMesh
  35961. */
  35962. disableEdgesRendering(): AbstractMesh;
  35963. /**
  35964. * Enables the edge rendering mode on the mesh.
  35965. * This mode makes the mesh edges visible
  35966. * @param epsilon defines the maximal distance between two angles to detect a face
  35967. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35968. * @param options options to the edge renderer
  35969. * @returns the currentAbstractMesh
  35970. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35971. */
  35972. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  35973. /**
  35974. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35975. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35976. */
  35977. getConnectedParticleSystems(): IParticleSystem[];
  35978. }
  35979. }
  35980. declare module BABYLON {
  35981. /**
  35982. * Interface used to define ActionEvent
  35983. */
  35984. export interface IActionEvent {
  35985. /** The mesh or sprite that triggered the action */
  35986. source: any;
  35987. /** The X mouse cursor position at the time of the event */
  35988. pointerX: number;
  35989. /** The Y mouse cursor position at the time of the event */
  35990. pointerY: number;
  35991. /** The mesh that is currently pointed at (can be null) */
  35992. meshUnderPointer: Nullable<AbstractMesh>;
  35993. /** the original (browser) event that triggered the ActionEvent */
  35994. sourceEvent?: any;
  35995. /** additional data for the event */
  35996. additionalData?: any;
  35997. }
  35998. /**
  35999. * ActionEvent is the event being sent when an action is triggered.
  36000. */
  36001. export class ActionEvent implements IActionEvent {
  36002. /** The mesh or sprite that triggered the action */
  36003. source: any;
  36004. /** The X mouse cursor position at the time of the event */
  36005. pointerX: number;
  36006. /** The Y mouse cursor position at the time of the event */
  36007. pointerY: number;
  36008. /** The mesh that is currently pointed at (can be null) */
  36009. meshUnderPointer: Nullable<AbstractMesh>;
  36010. /** the original (browser) event that triggered the ActionEvent */
  36011. sourceEvent?: any;
  36012. /** additional data for the event */
  36013. additionalData?: any;
  36014. /**
  36015. * Creates a new ActionEvent
  36016. * @param source The mesh or sprite that triggered the action
  36017. * @param pointerX The X mouse cursor position at the time of the event
  36018. * @param pointerY The Y mouse cursor position at the time of the event
  36019. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36020. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36021. * @param additionalData additional data for the event
  36022. */
  36023. constructor(
  36024. /** The mesh or sprite that triggered the action */
  36025. source: any,
  36026. /** The X mouse cursor position at the time of the event */
  36027. pointerX: number,
  36028. /** The Y mouse cursor position at the time of the event */
  36029. pointerY: number,
  36030. /** The mesh that is currently pointed at (can be null) */
  36031. meshUnderPointer: Nullable<AbstractMesh>,
  36032. /** the original (browser) event that triggered the ActionEvent */
  36033. sourceEvent?: any,
  36034. /** additional data for the event */
  36035. additionalData?: any);
  36036. /**
  36037. * Helper function to auto-create an ActionEvent from a source mesh.
  36038. * @param source The source mesh that triggered the event
  36039. * @param evt The original (browser) event
  36040. * @param additionalData additional data for the event
  36041. * @returns the new ActionEvent
  36042. */
  36043. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36044. /**
  36045. * Helper function to auto-create an ActionEvent from a source sprite
  36046. * @param source The source sprite that triggered the event
  36047. * @param scene Scene associated with the sprite
  36048. * @param evt The original (browser) event
  36049. * @param additionalData additional data for the event
  36050. * @returns the new ActionEvent
  36051. */
  36052. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36053. /**
  36054. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36055. * @param scene the scene where the event occurred
  36056. * @param evt The original (browser) event
  36057. * @returns the new ActionEvent
  36058. */
  36059. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36060. /**
  36061. * Helper function to auto-create an ActionEvent from a primitive
  36062. * @param prim defines the target primitive
  36063. * @param pointerPos defines the pointer position
  36064. * @param evt The original (browser) event
  36065. * @param additionalData additional data for the event
  36066. * @returns the new ActionEvent
  36067. */
  36068. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36069. }
  36070. }
  36071. declare module BABYLON {
  36072. /**
  36073. * Abstract class used to decouple action Manager from scene and meshes.
  36074. * Do not instantiate.
  36075. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36076. */
  36077. export abstract class AbstractActionManager implements IDisposable {
  36078. /** Gets the list of active triggers */
  36079. static Triggers: {
  36080. [key: string]: number;
  36081. };
  36082. /** Gets the cursor to use when hovering items */
  36083. hoverCursor: string;
  36084. /** Gets the list of actions */
  36085. actions: IAction[];
  36086. /**
  36087. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36088. */
  36089. isRecursive: boolean;
  36090. /**
  36091. * Releases all associated resources
  36092. */
  36093. abstract dispose(): void;
  36094. /**
  36095. * Does this action manager has pointer triggers
  36096. */
  36097. abstract get hasPointerTriggers(): boolean;
  36098. /**
  36099. * Does this action manager has pick triggers
  36100. */
  36101. abstract get hasPickTriggers(): boolean;
  36102. /**
  36103. * Process a specific trigger
  36104. * @param trigger defines the trigger to process
  36105. * @param evt defines the event details to be processed
  36106. */
  36107. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36108. /**
  36109. * Does this action manager handles actions of any of the given triggers
  36110. * @param triggers defines the triggers to be tested
  36111. * @return a boolean indicating whether one (or more) of the triggers is handled
  36112. */
  36113. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36114. /**
  36115. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36116. * speed.
  36117. * @param triggerA defines the trigger to be tested
  36118. * @param triggerB defines the trigger to be tested
  36119. * @return a boolean indicating whether one (or more) of the triggers is handled
  36120. */
  36121. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36122. /**
  36123. * Does this action manager handles actions of a given trigger
  36124. * @param trigger defines the trigger to be tested
  36125. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36126. * @return whether the trigger is handled
  36127. */
  36128. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36129. /**
  36130. * Serialize this manager to a JSON object
  36131. * @param name defines the property name to store this manager
  36132. * @returns a JSON representation of this manager
  36133. */
  36134. abstract serialize(name: string): any;
  36135. /**
  36136. * Registers an action to this action manager
  36137. * @param action defines the action to be registered
  36138. * @return the action amended (prepared) after registration
  36139. */
  36140. abstract registerAction(action: IAction): Nullable<IAction>;
  36141. /**
  36142. * Unregisters an action to this action manager
  36143. * @param action defines the action to be unregistered
  36144. * @return a boolean indicating whether the action has been unregistered
  36145. */
  36146. abstract unregisterAction(action: IAction): Boolean;
  36147. /**
  36148. * Does exist one action manager with at least one trigger
  36149. **/
  36150. static get HasTriggers(): boolean;
  36151. /**
  36152. * Does exist one action manager with at least one pick trigger
  36153. **/
  36154. static get HasPickTriggers(): boolean;
  36155. /**
  36156. * Does exist one action manager that handles actions of a given trigger
  36157. * @param trigger defines the trigger to be tested
  36158. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36159. **/
  36160. static HasSpecificTrigger(trigger: number): boolean;
  36161. }
  36162. }
  36163. declare module BABYLON {
  36164. /**
  36165. * Defines how a node can be built from a string name.
  36166. */
  36167. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36168. /**
  36169. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36170. */
  36171. export class Node implements IBehaviorAware<Node> {
  36172. /** @hidden */
  36173. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36174. private static _NodeConstructors;
  36175. /**
  36176. * Add a new node constructor
  36177. * @param type defines the type name of the node to construct
  36178. * @param constructorFunc defines the constructor function
  36179. */
  36180. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36181. /**
  36182. * Returns a node constructor based on type name
  36183. * @param type defines the type name
  36184. * @param name defines the new node name
  36185. * @param scene defines the hosting scene
  36186. * @param options defines optional options to transmit to constructors
  36187. * @returns the new constructor or null
  36188. */
  36189. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36190. /**
  36191. * Gets or sets the name of the node
  36192. */
  36193. name: string;
  36194. /**
  36195. * Gets or sets the id of the node
  36196. */
  36197. id: string;
  36198. /**
  36199. * Gets or sets the unique id of the node
  36200. */
  36201. uniqueId: number;
  36202. /**
  36203. * Gets or sets a string used to store user defined state for the node
  36204. */
  36205. state: string;
  36206. /**
  36207. * Gets or sets an object used to store user defined information for the node
  36208. */
  36209. metadata: any;
  36210. /**
  36211. * For internal use only. Please do not use.
  36212. */
  36213. reservedDataStore: any;
  36214. /**
  36215. * List of inspectable custom properties (used by the Inspector)
  36216. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36217. */
  36218. inspectableCustomProperties: IInspectable[];
  36219. private _doNotSerialize;
  36220. /**
  36221. * Gets or sets a boolean used to define if the node must be serialized
  36222. */
  36223. get doNotSerialize(): boolean;
  36224. set doNotSerialize(value: boolean);
  36225. /** @hidden */
  36226. _isDisposed: boolean;
  36227. /**
  36228. * Gets a list of Animations associated with the node
  36229. */
  36230. animations: Animation[];
  36231. protected _ranges: {
  36232. [name: string]: Nullable<AnimationRange>;
  36233. };
  36234. /**
  36235. * Callback raised when the node is ready to be used
  36236. */
  36237. onReady: Nullable<(node: Node) => void>;
  36238. private _isEnabled;
  36239. private _isParentEnabled;
  36240. private _isReady;
  36241. /** @hidden */
  36242. _currentRenderId: number;
  36243. private _parentUpdateId;
  36244. /** @hidden */
  36245. _childUpdateId: number;
  36246. /** @hidden */
  36247. _waitingParentId: Nullable<string>;
  36248. /** @hidden */
  36249. _scene: Scene;
  36250. /** @hidden */
  36251. _cache: any;
  36252. private _parentNode;
  36253. private _children;
  36254. /** @hidden */
  36255. _worldMatrix: Matrix;
  36256. /** @hidden */
  36257. _worldMatrixDeterminant: number;
  36258. /** @hidden */
  36259. _worldMatrixDeterminantIsDirty: boolean;
  36260. /** @hidden */
  36261. private _sceneRootNodesIndex;
  36262. /**
  36263. * Gets a boolean indicating if the node has been disposed
  36264. * @returns true if the node was disposed
  36265. */
  36266. isDisposed(): boolean;
  36267. /**
  36268. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36269. * @see https://doc.babylonjs.com/how_to/parenting
  36270. */
  36271. set parent(parent: Nullable<Node>);
  36272. get parent(): Nullable<Node>;
  36273. /** @hidden */
  36274. _addToSceneRootNodes(): void;
  36275. /** @hidden */
  36276. _removeFromSceneRootNodes(): void;
  36277. private _animationPropertiesOverride;
  36278. /**
  36279. * Gets or sets the animation properties override
  36280. */
  36281. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36282. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36283. /**
  36284. * Gets a string identifying the name of the class
  36285. * @returns "Node" string
  36286. */
  36287. getClassName(): string;
  36288. /** @hidden */
  36289. readonly _isNode: boolean;
  36290. /**
  36291. * An event triggered when the mesh is disposed
  36292. */
  36293. onDisposeObservable: Observable<Node>;
  36294. private _onDisposeObserver;
  36295. /**
  36296. * Sets a callback that will be raised when the node will be disposed
  36297. */
  36298. set onDispose(callback: () => void);
  36299. /**
  36300. * Creates a new Node
  36301. * @param name the name and id to be given to this node
  36302. * @param scene the scene this node will be added to
  36303. */
  36304. constructor(name: string, scene?: Nullable<Scene>);
  36305. /**
  36306. * Gets the scene of the node
  36307. * @returns a scene
  36308. */
  36309. getScene(): Scene;
  36310. /**
  36311. * Gets the engine of the node
  36312. * @returns a Engine
  36313. */
  36314. getEngine(): Engine;
  36315. private _behaviors;
  36316. /**
  36317. * Attach a behavior to the node
  36318. * @see https://doc.babylonjs.com/features/behaviour
  36319. * @param behavior defines the behavior to attach
  36320. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36321. * @returns the current Node
  36322. */
  36323. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36324. /**
  36325. * Remove an attached behavior
  36326. * @see https://doc.babylonjs.com/features/behaviour
  36327. * @param behavior defines the behavior to attach
  36328. * @returns the current Node
  36329. */
  36330. removeBehavior(behavior: Behavior<Node>): Node;
  36331. /**
  36332. * Gets the list of attached behaviors
  36333. * @see https://doc.babylonjs.com/features/behaviour
  36334. */
  36335. get behaviors(): Behavior<Node>[];
  36336. /**
  36337. * Gets an attached behavior by name
  36338. * @param name defines the name of the behavior to look for
  36339. * @see https://doc.babylonjs.com/features/behaviour
  36340. * @returns null if behavior was not found else the requested behavior
  36341. */
  36342. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36343. /**
  36344. * Returns the latest update of the World matrix
  36345. * @returns a Matrix
  36346. */
  36347. getWorldMatrix(): Matrix;
  36348. /** @hidden */
  36349. _getWorldMatrixDeterminant(): number;
  36350. /**
  36351. * Returns directly the latest state of the mesh World matrix.
  36352. * A Matrix is returned.
  36353. */
  36354. get worldMatrixFromCache(): Matrix;
  36355. /** @hidden */
  36356. _initCache(): void;
  36357. /** @hidden */
  36358. updateCache(force?: boolean): void;
  36359. /** @hidden */
  36360. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36361. /** @hidden */
  36362. _updateCache(ignoreParentClass?: boolean): void;
  36363. /** @hidden */
  36364. _isSynchronized(): boolean;
  36365. /** @hidden */
  36366. _markSyncedWithParent(): void;
  36367. /** @hidden */
  36368. isSynchronizedWithParent(): boolean;
  36369. /** @hidden */
  36370. isSynchronized(): boolean;
  36371. /**
  36372. * Is this node ready to be used/rendered
  36373. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36374. * @return true if the node is ready
  36375. */
  36376. isReady(completeCheck?: boolean): boolean;
  36377. /**
  36378. * Is this node enabled?
  36379. * 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
  36380. * @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
  36381. * @return whether this node (and its parent) is enabled
  36382. */
  36383. isEnabled(checkAncestors?: boolean): boolean;
  36384. /** @hidden */
  36385. protected _syncParentEnabledState(): void;
  36386. /**
  36387. * Set the enabled state of this node
  36388. * @param value defines the new enabled state
  36389. */
  36390. setEnabled(value: boolean): void;
  36391. /**
  36392. * Is this node a descendant of the given node?
  36393. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36394. * @param ancestor defines the parent node to inspect
  36395. * @returns a boolean indicating if this node is a descendant of the given node
  36396. */
  36397. isDescendantOf(ancestor: Node): boolean;
  36398. /** @hidden */
  36399. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36400. /**
  36401. * Will return all nodes that have this node as ascendant
  36402. * @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
  36403. * @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
  36404. * @return all children nodes of all types
  36405. */
  36406. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36407. /**
  36408. * Get all child-meshes of this node
  36409. * @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)
  36410. * @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
  36411. * @returns an array of AbstractMesh
  36412. */
  36413. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36414. /**
  36415. * Get all direct children of this node
  36416. * @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
  36417. * @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)
  36418. * @returns an array of Node
  36419. */
  36420. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36421. /** @hidden */
  36422. _setReady(state: boolean): void;
  36423. /**
  36424. * Get an animation by name
  36425. * @param name defines the name of the animation to look for
  36426. * @returns null if not found else the requested animation
  36427. */
  36428. getAnimationByName(name: string): Nullable<Animation>;
  36429. /**
  36430. * Creates an animation range for this node
  36431. * @param name defines the name of the range
  36432. * @param from defines the starting key
  36433. * @param to defines the end key
  36434. */
  36435. createAnimationRange(name: string, from: number, to: number): void;
  36436. /**
  36437. * Delete a specific animation range
  36438. * @param name defines the name of the range to delete
  36439. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36440. */
  36441. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36442. /**
  36443. * Get an animation range by name
  36444. * @param name defines the name of the animation range to look for
  36445. * @returns null if not found else the requested animation range
  36446. */
  36447. getAnimationRange(name: string): Nullable<AnimationRange>;
  36448. /**
  36449. * Gets the list of all animation ranges defined on this node
  36450. * @returns an array
  36451. */
  36452. getAnimationRanges(): Nullable<AnimationRange>[];
  36453. /**
  36454. * Will start the animation sequence
  36455. * @param name defines the range frames for animation sequence
  36456. * @param loop defines if the animation should loop (false by default)
  36457. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36458. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36459. * @returns the object created for this animation. If range does not exist, it will return null
  36460. */
  36461. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36462. /**
  36463. * Serialize animation ranges into a JSON compatible object
  36464. * @returns serialization object
  36465. */
  36466. serializeAnimationRanges(): any;
  36467. /**
  36468. * Computes the world matrix of the node
  36469. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36470. * @returns the world matrix
  36471. */
  36472. computeWorldMatrix(force?: boolean): Matrix;
  36473. /**
  36474. * Releases resources associated with this node.
  36475. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36476. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36477. */
  36478. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36479. /**
  36480. * Parse animation range data from a serialization object and store them into a given node
  36481. * @param node defines where to store the animation ranges
  36482. * @param parsedNode defines the serialization object to read data from
  36483. * @param scene defines the hosting scene
  36484. */
  36485. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36486. /**
  36487. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36488. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36489. * @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
  36490. * @returns the new bounding vectors
  36491. */
  36492. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36493. min: Vector3;
  36494. max: Vector3;
  36495. };
  36496. }
  36497. }
  36498. declare module BABYLON {
  36499. /**
  36500. * @hidden
  36501. */
  36502. export class _IAnimationState {
  36503. key: number;
  36504. repeatCount: number;
  36505. workValue?: any;
  36506. loopMode?: number;
  36507. offsetValue?: any;
  36508. highLimitValue?: any;
  36509. }
  36510. /**
  36511. * Class used to store any kind of animation
  36512. */
  36513. export class Animation {
  36514. /**Name of the animation */
  36515. name: string;
  36516. /**Property to animate */
  36517. targetProperty: string;
  36518. /**The frames per second of the animation */
  36519. framePerSecond: number;
  36520. /**The data type of the animation */
  36521. dataType: number;
  36522. /**The loop mode of the animation */
  36523. loopMode?: number | undefined;
  36524. /**Specifies if blending should be enabled */
  36525. enableBlending?: boolean | undefined;
  36526. /**
  36527. * Use matrix interpolation instead of using direct key value when animating matrices
  36528. */
  36529. static AllowMatricesInterpolation: boolean;
  36530. /**
  36531. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36532. */
  36533. static AllowMatrixDecomposeForInterpolation: boolean;
  36534. /** Define the Url to load snippets */
  36535. static SnippetUrl: string;
  36536. /** Snippet ID if the animation was created from the snippet server */
  36537. snippetId: string;
  36538. /**
  36539. * Stores the key frames of the animation
  36540. */
  36541. private _keys;
  36542. /**
  36543. * Stores the easing function of the animation
  36544. */
  36545. private _easingFunction;
  36546. /**
  36547. * @hidden Internal use only
  36548. */
  36549. _runtimeAnimations: RuntimeAnimation[];
  36550. /**
  36551. * The set of event that will be linked to this animation
  36552. */
  36553. private _events;
  36554. /**
  36555. * Stores an array of target property paths
  36556. */
  36557. targetPropertyPath: string[];
  36558. /**
  36559. * Stores the blending speed of the animation
  36560. */
  36561. blendingSpeed: number;
  36562. /**
  36563. * Stores the animation ranges for the animation
  36564. */
  36565. private _ranges;
  36566. /**
  36567. * @hidden Internal use
  36568. */
  36569. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36570. /**
  36571. * Sets up an animation
  36572. * @param property The property to animate
  36573. * @param animationType The animation type to apply
  36574. * @param framePerSecond The frames per second of the animation
  36575. * @param easingFunction The easing function used in the animation
  36576. * @returns The created animation
  36577. */
  36578. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36579. /**
  36580. * Create and start an animation on a node
  36581. * @param name defines the name of the global animation that will be run on all nodes
  36582. * @param node defines the root node where the animation will take place
  36583. * @param targetProperty defines property to animate
  36584. * @param framePerSecond defines the number of frame per second yo use
  36585. * @param totalFrame defines the number of frames in total
  36586. * @param from defines the initial value
  36587. * @param to defines the final value
  36588. * @param loopMode defines which loop mode you want to use (off by default)
  36589. * @param easingFunction defines the easing function to use (linear by default)
  36590. * @param onAnimationEnd defines the callback to call when animation end
  36591. * @returns the animatable created for this animation
  36592. */
  36593. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36594. /**
  36595. * Create and start an animation on a node and its descendants
  36596. * @param name defines the name of the global animation that will be run on all nodes
  36597. * @param node defines the root node where the animation will take place
  36598. * @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
  36599. * @param targetProperty defines property to animate
  36600. * @param framePerSecond defines the number of frame per second to use
  36601. * @param totalFrame defines the number of frames in total
  36602. * @param from defines the initial value
  36603. * @param to defines the final value
  36604. * @param loopMode defines which loop mode you want to use (off by default)
  36605. * @param easingFunction defines the easing function to use (linear by default)
  36606. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36607. * @returns the list of animatables created for all nodes
  36608. * @example https://www.babylonjs-playground.com/#MH0VLI
  36609. */
  36610. 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[]>;
  36611. /**
  36612. * Creates a new animation, merges it with the existing animations and starts it
  36613. * @param name Name of the animation
  36614. * @param node Node which contains the scene that begins the animations
  36615. * @param targetProperty Specifies which property to animate
  36616. * @param framePerSecond The frames per second of the animation
  36617. * @param totalFrame The total number of frames
  36618. * @param from The frame at the beginning of the animation
  36619. * @param to The frame at the end of the animation
  36620. * @param loopMode Specifies the loop mode of the animation
  36621. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36622. * @param onAnimationEnd Callback to run once the animation is complete
  36623. * @returns Nullable animation
  36624. */
  36625. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36626. /**
  36627. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36628. * @param sourceAnimation defines the Animation containing keyframes to convert
  36629. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36630. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36631. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36632. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36633. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36634. */
  36635. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36636. /**
  36637. * Transition property of an host to the target Value
  36638. * @param property The property to transition
  36639. * @param targetValue The target Value of the property
  36640. * @param host The object where the property to animate belongs
  36641. * @param scene Scene used to run the animation
  36642. * @param frameRate Framerate (in frame/s) to use
  36643. * @param transition The transition type we want to use
  36644. * @param duration The duration of the animation, in milliseconds
  36645. * @param onAnimationEnd Callback trigger at the end of the animation
  36646. * @returns Nullable animation
  36647. */
  36648. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36649. /**
  36650. * Return the array of runtime animations currently using this animation
  36651. */
  36652. get runtimeAnimations(): RuntimeAnimation[];
  36653. /**
  36654. * Specifies if any of the runtime animations are currently running
  36655. */
  36656. get hasRunningRuntimeAnimations(): boolean;
  36657. /**
  36658. * Initializes the animation
  36659. * @param name Name of the animation
  36660. * @param targetProperty Property to animate
  36661. * @param framePerSecond The frames per second of the animation
  36662. * @param dataType The data type of the animation
  36663. * @param loopMode The loop mode of the animation
  36664. * @param enableBlending Specifies if blending should be enabled
  36665. */
  36666. constructor(
  36667. /**Name of the animation */
  36668. name: string,
  36669. /**Property to animate */
  36670. targetProperty: string,
  36671. /**The frames per second of the animation */
  36672. framePerSecond: number,
  36673. /**The data type of the animation */
  36674. dataType: number,
  36675. /**The loop mode of the animation */
  36676. loopMode?: number | undefined,
  36677. /**Specifies if blending should be enabled */
  36678. enableBlending?: boolean | undefined);
  36679. /**
  36680. * Converts the animation to a string
  36681. * @param fullDetails support for multiple levels of logging within scene loading
  36682. * @returns String form of the animation
  36683. */
  36684. toString(fullDetails?: boolean): string;
  36685. /**
  36686. * Add an event to this animation
  36687. * @param event Event to add
  36688. */
  36689. addEvent(event: AnimationEvent): void;
  36690. /**
  36691. * Remove all events found at the given frame
  36692. * @param frame The frame to remove events from
  36693. */
  36694. removeEvents(frame: number): void;
  36695. /**
  36696. * Retrieves all the events from the animation
  36697. * @returns Events from the animation
  36698. */
  36699. getEvents(): AnimationEvent[];
  36700. /**
  36701. * Creates an animation range
  36702. * @param name Name of the animation range
  36703. * @param from Starting frame of the animation range
  36704. * @param to Ending frame of the animation
  36705. */
  36706. createRange(name: string, from: number, to: number): void;
  36707. /**
  36708. * Deletes an animation range by name
  36709. * @param name Name of the animation range to delete
  36710. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36711. */
  36712. deleteRange(name: string, deleteFrames?: boolean): void;
  36713. /**
  36714. * Gets the animation range by name, or null if not defined
  36715. * @param name Name of the animation range
  36716. * @returns Nullable animation range
  36717. */
  36718. getRange(name: string): Nullable<AnimationRange>;
  36719. /**
  36720. * Gets the key frames from the animation
  36721. * @returns The key frames of the animation
  36722. */
  36723. getKeys(): Array<IAnimationKey>;
  36724. /**
  36725. * Gets the highest frame rate of the animation
  36726. * @returns Highest frame rate of the animation
  36727. */
  36728. getHighestFrame(): number;
  36729. /**
  36730. * Gets the easing function of the animation
  36731. * @returns Easing function of the animation
  36732. */
  36733. getEasingFunction(): IEasingFunction;
  36734. /**
  36735. * Sets the easing function of the animation
  36736. * @param easingFunction A custom mathematical formula for animation
  36737. */
  36738. setEasingFunction(easingFunction: EasingFunction): void;
  36739. /**
  36740. * Interpolates a scalar linearly
  36741. * @param startValue Start value of the animation curve
  36742. * @param endValue End value of the animation curve
  36743. * @param gradient Scalar amount to interpolate
  36744. * @returns Interpolated scalar value
  36745. */
  36746. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36747. /**
  36748. * Interpolates a scalar cubically
  36749. * @param startValue Start value of the animation curve
  36750. * @param outTangent End tangent of the animation
  36751. * @param endValue End value of the animation curve
  36752. * @param inTangent Start tangent of the animation curve
  36753. * @param gradient Scalar amount to interpolate
  36754. * @returns Interpolated scalar value
  36755. */
  36756. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36757. /**
  36758. * Interpolates a quaternion using a spherical linear interpolation
  36759. * @param startValue Start value of the animation curve
  36760. * @param endValue End value of the animation curve
  36761. * @param gradient Scalar amount to interpolate
  36762. * @returns Interpolated quaternion value
  36763. */
  36764. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36765. /**
  36766. * Interpolates a quaternion cubically
  36767. * @param startValue Start value of the animation curve
  36768. * @param outTangent End tangent of the animation curve
  36769. * @param endValue End value of the animation curve
  36770. * @param inTangent Start tangent of the animation curve
  36771. * @param gradient Scalar amount to interpolate
  36772. * @returns Interpolated quaternion value
  36773. */
  36774. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36775. /**
  36776. * Interpolates a Vector3 linearl
  36777. * @param startValue Start value of the animation curve
  36778. * @param endValue End value of the animation curve
  36779. * @param gradient Scalar amount to interpolate
  36780. * @returns Interpolated scalar value
  36781. */
  36782. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36783. /**
  36784. * Interpolates a Vector3 cubically
  36785. * @param startValue Start value of the animation curve
  36786. * @param outTangent End tangent of the animation
  36787. * @param endValue End value of the animation curve
  36788. * @param inTangent Start tangent of the animation curve
  36789. * @param gradient Scalar amount to interpolate
  36790. * @returns InterpolatedVector3 value
  36791. */
  36792. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36793. /**
  36794. * Interpolates a Vector2 linearly
  36795. * @param startValue Start value of the animation curve
  36796. * @param endValue End value of the animation curve
  36797. * @param gradient Scalar amount to interpolate
  36798. * @returns Interpolated Vector2 value
  36799. */
  36800. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36801. /**
  36802. * Interpolates a Vector2 cubically
  36803. * @param startValue Start value of the animation curve
  36804. * @param outTangent End tangent of the animation
  36805. * @param endValue End value of the animation curve
  36806. * @param inTangent Start tangent of the animation curve
  36807. * @param gradient Scalar amount to interpolate
  36808. * @returns Interpolated Vector2 value
  36809. */
  36810. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36811. /**
  36812. * Interpolates a size linearly
  36813. * @param startValue Start value of the animation curve
  36814. * @param endValue End value of the animation curve
  36815. * @param gradient Scalar amount to interpolate
  36816. * @returns Interpolated Size value
  36817. */
  36818. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36819. /**
  36820. * Interpolates a Color3 linearly
  36821. * @param startValue Start value of the animation curve
  36822. * @param endValue End value of the animation curve
  36823. * @param gradient Scalar amount to interpolate
  36824. * @returns Interpolated Color3 value
  36825. */
  36826. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36827. /**
  36828. * Interpolates a Color4 linearly
  36829. * @param startValue Start value of the animation curve
  36830. * @param endValue End value of the animation curve
  36831. * @param gradient Scalar amount to interpolate
  36832. * @returns Interpolated Color3 value
  36833. */
  36834. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36835. /**
  36836. * @hidden Internal use only
  36837. */
  36838. _getKeyValue(value: any): any;
  36839. /**
  36840. * @hidden Internal use only
  36841. */
  36842. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36843. /**
  36844. * Defines the function to use to interpolate matrices
  36845. * @param startValue defines the start matrix
  36846. * @param endValue defines the end matrix
  36847. * @param gradient defines the gradient between both matrices
  36848. * @param result defines an optional target matrix where to store the interpolation
  36849. * @returns the interpolated matrix
  36850. */
  36851. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36852. /**
  36853. * Makes a copy of the animation
  36854. * @returns Cloned animation
  36855. */
  36856. clone(): Animation;
  36857. /**
  36858. * Sets the key frames of the animation
  36859. * @param values The animation key frames to set
  36860. */
  36861. setKeys(values: Array<IAnimationKey>): void;
  36862. /**
  36863. * Serializes the animation to an object
  36864. * @returns Serialized object
  36865. */
  36866. serialize(): any;
  36867. /**
  36868. * Float animation type
  36869. */
  36870. static readonly ANIMATIONTYPE_FLOAT: number;
  36871. /**
  36872. * Vector3 animation type
  36873. */
  36874. static readonly ANIMATIONTYPE_VECTOR3: number;
  36875. /**
  36876. * Quaternion animation type
  36877. */
  36878. static readonly ANIMATIONTYPE_QUATERNION: number;
  36879. /**
  36880. * Matrix animation type
  36881. */
  36882. static readonly ANIMATIONTYPE_MATRIX: number;
  36883. /**
  36884. * Color3 animation type
  36885. */
  36886. static readonly ANIMATIONTYPE_COLOR3: number;
  36887. /**
  36888. * Color3 animation type
  36889. */
  36890. static readonly ANIMATIONTYPE_COLOR4: number;
  36891. /**
  36892. * Vector2 animation type
  36893. */
  36894. static readonly ANIMATIONTYPE_VECTOR2: number;
  36895. /**
  36896. * Size animation type
  36897. */
  36898. static readonly ANIMATIONTYPE_SIZE: number;
  36899. /**
  36900. * Relative Loop Mode
  36901. */
  36902. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36903. /**
  36904. * Cycle Loop Mode
  36905. */
  36906. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36907. /**
  36908. * Constant Loop Mode
  36909. */
  36910. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36911. /** @hidden */
  36912. static _UniversalLerp(left: any, right: any, amount: number): any;
  36913. /**
  36914. * Parses an animation object and creates an animation
  36915. * @param parsedAnimation Parsed animation object
  36916. * @returns Animation object
  36917. */
  36918. static Parse(parsedAnimation: any): Animation;
  36919. /**
  36920. * Appends the serialized animations from the source animations
  36921. * @param source Source containing the animations
  36922. * @param destination Target to store the animations
  36923. */
  36924. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36925. /**
  36926. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36927. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36928. * @param url defines the url to load from
  36929. * @returns a promise that will resolve to the new animation or an array of animations
  36930. */
  36931. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36932. /**
  36933. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36934. * @param snippetId defines the snippet to load
  36935. * @returns a promise that will resolve to the new animation or a new array of animations
  36936. */
  36937. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36938. }
  36939. }
  36940. declare module BABYLON {
  36941. /**
  36942. * Interface containing an array of animations
  36943. */
  36944. export interface IAnimatable {
  36945. /**
  36946. * Array of animations
  36947. */
  36948. animations: Nullable<Array<Animation>>;
  36949. }
  36950. }
  36951. declare module BABYLON {
  36952. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36953. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36954. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36955. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36956. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36957. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36958. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36959. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36960. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36961. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36962. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36963. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36964. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36965. /**
  36966. * Decorator used to define property that can be serialized as reference to a camera
  36967. * @param sourceName defines the name of the property to decorate
  36968. */
  36969. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36970. /**
  36971. * Class used to help serialization objects
  36972. */
  36973. export class SerializationHelper {
  36974. /** @hidden */
  36975. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36976. /** @hidden */
  36977. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36978. /** @hidden */
  36979. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36980. /** @hidden */
  36981. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36982. /**
  36983. * Appends the serialized animations from the source animations
  36984. * @param source Source containing the animations
  36985. * @param destination Target to store the animations
  36986. */
  36987. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36988. /**
  36989. * Static function used to serialized a specific entity
  36990. * @param entity defines the entity to serialize
  36991. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36992. * @returns a JSON compatible object representing the serialization of the entity
  36993. */
  36994. static Serialize<T>(entity: T, serializationObject?: any): any;
  36995. /**
  36996. * Creates a new entity from a serialization data object
  36997. * @param creationFunction defines a function used to instanciated the new entity
  36998. * @param source defines the source serialization data
  36999. * @param scene defines the hosting scene
  37000. * @param rootUrl defines the root url for resources
  37001. * @returns a new entity
  37002. */
  37003. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37004. /**
  37005. * Clones an object
  37006. * @param creationFunction defines the function used to instanciate the new object
  37007. * @param source defines the source object
  37008. * @returns the cloned object
  37009. */
  37010. static Clone<T>(creationFunction: () => T, source: T): T;
  37011. /**
  37012. * Instanciates a new object based on a source one (some data will be shared between both object)
  37013. * @param creationFunction defines the function used to instanciate the new object
  37014. * @param source defines the source object
  37015. * @returns the new object
  37016. */
  37017. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37018. }
  37019. }
  37020. declare module BABYLON {
  37021. /**
  37022. * This is the base class of all the camera used in the application.
  37023. * @see https://doc.babylonjs.com/features/cameras
  37024. */
  37025. export class Camera extends Node {
  37026. /** @hidden */
  37027. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  37028. /**
  37029. * This is the default projection mode used by the cameras.
  37030. * It helps recreating a feeling of perspective and better appreciate depth.
  37031. * This is the best way to simulate real life cameras.
  37032. */
  37033. static readonly PERSPECTIVE_CAMERA: number;
  37034. /**
  37035. * This helps creating camera with an orthographic mode.
  37036. * 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.
  37037. */
  37038. static readonly ORTHOGRAPHIC_CAMERA: number;
  37039. /**
  37040. * This is the default FOV mode for perspective cameras.
  37041. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37042. */
  37043. static readonly FOVMODE_VERTICAL_FIXED: number;
  37044. /**
  37045. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37046. */
  37047. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37048. /**
  37049. * This specifies ther is no need for a camera rig.
  37050. * Basically only one eye is rendered corresponding to the camera.
  37051. */
  37052. static readonly RIG_MODE_NONE: number;
  37053. /**
  37054. * Simulates a camera Rig with one blue eye and one red eye.
  37055. * This can be use with 3d blue and red glasses.
  37056. */
  37057. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37058. /**
  37059. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37060. */
  37061. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37062. /**
  37063. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37064. */
  37065. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37066. /**
  37067. * Defines that both eyes of the camera will be rendered over under each other.
  37068. */
  37069. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37070. /**
  37071. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37072. */
  37073. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37074. /**
  37075. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37076. */
  37077. static readonly RIG_MODE_VR: number;
  37078. /**
  37079. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37080. */
  37081. static readonly RIG_MODE_WEBVR: number;
  37082. /**
  37083. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37084. */
  37085. static readonly RIG_MODE_CUSTOM: number;
  37086. /**
  37087. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37088. */
  37089. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37090. /**
  37091. * Define the input manager associated with the camera.
  37092. */
  37093. inputs: CameraInputsManager<Camera>;
  37094. /** @hidden */
  37095. _position: Vector3;
  37096. /**
  37097. * Define the current local position of the camera in the scene
  37098. */
  37099. get position(): Vector3;
  37100. set position(newPosition: Vector3);
  37101. protected _upVector: Vector3;
  37102. /**
  37103. * The vector the camera should consider as up.
  37104. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37105. */
  37106. set upVector(vec: Vector3);
  37107. get upVector(): Vector3;
  37108. /**
  37109. * Define the current limit on the left side for an orthographic camera
  37110. * In scene unit
  37111. */
  37112. orthoLeft: Nullable<number>;
  37113. /**
  37114. * Define the current limit on the right side for an orthographic camera
  37115. * In scene unit
  37116. */
  37117. orthoRight: Nullable<number>;
  37118. /**
  37119. * Define the current limit on the bottom side for an orthographic camera
  37120. * In scene unit
  37121. */
  37122. orthoBottom: Nullable<number>;
  37123. /**
  37124. * Define the current limit on the top side for an orthographic camera
  37125. * In scene unit
  37126. */
  37127. orthoTop: Nullable<number>;
  37128. /**
  37129. * Field Of View is set in Radians. (default is 0.8)
  37130. */
  37131. fov: number;
  37132. /**
  37133. * Define the minimum distance the camera can see from.
  37134. * This is important to note that the depth buffer are not infinite and the closer it starts
  37135. * the more your scene might encounter depth fighting issue.
  37136. */
  37137. minZ: number;
  37138. /**
  37139. * Define the maximum distance the camera can see to.
  37140. * This is important to note that the depth buffer are not infinite and the further it end
  37141. * the more your scene might encounter depth fighting issue.
  37142. */
  37143. maxZ: number;
  37144. /**
  37145. * Define the default inertia of the camera.
  37146. * This helps giving a smooth feeling to the camera movement.
  37147. */
  37148. inertia: number;
  37149. /**
  37150. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37151. */
  37152. mode: number;
  37153. /**
  37154. * Define whether the camera is intermediate.
  37155. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37156. */
  37157. isIntermediate: boolean;
  37158. /**
  37159. * Define the viewport of the camera.
  37160. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37161. */
  37162. viewport: Viewport;
  37163. /**
  37164. * Restricts the camera to viewing objects with the same layerMask.
  37165. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37166. */
  37167. layerMask: number;
  37168. /**
  37169. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37170. */
  37171. fovMode: number;
  37172. /**
  37173. * Rig mode of the camera.
  37174. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37175. * This is normally controlled byt the camera themselves as internal use.
  37176. */
  37177. cameraRigMode: number;
  37178. /**
  37179. * Defines the distance between both "eyes" in case of a RIG
  37180. */
  37181. interaxialDistance: number;
  37182. /**
  37183. * Defines if stereoscopic rendering is done side by side or over under.
  37184. */
  37185. isStereoscopicSideBySide: boolean;
  37186. /**
  37187. * 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
  37188. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37189. * else in the scene. (Eg. security camera)
  37190. *
  37191. * 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)
  37192. */
  37193. customRenderTargets: RenderTargetTexture[];
  37194. /**
  37195. * When set, the camera will render to this render target instead of the default canvas
  37196. *
  37197. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37198. */
  37199. outputRenderTarget: Nullable<RenderTargetTexture>;
  37200. /**
  37201. * Observable triggered when the camera view matrix has changed.
  37202. */
  37203. onViewMatrixChangedObservable: Observable<Camera>;
  37204. /**
  37205. * Observable triggered when the camera Projection matrix has changed.
  37206. */
  37207. onProjectionMatrixChangedObservable: Observable<Camera>;
  37208. /**
  37209. * Observable triggered when the inputs have been processed.
  37210. */
  37211. onAfterCheckInputsObservable: Observable<Camera>;
  37212. /**
  37213. * Observable triggered when reset has been called and applied to the camera.
  37214. */
  37215. onRestoreStateObservable: Observable<Camera>;
  37216. /**
  37217. * Is this camera a part of a rig system?
  37218. */
  37219. isRigCamera: boolean;
  37220. /**
  37221. * If isRigCamera set to true this will be set with the parent camera.
  37222. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37223. */
  37224. rigParent?: Camera;
  37225. /** @hidden */
  37226. _cameraRigParams: any;
  37227. /** @hidden */
  37228. _rigCameras: Camera[];
  37229. /** @hidden */
  37230. _rigPostProcess: Nullable<PostProcess>;
  37231. protected _webvrViewMatrix: Matrix;
  37232. /** @hidden */
  37233. _skipRendering: boolean;
  37234. /** @hidden */
  37235. _projectionMatrix: Matrix;
  37236. /** @hidden */
  37237. _postProcesses: Nullable<PostProcess>[];
  37238. /** @hidden */
  37239. _activeMeshes: SmartArray<AbstractMesh>;
  37240. protected _globalPosition: Vector3;
  37241. /** @hidden */
  37242. _computedViewMatrix: Matrix;
  37243. private _doNotComputeProjectionMatrix;
  37244. private _transformMatrix;
  37245. private _frustumPlanes;
  37246. private _refreshFrustumPlanes;
  37247. private _storedFov;
  37248. private _stateStored;
  37249. /**
  37250. * Instantiates a new camera object.
  37251. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37252. * @see https://doc.babylonjs.com/features/cameras
  37253. * @param name Defines the name of the camera in the scene
  37254. * @param position Defines the position of the camera
  37255. * @param scene Defines the scene the camera belongs too
  37256. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37257. */
  37258. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37259. /**
  37260. * Store current camera state (fov, position, etc..)
  37261. * @returns the camera
  37262. */
  37263. storeState(): Camera;
  37264. /**
  37265. * Restores the camera state values if it has been stored. You must call storeState() first
  37266. */
  37267. protected _restoreStateValues(): boolean;
  37268. /**
  37269. * Restored camera state. You must call storeState() first.
  37270. * @returns true if restored and false otherwise
  37271. */
  37272. restoreState(): boolean;
  37273. /**
  37274. * Gets the class name of the camera.
  37275. * @returns the class name
  37276. */
  37277. getClassName(): string;
  37278. /** @hidden */
  37279. readonly _isCamera: boolean;
  37280. /**
  37281. * Gets a string representation of the camera useful for debug purpose.
  37282. * @param fullDetails Defines that a more verboe level of logging is required
  37283. * @returns the string representation
  37284. */
  37285. toString(fullDetails?: boolean): string;
  37286. /**
  37287. * Gets the current world space position of the camera.
  37288. */
  37289. get globalPosition(): Vector3;
  37290. /**
  37291. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  37292. * @returns the active meshe list
  37293. */
  37294. getActiveMeshes(): SmartArray<AbstractMesh>;
  37295. /**
  37296. * Check whether a mesh is part of the current active mesh list of the camera
  37297. * @param mesh Defines the mesh to check
  37298. * @returns true if active, false otherwise
  37299. */
  37300. isActiveMesh(mesh: Mesh): boolean;
  37301. /**
  37302. * Is this camera ready to be used/rendered
  37303. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  37304. * @return true if the camera is ready
  37305. */
  37306. isReady(completeCheck?: boolean): boolean;
  37307. /** @hidden */
  37308. _initCache(): void;
  37309. /** @hidden */
  37310. _updateCache(ignoreParentClass?: boolean): void;
  37311. /** @hidden */
  37312. _isSynchronized(): boolean;
  37313. /** @hidden */
  37314. _isSynchronizedViewMatrix(): boolean;
  37315. /** @hidden */
  37316. _isSynchronizedProjectionMatrix(): boolean;
  37317. /**
  37318. * Attach the input controls to a specific dom element to get the input from.
  37319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37320. */
  37321. attachControl(noPreventDefault?: boolean): void;
  37322. /**
  37323. * Attach the input controls to a specific dom element to get the input from.
  37324. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  37325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37326. * BACK COMPAT SIGNATURE ONLY.
  37327. */
  37328. attachControl(ignored: any, noPreventDefault?: boolean): void;
  37329. /**
  37330. * Detach the current controls from the specified dom element.
  37331. */
  37332. detachControl(): void;
  37333. /**
  37334. * Detach the current controls from the specified dom element.
  37335. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  37336. */
  37337. detachControl(ignored: any): void;
  37338. /**
  37339. * Update the camera state according to the different inputs gathered during the frame.
  37340. */
  37341. update(): void;
  37342. /** @hidden */
  37343. _checkInputs(): void;
  37344. /** @hidden */
  37345. get rigCameras(): Camera[];
  37346. /**
  37347. * Gets the post process used by the rig cameras
  37348. */
  37349. get rigPostProcess(): Nullable<PostProcess>;
  37350. /**
  37351. * Internal, gets the first post proces.
  37352. * @returns the first post process to be run on this camera.
  37353. */
  37354. _getFirstPostProcess(): Nullable<PostProcess>;
  37355. private _cascadePostProcessesToRigCams;
  37356. /**
  37357. * Attach a post process to the camera.
  37358. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37359. * @param postProcess The post process to attach to the camera
  37360. * @param insertAt The position of the post process in case several of them are in use in the scene
  37361. * @returns the position the post process has been inserted at
  37362. */
  37363. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  37364. /**
  37365. * Detach a post process to the camera.
  37366. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37367. * @param postProcess The post process to detach from the camera
  37368. */
  37369. detachPostProcess(postProcess: PostProcess): void;
  37370. /**
  37371. * Gets the current world matrix of the camera
  37372. */
  37373. getWorldMatrix(): Matrix;
  37374. /** @hidden */
  37375. _getViewMatrix(): Matrix;
  37376. /**
  37377. * Gets the current view matrix of the camera.
  37378. * @param force forces the camera to recompute the matrix without looking at the cached state
  37379. * @returns the view matrix
  37380. */
  37381. getViewMatrix(force?: boolean): Matrix;
  37382. /**
  37383. * Freeze the projection matrix.
  37384. * It will prevent the cache check of the camera projection compute and can speed up perf
  37385. * if no parameter of the camera are meant to change
  37386. * @param projection Defines manually a projection if necessary
  37387. */
  37388. freezeProjectionMatrix(projection?: Matrix): void;
  37389. /**
  37390. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  37391. */
  37392. unfreezeProjectionMatrix(): void;
  37393. /**
  37394. * Gets the current projection matrix of the camera.
  37395. * @param force forces the camera to recompute the matrix without looking at the cached state
  37396. * @returns the projection matrix
  37397. */
  37398. getProjectionMatrix(force?: boolean): Matrix;
  37399. /**
  37400. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  37401. * @returns a Matrix
  37402. */
  37403. getTransformationMatrix(): Matrix;
  37404. private _updateFrustumPlanes;
  37405. /**
  37406. * Checks if a cullable object (mesh...) is in the camera frustum
  37407. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  37408. * @param target The object to check
  37409. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  37410. * @returns true if the object is in frustum otherwise false
  37411. */
  37412. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  37413. /**
  37414. * Checks if a cullable object (mesh...) is in the camera frustum
  37415. * Unlike isInFrustum this cheks the full bounding box
  37416. * @param target The object to check
  37417. * @returns true if the object is in frustum otherwise false
  37418. */
  37419. isCompletelyInFrustum(target: ICullable): boolean;
  37420. /**
  37421. * Gets a ray in the forward direction from the camera.
  37422. * @param length Defines the length of the ray to create
  37423. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37424. * @param origin Defines the start point of the ray which defaults to the camera position
  37425. * @returns the forward ray
  37426. */
  37427. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37428. /**
  37429. * Gets a ray in the forward direction from the camera.
  37430. * @param refRay the ray to (re)use when setting the values
  37431. * @param length Defines the length of the ray to create
  37432. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37433. * @param origin Defines the start point of the ray which defaults to the camera position
  37434. * @returns the forward ray
  37435. */
  37436. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37437. /**
  37438. * Releases resources associated with this node.
  37439. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37440. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37441. */
  37442. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37443. /** @hidden */
  37444. _isLeftCamera: boolean;
  37445. /**
  37446. * Gets the left camera of a rig setup in case of Rigged Camera
  37447. */
  37448. get isLeftCamera(): boolean;
  37449. /** @hidden */
  37450. _isRightCamera: boolean;
  37451. /**
  37452. * Gets the right camera of a rig setup in case of Rigged Camera
  37453. */
  37454. get isRightCamera(): boolean;
  37455. /**
  37456. * Gets the left camera of a rig setup in case of Rigged Camera
  37457. */
  37458. get leftCamera(): Nullable<FreeCamera>;
  37459. /**
  37460. * Gets the right camera of a rig setup in case of Rigged Camera
  37461. */
  37462. get rightCamera(): Nullable<FreeCamera>;
  37463. /**
  37464. * Gets the left camera target of a rig setup in case of Rigged Camera
  37465. * @returns the target position
  37466. */
  37467. getLeftTarget(): Nullable<Vector3>;
  37468. /**
  37469. * Gets the right camera target of a rig setup in case of Rigged Camera
  37470. * @returns the target position
  37471. */
  37472. getRightTarget(): Nullable<Vector3>;
  37473. /**
  37474. * @hidden
  37475. */
  37476. setCameraRigMode(mode: number, rigParams: any): void;
  37477. /** @hidden */
  37478. static _setStereoscopicRigMode(camera: Camera): void;
  37479. /** @hidden */
  37480. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  37481. /** @hidden */
  37482. static _setVRRigMode(camera: Camera, rigParams: any): void;
  37483. /** @hidden */
  37484. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  37485. /** @hidden */
  37486. _getVRProjectionMatrix(): Matrix;
  37487. protected _updateCameraRotationMatrix(): void;
  37488. protected _updateWebVRCameraRotationMatrix(): void;
  37489. /**
  37490. * This function MUST be overwritten by the different WebVR cameras available.
  37491. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37492. * @hidden
  37493. */
  37494. _getWebVRProjectionMatrix(): Matrix;
  37495. /**
  37496. * This function MUST be overwritten by the different WebVR cameras available.
  37497. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37498. * @hidden
  37499. */
  37500. _getWebVRViewMatrix(): Matrix;
  37501. /** @hidden */
  37502. setCameraRigParameter(name: string, value: any): void;
  37503. /**
  37504. * needs to be overridden by children so sub has required properties to be copied
  37505. * @hidden
  37506. */
  37507. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  37508. /**
  37509. * May need to be overridden by children
  37510. * @hidden
  37511. */
  37512. _updateRigCameras(): void;
  37513. /** @hidden */
  37514. _setupInputs(): void;
  37515. /**
  37516. * Serialiaze the camera setup to a json represention
  37517. * @returns the JSON representation
  37518. */
  37519. serialize(): any;
  37520. /**
  37521. * Clones the current camera.
  37522. * @param name The cloned camera name
  37523. * @returns the cloned camera
  37524. */
  37525. clone(name: string): Camera;
  37526. /**
  37527. * Gets the direction of the camera relative to a given local axis.
  37528. * @param localAxis Defines the reference axis to provide a relative direction.
  37529. * @return the direction
  37530. */
  37531. getDirection(localAxis: Vector3): Vector3;
  37532. /**
  37533. * Returns the current camera absolute rotation
  37534. */
  37535. get absoluteRotation(): Quaternion;
  37536. /**
  37537. * Gets the direction of the camera relative to a given local axis into a passed vector.
  37538. * @param localAxis Defines the reference axis to provide a relative direction.
  37539. * @param result Defines the vector to store the result in
  37540. */
  37541. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  37542. /**
  37543. * Gets a camera constructor for a given camera type
  37544. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  37545. * @param name The name of the camera the result will be able to instantiate
  37546. * @param scene The scene the result will construct the camera in
  37547. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  37548. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  37549. * @returns a factory method to construc the camera
  37550. */
  37551. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  37552. /**
  37553. * Compute the world matrix of the camera.
  37554. * @returns the camera world matrix
  37555. */
  37556. computeWorldMatrix(): Matrix;
  37557. /**
  37558. * Parse a JSON and creates the camera from the parsed information
  37559. * @param parsedCamera The JSON to parse
  37560. * @param scene The scene to instantiate the camera in
  37561. * @returns the newly constructed camera
  37562. */
  37563. static Parse(parsedCamera: any, scene: Scene): Camera;
  37564. }
  37565. }
  37566. declare module BABYLON {
  37567. /**
  37568. * PostProcessManager is used to manage one or more post processes or post process pipelines
  37569. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  37570. */
  37571. export class PostProcessManager {
  37572. private _scene;
  37573. private _indexBuffer;
  37574. private _vertexBuffers;
  37575. /**
  37576. * Creates a new instance PostProcess
  37577. * @param scene The scene that the post process is associated with.
  37578. */
  37579. constructor(scene: Scene);
  37580. private _prepareBuffers;
  37581. private _buildIndexBuffer;
  37582. /**
  37583. * Rebuilds the vertex buffers of the manager.
  37584. * @hidden
  37585. */
  37586. _rebuild(): void;
  37587. /**
  37588. * Prepares a frame to be run through a post process.
  37589. * @param sourceTexture The input texture to the post procesess. (default: null)
  37590. * @param postProcesses An array of post processes to be run. (default: null)
  37591. * @returns True if the post processes were able to be run.
  37592. * @hidden
  37593. */
  37594. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  37595. /**
  37596. * Manually render a set of post processes to a texture.
  37597. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  37598. * @param postProcesses An array of post processes to be run.
  37599. * @param targetTexture The target texture to render to.
  37600. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  37601. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  37602. * @param lodLevel defines which lod of the texture to render to
  37603. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  37604. */
  37605. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  37606. /**
  37607. * Finalize the result of the output of the postprocesses.
  37608. * @param doNotPresent If true the result will not be displayed to the screen.
  37609. * @param targetTexture The target texture to render to.
  37610. * @param faceIndex The index of the face to bind the target texture to.
  37611. * @param postProcesses The array of post processes to render.
  37612. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  37613. * @hidden
  37614. */
  37615. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  37616. /**
  37617. * Disposes of the post process manager.
  37618. */
  37619. dispose(): void;
  37620. }
  37621. }
  37622. declare module BABYLON {
  37623. /**
  37624. * This Helps creating a texture that will be created from a camera in your scene.
  37625. * It is basically a dynamic texture that could be used to create special effects for instance.
  37626. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  37627. */
  37628. export class RenderTargetTexture extends Texture {
  37629. /**
  37630. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  37631. */
  37632. static readonly REFRESHRATE_RENDER_ONCE: number;
  37633. /**
  37634. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  37635. */
  37636. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37637. /**
  37638. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  37639. * the central point of your effect and can save a lot of performances.
  37640. */
  37641. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37642. /**
  37643. * Use this predicate to dynamically define the list of mesh you want to render.
  37644. * If set, the renderList property will be overwritten.
  37645. */
  37646. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37647. private _renderList;
  37648. /**
  37649. * Use this list to define the list of mesh you want to render.
  37650. */
  37651. get renderList(): Nullable<Array<AbstractMesh>>;
  37652. set renderList(value: Nullable<Array<AbstractMesh>>);
  37653. /**
  37654. * Use this function to overload the renderList array at rendering time.
  37655. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  37656. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  37657. * the cube (if the RTT is a cube, else layerOrFace=0).
  37658. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  37659. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  37660. * hold dummy elements!
  37661. */
  37662. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  37663. private _hookArray;
  37664. /**
  37665. * Define if particles should be rendered in your texture.
  37666. */
  37667. renderParticles: boolean;
  37668. /**
  37669. * Define if sprites should be rendered in your texture.
  37670. */
  37671. renderSprites: boolean;
  37672. /**
  37673. * Define the camera used to render the texture.
  37674. */
  37675. activeCamera: Nullable<Camera>;
  37676. /**
  37677. * Override the mesh isReady function with your own one.
  37678. */
  37679. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  37680. /**
  37681. * Override the render function of the texture with your own one.
  37682. */
  37683. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37684. /**
  37685. * Define if camera post processes should be use while rendering the texture.
  37686. */
  37687. useCameraPostProcesses: boolean;
  37688. /**
  37689. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  37690. */
  37691. ignoreCameraViewport: boolean;
  37692. private _postProcessManager;
  37693. private _postProcesses;
  37694. private _resizeObserver;
  37695. /**
  37696. * An event triggered when the texture is unbind.
  37697. */
  37698. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37699. /**
  37700. * An event triggered when the texture is unbind.
  37701. */
  37702. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37703. private _onAfterUnbindObserver;
  37704. /**
  37705. * Set a after unbind callback in the texture.
  37706. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  37707. */
  37708. set onAfterUnbind(callback: () => void);
  37709. /**
  37710. * An event triggered before rendering the texture
  37711. */
  37712. onBeforeRenderObservable: Observable<number>;
  37713. private _onBeforeRenderObserver;
  37714. /**
  37715. * Set a before render callback in the texture.
  37716. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  37717. */
  37718. set onBeforeRender(callback: (faceIndex: number) => void);
  37719. /**
  37720. * An event triggered after rendering the texture
  37721. */
  37722. onAfterRenderObservable: Observable<number>;
  37723. private _onAfterRenderObserver;
  37724. /**
  37725. * Set a after render callback in the texture.
  37726. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  37727. */
  37728. set onAfterRender(callback: (faceIndex: number) => void);
  37729. /**
  37730. * An event triggered after the texture clear
  37731. */
  37732. onClearObservable: Observable<Engine>;
  37733. private _onClearObserver;
  37734. /**
  37735. * Set a clear callback in the texture.
  37736. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  37737. */
  37738. set onClear(callback: (Engine: Engine) => void);
  37739. /**
  37740. * An event triggered when the texture is resized.
  37741. */
  37742. onResizeObservable: Observable<RenderTargetTexture>;
  37743. /**
  37744. * Define the clear color of the Render Target if it should be different from the scene.
  37745. */
  37746. clearColor: Color4;
  37747. protected _size: number | {
  37748. width: number;
  37749. height: number;
  37750. layers?: number;
  37751. };
  37752. protected _initialSizeParameter: number | {
  37753. width: number;
  37754. height: number;
  37755. } | {
  37756. ratio: number;
  37757. };
  37758. protected _sizeRatio: Nullable<number>;
  37759. /** @hidden */
  37760. _generateMipMaps: boolean;
  37761. protected _renderingManager: RenderingManager;
  37762. /** @hidden */
  37763. _waitingRenderList?: string[];
  37764. protected _doNotChangeAspectRatio: boolean;
  37765. protected _currentRefreshId: number;
  37766. protected _refreshRate: number;
  37767. protected _textureMatrix: Matrix;
  37768. protected _samples: number;
  37769. protected _renderTargetOptions: RenderTargetCreationOptions;
  37770. /**
  37771. * Gets render target creation options that were used.
  37772. */
  37773. get renderTargetOptions(): RenderTargetCreationOptions;
  37774. protected _onRatioRescale(): void;
  37775. /**
  37776. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37777. * It must define where the camera used to render the texture is set
  37778. */
  37779. boundingBoxPosition: Vector3;
  37780. private _boundingBoxSize;
  37781. /**
  37782. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37783. * When defined, the cubemap will switch to local mode
  37784. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37785. * @example https://www.babylonjs-playground.com/#RNASML
  37786. */
  37787. set boundingBoxSize(value: Vector3);
  37788. get boundingBoxSize(): Vector3;
  37789. /**
  37790. * In case the RTT has been created with a depth texture, get the associated
  37791. * depth texture.
  37792. * Otherwise, return null.
  37793. */
  37794. get depthStencilTexture(): Nullable<InternalTexture>;
  37795. /**
  37796. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  37797. * or used a shadow, depth texture...
  37798. * @param name The friendly name of the texture
  37799. * @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)
  37800. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37801. * @param generateMipMaps True if mip maps need to be generated after render.
  37802. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37803. * @param type The type of the buffer in the RTT (int, half float, float...)
  37804. * @param isCube True if a cube texture needs to be created
  37805. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37806. * @param generateDepthBuffer True to generate a depth buffer
  37807. * @param generateStencilBuffer True to generate a stencil buffer
  37808. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37809. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37810. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37811. */
  37812. constructor(name: string, size: number | {
  37813. width: number;
  37814. height: number;
  37815. layers?: number;
  37816. } | {
  37817. ratio: number;
  37818. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  37819. /**
  37820. * Creates a depth stencil texture.
  37821. * This is only available in WebGL 2 or with the depth texture extension available.
  37822. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37823. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37824. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37825. */
  37826. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37827. private _processSizeParameter;
  37828. /**
  37829. * Define the number of samples to use in case of MSAA.
  37830. * It defaults to one meaning no MSAA has been enabled.
  37831. */
  37832. get samples(): number;
  37833. set samples(value: number);
  37834. /**
  37835. * Resets the refresh counter of the texture and start bak from scratch.
  37836. * Could be useful to regenerate the texture if it is setup to render only once.
  37837. */
  37838. resetRefreshCounter(): void;
  37839. /**
  37840. * Define the refresh rate of the texture or the rendering frequency.
  37841. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  37842. */
  37843. get refreshRate(): number;
  37844. set refreshRate(value: number);
  37845. /**
  37846. * Adds a post process to the render target rendering passes.
  37847. * @param postProcess define the post process to add
  37848. */
  37849. addPostProcess(postProcess: PostProcess): void;
  37850. /**
  37851. * Clear all the post processes attached to the render target
  37852. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  37853. */
  37854. clearPostProcesses(dispose?: boolean): void;
  37855. /**
  37856. * Remove one of the post process from the list of attached post processes to the texture
  37857. * @param postProcess define the post process to remove from the list
  37858. */
  37859. removePostProcess(postProcess: PostProcess): void;
  37860. /** @hidden */
  37861. _shouldRender(): boolean;
  37862. /**
  37863. * Gets the actual render size of the texture.
  37864. * @returns the width of the render size
  37865. */
  37866. getRenderSize(): number;
  37867. /**
  37868. * Gets the actual render width of the texture.
  37869. * @returns the width of the render size
  37870. */
  37871. getRenderWidth(): number;
  37872. /**
  37873. * Gets the actual render height of the texture.
  37874. * @returns the height of the render size
  37875. */
  37876. getRenderHeight(): number;
  37877. /**
  37878. * Gets the actual number of layers of the texture.
  37879. * @returns the number of layers
  37880. */
  37881. getRenderLayers(): number;
  37882. /**
  37883. * Get if the texture can be rescaled or not.
  37884. */
  37885. get canRescale(): boolean;
  37886. /**
  37887. * Resize the texture using a ratio.
  37888. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  37889. */
  37890. scale(ratio: number): void;
  37891. /**
  37892. * Get the texture reflection matrix used to rotate/transform the reflection.
  37893. * @returns the reflection matrix
  37894. */
  37895. getReflectionTextureMatrix(): Matrix;
  37896. /**
  37897. * Resize the texture to a new desired size.
  37898. * Be carrefull as it will recreate all the data in the new texture.
  37899. * @param size Define the new size. It can be:
  37900. * - a number for squared texture,
  37901. * - an object containing { width: number, height: number }
  37902. * - or an object containing a ratio { ratio: number }
  37903. */
  37904. resize(size: number | {
  37905. width: number;
  37906. height: number;
  37907. } | {
  37908. ratio: number;
  37909. }): void;
  37910. private _defaultRenderListPrepared;
  37911. /**
  37912. * Renders all the objects from the render list into the texture.
  37913. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  37914. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  37915. */
  37916. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37917. private _bestReflectionRenderTargetDimension;
  37918. private _prepareRenderingManager;
  37919. /**
  37920. * @hidden
  37921. * @param faceIndex face index to bind to if this is a cubetexture
  37922. * @param layer defines the index of the texture to bind in the array
  37923. */
  37924. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  37925. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37926. private renderToTarget;
  37927. /**
  37928. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37929. * This allowed control for front to back rendering or reversly depending of the special needs.
  37930. *
  37931. * @param renderingGroupId The rendering group id corresponding to its index
  37932. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37933. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37934. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37935. */
  37936. 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;
  37937. /**
  37938. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37939. *
  37940. * @param renderingGroupId The rendering group id corresponding to its index
  37941. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37942. */
  37943. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37944. /**
  37945. * Clones the texture.
  37946. * @returns the cloned texture
  37947. */
  37948. clone(): RenderTargetTexture;
  37949. /**
  37950. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  37951. * @returns The JSON representation of the texture
  37952. */
  37953. serialize(): any;
  37954. /**
  37955. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  37956. */
  37957. disposeFramebufferObjects(): void;
  37958. /**
  37959. * Dispose the texture and release its associated resources.
  37960. */
  37961. dispose(): void;
  37962. /** @hidden */
  37963. _rebuild(): void;
  37964. /**
  37965. * Clear the info related to rendering groups preventing retention point in material dispose.
  37966. */
  37967. freeRenderingGroups(): void;
  37968. /**
  37969. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  37970. * @returns the view count
  37971. */
  37972. getViewCount(): number;
  37973. }
  37974. }
  37975. declare module BABYLON {
  37976. /**
  37977. * Options to be used when creating an effect.
  37978. */
  37979. export interface IEffectCreationOptions {
  37980. /**
  37981. * Atrributes that will be used in the shader.
  37982. */
  37983. attributes: string[];
  37984. /**
  37985. * Uniform varible names that will be set in the shader.
  37986. */
  37987. uniformsNames: string[];
  37988. /**
  37989. * Uniform buffer variable names that will be set in the shader.
  37990. */
  37991. uniformBuffersNames: string[];
  37992. /**
  37993. * Sampler texture variable names that will be set in the shader.
  37994. */
  37995. samplers: string[];
  37996. /**
  37997. * Define statements that will be set in the shader.
  37998. */
  37999. defines: any;
  38000. /**
  38001. * Possible fallbacks for this effect to improve performance when needed.
  38002. */
  38003. fallbacks: Nullable<IEffectFallbacks>;
  38004. /**
  38005. * Callback that will be called when the shader is compiled.
  38006. */
  38007. onCompiled: Nullable<(effect: Effect) => void>;
  38008. /**
  38009. * Callback that will be called if an error occurs during shader compilation.
  38010. */
  38011. onError: Nullable<(effect: Effect, errors: string) => void>;
  38012. /**
  38013. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38014. */
  38015. indexParameters?: any;
  38016. /**
  38017. * Max number of lights that can be used in the shader.
  38018. */
  38019. maxSimultaneousLights?: number;
  38020. /**
  38021. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38022. */
  38023. transformFeedbackVaryings?: Nullable<string[]>;
  38024. /**
  38025. * 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
  38026. */
  38027. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38028. /**
  38029. * Is this effect rendering to several color attachments ?
  38030. */
  38031. multiTarget?: boolean;
  38032. }
  38033. /**
  38034. * Effect containing vertex and fragment shader that can be executed on an object.
  38035. */
  38036. export class Effect implements IDisposable {
  38037. /**
  38038. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38039. */
  38040. static ShadersRepository: string;
  38041. /**
  38042. * Enable logging of the shader code when a compilation error occurs
  38043. */
  38044. static LogShaderCodeOnCompilationError: boolean;
  38045. /**
  38046. * Name of the effect.
  38047. */
  38048. name: any;
  38049. /**
  38050. * String container all the define statements that should be set on the shader.
  38051. */
  38052. defines: string;
  38053. /**
  38054. * Callback that will be called when the shader is compiled.
  38055. */
  38056. onCompiled: Nullable<(effect: Effect) => void>;
  38057. /**
  38058. * Callback that will be called if an error occurs during shader compilation.
  38059. */
  38060. onError: Nullable<(effect: Effect, errors: string) => void>;
  38061. /**
  38062. * Callback that will be called when effect is bound.
  38063. */
  38064. onBind: Nullable<(effect: Effect) => void>;
  38065. /**
  38066. * Unique ID of the effect.
  38067. */
  38068. uniqueId: number;
  38069. /**
  38070. * Observable that will be called when the shader is compiled.
  38071. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38072. */
  38073. onCompileObservable: Observable<Effect>;
  38074. /**
  38075. * Observable that will be called if an error occurs during shader compilation.
  38076. */
  38077. onErrorObservable: Observable<Effect>;
  38078. /** @hidden */
  38079. _onBindObservable: Nullable<Observable<Effect>>;
  38080. /**
  38081. * @hidden
  38082. * Specifies if the effect was previously ready
  38083. */
  38084. _wasPreviouslyReady: boolean;
  38085. /**
  38086. * Observable that will be called when effect is bound.
  38087. */
  38088. get onBindObservable(): Observable<Effect>;
  38089. /** @hidden */
  38090. _bonesComputationForcedToCPU: boolean;
  38091. /** @hidden */
  38092. _multiTarget: boolean;
  38093. private static _uniqueIdSeed;
  38094. private _engine;
  38095. private _uniformBuffersNames;
  38096. private _uniformBuffersNamesList;
  38097. private _uniformsNames;
  38098. private _samplerList;
  38099. private _samplers;
  38100. private _isReady;
  38101. private _compilationError;
  38102. private _allFallbacksProcessed;
  38103. private _attributesNames;
  38104. private _attributes;
  38105. private _attributeLocationByName;
  38106. private _uniforms;
  38107. /**
  38108. * Key for the effect.
  38109. * @hidden
  38110. */
  38111. _key: string;
  38112. private _indexParameters;
  38113. private _fallbacks;
  38114. private _vertexSourceCode;
  38115. private _fragmentSourceCode;
  38116. private _vertexSourceCodeOverride;
  38117. private _fragmentSourceCodeOverride;
  38118. private _transformFeedbackVaryings;
  38119. private _rawVertexSourceCode;
  38120. private _rawFragmentSourceCode;
  38121. /**
  38122. * Compiled shader to webGL program.
  38123. * @hidden
  38124. */
  38125. _pipelineContext: Nullable<IPipelineContext>;
  38126. private _valueCache;
  38127. private static _baseCache;
  38128. /**
  38129. * Instantiates an effect.
  38130. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38131. * @param baseName Name of the effect.
  38132. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38133. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38134. * @param samplers List of sampler variables that will be passed to the shader.
  38135. * @param engine Engine to be used to render the effect
  38136. * @param defines Define statements to be added to the shader.
  38137. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38138. * @param onCompiled Callback that will be called when the shader is compiled.
  38139. * @param onError Callback that will be called if an error occurs during shader compilation.
  38140. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38141. */
  38142. 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);
  38143. private _useFinalCode;
  38144. /**
  38145. * Unique key for this effect
  38146. */
  38147. get key(): string;
  38148. /**
  38149. * If the effect has been compiled and prepared.
  38150. * @returns if the effect is compiled and prepared.
  38151. */
  38152. isReady(): boolean;
  38153. private _isReadyInternal;
  38154. /**
  38155. * The engine the effect was initialized with.
  38156. * @returns the engine.
  38157. */
  38158. getEngine(): Engine;
  38159. /**
  38160. * The pipeline context for this effect
  38161. * @returns the associated pipeline context
  38162. */
  38163. getPipelineContext(): Nullable<IPipelineContext>;
  38164. /**
  38165. * The set of names of attribute variables for the shader.
  38166. * @returns An array of attribute names.
  38167. */
  38168. getAttributesNames(): string[];
  38169. /**
  38170. * Returns the attribute at the given index.
  38171. * @param index The index of the attribute.
  38172. * @returns The location of the attribute.
  38173. */
  38174. getAttributeLocation(index: number): number;
  38175. /**
  38176. * Returns the attribute based on the name of the variable.
  38177. * @param name of the attribute to look up.
  38178. * @returns the attribute location.
  38179. */
  38180. getAttributeLocationByName(name: string): number;
  38181. /**
  38182. * The number of attributes.
  38183. * @returns the numnber of attributes.
  38184. */
  38185. getAttributesCount(): number;
  38186. /**
  38187. * Gets the index of a uniform variable.
  38188. * @param uniformName of the uniform to look up.
  38189. * @returns the index.
  38190. */
  38191. getUniformIndex(uniformName: string): number;
  38192. /**
  38193. * Returns the attribute based on the name of the variable.
  38194. * @param uniformName of the uniform to look up.
  38195. * @returns the location of the uniform.
  38196. */
  38197. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38198. /**
  38199. * Returns an array of sampler variable names
  38200. * @returns The array of sampler variable names.
  38201. */
  38202. getSamplers(): string[];
  38203. /**
  38204. * Returns an array of uniform variable names
  38205. * @returns The array of uniform variable names.
  38206. */
  38207. getUniformNames(): string[];
  38208. /**
  38209. * Returns an array of uniform buffer variable names
  38210. * @returns The array of uniform buffer variable names.
  38211. */
  38212. getUniformBuffersNames(): string[];
  38213. /**
  38214. * Returns the index parameters used to create the effect
  38215. * @returns The index parameters object
  38216. */
  38217. getIndexParameters(): any;
  38218. /**
  38219. * The error from the last compilation.
  38220. * @returns the error string.
  38221. */
  38222. getCompilationError(): string;
  38223. /**
  38224. * Gets a boolean indicating that all fallbacks were used during compilation
  38225. * @returns true if all fallbacks were used
  38226. */
  38227. allFallbacksProcessed(): boolean;
  38228. /**
  38229. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38230. * @param func The callback to be used.
  38231. */
  38232. executeWhenCompiled(func: (effect: Effect) => void): void;
  38233. private _checkIsReady;
  38234. private _loadShader;
  38235. /**
  38236. * Gets the vertex shader source code of this effect
  38237. */
  38238. get vertexSourceCode(): string;
  38239. /**
  38240. * Gets the fragment shader source code of this effect
  38241. */
  38242. get fragmentSourceCode(): string;
  38243. /**
  38244. * Gets the vertex shader source code before it has been processed by the preprocessor
  38245. */
  38246. get rawVertexSourceCode(): string;
  38247. /**
  38248. * Gets the fragment shader source code before it has been processed by the preprocessor
  38249. */
  38250. get rawFragmentSourceCode(): string;
  38251. /**
  38252. * Recompiles the webGL program
  38253. * @param vertexSourceCode The source code for the vertex shader.
  38254. * @param fragmentSourceCode The source code for the fragment shader.
  38255. * @param onCompiled Callback called when completed.
  38256. * @param onError Callback called on error.
  38257. * @hidden
  38258. */
  38259. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38260. /**
  38261. * Prepares the effect
  38262. * @hidden
  38263. */
  38264. _prepareEffect(): void;
  38265. private _getShaderCodeAndErrorLine;
  38266. private _processCompilationErrors;
  38267. /**
  38268. * Checks if the effect is supported. (Must be called after compilation)
  38269. */
  38270. get isSupported(): boolean;
  38271. /**
  38272. * Binds a texture to the engine to be used as output of the shader.
  38273. * @param channel Name of the output variable.
  38274. * @param texture Texture to bind.
  38275. * @hidden
  38276. */
  38277. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  38278. /**
  38279. * Sets a texture on the engine to be used in the shader.
  38280. * @param channel Name of the sampler variable.
  38281. * @param texture Texture to set.
  38282. */
  38283. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  38284. /**
  38285. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  38286. * @param channel Name of the sampler variable.
  38287. * @param texture Texture to set.
  38288. */
  38289. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  38290. /**
  38291. * Sets an array of textures on the engine to be used in the shader.
  38292. * @param channel Name of the variable.
  38293. * @param textures Textures to set.
  38294. */
  38295. setTextureArray(channel: string, textures: ThinTexture[]): void;
  38296. /**
  38297. * 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)
  38298. * @param channel Name of the sampler variable.
  38299. * @param postProcess Post process to get the input texture from.
  38300. */
  38301. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  38302. /**
  38303. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  38304. * 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)
  38305. * @param channel Name of the sampler variable.
  38306. * @param postProcess Post process to get the output texture from.
  38307. */
  38308. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38309. /** @hidden */
  38310. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38311. /** @hidden */
  38312. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38313. /** @hidden */
  38314. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38315. /** @hidden */
  38316. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38317. /**
  38318. * Binds a buffer to a uniform.
  38319. * @param buffer Buffer to bind.
  38320. * @param name Name of the uniform variable to bind to.
  38321. */
  38322. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38323. /**
  38324. * Binds block to a uniform.
  38325. * @param blockName Name of the block to bind.
  38326. * @param index Index to bind.
  38327. */
  38328. bindUniformBlock(blockName: string, index: number): void;
  38329. /**
  38330. * Sets an interger value on a uniform variable.
  38331. * @param uniformName Name of the variable.
  38332. * @param value Value to be set.
  38333. * @returns this effect.
  38334. */
  38335. setInt(uniformName: string, value: number): Effect;
  38336. /**
  38337. * Sets an int array on a uniform variable.
  38338. * @param uniformName Name of the variable.
  38339. * @param array array to be set.
  38340. * @returns this effect.
  38341. */
  38342. setIntArray(uniformName: string, array: Int32Array): Effect;
  38343. /**
  38344. * 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)
  38345. * @param uniformName Name of the variable.
  38346. * @param array array to be set.
  38347. * @returns this effect.
  38348. */
  38349. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38350. /**
  38351. * 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)
  38352. * @param uniformName Name of the variable.
  38353. * @param array array to be set.
  38354. * @returns this effect.
  38355. */
  38356. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38357. /**
  38358. * 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)
  38359. * @param uniformName Name of the variable.
  38360. * @param array array to be set.
  38361. * @returns this effect.
  38362. */
  38363. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38364. /**
  38365. * Sets an float array on a uniform variable.
  38366. * @param uniformName Name of the variable.
  38367. * @param array array to be set.
  38368. * @returns this effect.
  38369. */
  38370. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38371. /**
  38372. * 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)
  38373. * @param uniformName Name of the variable.
  38374. * @param array array to be set.
  38375. * @returns this effect.
  38376. */
  38377. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38378. /**
  38379. * 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)
  38380. * @param uniformName Name of the variable.
  38381. * @param array array to be set.
  38382. * @returns this effect.
  38383. */
  38384. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38385. /**
  38386. * 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)
  38387. * @param uniformName Name of the variable.
  38388. * @param array array to be set.
  38389. * @returns this effect.
  38390. */
  38391. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38392. /**
  38393. * Sets an array on a uniform variable.
  38394. * @param uniformName Name of the variable.
  38395. * @param array array to be set.
  38396. * @returns this effect.
  38397. */
  38398. setArray(uniformName: string, array: number[]): Effect;
  38399. /**
  38400. * 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)
  38401. * @param uniformName Name of the variable.
  38402. * @param array array to be set.
  38403. * @returns this effect.
  38404. */
  38405. setArray2(uniformName: string, array: number[]): Effect;
  38406. /**
  38407. * 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)
  38408. * @param uniformName Name of the variable.
  38409. * @param array array to be set.
  38410. * @returns this effect.
  38411. */
  38412. setArray3(uniformName: string, array: number[]): Effect;
  38413. /**
  38414. * 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)
  38415. * @param uniformName Name of the variable.
  38416. * @param array array to be set.
  38417. * @returns this effect.
  38418. */
  38419. setArray4(uniformName: string, array: number[]): Effect;
  38420. /**
  38421. * Sets matrices on a uniform variable.
  38422. * @param uniformName Name of the variable.
  38423. * @param matrices matrices to be set.
  38424. * @returns this effect.
  38425. */
  38426. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38427. /**
  38428. * Sets matrix on a uniform variable.
  38429. * @param uniformName Name of the variable.
  38430. * @param matrix matrix to be set.
  38431. * @returns this effect.
  38432. */
  38433. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38434. /**
  38435. * 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)
  38436. * @param uniformName Name of the variable.
  38437. * @param matrix matrix to be set.
  38438. * @returns this effect.
  38439. */
  38440. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38441. /**
  38442. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38443. * @param uniformName Name of the variable.
  38444. * @param matrix matrix to be set.
  38445. * @returns this effect.
  38446. */
  38447. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38448. /**
  38449. * Sets a float on a uniform variable.
  38450. * @param uniformName Name of the variable.
  38451. * @param value value to be set.
  38452. * @returns this effect.
  38453. */
  38454. setFloat(uniformName: string, value: number): Effect;
  38455. /**
  38456. * Sets a boolean on a uniform variable.
  38457. * @param uniformName Name of the variable.
  38458. * @param bool value to be set.
  38459. * @returns this effect.
  38460. */
  38461. setBool(uniformName: string, bool: boolean): Effect;
  38462. /**
  38463. * Sets a Vector2 on a uniform variable.
  38464. * @param uniformName Name of the variable.
  38465. * @param vector2 vector2 to be set.
  38466. * @returns this effect.
  38467. */
  38468. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38469. /**
  38470. * Sets a float2 on a uniform variable.
  38471. * @param uniformName Name of the variable.
  38472. * @param x First float in float2.
  38473. * @param y Second float in float2.
  38474. * @returns this effect.
  38475. */
  38476. setFloat2(uniformName: string, x: number, y: number): Effect;
  38477. /**
  38478. * Sets a Vector3 on a uniform variable.
  38479. * @param uniformName Name of the variable.
  38480. * @param vector3 Value to be set.
  38481. * @returns this effect.
  38482. */
  38483. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38484. /**
  38485. * Sets a float3 on a uniform variable.
  38486. * @param uniformName Name of the variable.
  38487. * @param x First float in float3.
  38488. * @param y Second float in float3.
  38489. * @param z Third float in float3.
  38490. * @returns this effect.
  38491. */
  38492. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38493. /**
  38494. * Sets a Vector4 on a uniform variable.
  38495. * @param uniformName Name of the variable.
  38496. * @param vector4 Value to be set.
  38497. * @returns this effect.
  38498. */
  38499. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38500. /**
  38501. * Sets a float4 on a uniform variable.
  38502. * @param uniformName Name of the variable.
  38503. * @param x First float in float4.
  38504. * @param y Second float in float4.
  38505. * @param z Third float in float4.
  38506. * @param w Fourth float in float4.
  38507. * @returns this effect.
  38508. */
  38509. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38510. /**
  38511. * Sets a Color3 on a uniform variable.
  38512. * @param uniformName Name of the variable.
  38513. * @param color3 Value to be set.
  38514. * @returns this effect.
  38515. */
  38516. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38517. /**
  38518. * Sets a Color4 on a uniform variable.
  38519. * @param uniformName Name of the variable.
  38520. * @param color3 Value to be set.
  38521. * @param alpha Alpha value to be set.
  38522. * @returns this effect.
  38523. */
  38524. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38525. /**
  38526. * Sets a Color4 on a uniform variable
  38527. * @param uniformName defines the name of the variable
  38528. * @param color4 defines the value to be set
  38529. * @returns this effect.
  38530. */
  38531. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38532. /** Release all associated resources */
  38533. dispose(): void;
  38534. /**
  38535. * This function will add a new shader to the shader store
  38536. * @param name the name of the shader
  38537. * @param pixelShader optional pixel shader content
  38538. * @param vertexShader optional vertex shader content
  38539. */
  38540. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38541. /**
  38542. * Store of each shader (The can be looked up using effect.key)
  38543. */
  38544. static ShadersStore: {
  38545. [key: string]: string;
  38546. };
  38547. /**
  38548. * Store of each included file for a shader (The can be looked up using effect.key)
  38549. */
  38550. static IncludesShadersStore: {
  38551. [key: string]: string;
  38552. };
  38553. /**
  38554. * Resets the cache of effects.
  38555. */
  38556. static ResetCache(): void;
  38557. }
  38558. }
  38559. declare module BABYLON {
  38560. /**
  38561. * Interface used to describe the capabilities of the engine relatively to the current browser
  38562. */
  38563. export interface EngineCapabilities {
  38564. /** Maximum textures units per fragment shader */
  38565. maxTexturesImageUnits: number;
  38566. /** Maximum texture units per vertex shader */
  38567. maxVertexTextureImageUnits: number;
  38568. /** Maximum textures units in the entire pipeline */
  38569. maxCombinedTexturesImageUnits: number;
  38570. /** Maximum texture size */
  38571. maxTextureSize: number;
  38572. /** Maximum texture samples */
  38573. maxSamples?: number;
  38574. /** Maximum cube texture size */
  38575. maxCubemapTextureSize: number;
  38576. /** Maximum render texture size */
  38577. maxRenderTextureSize: number;
  38578. /** Maximum number of vertex attributes */
  38579. maxVertexAttribs: number;
  38580. /** Maximum number of varyings */
  38581. maxVaryingVectors: number;
  38582. /** Maximum number of uniforms per vertex shader */
  38583. maxVertexUniformVectors: number;
  38584. /** Maximum number of uniforms per fragment shader */
  38585. maxFragmentUniformVectors: number;
  38586. /** Defines if standard derivates (dx/dy) are supported */
  38587. standardDerivatives: boolean;
  38588. /** Defines if s3tc texture compression is supported */
  38589. s3tc?: WEBGL_compressed_texture_s3tc;
  38590. /** Defines if pvrtc texture compression is supported */
  38591. pvrtc: any;
  38592. /** Defines if etc1 texture compression is supported */
  38593. etc1: any;
  38594. /** Defines if etc2 texture compression is supported */
  38595. etc2: any;
  38596. /** Defines if astc texture compression is supported */
  38597. astc: any;
  38598. /** Defines if bptc texture compression is supported */
  38599. bptc: any;
  38600. /** Defines if float textures are supported */
  38601. textureFloat: boolean;
  38602. /** Defines if vertex array objects are supported */
  38603. vertexArrayObject: boolean;
  38604. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38605. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38606. /** Gets the maximum level of anisotropy supported */
  38607. maxAnisotropy: number;
  38608. /** Defines if instancing is supported */
  38609. instancedArrays: boolean;
  38610. /** Defines if 32 bits indices are supported */
  38611. uintIndices: boolean;
  38612. /** Defines if high precision shaders are supported */
  38613. highPrecisionShaderSupported: boolean;
  38614. /** Defines if depth reading in the fragment shader is supported */
  38615. fragmentDepthSupported: boolean;
  38616. /** Defines if float texture linear filtering is supported*/
  38617. textureFloatLinearFiltering: boolean;
  38618. /** Defines if rendering to float textures is supported */
  38619. textureFloatRender: boolean;
  38620. /** Defines if half float textures are supported*/
  38621. textureHalfFloat: boolean;
  38622. /** Defines if half float texture linear filtering is supported*/
  38623. textureHalfFloatLinearFiltering: boolean;
  38624. /** Defines if rendering to half float textures is supported */
  38625. textureHalfFloatRender: boolean;
  38626. /** Defines if textureLOD shader command is supported */
  38627. textureLOD: boolean;
  38628. /** Defines if draw buffers extension is supported */
  38629. drawBuffersExtension: boolean;
  38630. /** Defines if depth textures are supported */
  38631. depthTextureExtension: boolean;
  38632. /** Defines if float color buffer are supported */
  38633. colorBufferFloat: boolean;
  38634. /** Gets disjoint timer query extension (null if not supported) */
  38635. timerQuery?: EXT_disjoint_timer_query;
  38636. /** Defines if timestamp can be used with timer query */
  38637. canUseTimestampForTimerQuery: boolean;
  38638. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38639. multiview?: any;
  38640. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38641. oculusMultiview?: any;
  38642. /** Function used to let the system compiles shaders in background */
  38643. parallelShaderCompile?: {
  38644. COMPLETION_STATUS_KHR: number;
  38645. };
  38646. /** Max number of texture samples for MSAA */
  38647. maxMSAASamples: number;
  38648. /** Defines if the blend min max extension is supported */
  38649. blendMinMax: boolean;
  38650. }
  38651. }
  38652. declare module BABYLON {
  38653. /**
  38654. * @hidden
  38655. **/
  38656. export class DepthCullingState {
  38657. private _isDepthTestDirty;
  38658. private _isDepthMaskDirty;
  38659. private _isDepthFuncDirty;
  38660. private _isCullFaceDirty;
  38661. private _isCullDirty;
  38662. private _isZOffsetDirty;
  38663. private _isFrontFaceDirty;
  38664. private _depthTest;
  38665. private _depthMask;
  38666. private _depthFunc;
  38667. private _cull;
  38668. private _cullFace;
  38669. private _zOffset;
  38670. private _frontFace;
  38671. /**
  38672. * Initializes the state.
  38673. */
  38674. constructor();
  38675. get isDirty(): boolean;
  38676. get zOffset(): number;
  38677. set zOffset(value: number);
  38678. get cullFace(): Nullable<number>;
  38679. set cullFace(value: Nullable<number>);
  38680. get cull(): Nullable<boolean>;
  38681. set cull(value: Nullable<boolean>);
  38682. get depthFunc(): Nullable<number>;
  38683. set depthFunc(value: Nullable<number>);
  38684. get depthMask(): boolean;
  38685. set depthMask(value: boolean);
  38686. get depthTest(): boolean;
  38687. set depthTest(value: boolean);
  38688. get frontFace(): Nullable<number>;
  38689. set frontFace(value: Nullable<number>);
  38690. reset(): void;
  38691. apply(gl: WebGLRenderingContext): void;
  38692. }
  38693. }
  38694. declare module BABYLON {
  38695. /**
  38696. * @hidden
  38697. **/
  38698. export class StencilState {
  38699. /** 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 */
  38700. static readonly ALWAYS: number;
  38701. /** Passed to stencilOperation to specify that stencil value must be kept */
  38702. static readonly KEEP: number;
  38703. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38704. static readonly REPLACE: number;
  38705. private _isStencilTestDirty;
  38706. private _isStencilMaskDirty;
  38707. private _isStencilFuncDirty;
  38708. private _isStencilOpDirty;
  38709. private _stencilTest;
  38710. private _stencilMask;
  38711. private _stencilFunc;
  38712. private _stencilFuncRef;
  38713. private _stencilFuncMask;
  38714. private _stencilOpStencilFail;
  38715. private _stencilOpDepthFail;
  38716. private _stencilOpStencilDepthPass;
  38717. get isDirty(): boolean;
  38718. get stencilFunc(): number;
  38719. set stencilFunc(value: number);
  38720. get stencilFuncRef(): number;
  38721. set stencilFuncRef(value: number);
  38722. get stencilFuncMask(): number;
  38723. set stencilFuncMask(value: number);
  38724. get stencilOpStencilFail(): number;
  38725. set stencilOpStencilFail(value: number);
  38726. get stencilOpDepthFail(): number;
  38727. set stencilOpDepthFail(value: number);
  38728. get stencilOpStencilDepthPass(): number;
  38729. set stencilOpStencilDepthPass(value: number);
  38730. get stencilMask(): number;
  38731. set stencilMask(value: number);
  38732. get stencilTest(): boolean;
  38733. set stencilTest(value: boolean);
  38734. constructor();
  38735. reset(): void;
  38736. apply(gl: WebGLRenderingContext): void;
  38737. }
  38738. }
  38739. declare module BABYLON {
  38740. /**
  38741. * @hidden
  38742. **/
  38743. export class AlphaState {
  38744. private _isAlphaBlendDirty;
  38745. private _isBlendFunctionParametersDirty;
  38746. private _isBlendEquationParametersDirty;
  38747. private _isBlendConstantsDirty;
  38748. private _alphaBlend;
  38749. private _blendFunctionParameters;
  38750. private _blendEquationParameters;
  38751. private _blendConstants;
  38752. /**
  38753. * Initializes the state.
  38754. */
  38755. constructor();
  38756. get isDirty(): boolean;
  38757. get alphaBlend(): boolean;
  38758. set alphaBlend(value: boolean);
  38759. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38760. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38761. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38762. reset(): void;
  38763. apply(gl: WebGLRenderingContext): void;
  38764. }
  38765. }
  38766. declare module BABYLON {
  38767. /** @hidden */
  38768. export class WebGLShaderProcessor implements IShaderProcessor {
  38769. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38770. }
  38771. }
  38772. declare module BABYLON {
  38773. /** @hidden */
  38774. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38775. attributeProcessor(attribute: string): string;
  38776. varyingProcessor(varying: string, isFragment: boolean): string;
  38777. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38778. }
  38779. }
  38780. declare module BABYLON {
  38781. /**
  38782. * Interface for attribute information associated with buffer instanciation
  38783. */
  38784. export interface InstancingAttributeInfo {
  38785. /**
  38786. * Name of the GLSL attribute
  38787. * if attribute index is not specified, this is used to retrieve the index from the effect
  38788. */
  38789. attributeName: string;
  38790. /**
  38791. * Index/offset of the attribute in the vertex shader
  38792. * if not specified, this will be computes from the name.
  38793. */
  38794. index?: number;
  38795. /**
  38796. * size of the attribute, 1, 2, 3 or 4
  38797. */
  38798. attributeSize: number;
  38799. /**
  38800. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38801. */
  38802. offset: number;
  38803. /**
  38804. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38805. * default to 1
  38806. */
  38807. divisor?: number;
  38808. /**
  38809. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38810. * default is FLOAT
  38811. */
  38812. attributeType?: number;
  38813. /**
  38814. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38815. */
  38816. normalized?: boolean;
  38817. }
  38818. }
  38819. declare module BABYLON {
  38820. interface ThinEngine {
  38821. /**
  38822. * Update a video texture
  38823. * @param texture defines the texture to update
  38824. * @param video defines the video element to use
  38825. * @param invertY defines if data must be stored with Y axis inverted
  38826. */
  38827. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38828. }
  38829. }
  38830. declare module BABYLON {
  38831. interface ThinEngine {
  38832. /**
  38833. * Creates a dynamic texture
  38834. * @param width defines the width of the texture
  38835. * @param height defines the height of the texture
  38836. * @param generateMipMaps defines if the engine should generate the mip levels
  38837. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38838. * @returns the dynamic texture inside an InternalTexture
  38839. */
  38840. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38841. /**
  38842. * Update the content of a dynamic texture
  38843. * @param texture defines the texture to update
  38844. * @param source defines the source containing the data
  38845. * @param invertY defines if data must be stored with Y axis inverted
  38846. * @param premulAlpha defines if alpha is stored as premultiplied
  38847. * @param format defines the format of the data
  38848. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38849. */
  38850. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38851. }
  38852. }
  38853. declare module BABYLON {
  38854. /**
  38855. * Settings for finer control over video usage
  38856. */
  38857. export interface VideoTextureSettings {
  38858. /**
  38859. * Applies `autoplay` to video, if specified
  38860. */
  38861. autoPlay?: boolean;
  38862. /**
  38863. * Applies `muted` to video, if specified
  38864. */
  38865. muted?: boolean;
  38866. /**
  38867. * Applies `loop` to video, if specified
  38868. */
  38869. loop?: boolean;
  38870. /**
  38871. * Automatically updates internal texture from video at every frame in the render loop
  38872. */
  38873. autoUpdateTexture: boolean;
  38874. /**
  38875. * Image src displayed during the video loading or until the user interacts with the video.
  38876. */
  38877. poster?: string;
  38878. }
  38879. /**
  38880. * If you want to display a video in your scene, this is the special texture for that.
  38881. * This special texture works similar to other textures, with the exception of a few parameters.
  38882. * @see https://doc.babylonjs.com/how_to/video_texture
  38883. */
  38884. export class VideoTexture extends Texture {
  38885. /**
  38886. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38887. */
  38888. readonly autoUpdateTexture: boolean;
  38889. /**
  38890. * The video instance used by the texture internally
  38891. */
  38892. readonly video: HTMLVideoElement;
  38893. private _onUserActionRequestedObservable;
  38894. /**
  38895. * Event triggerd when a dom action is required by the user to play the video.
  38896. * This happens due to recent changes in browser policies preventing video to auto start.
  38897. */
  38898. get onUserActionRequestedObservable(): Observable<Texture>;
  38899. private _generateMipMaps;
  38900. private _stillImageCaptured;
  38901. private _displayingPosterTexture;
  38902. private _settings;
  38903. private _createInternalTextureOnEvent;
  38904. private _frameId;
  38905. private _currentSrc;
  38906. /**
  38907. * Creates a video texture.
  38908. * If you want to display a video in your scene, this is the special texture for that.
  38909. * This special texture works similar to other textures, with the exception of a few parameters.
  38910. * @see https://doc.babylonjs.com/how_to/video_texture
  38911. * @param name optional name, will detect from video source, if not defined
  38912. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38913. * @param scene is obviously the current scene.
  38914. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38915. * @param invertY is false by default but can be used to invert video on Y axis
  38916. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38917. * @param settings allows finer control over video usage
  38918. */
  38919. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38920. private _getName;
  38921. private _getVideo;
  38922. private _createInternalTexture;
  38923. private reset;
  38924. /**
  38925. * @hidden Internal method to initiate `update`.
  38926. */
  38927. _rebuild(): void;
  38928. /**
  38929. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38930. */
  38931. update(): void;
  38932. /**
  38933. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38934. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38935. */
  38936. updateTexture(isVisible: boolean): void;
  38937. protected _updateInternalTexture: () => void;
  38938. /**
  38939. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38940. * @param url New url.
  38941. */
  38942. updateURL(url: string): void;
  38943. /**
  38944. * Clones the texture.
  38945. * @returns the cloned texture
  38946. */
  38947. clone(): VideoTexture;
  38948. /**
  38949. * Dispose the texture and release its associated resources.
  38950. */
  38951. dispose(): void;
  38952. /**
  38953. * Creates a video texture straight from a stream.
  38954. * @param scene Define the scene the texture should be created in
  38955. * @param stream Define the stream the texture should be created from
  38956. * @returns The created video texture as a promise
  38957. */
  38958. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38959. /**
  38960. * Creates a video texture straight from your WebCam video feed.
  38961. * @param scene Define the scene the texture should be created in
  38962. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38963. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38964. * @returns The created video texture as a promise
  38965. */
  38966. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38967. minWidth: number;
  38968. maxWidth: number;
  38969. minHeight: number;
  38970. maxHeight: number;
  38971. deviceId: string;
  38972. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38973. /**
  38974. * Creates a video texture straight from your WebCam video feed.
  38975. * @param scene Define the scene the texture should be created in
  38976. * @param onReady Define a callback to triggered once the texture will be ready
  38977. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38978. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38979. */
  38980. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38981. minWidth: number;
  38982. maxWidth: number;
  38983. minHeight: number;
  38984. maxHeight: number;
  38985. deviceId: string;
  38986. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38987. }
  38988. }
  38989. declare module BABYLON {
  38990. /**
  38991. * Defines the interface used by objects working like Scene
  38992. * @hidden
  38993. */
  38994. export interface ISceneLike {
  38995. _addPendingData(data: any): void;
  38996. _removePendingData(data: any): void;
  38997. offlineProvider: IOfflineProvider;
  38998. }
  38999. /**
  39000. * Information about the current host
  39001. */
  39002. export interface HostInformation {
  39003. /**
  39004. * Defines if the current host is a mobile
  39005. */
  39006. isMobile: boolean;
  39007. }
  39008. /** Interface defining initialization parameters for Engine class */
  39009. export interface EngineOptions extends WebGLContextAttributes {
  39010. /**
  39011. * Defines if the engine should no exceed a specified device ratio
  39012. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39013. */
  39014. limitDeviceRatio?: number;
  39015. /**
  39016. * Defines if webvr should be enabled automatically
  39017. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39018. */
  39019. autoEnableWebVR?: boolean;
  39020. /**
  39021. * Defines if webgl2 should be turned off even if supported
  39022. * @see https://doc.babylonjs.com/features/webgl2
  39023. */
  39024. disableWebGL2Support?: boolean;
  39025. /**
  39026. * Defines if webaudio should be initialized as well
  39027. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39028. */
  39029. audioEngine?: boolean;
  39030. /**
  39031. * Defines if animations should run using a deterministic lock step
  39032. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39033. */
  39034. deterministicLockstep?: boolean;
  39035. /** Defines the maximum steps to use with deterministic lock step mode */
  39036. lockstepMaxSteps?: number;
  39037. /** Defines the seconds between each deterministic lock step */
  39038. timeStep?: number;
  39039. /**
  39040. * Defines that engine should ignore context lost events
  39041. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39042. */
  39043. doNotHandleContextLost?: boolean;
  39044. /**
  39045. * Defines that engine should ignore modifying touch action attribute and style
  39046. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39047. */
  39048. doNotHandleTouchAction?: boolean;
  39049. /**
  39050. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39051. */
  39052. useHighPrecisionFloats?: boolean;
  39053. /**
  39054. * Make the canvas XR Compatible for XR sessions
  39055. */
  39056. xrCompatible?: boolean;
  39057. /**
  39058. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39059. */
  39060. useHighPrecisionMatrix?: boolean;
  39061. /**
  39062. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39063. */
  39064. failIfMajorPerformanceCaveat?: boolean;
  39065. }
  39066. /**
  39067. * The base engine class (root of all engines)
  39068. */
  39069. export class ThinEngine {
  39070. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39071. static ExceptionList: ({
  39072. key: string;
  39073. capture: string;
  39074. captureConstraint: number;
  39075. targets: string[];
  39076. } | {
  39077. key: string;
  39078. capture: null;
  39079. captureConstraint: null;
  39080. targets: string[];
  39081. })[];
  39082. /** @hidden */
  39083. static _TextureLoaders: IInternalTextureLoader[];
  39084. /**
  39085. * Returns the current npm package of the sdk
  39086. */
  39087. static get NpmPackage(): string;
  39088. /**
  39089. * Returns the current version of the framework
  39090. */
  39091. static get Version(): string;
  39092. /**
  39093. * Returns a string describing the current engine
  39094. */
  39095. get description(): string;
  39096. /**
  39097. * Gets or sets the epsilon value used by collision engine
  39098. */
  39099. static CollisionsEpsilon: number;
  39100. /**
  39101. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39102. */
  39103. static get ShadersRepository(): string;
  39104. static set ShadersRepository(value: string);
  39105. /** @hidden */
  39106. _shaderProcessor: IShaderProcessor;
  39107. /**
  39108. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39109. */
  39110. forcePOTTextures: boolean;
  39111. /**
  39112. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39113. */
  39114. isFullscreen: boolean;
  39115. /**
  39116. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39117. */
  39118. cullBackFaces: boolean;
  39119. /**
  39120. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39121. */
  39122. renderEvenInBackground: boolean;
  39123. /**
  39124. * Gets or sets a boolean indicating that cache can be kept between frames
  39125. */
  39126. preventCacheWipeBetweenFrames: boolean;
  39127. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39128. validateShaderPrograms: boolean;
  39129. /**
  39130. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39131. * This can provide greater z depth for distant objects.
  39132. */
  39133. useReverseDepthBuffer: boolean;
  39134. /**
  39135. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39136. */
  39137. disableUniformBuffers: boolean;
  39138. /** @hidden */
  39139. _uniformBuffers: UniformBuffer[];
  39140. /**
  39141. * Gets a boolean indicating that the engine supports uniform buffers
  39142. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39143. */
  39144. get supportsUniformBuffers(): boolean;
  39145. /** @hidden */
  39146. _gl: WebGLRenderingContext;
  39147. /** @hidden */
  39148. _webGLVersion: number;
  39149. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39150. protected _windowIsBackground: boolean;
  39151. protected _creationOptions: EngineOptions;
  39152. protected _highPrecisionShadersAllowed: boolean;
  39153. /** @hidden */
  39154. get _shouldUseHighPrecisionShader(): boolean;
  39155. /**
  39156. * Gets a boolean indicating that only power of 2 textures are supported
  39157. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39158. */
  39159. get needPOTTextures(): boolean;
  39160. /** @hidden */
  39161. _badOS: boolean;
  39162. /** @hidden */
  39163. _badDesktopOS: boolean;
  39164. private _hardwareScalingLevel;
  39165. /** @hidden */
  39166. _caps: EngineCapabilities;
  39167. private _isStencilEnable;
  39168. private _glVersion;
  39169. private _glRenderer;
  39170. private _glVendor;
  39171. /** @hidden */
  39172. _videoTextureSupported: boolean;
  39173. protected _renderingQueueLaunched: boolean;
  39174. protected _activeRenderLoops: (() => void)[];
  39175. /**
  39176. * Observable signaled when a context lost event is raised
  39177. */
  39178. onContextLostObservable: Observable<ThinEngine>;
  39179. /**
  39180. * Observable signaled when a context restored event is raised
  39181. */
  39182. onContextRestoredObservable: Observable<ThinEngine>;
  39183. private _onContextLost;
  39184. private _onContextRestored;
  39185. protected _contextWasLost: boolean;
  39186. /** @hidden */
  39187. _doNotHandleContextLost: boolean;
  39188. /**
  39189. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39190. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39191. */
  39192. get doNotHandleContextLost(): boolean;
  39193. set doNotHandleContextLost(value: boolean);
  39194. /**
  39195. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39196. */
  39197. disableVertexArrayObjects: boolean;
  39198. /** @hidden */
  39199. protected _colorWrite: boolean;
  39200. /** @hidden */
  39201. protected _colorWriteChanged: boolean;
  39202. /** @hidden */
  39203. protected _depthCullingState: DepthCullingState;
  39204. /** @hidden */
  39205. protected _stencilState: StencilState;
  39206. /** @hidden */
  39207. _alphaState: AlphaState;
  39208. /** @hidden */
  39209. _alphaMode: number;
  39210. /** @hidden */
  39211. _alphaEquation: number;
  39212. /** @hidden */
  39213. _internalTexturesCache: InternalTexture[];
  39214. /** @hidden */
  39215. protected _activeChannel: number;
  39216. private _currentTextureChannel;
  39217. /** @hidden */
  39218. protected _boundTexturesCache: {
  39219. [key: string]: Nullable<InternalTexture>;
  39220. };
  39221. /** @hidden */
  39222. protected _currentEffect: Nullable<Effect>;
  39223. /** @hidden */
  39224. protected _currentProgram: Nullable<WebGLProgram>;
  39225. private _compiledEffects;
  39226. private _vertexAttribArraysEnabled;
  39227. /** @hidden */
  39228. protected _cachedViewport: Nullable<IViewportLike>;
  39229. private _cachedVertexArrayObject;
  39230. /** @hidden */
  39231. protected _cachedVertexBuffers: any;
  39232. /** @hidden */
  39233. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  39234. /** @hidden */
  39235. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  39236. /** @hidden */
  39237. _currentRenderTarget: Nullable<InternalTexture>;
  39238. private _uintIndicesCurrentlySet;
  39239. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  39240. /** @hidden */
  39241. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  39242. /** @hidden */
  39243. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  39244. private _currentBufferPointers;
  39245. private _currentInstanceLocations;
  39246. private _currentInstanceBuffers;
  39247. private _textureUnits;
  39248. /** @hidden */
  39249. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39250. /** @hidden */
  39251. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39252. /** @hidden */
  39253. _boundRenderFunction: any;
  39254. private _vaoRecordInProgress;
  39255. private _mustWipeVertexAttributes;
  39256. private _emptyTexture;
  39257. private _emptyCubeTexture;
  39258. private _emptyTexture3D;
  39259. private _emptyTexture2DArray;
  39260. /** @hidden */
  39261. _frameHandler: number;
  39262. private _nextFreeTextureSlots;
  39263. private _maxSimultaneousTextures;
  39264. private _activeRequests;
  39265. /** @hidden */
  39266. _transformTextureUrl: Nullable<(url: string) => string>;
  39267. /**
  39268. * Gets information about the current host
  39269. */
  39270. hostInformation: HostInformation;
  39271. protected get _supportsHardwareTextureRescaling(): boolean;
  39272. private _framebufferDimensionsObject;
  39273. /**
  39274. * sets the object from which width and height will be taken from when getting render width and height
  39275. * Will fallback to the gl object
  39276. * @param dimensions the framebuffer width and height that will be used.
  39277. */
  39278. set framebufferDimensionsObject(dimensions: Nullable<{
  39279. framebufferWidth: number;
  39280. framebufferHeight: number;
  39281. }>);
  39282. /**
  39283. * Gets the current viewport
  39284. */
  39285. get currentViewport(): Nullable<IViewportLike>;
  39286. /**
  39287. * Gets the default empty texture
  39288. */
  39289. get emptyTexture(): InternalTexture;
  39290. /**
  39291. * Gets the default empty 3D texture
  39292. */
  39293. get emptyTexture3D(): InternalTexture;
  39294. /**
  39295. * Gets the default empty 2D array texture
  39296. */
  39297. get emptyTexture2DArray(): InternalTexture;
  39298. /**
  39299. * Gets the default empty cube texture
  39300. */
  39301. get emptyCubeTexture(): InternalTexture;
  39302. /**
  39303. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  39304. */
  39305. readonly premultipliedAlpha: boolean;
  39306. /**
  39307. * Observable event triggered before each texture is initialized
  39308. */
  39309. onBeforeTextureInitObservable: Observable<Texture>;
  39310. /**
  39311. * Creates a new engine
  39312. * @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
  39313. * @param antialias defines enable antialiasing (default: false)
  39314. * @param options defines further options to be sent to the getContext() function
  39315. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39316. */
  39317. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39318. private _rebuildInternalTextures;
  39319. private _rebuildEffects;
  39320. /**
  39321. * Gets a boolean indicating if all created effects are ready
  39322. * @returns true if all effects are ready
  39323. */
  39324. areAllEffectsReady(): boolean;
  39325. protected _rebuildBuffers(): void;
  39326. protected _initGLContext(): void;
  39327. /**
  39328. * Gets version of the current webGL context
  39329. */
  39330. get webGLVersion(): number;
  39331. /**
  39332. * Gets a string identifying the name of the class
  39333. * @returns "Engine" string
  39334. */
  39335. getClassName(): string;
  39336. /**
  39337. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39338. */
  39339. get isStencilEnable(): boolean;
  39340. /** @hidden */
  39341. _prepareWorkingCanvas(): void;
  39342. /**
  39343. * Reset the texture cache to empty state
  39344. */
  39345. resetTextureCache(): void;
  39346. /**
  39347. * Gets an object containing information about the current webGL context
  39348. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39349. */
  39350. getGlInfo(): {
  39351. vendor: string;
  39352. renderer: string;
  39353. version: string;
  39354. };
  39355. /**
  39356. * Defines the hardware scaling level.
  39357. * By default the hardware scaling level is computed from the window device ratio.
  39358. * 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.
  39359. * @param level defines the level to use
  39360. */
  39361. setHardwareScalingLevel(level: number): void;
  39362. /**
  39363. * Gets the current hardware scaling level.
  39364. * By default the hardware scaling level is computed from the window device ratio.
  39365. * 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.
  39366. * @returns a number indicating the current hardware scaling level
  39367. */
  39368. getHardwareScalingLevel(): number;
  39369. /**
  39370. * Gets the list of loaded textures
  39371. * @returns an array containing all loaded textures
  39372. */
  39373. getLoadedTexturesCache(): InternalTexture[];
  39374. /**
  39375. * Gets the object containing all engine capabilities
  39376. * @returns the EngineCapabilities object
  39377. */
  39378. getCaps(): EngineCapabilities;
  39379. /**
  39380. * stop executing a render loop function and remove it from the execution array
  39381. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39382. */
  39383. stopRenderLoop(renderFunction?: () => void): void;
  39384. /** @hidden */
  39385. _renderLoop(): void;
  39386. /**
  39387. * Gets the HTML canvas attached with the current webGL context
  39388. * @returns a HTML canvas
  39389. */
  39390. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39391. /**
  39392. * Gets host window
  39393. * @returns the host window object
  39394. */
  39395. getHostWindow(): Nullable<Window>;
  39396. /**
  39397. * Gets the current render width
  39398. * @param useScreen defines if screen size must be used (or the current render target if any)
  39399. * @returns a number defining the current render width
  39400. */
  39401. getRenderWidth(useScreen?: boolean): number;
  39402. /**
  39403. * Gets the current render height
  39404. * @param useScreen defines if screen size must be used (or the current render target if any)
  39405. * @returns a number defining the current render height
  39406. */
  39407. getRenderHeight(useScreen?: boolean): number;
  39408. /**
  39409. * Can be used to override the current requestAnimationFrame requester.
  39410. * @hidden
  39411. */
  39412. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39413. /**
  39414. * Register and execute a render loop. The engine can have more than one render function
  39415. * @param renderFunction defines the function to continuously execute
  39416. */
  39417. runRenderLoop(renderFunction: () => void): void;
  39418. /**
  39419. * Clear the current render buffer or the current render target (if any is set up)
  39420. * @param color defines the color to use
  39421. * @param backBuffer defines if the back buffer must be cleared
  39422. * @param depth defines if the depth buffer must be cleared
  39423. * @param stencil defines if the stencil buffer must be cleared
  39424. */
  39425. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39426. private _viewportCached;
  39427. /** @hidden */
  39428. _viewport(x: number, y: number, width: number, height: number): void;
  39429. /**
  39430. * Set the WebGL's viewport
  39431. * @param viewport defines the viewport element to be used
  39432. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39433. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39434. */
  39435. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39436. /**
  39437. * Begin a new frame
  39438. */
  39439. beginFrame(): void;
  39440. /**
  39441. * Enf the current frame
  39442. */
  39443. endFrame(): void;
  39444. /**
  39445. * Resize the view according to the canvas' size
  39446. */
  39447. resize(): void;
  39448. /**
  39449. * Force a specific size of the canvas
  39450. * @param width defines the new canvas' width
  39451. * @param height defines the new canvas' height
  39452. * @returns true if the size was changed
  39453. */
  39454. setSize(width: number, height: number): boolean;
  39455. /**
  39456. * Binds the frame buffer to the specified texture.
  39457. * @param texture The texture to render to or null for the default canvas
  39458. * @param faceIndex The face of the texture to render to in case of cube texture
  39459. * @param requiredWidth The width of the target to render to
  39460. * @param requiredHeight The height of the target to render to
  39461. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39462. * @param lodLevel defines the lod level to bind to the frame buffer
  39463. * @param layer defines the 2d array index to bind to frame buffer to
  39464. */
  39465. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39466. /** @hidden */
  39467. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39468. /**
  39469. * Unbind the current render target texture from the webGL context
  39470. * @param texture defines the render target texture to unbind
  39471. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39472. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39473. */
  39474. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39475. /**
  39476. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39477. */
  39478. flushFramebuffer(): void;
  39479. /**
  39480. * Unbind the current render target and bind the default framebuffer
  39481. */
  39482. restoreDefaultFramebuffer(): void;
  39483. /** @hidden */
  39484. protected _resetVertexBufferBinding(): void;
  39485. /**
  39486. * Creates a vertex buffer
  39487. * @param data the data for the vertex buffer
  39488. * @returns the new WebGL static buffer
  39489. */
  39490. createVertexBuffer(data: DataArray): DataBuffer;
  39491. private _createVertexBuffer;
  39492. /**
  39493. * Creates a dynamic vertex buffer
  39494. * @param data the data for the dynamic vertex buffer
  39495. * @returns the new WebGL dynamic buffer
  39496. */
  39497. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39498. protected _resetIndexBufferBinding(): void;
  39499. /**
  39500. * Creates a new index buffer
  39501. * @param indices defines the content of the index buffer
  39502. * @param updatable defines if the index buffer must be updatable
  39503. * @returns a new webGL buffer
  39504. */
  39505. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39506. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39507. /**
  39508. * Bind a webGL buffer to the webGL context
  39509. * @param buffer defines the buffer to bind
  39510. */
  39511. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39512. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39513. private bindBuffer;
  39514. /**
  39515. * update the bound buffer with the given data
  39516. * @param data defines the data to update
  39517. */
  39518. updateArrayBuffer(data: Float32Array): void;
  39519. private _vertexAttribPointer;
  39520. /** @hidden */
  39521. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39522. private _bindVertexBuffersAttributes;
  39523. /**
  39524. * Records a vertex array object
  39525. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39526. * @param vertexBuffers defines the list of vertex buffers to store
  39527. * @param indexBuffer defines the index buffer to store
  39528. * @param effect defines the effect to store
  39529. * @returns the new vertex array object
  39530. */
  39531. recordVertexArrayObject(vertexBuffers: {
  39532. [key: string]: VertexBuffer;
  39533. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39534. /**
  39535. * Bind a specific vertex array object
  39536. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39537. * @param vertexArrayObject defines the vertex array object to bind
  39538. * @param indexBuffer defines the index buffer to bind
  39539. */
  39540. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39541. /**
  39542. * Bind webGl buffers directly to the webGL context
  39543. * @param vertexBuffer defines the vertex buffer to bind
  39544. * @param indexBuffer defines the index buffer to bind
  39545. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39546. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39547. * @param effect defines the effect associated with the vertex buffer
  39548. */
  39549. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39550. private _unbindVertexArrayObject;
  39551. /**
  39552. * Bind a list of vertex buffers to the webGL context
  39553. * @param vertexBuffers defines the list of vertex buffers to bind
  39554. * @param indexBuffer defines the index buffer to bind
  39555. * @param effect defines the effect associated with the vertex buffers
  39556. */
  39557. bindBuffers(vertexBuffers: {
  39558. [key: string]: Nullable<VertexBuffer>;
  39559. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39560. /**
  39561. * Unbind all instance attributes
  39562. */
  39563. unbindInstanceAttributes(): void;
  39564. /**
  39565. * Release and free the memory of a vertex array object
  39566. * @param vao defines the vertex array object to delete
  39567. */
  39568. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39569. /** @hidden */
  39570. _releaseBuffer(buffer: DataBuffer): boolean;
  39571. protected _deleteBuffer(buffer: DataBuffer): void;
  39572. /**
  39573. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39574. * @param instancesBuffer defines the webGL buffer to update and bind
  39575. * @param data defines the data to store in the buffer
  39576. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39577. */
  39578. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39579. /**
  39580. * Bind the content of a webGL buffer used with instantiation
  39581. * @param instancesBuffer defines the webGL buffer to bind
  39582. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39583. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39584. */
  39585. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39586. /**
  39587. * Disable the instance attribute corresponding to the name in parameter
  39588. * @param name defines the name of the attribute to disable
  39589. */
  39590. disableInstanceAttributeByName(name: string): void;
  39591. /**
  39592. * Disable the instance attribute corresponding to the location in parameter
  39593. * @param attributeLocation defines the attribute location of the attribute to disable
  39594. */
  39595. disableInstanceAttribute(attributeLocation: number): void;
  39596. /**
  39597. * Disable the attribute corresponding to the location in parameter
  39598. * @param attributeLocation defines the attribute location of the attribute to disable
  39599. */
  39600. disableAttributeByIndex(attributeLocation: number): void;
  39601. /**
  39602. * Send a draw order
  39603. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39604. * @param indexStart defines the starting index
  39605. * @param indexCount defines the number of index to draw
  39606. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39607. */
  39608. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39609. /**
  39610. * Draw a list of points
  39611. * @param verticesStart defines the index of first vertex to draw
  39612. * @param verticesCount defines the count of vertices to draw
  39613. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39614. */
  39615. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39616. /**
  39617. * Draw a list of unindexed primitives
  39618. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39619. * @param verticesStart defines the index of first vertex to draw
  39620. * @param verticesCount defines the count of vertices to draw
  39621. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39622. */
  39623. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39624. /**
  39625. * Draw a list of indexed primitives
  39626. * @param fillMode defines the primitive to use
  39627. * @param indexStart defines the starting index
  39628. * @param indexCount defines the number of index to draw
  39629. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39630. */
  39631. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39632. /**
  39633. * Draw a list of unindexed primitives
  39634. * @param fillMode defines the primitive to use
  39635. * @param verticesStart defines the index of first vertex to draw
  39636. * @param verticesCount defines the count of vertices to draw
  39637. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39638. */
  39639. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39640. private _drawMode;
  39641. /** @hidden */
  39642. protected _reportDrawCall(): void;
  39643. /** @hidden */
  39644. _releaseEffect(effect: Effect): void;
  39645. /** @hidden */
  39646. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39647. /**
  39648. * Create a new effect (used to store vertex/fragment shaders)
  39649. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39650. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39651. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39652. * @param samplers defines an array of string used to represent textures
  39653. * @param defines defines the string containing the defines to use to compile the shaders
  39654. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39655. * @param onCompiled defines a function to call when the effect creation is successful
  39656. * @param onError defines a function to call when the effect creation has failed
  39657. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39658. * @returns the new Effect
  39659. */
  39660. 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;
  39661. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39662. private _compileShader;
  39663. private _compileRawShader;
  39664. /** @hidden */
  39665. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39666. /**
  39667. * Directly creates a webGL program
  39668. * @param pipelineContext defines the pipeline context to attach to
  39669. * @param vertexCode defines the vertex shader code to use
  39670. * @param fragmentCode defines the fragment shader code to use
  39671. * @param context defines the webGL context to use (if not set, the current one will be used)
  39672. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39673. * @returns the new webGL program
  39674. */
  39675. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39676. /**
  39677. * Creates a webGL program
  39678. * @param pipelineContext defines the pipeline context to attach to
  39679. * @param vertexCode defines the vertex shader code to use
  39680. * @param fragmentCode defines the fragment shader code to use
  39681. * @param defines defines the string containing the defines to use to compile the shaders
  39682. * @param context defines the webGL context to use (if not set, the current one will be used)
  39683. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39684. * @returns the new webGL program
  39685. */
  39686. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39687. /**
  39688. * Creates a new pipeline context
  39689. * @returns the new pipeline
  39690. */
  39691. createPipelineContext(): IPipelineContext;
  39692. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39693. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39694. /** @hidden */
  39695. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39696. /** @hidden */
  39697. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39698. /** @hidden */
  39699. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39700. /**
  39701. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39702. * @param pipelineContext defines the pipeline context to use
  39703. * @param uniformsNames defines the list of uniform names
  39704. * @returns an array of webGL uniform locations
  39705. */
  39706. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39707. /**
  39708. * Gets the lsit of active attributes for a given webGL program
  39709. * @param pipelineContext defines the pipeline context to use
  39710. * @param attributesNames defines the list of attribute names to get
  39711. * @returns an array of indices indicating the offset of each attribute
  39712. */
  39713. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39714. /**
  39715. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39716. * @param effect defines the effect to activate
  39717. */
  39718. enableEffect(effect: Nullable<Effect>): void;
  39719. /**
  39720. * Set the value of an uniform to a number (int)
  39721. * @param uniform defines the webGL uniform location where to store the value
  39722. * @param value defines the int number to store
  39723. * @returns true if the value was set
  39724. */
  39725. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39726. /**
  39727. * Set the value of an uniform to an array of int32
  39728. * @param uniform defines the webGL uniform location where to store the value
  39729. * @param array defines the array of int32 to store
  39730. * @returns true if the value was set
  39731. */
  39732. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39733. /**
  39734. * Set the value of an uniform to an array of int32 (stored as vec2)
  39735. * @param uniform defines the webGL uniform location where to store the value
  39736. * @param array defines the array of int32 to store
  39737. * @returns true if the value was set
  39738. */
  39739. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39740. /**
  39741. * Set the value of an uniform to an array of int32 (stored as vec3)
  39742. * @param uniform defines the webGL uniform location where to store the value
  39743. * @param array defines the array of int32 to store
  39744. * @returns true if the value was set
  39745. */
  39746. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39747. /**
  39748. * Set the value of an uniform to an array of int32 (stored as vec4)
  39749. * @param uniform defines the webGL uniform location where to store the value
  39750. * @param array defines the array of int32 to store
  39751. * @returns true if the value was set
  39752. */
  39753. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39754. /**
  39755. * Set the value of an uniform to an array of number
  39756. * @param uniform defines the webGL uniform location where to store the value
  39757. * @param array defines the array of number to store
  39758. * @returns true if the value was set
  39759. */
  39760. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39761. /**
  39762. * Set the value of an uniform to an array of number (stored as vec2)
  39763. * @param uniform defines the webGL uniform location where to store the value
  39764. * @param array defines the array of number to store
  39765. * @returns true if the value was set
  39766. */
  39767. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39768. /**
  39769. * Set the value of an uniform to an array of number (stored as vec3)
  39770. * @param uniform defines the webGL uniform location where to store the value
  39771. * @param array defines the array of number to store
  39772. * @returns true if the value was set
  39773. */
  39774. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39775. /**
  39776. * Set the value of an uniform to an array of number (stored as vec4)
  39777. * @param uniform defines the webGL uniform location where to store the value
  39778. * @param array defines the array of number to store
  39779. * @returns true if the value was set
  39780. */
  39781. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39782. /**
  39783. * Set the value of an uniform to an array of float32 (stored as matrices)
  39784. * @param uniform defines the webGL uniform location where to store the value
  39785. * @param matrices defines the array of float32 to store
  39786. * @returns true if the value was set
  39787. */
  39788. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39789. /**
  39790. * Set the value of an uniform to a matrix (3x3)
  39791. * @param uniform defines the webGL uniform location where to store the value
  39792. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39793. * @returns true if the value was set
  39794. */
  39795. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39796. /**
  39797. * Set the value of an uniform to a matrix (2x2)
  39798. * @param uniform defines the webGL uniform location where to store the value
  39799. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39800. * @returns true if the value was set
  39801. */
  39802. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39803. /**
  39804. * Set the value of an uniform to a number (float)
  39805. * @param uniform defines the webGL uniform location where to store the value
  39806. * @param value defines the float number to store
  39807. * @returns true if the value was transfered
  39808. */
  39809. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39810. /**
  39811. * Set the value of an uniform to a vec2
  39812. * @param uniform defines the webGL uniform location where to store the value
  39813. * @param x defines the 1st component of the value
  39814. * @param y defines the 2nd component of the value
  39815. * @returns true if the value was set
  39816. */
  39817. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39818. /**
  39819. * Set the value of an uniform to a vec3
  39820. * @param uniform defines the webGL uniform location where to store the value
  39821. * @param x defines the 1st component of the value
  39822. * @param y defines the 2nd component of the value
  39823. * @param z defines the 3rd component of the value
  39824. * @returns true if the value was set
  39825. */
  39826. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39827. /**
  39828. * Set the value of an uniform to a vec4
  39829. * @param uniform defines the webGL uniform location where to store the value
  39830. * @param x defines the 1st component of the value
  39831. * @param y defines the 2nd component of the value
  39832. * @param z defines the 3rd component of the value
  39833. * @param w defines the 4th component of the value
  39834. * @returns true if the value was set
  39835. */
  39836. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39837. /**
  39838. * Apply all cached states (depth, culling, stencil and alpha)
  39839. */
  39840. applyStates(): void;
  39841. /**
  39842. * Enable or disable color writing
  39843. * @param enable defines the state to set
  39844. */
  39845. setColorWrite(enable: boolean): void;
  39846. /**
  39847. * Gets a boolean indicating if color writing is enabled
  39848. * @returns the current color writing state
  39849. */
  39850. getColorWrite(): boolean;
  39851. /**
  39852. * Gets the depth culling state manager
  39853. */
  39854. get depthCullingState(): DepthCullingState;
  39855. /**
  39856. * Gets the alpha state manager
  39857. */
  39858. get alphaState(): AlphaState;
  39859. /**
  39860. * Gets the stencil state manager
  39861. */
  39862. get stencilState(): StencilState;
  39863. /**
  39864. * Clears the list of texture accessible through engine.
  39865. * This can help preventing texture load conflict due to name collision.
  39866. */
  39867. clearInternalTexturesCache(): void;
  39868. /**
  39869. * Force the entire cache to be cleared
  39870. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39871. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39872. */
  39873. wipeCaches(bruteForce?: boolean): void;
  39874. /** @hidden */
  39875. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39876. min: number;
  39877. mag: number;
  39878. };
  39879. /** @hidden */
  39880. _createTexture(): WebGLTexture;
  39881. /**
  39882. * Usually called from Texture.ts.
  39883. * Passed information to create a WebGLTexture
  39884. * @param url defines a value which contains one of the following:
  39885. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39886. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39887. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39888. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39889. * @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)
  39890. * @param scene needed for loading to the correct scene
  39891. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39892. * @param onLoad optional callback to be called upon successful completion
  39893. * @param onError optional callback to be called upon failure
  39894. * @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
  39895. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39896. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39897. * @param forcedExtension defines the extension to use to pick the right loader
  39898. * @param mimeType defines an optional mime type
  39899. * @param loaderOptions options to be passed to the loader
  39900. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39901. */
  39902. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  39903. /**
  39904. * Loads an image as an HTMLImageElement.
  39905. * @param input url string, ArrayBuffer, or Blob to load
  39906. * @param onLoad callback called when the image successfully loads
  39907. * @param onError callback called when the image fails to load
  39908. * @param offlineProvider offline provider for caching
  39909. * @param mimeType optional mime type
  39910. * @returns the HTMLImageElement of the loaded image
  39911. * @hidden
  39912. */
  39913. 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>;
  39914. /**
  39915. * @hidden
  39916. */
  39917. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39918. private _unpackFlipYCached;
  39919. /**
  39920. * In case you are sharing the context with other applications, it might
  39921. * be interested to not cache the unpack flip y state to ensure a consistent
  39922. * value would be set.
  39923. */
  39924. enableUnpackFlipYCached: boolean;
  39925. /** @hidden */
  39926. _unpackFlipY(value: boolean): void;
  39927. /** @hidden */
  39928. _getUnpackAlignement(): number;
  39929. private _getTextureTarget;
  39930. /**
  39931. * Update the sampling mode of a given texture
  39932. * @param samplingMode defines the required sampling mode
  39933. * @param texture defines the texture to update
  39934. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39935. */
  39936. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39937. /**
  39938. * Update the sampling mode of a given texture
  39939. * @param texture defines the texture to update
  39940. * @param wrapU defines the texture wrap mode of the u coordinates
  39941. * @param wrapV defines the texture wrap mode of the v coordinates
  39942. * @param wrapR defines the texture wrap mode of the r coordinates
  39943. */
  39944. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39945. /** @hidden */
  39946. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39947. width: number;
  39948. height: number;
  39949. layers?: number;
  39950. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39951. /** @hidden */
  39952. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39953. /** @hidden */
  39954. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39955. /**
  39956. * Update a portion of an internal texture
  39957. * @param texture defines the texture to update
  39958. * @param imageData defines the data to store into the texture
  39959. * @param xOffset defines the x coordinates of the update rectangle
  39960. * @param yOffset defines the y coordinates of the update rectangle
  39961. * @param width defines the width of the update rectangle
  39962. * @param height defines the height of the update rectangle
  39963. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39964. * @param lod defines the lod level to update (0 by default)
  39965. */
  39966. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39967. /** @hidden */
  39968. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39969. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39970. private _prepareWebGLTexture;
  39971. /** @hidden */
  39972. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39973. private _getDepthStencilBuffer;
  39974. /** @hidden */
  39975. _releaseFramebufferObjects(texture: InternalTexture): void;
  39976. /** @hidden */
  39977. _releaseTexture(texture: InternalTexture): void;
  39978. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39979. protected _setProgram(program: WebGLProgram): void;
  39980. protected _boundUniforms: {
  39981. [key: number]: WebGLUniformLocation;
  39982. };
  39983. /**
  39984. * Binds an effect to the webGL context
  39985. * @param effect defines the effect to bind
  39986. */
  39987. bindSamplers(effect: Effect): void;
  39988. private _activateCurrentTexture;
  39989. /** @hidden */
  39990. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39991. /** @hidden */
  39992. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39993. /**
  39994. * Unbind all textures from the webGL context
  39995. */
  39996. unbindAllTextures(): void;
  39997. /**
  39998. * Sets a texture to the according uniform.
  39999. * @param channel The texture channel
  40000. * @param uniform The uniform to set
  40001. * @param texture The texture to apply
  40002. */
  40003. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  40004. private _bindSamplerUniformToChannel;
  40005. private _getTextureWrapMode;
  40006. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  40007. /**
  40008. * Sets an array of texture to the webGL context
  40009. * @param channel defines the channel where the texture array must be set
  40010. * @param uniform defines the associated uniform location
  40011. * @param textures defines the array of textures to bind
  40012. */
  40013. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  40014. /** @hidden */
  40015. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40016. private _setTextureParameterFloat;
  40017. private _setTextureParameterInteger;
  40018. /**
  40019. * Unbind all vertex attributes from the webGL context
  40020. */
  40021. unbindAllAttributes(): void;
  40022. /**
  40023. * 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
  40024. */
  40025. releaseEffects(): void;
  40026. /**
  40027. * Dispose and release all associated resources
  40028. */
  40029. dispose(): void;
  40030. /**
  40031. * Attach a new callback raised when context lost event is fired
  40032. * @param callback defines the callback to call
  40033. */
  40034. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40035. /**
  40036. * Attach a new callback raised when context restored event is fired
  40037. * @param callback defines the callback to call
  40038. */
  40039. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40040. /**
  40041. * Get the current error code of the webGL context
  40042. * @returns the error code
  40043. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40044. */
  40045. getError(): number;
  40046. private _canRenderToFloatFramebuffer;
  40047. private _canRenderToHalfFloatFramebuffer;
  40048. private _canRenderToFramebuffer;
  40049. /** @hidden */
  40050. _getWebGLTextureType(type: number): number;
  40051. /** @hidden */
  40052. _getInternalFormat(format: number): number;
  40053. /** @hidden */
  40054. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40055. /** @hidden */
  40056. _getRGBAMultiSampleBufferFormat(type: number): number;
  40057. /** @hidden */
  40058. _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;
  40059. /**
  40060. * Loads a file from a url
  40061. * @param url url to load
  40062. * @param onSuccess callback called when the file successfully loads
  40063. * @param onProgress callback called while file is loading (if the server supports this mode)
  40064. * @param offlineProvider defines the offline provider for caching
  40065. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40066. * @param onError callback called when the file fails to load
  40067. * @returns a file request object
  40068. * @hidden
  40069. */
  40070. 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;
  40071. /**
  40072. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40073. * @param x defines the x coordinate of the rectangle where pixels must be read
  40074. * @param y defines the y coordinate of the rectangle where pixels must be read
  40075. * @param width defines the width of the rectangle where pixels must be read
  40076. * @param height defines the height of the rectangle where pixels must be read
  40077. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40078. * @returns a Uint8Array containing RGBA colors
  40079. */
  40080. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40081. private static _IsSupported;
  40082. private static _HasMajorPerformanceCaveat;
  40083. /**
  40084. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40085. */
  40086. static get IsSupported(): boolean;
  40087. /**
  40088. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40089. * @returns true if the engine can be created
  40090. * @ignorenaming
  40091. */
  40092. static isSupported(): boolean;
  40093. /**
  40094. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  40095. */
  40096. static get HasMajorPerformanceCaveat(): boolean;
  40097. /**
  40098. * Find the next highest power of two.
  40099. * @param x Number to start search from.
  40100. * @return Next highest power of two.
  40101. */
  40102. static CeilingPOT(x: number): number;
  40103. /**
  40104. * Find the next lowest power of two.
  40105. * @param x Number to start search from.
  40106. * @return Next lowest power of two.
  40107. */
  40108. static FloorPOT(x: number): number;
  40109. /**
  40110. * Find the nearest power of two.
  40111. * @param x Number to start search from.
  40112. * @return Next nearest power of two.
  40113. */
  40114. static NearestPOT(x: number): number;
  40115. /**
  40116. * Get the closest exponent of two
  40117. * @param value defines the value to approximate
  40118. * @param max defines the maximum value to return
  40119. * @param mode defines how to define the closest value
  40120. * @returns closest exponent of two of the given value
  40121. */
  40122. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40123. /**
  40124. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40125. * @param func - the function to be called
  40126. * @param requester - the object that will request the next frame. Falls back to window.
  40127. * @returns frame number
  40128. */
  40129. static QueueNewFrame(func: () => void, requester?: any): number;
  40130. /**
  40131. * Gets host document
  40132. * @returns the host document object
  40133. */
  40134. getHostDocument(): Nullable<Document>;
  40135. }
  40136. }
  40137. declare module BABYLON {
  40138. /**
  40139. * Defines the source of the internal texture
  40140. */
  40141. export enum InternalTextureSource {
  40142. /**
  40143. * The source of the texture data is unknown
  40144. */
  40145. Unknown = 0,
  40146. /**
  40147. * Texture data comes from an URL
  40148. */
  40149. Url = 1,
  40150. /**
  40151. * Texture data is only used for temporary storage
  40152. */
  40153. Temp = 2,
  40154. /**
  40155. * Texture data comes from raw data (ArrayBuffer)
  40156. */
  40157. Raw = 3,
  40158. /**
  40159. * Texture content is dynamic (video or dynamic texture)
  40160. */
  40161. Dynamic = 4,
  40162. /**
  40163. * Texture content is generated by rendering to it
  40164. */
  40165. RenderTarget = 5,
  40166. /**
  40167. * Texture content is part of a multi render target process
  40168. */
  40169. MultiRenderTarget = 6,
  40170. /**
  40171. * Texture data comes from a cube data file
  40172. */
  40173. Cube = 7,
  40174. /**
  40175. * Texture data comes from a raw cube data
  40176. */
  40177. CubeRaw = 8,
  40178. /**
  40179. * Texture data come from a prefiltered cube data file
  40180. */
  40181. CubePrefiltered = 9,
  40182. /**
  40183. * Texture content is raw 3D data
  40184. */
  40185. Raw3D = 10,
  40186. /**
  40187. * Texture content is raw 2D array data
  40188. */
  40189. Raw2DArray = 11,
  40190. /**
  40191. * Texture content is a depth texture
  40192. */
  40193. Depth = 12,
  40194. /**
  40195. * Texture data comes from a raw cube data encoded with RGBD
  40196. */
  40197. CubeRawRGBD = 13
  40198. }
  40199. /**
  40200. * Class used to store data associated with WebGL texture data for the engine
  40201. * This class should not be used directly
  40202. */
  40203. export class InternalTexture {
  40204. /** @hidden */
  40205. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40206. /**
  40207. * Defines if the texture is ready
  40208. */
  40209. isReady: boolean;
  40210. /**
  40211. * Defines if the texture is a cube texture
  40212. */
  40213. isCube: boolean;
  40214. /**
  40215. * Defines if the texture contains 3D data
  40216. */
  40217. is3D: boolean;
  40218. /**
  40219. * Defines if the texture contains 2D array data
  40220. */
  40221. is2DArray: boolean;
  40222. /**
  40223. * Defines if the texture contains multiview data
  40224. */
  40225. isMultiview: boolean;
  40226. /**
  40227. * Gets the URL used to load this texture
  40228. */
  40229. url: string;
  40230. /** @hidden */
  40231. _originalUrl: string;
  40232. /**
  40233. * Gets the sampling mode of the texture
  40234. */
  40235. samplingMode: number;
  40236. /**
  40237. * Gets a boolean indicating if the texture needs mipmaps generation
  40238. */
  40239. generateMipMaps: boolean;
  40240. /**
  40241. * Gets the number of samples used by the texture (WebGL2+ only)
  40242. */
  40243. samples: number;
  40244. /**
  40245. * Gets the type of the texture (int, float...)
  40246. */
  40247. type: number;
  40248. /**
  40249. * Gets the format of the texture (RGB, RGBA...)
  40250. */
  40251. format: number;
  40252. /**
  40253. * Observable called when the texture is loaded
  40254. */
  40255. onLoadedObservable: Observable<InternalTexture>;
  40256. /**
  40257. * Gets the width of the texture
  40258. */
  40259. width: number;
  40260. /**
  40261. * Gets the height of the texture
  40262. */
  40263. height: number;
  40264. /**
  40265. * Gets the depth of the texture
  40266. */
  40267. depth: number;
  40268. /**
  40269. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  40270. */
  40271. baseWidth: number;
  40272. /**
  40273. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  40274. */
  40275. baseHeight: number;
  40276. /**
  40277. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  40278. */
  40279. baseDepth: number;
  40280. /**
  40281. * Gets a boolean indicating if the texture is inverted on Y axis
  40282. */
  40283. invertY: boolean;
  40284. /** @hidden */
  40285. _invertVScale: boolean;
  40286. /** @hidden */
  40287. _associatedChannel: number;
  40288. /** @hidden */
  40289. _source: InternalTextureSource;
  40290. /** @hidden */
  40291. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  40292. /** @hidden */
  40293. _bufferView: Nullable<ArrayBufferView>;
  40294. /** @hidden */
  40295. _bufferViewArray: Nullable<ArrayBufferView[]>;
  40296. /** @hidden */
  40297. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  40298. /** @hidden */
  40299. _size: number;
  40300. /** @hidden */
  40301. _extension: string;
  40302. /** @hidden */
  40303. _files: Nullable<string[]>;
  40304. /** @hidden */
  40305. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40306. /** @hidden */
  40307. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40308. /** @hidden */
  40309. _framebuffer: Nullable<WebGLFramebuffer>;
  40310. /** @hidden */
  40311. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40312. /** @hidden */
  40313. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40314. /** @hidden */
  40315. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40316. /** @hidden */
  40317. _attachments: Nullable<number[]>;
  40318. /** @hidden */
  40319. _textureArray: Nullable<InternalTexture[]>;
  40320. /** @hidden */
  40321. _cachedCoordinatesMode: Nullable<number>;
  40322. /** @hidden */
  40323. _cachedWrapU: Nullable<number>;
  40324. /** @hidden */
  40325. _cachedWrapV: Nullable<number>;
  40326. /** @hidden */
  40327. _cachedWrapR: Nullable<number>;
  40328. /** @hidden */
  40329. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40330. /** @hidden */
  40331. _isDisabled: boolean;
  40332. /** @hidden */
  40333. _compression: Nullable<string>;
  40334. /** @hidden */
  40335. _generateStencilBuffer: boolean;
  40336. /** @hidden */
  40337. _generateDepthBuffer: boolean;
  40338. /** @hidden */
  40339. _comparisonFunction: number;
  40340. /** @hidden */
  40341. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40342. /** @hidden */
  40343. _lodGenerationScale: number;
  40344. /** @hidden */
  40345. _lodGenerationOffset: number;
  40346. /** @hidden */
  40347. _depthStencilTexture: Nullable<InternalTexture>;
  40348. /** @hidden */
  40349. _colorTextureArray: Nullable<WebGLTexture>;
  40350. /** @hidden */
  40351. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40352. /** @hidden */
  40353. _lodTextureHigh: Nullable<BaseTexture>;
  40354. /** @hidden */
  40355. _lodTextureMid: Nullable<BaseTexture>;
  40356. /** @hidden */
  40357. _lodTextureLow: Nullable<BaseTexture>;
  40358. /** @hidden */
  40359. _isRGBD: boolean;
  40360. /** @hidden */
  40361. _linearSpecularLOD: boolean;
  40362. /** @hidden */
  40363. _irradianceTexture: Nullable<BaseTexture>;
  40364. /** @hidden */
  40365. _webGLTexture: Nullable<WebGLTexture>;
  40366. /** @hidden */
  40367. _references: number;
  40368. /** @hidden */
  40369. _gammaSpace: Nullable<boolean>;
  40370. private _engine;
  40371. /**
  40372. * Gets the Engine the texture belongs to.
  40373. * @returns The babylon engine
  40374. */
  40375. getEngine(): ThinEngine;
  40376. /**
  40377. * Gets the data source type of the texture
  40378. */
  40379. get source(): InternalTextureSource;
  40380. /**
  40381. * Creates a new InternalTexture
  40382. * @param engine defines the engine to use
  40383. * @param source defines the type of data that will be used
  40384. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40385. */
  40386. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40387. /**
  40388. * Increments the number of references (ie. the number of Texture that point to it)
  40389. */
  40390. incrementReferences(): void;
  40391. /**
  40392. * Change the size of the texture (not the size of the content)
  40393. * @param width defines the new width
  40394. * @param height defines the new height
  40395. * @param depth defines the new depth (1 by default)
  40396. */
  40397. updateSize(width: int, height: int, depth?: int): void;
  40398. /** @hidden */
  40399. _rebuild(): void;
  40400. /** @hidden */
  40401. _swapAndDie(target: InternalTexture): void;
  40402. /**
  40403. * Dispose the current allocated resources
  40404. */
  40405. dispose(): void;
  40406. }
  40407. }
  40408. declare module BABYLON {
  40409. /**
  40410. * Interface used to present a loading screen while loading a scene
  40411. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40412. */
  40413. export interface ILoadingScreen {
  40414. /**
  40415. * Function called to display the loading screen
  40416. */
  40417. displayLoadingUI: () => void;
  40418. /**
  40419. * Function called to hide the loading screen
  40420. */
  40421. hideLoadingUI: () => void;
  40422. /**
  40423. * Gets or sets the color to use for the background
  40424. */
  40425. loadingUIBackgroundColor: string;
  40426. /**
  40427. * Gets or sets the text to display while loading
  40428. */
  40429. loadingUIText: string;
  40430. }
  40431. /**
  40432. * Class used for the default loading screen
  40433. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40434. */
  40435. export class DefaultLoadingScreen implements ILoadingScreen {
  40436. private _renderingCanvas;
  40437. private _loadingText;
  40438. private _loadingDivBackgroundColor;
  40439. private _loadingDiv;
  40440. private _loadingTextDiv;
  40441. /** Gets or sets the logo url to use for the default loading screen */
  40442. static DefaultLogoUrl: string;
  40443. /** Gets or sets the spinner url to use for the default loading screen */
  40444. static DefaultSpinnerUrl: string;
  40445. /**
  40446. * Creates a new default loading screen
  40447. * @param _renderingCanvas defines the canvas used to render the scene
  40448. * @param _loadingText defines the default text to display
  40449. * @param _loadingDivBackgroundColor defines the default background color
  40450. */
  40451. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40452. /**
  40453. * Function called to display the loading screen
  40454. */
  40455. displayLoadingUI(): void;
  40456. /**
  40457. * Function called to hide the loading screen
  40458. */
  40459. hideLoadingUI(): void;
  40460. /**
  40461. * Gets or sets the text to display while loading
  40462. */
  40463. set loadingUIText(text: string);
  40464. get loadingUIText(): string;
  40465. /**
  40466. * Gets or sets the color to use for the background
  40467. */
  40468. get loadingUIBackgroundColor(): string;
  40469. set loadingUIBackgroundColor(color: string);
  40470. private _resizeLoadingUI;
  40471. }
  40472. }
  40473. declare module BABYLON {
  40474. /**
  40475. * Interface for any object that can request an animation frame
  40476. */
  40477. export interface ICustomAnimationFrameRequester {
  40478. /**
  40479. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40480. */
  40481. renderFunction?: Function;
  40482. /**
  40483. * Called to request the next frame to render to
  40484. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40485. */
  40486. requestAnimationFrame: Function;
  40487. /**
  40488. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40489. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40490. */
  40491. requestID?: number;
  40492. }
  40493. }
  40494. declare module BABYLON {
  40495. /**
  40496. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40497. */
  40498. export class PerformanceMonitor {
  40499. private _enabled;
  40500. private _rollingFrameTime;
  40501. private _lastFrameTimeMs;
  40502. /**
  40503. * constructor
  40504. * @param frameSampleSize The number of samples required to saturate the sliding window
  40505. */
  40506. constructor(frameSampleSize?: number);
  40507. /**
  40508. * Samples current frame
  40509. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40510. */
  40511. sampleFrame(timeMs?: number): void;
  40512. /**
  40513. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40514. */
  40515. get averageFrameTime(): number;
  40516. /**
  40517. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40518. */
  40519. get averageFrameTimeVariance(): number;
  40520. /**
  40521. * Returns the frame time of the most recent frame
  40522. */
  40523. get instantaneousFrameTime(): number;
  40524. /**
  40525. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40526. */
  40527. get averageFPS(): number;
  40528. /**
  40529. * Returns the average framerate in frames per second using the most recent frame time
  40530. */
  40531. get instantaneousFPS(): number;
  40532. /**
  40533. * Returns true if enough samples have been taken to completely fill the sliding window
  40534. */
  40535. get isSaturated(): boolean;
  40536. /**
  40537. * Enables contributions to the sliding window sample set
  40538. */
  40539. enable(): void;
  40540. /**
  40541. * Disables contributions to the sliding window sample set
  40542. * Samples will not be interpolated over the disabled period
  40543. */
  40544. disable(): void;
  40545. /**
  40546. * Returns true if sampling is enabled
  40547. */
  40548. get isEnabled(): boolean;
  40549. /**
  40550. * Resets performance monitor
  40551. */
  40552. reset(): void;
  40553. }
  40554. /**
  40555. * RollingAverage
  40556. *
  40557. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40558. */
  40559. export class RollingAverage {
  40560. /**
  40561. * Current average
  40562. */
  40563. average: number;
  40564. /**
  40565. * Current variance
  40566. */
  40567. variance: number;
  40568. protected _samples: Array<number>;
  40569. protected _sampleCount: number;
  40570. protected _pos: number;
  40571. protected _m2: number;
  40572. /**
  40573. * constructor
  40574. * @param length The number of samples required to saturate the sliding window
  40575. */
  40576. constructor(length: number);
  40577. /**
  40578. * Adds a sample to the sample set
  40579. * @param v The sample value
  40580. */
  40581. add(v: number): void;
  40582. /**
  40583. * Returns previously added values or null if outside of history or outside the sliding window domain
  40584. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40585. * @return Value previously recorded with add() or null if outside of range
  40586. */
  40587. history(i: number): number;
  40588. /**
  40589. * Returns true if enough samples have been taken to completely fill the sliding window
  40590. * @return true if sample-set saturated
  40591. */
  40592. isSaturated(): boolean;
  40593. /**
  40594. * Resets the rolling average (equivalent to 0 samples taken so far)
  40595. */
  40596. reset(): void;
  40597. /**
  40598. * Wraps a value around the sample range boundaries
  40599. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40600. * @return Wrapped position in sample range
  40601. */
  40602. protected _wrapPosition(i: number): number;
  40603. }
  40604. }
  40605. declare module BABYLON {
  40606. /**
  40607. * This class is used to track a performance counter which is number based.
  40608. * The user has access to many properties which give statistics of different nature.
  40609. *
  40610. * The implementer can track two kinds of Performance Counter: time and count.
  40611. * 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.
  40612. * 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.
  40613. */
  40614. export class PerfCounter {
  40615. /**
  40616. * Gets or sets a global boolean to turn on and off all the counters
  40617. */
  40618. static Enabled: boolean;
  40619. /**
  40620. * Returns the smallest value ever
  40621. */
  40622. get min(): number;
  40623. /**
  40624. * Returns the biggest value ever
  40625. */
  40626. get max(): number;
  40627. /**
  40628. * Returns the average value since the performance counter is running
  40629. */
  40630. get average(): number;
  40631. /**
  40632. * Returns the average value of the last second the counter was monitored
  40633. */
  40634. get lastSecAverage(): number;
  40635. /**
  40636. * Returns the current value
  40637. */
  40638. get current(): number;
  40639. /**
  40640. * Gets the accumulated total
  40641. */
  40642. get total(): number;
  40643. /**
  40644. * Gets the total value count
  40645. */
  40646. get count(): number;
  40647. /**
  40648. * Creates a new counter
  40649. */
  40650. constructor();
  40651. /**
  40652. * Call this method to start monitoring a new frame.
  40653. * 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.
  40654. */
  40655. fetchNewFrame(): void;
  40656. /**
  40657. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40658. * @param newCount the count value to add to the monitored count
  40659. * @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.
  40660. */
  40661. addCount(newCount: number, fetchResult: boolean): void;
  40662. /**
  40663. * Start monitoring this performance counter
  40664. */
  40665. beginMonitoring(): void;
  40666. /**
  40667. * Compute the time lapsed since the previous beginMonitoring() call.
  40668. * @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
  40669. */
  40670. endMonitoring(newFrame?: boolean): void;
  40671. private _fetchResult;
  40672. private _startMonitoringTime;
  40673. private _min;
  40674. private _max;
  40675. private _average;
  40676. private _current;
  40677. private _totalValueCount;
  40678. private _totalAccumulated;
  40679. private _lastSecAverage;
  40680. private _lastSecAccumulated;
  40681. private _lastSecTime;
  40682. private _lastSecValueCount;
  40683. }
  40684. }
  40685. declare module BABYLON {
  40686. interface ThinEngine {
  40687. /** @hidden */
  40688. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40689. }
  40690. }
  40691. declare module BABYLON {
  40692. /**
  40693. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40694. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40695. */
  40696. export class Analyser {
  40697. /**
  40698. * Gets or sets the smoothing
  40699. * @ignorenaming
  40700. */
  40701. SMOOTHING: number;
  40702. /**
  40703. * Gets or sets the FFT table size
  40704. * @ignorenaming
  40705. */
  40706. FFT_SIZE: number;
  40707. /**
  40708. * Gets or sets the bar graph amplitude
  40709. * @ignorenaming
  40710. */
  40711. BARGRAPHAMPLITUDE: number;
  40712. /**
  40713. * Gets or sets the position of the debug canvas
  40714. * @ignorenaming
  40715. */
  40716. DEBUGCANVASPOS: {
  40717. x: number;
  40718. y: number;
  40719. };
  40720. /**
  40721. * Gets or sets the debug canvas size
  40722. * @ignorenaming
  40723. */
  40724. DEBUGCANVASSIZE: {
  40725. width: number;
  40726. height: number;
  40727. };
  40728. private _byteFreqs;
  40729. private _byteTime;
  40730. private _floatFreqs;
  40731. private _webAudioAnalyser;
  40732. private _debugCanvas;
  40733. private _debugCanvasContext;
  40734. private _scene;
  40735. private _registerFunc;
  40736. private _audioEngine;
  40737. /**
  40738. * Creates a new analyser
  40739. * @param scene defines hosting scene
  40740. */
  40741. constructor(scene: Scene);
  40742. /**
  40743. * Get the number of data values you will have to play with for the visualization
  40744. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40745. * @returns a number
  40746. */
  40747. getFrequencyBinCount(): number;
  40748. /**
  40749. * Gets the current frequency data as a byte array
  40750. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40751. * @returns a Uint8Array
  40752. */
  40753. getByteFrequencyData(): Uint8Array;
  40754. /**
  40755. * Gets the current waveform as a byte array
  40756. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40757. * @returns a Uint8Array
  40758. */
  40759. getByteTimeDomainData(): Uint8Array;
  40760. /**
  40761. * Gets the current frequency data as a float array
  40762. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40763. * @returns a Float32Array
  40764. */
  40765. getFloatFrequencyData(): Float32Array;
  40766. /**
  40767. * Renders the debug canvas
  40768. */
  40769. drawDebugCanvas(): void;
  40770. /**
  40771. * Stops rendering the debug canvas and removes it
  40772. */
  40773. stopDebugCanvas(): void;
  40774. /**
  40775. * Connects two audio nodes
  40776. * @param inputAudioNode defines first node to connect
  40777. * @param outputAudioNode defines second node to connect
  40778. */
  40779. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40780. /**
  40781. * Releases all associated resources
  40782. */
  40783. dispose(): void;
  40784. }
  40785. }
  40786. declare module BABYLON {
  40787. /**
  40788. * This represents an audio engine and it is responsible
  40789. * to play, synchronize and analyse sounds throughout the application.
  40790. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40791. */
  40792. export interface IAudioEngine extends IDisposable {
  40793. /**
  40794. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40795. */
  40796. readonly canUseWebAudio: boolean;
  40797. /**
  40798. * Gets the current AudioContext if available.
  40799. */
  40800. readonly audioContext: Nullable<AudioContext>;
  40801. /**
  40802. * The master gain node defines the global audio volume of your audio engine.
  40803. */
  40804. readonly masterGain: GainNode;
  40805. /**
  40806. * Gets whether or not mp3 are supported by your browser.
  40807. */
  40808. readonly isMP3supported: boolean;
  40809. /**
  40810. * Gets whether or not ogg are supported by your browser.
  40811. */
  40812. readonly isOGGsupported: boolean;
  40813. /**
  40814. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40815. * @ignoreNaming
  40816. */
  40817. WarnedWebAudioUnsupported: boolean;
  40818. /**
  40819. * Defines if the audio engine relies on a custom unlocked button.
  40820. * In this case, the embedded button will not be displayed.
  40821. */
  40822. useCustomUnlockedButton: boolean;
  40823. /**
  40824. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40825. */
  40826. readonly unlocked: boolean;
  40827. /**
  40828. * Event raised when audio has been unlocked on the browser.
  40829. */
  40830. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40831. /**
  40832. * Event raised when audio has been locked on the browser.
  40833. */
  40834. onAudioLockedObservable: Observable<IAudioEngine>;
  40835. /**
  40836. * Flags the audio engine in Locked state.
  40837. * This happens due to new browser policies preventing audio to autoplay.
  40838. */
  40839. lock(): void;
  40840. /**
  40841. * Unlocks the audio engine once a user action has been done on the dom.
  40842. * This is helpful to resume play once browser policies have been satisfied.
  40843. */
  40844. unlock(): void;
  40845. /**
  40846. * Gets the global volume sets on the master gain.
  40847. * @returns the global volume if set or -1 otherwise
  40848. */
  40849. getGlobalVolume(): number;
  40850. /**
  40851. * Sets the global volume of your experience (sets on the master gain).
  40852. * @param newVolume Defines the new global volume of the application
  40853. */
  40854. setGlobalVolume(newVolume: number): void;
  40855. /**
  40856. * Connect the audio engine to an audio analyser allowing some amazing
  40857. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40858. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40859. * @param analyser The analyser to connect to the engine
  40860. */
  40861. connectToAnalyser(analyser: Analyser): void;
  40862. }
  40863. }
  40864. declare module BABYLON {
  40865. /**
  40866. * Defines the interface used by display changed events
  40867. */
  40868. export interface IDisplayChangedEventArgs {
  40869. /** Gets the vrDisplay object (if any) */
  40870. vrDisplay: Nullable<any>;
  40871. /** Gets a boolean indicating if webVR is supported */
  40872. vrSupported: boolean;
  40873. }
  40874. /**
  40875. * Defines the interface used by objects containing a viewport (like a camera)
  40876. */
  40877. interface IViewportOwnerLike {
  40878. /**
  40879. * Gets or sets the viewport
  40880. */
  40881. viewport: IViewportLike;
  40882. }
  40883. /**
  40884. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40885. */
  40886. export class Engine extends ThinEngine {
  40887. /** Defines that alpha blending is disabled */
  40888. static readonly ALPHA_DISABLE: number;
  40889. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40890. static readonly ALPHA_ADD: number;
  40891. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40892. static readonly ALPHA_COMBINE: number;
  40893. /** Defines that alpha blending to DEST - SRC * DEST */
  40894. static readonly ALPHA_SUBTRACT: number;
  40895. /** Defines that alpha blending to SRC * DEST */
  40896. static readonly ALPHA_MULTIPLY: number;
  40897. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40898. static readonly ALPHA_MAXIMIZED: number;
  40899. /** Defines that alpha blending to SRC + DEST */
  40900. static readonly ALPHA_ONEONE: number;
  40901. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40902. static readonly ALPHA_PREMULTIPLIED: number;
  40903. /**
  40904. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40905. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40906. */
  40907. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40908. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40909. static readonly ALPHA_INTERPOLATE: number;
  40910. /**
  40911. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40912. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40913. */
  40914. static readonly ALPHA_SCREENMODE: number;
  40915. /** Defines that the ressource is not delayed*/
  40916. static readonly DELAYLOADSTATE_NONE: number;
  40917. /** Defines that the ressource was successfully delay loaded */
  40918. static readonly DELAYLOADSTATE_LOADED: number;
  40919. /** Defines that the ressource is currently delay loading */
  40920. static readonly DELAYLOADSTATE_LOADING: number;
  40921. /** Defines that the ressource is delayed and has not started loading */
  40922. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40923. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40924. static readonly NEVER: number;
  40925. /** 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 */
  40926. static readonly ALWAYS: number;
  40927. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40928. static readonly LESS: number;
  40929. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40930. static readonly EQUAL: number;
  40931. /** 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 */
  40932. static readonly LEQUAL: number;
  40933. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40934. static readonly GREATER: number;
  40935. /** 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 */
  40936. static readonly GEQUAL: number;
  40937. /** 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 */
  40938. static readonly NOTEQUAL: number;
  40939. /** Passed to stencilOperation to specify that stencil value must be kept */
  40940. static readonly KEEP: number;
  40941. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40942. static readonly REPLACE: number;
  40943. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40944. static readonly INCR: number;
  40945. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40946. static readonly DECR: number;
  40947. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40948. static readonly INVERT: number;
  40949. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40950. static readonly INCR_WRAP: number;
  40951. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40952. static readonly DECR_WRAP: number;
  40953. /** Texture is not repeating outside of 0..1 UVs */
  40954. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40955. /** Texture is repeating outside of 0..1 UVs */
  40956. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40957. /** Texture is repeating and mirrored */
  40958. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40959. /** ALPHA */
  40960. static readonly TEXTUREFORMAT_ALPHA: number;
  40961. /** LUMINANCE */
  40962. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40963. /** LUMINANCE_ALPHA */
  40964. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40965. /** RGB */
  40966. static readonly TEXTUREFORMAT_RGB: number;
  40967. /** RGBA */
  40968. static readonly TEXTUREFORMAT_RGBA: number;
  40969. /** RED */
  40970. static readonly TEXTUREFORMAT_RED: number;
  40971. /** RED (2nd reference) */
  40972. static readonly TEXTUREFORMAT_R: number;
  40973. /** RG */
  40974. static readonly TEXTUREFORMAT_RG: number;
  40975. /** RED_INTEGER */
  40976. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40977. /** RED_INTEGER (2nd reference) */
  40978. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40979. /** RG_INTEGER */
  40980. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40981. /** RGB_INTEGER */
  40982. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40983. /** RGBA_INTEGER */
  40984. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40985. /** UNSIGNED_BYTE */
  40986. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40987. /** UNSIGNED_BYTE (2nd reference) */
  40988. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40989. /** FLOAT */
  40990. static readonly TEXTURETYPE_FLOAT: number;
  40991. /** HALF_FLOAT */
  40992. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40993. /** BYTE */
  40994. static readonly TEXTURETYPE_BYTE: number;
  40995. /** SHORT */
  40996. static readonly TEXTURETYPE_SHORT: number;
  40997. /** UNSIGNED_SHORT */
  40998. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40999. /** INT */
  41000. static readonly TEXTURETYPE_INT: number;
  41001. /** UNSIGNED_INT */
  41002. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41003. /** UNSIGNED_SHORT_4_4_4_4 */
  41004. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41005. /** UNSIGNED_SHORT_5_5_5_1 */
  41006. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41007. /** UNSIGNED_SHORT_5_6_5 */
  41008. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41009. /** UNSIGNED_INT_2_10_10_10_REV */
  41010. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41011. /** UNSIGNED_INT_24_8 */
  41012. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41013. /** UNSIGNED_INT_10F_11F_11F_REV */
  41014. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41015. /** UNSIGNED_INT_5_9_9_9_REV */
  41016. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41017. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41018. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41019. /** nearest is mag = nearest and min = nearest and mip = linear */
  41020. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41021. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41022. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41023. /** Trilinear is mag = linear and min = linear and mip = linear */
  41024. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41025. /** nearest is mag = nearest and min = nearest and mip = linear */
  41026. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41027. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41028. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  41029. /** Trilinear is mag = linear and min = linear and mip = linear */
  41030. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41031. /** mag = nearest and min = nearest and mip = nearest */
  41032. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41033. /** mag = nearest and min = linear and mip = nearest */
  41034. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41035. /** mag = nearest and min = linear and mip = linear */
  41036. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  41037. /** mag = nearest and min = linear and mip = none */
  41038. static readonly TEXTURE_NEAREST_LINEAR: number;
  41039. /** mag = nearest and min = nearest and mip = none */
  41040. static readonly TEXTURE_NEAREST_NEAREST: number;
  41041. /** mag = linear and min = nearest and mip = nearest */
  41042. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  41043. /** mag = linear and min = nearest and mip = linear */
  41044. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41045. /** mag = linear and min = linear and mip = none */
  41046. static readonly TEXTURE_LINEAR_LINEAR: number;
  41047. /** mag = linear and min = nearest and mip = none */
  41048. static readonly TEXTURE_LINEAR_NEAREST: number;
  41049. /** Explicit coordinates mode */
  41050. static readonly TEXTURE_EXPLICIT_MODE: number;
  41051. /** Spherical coordinates mode */
  41052. static readonly TEXTURE_SPHERICAL_MODE: number;
  41053. /** Planar coordinates mode */
  41054. static readonly TEXTURE_PLANAR_MODE: number;
  41055. /** Cubic coordinates mode */
  41056. static readonly TEXTURE_CUBIC_MODE: number;
  41057. /** Projection coordinates mode */
  41058. static readonly TEXTURE_PROJECTION_MODE: number;
  41059. /** Skybox coordinates mode */
  41060. static readonly TEXTURE_SKYBOX_MODE: number;
  41061. /** Inverse Cubic coordinates mode */
  41062. static readonly TEXTURE_INVCUBIC_MODE: number;
  41063. /** Equirectangular coordinates mode */
  41064. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  41065. /** Equirectangular Fixed coordinates mode */
  41066. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  41067. /** Equirectangular Fixed Mirrored coordinates mode */
  41068. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  41069. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  41070. static readonly SCALEMODE_FLOOR: number;
  41071. /** Defines that texture rescaling will look for the nearest power of 2 size */
  41072. static readonly SCALEMODE_NEAREST: number;
  41073. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  41074. static readonly SCALEMODE_CEILING: number;
  41075. /**
  41076. * Returns the current npm package of the sdk
  41077. */
  41078. static get NpmPackage(): string;
  41079. /**
  41080. * Returns the current version of the framework
  41081. */
  41082. static get Version(): string;
  41083. /** Gets the list of created engines */
  41084. static get Instances(): Engine[];
  41085. /**
  41086. * Gets the latest created engine
  41087. */
  41088. static get LastCreatedEngine(): Nullable<Engine>;
  41089. /**
  41090. * Gets the latest created scene
  41091. */
  41092. static get LastCreatedScene(): Nullable<Scene>;
  41093. /**
  41094. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  41095. * @param flag defines which part of the materials must be marked as dirty
  41096. * @param predicate defines a predicate used to filter which materials should be affected
  41097. */
  41098. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41099. /**
  41100. * Method called to create the default loading screen.
  41101. * This can be overriden in your own app.
  41102. * @param canvas The rendering canvas element
  41103. * @returns The loading screen
  41104. */
  41105. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  41106. /**
  41107. * Method called to create the default rescale post process on each engine.
  41108. */
  41109. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  41110. /**
  41111. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  41112. **/
  41113. enableOfflineSupport: boolean;
  41114. /**
  41115. * 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)
  41116. **/
  41117. disableManifestCheck: boolean;
  41118. /**
  41119. * Gets the list of created scenes
  41120. */
  41121. scenes: Scene[];
  41122. /**
  41123. * Event raised when a new scene is created
  41124. */
  41125. onNewSceneAddedObservable: Observable<Scene>;
  41126. /**
  41127. * Gets the list of created postprocesses
  41128. */
  41129. postProcesses: PostProcess[];
  41130. /**
  41131. * Gets a boolean indicating if the pointer is currently locked
  41132. */
  41133. isPointerLock: boolean;
  41134. /**
  41135. * Observable event triggered each time the rendering canvas is resized
  41136. */
  41137. onResizeObservable: Observable<Engine>;
  41138. /**
  41139. * Observable event triggered each time the canvas loses focus
  41140. */
  41141. onCanvasBlurObservable: Observable<Engine>;
  41142. /**
  41143. * Observable event triggered each time the canvas gains focus
  41144. */
  41145. onCanvasFocusObservable: Observable<Engine>;
  41146. /**
  41147. * Observable event triggered each time the canvas receives pointerout event
  41148. */
  41149. onCanvasPointerOutObservable: Observable<PointerEvent>;
  41150. /**
  41151. * Observable raised when the engine begins a new frame
  41152. */
  41153. onBeginFrameObservable: Observable<Engine>;
  41154. /**
  41155. * If set, will be used to request the next animation frame for the render loop
  41156. */
  41157. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  41158. /**
  41159. * Observable raised when the engine ends the current frame
  41160. */
  41161. onEndFrameObservable: Observable<Engine>;
  41162. /**
  41163. * Observable raised when the engine is about to compile a shader
  41164. */
  41165. onBeforeShaderCompilationObservable: Observable<Engine>;
  41166. /**
  41167. * Observable raised when the engine has jsut compiled a shader
  41168. */
  41169. onAfterShaderCompilationObservable: Observable<Engine>;
  41170. /**
  41171. * Gets the audio engine
  41172. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41173. * @ignorenaming
  41174. */
  41175. static audioEngine: IAudioEngine;
  41176. /**
  41177. * Default AudioEngine factory responsible of creating the Audio Engine.
  41178. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  41179. */
  41180. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  41181. /**
  41182. * Default offline support factory responsible of creating a tool used to store data locally.
  41183. * By default, this will create a Database object if the workload has been embedded.
  41184. */
  41185. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  41186. private _loadingScreen;
  41187. private _pointerLockRequested;
  41188. private _rescalePostProcess;
  41189. private _deterministicLockstep;
  41190. private _lockstepMaxSteps;
  41191. private _timeStep;
  41192. protected get _supportsHardwareTextureRescaling(): boolean;
  41193. private _fps;
  41194. private _deltaTime;
  41195. /** @hidden */
  41196. _drawCalls: PerfCounter;
  41197. /** 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 */
  41198. canvasTabIndex: number;
  41199. /**
  41200. * Turn this value on if you want to pause FPS computation when in background
  41201. */
  41202. disablePerformanceMonitorInBackground: boolean;
  41203. private _performanceMonitor;
  41204. /**
  41205. * Gets the performance monitor attached to this engine
  41206. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41207. */
  41208. get performanceMonitor(): PerformanceMonitor;
  41209. private _onFocus;
  41210. private _onBlur;
  41211. private _onCanvasPointerOut;
  41212. private _onCanvasBlur;
  41213. private _onCanvasFocus;
  41214. private _onFullscreenChange;
  41215. private _onPointerLockChange;
  41216. /**
  41217. * Gets the HTML element used to attach event listeners
  41218. * @returns a HTML element
  41219. */
  41220. getInputElement(): Nullable<HTMLElement>;
  41221. /**
  41222. * Creates a new engine
  41223. * @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
  41224. * @param antialias defines enable antialiasing (default: false)
  41225. * @param options defines further options to be sent to the getContext() function
  41226. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41227. */
  41228. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41229. /**
  41230. * Gets current aspect ratio
  41231. * @param viewportOwner defines the camera to use to get the aspect ratio
  41232. * @param useScreen defines if screen size must be used (or the current render target if any)
  41233. * @returns a number defining the aspect ratio
  41234. */
  41235. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  41236. /**
  41237. * Gets current screen aspect ratio
  41238. * @returns a number defining the aspect ratio
  41239. */
  41240. getScreenAspectRatio(): number;
  41241. /**
  41242. * Gets the client rect of the HTML canvas attached with the current webGL context
  41243. * @returns a client rectanglee
  41244. */
  41245. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  41246. /**
  41247. * Gets the client rect of the HTML element used for events
  41248. * @returns a client rectanglee
  41249. */
  41250. getInputElementClientRect(): Nullable<ClientRect>;
  41251. /**
  41252. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  41253. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41254. * @returns true if engine is in deterministic lock step mode
  41255. */
  41256. isDeterministicLockStep(): boolean;
  41257. /**
  41258. * Gets the max steps when engine is running in deterministic lock step
  41259. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41260. * @returns the max steps
  41261. */
  41262. getLockstepMaxSteps(): number;
  41263. /**
  41264. * Returns the time in ms between steps when using deterministic lock step.
  41265. * @returns time step in (ms)
  41266. */
  41267. getTimeStep(): number;
  41268. /**
  41269. * Force the mipmap generation for the given render target texture
  41270. * @param texture defines the render target texture to use
  41271. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  41272. */
  41273. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  41274. /** States */
  41275. /**
  41276. * Set various states to the webGL context
  41277. * @param culling defines backface culling state
  41278. * @param zOffset defines the value to apply to zOffset (0 by default)
  41279. * @param force defines if states must be applied even if cache is up to date
  41280. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  41281. */
  41282. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41283. /**
  41284. * Set the z offset to apply to current rendering
  41285. * @param value defines the offset to apply
  41286. */
  41287. setZOffset(value: number): void;
  41288. /**
  41289. * Gets the current value of the zOffset
  41290. * @returns the current zOffset state
  41291. */
  41292. getZOffset(): number;
  41293. /**
  41294. * Enable or disable depth buffering
  41295. * @param enable defines the state to set
  41296. */
  41297. setDepthBuffer(enable: boolean): void;
  41298. /**
  41299. * Gets a boolean indicating if depth writing is enabled
  41300. * @returns the current depth writing state
  41301. */
  41302. getDepthWrite(): boolean;
  41303. /**
  41304. * Enable or disable depth writing
  41305. * @param enable defines the state to set
  41306. */
  41307. setDepthWrite(enable: boolean): void;
  41308. /**
  41309. * Gets a boolean indicating if stencil buffer is enabled
  41310. * @returns the current stencil buffer state
  41311. */
  41312. getStencilBuffer(): boolean;
  41313. /**
  41314. * Enable or disable the stencil buffer
  41315. * @param enable defines if the stencil buffer must be enabled or disabled
  41316. */
  41317. setStencilBuffer(enable: boolean): void;
  41318. /**
  41319. * Gets the current stencil mask
  41320. * @returns a number defining the new stencil mask to use
  41321. */
  41322. getStencilMask(): number;
  41323. /**
  41324. * Sets the current stencil mask
  41325. * @param mask defines the new stencil mask to use
  41326. */
  41327. setStencilMask(mask: number): void;
  41328. /**
  41329. * Gets the current stencil function
  41330. * @returns a number defining the stencil function to use
  41331. */
  41332. getStencilFunction(): number;
  41333. /**
  41334. * Gets the current stencil reference value
  41335. * @returns a number defining the stencil reference value to use
  41336. */
  41337. getStencilFunctionReference(): number;
  41338. /**
  41339. * Gets the current stencil mask
  41340. * @returns a number defining the stencil mask to use
  41341. */
  41342. getStencilFunctionMask(): number;
  41343. /**
  41344. * Sets the current stencil function
  41345. * @param stencilFunc defines the new stencil function to use
  41346. */
  41347. setStencilFunction(stencilFunc: number): void;
  41348. /**
  41349. * Sets the current stencil reference
  41350. * @param reference defines the new stencil reference to use
  41351. */
  41352. setStencilFunctionReference(reference: number): void;
  41353. /**
  41354. * Sets the current stencil mask
  41355. * @param mask defines the new stencil mask to use
  41356. */
  41357. setStencilFunctionMask(mask: number): void;
  41358. /**
  41359. * Gets the current stencil operation when stencil fails
  41360. * @returns a number defining stencil operation to use when stencil fails
  41361. */
  41362. getStencilOperationFail(): number;
  41363. /**
  41364. * Gets the current stencil operation when depth fails
  41365. * @returns a number defining stencil operation to use when depth fails
  41366. */
  41367. getStencilOperationDepthFail(): number;
  41368. /**
  41369. * Gets the current stencil operation when stencil passes
  41370. * @returns a number defining stencil operation to use when stencil passes
  41371. */
  41372. getStencilOperationPass(): number;
  41373. /**
  41374. * Sets the stencil operation to use when stencil fails
  41375. * @param operation defines the stencil operation to use when stencil fails
  41376. */
  41377. setStencilOperationFail(operation: number): void;
  41378. /**
  41379. * Sets the stencil operation to use when depth fails
  41380. * @param operation defines the stencil operation to use when depth fails
  41381. */
  41382. setStencilOperationDepthFail(operation: number): void;
  41383. /**
  41384. * Sets the stencil operation to use when stencil passes
  41385. * @param operation defines the stencil operation to use when stencil passes
  41386. */
  41387. setStencilOperationPass(operation: number): void;
  41388. /**
  41389. * Sets a boolean indicating if the dithering state is enabled or disabled
  41390. * @param value defines the dithering state
  41391. */
  41392. setDitheringState(value: boolean): void;
  41393. /**
  41394. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41395. * @param value defines the rasterizer state
  41396. */
  41397. setRasterizerState(value: boolean): void;
  41398. /**
  41399. * Gets the current depth function
  41400. * @returns a number defining the depth function
  41401. */
  41402. getDepthFunction(): Nullable<number>;
  41403. /**
  41404. * Sets the current depth function
  41405. * @param depthFunc defines the function to use
  41406. */
  41407. setDepthFunction(depthFunc: number): void;
  41408. /**
  41409. * Sets the current depth function to GREATER
  41410. */
  41411. setDepthFunctionToGreater(): void;
  41412. /**
  41413. * Sets the current depth function to GEQUAL
  41414. */
  41415. setDepthFunctionToGreaterOrEqual(): void;
  41416. /**
  41417. * Sets the current depth function to LESS
  41418. */
  41419. setDepthFunctionToLess(): void;
  41420. /**
  41421. * Sets the current depth function to LEQUAL
  41422. */
  41423. setDepthFunctionToLessOrEqual(): void;
  41424. private _cachedStencilBuffer;
  41425. private _cachedStencilFunction;
  41426. private _cachedStencilMask;
  41427. private _cachedStencilOperationPass;
  41428. private _cachedStencilOperationFail;
  41429. private _cachedStencilOperationDepthFail;
  41430. private _cachedStencilReference;
  41431. /**
  41432. * Caches the the state of the stencil buffer
  41433. */
  41434. cacheStencilState(): void;
  41435. /**
  41436. * Restores the state of the stencil buffer
  41437. */
  41438. restoreStencilState(): void;
  41439. /**
  41440. * Directly set the WebGL Viewport
  41441. * @param x defines the x coordinate of the viewport (in screen space)
  41442. * @param y defines the y coordinate of the viewport (in screen space)
  41443. * @param width defines the width of the viewport (in screen space)
  41444. * @param height defines the height of the viewport (in screen space)
  41445. * @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
  41446. */
  41447. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41448. /**
  41449. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41450. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41451. * @param y defines the y-coordinate of the corner of the clear rectangle
  41452. * @param width defines the width of the clear rectangle
  41453. * @param height defines the height of the clear rectangle
  41454. * @param clearColor defines the clear color
  41455. */
  41456. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41457. /**
  41458. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41459. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41460. * @param y defines the y-coordinate of the corner of the clear rectangle
  41461. * @param width defines the width of the clear rectangle
  41462. * @param height defines the height of the clear rectangle
  41463. */
  41464. enableScissor(x: number, y: number, width: number, height: number): void;
  41465. /**
  41466. * Disable previously set scissor test rectangle
  41467. */
  41468. disableScissor(): void;
  41469. protected _reportDrawCall(): void;
  41470. /**
  41471. * Initializes a webVR display and starts listening to display change events
  41472. * The onVRDisplayChangedObservable will be notified upon these changes
  41473. * @returns The onVRDisplayChangedObservable
  41474. */
  41475. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41476. /** @hidden */
  41477. _prepareVRComponent(): void;
  41478. /** @hidden */
  41479. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41480. /** @hidden */
  41481. _submitVRFrame(): void;
  41482. /**
  41483. * Call this function to leave webVR mode
  41484. * Will do nothing if webVR is not supported or if there is no webVR device
  41485. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41486. */
  41487. disableVR(): void;
  41488. /**
  41489. * Gets a boolean indicating that the system is in VR mode and is presenting
  41490. * @returns true if VR mode is engaged
  41491. */
  41492. isVRPresenting(): boolean;
  41493. /** @hidden */
  41494. _requestVRFrame(): void;
  41495. /** @hidden */
  41496. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41497. /**
  41498. * Gets the source code of the vertex shader associated with a specific webGL program
  41499. * @param program defines the program to use
  41500. * @returns a string containing the source code of the vertex shader associated with the program
  41501. */
  41502. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41503. /**
  41504. * Gets the source code of the fragment shader associated with a specific webGL program
  41505. * @param program defines the program to use
  41506. * @returns a string containing the source code of the fragment shader associated with the program
  41507. */
  41508. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41509. /**
  41510. * Sets a depth stencil texture from a render target to the according uniform.
  41511. * @param channel The texture channel
  41512. * @param uniform The uniform to set
  41513. * @param texture The render target texture containing the depth stencil texture to apply
  41514. */
  41515. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41516. /**
  41517. * Sets a texture to the webGL context from a postprocess
  41518. * @param channel defines the channel to use
  41519. * @param postProcess defines the source postprocess
  41520. */
  41521. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41522. /**
  41523. * Binds the output of the passed in post process to the texture channel specified
  41524. * @param channel The channel the texture should be bound to
  41525. * @param postProcess The post process which's output should be bound
  41526. */
  41527. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41528. protected _rebuildBuffers(): void;
  41529. /** @hidden */
  41530. _renderFrame(): void;
  41531. _renderLoop(): void;
  41532. /** @hidden */
  41533. _renderViews(): boolean;
  41534. /**
  41535. * Toggle full screen mode
  41536. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41537. */
  41538. switchFullscreen(requestPointerLock: boolean): void;
  41539. /**
  41540. * Enters full screen mode
  41541. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41542. */
  41543. enterFullscreen(requestPointerLock: boolean): void;
  41544. /**
  41545. * Exits full screen mode
  41546. */
  41547. exitFullscreen(): void;
  41548. /**
  41549. * Enters Pointerlock mode
  41550. */
  41551. enterPointerlock(): void;
  41552. /**
  41553. * Exits Pointerlock mode
  41554. */
  41555. exitPointerlock(): void;
  41556. /**
  41557. * Begin a new frame
  41558. */
  41559. beginFrame(): void;
  41560. /**
  41561. * Enf the current frame
  41562. */
  41563. endFrame(): void;
  41564. resize(): void;
  41565. /**
  41566. * Force a specific size of the canvas
  41567. * @param width defines the new canvas' width
  41568. * @param height defines the new canvas' height
  41569. * @returns true if the size was changed
  41570. */
  41571. setSize(width: number, height: number): boolean;
  41572. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41573. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41574. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41575. _releaseTexture(texture: InternalTexture): void;
  41576. /**
  41577. * @hidden
  41578. * Rescales a texture
  41579. * @param source input texutre
  41580. * @param destination destination texture
  41581. * @param scene scene to use to render the resize
  41582. * @param internalFormat format to use when resizing
  41583. * @param onComplete callback to be called when resize has completed
  41584. */
  41585. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41586. /**
  41587. * Gets the current framerate
  41588. * @returns a number representing the framerate
  41589. */
  41590. getFps(): number;
  41591. /**
  41592. * Gets the time spent between current and previous frame
  41593. * @returns a number representing the delta time in ms
  41594. */
  41595. getDeltaTime(): number;
  41596. private _measureFps;
  41597. /** @hidden */
  41598. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41599. /**
  41600. * Updates the sample count of a render target texture
  41601. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41602. * @param texture defines the texture to update
  41603. * @param samples defines the sample count to set
  41604. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41605. */
  41606. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41607. /**
  41608. * Updates a depth texture Comparison Mode and Function.
  41609. * If the comparison Function is equal to 0, the mode will be set to none.
  41610. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41611. * @param texture The texture to set the comparison function for
  41612. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41613. */
  41614. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41615. /**
  41616. * Creates a webGL buffer to use with instanciation
  41617. * @param capacity defines the size of the buffer
  41618. * @returns the webGL buffer
  41619. */
  41620. createInstancesBuffer(capacity: number): DataBuffer;
  41621. /**
  41622. * Delete a webGL buffer used with instanciation
  41623. * @param buffer defines the webGL buffer to delete
  41624. */
  41625. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41626. private _clientWaitAsync;
  41627. /** @hidden */
  41628. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41629. dispose(): void;
  41630. private _disableTouchAction;
  41631. /**
  41632. * Display the loading screen
  41633. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41634. */
  41635. displayLoadingUI(): void;
  41636. /**
  41637. * Hide the loading screen
  41638. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41639. */
  41640. hideLoadingUI(): void;
  41641. /**
  41642. * Gets the current loading screen object
  41643. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41644. */
  41645. get loadingScreen(): ILoadingScreen;
  41646. /**
  41647. * Sets the current loading screen object
  41648. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41649. */
  41650. set loadingScreen(loadingScreen: ILoadingScreen);
  41651. /**
  41652. * Sets the current loading screen text
  41653. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41654. */
  41655. set loadingUIText(text: string);
  41656. /**
  41657. * Sets the current loading screen background color
  41658. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41659. */
  41660. set loadingUIBackgroundColor(color: string);
  41661. /** Pointerlock and fullscreen */
  41662. /**
  41663. * Ask the browser to promote the current element to pointerlock mode
  41664. * @param element defines the DOM element to promote
  41665. */
  41666. static _RequestPointerlock(element: HTMLElement): void;
  41667. /**
  41668. * Asks the browser to exit pointerlock mode
  41669. */
  41670. static _ExitPointerlock(): void;
  41671. /**
  41672. * Ask the browser to promote the current element to fullscreen rendering mode
  41673. * @param element defines the DOM element to promote
  41674. */
  41675. static _RequestFullscreen(element: HTMLElement): void;
  41676. /**
  41677. * Asks the browser to exit fullscreen mode
  41678. */
  41679. static _ExitFullscreen(): void;
  41680. }
  41681. }
  41682. declare module BABYLON {
  41683. /**
  41684. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41685. * during the life time of the application.
  41686. */
  41687. export class EngineStore {
  41688. /** Gets the list of created engines */
  41689. static Instances: Engine[];
  41690. /** @hidden */
  41691. static _LastCreatedScene: Nullable<Scene>;
  41692. /**
  41693. * Gets the latest created engine
  41694. */
  41695. static get LastCreatedEngine(): Nullable<Engine>;
  41696. /**
  41697. * Gets the latest created scene
  41698. */
  41699. static get LastCreatedScene(): Nullable<Scene>;
  41700. /**
  41701. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41702. * @ignorenaming
  41703. */
  41704. static UseFallbackTexture: boolean;
  41705. /**
  41706. * Texture content used if a texture cannot loaded
  41707. * @ignorenaming
  41708. */
  41709. static FallbackTexture: string;
  41710. }
  41711. }
  41712. declare module BABYLON {
  41713. /**
  41714. * Helper class that provides a small promise polyfill
  41715. */
  41716. export class PromisePolyfill {
  41717. /**
  41718. * Static function used to check if the polyfill is required
  41719. * If this is the case then the function will inject the polyfill to window.Promise
  41720. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41721. */
  41722. static Apply(force?: boolean): void;
  41723. }
  41724. }
  41725. declare module BABYLON {
  41726. /**
  41727. * Interface for screenshot methods with describe argument called `size` as object with options
  41728. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41729. */
  41730. export interface IScreenshotSize {
  41731. /**
  41732. * number in pixels for canvas height
  41733. */
  41734. height?: number;
  41735. /**
  41736. * multiplier allowing render at a higher or lower resolution
  41737. * If value is defined then height and width will be ignored and taken from camera
  41738. */
  41739. precision?: number;
  41740. /**
  41741. * number in pixels for canvas width
  41742. */
  41743. width?: number;
  41744. }
  41745. }
  41746. declare module BABYLON {
  41747. interface IColor4Like {
  41748. r: float;
  41749. g: float;
  41750. b: float;
  41751. a: float;
  41752. }
  41753. /**
  41754. * Class containing a set of static utilities functions
  41755. */
  41756. export class Tools {
  41757. /**
  41758. * Gets or sets the base URL to use to load assets
  41759. */
  41760. static get BaseUrl(): string;
  41761. static set BaseUrl(value: string);
  41762. /**
  41763. * Enable/Disable Custom HTTP Request Headers globally.
  41764. * default = false
  41765. * @see CustomRequestHeaders
  41766. */
  41767. static UseCustomRequestHeaders: boolean;
  41768. /**
  41769. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41770. * i.e. when loading files, where the server/service expects an Authorization header
  41771. */
  41772. static CustomRequestHeaders: {
  41773. [key: string]: string;
  41774. };
  41775. /**
  41776. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41777. */
  41778. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41779. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41780. /**
  41781. * Default behaviour for cors in the application.
  41782. * It can be a string if the expected behavior is identical in the entire app.
  41783. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41784. */
  41785. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41786. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41787. /**
  41788. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41789. * @ignorenaming
  41790. */
  41791. static get UseFallbackTexture(): boolean;
  41792. static set UseFallbackTexture(value: boolean);
  41793. /**
  41794. * Use this object to register external classes like custom textures or material
  41795. * to allow the laoders to instantiate them
  41796. */
  41797. static get RegisteredExternalClasses(): {
  41798. [key: string]: Object;
  41799. };
  41800. static set RegisteredExternalClasses(classes: {
  41801. [key: string]: Object;
  41802. });
  41803. /**
  41804. * Texture content used if a texture cannot loaded
  41805. * @ignorenaming
  41806. */
  41807. static get fallbackTexture(): string;
  41808. static set fallbackTexture(value: string);
  41809. /**
  41810. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41811. * @param u defines the coordinate on X axis
  41812. * @param v defines the coordinate on Y axis
  41813. * @param width defines the width of the source data
  41814. * @param height defines the height of the source data
  41815. * @param pixels defines the source byte array
  41816. * @param color defines the output color
  41817. */
  41818. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41819. /**
  41820. * Interpolates between a and b via alpha
  41821. * @param a The lower value (returned when alpha = 0)
  41822. * @param b The upper value (returned when alpha = 1)
  41823. * @param alpha The interpolation-factor
  41824. * @return The mixed value
  41825. */
  41826. static Mix(a: number, b: number, alpha: number): number;
  41827. /**
  41828. * Tries to instantiate a new object from a given class name
  41829. * @param className defines the class name to instantiate
  41830. * @returns the new object or null if the system was not able to do the instantiation
  41831. */
  41832. static Instantiate(className: string): any;
  41833. /**
  41834. * Provides a slice function that will work even on IE
  41835. * @param data defines the array to slice
  41836. * @param start defines the start of the data (optional)
  41837. * @param end defines the end of the data (optional)
  41838. * @returns the new sliced array
  41839. */
  41840. static Slice<T>(data: T, start?: number, end?: number): T;
  41841. /**
  41842. * Provides a slice function that will work even on IE
  41843. * The difference between this and Slice is that this will force-convert to array
  41844. * @param data defines the array to slice
  41845. * @param start defines the start of the data (optional)
  41846. * @param end defines the end of the data (optional)
  41847. * @returns the new sliced array
  41848. */
  41849. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41850. /**
  41851. * Polyfill for setImmediate
  41852. * @param action defines the action to execute after the current execution block
  41853. */
  41854. static SetImmediate(action: () => void): void;
  41855. /**
  41856. * Function indicating if a number is an exponent of 2
  41857. * @param value defines the value to test
  41858. * @returns true if the value is an exponent of 2
  41859. */
  41860. static IsExponentOfTwo(value: number): boolean;
  41861. private static _tmpFloatArray;
  41862. /**
  41863. * Returns the nearest 32-bit single precision float representation of a Number
  41864. * @param value A Number. If the parameter is of a different type, it will get converted
  41865. * to a number or to NaN if it cannot be converted
  41866. * @returns number
  41867. */
  41868. static FloatRound(value: number): number;
  41869. /**
  41870. * Extracts the filename from a path
  41871. * @param path defines the path to use
  41872. * @returns the filename
  41873. */
  41874. static GetFilename(path: string): string;
  41875. /**
  41876. * Extracts the "folder" part of a path (everything before the filename).
  41877. * @param uri The URI to extract the info from
  41878. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41879. * @returns The "folder" part of the path
  41880. */
  41881. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41882. /**
  41883. * Extracts text content from a DOM element hierarchy
  41884. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41885. */
  41886. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41887. /**
  41888. * Convert an angle in radians to degrees
  41889. * @param angle defines the angle to convert
  41890. * @returns the angle in degrees
  41891. */
  41892. static ToDegrees(angle: number): number;
  41893. /**
  41894. * Convert an angle in degrees to radians
  41895. * @param angle defines the angle to convert
  41896. * @returns the angle in radians
  41897. */
  41898. static ToRadians(angle: number): number;
  41899. /**
  41900. * Returns an array if obj is not an array
  41901. * @param obj defines the object to evaluate as an array
  41902. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41903. * @returns either obj directly if obj is an array or a new array containing obj
  41904. */
  41905. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41906. /**
  41907. * Gets the pointer prefix to use
  41908. * @param engine defines the engine we are finding the prefix for
  41909. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41910. */
  41911. static GetPointerPrefix(engine: Engine): string;
  41912. /**
  41913. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41914. * @param url define the url we are trying
  41915. * @param element define the dom element where to configure the cors policy
  41916. */
  41917. static SetCorsBehavior(url: string | string[], element: {
  41918. crossOrigin: string | null;
  41919. }): void;
  41920. /**
  41921. * Removes unwanted characters from an url
  41922. * @param url defines the url to clean
  41923. * @returns the cleaned url
  41924. */
  41925. static CleanUrl(url: string): string;
  41926. /**
  41927. * Gets or sets a function used to pre-process url before using them to load assets
  41928. */
  41929. static get PreprocessUrl(): (url: string) => string;
  41930. static set PreprocessUrl(processor: (url: string) => string);
  41931. /**
  41932. * Loads an image as an HTMLImageElement.
  41933. * @param input url string, ArrayBuffer, or Blob to load
  41934. * @param onLoad callback called when the image successfully loads
  41935. * @param onError callback called when the image fails to load
  41936. * @param offlineProvider offline provider for caching
  41937. * @param mimeType optional mime type
  41938. * @returns the HTMLImageElement of the loaded image
  41939. */
  41940. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41941. /**
  41942. * Loads a file from a url
  41943. * @param url url string, ArrayBuffer, or Blob to load
  41944. * @param onSuccess callback called when the file successfully loads
  41945. * @param onProgress callback called while file is loading (if the server supports this mode)
  41946. * @param offlineProvider defines the offline provider for caching
  41947. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41948. * @param onError callback called when the file fails to load
  41949. * @returns a file request object
  41950. */
  41951. 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;
  41952. /**
  41953. * Loads a file from a url
  41954. * @param url the file url to load
  41955. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41956. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41957. */
  41958. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41959. /**
  41960. * Load a script (identified by an url). When the url returns, the
  41961. * content of this file is added into a new script element, attached to the DOM (body element)
  41962. * @param scriptUrl defines the url of the script to laod
  41963. * @param onSuccess defines the callback called when the script is loaded
  41964. * @param onError defines the callback to call if an error occurs
  41965. * @param scriptId defines the id of the script element
  41966. */
  41967. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41968. /**
  41969. * Load an asynchronous script (identified by an url). When the url returns, the
  41970. * content of this file is added into a new script element, attached to the DOM (body element)
  41971. * @param scriptUrl defines the url of the script to laod
  41972. * @param scriptId defines the id of the script element
  41973. * @returns a promise request object
  41974. */
  41975. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41976. /**
  41977. * Loads a file from a blob
  41978. * @param fileToLoad defines the blob to use
  41979. * @param callback defines the callback to call when data is loaded
  41980. * @param progressCallback defines the callback to call during loading process
  41981. * @returns a file request object
  41982. */
  41983. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41984. /**
  41985. * Reads a file from a File object
  41986. * @param file defines the file to load
  41987. * @param onSuccess defines the callback to call when data is loaded
  41988. * @param onProgress defines the callback to call during loading process
  41989. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41990. * @param onError defines the callback to call when an error occurs
  41991. * @returns a file request object
  41992. */
  41993. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41994. /**
  41995. * Creates a data url from a given string content
  41996. * @param content defines the content to convert
  41997. * @returns the new data url link
  41998. */
  41999. static FileAsURL(content: string): string;
  42000. /**
  42001. * Format the given number to a specific decimal format
  42002. * @param value defines the number to format
  42003. * @param decimals defines the number of decimals to use
  42004. * @returns the formatted string
  42005. */
  42006. static Format(value: number, decimals?: number): string;
  42007. /**
  42008. * Tries to copy an object by duplicating every property
  42009. * @param source defines the source object
  42010. * @param destination defines the target object
  42011. * @param doNotCopyList defines a list of properties to avoid
  42012. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  42013. */
  42014. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  42015. /**
  42016. * Gets a boolean indicating if the given object has no own property
  42017. * @param obj defines the object to test
  42018. * @returns true if object has no own property
  42019. */
  42020. static IsEmpty(obj: any): boolean;
  42021. /**
  42022. * Function used to register events at window level
  42023. * @param windowElement defines the Window object to use
  42024. * @param events defines the events to register
  42025. */
  42026. static RegisterTopRootEvents(windowElement: Window, events: {
  42027. name: string;
  42028. handler: Nullable<(e: FocusEvent) => any>;
  42029. }[]): void;
  42030. /**
  42031. * Function used to unregister events from window level
  42032. * @param windowElement defines the Window object to use
  42033. * @param events defines the events to unregister
  42034. */
  42035. static UnregisterTopRootEvents(windowElement: Window, events: {
  42036. name: string;
  42037. handler: Nullable<(e: FocusEvent) => any>;
  42038. }[]): void;
  42039. /**
  42040. * @ignore
  42041. */
  42042. static _ScreenshotCanvas: HTMLCanvasElement;
  42043. /**
  42044. * Dumps the current bound framebuffer
  42045. * @param width defines the rendering width
  42046. * @param height defines the rendering height
  42047. * @param engine defines the hosting engine
  42048. * @param successCallback defines the callback triggered once the data are available
  42049. * @param mimeType defines the mime type of the result
  42050. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  42051. */
  42052. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42053. /**
  42054. * Converts the canvas data to blob.
  42055. * This acts as a polyfill for browsers not supporting the to blob function.
  42056. * @param canvas Defines the canvas to extract the data from
  42057. * @param successCallback Defines the callback triggered once the data are available
  42058. * @param mimeType Defines the mime type of the result
  42059. */
  42060. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  42061. /**
  42062. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  42063. * @param successCallback defines the callback triggered once the data are available
  42064. * @param mimeType defines the mime type of the result
  42065. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  42066. */
  42067. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42068. /**
  42069. * Downloads a blob in the browser
  42070. * @param blob defines the blob to download
  42071. * @param fileName defines the name of the downloaded file
  42072. */
  42073. static Download(blob: Blob, fileName: string): void;
  42074. /**
  42075. * Will return the right value of the noPreventDefault variable
  42076. * Needed to keep backwards compatibility to the old API.
  42077. *
  42078. * @param args arguments passed to the attachControl function
  42079. * @returns the correct value for noPreventDefault
  42080. */
  42081. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  42082. /**
  42083. * Captures a screenshot of the current rendering
  42084. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42085. * @param engine defines the rendering engine
  42086. * @param camera defines the source camera
  42087. * @param size This parameter can be set to a single number or to an object with the
  42088. * following (optional) properties: precision, width, height. If a single number is passed,
  42089. * it will be used for both width and height. If an object is passed, the screenshot size
  42090. * will be derived from the parameters. The precision property is a multiplier allowing
  42091. * rendering at a higher or lower resolution
  42092. * @param successCallback defines the callback receives a single parameter which contains the
  42093. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42094. * src parameter of an <img> to display it
  42095. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42096. * Check your browser for supported MIME types
  42097. */
  42098. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  42099. /**
  42100. * Captures a screenshot of the current rendering
  42101. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42102. * @param engine defines the rendering engine
  42103. * @param camera defines the source camera
  42104. * @param size This parameter can be set to a single number or to an object with the
  42105. * following (optional) properties: precision, width, height. If a single number is passed,
  42106. * it will be used for both width and height. If an object is passed, the screenshot size
  42107. * will be derived from the parameters. The precision property is a multiplier allowing
  42108. * rendering at a higher or lower resolution
  42109. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42110. * Check your browser for supported MIME types
  42111. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42112. * to the src parameter of an <img> to display it
  42113. */
  42114. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  42115. /**
  42116. * Generates an image screenshot from the specified camera.
  42117. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42118. * @param engine The engine to use for rendering
  42119. * @param camera The camera to use for rendering
  42120. * @param size This parameter can be set to a single number or to an object with the
  42121. * following (optional) properties: precision, width, height. If a single number is passed,
  42122. * it will be used for both width and height. If an object is passed, the screenshot size
  42123. * will be derived from the parameters. The precision property is a multiplier allowing
  42124. * rendering at a higher or lower resolution
  42125. * @param successCallback The callback receives a single parameter which contains the
  42126. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42127. * src parameter of an <img> to display it
  42128. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42129. * Check your browser for supported MIME types
  42130. * @param samples Texture samples (default: 1)
  42131. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42132. * @param fileName A name for for the downloaded file.
  42133. */
  42134. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  42135. /**
  42136. * Generates an image screenshot from the specified camera.
  42137. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42138. * @param engine The engine to use for rendering
  42139. * @param camera The camera to use for rendering
  42140. * @param size This parameter can be set to a single number or to an object with the
  42141. * following (optional) properties: precision, width, height. If a single number is passed,
  42142. * it will be used for both width and height. If an object is passed, the screenshot size
  42143. * will be derived from the parameters. The precision property is a multiplier allowing
  42144. * rendering at a higher or lower resolution
  42145. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42146. * Check your browser for supported MIME types
  42147. * @param samples Texture samples (default: 1)
  42148. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42149. * @param fileName A name for for the downloaded file.
  42150. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42151. * to the src parameter of an <img> to display it
  42152. */
  42153. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  42154. /**
  42155. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  42156. * Be aware Math.random() could cause collisions, but:
  42157. * "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"
  42158. * @returns a pseudo random id
  42159. */
  42160. static RandomId(): string;
  42161. /**
  42162. * Test if the given uri is a base64 string
  42163. * @param uri The uri to test
  42164. * @return True if the uri is a base64 string or false otherwise
  42165. */
  42166. static IsBase64(uri: string): boolean;
  42167. /**
  42168. * Decode the given base64 uri.
  42169. * @param uri The uri to decode
  42170. * @return The decoded base64 data.
  42171. */
  42172. static DecodeBase64(uri: string): ArrayBuffer;
  42173. /**
  42174. * Gets the absolute url.
  42175. * @param url the input url
  42176. * @return the absolute url
  42177. */
  42178. static GetAbsoluteUrl(url: string): string;
  42179. /**
  42180. * No log
  42181. */
  42182. static readonly NoneLogLevel: number;
  42183. /**
  42184. * Only message logs
  42185. */
  42186. static readonly MessageLogLevel: number;
  42187. /**
  42188. * Only warning logs
  42189. */
  42190. static readonly WarningLogLevel: number;
  42191. /**
  42192. * Only error logs
  42193. */
  42194. static readonly ErrorLogLevel: number;
  42195. /**
  42196. * All logs
  42197. */
  42198. static readonly AllLogLevel: number;
  42199. /**
  42200. * Gets a value indicating the number of loading errors
  42201. * @ignorenaming
  42202. */
  42203. static get errorsCount(): number;
  42204. /**
  42205. * Callback called when a new log is added
  42206. */
  42207. static OnNewCacheEntry: (entry: string) => void;
  42208. /**
  42209. * Log a message to the console
  42210. * @param message defines the message to log
  42211. */
  42212. static Log(message: string): void;
  42213. /**
  42214. * Write a warning message to the console
  42215. * @param message defines the message to log
  42216. */
  42217. static Warn(message: string): void;
  42218. /**
  42219. * Write an error message to the console
  42220. * @param message defines the message to log
  42221. */
  42222. static Error(message: string): void;
  42223. /**
  42224. * Gets current log cache (list of logs)
  42225. */
  42226. static get LogCache(): string;
  42227. /**
  42228. * Clears the log cache
  42229. */
  42230. static ClearLogCache(): void;
  42231. /**
  42232. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  42233. */
  42234. static set LogLevels(level: number);
  42235. /**
  42236. * Checks if the window object exists
  42237. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  42238. */
  42239. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  42240. /**
  42241. * No performance log
  42242. */
  42243. static readonly PerformanceNoneLogLevel: number;
  42244. /**
  42245. * Use user marks to log performance
  42246. */
  42247. static readonly PerformanceUserMarkLogLevel: number;
  42248. /**
  42249. * Log performance to the console
  42250. */
  42251. static readonly PerformanceConsoleLogLevel: number;
  42252. private static _performance;
  42253. /**
  42254. * Sets the current performance log level
  42255. */
  42256. static set PerformanceLogLevel(level: number);
  42257. private static _StartPerformanceCounterDisabled;
  42258. private static _EndPerformanceCounterDisabled;
  42259. private static _StartUserMark;
  42260. private static _EndUserMark;
  42261. private static _StartPerformanceConsole;
  42262. private static _EndPerformanceConsole;
  42263. /**
  42264. * Starts a performance counter
  42265. */
  42266. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42267. /**
  42268. * Ends a specific performance coutner
  42269. */
  42270. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42271. /**
  42272. * Gets either window.performance.now() if supported or Date.now() else
  42273. */
  42274. static get Now(): number;
  42275. /**
  42276. * This method will return the name of the class used to create the instance of the given object.
  42277. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  42278. * @param object the object to get the class name from
  42279. * @param isType defines if the object is actually a type
  42280. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  42281. */
  42282. static GetClassName(object: any, isType?: boolean): string;
  42283. /**
  42284. * Gets the first element of an array satisfying a given predicate
  42285. * @param array defines the array to browse
  42286. * @param predicate defines the predicate to use
  42287. * @returns null if not found or the element
  42288. */
  42289. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  42290. /**
  42291. * This method will return the name of the full name of the class, including its owning module (if any).
  42292. * 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).
  42293. * @param object the object to get the class name from
  42294. * @param isType defines if the object is actually a type
  42295. * @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.
  42296. * @ignorenaming
  42297. */
  42298. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  42299. /**
  42300. * Returns a promise that resolves after the given amount of time.
  42301. * @param delay Number of milliseconds to delay
  42302. * @returns Promise that resolves after the given amount of time
  42303. */
  42304. static DelayAsync(delay: number): Promise<void>;
  42305. /**
  42306. * Utility function to detect if the current user agent is Safari
  42307. * @returns whether or not the current user agent is safari
  42308. */
  42309. static IsSafari(): boolean;
  42310. }
  42311. /**
  42312. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42313. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42314. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42315. * @param name The name of the class, case should be preserved
  42316. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42317. */
  42318. export function className(name: string, module?: string): (target: Object) => void;
  42319. /**
  42320. * An implementation of a loop for asynchronous functions.
  42321. */
  42322. export class AsyncLoop {
  42323. /**
  42324. * Defines the number of iterations for the loop
  42325. */
  42326. iterations: number;
  42327. /**
  42328. * Defines the current index of the loop.
  42329. */
  42330. index: number;
  42331. private _done;
  42332. private _fn;
  42333. private _successCallback;
  42334. /**
  42335. * Constructor.
  42336. * @param iterations the number of iterations.
  42337. * @param func the function to run each iteration
  42338. * @param successCallback the callback that will be called upon succesful execution
  42339. * @param offset starting offset.
  42340. */
  42341. constructor(
  42342. /**
  42343. * Defines the number of iterations for the loop
  42344. */
  42345. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42346. /**
  42347. * Execute the next iteration. Must be called after the last iteration was finished.
  42348. */
  42349. executeNext(): void;
  42350. /**
  42351. * Break the loop and run the success callback.
  42352. */
  42353. breakLoop(): void;
  42354. /**
  42355. * Create and run an async loop.
  42356. * @param iterations the number of iterations.
  42357. * @param fn the function to run each iteration
  42358. * @param successCallback the callback that will be called upon succesful execution
  42359. * @param offset starting offset.
  42360. * @returns the created async loop object
  42361. */
  42362. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42363. /**
  42364. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42365. * @param iterations total number of iterations
  42366. * @param syncedIterations number of synchronous iterations in each async iteration.
  42367. * @param fn the function to call each iteration.
  42368. * @param callback a success call back that will be called when iterating stops.
  42369. * @param breakFunction a break condition (optional)
  42370. * @param timeout timeout settings for the setTimeout function. default - 0.
  42371. * @returns the created async loop object
  42372. */
  42373. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42374. }
  42375. }
  42376. declare module BABYLON {
  42377. /**
  42378. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42379. * The underlying implementation relies on an associative array to ensure the best performances.
  42380. * The value can be anything including 'null' but except 'undefined'
  42381. */
  42382. export class StringDictionary<T> {
  42383. /**
  42384. * This will clear this dictionary and copy the content from the 'source' one.
  42385. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42386. * @param source the dictionary to take the content from and copy to this dictionary
  42387. */
  42388. copyFrom(source: StringDictionary<T>): void;
  42389. /**
  42390. * Get a value based from its key
  42391. * @param key the given key to get the matching value from
  42392. * @return the value if found, otherwise undefined is returned
  42393. */
  42394. get(key: string): T | undefined;
  42395. /**
  42396. * Get a value from its key or add it if it doesn't exist.
  42397. * This method will ensure you that a given key/data will be present in the dictionary.
  42398. * @param key the given key to get the matching value from
  42399. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42400. * The factory will only be invoked if there's no data for the given key.
  42401. * @return the value corresponding to the key.
  42402. */
  42403. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42404. /**
  42405. * Get a value from its key if present in the dictionary otherwise add it
  42406. * @param key the key to get the value from
  42407. * @param val if there's no such key/value pair in the dictionary add it with this value
  42408. * @return the value corresponding to the key
  42409. */
  42410. getOrAdd(key: string, val: T): T;
  42411. /**
  42412. * Check if there's a given key in the dictionary
  42413. * @param key the key to check for
  42414. * @return true if the key is present, false otherwise
  42415. */
  42416. contains(key: string): boolean;
  42417. /**
  42418. * Add a new key and its corresponding value
  42419. * @param key the key to add
  42420. * @param value the value corresponding to the key
  42421. * @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
  42422. */
  42423. add(key: string, value: T): boolean;
  42424. /**
  42425. * Update a specific value associated to a key
  42426. * @param key defines the key to use
  42427. * @param value defines the value to store
  42428. * @returns true if the value was updated (or false if the key was not found)
  42429. */
  42430. set(key: string, value: T): boolean;
  42431. /**
  42432. * Get the element of the given key and remove it from the dictionary
  42433. * @param key defines the key to search
  42434. * @returns the value associated with the key or null if not found
  42435. */
  42436. getAndRemove(key: string): Nullable<T>;
  42437. /**
  42438. * Remove a key/value from the dictionary.
  42439. * @param key the key to remove
  42440. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42441. */
  42442. remove(key: string): boolean;
  42443. /**
  42444. * Clear the whole content of the dictionary
  42445. */
  42446. clear(): void;
  42447. /**
  42448. * Gets the current count
  42449. */
  42450. get count(): number;
  42451. /**
  42452. * Execute a callback on each key/val of the dictionary.
  42453. * Note that you can remove any element in this dictionary in the callback implementation
  42454. * @param callback the callback to execute on a given key/value pair
  42455. */
  42456. forEach(callback: (key: string, val: T) => void): void;
  42457. /**
  42458. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42459. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42460. * Note that you can remove any element in this dictionary in the callback implementation
  42461. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42462. * @returns the first item
  42463. */
  42464. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42465. private _count;
  42466. private _data;
  42467. }
  42468. }
  42469. declare module BABYLON {
  42470. /** @hidden */
  42471. export interface ICollisionCoordinator {
  42472. createCollider(): Collider;
  42473. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42474. init(scene: Scene): void;
  42475. }
  42476. /** @hidden */
  42477. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42478. private _scene;
  42479. private _scaledPosition;
  42480. private _scaledVelocity;
  42481. private _finalPosition;
  42482. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42483. createCollider(): Collider;
  42484. init(scene: Scene): void;
  42485. private _collideWithWorld;
  42486. }
  42487. }
  42488. declare module BABYLON {
  42489. /**
  42490. * Class used to manage all inputs for the scene.
  42491. */
  42492. export class InputManager {
  42493. /** The distance in pixel that you have to move to prevent some events */
  42494. static DragMovementThreshold: number;
  42495. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42496. static LongPressDelay: number;
  42497. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42498. static DoubleClickDelay: number;
  42499. /** If you need to check double click without raising a single click at first click, enable this flag */
  42500. static ExclusiveDoubleClickMode: boolean;
  42501. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  42502. private _alreadyAttached;
  42503. private _alreadyAttachedTo;
  42504. private _wheelEventName;
  42505. private _onPointerMove;
  42506. private _onPointerDown;
  42507. private _onPointerUp;
  42508. private _initClickEvent;
  42509. private _initActionManager;
  42510. private _delayedSimpleClick;
  42511. private _delayedSimpleClickTimeout;
  42512. private _previousDelayedSimpleClickTimeout;
  42513. private _meshPickProceed;
  42514. private _previousButtonPressed;
  42515. private _currentPickResult;
  42516. private _previousPickResult;
  42517. private _totalPointersPressed;
  42518. private _doubleClickOccured;
  42519. private _pointerOverMesh;
  42520. private _pickedDownMesh;
  42521. private _pickedUpMesh;
  42522. private _pointerX;
  42523. private _pointerY;
  42524. private _unTranslatedPointerX;
  42525. private _unTranslatedPointerY;
  42526. private _startingPointerPosition;
  42527. private _previousStartingPointerPosition;
  42528. private _startingPointerTime;
  42529. private _previousStartingPointerTime;
  42530. private _pointerCaptures;
  42531. private _meshUnderPointerId;
  42532. private _onKeyDown;
  42533. private _onKeyUp;
  42534. private _keyboardIsAttached;
  42535. private _onCanvasFocusObserver;
  42536. private _onCanvasBlurObserver;
  42537. private _scene;
  42538. /**
  42539. * Creates a new InputManager
  42540. * @param scene defines the hosting scene
  42541. */
  42542. constructor(scene: Scene);
  42543. /**
  42544. * Gets the mesh that is currently under the pointer
  42545. */
  42546. get meshUnderPointer(): Nullable<AbstractMesh>;
  42547. /**
  42548. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42549. * @param pointerId the pointer id to use
  42550. * @returns The mesh under this pointer id or null if not found
  42551. */
  42552. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42553. /**
  42554. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42555. */
  42556. get unTranslatedPointer(): Vector2;
  42557. /**
  42558. * Gets or sets the current on-screen X position of the pointer
  42559. */
  42560. get pointerX(): number;
  42561. set pointerX(value: number);
  42562. /**
  42563. * Gets or sets the current on-screen Y position of the pointer
  42564. */
  42565. get pointerY(): number;
  42566. set pointerY(value: number);
  42567. private _updatePointerPosition;
  42568. private _processPointerMove;
  42569. private _setRayOnPointerInfo;
  42570. private _checkPrePointerObservable;
  42571. /**
  42572. * Use this method to simulate a pointer move on a mesh
  42573. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42574. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42575. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42576. */
  42577. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42578. /**
  42579. * Use this method to simulate a pointer down on a mesh
  42580. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42581. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42582. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42583. */
  42584. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42585. private _processPointerDown;
  42586. /** @hidden */
  42587. _isPointerSwiping(): boolean;
  42588. /**
  42589. * Use this method to simulate a pointer up on a mesh
  42590. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42591. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42592. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42593. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42594. */
  42595. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42596. private _processPointerUp;
  42597. /**
  42598. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42599. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42600. * @returns true if the pointer was captured
  42601. */
  42602. isPointerCaptured(pointerId?: number): boolean;
  42603. /**
  42604. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42605. * @param attachUp defines if you want to attach events to pointerup
  42606. * @param attachDown defines if you want to attach events to pointerdown
  42607. * @param attachMove defines if you want to attach events to pointermove
  42608. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42609. */
  42610. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42611. /**
  42612. * Detaches all event handlers
  42613. */
  42614. detachControl(): void;
  42615. /**
  42616. * Force the value of meshUnderPointer
  42617. * @param mesh defines the mesh to use
  42618. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42619. */
  42620. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42621. /**
  42622. * Gets the mesh under the pointer
  42623. * @returns a Mesh or null if no mesh is under the pointer
  42624. */
  42625. getPointerOverMesh(): Nullable<AbstractMesh>;
  42626. }
  42627. }
  42628. declare module BABYLON {
  42629. /**
  42630. * This class defines the direct association between an animation and a target
  42631. */
  42632. export class TargetedAnimation {
  42633. /**
  42634. * Animation to perform
  42635. */
  42636. animation: Animation;
  42637. /**
  42638. * Target to animate
  42639. */
  42640. target: any;
  42641. /**
  42642. * Returns the string "TargetedAnimation"
  42643. * @returns "TargetedAnimation"
  42644. */
  42645. getClassName(): string;
  42646. /**
  42647. * Serialize the object
  42648. * @returns the JSON object representing the current entity
  42649. */
  42650. serialize(): any;
  42651. }
  42652. /**
  42653. * Use this class to create coordinated animations on multiple targets
  42654. */
  42655. export class AnimationGroup implements IDisposable {
  42656. /** The name of the animation group */
  42657. name: string;
  42658. private _scene;
  42659. private _targetedAnimations;
  42660. private _animatables;
  42661. private _from;
  42662. private _to;
  42663. private _isStarted;
  42664. private _isPaused;
  42665. private _speedRatio;
  42666. private _loopAnimation;
  42667. private _isAdditive;
  42668. /**
  42669. * Gets or sets the unique id of the node
  42670. */
  42671. uniqueId: number;
  42672. /**
  42673. * This observable will notify when one animation have ended
  42674. */
  42675. onAnimationEndObservable: Observable<TargetedAnimation>;
  42676. /**
  42677. * Observer raised when one animation loops
  42678. */
  42679. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42680. /**
  42681. * Observer raised when all animations have looped
  42682. */
  42683. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42684. /**
  42685. * This observable will notify when all animations have ended.
  42686. */
  42687. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42688. /**
  42689. * This observable will notify when all animations have paused.
  42690. */
  42691. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42692. /**
  42693. * This observable will notify when all animations are playing.
  42694. */
  42695. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42696. /**
  42697. * Gets the first frame
  42698. */
  42699. get from(): number;
  42700. /**
  42701. * Gets the last frame
  42702. */
  42703. get to(): number;
  42704. /**
  42705. * Define if the animations are started
  42706. */
  42707. get isStarted(): boolean;
  42708. /**
  42709. * Gets a value indicating that the current group is playing
  42710. */
  42711. get isPlaying(): boolean;
  42712. /**
  42713. * Gets or sets the speed ratio to use for all animations
  42714. */
  42715. get speedRatio(): number;
  42716. /**
  42717. * Gets or sets the speed ratio to use for all animations
  42718. */
  42719. set speedRatio(value: number);
  42720. /**
  42721. * Gets or sets if all animations should loop or not
  42722. */
  42723. get loopAnimation(): boolean;
  42724. set loopAnimation(value: boolean);
  42725. /**
  42726. * Gets or sets if all animations should be evaluated additively
  42727. */
  42728. get isAdditive(): boolean;
  42729. set isAdditive(value: boolean);
  42730. /**
  42731. * Gets the targeted animations for this animation group
  42732. */
  42733. get targetedAnimations(): Array<TargetedAnimation>;
  42734. /**
  42735. * returning the list of animatables controlled by this animation group.
  42736. */
  42737. get animatables(): Array<Animatable>;
  42738. /**
  42739. * Gets the list of target animations
  42740. */
  42741. get children(): TargetedAnimation[];
  42742. /**
  42743. * Instantiates a new Animation Group.
  42744. * This helps managing several animations at once.
  42745. * @see https://doc.babylonjs.com/how_to/group
  42746. * @param name Defines the name of the group
  42747. * @param scene Defines the scene the group belongs to
  42748. */
  42749. constructor(
  42750. /** The name of the animation group */
  42751. name: string, scene?: Nullable<Scene>);
  42752. /**
  42753. * Add an animation (with its target) in the group
  42754. * @param animation defines the animation we want to add
  42755. * @param target defines the target of the animation
  42756. * @returns the TargetedAnimation object
  42757. */
  42758. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42759. /**
  42760. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42761. * It can add constant keys at begin or end
  42762. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42763. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42764. * @returns the animation group
  42765. */
  42766. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42767. private _animationLoopCount;
  42768. private _animationLoopFlags;
  42769. private _processLoop;
  42770. /**
  42771. * Start all animations on given targets
  42772. * @param loop defines if animations must loop
  42773. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42774. * @param from defines the from key (optional)
  42775. * @param to defines the to key (optional)
  42776. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42777. * @returns the current animation group
  42778. */
  42779. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42780. /**
  42781. * Pause all animations
  42782. * @returns the animation group
  42783. */
  42784. pause(): AnimationGroup;
  42785. /**
  42786. * Play all animations to initial state
  42787. * This function will start() the animations if they were not started or will restart() them if they were paused
  42788. * @param loop defines if animations must loop
  42789. * @returns the animation group
  42790. */
  42791. play(loop?: boolean): AnimationGroup;
  42792. /**
  42793. * Reset all animations to initial state
  42794. * @returns the animation group
  42795. */
  42796. reset(): AnimationGroup;
  42797. /**
  42798. * Restart animations from key 0
  42799. * @returns the animation group
  42800. */
  42801. restart(): AnimationGroup;
  42802. /**
  42803. * Stop all animations
  42804. * @returns the animation group
  42805. */
  42806. stop(): AnimationGroup;
  42807. /**
  42808. * Set animation weight for all animatables
  42809. * @param weight defines the weight to use
  42810. * @return the animationGroup
  42811. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42812. */
  42813. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42814. /**
  42815. * Synchronize and normalize all animatables with a source animatable
  42816. * @param root defines the root animatable to synchronize with
  42817. * @return the animationGroup
  42818. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42819. */
  42820. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42821. /**
  42822. * Goes to a specific frame in this animation group
  42823. * @param frame the frame number to go to
  42824. * @return the animationGroup
  42825. */
  42826. goToFrame(frame: number): AnimationGroup;
  42827. /**
  42828. * Dispose all associated resources
  42829. */
  42830. dispose(): void;
  42831. private _checkAnimationGroupEnded;
  42832. /**
  42833. * Clone the current animation group and returns a copy
  42834. * @param newName defines the name of the new group
  42835. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42836. * @returns the new aniamtion group
  42837. */
  42838. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42839. /**
  42840. * Serializes the animationGroup to an object
  42841. * @returns Serialized object
  42842. */
  42843. serialize(): any;
  42844. /**
  42845. * Returns a new AnimationGroup object parsed from the source provided.
  42846. * @param parsedAnimationGroup defines the source
  42847. * @param scene defines the scene that will receive the animationGroup
  42848. * @returns a new AnimationGroup
  42849. */
  42850. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42851. /**
  42852. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42853. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42854. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42855. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42856. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42857. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42858. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42859. */
  42860. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42861. /**
  42862. * Returns the string "AnimationGroup"
  42863. * @returns "AnimationGroup"
  42864. */
  42865. getClassName(): string;
  42866. /**
  42867. * Creates a detailled string about the object
  42868. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42869. * @returns a string representing the object
  42870. */
  42871. toString(fullDetails?: boolean): string;
  42872. }
  42873. }
  42874. declare module BABYLON {
  42875. /**
  42876. * Define an interface for all classes that will hold resources
  42877. */
  42878. export interface IDisposable {
  42879. /**
  42880. * Releases all held resources
  42881. */
  42882. dispose(): void;
  42883. }
  42884. /** Interface defining initialization parameters for Scene class */
  42885. export interface SceneOptions {
  42886. /**
  42887. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42888. * It will improve performance when the number of geometries becomes important.
  42889. */
  42890. useGeometryUniqueIdsMap?: boolean;
  42891. /**
  42892. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42893. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42894. */
  42895. useMaterialMeshMap?: boolean;
  42896. /**
  42897. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42898. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42899. */
  42900. useClonedMeshMap?: boolean;
  42901. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42902. virtual?: boolean;
  42903. }
  42904. /**
  42905. * Represents a scene to be rendered by the engine.
  42906. * @see https://doc.babylonjs.com/features/scene
  42907. */
  42908. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42909. /** The fog is deactivated */
  42910. static readonly FOGMODE_NONE: number;
  42911. /** The fog density is following an exponential function */
  42912. static readonly FOGMODE_EXP: number;
  42913. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42914. static readonly FOGMODE_EXP2: number;
  42915. /** The fog density is following a linear function. */
  42916. static readonly FOGMODE_LINEAR: number;
  42917. /**
  42918. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42919. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42920. */
  42921. static MinDeltaTime: number;
  42922. /**
  42923. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42924. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42925. */
  42926. static MaxDeltaTime: number;
  42927. /**
  42928. * Factory used to create the default material.
  42929. * @param name The name of the material to create
  42930. * @param scene The scene to create the material for
  42931. * @returns The default material
  42932. */
  42933. static DefaultMaterialFactory(scene: Scene): Material;
  42934. /**
  42935. * Factory used to create the a collision coordinator.
  42936. * @returns The collision coordinator
  42937. */
  42938. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42939. /** @hidden */
  42940. _inputManager: InputManager;
  42941. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42942. cameraToUseForPointers: Nullable<Camera>;
  42943. /** @hidden */
  42944. readonly _isScene: boolean;
  42945. /** @hidden */
  42946. _blockEntityCollection: boolean;
  42947. /**
  42948. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42949. */
  42950. autoClear: boolean;
  42951. /**
  42952. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42953. */
  42954. autoClearDepthAndStencil: boolean;
  42955. /**
  42956. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42957. */
  42958. clearColor: Color4;
  42959. /**
  42960. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42961. */
  42962. ambientColor: Color3;
  42963. /**
  42964. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42965. * It should only be one of the following (if not the default embedded one):
  42966. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42967. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42968. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42969. * The material properties need to be setup according to the type of texture in use.
  42970. */
  42971. environmentBRDFTexture: BaseTexture;
  42972. /**
  42973. * Texture used in all pbr material as the reflection texture.
  42974. * As in the majority of the scene they are the same (exception for multi room and so on),
  42975. * this is easier to reference from here than from all the materials.
  42976. */
  42977. get environmentTexture(): Nullable<BaseTexture>;
  42978. /**
  42979. * Texture used in all pbr material as the reflection texture.
  42980. * As in the majority of the scene they are the same (exception for multi room and so on),
  42981. * this is easier to set here than in all the materials.
  42982. */
  42983. set environmentTexture(value: Nullable<BaseTexture>);
  42984. /** @hidden */
  42985. protected _environmentIntensity: number;
  42986. /**
  42987. * Intensity of the environment in all pbr material.
  42988. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42989. * As in the majority of the scene they are the same (exception for multi room and so on),
  42990. * this is easier to reference from here than from all the materials.
  42991. */
  42992. get environmentIntensity(): number;
  42993. /**
  42994. * Intensity of the environment in all pbr material.
  42995. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42996. * As in the majority of the scene they are the same (exception for multi room and so on),
  42997. * this is easier to set here than in all the materials.
  42998. */
  42999. set environmentIntensity(value: number);
  43000. /** @hidden */
  43001. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43002. /**
  43003. * Default image processing configuration used either in the rendering
  43004. * Forward main pass or through the imageProcessingPostProcess if present.
  43005. * As in the majority of the scene they are the same (exception for multi camera),
  43006. * this is easier to reference from here than from all the materials and post process.
  43007. *
  43008. * No setter as we it is a shared configuration, you can set the values instead.
  43009. */
  43010. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43011. private _forceWireframe;
  43012. /**
  43013. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  43014. */
  43015. set forceWireframe(value: boolean);
  43016. get forceWireframe(): boolean;
  43017. private _skipFrustumClipping;
  43018. /**
  43019. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  43020. */
  43021. set skipFrustumClipping(value: boolean);
  43022. get skipFrustumClipping(): boolean;
  43023. private _forcePointsCloud;
  43024. /**
  43025. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  43026. */
  43027. set forcePointsCloud(value: boolean);
  43028. get forcePointsCloud(): boolean;
  43029. /**
  43030. * Gets or sets the active clipplane 1
  43031. */
  43032. clipPlane: Nullable<Plane>;
  43033. /**
  43034. * Gets or sets the active clipplane 2
  43035. */
  43036. clipPlane2: Nullable<Plane>;
  43037. /**
  43038. * Gets or sets the active clipplane 3
  43039. */
  43040. clipPlane3: Nullable<Plane>;
  43041. /**
  43042. * Gets or sets the active clipplane 4
  43043. */
  43044. clipPlane4: Nullable<Plane>;
  43045. /**
  43046. * Gets or sets the active clipplane 5
  43047. */
  43048. clipPlane5: Nullable<Plane>;
  43049. /**
  43050. * Gets or sets the active clipplane 6
  43051. */
  43052. clipPlane6: Nullable<Plane>;
  43053. /**
  43054. * Gets or sets a boolean indicating if animations are enabled
  43055. */
  43056. animationsEnabled: boolean;
  43057. private _animationPropertiesOverride;
  43058. /**
  43059. * Gets or sets the animation properties override
  43060. */
  43061. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  43062. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  43063. /**
  43064. * Gets or sets a boolean indicating if a constant deltatime has to be used
  43065. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  43066. */
  43067. useConstantAnimationDeltaTime: boolean;
  43068. /**
  43069. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  43070. * Please note that it requires to run a ray cast through the scene on every frame
  43071. */
  43072. constantlyUpdateMeshUnderPointer: boolean;
  43073. /**
  43074. * Defines the HTML cursor to use when hovering over interactive elements
  43075. */
  43076. hoverCursor: string;
  43077. /**
  43078. * Defines the HTML default cursor to use (empty by default)
  43079. */
  43080. defaultCursor: string;
  43081. /**
  43082. * Defines whether cursors are handled by the scene.
  43083. */
  43084. doNotHandleCursors: boolean;
  43085. /**
  43086. * This is used to call preventDefault() on pointer down
  43087. * in order to block unwanted artifacts like system double clicks
  43088. */
  43089. preventDefaultOnPointerDown: boolean;
  43090. /**
  43091. * This is used to call preventDefault() on pointer up
  43092. * in order to block unwanted artifacts like system double clicks
  43093. */
  43094. preventDefaultOnPointerUp: boolean;
  43095. /**
  43096. * Gets or sets user defined metadata
  43097. */
  43098. metadata: any;
  43099. /**
  43100. * For internal use only. Please do not use.
  43101. */
  43102. reservedDataStore: any;
  43103. /**
  43104. * Gets the name of the plugin used to load this scene (null by default)
  43105. */
  43106. loadingPluginName: string;
  43107. /**
  43108. * Use this array to add regular expressions used to disable offline support for specific urls
  43109. */
  43110. disableOfflineSupportExceptionRules: RegExp[];
  43111. /**
  43112. * An event triggered when the scene is disposed.
  43113. */
  43114. onDisposeObservable: Observable<Scene>;
  43115. private _onDisposeObserver;
  43116. /** Sets a function to be executed when this scene is disposed. */
  43117. set onDispose(callback: () => void);
  43118. /**
  43119. * An event triggered before rendering the scene (right after animations and physics)
  43120. */
  43121. onBeforeRenderObservable: Observable<Scene>;
  43122. private _onBeforeRenderObserver;
  43123. /** Sets a function to be executed before rendering this scene */
  43124. set beforeRender(callback: Nullable<() => void>);
  43125. /**
  43126. * An event triggered after rendering the scene
  43127. */
  43128. onAfterRenderObservable: Observable<Scene>;
  43129. /**
  43130. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  43131. */
  43132. onAfterRenderCameraObservable: Observable<Camera>;
  43133. private _onAfterRenderObserver;
  43134. /** Sets a function to be executed after rendering this scene */
  43135. set afterRender(callback: Nullable<() => void>);
  43136. /**
  43137. * An event triggered before animating the scene
  43138. */
  43139. onBeforeAnimationsObservable: Observable<Scene>;
  43140. /**
  43141. * An event triggered after animations processing
  43142. */
  43143. onAfterAnimationsObservable: Observable<Scene>;
  43144. /**
  43145. * An event triggered before draw calls are ready to be sent
  43146. */
  43147. onBeforeDrawPhaseObservable: Observable<Scene>;
  43148. /**
  43149. * An event triggered after draw calls have been sent
  43150. */
  43151. onAfterDrawPhaseObservable: Observable<Scene>;
  43152. /**
  43153. * An event triggered when the scene is ready
  43154. */
  43155. onReadyObservable: Observable<Scene>;
  43156. /**
  43157. * An event triggered before rendering a camera
  43158. */
  43159. onBeforeCameraRenderObservable: Observable<Camera>;
  43160. private _onBeforeCameraRenderObserver;
  43161. /** Sets a function to be executed before rendering a camera*/
  43162. set beforeCameraRender(callback: () => void);
  43163. /**
  43164. * An event triggered after rendering a camera
  43165. */
  43166. onAfterCameraRenderObservable: Observable<Camera>;
  43167. private _onAfterCameraRenderObserver;
  43168. /** Sets a function to be executed after rendering a camera*/
  43169. set afterCameraRender(callback: () => void);
  43170. /**
  43171. * An event triggered when active meshes evaluation is about to start
  43172. */
  43173. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  43174. /**
  43175. * An event triggered when active meshes evaluation is done
  43176. */
  43177. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  43178. /**
  43179. * An event triggered when particles rendering is about to start
  43180. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43181. */
  43182. onBeforeParticlesRenderingObservable: Observable<Scene>;
  43183. /**
  43184. * An event triggered when particles rendering is done
  43185. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43186. */
  43187. onAfterParticlesRenderingObservable: Observable<Scene>;
  43188. /**
  43189. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  43190. */
  43191. onDataLoadedObservable: Observable<Scene>;
  43192. /**
  43193. * An event triggered when a camera is created
  43194. */
  43195. onNewCameraAddedObservable: Observable<Camera>;
  43196. /**
  43197. * An event triggered when a camera is removed
  43198. */
  43199. onCameraRemovedObservable: Observable<Camera>;
  43200. /**
  43201. * An event triggered when a light is created
  43202. */
  43203. onNewLightAddedObservable: Observable<Light>;
  43204. /**
  43205. * An event triggered when a light is removed
  43206. */
  43207. onLightRemovedObservable: Observable<Light>;
  43208. /**
  43209. * An event triggered when a geometry is created
  43210. */
  43211. onNewGeometryAddedObservable: Observable<Geometry>;
  43212. /**
  43213. * An event triggered when a geometry is removed
  43214. */
  43215. onGeometryRemovedObservable: Observable<Geometry>;
  43216. /**
  43217. * An event triggered when a transform node is created
  43218. */
  43219. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  43220. /**
  43221. * An event triggered when a transform node is removed
  43222. */
  43223. onTransformNodeRemovedObservable: Observable<TransformNode>;
  43224. /**
  43225. * An event triggered when a mesh is created
  43226. */
  43227. onNewMeshAddedObservable: Observable<AbstractMesh>;
  43228. /**
  43229. * An event triggered when a mesh is removed
  43230. */
  43231. onMeshRemovedObservable: Observable<AbstractMesh>;
  43232. /**
  43233. * An event triggered when a skeleton is created
  43234. */
  43235. onNewSkeletonAddedObservable: Observable<Skeleton>;
  43236. /**
  43237. * An event triggered when a skeleton is removed
  43238. */
  43239. onSkeletonRemovedObservable: Observable<Skeleton>;
  43240. /**
  43241. * An event triggered when a material is created
  43242. */
  43243. onNewMaterialAddedObservable: Observable<Material>;
  43244. /**
  43245. * An event triggered when a multi material is created
  43246. */
  43247. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  43248. /**
  43249. * An event triggered when a material is removed
  43250. */
  43251. onMaterialRemovedObservable: Observable<Material>;
  43252. /**
  43253. * An event triggered when a multi material is removed
  43254. */
  43255. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  43256. /**
  43257. * An event triggered when a texture is created
  43258. */
  43259. onNewTextureAddedObservable: Observable<BaseTexture>;
  43260. /**
  43261. * An event triggered when a texture is removed
  43262. */
  43263. onTextureRemovedObservable: Observable<BaseTexture>;
  43264. /**
  43265. * An event triggered when render targets are about to be rendered
  43266. * Can happen multiple times per frame.
  43267. */
  43268. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  43269. /**
  43270. * An event triggered when render targets were rendered.
  43271. * Can happen multiple times per frame.
  43272. */
  43273. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  43274. /**
  43275. * An event triggered before calculating deterministic simulation step
  43276. */
  43277. onBeforeStepObservable: Observable<Scene>;
  43278. /**
  43279. * An event triggered after calculating deterministic simulation step
  43280. */
  43281. onAfterStepObservable: Observable<Scene>;
  43282. /**
  43283. * An event triggered when the activeCamera property is updated
  43284. */
  43285. onActiveCameraChanged: Observable<Scene>;
  43286. /**
  43287. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  43288. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43289. * 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)
  43290. */
  43291. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43292. /**
  43293. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  43294. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43295. * 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)
  43296. */
  43297. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43298. /**
  43299. * This Observable will when a mesh has been imported into the scene.
  43300. */
  43301. onMeshImportedObservable: Observable<AbstractMesh>;
  43302. /**
  43303. * This Observable will when an animation file has been imported into the scene.
  43304. */
  43305. onAnimationFileImportedObservable: Observable<Scene>;
  43306. /**
  43307. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43308. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43309. */
  43310. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43311. /** @hidden */
  43312. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43313. /**
  43314. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43315. */
  43316. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43317. /**
  43318. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43319. */
  43320. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43321. /**
  43322. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43323. */
  43324. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43325. /** Callback called when a pointer move is detected */
  43326. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43327. /** Callback called when a pointer down is detected */
  43328. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43329. /** Callback called when a pointer up is detected */
  43330. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43331. /** Callback called when a pointer pick is detected */
  43332. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43333. /**
  43334. * 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).
  43335. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43336. */
  43337. onPrePointerObservable: Observable<PointerInfoPre>;
  43338. /**
  43339. * Observable event triggered each time an input event is received from the rendering canvas
  43340. */
  43341. onPointerObservable: Observable<PointerInfo>;
  43342. /**
  43343. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43344. */
  43345. get unTranslatedPointer(): Vector2;
  43346. /**
  43347. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43348. */
  43349. static get DragMovementThreshold(): number;
  43350. static set DragMovementThreshold(value: number);
  43351. /**
  43352. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43353. */
  43354. static get LongPressDelay(): number;
  43355. static set LongPressDelay(value: number);
  43356. /**
  43357. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43358. */
  43359. static get DoubleClickDelay(): number;
  43360. static set DoubleClickDelay(value: number);
  43361. /** If you need to check double click without raising a single click at first click, enable this flag */
  43362. static get ExclusiveDoubleClickMode(): boolean;
  43363. static set ExclusiveDoubleClickMode(value: boolean);
  43364. /** @hidden */
  43365. _mirroredCameraPosition: Nullable<Vector3>;
  43366. /**
  43367. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43368. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43369. */
  43370. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43371. /**
  43372. * Observable event triggered each time an keyboard event is received from the hosting window
  43373. */
  43374. onKeyboardObservable: Observable<KeyboardInfo>;
  43375. private _useRightHandedSystem;
  43376. /**
  43377. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43378. */
  43379. set useRightHandedSystem(value: boolean);
  43380. get useRightHandedSystem(): boolean;
  43381. private _timeAccumulator;
  43382. private _currentStepId;
  43383. private _currentInternalStep;
  43384. /**
  43385. * Sets the step Id used by deterministic lock step
  43386. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43387. * @param newStepId defines the step Id
  43388. */
  43389. setStepId(newStepId: number): void;
  43390. /**
  43391. * Gets the step Id used by deterministic lock step
  43392. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43393. * @returns the step Id
  43394. */
  43395. getStepId(): number;
  43396. /**
  43397. * Gets the internal step used by deterministic lock step
  43398. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43399. * @returns the internal step
  43400. */
  43401. getInternalStep(): number;
  43402. private _fogEnabled;
  43403. /**
  43404. * Gets or sets a boolean indicating if fog is enabled on this scene
  43405. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43406. * (Default is true)
  43407. */
  43408. set fogEnabled(value: boolean);
  43409. get fogEnabled(): boolean;
  43410. private _fogMode;
  43411. /**
  43412. * Gets or sets the fog mode to use
  43413. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43414. * | mode | value |
  43415. * | --- | --- |
  43416. * | FOGMODE_NONE | 0 |
  43417. * | FOGMODE_EXP | 1 |
  43418. * | FOGMODE_EXP2 | 2 |
  43419. * | FOGMODE_LINEAR | 3 |
  43420. */
  43421. set fogMode(value: number);
  43422. get fogMode(): number;
  43423. /**
  43424. * Gets or sets the fog color to use
  43425. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43426. * (Default is Color3(0.2, 0.2, 0.3))
  43427. */
  43428. fogColor: Color3;
  43429. /**
  43430. * Gets or sets the fog density to use
  43431. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43432. * (Default is 0.1)
  43433. */
  43434. fogDensity: number;
  43435. /**
  43436. * Gets or sets the fog start distance to use
  43437. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43438. * (Default is 0)
  43439. */
  43440. fogStart: number;
  43441. /**
  43442. * Gets or sets the fog end distance to use
  43443. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43444. * (Default is 1000)
  43445. */
  43446. fogEnd: number;
  43447. /**
  43448. * Flag indicating that the frame buffer binding is handled by another component
  43449. */
  43450. prePass: boolean;
  43451. private _shadowsEnabled;
  43452. /**
  43453. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43454. */
  43455. set shadowsEnabled(value: boolean);
  43456. get shadowsEnabled(): boolean;
  43457. private _lightsEnabled;
  43458. /**
  43459. * Gets or sets a boolean indicating if lights are enabled on this scene
  43460. */
  43461. set lightsEnabled(value: boolean);
  43462. get lightsEnabled(): boolean;
  43463. /** All of the active cameras added to this scene. */
  43464. activeCameras: Nullable<Camera[]>;
  43465. /** @hidden */
  43466. _activeCamera: Nullable<Camera>;
  43467. /** Gets or sets the current active camera */
  43468. get activeCamera(): Nullable<Camera>;
  43469. set activeCamera(value: Nullable<Camera>);
  43470. private _defaultMaterial;
  43471. /** The default material used on meshes when no material is affected */
  43472. get defaultMaterial(): Material;
  43473. /** The default material used on meshes when no material is affected */
  43474. set defaultMaterial(value: Material);
  43475. private _texturesEnabled;
  43476. /**
  43477. * Gets or sets a boolean indicating if textures are enabled on this scene
  43478. */
  43479. set texturesEnabled(value: boolean);
  43480. get texturesEnabled(): boolean;
  43481. /**
  43482. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43483. */
  43484. physicsEnabled: boolean;
  43485. /**
  43486. * Gets or sets a boolean indicating if particles are enabled on this scene
  43487. */
  43488. particlesEnabled: boolean;
  43489. /**
  43490. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43491. */
  43492. spritesEnabled: boolean;
  43493. private _skeletonsEnabled;
  43494. /**
  43495. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43496. */
  43497. set skeletonsEnabled(value: boolean);
  43498. get skeletonsEnabled(): boolean;
  43499. /**
  43500. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43501. */
  43502. lensFlaresEnabled: boolean;
  43503. /**
  43504. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43505. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43506. */
  43507. collisionsEnabled: boolean;
  43508. private _collisionCoordinator;
  43509. /** @hidden */
  43510. get collisionCoordinator(): ICollisionCoordinator;
  43511. /**
  43512. * Defines the gravity applied to this scene (used only for collisions)
  43513. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43514. */
  43515. gravity: Vector3;
  43516. /**
  43517. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43518. */
  43519. postProcessesEnabled: boolean;
  43520. /**
  43521. * Gets the current postprocess manager
  43522. */
  43523. postProcessManager: PostProcessManager;
  43524. /**
  43525. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43526. */
  43527. renderTargetsEnabled: boolean;
  43528. /**
  43529. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43530. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43531. */
  43532. dumpNextRenderTargets: boolean;
  43533. /**
  43534. * The list of user defined render targets added to the scene
  43535. */
  43536. customRenderTargets: RenderTargetTexture[];
  43537. /**
  43538. * Defines if texture loading must be delayed
  43539. * If true, textures will only be loaded when they need to be rendered
  43540. */
  43541. useDelayedTextureLoading: boolean;
  43542. /**
  43543. * Gets the list of meshes imported to the scene through SceneLoader
  43544. */
  43545. importedMeshesFiles: String[];
  43546. /**
  43547. * Gets or sets a boolean indicating if probes are enabled on this scene
  43548. */
  43549. probesEnabled: boolean;
  43550. /**
  43551. * Gets or sets the current offline provider to use to store scene data
  43552. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43553. */
  43554. offlineProvider: IOfflineProvider;
  43555. /**
  43556. * Gets or sets the action manager associated with the scene
  43557. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43558. */
  43559. actionManager: AbstractActionManager;
  43560. private _meshesForIntersections;
  43561. /**
  43562. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43563. */
  43564. proceduralTexturesEnabled: boolean;
  43565. private _engine;
  43566. private _totalVertices;
  43567. /** @hidden */
  43568. _activeIndices: PerfCounter;
  43569. /** @hidden */
  43570. _activeParticles: PerfCounter;
  43571. /** @hidden */
  43572. _activeBones: PerfCounter;
  43573. private _animationRatio;
  43574. /** @hidden */
  43575. _animationTimeLast: number;
  43576. /** @hidden */
  43577. _animationTime: number;
  43578. /**
  43579. * Gets or sets a general scale for animation speed
  43580. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43581. */
  43582. animationTimeScale: number;
  43583. /** @hidden */
  43584. _cachedMaterial: Nullable<Material>;
  43585. /** @hidden */
  43586. _cachedEffect: Nullable<Effect>;
  43587. /** @hidden */
  43588. _cachedVisibility: Nullable<number>;
  43589. private _renderId;
  43590. private _frameId;
  43591. private _executeWhenReadyTimeoutId;
  43592. private _intermediateRendering;
  43593. private _viewUpdateFlag;
  43594. private _projectionUpdateFlag;
  43595. /** @hidden */
  43596. _toBeDisposed: Nullable<IDisposable>[];
  43597. private _activeRequests;
  43598. /** @hidden */
  43599. _pendingData: any[];
  43600. private _isDisposed;
  43601. /**
  43602. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43603. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43604. */
  43605. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43606. private _activeMeshes;
  43607. private _processedMaterials;
  43608. private _renderTargets;
  43609. /** @hidden */
  43610. _activeParticleSystems: SmartArray<IParticleSystem>;
  43611. private _activeSkeletons;
  43612. private _softwareSkinnedMeshes;
  43613. private _renderingManager;
  43614. /** @hidden */
  43615. _activeAnimatables: Animatable[];
  43616. private _transformMatrix;
  43617. private _sceneUbo;
  43618. /** @hidden */
  43619. _viewMatrix: Matrix;
  43620. private _projectionMatrix;
  43621. /** @hidden */
  43622. _forcedViewPosition: Nullable<Vector3>;
  43623. /** @hidden */
  43624. _frustumPlanes: Plane[];
  43625. /**
  43626. * Gets the list of frustum planes (built from the active camera)
  43627. */
  43628. get frustumPlanes(): Plane[];
  43629. /**
  43630. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43631. * This is useful if there are more lights that the maximum simulteanous authorized
  43632. */
  43633. requireLightSorting: boolean;
  43634. /** @hidden */
  43635. readonly useMaterialMeshMap: boolean;
  43636. /** @hidden */
  43637. readonly useClonedMeshMap: boolean;
  43638. private _externalData;
  43639. private _uid;
  43640. /**
  43641. * @hidden
  43642. * Backing store of defined scene components.
  43643. */
  43644. _components: ISceneComponent[];
  43645. /**
  43646. * @hidden
  43647. * Backing store of defined scene components.
  43648. */
  43649. _serializableComponents: ISceneSerializableComponent[];
  43650. /**
  43651. * List of components to register on the next registration step.
  43652. */
  43653. private _transientComponents;
  43654. /**
  43655. * Registers the transient components if needed.
  43656. */
  43657. private _registerTransientComponents;
  43658. /**
  43659. * @hidden
  43660. * Add a component to the scene.
  43661. * Note that the ccomponent could be registered on th next frame if this is called after
  43662. * the register component stage.
  43663. * @param component Defines the component to add to the scene
  43664. */
  43665. _addComponent(component: ISceneComponent): void;
  43666. /**
  43667. * @hidden
  43668. * Gets a component from the scene.
  43669. * @param name defines the name of the component to retrieve
  43670. * @returns the component or null if not present
  43671. */
  43672. _getComponent(name: string): Nullable<ISceneComponent>;
  43673. /**
  43674. * @hidden
  43675. * Defines the actions happening before camera updates.
  43676. */
  43677. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43678. /**
  43679. * @hidden
  43680. * Defines the actions happening before clear the canvas.
  43681. */
  43682. _beforeClearStage: Stage<SimpleStageAction>;
  43683. /**
  43684. * @hidden
  43685. * Defines the actions when collecting render targets for the frame.
  43686. */
  43687. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43688. /**
  43689. * @hidden
  43690. * Defines the actions happening for one camera in the frame.
  43691. */
  43692. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43693. /**
  43694. * @hidden
  43695. * Defines the actions happening during the per mesh ready checks.
  43696. */
  43697. _isReadyForMeshStage: Stage<MeshStageAction>;
  43698. /**
  43699. * @hidden
  43700. * Defines the actions happening before evaluate active mesh checks.
  43701. */
  43702. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43703. /**
  43704. * @hidden
  43705. * Defines the actions happening during the evaluate sub mesh checks.
  43706. */
  43707. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43708. /**
  43709. * @hidden
  43710. * Defines the actions happening during the active mesh stage.
  43711. */
  43712. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43713. /**
  43714. * @hidden
  43715. * Defines the actions happening during the per camera render target step.
  43716. */
  43717. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43718. /**
  43719. * @hidden
  43720. * Defines the actions happening just before the active camera is drawing.
  43721. */
  43722. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43723. /**
  43724. * @hidden
  43725. * Defines the actions happening just before a render target is drawing.
  43726. */
  43727. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43728. /**
  43729. * @hidden
  43730. * Defines the actions happening just before a rendering group is drawing.
  43731. */
  43732. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43733. /**
  43734. * @hidden
  43735. * Defines the actions happening just before a mesh is drawing.
  43736. */
  43737. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43738. /**
  43739. * @hidden
  43740. * Defines the actions happening just after a mesh has been drawn.
  43741. */
  43742. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43743. /**
  43744. * @hidden
  43745. * Defines the actions happening just after a rendering group has been drawn.
  43746. */
  43747. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43748. /**
  43749. * @hidden
  43750. * Defines the actions happening just after the active camera has been drawn.
  43751. */
  43752. _afterCameraDrawStage: Stage<CameraStageAction>;
  43753. /**
  43754. * @hidden
  43755. * Defines the actions happening just after a render target has been drawn.
  43756. */
  43757. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43758. /**
  43759. * @hidden
  43760. * Defines the actions happening just after rendering all cameras and computing intersections.
  43761. */
  43762. _afterRenderStage: Stage<SimpleStageAction>;
  43763. /**
  43764. * @hidden
  43765. * Defines the actions happening when a pointer move event happens.
  43766. */
  43767. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43768. /**
  43769. * @hidden
  43770. * Defines the actions happening when a pointer down event happens.
  43771. */
  43772. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43773. /**
  43774. * @hidden
  43775. * Defines the actions happening when a pointer up event happens.
  43776. */
  43777. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43778. /**
  43779. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43780. */
  43781. private geometriesByUniqueId;
  43782. /**
  43783. * Creates a new Scene
  43784. * @param engine defines the engine to use to render this scene
  43785. * @param options defines the scene options
  43786. */
  43787. constructor(engine: Engine, options?: SceneOptions);
  43788. /**
  43789. * Gets a string identifying the name of the class
  43790. * @returns "Scene" string
  43791. */
  43792. getClassName(): string;
  43793. private _defaultMeshCandidates;
  43794. /**
  43795. * @hidden
  43796. */
  43797. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43798. private _defaultSubMeshCandidates;
  43799. /**
  43800. * @hidden
  43801. */
  43802. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43803. /**
  43804. * Sets the default candidate providers for the scene.
  43805. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43806. * and getCollidingSubMeshCandidates to their default function
  43807. */
  43808. setDefaultCandidateProviders(): void;
  43809. /**
  43810. * Gets the mesh that is currently under the pointer
  43811. */
  43812. get meshUnderPointer(): Nullable<AbstractMesh>;
  43813. /**
  43814. * Gets or sets the current on-screen X position of the pointer
  43815. */
  43816. get pointerX(): number;
  43817. set pointerX(value: number);
  43818. /**
  43819. * Gets or sets the current on-screen Y position of the pointer
  43820. */
  43821. get pointerY(): number;
  43822. set pointerY(value: number);
  43823. /**
  43824. * Gets the cached material (ie. the latest rendered one)
  43825. * @returns the cached material
  43826. */
  43827. getCachedMaterial(): Nullable<Material>;
  43828. /**
  43829. * Gets the cached effect (ie. the latest rendered one)
  43830. * @returns the cached effect
  43831. */
  43832. getCachedEffect(): Nullable<Effect>;
  43833. /**
  43834. * Gets the cached visibility state (ie. the latest rendered one)
  43835. * @returns the cached visibility state
  43836. */
  43837. getCachedVisibility(): Nullable<number>;
  43838. /**
  43839. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43840. * @param material defines the current material
  43841. * @param effect defines the current effect
  43842. * @param visibility defines the current visibility state
  43843. * @returns true if one parameter is not cached
  43844. */
  43845. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43846. /**
  43847. * Gets the engine associated with the scene
  43848. * @returns an Engine
  43849. */
  43850. getEngine(): Engine;
  43851. /**
  43852. * Gets the total number of vertices rendered per frame
  43853. * @returns the total number of vertices rendered per frame
  43854. */
  43855. getTotalVertices(): number;
  43856. /**
  43857. * Gets the performance counter for total vertices
  43858. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43859. */
  43860. get totalVerticesPerfCounter(): PerfCounter;
  43861. /**
  43862. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43863. * @returns the total number of active indices rendered per frame
  43864. */
  43865. getActiveIndices(): number;
  43866. /**
  43867. * Gets the performance counter for active indices
  43868. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43869. */
  43870. get totalActiveIndicesPerfCounter(): PerfCounter;
  43871. /**
  43872. * Gets the total number of active particles rendered per frame
  43873. * @returns the total number of active particles rendered per frame
  43874. */
  43875. getActiveParticles(): number;
  43876. /**
  43877. * Gets the performance counter for active particles
  43878. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43879. */
  43880. get activeParticlesPerfCounter(): PerfCounter;
  43881. /**
  43882. * Gets the total number of active bones rendered per frame
  43883. * @returns the total number of active bones rendered per frame
  43884. */
  43885. getActiveBones(): number;
  43886. /**
  43887. * Gets the performance counter for active bones
  43888. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43889. */
  43890. get activeBonesPerfCounter(): PerfCounter;
  43891. /**
  43892. * Gets the array of active meshes
  43893. * @returns an array of AbstractMesh
  43894. */
  43895. getActiveMeshes(): SmartArray<AbstractMesh>;
  43896. /**
  43897. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43898. * @returns a number
  43899. */
  43900. getAnimationRatio(): number;
  43901. /**
  43902. * Gets an unique Id for the current render phase
  43903. * @returns a number
  43904. */
  43905. getRenderId(): number;
  43906. /**
  43907. * Gets an unique Id for the current frame
  43908. * @returns a number
  43909. */
  43910. getFrameId(): number;
  43911. /** Call this function if you want to manually increment the render Id*/
  43912. incrementRenderId(): void;
  43913. private _createUbo;
  43914. /**
  43915. * Use this method to simulate a pointer move on a mesh
  43916. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43917. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43918. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43919. * @returns the current scene
  43920. */
  43921. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43922. /**
  43923. * Use this method to simulate a pointer down on a mesh
  43924. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43925. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43926. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43927. * @returns the current scene
  43928. */
  43929. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43930. /**
  43931. * Use this method to simulate a pointer up on a mesh
  43932. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43933. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43934. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43935. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43936. * @returns the current scene
  43937. */
  43938. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43939. /**
  43940. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43941. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43942. * @returns true if the pointer was captured
  43943. */
  43944. isPointerCaptured(pointerId?: number): boolean;
  43945. /**
  43946. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43947. * @param attachUp defines if you want to attach events to pointerup
  43948. * @param attachDown defines if you want to attach events to pointerdown
  43949. * @param attachMove defines if you want to attach events to pointermove
  43950. */
  43951. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43952. /** Detaches all event handlers*/
  43953. detachControl(): void;
  43954. /**
  43955. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43956. * Delay loaded resources are not taking in account
  43957. * @return true if all required resources are ready
  43958. */
  43959. isReady(): boolean;
  43960. /** Resets all cached information relative to material (including effect and visibility) */
  43961. resetCachedMaterial(): void;
  43962. /**
  43963. * Registers a function to be called before every frame render
  43964. * @param func defines the function to register
  43965. */
  43966. registerBeforeRender(func: () => void): void;
  43967. /**
  43968. * Unregisters a function called before every frame render
  43969. * @param func defines the function to unregister
  43970. */
  43971. unregisterBeforeRender(func: () => void): void;
  43972. /**
  43973. * Registers a function to be called after every frame render
  43974. * @param func defines the function to register
  43975. */
  43976. registerAfterRender(func: () => void): void;
  43977. /**
  43978. * Unregisters a function called after every frame render
  43979. * @param func defines the function to unregister
  43980. */
  43981. unregisterAfterRender(func: () => void): void;
  43982. private _executeOnceBeforeRender;
  43983. /**
  43984. * The provided function will run before render once and will be disposed afterwards.
  43985. * A timeout delay can be provided so that the function will be executed in N ms.
  43986. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43987. * @param func The function to be executed.
  43988. * @param timeout optional delay in ms
  43989. */
  43990. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43991. /** @hidden */
  43992. _addPendingData(data: any): void;
  43993. /** @hidden */
  43994. _removePendingData(data: any): void;
  43995. /**
  43996. * Returns the number of items waiting to be loaded
  43997. * @returns the number of items waiting to be loaded
  43998. */
  43999. getWaitingItemsCount(): number;
  44000. /**
  44001. * Returns a boolean indicating if the scene is still loading data
  44002. */
  44003. get isLoading(): boolean;
  44004. /**
  44005. * Registers a function to be executed when the scene is ready
  44006. * @param {Function} func - the function to be executed
  44007. */
  44008. executeWhenReady(func: () => void): void;
  44009. /**
  44010. * Returns a promise that resolves when the scene is ready
  44011. * @returns A promise that resolves when the scene is ready
  44012. */
  44013. whenReadyAsync(): Promise<void>;
  44014. /** @hidden */
  44015. _checkIsReady(): void;
  44016. /**
  44017. * Gets all animatable attached to the scene
  44018. */
  44019. get animatables(): Animatable[];
  44020. /**
  44021. * Resets the last animation time frame.
  44022. * Useful to override when animations start running when loading a scene for the first time.
  44023. */
  44024. resetLastAnimationTimeFrame(): void;
  44025. /**
  44026. * Gets the current view matrix
  44027. * @returns a Matrix
  44028. */
  44029. getViewMatrix(): Matrix;
  44030. /**
  44031. * Gets the current projection matrix
  44032. * @returns a Matrix
  44033. */
  44034. getProjectionMatrix(): Matrix;
  44035. /**
  44036. * Gets the current transform matrix
  44037. * @returns a Matrix made of View * Projection
  44038. */
  44039. getTransformMatrix(): Matrix;
  44040. /**
  44041. * Sets the current transform matrix
  44042. * @param viewL defines the View matrix to use
  44043. * @param projectionL defines the Projection matrix to use
  44044. * @param viewR defines the right View matrix to use (if provided)
  44045. * @param projectionR defines the right Projection matrix to use (if provided)
  44046. */
  44047. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  44048. /**
  44049. * Gets the uniform buffer used to store scene data
  44050. * @returns a UniformBuffer
  44051. */
  44052. getSceneUniformBuffer(): UniformBuffer;
  44053. /**
  44054. * Gets an unique (relatively to the current scene) Id
  44055. * @returns an unique number for the scene
  44056. */
  44057. getUniqueId(): number;
  44058. /**
  44059. * Add a mesh to the list of scene's meshes
  44060. * @param newMesh defines the mesh to add
  44061. * @param recursive if all child meshes should also be added to the scene
  44062. */
  44063. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  44064. /**
  44065. * Remove a mesh for the list of scene's meshes
  44066. * @param toRemove defines the mesh to remove
  44067. * @param recursive if all child meshes should also be removed from the scene
  44068. * @returns the index where the mesh was in the mesh list
  44069. */
  44070. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  44071. /**
  44072. * Add a transform node to the list of scene's transform nodes
  44073. * @param newTransformNode defines the transform node to add
  44074. */
  44075. addTransformNode(newTransformNode: TransformNode): void;
  44076. /**
  44077. * Remove a transform node for the list of scene's transform nodes
  44078. * @param toRemove defines the transform node to remove
  44079. * @returns the index where the transform node was in the transform node list
  44080. */
  44081. removeTransformNode(toRemove: TransformNode): number;
  44082. /**
  44083. * Remove a skeleton for the list of scene's skeletons
  44084. * @param toRemove defines the skeleton to remove
  44085. * @returns the index where the skeleton was in the skeleton list
  44086. */
  44087. removeSkeleton(toRemove: Skeleton): number;
  44088. /**
  44089. * Remove a morph target for the list of scene's morph targets
  44090. * @param toRemove defines the morph target to remove
  44091. * @returns the index where the morph target was in the morph target list
  44092. */
  44093. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  44094. /**
  44095. * Remove a light for the list of scene's lights
  44096. * @param toRemove defines the light to remove
  44097. * @returns the index where the light was in the light list
  44098. */
  44099. removeLight(toRemove: Light): number;
  44100. /**
  44101. * Remove a camera for the list of scene's cameras
  44102. * @param toRemove defines the camera to remove
  44103. * @returns the index where the camera was in the camera list
  44104. */
  44105. removeCamera(toRemove: Camera): number;
  44106. /**
  44107. * Remove a particle system for the list of scene's particle systems
  44108. * @param toRemove defines the particle system to remove
  44109. * @returns the index where the particle system was in the particle system list
  44110. */
  44111. removeParticleSystem(toRemove: IParticleSystem): number;
  44112. /**
  44113. * Remove a animation for the list of scene's animations
  44114. * @param toRemove defines the animation to remove
  44115. * @returns the index where the animation was in the animation list
  44116. */
  44117. removeAnimation(toRemove: Animation): number;
  44118. /**
  44119. * Will stop the animation of the given target
  44120. * @param target - the target
  44121. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  44122. * @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)
  44123. */
  44124. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  44125. /**
  44126. * Removes the given animation group from this scene.
  44127. * @param toRemove The animation group to remove
  44128. * @returns The index of the removed animation group
  44129. */
  44130. removeAnimationGroup(toRemove: AnimationGroup): number;
  44131. /**
  44132. * Removes the given multi-material from this scene.
  44133. * @param toRemove The multi-material to remove
  44134. * @returns The index of the removed multi-material
  44135. */
  44136. removeMultiMaterial(toRemove: MultiMaterial): number;
  44137. /**
  44138. * Removes the given material from this scene.
  44139. * @param toRemove The material to remove
  44140. * @returns The index of the removed material
  44141. */
  44142. removeMaterial(toRemove: Material): number;
  44143. /**
  44144. * Removes the given action manager from this scene.
  44145. * @param toRemove The action manager to remove
  44146. * @returns The index of the removed action manager
  44147. */
  44148. removeActionManager(toRemove: AbstractActionManager): number;
  44149. /**
  44150. * Removes the given texture from this scene.
  44151. * @param toRemove The texture to remove
  44152. * @returns The index of the removed texture
  44153. */
  44154. removeTexture(toRemove: BaseTexture): number;
  44155. /**
  44156. * Adds the given light to this scene
  44157. * @param newLight The light to add
  44158. */
  44159. addLight(newLight: Light): void;
  44160. /**
  44161. * Sorts the list list based on light priorities
  44162. */
  44163. sortLightsByPriority(): void;
  44164. /**
  44165. * Adds the given camera to this scene
  44166. * @param newCamera The camera to add
  44167. */
  44168. addCamera(newCamera: Camera): void;
  44169. /**
  44170. * Adds the given skeleton to this scene
  44171. * @param newSkeleton The skeleton to add
  44172. */
  44173. addSkeleton(newSkeleton: Skeleton): void;
  44174. /**
  44175. * Adds the given particle system to this scene
  44176. * @param newParticleSystem The particle system to add
  44177. */
  44178. addParticleSystem(newParticleSystem: IParticleSystem): void;
  44179. /**
  44180. * Adds the given animation to this scene
  44181. * @param newAnimation The animation to add
  44182. */
  44183. addAnimation(newAnimation: Animation): void;
  44184. /**
  44185. * Adds the given animation group to this scene.
  44186. * @param newAnimationGroup The animation group to add
  44187. */
  44188. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  44189. /**
  44190. * Adds the given multi-material to this scene
  44191. * @param newMultiMaterial The multi-material to add
  44192. */
  44193. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  44194. /**
  44195. * Adds the given material to this scene
  44196. * @param newMaterial The material to add
  44197. */
  44198. addMaterial(newMaterial: Material): void;
  44199. /**
  44200. * Adds the given morph target to this scene
  44201. * @param newMorphTargetManager The morph target to add
  44202. */
  44203. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  44204. /**
  44205. * Adds the given geometry to this scene
  44206. * @param newGeometry The geometry to add
  44207. */
  44208. addGeometry(newGeometry: Geometry): void;
  44209. /**
  44210. * Adds the given action manager to this scene
  44211. * @param newActionManager The action manager to add
  44212. */
  44213. addActionManager(newActionManager: AbstractActionManager): void;
  44214. /**
  44215. * Adds the given texture to this scene.
  44216. * @param newTexture The texture to add
  44217. */
  44218. addTexture(newTexture: BaseTexture): void;
  44219. /**
  44220. * Switch active camera
  44221. * @param newCamera defines the new active camera
  44222. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  44223. */
  44224. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  44225. /**
  44226. * sets the active camera of the scene using its ID
  44227. * @param id defines the camera's ID
  44228. * @return the new active camera or null if none found.
  44229. */
  44230. setActiveCameraByID(id: string): Nullable<Camera>;
  44231. /**
  44232. * sets the active camera of the scene using its name
  44233. * @param name defines the camera's name
  44234. * @returns the new active camera or null if none found.
  44235. */
  44236. setActiveCameraByName(name: string): Nullable<Camera>;
  44237. /**
  44238. * get an animation group using its name
  44239. * @param name defines the material's name
  44240. * @return the animation group or null if none found.
  44241. */
  44242. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  44243. /**
  44244. * Get a material using its unique id
  44245. * @param uniqueId defines the material's unique id
  44246. * @return the material or null if none found.
  44247. */
  44248. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  44249. /**
  44250. * get a material using its id
  44251. * @param id defines the material's ID
  44252. * @return the material or null if none found.
  44253. */
  44254. getMaterialByID(id: string): Nullable<Material>;
  44255. /**
  44256. * Gets a the last added material using a given id
  44257. * @param id defines the material's ID
  44258. * @return the last material with the given id or null if none found.
  44259. */
  44260. getLastMaterialByID(id: string): Nullable<Material>;
  44261. /**
  44262. * Gets a material using its name
  44263. * @param name defines the material's name
  44264. * @return the material or null if none found.
  44265. */
  44266. getMaterialByName(name: string): Nullable<Material>;
  44267. /**
  44268. * Get a texture using its unique id
  44269. * @param uniqueId defines the texture's unique id
  44270. * @return the texture or null if none found.
  44271. */
  44272. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  44273. /**
  44274. * Gets a camera using its id
  44275. * @param id defines the id to look for
  44276. * @returns the camera or null if not found
  44277. */
  44278. getCameraByID(id: string): Nullable<Camera>;
  44279. /**
  44280. * Gets a camera using its unique id
  44281. * @param uniqueId defines the unique id to look for
  44282. * @returns the camera or null if not found
  44283. */
  44284. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  44285. /**
  44286. * Gets a camera using its name
  44287. * @param name defines the camera's name
  44288. * @return the camera or null if none found.
  44289. */
  44290. getCameraByName(name: string): Nullable<Camera>;
  44291. /**
  44292. * Gets a bone using its id
  44293. * @param id defines the bone's id
  44294. * @return the bone or null if not found
  44295. */
  44296. getBoneByID(id: string): Nullable<Bone>;
  44297. /**
  44298. * Gets a bone using its id
  44299. * @param name defines the bone's name
  44300. * @return the bone or null if not found
  44301. */
  44302. getBoneByName(name: string): Nullable<Bone>;
  44303. /**
  44304. * Gets a light node using its name
  44305. * @param name defines the the light's name
  44306. * @return the light or null if none found.
  44307. */
  44308. getLightByName(name: string): Nullable<Light>;
  44309. /**
  44310. * Gets a light node using its id
  44311. * @param id defines the light's id
  44312. * @return the light or null if none found.
  44313. */
  44314. getLightByID(id: string): Nullable<Light>;
  44315. /**
  44316. * Gets a light node using its scene-generated unique ID
  44317. * @param uniqueId defines the light's unique id
  44318. * @return the light or null if none found.
  44319. */
  44320. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44321. /**
  44322. * Gets a particle system by id
  44323. * @param id defines the particle system id
  44324. * @return the corresponding system or null if none found
  44325. */
  44326. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44327. /**
  44328. * Gets a geometry using its ID
  44329. * @param id defines the geometry's id
  44330. * @return the geometry or null if none found.
  44331. */
  44332. getGeometryByID(id: string): Nullable<Geometry>;
  44333. private _getGeometryByUniqueID;
  44334. /**
  44335. * Add a new geometry to this scene
  44336. * @param geometry defines the geometry to be added to the scene.
  44337. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44338. * @return a boolean defining if the geometry was added or not
  44339. */
  44340. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44341. /**
  44342. * Removes an existing geometry
  44343. * @param geometry defines the geometry to be removed from the scene
  44344. * @return a boolean defining if the geometry was removed or not
  44345. */
  44346. removeGeometry(geometry: Geometry): boolean;
  44347. /**
  44348. * Gets the list of geometries attached to the scene
  44349. * @returns an array of Geometry
  44350. */
  44351. getGeometries(): Geometry[];
  44352. /**
  44353. * Gets the first added mesh found of a given ID
  44354. * @param id defines the id to search for
  44355. * @return the mesh found or null if not found at all
  44356. */
  44357. getMeshByID(id: string): Nullable<AbstractMesh>;
  44358. /**
  44359. * Gets a list of meshes using their id
  44360. * @param id defines the id to search for
  44361. * @returns a list of meshes
  44362. */
  44363. getMeshesByID(id: string): Array<AbstractMesh>;
  44364. /**
  44365. * Gets the first added transform node found of a given ID
  44366. * @param id defines the id to search for
  44367. * @return the found transform node or null if not found at all.
  44368. */
  44369. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44370. /**
  44371. * Gets a transform node with its auto-generated unique id
  44372. * @param uniqueId efines the unique id to search for
  44373. * @return the found transform node or null if not found at all.
  44374. */
  44375. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44376. /**
  44377. * Gets a list of transform nodes using their id
  44378. * @param id defines the id to search for
  44379. * @returns a list of transform nodes
  44380. */
  44381. getTransformNodesByID(id: string): Array<TransformNode>;
  44382. /**
  44383. * Gets a mesh with its auto-generated unique id
  44384. * @param uniqueId defines the unique id to search for
  44385. * @return the found mesh or null if not found at all.
  44386. */
  44387. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44388. /**
  44389. * Gets a the last added mesh using a given id
  44390. * @param id defines the id to search for
  44391. * @return the found mesh or null if not found at all.
  44392. */
  44393. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44394. /**
  44395. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44396. * @param id defines the id to search for
  44397. * @return the found node or null if not found at all
  44398. */
  44399. getLastEntryByID(id: string): Nullable<Node>;
  44400. /**
  44401. * Gets a node (Mesh, Camera, Light) using a given id
  44402. * @param id defines the id to search for
  44403. * @return the found node or null if not found at all
  44404. */
  44405. getNodeByID(id: string): Nullable<Node>;
  44406. /**
  44407. * Gets a node (Mesh, Camera, Light) using a given name
  44408. * @param name defines the name to search for
  44409. * @return the found node or null if not found at all.
  44410. */
  44411. getNodeByName(name: string): Nullable<Node>;
  44412. /**
  44413. * Gets a mesh using a given name
  44414. * @param name defines the name to search for
  44415. * @return the found mesh or null if not found at all.
  44416. */
  44417. getMeshByName(name: string): Nullable<AbstractMesh>;
  44418. /**
  44419. * Gets a transform node using a given name
  44420. * @param name defines the name to search for
  44421. * @return the found transform node or null if not found at all.
  44422. */
  44423. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44424. /**
  44425. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44426. * @param id defines the id to search for
  44427. * @return the found skeleton or null if not found at all.
  44428. */
  44429. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44430. /**
  44431. * Gets a skeleton using a given auto generated unique id
  44432. * @param uniqueId defines the unique id to search for
  44433. * @return the found skeleton or null if not found at all.
  44434. */
  44435. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44436. /**
  44437. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44438. * @param id defines the id to search for
  44439. * @return the found skeleton or null if not found at all.
  44440. */
  44441. getSkeletonById(id: string): Nullable<Skeleton>;
  44442. /**
  44443. * Gets a skeleton using a given name
  44444. * @param name defines the name to search for
  44445. * @return the found skeleton or null if not found at all.
  44446. */
  44447. getSkeletonByName(name: string): Nullable<Skeleton>;
  44448. /**
  44449. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44450. * @param id defines the id to search for
  44451. * @return the found morph target manager or null if not found at all.
  44452. */
  44453. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44454. /**
  44455. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44456. * @param id defines the id to search for
  44457. * @return the found morph target or null if not found at all.
  44458. */
  44459. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44460. /**
  44461. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44462. * @param name defines the name to search for
  44463. * @return the found morph target or null if not found at all.
  44464. */
  44465. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44466. /**
  44467. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44468. * @param name defines the name to search for
  44469. * @return the found post process or null if not found at all.
  44470. */
  44471. getPostProcessByName(name: string): Nullable<PostProcess>;
  44472. /**
  44473. * Gets a boolean indicating if the given mesh is active
  44474. * @param mesh defines the mesh to look for
  44475. * @returns true if the mesh is in the active list
  44476. */
  44477. isActiveMesh(mesh: AbstractMesh): boolean;
  44478. /**
  44479. * Return a unique id as a string which can serve as an identifier for the scene
  44480. */
  44481. get uid(): string;
  44482. /**
  44483. * Add an externaly attached data from its key.
  44484. * This method call will fail and return false, if such key already exists.
  44485. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44486. * @param key the unique key that identifies the data
  44487. * @param data the data object to associate to the key for this Engine instance
  44488. * @return true if no such key were already present and the data was added successfully, false otherwise
  44489. */
  44490. addExternalData<T>(key: string, data: T): boolean;
  44491. /**
  44492. * Get an externaly attached data from its key
  44493. * @param key the unique key that identifies the data
  44494. * @return the associated data, if present (can be null), or undefined if not present
  44495. */
  44496. getExternalData<T>(key: string): Nullable<T>;
  44497. /**
  44498. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44499. * @param key the unique key that identifies the data
  44500. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44501. * @return the associated data, can be null if the factory returned null.
  44502. */
  44503. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44504. /**
  44505. * Remove an externaly attached data from the Engine instance
  44506. * @param key the unique key that identifies the data
  44507. * @return true if the data was successfully removed, false if it doesn't exist
  44508. */
  44509. removeExternalData(key: string): boolean;
  44510. private _evaluateSubMesh;
  44511. /**
  44512. * Clear the processed materials smart array preventing retention point in material dispose.
  44513. */
  44514. freeProcessedMaterials(): void;
  44515. private _preventFreeActiveMeshesAndRenderingGroups;
  44516. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44517. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44518. * when disposing several meshes in a row or a hierarchy of meshes.
  44519. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44520. */
  44521. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44522. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44523. /**
  44524. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44525. */
  44526. freeActiveMeshes(): void;
  44527. /**
  44528. * Clear the info related to rendering groups preventing retention points during dispose.
  44529. */
  44530. freeRenderingGroups(): void;
  44531. /** @hidden */
  44532. _isInIntermediateRendering(): boolean;
  44533. /**
  44534. * Lambda returning the list of potentially active meshes.
  44535. */
  44536. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44537. /**
  44538. * Lambda returning the list of potentially active sub meshes.
  44539. */
  44540. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44541. /**
  44542. * Lambda returning the list of potentially intersecting sub meshes.
  44543. */
  44544. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44545. /**
  44546. * Lambda returning the list of potentially colliding sub meshes.
  44547. */
  44548. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44549. /** @hidden */
  44550. _activeMeshesFrozen: boolean;
  44551. private _skipEvaluateActiveMeshesCompletely;
  44552. /**
  44553. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44554. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44555. * @param onSuccess optional success callback
  44556. * @param onError optional error callback
  44557. * @returns the current scene
  44558. */
  44559. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44560. /**
  44561. * Use this function to restart evaluating active meshes on every frame
  44562. * @returns the current scene
  44563. */
  44564. unfreezeActiveMeshes(): Scene;
  44565. private _evaluateActiveMeshes;
  44566. private _activeMesh;
  44567. /**
  44568. * Update the transform matrix to update from the current active camera
  44569. * @param force defines a boolean used to force the update even if cache is up to date
  44570. */
  44571. updateTransformMatrix(force?: boolean): void;
  44572. private _bindFrameBuffer;
  44573. /** @hidden */
  44574. _allowPostProcessClearColor: boolean;
  44575. /** @hidden */
  44576. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44577. private _processSubCameras;
  44578. private _checkIntersections;
  44579. /** @hidden */
  44580. _advancePhysicsEngineStep(step: number): void;
  44581. /**
  44582. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44583. */
  44584. getDeterministicFrameTime: () => number;
  44585. /** @hidden */
  44586. _animate(): void;
  44587. /** Execute all animations (for a frame) */
  44588. animate(): void;
  44589. /**
  44590. * Render the scene
  44591. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44592. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44593. */
  44594. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44595. /**
  44596. * Freeze all materials
  44597. * A frozen material will not be updatable but should be faster to render
  44598. */
  44599. freezeMaterials(): void;
  44600. /**
  44601. * Unfreeze all materials
  44602. * A frozen material will not be updatable but should be faster to render
  44603. */
  44604. unfreezeMaterials(): void;
  44605. /**
  44606. * Releases all held ressources
  44607. */
  44608. dispose(): void;
  44609. /**
  44610. * Gets if the scene is already disposed
  44611. */
  44612. get isDisposed(): boolean;
  44613. /**
  44614. * Call this function to reduce memory footprint of the scene.
  44615. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44616. */
  44617. clearCachedVertexData(): void;
  44618. /**
  44619. * This function will remove the local cached buffer data from texture.
  44620. * It will save memory but will prevent the texture from being rebuilt
  44621. */
  44622. cleanCachedTextureBuffer(): void;
  44623. /**
  44624. * Get the world extend vectors with an optional filter
  44625. *
  44626. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44627. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44628. */
  44629. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44630. min: Vector3;
  44631. max: Vector3;
  44632. };
  44633. /**
  44634. * Creates a ray that can be used to pick in the scene
  44635. * @param x defines the x coordinate of the origin (on-screen)
  44636. * @param y defines the y coordinate of the origin (on-screen)
  44637. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44638. * @param camera defines the camera to use for the picking
  44639. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44640. * @returns a Ray
  44641. */
  44642. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44643. /**
  44644. * Creates a ray that can be used to pick in the scene
  44645. * @param x defines the x coordinate of the origin (on-screen)
  44646. * @param y defines the y coordinate of the origin (on-screen)
  44647. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44648. * @param result defines the ray where to store the picking ray
  44649. * @param camera defines the camera to use for the picking
  44650. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44651. * @returns the current scene
  44652. */
  44653. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44654. /**
  44655. * Creates a ray that can be used to pick in the scene
  44656. * @param x defines the x coordinate of the origin (on-screen)
  44657. * @param y defines the y coordinate of the origin (on-screen)
  44658. * @param camera defines the camera to use for the picking
  44659. * @returns a Ray
  44660. */
  44661. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44662. /**
  44663. * Creates a ray that can be used to pick in the scene
  44664. * @param x defines the x coordinate of the origin (on-screen)
  44665. * @param y defines the y coordinate of the origin (on-screen)
  44666. * @param result defines the ray where to store the picking ray
  44667. * @param camera defines the camera to use for the picking
  44668. * @returns the current scene
  44669. */
  44670. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44671. /** Launch a ray to try to pick a mesh in the scene
  44672. * @param x position on screen
  44673. * @param y position on screen
  44674. * @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
  44675. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44676. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44677. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44678. * @returns a PickingInfo
  44679. */
  44680. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44681. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44682. * @param x position on screen
  44683. * @param y position on screen
  44684. * @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
  44685. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44686. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44687. * @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)
  44688. */
  44689. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44690. /** Use the given ray to pick a mesh in the scene
  44691. * @param ray The ray to use to pick meshes
  44692. * @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
  44693. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44694. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44695. * @returns a PickingInfo
  44696. */
  44697. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44698. /**
  44699. * Launch a ray to try to pick a mesh in the scene
  44700. * @param x X position on screen
  44701. * @param y Y position on screen
  44702. * @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
  44703. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44704. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44705. * @returns an array of PickingInfo
  44706. */
  44707. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44708. /**
  44709. * Launch a ray to try to pick a mesh in the scene
  44710. * @param ray Ray to use
  44711. * @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
  44712. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44713. * @returns an array of PickingInfo
  44714. */
  44715. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44716. /**
  44717. * Force the value of meshUnderPointer
  44718. * @param mesh defines the mesh to use
  44719. * @param pointerId optional pointer id when using more than one pointer
  44720. */
  44721. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44722. /**
  44723. * Gets the mesh under the pointer
  44724. * @returns a Mesh or null if no mesh is under the pointer
  44725. */
  44726. getPointerOverMesh(): Nullable<AbstractMesh>;
  44727. /** @hidden */
  44728. _rebuildGeometries(): void;
  44729. /** @hidden */
  44730. _rebuildTextures(): void;
  44731. private _getByTags;
  44732. /**
  44733. * Get a list of meshes by tags
  44734. * @param tagsQuery defines the tags query to use
  44735. * @param forEach defines a predicate used to filter results
  44736. * @returns an array of Mesh
  44737. */
  44738. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44739. /**
  44740. * Get a list of cameras by tags
  44741. * @param tagsQuery defines the tags query to use
  44742. * @param forEach defines a predicate used to filter results
  44743. * @returns an array of Camera
  44744. */
  44745. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44746. /**
  44747. * Get a list of lights by tags
  44748. * @param tagsQuery defines the tags query to use
  44749. * @param forEach defines a predicate used to filter results
  44750. * @returns an array of Light
  44751. */
  44752. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44753. /**
  44754. * Get a list of materials by tags
  44755. * @param tagsQuery defines the tags query to use
  44756. * @param forEach defines a predicate used to filter results
  44757. * @returns an array of Material
  44758. */
  44759. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44760. /**
  44761. * Get a list of transform nodes by tags
  44762. * @param tagsQuery defines the tags query to use
  44763. * @param forEach defines a predicate used to filter results
  44764. * @returns an array of TransformNode
  44765. */
  44766. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44767. /**
  44768. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44769. * This allowed control for front to back rendering or reversly depending of the special needs.
  44770. *
  44771. * @param renderingGroupId The rendering group id corresponding to its index
  44772. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44773. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44774. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44775. */
  44776. 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;
  44777. /**
  44778. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44779. *
  44780. * @param renderingGroupId The rendering group id corresponding to its index
  44781. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44782. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44783. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44784. */
  44785. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44786. /**
  44787. * Gets the current auto clear configuration for one rendering group of the rendering
  44788. * manager.
  44789. * @param index the rendering group index to get the information for
  44790. * @returns The auto clear setup for the requested rendering group
  44791. */
  44792. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44793. private _blockMaterialDirtyMechanism;
  44794. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44795. get blockMaterialDirtyMechanism(): boolean;
  44796. set blockMaterialDirtyMechanism(value: boolean);
  44797. /**
  44798. * Will flag all materials as dirty to trigger new shader compilation
  44799. * @param flag defines the flag used to specify which material part must be marked as dirty
  44800. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44801. */
  44802. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44803. /** @hidden */
  44804. _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;
  44805. /** @hidden */
  44806. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44807. /** @hidden */
  44808. _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;
  44809. /** @hidden */
  44810. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44811. /** @hidden */
  44812. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44813. /** @hidden */
  44814. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44815. }
  44816. }
  44817. declare module BABYLON {
  44818. /**
  44819. * Set of assets to keep when moving a scene into an asset container.
  44820. */
  44821. export class KeepAssets extends AbstractScene {
  44822. }
  44823. /**
  44824. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44825. */
  44826. export class InstantiatedEntries {
  44827. /**
  44828. * List of new root nodes (eg. nodes with no parent)
  44829. */
  44830. rootNodes: TransformNode[];
  44831. /**
  44832. * List of new skeletons
  44833. */
  44834. skeletons: Skeleton[];
  44835. /**
  44836. * List of new animation groups
  44837. */
  44838. animationGroups: AnimationGroup[];
  44839. }
  44840. /**
  44841. * Container with a set of assets that can be added or removed from a scene.
  44842. */
  44843. export class AssetContainer extends AbstractScene {
  44844. private _wasAddedToScene;
  44845. /**
  44846. * The scene the AssetContainer belongs to.
  44847. */
  44848. scene: Scene;
  44849. /**
  44850. * Instantiates an AssetContainer.
  44851. * @param scene The scene the AssetContainer belongs to.
  44852. */
  44853. constructor(scene: Scene);
  44854. /**
  44855. * Instantiate or clone all meshes and add the new ones to the scene.
  44856. * Skeletons and animation groups will all be cloned
  44857. * @param nameFunction defines an optional function used to get new names for clones
  44858. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44859. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44860. */
  44861. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44862. /**
  44863. * Adds all the assets from the container to the scene.
  44864. */
  44865. addAllToScene(): void;
  44866. /**
  44867. * Removes all the assets in the container from the scene
  44868. */
  44869. removeAllFromScene(): void;
  44870. /**
  44871. * Disposes all the assets in the container
  44872. */
  44873. dispose(): void;
  44874. private _moveAssets;
  44875. /**
  44876. * Removes all the assets contained in the scene and adds them to the container.
  44877. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44878. */
  44879. moveAllFromScene(keepAssets?: KeepAssets): void;
  44880. /**
  44881. * 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.
  44882. * @returns the root mesh
  44883. */
  44884. createRootMesh(): Mesh;
  44885. /**
  44886. * Merge animations (direct and animation groups) from this asset container into a scene
  44887. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44888. * @param animatables set of animatables to retarget to a node from the scene
  44889. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44890. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44891. */
  44892. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44893. }
  44894. }
  44895. declare module BABYLON {
  44896. /**
  44897. * Defines how the parser contract is defined.
  44898. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44899. */
  44900. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44901. /**
  44902. * Defines how the individual parser contract is defined.
  44903. * These parser can parse an individual asset
  44904. */
  44905. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44906. /**
  44907. * Base class of the scene acting as a container for the different elements composing a scene.
  44908. * This class is dynamically extended by the different components of the scene increasing
  44909. * flexibility and reducing coupling
  44910. */
  44911. export abstract class AbstractScene {
  44912. /**
  44913. * Stores the list of available parsers in the application.
  44914. */
  44915. private static _BabylonFileParsers;
  44916. /**
  44917. * Stores the list of available individual parsers in the application.
  44918. */
  44919. private static _IndividualBabylonFileParsers;
  44920. /**
  44921. * Adds a parser in the list of available ones
  44922. * @param name Defines the name of the parser
  44923. * @param parser Defines the parser to add
  44924. */
  44925. static AddParser(name: string, parser: BabylonFileParser): void;
  44926. /**
  44927. * Gets a general parser from the list of avaialble ones
  44928. * @param name Defines the name of the parser
  44929. * @returns the requested parser or null
  44930. */
  44931. static GetParser(name: string): Nullable<BabylonFileParser>;
  44932. /**
  44933. * Adds n individual parser in the list of available ones
  44934. * @param name Defines the name of the parser
  44935. * @param parser Defines the parser to add
  44936. */
  44937. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44938. /**
  44939. * Gets an individual parser from the list of avaialble ones
  44940. * @param name Defines the name of the parser
  44941. * @returns the requested parser or null
  44942. */
  44943. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44944. /**
  44945. * Parser json data and populate both a scene and its associated container object
  44946. * @param jsonData Defines the data to parse
  44947. * @param scene Defines the scene to parse the data for
  44948. * @param container Defines the container attached to the parsing sequence
  44949. * @param rootUrl Defines the root url of the data
  44950. */
  44951. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44952. /**
  44953. * Gets the list of root nodes (ie. nodes with no parent)
  44954. */
  44955. rootNodes: Node[];
  44956. /** All of the cameras added to this scene
  44957. * @see https://doc.babylonjs.com/babylon101/cameras
  44958. */
  44959. cameras: Camera[];
  44960. /**
  44961. * All of the lights added to this scene
  44962. * @see https://doc.babylonjs.com/babylon101/lights
  44963. */
  44964. lights: Light[];
  44965. /**
  44966. * All of the (abstract) meshes added to this scene
  44967. */
  44968. meshes: AbstractMesh[];
  44969. /**
  44970. * The list of skeletons added to the scene
  44971. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44972. */
  44973. skeletons: Skeleton[];
  44974. /**
  44975. * All of the particle systems added to this scene
  44976. * @see https://doc.babylonjs.com/babylon101/particles
  44977. */
  44978. particleSystems: IParticleSystem[];
  44979. /**
  44980. * Gets a list of Animations associated with the scene
  44981. */
  44982. animations: Animation[];
  44983. /**
  44984. * All of the animation groups added to this scene
  44985. * @see https://doc.babylonjs.com/how_to/group
  44986. */
  44987. animationGroups: AnimationGroup[];
  44988. /**
  44989. * All of the multi-materials added to this scene
  44990. * @see https://doc.babylonjs.com/how_to/multi_materials
  44991. */
  44992. multiMaterials: MultiMaterial[];
  44993. /**
  44994. * All of the materials added to this scene
  44995. * In the context of a Scene, it is not supposed to be modified manually.
  44996. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44997. * Note also that the order of the Material within the array is not significant and might change.
  44998. * @see https://doc.babylonjs.com/babylon101/materials
  44999. */
  45000. materials: Material[];
  45001. /**
  45002. * The list of morph target managers added to the scene
  45003. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  45004. */
  45005. morphTargetManagers: MorphTargetManager[];
  45006. /**
  45007. * The list of geometries used in the scene.
  45008. */
  45009. geometries: Geometry[];
  45010. /**
  45011. * All of the tranform nodes added to this scene
  45012. * In the context of a Scene, it is not supposed to be modified manually.
  45013. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  45014. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  45015. * @see https://doc.babylonjs.com/how_to/transformnode
  45016. */
  45017. transformNodes: TransformNode[];
  45018. /**
  45019. * ActionManagers available on the scene.
  45020. */
  45021. actionManagers: AbstractActionManager[];
  45022. /**
  45023. * Textures to keep.
  45024. */
  45025. textures: BaseTexture[];
  45026. /** @hidden */
  45027. protected _environmentTexture: Nullable<BaseTexture>;
  45028. /**
  45029. * Texture used in all pbr material as the reflection texture.
  45030. * As in the majority of the scene they are the same (exception for multi room and so on),
  45031. * this is easier to reference from here than from all the materials.
  45032. */
  45033. get environmentTexture(): Nullable<BaseTexture>;
  45034. set environmentTexture(value: Nullable<BaseTexture>);
  45035. /**
  45036. * The list of postprocesses added to the scene
  45037. */
  45038. postProcesses: PostProcess[];
  45039. /**
  45040. * @returns all meshes, lights, cameras, transformNodes and bones
  45041. */
  45042. getNodes(): Array<Node>;
  45043. }
  45044. }
  45045. declare module BABYLON {
  45046. /**
  45047. * Interface used to define options for Sound class
  45048. */
  45049. export interface ISoundOptions {
  45050. /**
  45051. * Does the sound autoplay once loaded.
  45052. */
  45053. autoplay?: boolean;
  45054. /**
  45055. * Does the sound loop after it finishes playing once.
  45056. */
  45057. loop?: boolean;
  45058. /**
  45059. * Sound's volume
  45060. */
  45061. volume?: number;
  45062. /**
  45063. * Is it a spatial sound?
  45064. */
  45065. spatialSound?: boolean;
  45066. /**
  45067. * Maximum distance to hear that sound
  45068. */
  45069. maxDistance?: number;
  45070. /**
  45071. * Uses user defined attenuation function
  45072. */
  45073. useCustomAttenuation?: boolean;
  45074. /**
  45075. * Define the roll off factor of spatial sounds.
  45076. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45077. */
  45078. rolloffFactor?: number;
  45079. /**
  45080. * Define the reference distance the sound should be heard perfectly.
  45081. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45082. */
  45083. refDistance?: number;
  45084. /**
  45085. * Define the distance attenuation model the sound will follow.
  45086. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45087. */
  45088. distanceModel?: string;
  45089. /**
  45090. * Defines the playback speed (1 by default)
  45091. */
  45092. playbackRate?: number;
  45093. /**
  45094. * Defines if the sound is from a streaming source
  45095. */
  45096. streaming?: boolean;
  45097. /**
  45098. * Defines an optional length (in seconds) inside the sound file
  45099. */
  45100. length?: number;
  45101. /**
  45102. * Defines an optional offset (in seconds) inside the sound file
  45103. */
  45104. offset?: number;
  45105. /**
  45106. * If true, URLs will not be required to state the audio file codec to use.
  45107. */
  45108. skipCodecCheck?: boolean;
  45109. }
  45110. }
  45111. declare module BABYLON {
  45112. /**
  45113. * Defines a sound that can be played in the application.
  45114. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  45115. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45116. */
  45117. export class Sound {
  45118. /**
  45119. * The name of the sound in the scene.
  45120. */
  45121. name: string;
  45122. /**
  45123. * Does the sound autoplay once loaded.
  45124. */
  45125. autoplay: boolean;
  45126. private _loop;
  45127. /**
  45128. * Does the sound loop after it finishes playing once.
  45129. */
  45130. get loop(): boolean;
  45131. set loop(value: boolean);
  45132. /**
  45133. * Does the sound use a custom attenuation curve to simulate the falloff
  45134. * happening when the source gets further away from the camera.
  45135. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45136. */
  45137. useCustomAttenuation: boolean;
  45138. /**
  45139. * The sound track id this sound belongs to.
  45140. */
  45141. soundTrackId: number;
  45142. /**
  45143. * Is this sound currently played.
  45144. */
  45145. isPlaying: boolean;
  45146. /**
  45147. * Is this sound currently paused.
  45148. */
  45149. isPaused: boolean;
  45150. /**
  45151. * Does this sound enables spatial sound.
  45152. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45153. */
  45154. spatialSound: boolean;
  45155. /**
  45156. * Define the reference distance the sound should be heard perfectly.
  45157. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45158. */
  45159. refDistance: number;
  45160. /**
  45161. * Define the roll off factor of spatial sounds.
  45162. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45163. */
  45164. rolloffFactor: number;
  45165. /**
  45166. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  45167. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45168. */
  45169. maxDistance: number;
  45170. /**
  45171. * Define the distance attenuation model the sound will follow.
  45172. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45173. */
  45174. distanceModel: string;
  45175. /**
  45176. * @hidden
  45177. * Back Compat
  45178. **/
  45179. onended: () => any;
  45180. /**
  45181. * Gets or sets an object used to store user defined information for the sound.
  45182. */
  45183. metadata: any;
  45184. /**
  45185. * Observable event when the current playing sound finishes.
  45186. */
  45187. onEndedObservable: Observable<Sound>;
  45188. /**
  45189. * Gets the current time for the sound.
  45190. */
  45191. get currentTime(): number;
  45192. private _panningModel;
  45193. private _playbackRate;
  45194. private _streaming;
  45195. private _startTime;
  45196. private _startOffset;
  45197. private _position;
  45198. /** @hidden */
  45199. _positionInEmitterSpace: boolean;
  45200. private _localDirection;
  45201. private _volume;
  45202. private _isReadyToPlay;
  45203. private _isDirectional;
  45204. private _readyToPlayCallback;
  45205. private _audioBuffer;
  45206. private _soundSource;
  45207. private _streamingSource;
  45208. private _soundPanner;
  45209. private _soundGain;
  45210. private _inputAudioNode;
  45211. private _outputAudioNode;
  45212. private _coneInnerAngle;
  45213. private _coneOuterAngle;
  45214. private _coneOuterGain;
  45215. private _scene;
  45216. private _connectedTransformNode;
  45217. private _customAttenuationFunction;
  45218. private _registerFunc;
  45219. private _isOutputConnected;
  45220. private _htmlAudioElement;
  45221. private _urlType;
  45222. private _length?;
  45223. private _offset?;
  45224. /** @hidden */
  45225. static _SceneComponentInitialization: (scene: Scene) => void;
  45226. /**
  45227. * Create a sound and attach it to a scene
  45228. * @param name Name of your sound
  45229. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  45230. * @param scene defines the scene the sound belongs to
  45231. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  45232. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  45233. */
  45234. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  45235. /**
  45236. * Release the sound and its associated resources
  45237. */
  45238. dispose(): void;
  45239. /**
  45240. * Gets if the sounds is ready to be played or not.
  45241. * @returns true if ready, otherwise false
  45242. */
  45243. isReady(): boolean;
  45244. /**
  45245. * Get the current class name.
  45246. * @returns current class name
  45247. */
  45248. getClassName(): string;
  45249. private _soundLoaded;
  45250. /**
  45251. * Sets the data of the sound from an audiobuffer
  45252. * @param audioBuffer The audioBuffer containing the data
  45253. */
  45254. setAudioBuffer(audioBuffer: AudioBuffer): void;
  45255. /**
  45256. * Updates the current sounds options such as maxdistance, loop...
  45257. * @param options A JSON object containing values named as the object properties
  45258. */
  45259. updateOptions(options: ISoundOptions): void;
  45260. private _createSpatialParameters;
  45261. private _updateSpatialParameters;
  45262. /**
  45263. * Switch the panning model to HRTF:
  45264. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45265. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45266. */
  45267. switchPanningModelToHRTF(): void;
  45268. /**
  45269. * Switch the panning model to Equal Power:
  45270. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45271. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45272. */
  45273. switchPanningModelToEqualPower(): void;
  45274. private _switchPanningModel;
  45275. /**
  45276. * Connect this sound to a sound track audio node like gain...
  45277. * @param soundTrackAudioNode the sound track audio node to connect to
  45278. */
  45279. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  45280. /**
  45281. * Transform this sound into a directional source
  45282. * @param coneInnerAngle Size of the inner cone in degree
  45283. * @param coneOuterAngle Size of the outer cone in degree
  45284. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  45285. */
  45286. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  45287. /**
  45288. * Gets or sets the inner angle for the directional cone.
  45289. */
  45290. get directionalConeInnerAngle(): number;
  45291. /**
  45292. * Gets or sets the inner angle for the directional cone.
  45293. */
  45294. set directionalConeInnerAngle(value: number);
  45295. /**
  45296. * Gets or sets the outer angle for the directional cone.
  45297. */
  45298. get directionalConeOuterAngle(): number;
  45299. /**
  45300. * Gets or sets the outer angle for the directional cone.
  45301. */
  45302. set directionalConeOuterAngle(value: number);
  45303. /**
  45304. * Sets the position of the emitter if spatial sound is enabled
  45305. * @param newPosition Defines the new posisiton
  45306. */
  45307. setPosition(newPosition: Vector3): void;
  45308. /**
  45309. * Sets the local direction of the emitter if spatial sound is enabled
  45310. * @param newLocalDirection Defines the new local direction
  45311. */
  45312. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45313. private _updateDirection;
  45314. /** @hidden */
  45315. updateDistanceFromListener(): void;
  45316. /**
  45317. * Sets a new custom attenuation function for the sound.
  45318. * @param callback Defines the function used for the attenuation
  45319. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45320. */
  45321. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45322. /**
  45323. * Play the sound
  45324. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45325. * @param offset (optional) Start the sound at a specific time in seconds
  45326. * @param length (optional) Sound duration (in seconds)
  45327. */
  45328. play(time?: number, offset?: number, length?: number): void;
  45329. private _onended;
  45330. /**
  45331. * Stop the sound
  45332. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45333. */
  45334. stop(time?: number): void;
  45335. /**
  45336. * Put the sound in pause
  45337. */
  45338. pause(): void;
  45339. /**
  45340. * Sets a dedicated volume for this sounds
  45341. * @param newVolume Define the new volume of the sound
  45342. * @param time Define time for gradual change to new volume
  45343. */
  45344. setVolume(newVolume: number, time?: number): void;
  45345. /**
  45346. * Set the sound play back rate
  45347. * @param newPlaybackRate Define the playback rate the sound should be played at
  45348. */
  45349. setPlaybackRate(newPlaybackRate: number): void;
  45350. /**
  45351. * Gets the volume of the sound.
  45352. * @returns the volume of the sound
  45353. */
  45354. getVolume(): number;
  45355. /**
  45356. * Attach the sound to a dedicated mesh
  45357. * @param transformNode The transform node to connect the sound with
  45358. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45359. */
  45360. attachToMesh(transformNode: TransformNode): void;
  45361. /**
  45362. * Detach the sound from the previously attached mesh
  45363. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45364. */
  45365. detachFromMesh(): void;
  45366. private _onRegisterAfterWorldMatrixUpdate;
  45367. /**
  45368. * Clone the current sound in the scene.
  45369. * @returns the new sound clone
  45370. */
  45371. clone(): Nullable<Sound>;
  45372. /**
  45373. * Gets the current underlying audio buffer containing the data
  45374. * @returns the audio buffer
  45375. */
  45376. getAudioBuffer(): Nullable<AudioBuffer>;
  45377. /**
  45378. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45379. * @returns the source node
  45380. */
  45381. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45382. /**
  45383. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45384. * @returns the gain node
  45385. */
  45386. getSoundGain(): Nullable<GainNode>;
  45387. /**
  45388. * Serializes the Sound in a JSON representation
  45389. * @returns the JSON representation of the sound
  45390. */
  45391. serialize(): any;
  45392. /**
  45393. * Parse a JSON representation of a sound to innstantiate in a given scene
  45394. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45395. * @param scene Define the scene the new parsed sound should be created in
  45396. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45397. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45398. * @returns the newly parsed sound
  45399. */
  45400. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45401. }
  45402. }
  45403. declare module BABYLON {
  45404. /**
  45405. * This defines an action helpful to play a defined sound on a triggered action.
  45406. */
  45407. export class PlaySoundAction extends Action {
  45408. private _sound;
  45409. /**
  45410. * Instantiate the action
  45411. * @param triggerOptions defines the trigger options
  45412. * @param sound defines the sound to play
  45413. * @param condition defines the trigger related conditions
  45414. */
  45415. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45416. /** @hidden */
  45417. _prepare(): void;
  45418. /**
  45419. * Execute the action and play the sound.
  45420. */
  45421. execute(): void;
  45422. /**
  45423. * Serializes the actions and its related information.
  45424. * @param parent defines the object to serialize in
  45425. * @returns the serialized object
  45426. */
  45427. serialize(parent: any): any;
  45428. }
  45429. /**
  45430. * This defines an action helpful to stop a defined sound on a triggered action.
  45431. */
  45432. export class StopSoundAction extends Action {
  45433. private _sound;
  45434. /**
  45435. * Instantiate the action
  45436. * @param triggerOptions defines the trigger options
  45437. * @param sound defines the sound to stop
  45438. * @param condition defines the trigger related conditions
  45439. */
  45440. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45441. /** @hidden */
  45442. _prepare(): void;
  45443. /**
  45444. * Execute the action and stop the sound.
  45445. */
  45446. execute(): void;
  45447. /**
  45448. * Serializes the actions and its related information.
  45449. * @param parent defines the object to serialize in
  45450. * @returns the serialized object
  45451. */
  45452. serialize(parent: any): any;
  45453. }
  45454. }
  45455. declare module BABYLON {
  45456. /**
  45457. * This defines an action responsible to change the value of a property
  45458. * by interpolating between its current value and the newly set one once triggered.
  45459. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45460. */
  45461. export class InterpolateValueAction extends Action {
  45462. /**
  45463. * Defines the path of the property where the value should be interpolated
  45464. */
  45465. propertyPath: string;
  45466. /**
  45467. * Defines the target value at the end of the interpolation.
  45468. */
  45469. value: any;
  45470. /**
  45471. * Defines the time it will take for the property to interpolate to the value.
  45472. */
  45473. duration: number;
  45474. /**
  45475. * Defines if the other scene animations should be stopped when the action has been triggered
  45476. */
  45477. stopOtherAnimations?: boolean;
  45478. /**
  45479. * Defines a callback raised once the interpolation animation has been done.
  45480. */
  45481. onInterpolationDone?: () => void;
  45482. /**
  45483. * Observable triggered once the interpolation animation has been done.
  45484. */
  45485. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45486. private _target;
  45487. private _effectiveTarget;
  45488. private _property;
  45489. /**
  45490. * Instantiate the action
  45491. * @param triggerOptions defines the trigger options
  45492. * @param target defines the object containing the value to interpolate
  45493. * @param propertyPath defines the path to the property in the target object
  45494. * @param value defines the target value at the end of the interpolation
  45495. * @param duration deines the time it will take for the property to interpolate to the value.
  45496. * @param condition defines the trigger related conditions
  45497. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45498. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45499. */
  45500. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45501. /** @hidden */
  45502. _prepare(): void;
  45503. /**
  45504. * Execute the action starts the value interpolation.
  45505. */
  45506. execute(): void;
  45507. /**
  45508. * Serializes the actions and its related information.
  45509. * @param parent defines the object to serialize in
  45510. * @returns the serialized object
  45511. */
  45512. serialize(parent: any): any;
  45513. }
  45514. }
  45515. declare module BABYLON {
  45516. /**
  45517. * This represents the default audio engine used in babylon.
  45518. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45519. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45520. */
  45521. export class AudioEngine implements IAudioEngine {
  45522. private _audioContext;
  45523. private _audioContextInitialized;
  45524. private _muteButton;
  45525. private _hostElement;
  45526. /**
  45527. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45528. */
  45529. canUseWebAudio: boolean;
  45530. /**
  45531. * The master gain node defines the global audio volume of your audio engine.
  45532. */
  45533. masterGain: GainNode;
  45534. /**
  45535. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45536. * @ignoreNaming
  45537. */
  45538. WarnedWebAudioUnsupported: boolean;
  45539. /**
  45540. * Gets whether or not mp3 are supported by your browser.
  45541. */
  45542. isMP3supported: boolean;
  45543. /**
  45544. * Gets whether or not ogg are supported by your browser.
  45545. */
  45546. isOGGsupported: boolean;
  45547. /**
  45548. * Gets whether audio has been unlocked on the device.
  45549. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45550. * a user interaction has happened.
  45551. */
  45552. unlocked: boolean;
  45553. /**
  45554. * Defines if the audio engine relies on a custom unlocked button.
  45555. * In this case, the embedded button will not be displayed.
  45556. */
  45557. useCustomUnlockedButton: boolean;
  45558. /**
  45559. * Event raised when audio has been unlocked on the browser.
  45560. */
  45561. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45562. /**
  45563. * Event raised when audio has been locked on the browser.
  45564. */
  45565. onAudioLockedObservable: Observable<IAudioEngine>;
  45566. /**
  45567. * Gets the current AudioContext if available.
  45568. */
  45569. get audioContext(): Nullable<AudioContext>;
  45570. private _connectedAnalyser;
  45571. /**
  45572. * Instantiates a new audio engine.
  45573. *
  45574. * There should be only one per page as some browsers restrict the number
  45575. * of audio contexts you can create.
  45576. * @param hostElement defines the host element where to display the mute icon if necessary
  45577. */
  45578. constructor(hostElement?: Nullable<HTMLElement>);
  45579. /**
  45580. * Flags the audio engine in Locked state.
  45581. * This happens due to new browser policies preventing audio to autoplay.
  45582. */
  45583. lock(): void;
  45584. /**
  45585. * Unlocks the audio engine once a user action has been done on the dom.
  45586. * This is helpful to resume play once browser policies have been satisfied.
  45587. */
  45588. unlock(): void;
  45589. private _resumeAudioContext;
  45590. private _initializeAudioContext;
  45591. private _tryToRun;
  45592. private _triggerRunningState;
  45593. private _triggerSuspendedState;
  45594. private _displayMuteButton;
  45595. private _moveButtonToTopLeft;
  45596. private _onResize;
  45597. private _hideMuteButton;
  45598. /**
  45599. * Destroy and release the resources associated with the audio ccontext.
  45600. */
  45601. dispose(): void;
  45602. /**
  45603. * Gets the global volume sets on the master gain.
  45604. * @returns the global volume if set or -1 otherwise
  45605. */
  45606. getGlobalVolume(): number;
  45607. /**
  45608. * Sets the global volume of your experience (sets on the master gain).
  45609. * @param newVolume Defines the new global volume of the application
  45610. */
  45611. setGlobalVolume(newVolume: number): void;
  45612. /**
  45613. * Connect the audio engine to an audio analyser allowing some amazing
  45614. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45615. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45616. * @param analyser The analyser to connect to the engine
  45617. */
  45618. connectToAnalyser(analyser: Analyser): void;
  45619. }
  45620. }
  45621. declare module BABYLON {
  45622. /**
  45623. * Options allowed during the creation of a sound track.
  45624. */
  45625. export interface ISoundTrackOptions {
  45626. /**
  45627. * The volume the sound track should take during creation
  45628. */
  45629. volume?: number;
  45630. /**
  45631. * Define if the sound track is the main sound track of the scene
  45632. */
  45633. mainTrack?: boolean;
  45634. }
  45635. /**
  45636. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45637. * It will be also used in a future release to apply effects on a specific track.
  45638. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45639. */
  45640. export class SoundTrack {
  45641. /**
  45642. * The unique identifier of the sound track in the scene.
  45643. */
  45644. id: number;
  45645. /**
  45646. * The list of sounds included in the sound track.
  45647. */
  45648. soundCollection: Array<Sound>;
  45649. private _outputAudioNode;
  45650. private _scene;
  45651. private _connectedAnalyser;
  45652. private _options;
  45653. private _isInitialized;
  45654. /**
  45655. * Creates a new sound track.
  45656. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45657. * @param scene Define the scene the sound track belongs to
  45658. * @param options
  45659. */
  45660. constructor(scene: Scene, options?: ISoundTrackOptions);
  45661. private _initializeSoundTrackAudioGraph;
  45662. /**
  45663. * Release the sound track and its associated resources
  45664. */
  45665. dispose(): void;
  45666. /**
  45667. * Adds a sound to this sound track
  45668. * @param sound define the cound to add
  45669. * @ignoreNaming
  45670. */
  45671. addSound(sound: Sound): void;
  45672. /**
  45673. * Removes a sound to this sound track
  45674. * @param sound define the cound to remove
  45675. * @ignoreNaming
  45676. */
  45677. removeSound(sound: Sound): void;
  45678. /**
  45679. * Set a global volume for the full sound track.
  45680. * @param newVolume Define the new volume of the sound track
  45681. */
  45682. setVolume(newVolume: number): void;
  45683. /**
  45684. * Switch the panning model to HRTF:
  45685. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45686. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45687. */
  45688. switchPanningModelToHRTF(): void;
  45689. /**
  45690. * Switch the panning model to Equal Power:
  45691. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45692. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45693. */
  45694. switchPanningModelToEqualPower(): void;
  45695. /**
  45696. * Connect the sound track to an audio analyser allowing some amazing
  45697. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45698. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45699. * @param analyser The analyser to connect to the engine
  45700. */
  45701. connectToAnalyser(analyser: Analyser): void;
  45702. }
  45703. }
  45704. declare module BABYLON {
  45705. interface AbstractScene {
  45706. /**
  45707. * The list of sounds used in the scene.
  45708. */
  45709. sounds: Nullable<Array<Sound>>;
  45710. }
  45711. interface Scene {
  45712. /**
  45713. * @hidden
  45714. * Backing field
  45715. */
  45716. _mainSoundTrack: SoundTrack;
  45717. /**
  45718. * The main sound track played by the scene.
  45719. * It cotains your primary collection of sounds.
  45720. */
  45721. mainSoundTrack: SoundTrack;
  45722. /**
  45723. * The list of sound tracks added to the scene
  45724. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45725. */
  45726. soundTracks: Nullable<Array<SoundTrack>>;
  45727. /**
  45728. * Gets a sound using a given name
  45729. * @param name defines the name to search for
  45730. * @return the found sound or null if not found at all.
  45731. */
  45732. getSoundByName(name: string): Nullable<Sound>;
  45733. /**
  45734. * Gets or sets if audio support is enabled
  45735. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45736. */
  45737. audioEnabled: boolean;
  45738. /**
  45739. * Gets or sets if audio will be output to headphones
  45740. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45741. */
  45742. headphone: boolean;
  45743. /**
  45744. * Gets or sets custom audio listener position provider
  45745. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45746. */
  45747. audioListenerPositionProvider: Nullable<() => Vector3>;
  45748. /**
  45749. * Gets or sets a refresh rate when using 3D audio positioning
  45750. */
  45751. audioPositioningRefreshRate: number;
  45752. }
  45753. /**
  45754. * Defines the sound scene component responsible to manage any sounds
  45755. * in a given scene.
  45756. */
  45757. export class AudioSceneComponent implements ISceneSerializableComponent {
  45758. private static _CameraDirectionLH;
  45759. private static _CameraDirectionRH;
  45760. /**
  45761. * The component name helpfull to identify the component in the list of scene components.
  45762. */
  45763. readonly name: string;
  45764. /**
  45765. * The scene the component belongs to.
  45766. */
  45767. scene: Scene;
  45768. private _audioEnabled;
  45769. /**
  45770. * Gets whether audio is enabled or not.
  45771. * Please use related enable/disable method to switch state.
  45772. */
  45773. get audioEnabled(): boolean;
  45774. private _headphone;
  45775. /**
  45776. * Gets whether audio is outputing to headphone or not.
  45777. * Please use the according Switch methods to change output.
  45778. */
  45779. get headphone(): boolean;
  45780. /**
  45781. * Gets or sets a refresh rate when using 3D audio positioning
  45782. */
  45783. audioPositioningRefreshRate: number;
  45784. private _audioListenerPositionProvider;
  45785. /**
  45786. * Gets the current audio listener position provider
  45787. */
  45788. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45789. /**
  45790. * Sets a custom listener position for all sounds in the scene
  45791. * By default, this is the position of the first active camera
  45792. */
  45793. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45794. /**
  45795. * Creates a new instance of the component for the given scene
  45796. * @param scene Defines the scene to register the component in
  45797. */
  45798. constructor(scene: Scene);
  45799. /**
  45800. * Registers the component in a given scene
  45801. */
  45802. register(): void;
  45803. /**
  45804. * Rebuilds the elements related to this component in case of
  45805. * context lost for instance.
  45806. */
  45807. rebuild(): void;
  45808. /**
  45809. * Serializes the component data to the specified json object
  45810. * @param serializationObject The object to serialize to
  45811. */
  45812. serialize(serializationObject: any): void;
  45813. /**
  45814. * Adds all the elements from the container to the scene
  45815. * @param container the container holding the elements
  45816. */
  45817. addFromContainer(container: AbstractScene): void;
  45818. /**
  45819. * Removes all the elements in the container from the scene
  45820. * @param container contains the elements to remove
  45821. * @param dispose if the removed element should be disposed (default: false)
  45822. */
  45823. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45824. /**
  45825. * Disposes the component and the associated ressources.
  45826. */
  45827. dispose(): void;
  45828. /**
  45829. * Disables audio in the associated scene.
  45830. */
  45831. disableAudio(): void;
  45832. /**
  45833. * Enables audio in the associated scene.
  45834. */
  45835. enableAudio(): void;
  45836. /**
  45837. * Switch audio to headphone output.
  45838. */
  45839. switchAudioModeForHeadphones(): void;
  45840. /**
  45841. * Switch audio to normal speakers.
  45842. */
  45843. switchAudioModeForNormalSpeakers(): void;
  45844. private _cachedCameraDirection;
  45845. private _cachedCameraPosition;
  45846. private _lastCheck;
  45847. private _afterRender;
  45848. }
  45849. }
  45850. declare module BABYLON {
  45851. /**
  45852. * Wraps one or more Sound objects and selects one with random weight for playback.
  45853. */
  45854. export class WeightedSound {
  45855. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45856. loop: boolean;
  45857. private _coneInnerAngle;
  45858. private _coneOuterAngle;
  45859. private _volume;
  45860. /** A Sound is currently playing. */
  45861. isPlaying: boolean;
  45862. /** A Sound is currently paused. */
  45863. isPaused: boolean;
  45864. private _sounds;
  45865. private _weights;
  45866. private _currentIndex?;
  45867. /**
  45868. * Creates a new WeightedSound from the list of sounds given.
  45869. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45870. * @param sounds Array of Sounds that will be selected from.
  45871. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45872. */
  45873. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45874. /**
  45875. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45876. */
  45877. get directionalConeInnerAngle(): number;
  45878. /**
  45879. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45880. */
  45881. set directionalConeInnerAngle(value: number);
  45882. /**
  45883. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45884. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45885. */
  45886. get directionalConeOuterAngle(): number;
  45887. /**
  45888. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45889. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45890. */
  45891. set directionalConeOuterAngle(value: number);
  45892. /**
  45893. * Playback volume.
  45894. */
  45895. get volume(): number;
  45896. /**
  45897. * Playback volume.
  45898. */
  45899. set volume(value: number);
  45900. private _onended;
  45901. /**
  45902. * Suspend playback
  45903. */
  45904. pause(): void;
  45905. /**
  45906. * Stop playback
  45907. */
  45908. stop(): void;
  45909. /**
  45910. * Start playback.
  45911. * @param startOffset Position the clip head at a specific time in seconds.
  45912. */
  45913. play(startOffset?: number): void;
  45914. }
  45915. }
  45916. declare module BABYLON {
  45917. /**
  45918. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45919. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45920. */
  45921. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45922. /**
  45923. * Gets the name of the behavior.
  45924. */
  45925. get name(): string;
  45926. /**
  45927. * The easing function used by animations
  45928. */
  45929. static EasingFunction: BackEase;
  45930. /**
  45931. * The easing mode used by animations
  45932. */
  45933. static EasingMode: number;
  45934. /**
  45935. * The duration of the animation, in milliseconds
  45936. */
  45937. transitionDuration: number;
  45938. /**
  45939. * Length of the distance animated by the transition when lower radius is reached
  45940. */
  45941. lowerRadiusTransitionRange: number;
  45942. /**
  45943. * Length of the distance animated by the transition when upper radius is reached
  45944. */
  45945. upperRadiusTransitionRange: number;
  45946. private _autoTransitionRange;
  45947. /**
  45948. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45949. */
  45950. get autoTransitionRange(): boolean;
  45951. /**
  45952. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45953. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45954. */
  45955. set autoTransitionRange(value: boolean);
  45956. private _attachedCamera;
  45957. private _onAfterCheckInputsObserver;
  45958. private _onMeshTargetChangedObserver;
  45959. /**
  45960. * Initializes the behavior.
  45961. */
  45962. init(): void;
  45963. /**
  45964. * Attaches the behavior to its arc rotate camera.
  45965. * @param camera Defines the camera to attach the behavior to
  45966. */
  45967. attach(camera: ArcRotateCamera): void;
  45968. /**
  45969. * Detaches the behavior from its current arc rotate camera.
  45970. */
  45971. detach(): void;
  45972. private _radiusIsAnimating;
  45973. private _radiusBounceTransition;
  45974. private _animatables;
  45975. private _cachedWheelPrecision;
  45976. /**
  45977. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45978. * @param radiusLimit The limit to check against.
  45979. * @return Bool to indicate if at limit.
  45980. */
  45981. private _isRadiusAtLimit;
  45982. /**
  45983. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45984. * @param radiusDelta The delta by which to animate to. Can be negative.
  45985. */
  45986. private _applyBoundRadiusAnimation;
  45987. /**
  45988. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45989. */
  45990. protected _clearAnimationLocks(): void;
  45991. /**
  45992. * Stops and removes all animations that have been applied to the camera
  45993. */
  45994. stopAllAnimations(): void;
  45995. }
  45996. }
  45997. declare module BABYLON {
  45998. /**
  45999. * 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.
  46000. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46001. */
  46002. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  46003. /**
  46004. * Gets the name of the behavior.
  46005. */
  46006. get name(): string;
  46007. private _mode;
  46008. private _radiusScale;
  46009. private _positionScale;
  46010. private _defaultElevation;
  46011. private _elevationReturnTime;
  46012. private _elevationReturnWaitTime;
  46013. private _zoomStopsAnimation;
  46014. private _framingTime;
  46015. /**
  46016. * The easing function used by animations
  46017. */
  46018. static EasingFunction: ExponentialEase;
  46019. /**
  46020. * The easing mode used by animations
  46021. */
  46022. static EasingMode: number;
  46023. /**
  46024. * Sets the current mode used by the behavior
  46025. */
  46026. set mode(mode: number);
  46027. /**
  46028. * Gets current mode used by the behavior.
  46029. */
  46030. get mode(): number;
  46031. /**
  46032. * Sets the scale applied to the radius (1 by default)
  46033. */
  46034. set radiusScale(radius: number);
  46035. /**
  46036. * Gets the scale applied to the radius
  46037. */
  46038. get radiusScale(): number;
  46039. /**
  46040. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46041. */
  46042. set positionScale(scale: number);
  46043. /**
  46044. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46045. */
  46046. get positionScale(): number;
  46047. /**
  46048. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46049. * behaviour is triggered, in radians.
  46050. */
  46051. set defaultElevation(elevation: number);
  46052. /**
  46053. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46054. * behaviour is triggered, in radians.
  46055. */
  46056. get defaultElevation(): number;
  46057. /**
  46058. * Sets the time (in milliseconds) taken to return to the default beta position.
  46059. * Negative value indicates camera should not return to default.
  46060. */
  46061. set elevationReturnTime(speed: number);
  46062. /**
  46063. * Gets the time (in milliseconds) taken to return to the default beta position.
  46064. * Negative value indicates camera should not return to default.
  46065. */
  46066. get elevationReturnTime(): number;
  46067. /**
  46068. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46069. */
  46070. set elevationReturnWaitTime(time: number);
  46071. /**
  46072. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46073. */
  46074. get elevationReturnWaitTime(): number;
  46075. /**
  46076. * Sets the flag that indicates if user zooming should stop animation.
  46077. */
  46078. set zoomStopsAnimation(flag: boolean);
  46079. /**
  46080. * Gets the flag that indicates if user zooming should stop animation.
  46081. */
  46082. get zoomStopsAnimation(): boolean;
  46083. /**
  46084. * Sets the transition time when framing the mesh, in milliseconds
  46085. */
  46086. set framingTime(time: number);
  46087. /**
  46088. * Gets the transition time when framing the mesh, in milliseconds
  46089. */
  46090. get framingTime(): number;
  46091. /**
  46092. * Define if the behavior should automatically change the configured
  46093. * camera limits and sensibilities.
  46094. */
  46095. autoCorrectCameraLimitsAndSensibility: boolean;
  46096. private _onPrePointerObservableObserver;
  46097. private _onAfterCheckInputsObserver;
  46098. private _onMeshTargetChangedObserver;
  46099. private _attachedCamera;
  46100. private _isPointerDown;
  46101. private _lastInteractionTime;
  46102. /**
  46103. * Initializes the behavior.
  46104. */
  46105. init(): void;
  46106. /**
  46107. * Attaches the behavior to its arc rotate camera.
  46108. * @param camera Defines the camera to attach the behavior to
  46109. */
  46110. attach(camera: ArcRotateCamera): void;
  46111. /**
  46112. * Detaches the behavior from its current arc rotate camera.
  46113. */
  46114. detach(): void;
  46115. private _animatables;
  46116. private _betaIsAnimating;
  46117. private _betaTransition;
  46118. private _radiusTransition;
  46119. private _vectorTransition;
  46120. /**
  46121. * Targets the given mesh and updates zoom level accordingly.
  46122. * @param mesh The mesh to target.
  46123. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46124. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46125. */
  46126. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46127. /**
  46128. * Targets the given mesh with its children and updates zoom level accordingly.
  46129. * @param mesh The mesh to target.
  46130. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46131. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46132. */
  46133. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46134. /**
  46135. * Targets the given meshes with their children and updates zoom level accordingly.
  46136. * @param meshes The mesh to target.
  46137. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46138. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46139. */
  46140. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46141. /**
  46142. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  46143. * @param minimumWorld Determines the smaller position of the bounding box extend
  46144. * @param maximumWorld Determines the bigger position of the bounding box extend
  46145. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46146. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46147. */
  46148. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46149. /**
  46150. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  46151. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  46152. * frustum width.
  46153. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  46154. * to fully enclose the mesh in the viewing frustum.
  46155. */
  46156. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  46157. /**
  46158. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  46159. * is automatically returned to its default position (expected to be above ground plane).
  46160. */
  46161. private _maintainCameraAboveGround;
  46162. /**
  46163. * Returns the frustum slope based on the canvas ratio and camera FOV
  46164. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  46165. */
  46166. private _getFrustumSlope;
  46167. /**
  46168. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  46169. */
  46170. private _clearAnimationLocks;
  46171. /**
  46172. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46173. */
  46174. private _applyUserInteraction;
  46175. /**
  46176. * Stops and removes all animations that have been applied to the camera
  46177. */
  46178. stopAllAnimations(): void;
  46179. /**
  46180. * Gets a value indicating if the user is moving the camera
  46181. */
  46182. get isUserIsMoving(): boolean;
  46183. /**
  46184. * The camera can move all the way towards the mesh.
  46185. */
  46186. static IgnoreBoundsSizeMode: number;
  46187. /**
  46188. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  46189. */
  46190. static FitFrustumSidesMode: number;
  46191. }
  46192. }
  46193. declare module BABYLON {
  46194. /**
  46195. * Base class for Camera Pointer Inputs.
  46196. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  46197. * for example usage.
  46198. */
  46199. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  46200. /**
  46201. * Defines the camera the input is attached to.
  46202. */
  46203. abstract camera: Camera;
  46204. /**
  46205. * Whether keyboard modifier keys are pressed at time of last mouse event.
  46206. */
  46207. protected _altKey: boolean;
  46208. protected _ctrlKey: boolean;
  46209. protected _metaKey: boolean;
  46210. protected _shiftKey: boolean;
  46211. /**
  46212. * Which mouse buttons were pressed at time of last mouse event.
  46213. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  46214. */
  46215. protected _buttonsPressed: number;
  46216. /**
  46217. * Defines the buttons associated with the input to handle camera move.
  46218. */
  46219. buttons: number[];
  46220. /**
  46221. * Attach the input controls to a specific dom element to get the input from.
  46222. * @param element Defines the element the controls should be listened from
  46223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46224. */
  46225. attachControl(noPreventDefault?: boolean): void;
  46226. /**
  46227. * Detach the current controls from the specified dom element.
  46228. */
  46229. detachControl(): void;
  46230. /**
  46231. * Gets the class name of the current input.
  46232. * @returns the class name
  46233. */
  46234. getClassName(): string;
  46235. /**
  46236. * Get the friendly name associated with the input class.
  46237. * @returns the input friendly name
  46238. */
  46239. getSimpleName(): string;
  46240. /**
  46241. * Called on pointer POINTERDOUBLETAP event.
  46242. * Override this method to provide functionality on POINTERDOUBLETAP event.
  46243. */
  46244. protected onDoubleTap(type: string): void;
  46245. /**
  46246. * Called on pointer POINTERMOVE event if only a single touch is active.
  46247. * Override this method to provide functionality.
  46248. */
  46249. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46250. /**
  46251. * Called on pointer POINTERMOVE event if multiple touches are active.
  46252. * Override this method to provide functionality.
  46253. */
  46254. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46255. /**
  46256. * Called on JS contextmenu event.
  46257. * Override this method to provide functionality.
  46258. */
  46259. protected onContextMenu(evt: PointerEvent): void;
  46260. /**
  46261. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46262. * press.
  46263. * Override this method to provide functionality.
  46264. */
  46265. protected onButtonDown(evt: PointerEvent): void;
  46266. /**
  46267. * Called each time a new POINTERUP event occurs. Ie, for each button
  46268. * release.
  46269. * Override this method to provide functionality.
  46270. */
  46271. protected onButtonUp(evt: PointerEvent): void;
  46272. /**
  46273. * Called when window becomes inactive.
  46274. * Override this method to provide functionality.
  46275. */
  46276. protected onLostFocus(): void;
  46277. private _pointerInput;
  46278. private _observer;
  46279. private _onLostFocus;
  46280. private pointA;
  46281. private pointB;
  46282. }
  46283. }
  46284. declare module BABYLON {
  46285. /**
  46286. * Manage the pointers inputs to control an arc rotate camera.
  46287. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46288. */
  46289. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  46290. /**
  46291. * Defines the camera the input is attached to.
  46292. */
  46293. camera: ArcRotateCamera;
  46294. /**
  46295. * Gets the class name of the current input.
  46296. * @returns the class name
  46297. */
  46298. getClassName(): string;
  46299. /**
  46300. * Defines the buttons associated with the input to handle camera move.
  46301. */
  46302. buttons: number[];
  46303. /**
  46304. * Defines the pointer angular sensibility along the X axis or how fast is
  46305. * the camera rotating.
  46306. */
  46307. angularSensibilityX: number;
  46308. /**
  46309. * Defines the pointer angular sensibility along the Y axis or how fast is
  46310. * the camera rotating.
  46311. */
  46312. angularSensibilityY: number;
  46313. /**
  46314. * Defines the pointer pinch precision or how fast is the camera zooming.
  46315. */
  46316. pinchPrecision: number;
  46317. /**
  46318. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46319. * from 0.
  46320. * It defines the percentage of current camera.radius to use as delta when
  46321. * pinch zoom is used.
  46322. */
  46323. pinchDeltaPercentage: number;
  46324. /**
  46325. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46326. * that any object in the plane at the camera's target point will scale
  46327. * perfectly with finger motion.
  46328. * Overrides pinchDeltaPercentage and pinchPrecision.
  46329. */
  46330. useNaturalPinchZoom: boolean;
  46331. /**
  46332. * Defines the pointer panning sensibility or how fast is the camera moving.
  46333. */
  46334. panningSensibility: number;
  46335. /**
  46336. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46337. */
  46338. multiTouchPanning: boolean;
  46339. /**
  46340. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46341. * zoom (pinch) through multitouch.
  46342. */
  46343. multiTouchPanAndZoom: boolean;
  46344. /**
  46345. * Revers pinch action direction.
  46346. */
  46347. pinchInwards: boolean;
  46348. private _isPanClick;
  46349. private _twoFingerActivityCount;
  46350. private _isPinching;
  46351. /**
  46352. * Called on pointer POINTERMOVE event if only a single touch is active.
  46353. */
  46354. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46355. /**
  46356. * Called on pointer POINTERDOUBLETAP event.
  46357. */
  46358. protected onDoubleTap(type: string): void;
  46359. /**
  46360. * Called on pointer POINTERMOVE event if multiple touches are active.
  46361. */
  46362. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46363. /**
  46364. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46365. * press.
  46366. */
  46367. protected onButtonDown(evt: PointerEvent): void;
  46368. /**
  46369. * Called each time a new POINTERUP event occurs. Ie, for each button
  46370. * release.
  46371. */
  46372. protected onButtonUp(evt: PointerEvent): void;
  46373. /**
  46374. * Called when window becomes inactive.
  46375. */
  46376. protected onLostFocus(): void;
  46377. }
  46378. }
  46379. declare module BABYLON {
  46380. /**
  46381. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46382. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46383. */
  46384. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46385. /**
  46386. * Defines the camera the input is attached to.
  46387. */
  46388. camera: ArcRotateCamera;
  46389. /**
  46390. * Defines the list of key codes associated with the up action (increase alpha)
  46391. */
  46392. keysUp: number[];
  46393. /**
  46394. * Defines the list of key codes associated with the down action (decrease alpha)
  46395. */
  46396. keysDown: number[];
  46397. /**
  46398. * Defines the list of key codes associated with the left action (increase beta)
  46399. */
  46400. keysLeft: number[];
  46401. /**
  46402. * Defines the list of key codes associated with the right action (decrease beta)
  46403. */
  46404. keysRight: number[];
  46405. /**
  46406. * Defines the list of key codes associated with the reset action.
  46407. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46408. */
  46409. keysReset: number[];
  46410. /**
  46411. * Defines the panning sensibility of the inputs.
  46412. * (How fast is the camera panning)
  46413. */
  46414. panningSensibility: number;
  46415. /**
  46416. * Defines the zooming sensibility of the inputs.
  46417. * (How fast is the camera zooming)
  46418. */
  46419. zoomingSensibility: number;
  46420. /**
  46421. * Defines whether maintaining the alt key down switch the movement mode from
  46422. * orientation to zoom.
  46423. */
  46424. useAltToZoom: boolean;
  46425. /**
  46426. * Rotation speed of the camera
  46427. */
  46428. angularSpeed: number;
  46429. private _keys;
  46430. private _ctrlPressed;
  46431. private _altPressed;
  46432. private _onCanvasBlurObserver;
  46433. private _onKeyboardObserver;
  46434. private _engine;
  46435. private _scene;
  46436. /**
  46437. * Attach the input controls to a specific dom element to get the input from.
  46438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46439. */
  46440. attachControl(noPreventDefault?: boolean): void;
  46441. /**
  46442. * Detach the current controls from the specified dom element.
  46443. */
  46444. detachControl(): void;
  46445. /**
  46446. * Update the current camera state depending on the inputs that have been used this frame.
  46447. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46448. */
  46449. checkInputs(): void;
  46450. /**
  46451. * Gets the class name of the current intput.
  46452. * @returns the class name
  46453. */
  46454. getClassName(): string;
  46455. /**
  46456. * Get the friendly name associated with the input class.
  46457. * @returns the input friendly name
  46458. */
  46459. getSimpleName(): string;
  46460. }
  46461. }
  46462. declare module BABYLON {
  46463. /**
  46464. * Manage the mouse wheel inputs to control an arc rotate camera.
  46465. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46466. */
  46467. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46468. /**
  46469. * Defines the camera the input is attached to.
  46470. */
  46471. camera: ArcRotateCamera;
  46472. /**
  46473. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46474. */
  46475. wheelPrecision: number;
  46476. /**
  46477. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46478. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46479. */
  46480. wheelDeltaPercentage: number;
  46481. private _wheel;
  46482. private _observer;
  46483. private computeDeltaFromMouseWheelLegacyEvent;
  46484. /**
  46485. * Attach the input controls to a specific dom element to get the input from.
  46486. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46487. */
  46488. attachControl(noPreventDefault?: boolean): void;
  46489. /**
  46490. * Detach the current controls from the specified dom element.
  46491. */
  46492. detachControl(): void;
  46493. /**
  46494. * Gets the class name of the current intput.
  46495. * @returns the class name
  46496. */
  46497. getClassName(): string;
  46498. /**
  46499. * Get the friendly name associated with the input class.
  46500. * @returns the input friendly name
  46501. */
  46502. getSimpleName(): string;
  46503. }
  46504. }
  46505. declare module BABYLON {
  46506. /**
  46507. * Default Inputs manager for the ArcRotateCamera.
  46508. * It groups all the default supported inputs for ease of use.
  46509. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46510. */
  46511. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46512. /**
  46513. * Instantiates a new ArcRotateCameraInputsManager.
  46514. * @param camera Defines the camera the inputs belong to
  46515. */
  46516. constructor(camera: ArcRotateCamera);
  46517. /**
  46518. * Add mouse wheel input support to the input manager.
  46519. * @returns the current input manager
  46520. */
  46521. addMouseWheel(): ArcRotateCameraInputsManager;
  46522. /**
  46523. * Add pointers input support to the input manager.
  46524. * @returns the current input manager
  46525. */
  46526. addPointers(): ArcRotateCameraInputsManager;
  46527. /**
  46528. * Add keyboard input support to the input manager.
  46529. * @returns the current input manager
  46530. */
  46531. addKeyboard(): ArcRotateCameraInputsManager;
  46532. }
  46533. }
  46534. declare module BABYLON {
  46535. /**
  46536. * This represents an orbital type of camera.
  46537. *
  46538. * 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.
  46539. * 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.
  46540. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46541. */
  46542. export class ArcRotateCamera extends TargetCamera {
  46543. /**
  46544. * Defines the rotation angle of the camera along the longitudinal axis.
  46545. */
  46546. alpha: number;
  46547. /**
  46548. * Defines the rotation angle of the camera along the latitudinal axis.
  46549. */
  46550. beta: number;
  46551. /**
  46552. * Defines the radius of the camera from it s target point.
  46553. */
  46554. radius: number;
  46555. protected _target: Vector3;
  46556. protected _targetHost: Nullable<AbstractMesh>;
  46557. /**
  46558. * Defines the target point of the camera.
  46559. * The camera looks towards it form the radius distance.
  46560. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46561. */
  46562. get target(): Vector3;
  46563. set target(value: Vector3);
  46564. /**
  46565. * Define the current local position of the camera in the scene
  46566. */
  46567. get position(): Vector3;
  46568. set position(newPosition: Vector3);
  46569. protected _upToYMatrix: Matrix;
  46570. protected _YToUpMatrix: Matrix;
  46571. /**
  46572. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46573. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46574. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46575. */
  46576. set upVector(vec: Vector3);
  46577. get upVector(): Vector3;
  46578. /**
  46579. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46580. */
  46581. setMatUp(): void;
  46582. /**
  46583. * Current inertia value on the longitudinal axis.
  46584. * The bigger this number the longer it will take for the camera to stop.
  46585. */
  46586. inertialAlphaOffset: number;
  46587. /**
  46588. * Current inertia value on the latitudinal axis.
  46589. * The bigger this number the longer it will take for the camera to stop.
  46590. */
  46591. inertialBetaOffset: number;
  46592. /**
  46593. * Current inertia value on the radius axis.
  46594. * The bigger this number the longer it will take for the camera to stop.
  46595. */
  46596. inertialRadiusOffset: number;
  46597. /**
  46598. * Minimum allowed angle on the longitudinal axis.
  46599. * This can help limiting how the Camera is able to move in the scene.
  46600. */
  46601. lowerAlphaLimit: Nullable<number>;
  46602. /**
  46603. * Maximum allowed angle on the longitudinal axis.
  46604. * This can help limiting how the Camera is able to move in the scene.
  46605. */
  46606. upperAlphaLimit: Nullable<number>;
  46607. /**
  46608. * Minimum allowed angle on the latitudinal axis.
  46609. * This can help limiting how the Camera is able to move in the scene.
  46610. */
  46611. lowerBetaLimit: number;
  46612. /**
  46613. * Maximum allowed angle on the latitudinal axis.
  46614. * This can help limiting how the Camera is able to move in the scene.
  46615. */
  46616. upperBetaLimit: number;
  46617. /**
  46618. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46619. * This can help limiting how the Camera is able to move in the scene.
  46620. */
  46621. lowerRadiusLimit: Nullable<number>;
  46622. /**
  46623. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46624. * This can help limiting how the Camera is able to move in the scene.
  46625. */
  46626. upperRadiusLimit: Nullable<number>;
  46627. /**
  46628. * Defines the current inertia value used during panning of the camera along the X axis.
  46629. */
  46630. inertialPanningX: number;
  46631. /**
  46632. * Defines the current inertia value used during panning of the camera along the Y axis.
  46633. */
  46634. inertialPanningY: number;
  46635. /**
  46636. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46637. * Basically if your fingers moves away from more than this distance you will be considered
  46638. * in pinch mode.
  46639. */
  46640. pinchToPanMaxDistance: number;
  46641. /**
  46642. * Defines the maximum distance the camera can pan.
  46643. * This could help keeping the cammera always in your scene.
  46644. */
  46645. panningDistanceLimit: Nullable<number>;
  46646. /**
  46647. * Defines the target of the camera before paning.
  46648. */
  46649. panningOriginTarget: Vector3;
  46650. /**
  46651. * Defines the value of the inertia used during panning.
  46652. * 0 would mean stop inertia and one would mean no decelleration at all.
  46653. */
  46654. panningInertia: number;
  46655. /**
  46656. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46657. */
  46658. get angularSensibilityX(): number;
  46659. set angularSensibilityX(value: number);
  46660. /**
  46661. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46662. */
  46663. get angularSensibilityY(): number;
  46664. set angularSensibilityY(value: number);
  46665. /**
  46666. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46667. */
  46668. get pinchPrecision(): number;
  46669. set pinchPrecision(value: number);
  46670. /**
  46671. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46672. * It will be used instead of pinchDeltaPrecision if different from 0.
  46673. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46674. */
  46675. get pinchDeltaPercentage(): number;
  46676. set pinchDeltaPercentage(value: number);
  46677. /**
  46678. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46679. * and pinch delta percentage.
  46680. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46681. * that any object in the plane at the camera's target point will scale
  46682. * perfectly with finger motion.
  46683. */
  46684. get useNaturalPinchZoom(): boolean;
  46685. set useNaturalPinchZoom(value: boolean);
  46686. /**
  46687. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46688. */
  46689. get panningSensibility(): number;
  46690. set panningSensibility(value: number);
  46691. /**
  46692. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46693. */
  46694. get keysUp(): number[];
  46695. set keysUp(value: number[]);
  46696. /**
  46697. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46698. */
  46699. get keysDown(): number[];
  46700. set keysDown(value: number[]);
  46701. /**
  46702. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46703. */
  46704. get keysLeft(): number[];
  46705. set keysLeft(value: number[]);
  46706. /**
  46707. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46708. */
  46709. get keysRight(): number[];
  46710. set keysRight(value: number[]);
  46711. /**
  46712. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46713. */
  46714. get wheelPrecision(): number;
  46715. set wheelPrecision(value: number);
  46716. /**
  46717. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46718. * It will be used instead of pinchDeltaPrecision if different from 0.
  46719. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46720. */
  46721. get wheelDeltaPercentage(): number;
  46722. set wheelDeltaPercentage(value: number);
  46723. /**
  46724. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46725. */
  46726. zoomOnFactor: number;
  46727. /**
  46728. * Defines a screen offset for the camera position.
  46729. */
  46730. targetScreenOffset: Vector2;
  46731. /**
  46732. * Allows the camera to be completely reversed.
  46733. * If false the camera can not arrive upside down.
  46734. */
  46735. allowUpsideDown: boolean;
  46736. /**
  46737. * Define if double tap/click is used to restore the previously saved state of the camera.
  46738. */
  46739. useInputToRestoreState: boolean;
  46740. /** @hidden */
  46741. _viewMatrix: Matrix;
  46742. /** @hidden */
  46743. _useCtrlForPanning: boolean;
  46744. /** @hidden */
  46745. _panningMouseButton: number;
  46746. /**
  46747. * Defines the input associated to the camera.
  46748. */
  46749. inputs: ArcRotateCameraInputsManager;
  46750. /** @hidden */
  46751. _reset: () => void;
  46752. /**
  46753. * Defines the allowed panning axis.
  46754. */
  46755. panningAxis: Vector3;
  46756. protected _localDirection: Vector3;
  46757. protected _transformedDirection: Vector3;
  46758. private _bouncingBehavior;
  46759. /**
  46760. * Gets the bouncing behavior of the camera if it has been enabled.
  46761. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46762. */
  46763. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46764. /**
  46765. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46766. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46767. */
  46768. get useBouncingBehavior(): boolean;
  46769. set useBouncingBehavior(value: boolean);
  46770. private _framingBehavior;
  46771. /**
  46772. * Gets the framing behavior of the camera if it has been enabled.
  46773. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46774. */
  46775. get framingBehavior(): Nullable<FramingBehavior>;
  46776. /**
  46777. * Defines if the framing behavior of the camera is enabled on the camera.
  46778. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46779. */
  46780. get useFramingBehavior(): boolean;
  46781. set useFramingBehavior(value: boolean);
  46782. private _autoRotationBehavior;
  46783. /**
  46784. * Gets the auto rotation behavior of the camera if it has been enabled.
  46785. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46786. */
  46787. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46788. /**
  46789. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46790. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46791. */
  46792. get useAutoRotationBehavior(): boolean;
  46793. set useAutoRotationBehavior(value: boolean);
  46794. /**
  46795. * Observable triggered when the mesh target has been changed on the camera.
  46796. */
  46797. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46798. /**
  46799. * Event raised when the camera is colliding with a mesh.
  46800. */
  46801. onCollide: (collidedMesh: AbstractMesh) => void;
  46802. /**
  46803. * Defines whether the camera should check collision with the objects oh the scene.
  46804. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46805. */
  46806. checkCollisions: boolean;
  46807. /**
  46808. * Defines the collision radius of the camera.
  46809. * This simulates a sphere around the camera.
  46810. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46811. */
  46812. collisionRadius: Vector3;
  46813. protected _collider: Collider;
  46814. protected _previousPosition: Vector3;
  46815. protected _collisionVelocity: Vector3;
  46816. protected _newPosition: Vector3;
  46817. protected _previousAlpha: number;
  46818. protected _previousBeta: number;
  46819. protected _previousRadius: number;
  46820. protected _collisionTriggered: boolean;
  46821. protected _targetBoundingCenter: Nullable<Vector3>;
  46822. private _computationVector;
  46823. /**
  46824. * Instantiates a new ArcRotateCamera in a given scene
  46825. * @param name Defines the name of the camera
  46826. * @param alpha Defines the camera rotation along the logitudinal axis
  46827. * @param beta Defines the camera rotation along the latitudinal axis
  46828. * @param radius Defines the camera distance from its target
  46829. * @param target Defines the camera target
  46830. * @param scene Defines the scene the camera belongs to
  46831. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46832. */
  46833. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46834. /** @hidden */
  46835. _initCache(): void;
  46836. /** @hidden */
  46837. _updateCache(ignoreParentClass?: boolean): void;
  46838. protected _getTargetPosition(): Vector3;
  46839. private _storedAlpha;
  46840. private _storedBeta;
  46841. private _storedRadius;
  46842. private _storedTarget;
  46843. private _storedTargetScreenOffset;
  46844. /**
  46845. * Stores the current state of the camera (alpha, beta, radius and target)
  46846. * @returns the camera itself
  46847. */
  46848. storeState(): Camera;
  46849. /**
  46850. * @hidden
  46851. * Restored camera state. You must call storeState() first
  46852. */
  46853. _restoreStateValues(): boolean;
  46854. /** @hidden */
  46855. _isSynchronizedViewMatrix(): boolean;
  46856. /**
  46857. * Attach the input controls to a specific dom element to get the input from.
  46858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46859. */
  46860. attachControl(noPreventDefault?: boolean): void;
  46861. /**
  46862. * Attach the input controls to a specific dom element to get the input from.
  46863. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46865. */
  46866. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46867. /**
  46868. * Attached controls to the current camera.
  46869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46870. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46871. */
  46872. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46873. /**
  46874. * Attached controls to the current camera.
  46875. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46877. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46878. */
  46879. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46880. /**
  46881. * Attached controls to the current camera.
  46882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46883. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46884. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46885. */
  46886. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46887. /**
  46888. * Detach the current controls from the specified dom element.
  46889. */
  46890. detachControl(): void;
  46891. /**
  46892. * Detach the current controls from the specified dom element.
  46893. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46894. */
  46895. detachControl(ignored: any): void;
  46896. /** @hidden */
  46897. _checkInputs(): void;
  46898. protected _checkLimits(): void;
  46899. /**
  46900. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46901. */
  46902. rebuildAnglesAndRadius(): void;
  46903. /**
  46904. * Use a position to define the current camera related information like alpha, beta and radius
  46905. * @param position Defines the position to set the camera at
  46906. */
  46907. setPosition(position: Vector3): void;
  46908. /**
  46909. * Defines the target the camera should look at.
  46910. * This will automatically adapt alpha beta and radius to fit within the new target.
  46911. * @param target Defines the new target as a Vector or a mesh
  46912. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46913. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46914. */
  46915. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46916. /** @hidden */
  46917. _getViewMatrix(): Matrix;
  46918. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46919. /**
  46920. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46921. * @param meshes Defines the mesh to zoom on
  46922. * @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)
  46923. */
  46924. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46925. /**
  46926. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46927. * The target will be changed but the radius
  46928. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46929. * @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)
  46930. */
  46931. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46932. min: Vector3;
  46933. max: Vector3;
  46934. distance: number;
  46935. }, doNotUpdateMaxZ?: boolean): void;
  46936. /**
  46937. * @override
  46938. * Override Camera.createRigCamera
  46939. */
  46940. createRigCamera(name: string, cameraIndex: number): Camera;
  46941. /**
  46942. * @hidden
  46943. * @override
  46944. * Override Camera._updateRigCameras
  46945. */
  46946. _updateRigCameras(): void;
  46947. /**
  46948. * Destroy the camera and release the current resources hold by it.
  46949. */
  46950. dispose(): void;
  46951. /**
  46952. * Gets the current object class name.
  46953. * @return the class name
  46954. */
  46955. getClassName(): string;
  46956. }
  46957. }
  46958. declare module BABYLON {
  46959. /**
  46960. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46961. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46962. */
  46963. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46964. /**
  46965. * Gets the name of the behavior.
  46966. */
  46967. get name(): string;
  46968. private _zoomStopsAnimation;
  46969. private _idleRotationSpeed;
  46970. private _idleRotationWaitTime;
  46971. private _idleRotationSpinupTime;
  46972. /**
  46973. * Sets the flag that indicates if user zooming should stop animation.
  46974. */
  46975. set zoomStopsAnimation(flag: boolean);
  46976. /**
  46977. * Gets the flag that indicates if user zooming should stop animation.
  46978. */
  46979. get zoomStopsAnimation(): boolean;
  46980. /**
  46981. * Sets the default speed at which the camera rotates around the model.
  46982. */
  46983. set idleRotationSpeed(speed: number);
  46984. /**
  46985. * Gets the default speed at which the camera rotates around the model.
  46986. */
  46987. get idleRotationSpeed(): number;
  46988. /**
  46989. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46990. */
  46991. set idleRotationWaitTime(time: number);
  46992. /**
  46993. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46994. */
  46995. get idleRotationWaitTime(): number;
  46996. /**
  46997. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46998. */
  46999. set idleRotationSpinupTime(time: number);
  47000. /**
  47001. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  47002. */
  47003. get idleRotationSpinupTime(): number;
  47004. /**
  47005. * Gets a value indicating if the camera is currently rotating because of this behavior
  47006. */
  47007. get rotationInProgress(): boolean;
  47008. private _onPrePointerObservableObserver;
  47009. private _onAfterCheckInputsObserver;
  47010. private _attachedCamera;
  47011. private _isPointerDown;
  47012. private _lastFrameTime;
  47013. private _lastInteractionTime;
  47014. private _cameraRotationSpeed;
  47015. /**
  47016. * Initializes the behavior.
  47017. */
  47018. init(): void;
  47019. /**
  47020. * Attaches the behavior to its arc rotate camera.
  47021. * @param camera Defines the camera to attach the behavior to
  47022. */
  47023. attach(camera: ArcRotateCamera): void;
  47024. /**
  47025. * Detaches the behavior from its current arc rotate camera.
  47026. */
  47027. detach(): void;
  47028. /**
  47029. * Returns true if user is scrolling.
  47030. * @return true if user is scrolling.
  47031. */
  47032. private _userIsZooming;
  47033. private _lastFrameRadius;
  47034. private _shouldAnimationStopForInteraction;
  47035. /**
  47036. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47037. */
  47038. private _applyUserInteraction;
  47039. private _userIsMoving;
  47040. }
  47041. }
  47042. declare module BABYLON {
  47043. /**
  47044. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  47045. */
  47046. export class AttachToBoxBehavior implements Behavior<Mesh> {
  47047. private ui;
  47048. /**
  47049. * The name of the behavior
  47050. */
  47051. name: string;
  47052. /**
  47053. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  47054. */
  47055. distanceAwayFromFace: number;
  47056. /**
  47057. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  47058. */
  47059. distanceAwayFromBottomOfFace: number;
  47060. private _faceVectors;
  47061. private _target;
  47062. private _scene;
  47063. private _onRenderObserver;
  47064. private _tmpMatrix;
  47065. private _tmpVector;
  47066. /**
  47067. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  47068. * @param ui The transform node that should be attched to the mesh
  47069. */
  47070. constructor(ui: TransformNode);
  47071. /**
  47072. * Initializes the behavior
  47073. */
  47074. init(): void;
  47075. private _closestFace;
  47076. private _zeroVector;
  47077. private _lookAtTmpMatrix;
  47078. private _lookAtToRef;
  47079. /**
  47080. * Attaches the AttachToBoxBehavior to the passed in mesh
  47081. * @param target The mesh that the specified node will be attached to
  47082. */
  47083. attach(target: Mesh): void;
  47084. /**
  47085. * Detaches the behavior from the mesh
  47086. */
  47087. detach(): void;
  47088. }
  47089. }
  47090. declare module BABYLON {
  47091. /**
  47092. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  47093. */
  47094. export class FadeInOutBehavior implements Behavior<Mesh> {
  47095. /**
  47096. * Time in milliseconds to delay before fading in (Default: 0)
  47097. */
  47098. delay: number;
  47099. /**
  47100. * Time in milliseconds for the mesh to fade in (Default: 300)
  47101. */
  47102. fadeInTime: number;
  47103. private _millisecondsPerFrame;
  47104. private _hovered;
  47105. private _hoverValue;
  47106. private _ownerNode;
  47107. /**
  47108. * Instatiates the FadeInOutBehavior
  47109. */
  47110. constructor();
  47111. /**
  47112. * The name of the behavior
  47113. */
  47114. get name(): string;
  47115. /**
  47116. * Initializes the behavior
  47117. */
  47118. init(): void;
  47119. /**
  47120. * Attaches the fade behavior on the passed in mesh
  47121. * @param ownerNode The mesh that will be faded in/out once attached
  47122. */
  47123. attach(ownerNode: Mesh): void;
  47124. /**
  47125. * Detaches the behavior from the mesh
  47126. */
  47127. detach(): void;
  47128. /**
  47129. * Triggers the mesh to begin fading in or out
  47130. * @param value if the object should fade in or out (true to fade in)
  47131. */
  47132. fadeIn(value: boolean): void;
  47133. private _update;
  47134. private _setAllVisibility;
  47135. }
  47136. }
  47137. declare module BABYLON {
  47138. /**
  47139. * Class containing a set of static utilities functions for managing Pivots
  47140. * @hidden
  47141. */
  47142. export class PivotTools {
  47143. private static _PivotCached;
  47144. private static _OldPivotPoint;
  47145. private static _PivotTranslation;
  47146. private static _PivotTmpVector;
  47147. private static _PivotPostMultiplyPivotMatrix;
  47148. /** @hidden */
  47149. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  47150. /** @hidden */
  47151. static _RestorePivotPoint(mesh: AbstractMesh): void;
  47152. }
  47153. }
  47154. declare module BABYLON {
  47155. /**
  47156. * Class containing static functions to help procedurally build meshes
  47157. */
  47158. export class PlaneBuilder {
  47159. /**
  47160. * Creates a plane mesh
  47161. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  47162. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  47163. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  47164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47165. * * 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
  47166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47167. * @param name defines the name of the mesh
  47168. * @param options defines the options used to create the mesh
  47169. * @param scene defines the hosting scene
  47170. * @returns the plane mesh
  47171. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  47172. */
  47173. static CreatePlane(name: string, options: {
  47174. size?: number;
  47175. width?: number;
  47176. height?: number;
  47177. sideOrientation?: number;
  47178. frontUVs?: Vector4;
  47179. backUVs?: Vector4;
  47180. updatable?: boolean;
  47181. sourcePlane?: Plane;
  47182. }, scene?: Nullable<Scene>): Mesh;
  47183. }
  47184. }
  47185. declare module BABYLON {
  47186. /**
  47187. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  47188. */
  47189. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  47190. private static _AnyMouseID;
  47191. /**
  47192. * Abstract mesh the behavior is set on
  47193. */
  47194. attachedNode: AbstractMesh;
  47195. private _dragPlane;
  47196. private _scene;
  47197. private _pointerObserver;
  47198. private _beforeRenderObserver;
  47199. private static _planeScene;
  47200. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  47201. /**
  47202. * 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)
  47203. */
  47204. maxDragAngle: number;
  47205. /**
  47206. * @hidden
  47207. */
  47208. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  47209. /**
  47210. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47211. */
  47212. currentDraggingPointerID: number;
  47213. /**
  47214. * The last position where the pointer hit the drag plane in world space
  47215. */
  47216. lastDragPosition: Vector3;
  47217. /**
  47218. * If the behavior is currently in a dragging state
  47219. */
  47220. dragging: boolean;
  47221. /**
  47222. * 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)
  47223. */
  47224. dragDeltaRatio: number;
  47225. /**
  47226. * If the drag plane orientation should be updated during the dragging (Default: true)
  47227. */
  47228. updateDragPlane: boolean;
  47229. private _debugMode;
  47230. private _moving;
  47231. /**
  47232. * Fires each time the attached mesh is dragged with the pointer
  47233. * * delta between last drag position and current drag position in world space
  47234. * * dragDistance along the drag axis
  47235. * * dragPlaneNormal normal of the current drag plane used during the drag
  47236. * * dragPlanePoint in world space where the drag intersects the drag plane
  47237. */
  47238. onDragObservable: Observable<{
  47239. delta: Vector3;
  47240. dragPlanePoint: Vector3;
  47241. dragPlaneNormal: Vector3;
  47242. dragDistance: number;
  47243. pointerId: number;
  47244. }>;
  47245. /**
  47246. * Fires each time a drag begins (eg. mouse down on mesh)
  47247. */
  47248. onDragStartObservable: Observable<{
  47249. dragPlanePoint: Vector3;
  47250. pointerId: number;
  47251. }>;
  47252. /**
  47253. * Fires each time a drag ends (eg. mouse release after drag)
  47254. */
  47255. onDragEndObservable: Observable<{
  47256. dragPlanePoint: Vector3;
  47257. pointerId: number;
  47258. }>;
  47259. /**
  47260. * If the attached mesh should be moved when dragged
  47261. */
  47262. moveAttached: boolean;
  47263. /**
  47264. * If the drag behavior will react to drag events (Default: true)
  47265. */
  47266. enabled: boolean;
  47267. /**
  47268. * If pointer events should start and release the drag (Default: true)
  47269. */
  47270. startAndReleaseDragOnPointerEvents: boolean;
  47271. /**
  47272. * If camera controls should be detached during the drag
  47273. */
  47274. detachCameraControls: boolean;
  47275. /**
  47276. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  47277. */
  47278. useObjectOrientationForDragging: boolean;
  47279. private _options;
  47280. /**
  47281. * Gets the options used by the behavior
  47282. */
  47283. get options(): {
  47284. dragAxis?: Vector3;
  47285. dragPlaneNormal?: Vector3;
  47286. };
  47287. /**
  47288. * Sets the options used by the behavior
  47289. */
  47290. set options(options: {
  47291. dragAxis?: Vector3;
  47292. dragPlaneNormal?: Vector3;
  47293. });
  47294. /**
  47295. * Creates a pointer drag behavior that can be attached to a mesh
  47296. * @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)
  47297. */
  47298. constructor(options?: {
  47299. dragAxis?: Vector3;
  47300. dragPlaneNormal?: Vector3;
  47301. });
  47302. /**
  47303. * Predicate to determine if it is valid to move the object to a new position when it is moved
  47304. */
  47305. validateDrag: (targetPosition: Vector3) => boolean;
  47306. /**
  47307. * The name of the behavior
  47308. */
  47309. get name(): string;
  47310. /**
  47311. * Initializes the behavior
  47312. */
  47313. init(): void;
  47314. private _tmpVector;
  47315. private _alternatePickedPoint;
  47316. private _worldDragAxis;
  47317. private _targetPosition;
  47318. private _attachedToElement;
  47319. /**
  47320. * Attaches the drag behavior the passed in mesh
  47321. * @param ownerNode The mesh that will be dragged around once attached
  47322. * @param predicate Predicate to use for pick filtering
  47323. */
  47324. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  47325. /**
  47326. * Force relase the drag action by code.
  47327. */
  47328. releaseDrag(): void;
  47329. private _startDragRay;
  47330. private _lastPointerRay;
  47331. /**
  47332. * Simulates the start of a pointer drag event on the behavior
  47333. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47334. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47335. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47336. */
  47337. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47338. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47339. private _dragDelta;
  47340. protected _moveDrag(ray: Ray): void;
  47341. private _pickWithRayOnDragPlane;
  47342. private _pointA;
  47343. private _pointC;
  47344. private _localAxis;
  47345. private _lookAt;
  47346. private _updateDragPlanePosition;
  47347. /**
  47348. * Detaches the behavior from the mesh
  47349. */
  47350. detach(): void;
  47351. }
  47352. }
  47353. declare module BABYLON {
  47354. /**
  47355. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47356. */
  47357. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47358. private _dragBehaviorA;
  47359. private _dragBehaviorB;
  47360. private _startDistance;
  47361. private _initialScale;
  47362. private _targetScale;
  47363. private _ownerNode;
  47364. private _sceneRenderObserver;
  47365. /**
  47366. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47367. */
  47368. constructor();
  47369. /**
  47370. * The name of the behavior
  47371. */
  47372. get name(): string;
  47373. /**
  47374. * Initializes the behavior
  47375. */
  47376. init(): void;
  47377. private _getCurrentDistance;
  47378. /**
  47379. * Attaches the scale behavior the passed in mesh
  47380. * @param ownerNode The mesh that will be scaled around once attached
  47381. */
  47382. attach(ownerNode: Mesh): void;
  47383. /**
  47384. * Detaches the behavior from the mesh
  47385. */
  47386. detach(): void;
  47387. }
  47388. }
  47389. declare module BABYLON {
  47390. /**
  47391. * 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
  47392. */
  47393. export class SixDofDragBehavior implements Behavior<Mesh> {
  47394. private static _virtualScene;
  47395. private _ownerNode;
  47396. private _sceneRenderObserver;
  47397. private _scene;
  47398. private _targetPosition;
  47399. private _virtualOriginMesh;
  47400. private _virtualDragMesh;
  47401. private _pointerObserver;
  47402. private _moving;
  47403. private _startingOrientation;
  47404. private _attachedToElement;
  47405. /**
  47406. * 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)
  47407. */
  47408. private zDragFactor;
  47409. /**
  47410. * If the object should rotate to face the drag origin
  47411. */
  47412. rotateDraggedObject: boolean;
  47413. /**
  47414. * If the behavior is currently in a dragging state
  47415. */
  47416. dragging: boolean;
  47417. /**
  47418. * 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)
  47419. */
  47420. dragDeltaRatio: number;
  47421. /**
  47422. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47423. */
  47424. currentDraggingPointerID: number;
  47425. /**
  47426. * If camera controls should be detached during the drag
  47427. */
  47428. detachCameraControls: boolean;
  47429. /**
  47430. * Fires each time a drag starts
  47431. */
  47432. onDragStartObservable: Observable<{}>;
  47433. /**
  47434. * Fires each time a drag happens
  47435. */
  47436. onDragObservable: Observable<void>;
  47437. /**
  47438. * Fires each time a drag ends (eg. mouse release after drag)
  47439. */
  47440. onDragEndObservable: Observable<{}>;
  47441. /**
  47442. * 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
  47443. */
  47444. constructor();
  47445. /**
  47446. * The name of the behavior
  47447. */
  47448. get name(): string;
  47449. /**
  47450. * Initializes the behavior
  47451. */
  47452. init(): void;
  47453. /**
  47454. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47455. */
  47456. private get _pointerCamera();
  47457. /**
  47458. * Attaches the scale behavior the passed in mesh
  47459. * @param ownerNode The mesh that will be scaled around once attached
  47460. */
  47461. attach(ownerNode: Mesh): void;
  47462. /**
  47463. * Detaches the behavior from the mesh
  47464. */
  47465. detach(): void;
  47466. }
  47467. }
  47468. declare module BABYLON {
  47469. /**
  47470. * Class used to apply inverse kinematics to bones
  47471. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47472. */
  47473. export class BoneIKController {
  47474. private static _tmpVecs;
  47475. private static _tmpQuat;
  47476. private static _tmpMats;
  47477. /**
  47478. * Gets or sets the target mesh
  47479. */
  47480. targetMesh: AbstractMesh;
  47481. /** Gets or sets the mesh used as pole */
  47482. poleTargetMesh: AbstractMesh;
  47483. /**
  47484. * Gets or sets the bone used as pole
  47485. */
  47486. poleTargetBone: Nullable<Bone>;
  47487. /**
  47488. * Gets or sets the target position
  47489. */
  47490. targetPosition: Vector3;
  47491. /**
  47492. * Gets or sets the pole target position
  47493. */
  47494. poleTargetPosition: Vector3;
  47495. /**
  47496. * Gets or sets the pole target local offset
  47497. */
  47498. poleTargetLocalOffset: Vector3;
  47499. /**
  47500. * Gets or sets the pole angle
  47501. */
  47502. poleAngle: number;
  47503. /**
  47504. * Gets or sets the mesh associated with the controller
  47505. */
  47506. mesh: AbstractMesh;
  47507. /**
  47508. * 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)
  47509. */
  47510. slerpAmount: number;
  47511. private _bone1Quat;
  47512. private _bone1Mat;
  47513. private _bone2Ang;
  47514. private _bone1;
  47515. private _bone2;
  47516. private _bone1Length;
  47517. private _bone2Length;
  47518. private _maxAngle;
  47519. private _maxReach;
  47520. private _rightHandedSystem;
  47521. private _bendAxis;
  47522. private _slerping;
  47523. private _adjustRoll;
  47524. /**
  47525. * Gets or sets maximum allowed angle
  47526. */
  47527. get maxAngle(): number;
  47528. set maxAngle(value: number);
  47529. /**
  47530. * Creates a new BoneIKController
  47531. * @param mesh defines the mesh to control
  47532. * @param bone defines the bone to control
  47533. * @param options defines options to set up the controller
  47534. */
  47535. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47536. targetMesh?: AbstractMesh;
  47537. poleTargetMesh?: AbstractMesh;
  47538. poleTargetBone?: Bone;
  47539. poleTargetLocalOffset?: Vector3;
  47540. poleAngle?: number;
  47541. bendAxis?: Vector3;
  47542. maxAngle?: number;
  47543. slerpAmount?: number;
  47544. });
  47545. private _setMaxAngle;
  47546. /**
  47547. * Force the controller to update the bones
  47548. */
  47549. update(): void;
  47550. }
  47551. }
  47552. declare module BABYLON {
  47553. /**
  47554. * Class used to make a bone look toward a point in space
  47555. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47556. */
  47557. export class BoneLookController {
  47558. private static _tmpVecs;
  47559. private static _tmpQuat;
  47560. private static _tmpMats;
  47561. /**
  47562. * The target Vector3 that the bone will look at
  47563. */
  47564. target: Vector3;
  47565. /**
  47566. * The mesh that the bone is attached to
  47567. */
  47568. mesh: AbstractMesh;
  47569. /**
  47570. * The bone that will be looking to the target
  47571. */
  47572. bone: Bone;
  47573. /**
  47574. * The up axis of the coordinate system that is used when the bone is rotated
  47575. */
  47576. upAxis: Vector3;
  47577. /**
  47578. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47579. */
  47580. upAxisSpace: Space;
  47581. /**
  47582. * Used to make an adjustment to the yaw of the bone
  47583. */
  47584. adjustYaw: number;
  47585. /**
  47586. * Used to make an adjustment to the pitch of the bone
  47587. */
  47588. adjustPitch: number;
  47589. /**
  47590. * Used to make an adjustment to the roll of the bone
  47591. */
  47592. adjustRoll: number;
  47593. /**
  47594. * 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)
  47595. */
  47596. slerpAmount: number;
  47597. private _minYaw;
  47598. private _maxYaw;
  47599. private _minPitch;
  47600. private _maxPitch;
  47601. private _minYawSin;
  47602. private _minYawCos;
  47603. private _maxYawSin;
  47604. private _maxYawCos;
  47605. private _midYawConstraint;
  47606. private _minPitchTan;
  47607. private _maxPitchTan;
  47608. private _boneQuat;
  47609. private _slerping;
  47610. private _transformYawPitch;
  47611. private _transformYawPitchInv;
  47612. private _firstFrameSkipped;
  47613. private _yawRange;
  47614. private _fowardAxis;
  47615. /**
  47616. * Gets or sets the minimum yaw angle that the bone can look to
  47617. */
  47618. get minYaw(): number;
  47619. set minYaw(value: number);
  47620. /**
  47621. * Gets or sets the maximum yaw angle that the bone can look to
  47622. */
  47623. get maxYaw(): number;
  47624. set maxYaw(value: number);
  47625. /**
  47626. * Gets or sets the minimum pitch angle that the bone can look to
  47627. */
  47628. get minPitch(): number;
  47629. set minPitch(value: number);
  47630. /**
  47631. * Gets or sets the maximum pitch angle that the bone can look to
  47632. */
  47633. get maxPitch(): number;
  47634. set maxPitch(value: number);
  47635. /**
  47636. * Create a BoneLookController
  47637. * @param mesh the mesh that the bone belongs to
  47638. * @param bone the bone that will be looking to the target
  47639. * @param target the target Vector3 to look at
  47640. * @param options optional settings:
  47641. * * maxYaw: the maximum angle the bone will yaw to
  47642. * * minYaw: the minimum angle the bone will yaw to
  47643. * * maxPitch: the maximum angle the bone will pitch to
  47644. * * minPitch: the minimum angle the bone will yaw to
  47645. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47646. * * upAxis: the up axis of the coordinate system
  47647. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47648. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47649. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47650. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47651. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47652. * * adjustRoll: used to make an adjustment to the roll of the bone
  47653. **/
  47654. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47655. maxYaw?: number;
  47656. minYaw?: number;
  47657. maxPitch?: number;
  47658. minPitch?: number;
  47659. slerpAmount?: number;
  47660. upAxis?: Vector3;
  47661. upAxisSpace?: Space;
  47662. yawAxis?: Vector3;
  47663. pitchAxis?: Vector3;
  47664. adjustYaw?: number;
  47665. adjustPitch?: number;
  47666. adjustRoll?: number;
  47667. });
  47668. /**
  47669. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47670. */
  47671. update(): void;
  47672. private _getAngleDiff;
  47673. private _getAngleBetween;
  47674. private _isAngleBetween;
  47675. }
  47676. }
  47677. declare module BABYLON {
  47678. /**
  47679. * Manage the gamepad inputs to control an arc rotate camera.
  47680. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47681. */
  47682. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47683. /**
  47684. * Defines the camera the input is attached to.
  47685. */
  47686. camera: ArcRotateCamera;
  47687. /**
  47688. * Defines the gamepad the input is gathering event from.
  47689. */
  47690. gamepad: Nullable<Gamepad>;
  47691. /**
  47692. * Defines the gamepad rotation sensiblity.
  47693. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47694. */
  47695. gamepadRotationSensibility: number;
  47696. /**
  47697. * Defines the gamepad move sensiblity.
  47698. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47699. */
  47700. gamepadMoveSensibility: number;
  47701. private _yAxisScale;
  47702. /**
  47703. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47704. */
  47705. get invertYAxis(): boolean;
  47706. set invertYAxis(value: boolean);
  47707. private _onGamepadConnectedObserver;
  47708. private _onGamepadDisconnectedObserver;
  47709. /**
  47710. * Attach the input controls to a specific dom element to get the input from.
  47711. */
  47712. attachControl(): void;
  47713. /**
  47714. * Detach the current controls from the specified dom element.
  47715. */
  47716. detachControl(): void;
  47717. /**
  47718. * Update the current camera state depending on the inputs that have been used this frame.
  47719. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47720. */
  47721. checkInputs(): void;
  47722. /**
  47723. * Gets the class name of the current intput.
  47724. * @returns the class name
  47725. */
  47726. getClassName(): string;
  47727. /**
  47728. * Get the friendly name associated with the input class.
  47729. * @returns the input friendly name
  47730. */
  47731. getSimpleName(): string;
  47732. }
  47733. }
  47734. declare module BABYLON {
  47735. interface ArcRotateCameraInputsManager {
  47736. /**
  47737. * Add orientation input support to the input manager.
  47738. * @returns the current input manager
  47739. */
  47740. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47741. }
  47742. /**
  47743. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47744. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47745. */
  47746. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47747. /**
  47748. * Defines the camera the input is attached to.
  47749. */
  47750. camera: ArcRotateCamera;
  47751. /**
  47752. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47753. */
  47754. alphaCorrection: number;
  47755. /**
  47756. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47757. */
  47758. gammaCorrection: number;
  47759. private _alpha;
  47760. private _gamma;
  47761. private _dirty;
  47762. private _deviceOrientationHandler;
  47763. /**
  47764. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47765. */
  47766. constructor();
  47767. /**
  47768. * Attach the input controls to a specific dom element to get the input from.
  47769. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47770. */
  47771. attachControl(noPreventDefault?: boolean): void;
  47772. /** @hidden */
  47773. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47774. /**
  47775. * Update the current camera state depending on the inputs that have been used this frame.
  47776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47777. */
  47778. checkInputs(): void;
  47779. /**
  47780. * Detach the current controls from the specified dom element.
  47781. */
  47782. detachControl(): void;
  47783. /**
  47784. * Gets the class name of the current intput.
  47785. * @returns the class name
  47786. */
  47787. getClassName(): string;
  47788. /**
  47789. * Get the friendly name associated with the input class.
  47790. * @returns the input friendly name
  47791. */
  47792. getSimpleName(): string;
  47793. }
  47794. }
  47795. declare module BABYLON {
  47796. /**
  47797. * Listen to mouse events to control the camera.
  47798. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47799. */
  47800. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47801. /**
  47802. * Defines the camera the input is attached to.
  47803. */
  47804. camera: FlyCamera;
  47805. /**
  47806. * Defines if touch is enabled. (Default is true.)
  47807. */
  47808. touchEnabled: boolean;
  47809. /**
  47810. * Defines the buttons associated with the input to handle camera rotation.
  47811. */
  47812. buttons: number[];
  47813. /**
  47814. * Assign buttons for Yaw control.
  47815. */
  47816. buttonsYaw: number[];
  47817. /**
  47818. * Assign buttons for Pitch control.
  47819. */
  47820. buttonsPitch: number[];
  47821. /**
  47822. * Assign buttons for Roll control.
  47823. */
  47824. buttonsRoll: number[];
  47825. /**
  47826. * Detect if any button is being pressed while mouse is moved.
  47827. * -1 = Mouse locked.
  47828. * 0 = Left button.
  47829. * 1 = Middle Button.
  47830. * 2 = Right Button.
  47831. */
  47832. activeButton: number;
  47833. /**
  47834. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47835. * Higher values reduce its sensitivity.
  47836. */
  47837. angularSensibility: number;
  47838. private _observer;
  47839. private _rollObserver;
  47840. private previousPosition;
  47841. private noPreventDefault;
  47842. private element;
  47843. /**
  47844. * Listen to mouse events to control the camera.
  47845. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47846. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47847. */
  47848. constructor(touchEnabled?: boolean);
  47849. /**
  47850. * Attach the mouse control to the HTML DOM element.
  47851. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47852. */
  47853. attachControl(noPreventDefault?: boolean): void;
  47854. /**
  47855. * Detach the current controls from the specified dom element.
  47856. */
  47857. detachControl(): void;
  47858. /**
  47859. * Gets the class name of the current input.
  47860. * @returns the class name.
  47861. */
  47862. getClassName(): string;
  47863. /**
  47864. * Get the friendly name associated with the input class.
  47865. * @returns the input's friendly name.
  47866. */
  47867. getSimpleName(): string;
  47868. private _pointerInput;
  47869. private _onMouseMove;
  47870. /**
  47871. * Rotate camera by mouse offset.
  47872. */
  47873. private rotateCamera;
  47874. }
  47875. }
  47876. declare module BABYLON {
  47877. /**
  47878. * Default Inputs manager for the FlyCamera.
  47879. * It groups all the default supported inputs for ease of use.
  47880. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47881. */
  47882. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47883. /**
  47884. * Instantiates a new FlyCameraInputsManager.
  47885. * @param camera Defines the camera the inputs belong to.
  47886. */
  47887. constructor(camera: FlyCamera);
  47888. /**
  47889. * Add keyboard input support to the input manager.
  47890. * @returns the new FlyCameraKeyboardMoveInput().
  47891. */
  47892. addKeyboard(): FlyCameraInputsManager;
  47893. /**
  47894. * Add mouse input support to the input manager.
  47895. * @param touchEnabled Enable touch screen support.
  47896. * @returns the new FlyCameraMouseInput().
  47897. */
  47898. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47899. }
  47900. }
  47901. declare module BABYLON {
  47902. /**
  47903. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47904. * such as in a 3D Space Shooter or a Flight Simulator.
  47905. */
  47906. export class FlyCamera extends TargetCamera {
  47907. /**
  47908. * Define the collision ellipsoid of the camera.
  47909. * This is helpful for simulating a camera body, like a player's body.
  47910. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47911. */
  47912. ellipsoid: Vector3;
  47913. /**
  47914. * Define an offset for the position of the ellipsoid around the camera.
  47915. * This can be helpful if the camera is attached away from the player's body center,
  47916. * such as at its head.
  47917. */
  47918. ellipsoidOffset: Vector3;
  47919. /**
  47920. * Enable or disable collisions of the camera with the rest of the scene objects.
  47921. */
  47922. checkCollisions: boolean;
  47923. /**
  47924. * Enable or disable gravity on the camera.
  47925. */
  47926. applyGravity: boolean;
  47927. /**
  47928. * Define the current direction the camera is moving to.
  47929. */
  47930. cameraDirection: Vector3;
  47931. /**
  47932. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47933. * This overrides and empties cameraRotation.
  47934. */
  47935. rotationQuaternion: Quaternion;
  47936. /**
  47937. * Track Roll to maintain the wanted Rolling when looking around.
  47938. */
  47939. _trackRoll: number;
  47940. /**
  47941. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47942. */
  47943. rollCorrect: number;
  47944. /**
  47945. * Mimic a banked turn, Rolling the camera when Yawing.
  47946. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47947. */
  47948. bankedTurn: boolean;
  47949. /**
  47950. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47951. */
  47952. bankedTurnLimit: number;
  47953. /**
  47954. * Value of 0 disables the banked Roll.
  47955. * Value of 1 is equal to the Yaw angle in radians.
  47956. */
  47957. bankedTurnMultiplier: number;
  47958. /**
  47959. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47960. */
  47961. inputs: FlyCameraInputsManager;
  47962. /**
  47963. * Gets the input sensibility for mouse input.
  47964. * Higher values reduce sensitivity.
  47965. */
  47966. get angularSensibility(): number;
  47967. /**
  47968. * Sets the input sensibility for a mouse input.
  47969. * Higher values reduce sensitivity.
  47970. */
  47971. set angularSensibility(value: number);
  47972. /**
  47973. * Get the keys for camera movement forward.
  47974. */
  47975. get keysForward(): number[];
  47976. /**
  47977. * Set the keys for camera movement forward.
  47978. */
  47979. set keysForward(value: number[]);
  47980. /**
  47981. * Get the keys for camera movement backward.
  47982. */
  47983. get keysBackward(): number[];
  47984. set keysBackward(value: number[]);
  47985. /**
  47986. * Get the keys for camera movement up.
  47987. */
  47988. get keysUp(): number[];
  47989. /**
  47990. * Set the keys for camera movement up.
  47991. */
  47992. set keysUp(value: number[]);
  47993. /**
  47994. * Get the keys for camera movement down.
  47995. */
  47996. get keysDown(): number[];
  47997. /**
  47998. * Set the keys for camera movement down.
  47999. */
  48000. set keysDown(value: number[]);
  48001. /**
  48002. * Get the keys for camera movement left.
  48003. */
  48004. get keysLeft(): number[];
  48005. /**
  48006. * Set the keys for camera movement left.
  48007. */
  48008. set keysLeft(value: number[]);
  48009. /**
  48010. * Set the keys for camera movement right.
  48011. */
  48012. get keysRight(): number[];
  48013. /**
  48014. * Set the keys for camera movement right.
  48015. */
  48016. set keysRight(value: number[]);
  48017. /**
  48018. * Event raised when the camera collides with a mesh in the scene.
  48019. */
  48020. onCollide: (collidedMesh: AbstractMesh) => void;
  48021. private _collider;
  48022. private _needMoveForGravity;
  48023. private _oldPosition;
  48024. private _diffPosition;
  48025. private _newPosition;
  48026. /** @hidden */
  48027. _localDirection: Vector3;
  48028. /** @hidden */
  48029. _transformedDirection: Vector3;
  48030. /**
  48031. * Instantiates a FlyCamera.
  48032. * This is a flying camera, designed for 3D movement and rotation in all directions,
  48033. * such as in a 3D Space Shooter or a Flight Simulator.
  48034. * @param name Define the name of the camera in the scene.
  48035. * @param position Define the starting position of the camera in the scene.
  48036. * @param scene Define the scene the camera belongs to.
  48037. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  48038. */
  48039. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48040. /**
  48041. * Attach the input controls to a specific dom element to get the input from.
  48042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48043. */
  48044. attachControl(noPreventDefault?: boolean): void;
  48045. /**
  48046. * Detach a control from the HTML DOM element.
  48047. * The camera will stop reacting to that input.
  48048. */
  48049. detachControl(): void;
  48050. private _collisionMask;
  48051. /**
  48052. * Get the mask that the camera ignores in collision events.
  48053. */
  48054. get collisionMask(): number;
  48055. /**
  48056. * Set the mask that the camera ignores in collision events.
  48057. */
  48058. set collisionMask(mask: number);
  48059. /** @hidden */
  48060. _collideWithWorld(displacement: Vector3): void;
  48061. /** @hidden */
  48062. private _onCollisionPositionChange;
  48063. /** @hidden */
  48064. _checkInputs(): void;
  48065. /** @hidden */
  48066. _decideIfNeedsToMove(): boolean;
  48067. /** @hidden */
  48068. _updatePosition(): void;
  48069. /**
  48070. * Restore the Roll to its target value at the rate specified.
  48071. * @param rate - Higher means slower restoring.
  48072. * @hidden
  48073. */
  48074. restoreRoll(rate: number): void;
  48075. /**
  48076. * Destroy the camera and release the current resources held by it.
  48077. */
  48078. dispose(): void;
  48079. /**
  48080. * Get the current object class name.
  48081. * @returns the class name.
  48082. */
  48083. getClassName(): string;
  48084. }
  48085. }
  48086. declare module BABYLON {
  48087. /**
  48088. * Listen to keyboard events to control the camera.
  48089. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48090. */
  48091. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  48092. /**
  48093. * Defines the camera the input is attached to.
  48094. */
  48095. camera: FlyCamera;
  48096. /**
  48097. * The list of keyboard keys used to control the forward move of the camera.
  48098. */
  48099. keysForward: number[];
  48100. /**
  48101. * The list of keyboard keys used to control the backward move of the camera.
  48102. */
  48103. keysBackward: number[];
  48104. /**
  48105. * The list of keyboard keys used to control the forward move of the camera.
  48106. */
  48107. keysUp: number[];
  48108. /**
  48109. * The list of keyboard keys used to control the backward move of the camera.
  48110. */
  48111. keysDown: number[];
  48112. /**
  48113. * The list of keyboard keys used to control the right strafe move of the camera.
  48114. */
  48115. keysRight: number[];
  48116. /**
  48117. * The list of keyboard keys used to control the left strafe move of the camera.
  48118. */
  48119. keysLeft: number[];
  48120. private _keys;
  48121. private _onCanvasBlurObserver;
  48122. private _onKeyboardObserver;
  48123. private _engine;
  48124. private _scene;
  48125. /**
  48126. * Attach the input controls to a specific dom element to get the input from.
  48127. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48128. */
  48129. attachControl(noPreventDefault?: boolean): void;
  48130. /**
  48131. * Detach the current controls from the specified dom element.
  48132. */
  48133. detachControl(): void;
  48134. /**
  48135. * Gets the class name of the current intput.
  48136. * @returns the class name
  48137. */
  48138. getClassName(): string;
  48139. /** @hidden */
  48140. _onLostFocus(e: FocusEvent): void;
  48141. /**
  48142. * Get the friendly name associated with the input class.
  48143. * @returns the input friendly name
  48144. */
  48145. getSimpleName(): string;
  48146. /**
  48147. * Update the current camera state depending on the inputs that have been used this frame.
  48148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48149. */
  48150. checkInputs(): void;
  48151. }
  48152. }
  48153. declare module BABYLON {
  48154. /**
  48155. * Manage the mouse wheel inputs to control a follow camera.
  48156. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48157. */
  48158. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  48159. /**
  48160. * Defines the camera the input is attached to.
  48161. */
  48162. camera: FollowCamera;
  48163. /**
  48164. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  48165. */
  48166. axisControlRadius: boolean;
  48167. /**
  48168. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  48169. */
  48170. axisControlHeight: boolean;
  48171. /**
  48172. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  48173. */
  48174. axisControlRotation: boolean;
  48175. /**
  48176. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  48177. * relation to mouseWheel events.
  48178. */
  48179. wheelPrecision: number;
  48180. /**
  48181. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48182. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48183. */
  48184. wheelDeltaPercentage: number;
  48185. private _wheel;
  48186. private _observer;
  48187. /**
  48188. * Attach the input controls to a specific dom element to get the input from.
  48189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48190. */
  48191. attachControl(noPreventDefault?: boolean): void;
  48192. /**
  48193. * Detach the current controls from the specified dom element.
  48194. */
  48195. detachControl(): void;
  48196. /**
  48197. * Gets the class name of the current intput.
  48198. * @returns the class name
  48199. */
  48200. getClassName(): string;
  48201. /**
  48202. * Get the friendly name associated with the input class.
  48203. * @returns the input friendly name
  48204. */
  48205. getSimpleName(): string;
  48206. }
  48207. }
  48208. declare module BABYLON {
  48209. /**
  48210. * Manage the pointers inputs to control an follow camera.
  48211. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48212. */
  48213. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  48214. /**
  48215. * Defines the camera the input is attached to.
  48216. */
  48217. camera: FollowCamera;
  48218. /**
  48219. * Gets the class name of the current input.
  48220. * @returns the class name
  48221. */
  48222. getClassName(): string;
  48223. /**
  48224. * Defines the pointer angular sensibility along the X axis or how fast is
  48225. * the camera rotating.
  48226. * A negative number will reverse the axis direction.
  48227. */
  48228. angularSensibilityX: number;
  48229. /**
  48230. * Defines the pointer angular sensibility along the Y axis or how fast is
  48231. * the camera rotating.
  48232. * A negative number will reverse the axis direction.
  48233. */
  48234. angularSensibilityY: number;
  48235. /**
  48236. * Defines the pointer pinch precision or how fast is the camera zooming.
  48237. * A negative number will reverse the axis direction.
  48238. */
  48239. pinchPrecision: number;
  48240. /**
  48241. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  48242. * from 0.
  48243. * It defines the percentage of current camera.radius to use as delta when
  48244. * pinch zoom is used.
  48245. */
  48246. pinchDeltaPercentage: number;
  48247. /**
  48248. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  48249. */
  48250. axisXControlRadius: boolean;
  48251. /**
  48252. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  48253. */
  48254. axisXControlHeight: boolean;
  48255. /**
  48256. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  48257. */
  48258. axisXControlRotation: boolean;
  48259. /**
  48260. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  48261. */
  48262. axisYControlRadius: boolean;
  48263. /**
  48264. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  48265. */
  48266. axisYControlHeight: boolean;
  48267. /**
  48268. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  48269. */
  48270. axisYControlRotation: boolean;
  48271. /**
  48272. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  48273. */
  48274. axisPinchControlRadius: boolean;
  48275. /**
  48276. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  48277. */
  48278. axisPinchControlHeight: boolean;
  48279. /**
  48280. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  48281. */
  48282. axisPinchControlRotation: boolean;
  48283. /**
  48284. * Log error messages if basic misconfiguration has occurred.
  48285. */
  48286. warningEnable: boolean;
  48287. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48288. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48289. private _warningCounter;
  48290. private _warning;
  48291. }
  48292. }
  48293. declare module BABYLON {
  48294. /**
  48295. * Default Inputs manager for the FollowCamera.
  48296. * It groups all the default supported inputs for ease of use.
  48297. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48298. */
  48299. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  48300. /**
  48301. * Instantiates a new FollowCameraInputsManager.
  48302. * @param camera Defines the camera the inputs belong to
  48303. */
  48304. constructor(camera: FollowCamera);
  48305. /**
  48306. * Add keyboard input support to the input manager.
  48307. * @returns the current input manager
  48308. */
  48309. addKeyboard(): FollowCameraInputsManager;
  48310. /**
  48311. * Add mouse wheel input support to the input manager.
  48312. * @returns the current input manager
  48313. */
  48314. addMouseWheel(): FollowCameraInputsManager;
  48315. /**
  48316. * Add pointers input support to the input manager.
  48317. * @returns the current input manager
  48318. */
  48319. addPointers(): FollowCameraInputsManager;
  48320. /**
  48321. * Add orientation input support to the input manager.
  48322. * @returns the current input manager
  48323. */
  48324. addVRDeviceOrientation(): FollowCameraInputsManager;
  48325. }
  48326. }
  48327. declare module BABYLON {
  48328. /**
  48329. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  48330. * an arc rotate version arcFollowCamera are available.
  48331. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48332. */
  48333. export class FollowCamera extends TargetCamera {
  48334. /**
  48335. * Distance the follow camera should follow an object at
  48336. */
  48337. radius: number;
  48338. /**
  48339. * Minimum allowed distance of the camera to the axis of rotation
  48340. * (The camera can not get closer).
  48341. * This can help limiting how the Camera is able to move in the scene.
  48342. */
  48343. lowerRadiusLimit: Nullable<number>;
  48344. /**
  48345. * Maximum allowed distance of the camera to the axis of rotation
  48346. * (The camera can not get further).
  48347. * This can help limiting how the Camera is able to move in the scene.
  48348. */
  48349. upperRadiusLimit: Nullable<number>;
  48350. /**
  48351. * Define a rotation offset between the camera and the object it follows
  48352. */
  48353. rotationOffset: number;
  48354. /**
  48355. * Minimum allowed angle to camera position relative to target object.
  48356. * This can help limiting how the Camera is able to move in the scene.
  48357. */
  48358. lowerRotationOffsetLimit: Nullable<number>;
  48359. /**
  48360. * Maximum allowed angle to camera position relative to target object.
  48361. * This can help limiting how the Camera is able to move in the scene.
  48362. */
  48363. upperRotationOffsetLimit: Nullable<number>;
  48364. /**
  48365. * Define a height offset between the camera and the object it follows.
  48366. * It can help following an object from the top (like a car chaing a plane)
  48367. */
  48368. heightOffset: number;
  48369. /**
  48370. * Minimum allowed height of camera position relative to target object.
  48371. * This can help limiting how the Camera is able to move in the scene.
  48372. */
  48373. lowerHeightOffsetLimit: Nullable<number>;
  48374. /**
  48375. * Maximum allowed height of camera position relative to target object.
  48376. * This can help limiting how the Camera is able to move in the scene.
  48377. */
  48378. upperHeightOffsetLimit: Nullable<number>;
  48379. /**
  48380. * Define how fast the camera can accelerate to follow it s target.
  48381. */
  48382. cameraAcceleration: number;
  48383. /**
  48384. * Define the speed limit of the camera following an object.
  48385. */
  48386. maxCameraSpeed: number;
  48387. /**
  48388. * Define the target of the camera.
  48389. */
  48390. lockedTarget: Nullable<AbstractMesh>;
  48391. /**
  48392. * Defines the input associated with the camera.
  48393. */
  48394. inputs: FollowCameraInputsManager;
  48395. /**
  48396. * Instantiates the follow camera.
  48397. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48398. * @param name Define the name of the camera in the scene
  48399. * @param position Define the position of the camera
  48400. * @param scene Define the scene the camera belong to
  48401. * @param lockedTarget Define the target of the camera
  48402. */
  48403. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48404. private _follow;
  48405. /**
  48406. * Attach the input controls to a specific dom element to get the input from.
  48407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48408. */
  48409. attachControl(noPreventDefault?: boolean): void;
  48410. /**
  48411. * Detach the current controls from the specified dom element.
  48412. */
  48413. detachControl(): void;
  48414. /** @hidden */
  48415. _checkInputs(): void;
  48416. private _checkLimits;
  48417. /**
  48418. * Gets the camera class name.
  48419. * @returns the class name
  48420. */
  48421. getClassName(): string;
  48422. }
  48423. /**
  48424. * Arc Rotate version of the follow camera.
  48425. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48426. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48427. */
  48428. export class ArcFollowCamera extends TargetCamera {
  48429. /** The longitudinal angle of the camera */
  48430. alpha: number;
  48431. /** The latitudinal angle of the camera */
  48432. beta: number;
  48433. /** The radius of the camera from its target */
  48434. radius: number;
  48435. private _cartesianCoordinates;
  48436. /** Define the camera target (the mesh it should follow) */
  48437. private _meshTarget;
  48438. /**
  48439. * Instantiates a new ArcFollowCamera
  48440. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48441. * @param name Define the name of the camera
  48442. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48443. * @param beta Define the rotation angle of the camera around the elevation axis
  48444. * @param radius Define the radius of the camera from its target point
  48445. * @param target Define the target of the camera
  48446. * @param scene Define the scene the camera belongs to
  48447. */
  48448. constructor(name: string,
  48449. /** The longitudinal angle of the camera */
  48450. alpha: number,
  48451. /** The latitudinal angle of the camera */
  48452. beta: number,
  48453. /** The radius of the camera from its target */
  48454. radius: number,
  48455. /** Define the camera target (the mesh it should follow) */
  48456. target: Nullable<AbstractMesh>, scene: Scene);
  48457. private _follow;
  48458. /** @hidden */
  48459. _checkInputs(): void;
  48460. /**
  48461. * Returns the class name of the object.
  48462. * It is mostly used internally for serialization purposes.
  48463. */
  48464. getClassName(): string;
  48465. }
  48466. }
  48467. declare module BABYLON {
  48468. /**
  48469. * Manage the keyboard inputs to control the movement of a follow camera.
  48470. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48471. */
  48472. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48473. /**
  48474. * Defines the camera the input is attached to.
  48475. */
  48476. camera: FollowCamera;
  48477. /**
  48478. * Defines the list of key codes associated with the up action (increase heightOffset)
  48479. */
  48480. keysHeightOffsetIncr: number[];
  48481. /**
  48482. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48483. */
  48484. keysHeightOffsetDecr: number[];
  48485. /**
  48486. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48487. */
  48488. keysHeightOffsetModifierAlt: boolean;
  48489. /**
  48490. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48491. */
  48492. keysHeightOffsetModifierCtrl: boolean;
  48493. /**
  48494. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48495. */
  48496. keysHeightOffsetModifierShift: boolean;
  48497. /**
  48498. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48499. */
  48500. keysRotationOffsetIncr: number[];
  48501. /**
  48502. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48503. */
  48504. keysRotationOffsetDecr: number[];
  48505. /**
  48506. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48507. */
  48508. keysRotationOffsetModifierAlt: boolean;
  48509. /**
  48510. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48511. */
  48512. keysRotationOffsetModifierCtrl: boolean;
  48513. /**
  48514. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48515. */
  48516. keysRotationOffsetModifierShift: boolean;
  48517. /**
  48518. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48519. */
  48520. keysRadiusIncr: number[];
  48521. /**
  48522. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48523. */
  48524. keysRadiusDecr: number[];
  48525. /**
  48526. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48527. */
  48528. keysRadiusModifierAlt: boolean;
  48529. /**
  48530. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48531. */
  48532. keysRadiusModifierCtrl: boolean;
  48533. /**
  48534. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48535. */
  48536. keysRadiusModifierShift: boolean;
  48537. /**
  48538. * Defines the rate of change of heightOffset.
  48539. */
  48540. heightSensibility: number;
  48541. /**
  48542. * Defines the rate of change of rotationOffset.
  48543. */
  48544. rotationSensibility: number;
  48545. /**
  48546. * Defines the rate of change of radius.
  48547. */
  48548. radiusSensibility: number;
  48549. private _keys;
  48550. private _ctrlPressed;
  48551. private _altPressed;
  48552. private _shiftPressed;
  48553. private _onCanvasBlurObserver;
  48554. private _onKeyboardObserver;
  48555. private _engine;
  48556. private _scene;
  48557. /**
  48558. * Attach the input controls to a specific dom element to get the input from.
  48559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48560. */
  48561. attachControl(noPreventDefault?: boolean): void;
  48562. /**
  48563. * Detach the current controls from the specified dom element.
  48564. */
  48565. detachControl(): void;
  48566. /**
  48567. * Update the current camera state depending on the inputs that have been used this frame.
  48568. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48569. */
  48570. checkInputs(): void;
  48571. /**
  48572. * Gets the class name of the current input.
  48573. * @returns the class name
  48574. */
  48575. getClassName(): string;
  48576. /**
  48577. * Get the friendly name associated with the input class.
  48578. * @returns the input friendly name
  48579. */
  48580. getSimpleName(): string;
  48581. /**
  48582. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48583. * allow modification of the heightOffset value.
  48584. */
  48585. private _modifierHeightOffset;
  48586. /**
  48587. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48588. * allow modification of the rotationOffset value.
  48589. */
  48590. private _modifierRotationOffset;
  48591. /**
  48592. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48593. * allow modification of the radius value.
  48594. */
  48595. private _modifierRadius;
  48596. }
  48597. }
  48598. declare module BABYLON {
  48599. interface FreeCameraInputsManager {
  48600. /**
  48601. * @hidden
  48602. */
  48603. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48604. /**
  48605. * Add orientation input support to the input manager.
  48606. * @returns the current input manager
  48607. */
  48608. addDeviceOrientation(): FreeCameraInputsManager;
  48609. }
  48610. /**
  48611. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48612. * Screen rotation is taken into account.
  48613. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48614. */
  48615. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48616. private _camera;
  48617. private _screenOrientationAngle;
  48618. private _constantTranform;
  48619. private _screenQuaternion;
  48620. private _alpha;
  48621. private _beta;
  48622. private _gamma;
  48623. /**
  48624. * Can be used to detect if a device orientation sensor is available on a device
  48625. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48626. * @returns a promise that will resolve on orientation change
  48627. */
  48628. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48629. /**
  48630. * @hidden
  48631. */
  48632. _onDeviceOrientationChangedObservable: Observable<void>;
  48633. /**
  48634. * Instantiates a new input
  48635. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48636. */
  48637. constructor();
  48638. /**
  48639. * Define the camera controlled by the input.
  48640. */
  48641. get camera(): FreeCamera;
  48642. set camera(camera: FreeCamera);
  48643. /**
  48644. * Attach the input controls to a specific dom element to get the input from.
  48645. */
  48646. attachControl(): void;
  48647. private _orientationChanged;
  48648. private _deviceOrientation;
  48649. /**
  48650. * Detach the current controls from the specified dom element.
  48651. */
  48652. detachControl(): void;
  48653. /**
  48654. * Update the current camera state depending on the inputs that have been used this frame.
  48655. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48656. */
  48657. checkInputs(): void;
  48658. /**
  48659. * Gets the class name of the current intput.
  48660. * @returns the class name
  48661. */
  48662. getClassName(): string;
  48663. /**
  48664. * Get the friendly name associated with the input class.
  48665. * @returns the input friendly name
  48666. */
  48667. getSimpleName(): string;
  48668. }
  48669. }
  48670. declare module BABYLON {
  48671. /**
  48672. * Manage the gamepad inputs to control a free camera.
  48673. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48674. */
  48675. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48676. /**
  48677. * Define the camera the input is attached to.
  48678. */
  48679. camera: FreeCamera;
  48680. /**
  48681. * Define the Gamepad controlling the input
  48682. */
  48683. gamepad: Nullable<Gamepad>;
  48684. /**
  48685. * Defines the gamepad rotation sensiblity.
  48686. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48687. */
  48688. gamepadAngularSensibility: number;
  48689. /**
  48690. * Defines the gamepad move sensiblity.
  48691. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48692. */
  48693. gamepadMoveSensibility: number;
  48694. private _yAxisScale;
  48695. /**
  48696. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48697. */
  48698. get invertYAxis(): boolean;
  48699. set invertYAxis(value: boolean);
  48700. private _onGamepadConnectedObserver;
  48701. private _onGamepadDisconnectedObserver;
  48702. private _cameraTransform;
  48703. private _deltaTransform;
  48704. private _vector3;
  48705. private _vector2;
  48706. /**
  48707. * Attach the input controls to a specific dom element to get the input from.
  48708. */
  48709. attachControl(): void;
  48710. /**
  48711. * Detach the current controls from the specified dom element.
  48712. */
  48713. detachControl(): void;
  48714. /**
  48715. * Update the current camera state depending on the inputs that have been used this frame.
  48716. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48717. */
  48718. checkInputs(): void;
  48719. /**
  48720. * Gets the class name of the current intput.
  48721. * @returns the class name
  48722. */
  48723. getClassName(): string;
  48724. /**
  48725. * Get the friendly name associated with the input class.
  48726. * @returns the input friendly name
  48727. */
  48728. getSimpleName(): string;
  48729. }
  48730. }
  48731. declare module BABYLON {
  48732. /**
  48733. * Defines the potential axis of a Joystick
  48734. */
  48735. export enum JoystickAxis {
  48736. /** X axis */
  48737. X = 0,
  48738. /** Y axis */
  48739. Y = 1,
  48740. /** Z axis */
  48741. Z = 2
  48742. }
  48743. /**
  48744. * Represents the different customization options available
  48745. * for VirtualJoystick
  48746. */
  48747. interface VirtualJoystickCustomizations {
  48748. /**
  48749. * Size of the joystick's puck
  48750. */
  48751. puckSize: number;
  48752. /**
  48753. * Size of the joystick's container
  48754. */
  48755. containerSize: number;
  48756. /**
  48757. * Color of the joystick && puck
  48758. */
  48759. color: string;
  48760. /**
  48761. * Image URL for the joystick's puck
  48762. */
  48763. puckImage?: string;
  48764. /**
  48765. * Image URL for the joystick's container
  48766. */
  48767. containerImage?: string;
  48768. /**
  48769. * Defines the unmoving position of the joystick container
  48770. */
  48771. position?: {
  48772. x: number;
  48773. y: number;
  48774. };
  48775. /**
  48776. * Defines whether or not the joystick container is always visible
  48777. */
  48778. alwaysVisible: boolean;
  48779. /**
  48780. * Defines whether or not to limit the movement of the puck to the joystick's container
  48781. */
  48782. limitToContainer: boolean;
  48783. }
  48784. /**
  48785. * Class used to define virtual joystick (used in touch mode)
  48786. */
  48787. export class VirtualJoystick {
  48788. /**
  48789. * Gets or sets a boolean indicating that left and right values must be inverted
  48790. */
  48791. reverseLeftRight: boolean;
  48792. /**
  48793. * Gets or sets a boolean indicating that up and down values must be inverted
  48794. */
  48795. reverseUpDown: boolean;
  48796. /**
  48797. * Gets the offset value for the position (ie. the change of the position value)
  48798. */
  48799. deltaPosition: Vector3;
  48800. /**
  48801. * Gets a boolean indicating if the virtual joystick was pressed
  48802. */
  48803. pressed: boolean;
  48804. /**
  48805. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48806. */
  48807. static Canvas: Nullable<HTMLCanvasElement>;
  48808. /**
  48809. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48810. */
  48811. limitToContainer: boolean;
  48812. private static _globalJoystickIndex;
  48813. private static _alwaysVisibleSticks;
  48814. private static vjCanvasContext;
  48815. private static vjCanvasWidth;
  48816. private static vjCanvasHeight;
  48817. private static halfWidth;
  48818. private static _GetDefaultOptions;
  48819. private _action;
  48820. private _axisTargetedByLeftAndRight;
  48821. private _axisTargetedByUpAndDown;
  48822. private _joystickSensibility;
  48823. private _inversedSensibility;
  48824. private _joystickPointerID;
  48825. private _joystickColor;
  48826. private _joystickPointerPos;
  48827. private _joystickPreviousPointerPos;
  48828. private _joystickPointerStartPos;
  48829. private _deltaJoystickVector;
  48830. private _leftJoystick;
  48831. private _touches;
  48832. private _joystickPosition;
  48833. private _alwaysVisible;
  48834. private _puckImage;
  48835. private _containerImage;
  48836. private _joystickPuckSize;
  48837. private _joystickContainerSize;
  48838. private _clearPuckSize;
  48839. private _clearContainerSize;
  48840. private _clearPuckSizeOffset;
  48841. private _clearContainerSizeOffset;
  48842. private _onPointerDownHandlerRef;
  48843. private _onPointerMoveHandlerRef;
  48844. private _onPointerUpHandlerRef;
  48845. private _onResize;
  48846. /**
  48847. * Creates a new virtual joystick
  48848. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48849. * @param customizations Defines the options we want to customize the VirtualJoystick
  48850. */
  48851. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48852. /**
  48853. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48854. * @param newJoystickSensibility defines the new sensibility
  48855. */
  48856. setJoystickSensibility(newJoystickSensibility: number): void;
  48857. private _onPointerDown;
  48858. private _onPointerMove;
  48859. private _onPointerUp;
  48860. /**
  48861. * Change the color of the virtual joystick
  48862. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48863. */
  48864. setJoystickColor(newColor: string): void;
  48865. /**
  48866. * Size of the joystick's container
  48867. */
  48868. set containerSize(newSize: number);
  48869. get containerSize(): number;
  48870. /**
  48871. * Size of the joystick's puck
  48872. */
  48873. set puckSize(newSize: number);
  48874. get puckSize(): number;
  48875. /**
  48876. * Clears the set position of the joystick
  48877. */
  48878. clearPosition(): void;
  48879. /**
  48880. * Defines whether or not the joystick container is always visible
  48881. */
  48882. set alwaysVisible(value: boolean);
  48883. get alwaysVisible(): boolean;
  48884. /**
  48885. * Sets the constant position of the Joystick container
  48886. * @param x X axis coordinate
  48887. * @param y Y axis coordinate
  48888. */
  48889. setPosition(x: number, y: number): void;
  48890. /**
  48891. * Defines a callback to call when the joystick is touched
  48892. * @param action defines the callback
  48893. */
  48894. setActionOnTouch(action: () => any): void;
  48895. /**
  48896. * Defines which axis you'd like to control for left & right
  48897. * @param axis defines the axis to use
  48898. */
  48899. setAxisForLeftRight(axis: JoystickAxis): void;
  48900. /**
  48901. * Defines which axis you'd like to control for up & down
  48902. * @param axis defines the axis to use
  48903. */
  48904. setAxisForUpDown(axis: JoystickAxis): void;
  48905. /**
  48906. * Clears the canvas from the previous puck / container draw
  48907. */
  48908. private _clearPreviousDraw;
  48909. /**
  48910. * Loads `urlPath` to be used for the container's image
  48911. * @param urlPath defines the urlPath of an image to use
  48912. */
  48913. setContainerImage(urlPath: string): void;
  48914. /**
  48915. * Loads `urlPath` to be used for the puck's image
  48916. * @param urlPath defines the urlPath of an image to use
  48917. */
  48918. setPuckImage(urlPath: string): void;
  48919. /**
  48920. * Draws the Virtual Joystick's container
  48921. */
  48922. private _drawContainer;
  48923. /**
  48924. * Draws the Virtual Joystick's puck
  48925. */
  48926. private _drawPuck;
  48927. private _drawVirtualJoystick;
  48928. /**
  48929. * Release internal HTML canvas
  48930. */
  48931. releaseCanvas(): void;
  48932. }
  48933. }
  48934. declare module BABYLON {
  48935. interface FreeCameraInputsManager {
  48936. /**
  48937. * Add virtual joystick input support to the input manager.
  48938. * @returns the current input manager
  48939. */
  48940. addVirtualJoystick(): FreeCameraInputsManager;
  48941. }
  48942. /**
  48943. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48944. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48945. */
  48946. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48947. /**
  48948. * Defines the camera the input is attached to.
  48949. */
  48950. camera: FreeCamera;
  48951. private _leftjoystick;
  48952. private _rightjoystick;
  48953. /**
  48954. * Gets the left stick of the virtual joystick.
  48955. * @returns The virtual Joystick
  48956. */
  48957. getLeftJoystick(): VirtualJoystick;
  48958. /**
  48959. * Gets the right stick of the virtual joystick.
  48960. * @returns The virtual Joystick
  48961. */
  48962. getRightJoystick(): VirtualJoystick;
  48963. /**
  48964. * Update the current camera state depending on the inputs that have been used this frame.
  48965. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48966. */
  48967. checkInputs(): void;
  48968. /**
  48969. * Attach the input controls to a specific dom element to get the input from.
  48970. */
  48971. attachControl(): void;
  48972. /**
  48973. * Detach the current controls from the specified dom element.
  48974. */
  48975. detachControl(): void;
  48976. /**
  48977. * Gets the class name of the current intput.
  48978. * @returns the class name
  48979. */
  48980. getClassName(): string;
  48981. /**
  48982. * Get the friendly name associated with the input class.
  48983. * @returns the input friendly name
  48984. */
  48985. getSimpleName(): string;
  48986. }
  48987. }
  48988. declare module BABYLON {
  48989. /**
  48990. * This represents a FPS type of camera controlled by touch.
  48991. * This is like a universal camera minus the Gamepad controls.
  48992. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48993. */
  48994. export class TouchCamera extends FreeCamera {
  48995. /**
  48996. * Defines the touch sensibility for rotation.
  48997. * The higher the faster.
  48998. */
  48999. get touchAngularSensibility(): number;
  49000. set touchAngularSensibility(value: number);
  49001. /**
  49002. * Defines the touch sensibility for move.
  49003. * The higher the faster.
  49004. */
  49005. get touchMoveSensibility(): number;
  49006. set touchMoveSensibility(value: number);
  49007. /**
  49008. * Instantiates a new touch camera.
  49009. * This represents a FPS type of camera controlled by touch.
  49010. * This is like a universal camera minus the Gamepad controls.
  49011. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49012. * @param name Define the name of the camera in the scene
  49013. * @param position Define the start position of the camera in the scene
  49014. * @param scene Define the scene the camera belongs to
  49015. */
  49016. constructor(name: string, position: Vector3, scene: Scene);
  49017. /**
  49018. * Gets the current object class name.
  49019. * @return the class name
  49020. */
  49021. getClassName(): string;
  49022. /** @hidden */
  49023. _setupInputs(): void;
  49024. }
  49025. }
  49026. declare module BABYLON {
  49027. /**
  49028. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  49029. * being tilted forward or back and left or right.
  49030. */
  49031. export class DeviceOrientationCamera extends FreeCamera {
  49032. private _initialQuaternion;
  49033. private _quaternionCache;
  49034. private _tmpDragQuaternion;
  49035. private _disablePointerInputWhenUsingDeviceOrientation;
  49036. /**
  49037. * Creates a new device orientation camera
  49038. * @param name The name of the camera
  49039. * @param position The start position camera
  49040. * @param scene The scene the camera belongs to
  49041. */
  49042. constructor(name: string, position: Vector3, scene: Scene);
  49043. /**
  49044. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  49045. */
  49046. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  49047. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  49048. private _dragFactor;
  49049. /**
  49050. * Enabled turning on the y axis when the orientation sensor is active
  49051. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  49052. */
  49053. enableHorizontalDragging(dragFactor?: number): void;
  49054. /**
  49055. * Gets the current instance class name ("DeviceOrientationCamera").
  49056. * This helps avoiding instanceof at run time.
  49057. * @returns the class name
  49058. */
  49059. getClassName(): string;
  49060. /**
  49061. * @hidden
  49062. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  49063. */
  49064. _checkInputs(): void;
  49065. /**
  49066. * Reset the camera to its default orientation on the specified axis only.
  49067. * @param axis The axis to reset
  49068. */
  49069. resetToCurrentRotation(axis?: Axis): void;
  49070. }
  49071. }
  49072. declare module BABYLON {
  49073. /**
  49074. * Defines supported buttons for XBox360 compatible gamepads
  49075. */
  49076. export enum Xbox360Button {
  49077. /** A */
  49078. A = 0,
  49079. /** B */
  49080. B = 1,
  49081. /** X */
  49082. X = 2,
  49083. /** Y */
  49084. Y = 3,
  49085. /** Left button */
  49086. LB = 4,
  49087. /** Right button */
  49088. RB = 5,
  49089. /** Back */
  49090. Back = 8,
  49091. /** Start */
  49092. Start = 9,
  49093. /** Left stick */
  49094. LeftStick = 10,
  49095. /** Right stick */
  49096. RightStick = 11
  49097. }
  49098. /** Defines values for XBox360 DPad */
  49099. export enum Xbox360Dpad {
  49100. /** Up */
  49101. Up = 12,
  49102. /** Down */
  49103. Down = 13,
  49104. /** Left */
  49105. Left = 14,
  49106. /** Right */
  49107. Right = 15
  49108. }
  49109. /**
  49110. * Defines a XBox360 gamepad
  49111. */
  49112. export class Xbox360Pad extends Gamepad {
  49113. private _leftTrigger;
  49114. private _rightTrigger;
  49115. private _onlefttriggerchanged;
  49116. private _onrighttriggerchanged;
  49117. private _onbuttondown;
  49118. private _onbuttonup;
  49119. private _ondpaddown;
  49120. private _ondpadup;
  49121. /** Observable raised when a button is pressed */
  49122. onButtonDownObservable: Observable<Xbox360Button>;
  49123. /** Observable raised when a button is released */
  49124. onButtonUpObservable: Observable<Xbox360Button>;
  49125. /** Observable raised when a pad is pressed */
  49126. onPadDownObservable: Observable<Xbox360Dpad>;
  49127. /** Observable raised when a pad is released */
  49128. onPadUpObservable: Observable<Xbox360Dpad>;
  49129. private _buttonA;
  49130. private _buttonB;
  49131. private _buttonX;
  49132. private _buttonY;
  49133. private _buttonBack;
  49134. private _buttonStart;
  49135. private _buttonLB;
  49136. private _buttonRB;
  49137. private _buttonLeftStick;
  49138. private _buttonRightStick;
  49139. private _dPadUp;
  49140. private _dPadDown;
  49141. private _dPadLeft;
  49142. private _dPadRight;
  49143. private _isXboxOnePad;
  49144. /**
  49145. * Creates a new XBox360 gamepad object
  49146. * @param id defines the id of this gamepad
  49147. * @param index defines its index
  49148. * @param gamepad defines the internal HTML gamepad object
  49149. * @param xboxOne defines if it is a XBox One gamepad
  49150. */
  49151. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  49152. /**
  49153. * Defines the callback to call when left trigger is pressed
  49154. * @param callback defines the callback to use
  49155. */
  49156. onlefttriggerchanged(callback: (value: number) => void): void;
  49157. /**
  49158. * Defines the callback to call when right trigger is pressed
  49159. * @param callback defines the callback to use
  49160. */
  49161. onrighttriggerchanged(callback: (value: number) => void): void;
  49162. /**
  49163. * Gets the left trigger value
  49164. */
  49165. get leftTrigger(): number;
  49166. /**
  49167. * Sets the left trigger value
  49168. */
  49169. set leftTrigger(newValue: number);
  49170. /**
  49171. * Gets the right trigger value
  49172. */
  49173. get rightTrigger(): number;
  49174. /**
  49175. * Sets the right trigger value
  49176. */
  49177. set rightTrigger(newValue: number);
  49178. /**
  49179. * Defines the callback to call when a button is pressed
  49180. * @param callback defines the callback to use
  49181. */
  49182. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  49183. /**
  49184. * Defines the callback to call when a button is released
  49185. * @param callback defines the callback to use
  49186. */
  49187. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  49188. /**
  49189. * Defines the callback to call when a pad is pressed
  49190. * @param callback defines the callback to use
  49191. */
  49192. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  49193. /**
  49194. * Defines the callback to call when a pad is released
  49195. * @param callback defines the callback to use
  49196. */
  49197. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  49198. private _setButtonValue;
  49199. private _setDPadValue;
  49200. /**
  49201. * Gets the value of the `A` button
  49202. */
  49203. get buttonA(): number;
  49204. /**
  49205. * Sets the value of the `A` button
  49206. */
  49207. set buttonA(value: number);
  49208. /**
  49209. * Gets the value of the `B` button
  49210. */
  49211. get buttonB(): number;
  49212. /**
  49213. * Sets the value of the `B` button
  49214. */
  49215. set buttonB(value: number);
  49216. /**
  49217. * Gets the value of the `X` button
  49218. */
  49219. get buttonX(): number;
  49220. /**
  49221. * Sets the value of the `X` button
  49222. */
  49223. set buttonX(value: number);
  49224. /**
  49225. * Gets the value of the `Y` button
  49226. */
  49227. get buttonY(): number;
  49228. /**
  49229. * Sets the value of the `Y` button
  49230. */
  49231. set buttonY(value: number);
  49232. /**
  49233. * Gets the value of the `Start` button
  49234. */
  49235. get buttonStart(): number;
  49236. /**
  49237. * Sets the value of the `Start` button
  49238. */
  49239. set buttonStart(value: number);
  49240. /**
  49241. * Gets the value of the `Back` button
  49242. */
  49243. get buttonBack(): number;
  49244. /**
  49245. * Sets the value of the `Back` button
  49246. */
  49247. set buttonBack(value: number);
  49248. /**
  49249. * Gets the value of the `Left` button
  49250. */
  49251. get buttonLB(): number;
  49252. /**
  49253. * Sets the value of the `Left` button
  49254. */
  49255. set buttonLB(value: number);
  49256. /**
  49257. * Gets the value of the `Right` button
  49258. */
  49259. get buttonRB(): number;
  49260. /**
  49261. * Sets the value of the `Right` button
  49262. */
  49263. set buttonRB(value: number);
  49264. /**
  49265. * Gets the value of the Left joystick
  49266. */
  49267. get buttonLeftStick(): number;
  49268. /**
  49269. * Sets the value of the Left joystick
  49270. */
  49271. set buttonLeftStick(value: number);
  49272. /**
  49273. * Gets the value of the Right joystick
  49274. */
  49275. get buttonRightStick(): number;
  49276. /**
  49277. * Sets the value of the Right joystick
  49278. */
  49279. set buttonRightStick(value: number);
  49280. /**
  49281. * Gets the value of D-pad up
  49282. */
  49283. get dPadUp(): number;
  49284. /**
  49285. * Sets the value of D-pad up
  49286. */
  49287. set dPadUp(value: number);
  49288. /**
  49289. * Gets the value of D-pad down
  49290. */
  49291. get dPadDown(): number;
  49292. /**
  49293. * Sets the value of D-pad down
  49294. */
  49295. set dPadDown(value: number);
  49296. /**
  49297. * Gets the value of D-pad left
  49298. */
  49299. get dPadLeft(): number;
  49300. /**
  49301. * Sets the value of D-pad left
  49302. */
  49303. set dPadLeft(value: number);
  49304. /**
  49305. * Gets the value of D-pad right
  49306. */
  49307. get dPadRight(): number;
  49308. /**
  49309. * Sets the value of D-pad right
  49310. */
  49311. set dPadRight(value: number);
  49312. /**
  49313. * Force the gamepad to synchronize with device values
  49314. */
  49315. update(): void;
  49316. /**
  49317. * Disposes the gamepad
  49318. */
  49319. dispose(): void;
  49320. }
  49321. }
  49322. declare module BABYLON {
  49323. /**
  49324. * Defines supported buttons for DualShock compatible gamepads
  49325. */
  49326. export enum DualShockButton {
  49327. /** Cross */
  49328. Cross = 0,
  49329. /** Circle */
  49330. Circle = 1,
  49331. /** Square */
  49332. Square = 2,
  49333. /** Triangle */
  49334. Triangle = 3,
  49335. /** L1 */
  49336. L1 = 4,
  49337. /** R1 */
  49338. R1 = 5,
  49339. /** Share */
  49340. Share = 8,
  49341. /** Options */
  49342. Options = 9,
  49343. /** Left stick */
  49344. LeftStick = 10,
  49345. /** Right stick */
  49346. RightStick = 11
  49347. }
  49348. /** Defines values for DualShock DPad */
  49349. export enum DualShockDpad {
  49350. /** Up */
  49351. Up = 12,
  49352. /** Down */
  49353. Down = 13,
  49354. /** Left */
  49355. Left = 14,
  49356. /** Right */
  49357. Right = 15
  49358. }
  49359. /**
  49360. * Defines a DualShock gamepad
  49361. */
  49362. export class DualShockPad extends Gamepad {
  49363. private _leftTrigger;
  49364. private _rightTrigger;
  49365. private _onlefttriggerchanged;
  49366. private _onrighttriggerchanged;
  49367. private _onbuttondown;
  49368. private _onbuttonup;
  49369. private _ondpaddown;
  49370. private _ondpadup;
  49371. /** Observable raised when a button is pressed */
  49372. onButtonDownObservable: Observable<DualShockButton>;
  49373. /** Observable raised when a button is released */
  49374. onButtonUpObservable: Observable<DualShockButton>;
  49375. /** Observable raised when a pad is pressed */
  49376. onPadDownObservable: Observable<DualShockDpad>;
  49377. /** Observable raised when a pad is released */
  49378. onPadUpObservable: Observable<DualShockDpad>;
  49379. private _buttonCross;
  49380. private _buttonCircle;
  49381. private _buttonSquare;
  49382. private _buttonTriangle;
  49383. private _buttonShare;
  49384. private _buttonOptions;
  49385. private _buttonL1;
  49386. private _buttonR1;
  49387. private _buttonLeftStick;
  49388. private _buttonRightStick;
  49389. private _dPadUp;
  49390. private _dPadDown;
  49391. private _dPadLeft;
  49392. private _dPadRight;
  49393. /**
  49394. * Creates a new DualShock gamepad object
  49395. * @param id defines the id of this gamepad
  49396. * @param index defines its index
  49397. * @param gamepad defines the internal HTML gamepad object
  49398. */
  49399. constructor(id: string, index: number, gamepad: any);
  49400. /**
  49401. * Defines the callback to call when left trigger is pressed
  49402. * @param callback defines the callback to use
  49403. */
  49404. onlefttriggerchanged(callback: (value: number) => void): void;
  49405. /**
  49406. * Defines the callback to call when right trigger is pressed
  49407. * @param callback defines the callback to use
  49408. */
  49409. onrighttriggerchanged(callback: (value: number) => void): void;
  49410. /**
  49411. * Gets the left trigger value
  49412. */
  49413. get leftTrigger(): number;
  49414. /**
  49415. * Sets the left trigger value
  49416. */
  49417. set leftTrigger(newValue: number);
  49418. /**
  49419. * Gets the right trigger value
  49420. */
  49421. get rightTrigger(): number;
  49422. /**
  49423. * Sets the right trigger value
  49424. */
  49425. set rightTrigger(newValue: number);
  49426. /**
  49427. * Defines the callback to call when a button is pressed
  49428. * @param callback defines the callback to use
  49429. */
  49430. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49431. /**
  49432. * Defines the callback to call when a button is released
  49433. * @param callback defines the callback to use
  49434. */
  49435. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49436. /**
  49437. * Defines the callback to call when a pad is pressed
  49438. * @param callback defines the callback to use
  49439. */
  49440. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49441. /**
  49442. * Defines the callback to call when a pad is released
  49443. * @param callback defines the callback to use
  49444. */
  49445. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49446. private _setButtonValue;
  49447. private _setDPadValue;
  49448. /**
  49449. * Gets the value of the `Cross` button
  49450. */
  49451. get buttonCross(): number;
  49452. /**
  49453. * Sets the value of the `Cross` button
  49454. */
  49455. set buttonCross(value: number);
  49456. /**
  49457. * Gets the value of the `Circle` button
  49458. */
  49459. get buttonCircle(): number;
  49460. /**
  49461. * Sets the value of the `Circle` button
  49462. */
  49463. set buttonCircle(value: number);
  49464. /**
  49465. * Gets the value of the `Square` button
  49466. */
  49467. get buttonSquare(): number;
  49468. /**
  49469. * Sets the value of the `Square` button
  49470. */
  49471. set buttonSquare(value: number);
  49472. /**
  49473. * Gets the value of the `Triangle` button
  49474. */
  49475. get buttonTriangle(): number;
  49476. /**
  49477. * Sets the value of the `Triangle` button
  49478. */
  49479. set buttonTriangle(value: number);
  49480. /**
  49481. * Gets the value of the `Options` button
  49482. */
  49483. get buttonOptions(): number;
  49484. /**
  49485. * Sets the value of the `Options` button
  49486. */
  49487. set buttonOptions(value: number);
  49488. /**
  49489. * Gets the value of the `Share` button
  49490. */
  49491. get buttonShare(): number;
  49492. /**
  49493. * Sets the value of the `Share` button
  49494. */
  49495. set buttonShare(value: number);
  49496. /**
  49497. * Gets the value of the `L1` button
  49498. */
  49499. get buttonL1(): number;
  49500. /**
  49501. * Sets the value of the `L1` button
  49502. */
  49503. set buttonL1(value: number);
  49504. /**
  49505. * Gets the value of the `R1` button
  49506. */
  49507. get buttonR1(): number;
  49508. /**
  49509. * Sets the value of the `R1` button
  49510. */
  49511. set buttonR1(value: number);
  49512. /**
  49513. * Gets the value of the Left joystick
  49514. */
  49515. get buttonLeftStick(): number;
  49516. /**
  49517. * Sets the value of the Left joystick
  49518. */
  49519. set buttonLeftStick(value: number);
  49520. /**
  49521. * Gets the value of the Right joystick
  49522. */
  49523. get buttonRightStick(): number;
  49524. /**
  49525. * Sets the value of the Right joystick
  49526. */
  49527. set buttonRightStick(value: number);
  49528. /**
  49529. * Gets the value of D-pad up
  49530. */
  49531. get dPadUp(): number;
  49532. /**
  49533. * Sets the value of D-pad up
  49534. */
  49535. set dPadUp(value: number);
  49536. /**
  49537. * Gets the value of D-pad down
  49538. */
  49539. get dPadDown(): number;
  49540. /**
  49541. * Sets the value of D-pad down
  49542. */
  49543. set dPadDown(value: number);
  49544. /**
  49545. * Gets the value of D-pad left
  49546. */
  49547. get dPadLeft(): number;
  49548. /**
  49549. * Sets the value of D-pad left
  49550. */
  49551. set dPadLeft(value: number);
  49552. /**
  49553. * Gets the value of D-pad right
  49554. */
  49555. get dPadRight(): number;
  49556. /**
  49557. * Sets the value of D-pad right
  49558. */
  49559. set dPadRight(value: number);
  49560. /**
  49561. * Force the gamepad to synchronize with device values
  49562. */
  49563. update(): void;
  49564. /**
  49565. * Disposes the gamepad
  49566. */
  49567. dispose(): void;
  49568. }
  49569. }
  49570. declare module BABYLON {
  49571. /**
  49572. * Manager for handling gamepads
  49573. */
  49574. export class GamepadManager {
  49575. private _scene?;
  49576. private _babylonGamepads;
  49577. private _oneGamepadConnected;
  49578. /** @hidden */
  49579. _isMonitoring: boolean;
  49580. private _gamepadEventSupported;
  49581. private _gamepadSupport?;
  49582. /**
  49583. * observable to be triggered when the gamepad controller has been connected
  49584. */
  49585. onGamepadConnectedObservable: Observable<Gamepad>;
  49586. /**
  49587. * observable to be triggered when the gamepad controller has been disconnected
  49588. */
  49589. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49590. private _onGamepadConnectedEvent;
  49591. private _onGamepadDisconnectedEvent;
  49592. /**
  49593. * Initializes the gamepad manager
  49594. * @param _scene BabylonJS scene
  49595. */
  49596. constructor(_scene?: Scene | undefined);
  49597. /**
  49598. * The gamepads in the game pad manager
  49599. */
  49600. get gamepads(): Gamepad[];
  49601. /**
  49602. * Get the gamepad controllers based on type
  49603. * @param type The type of gamepad controller
  49604. * @returns Nullable gamepad
  49605. */
  49606. getGamepadByType(type?: number): Nullable<Gamepad>;
  49607. /**
  49608. * Disposes the gamepad manager
  49609. */
  49610. dispose(): void;
  49611. private _addNewGamepad;
  49612. private _startMonitoringGamepads;
  49613. private _stopMonitoringGamepads;
  49614. /** @hidden */
  49615. _checkGamepadsStatus(): void;
  49616. private _updateGamepadObjects;
  49617. }
  49618. }
  49619. declare module BABYLON {
  49620. interface Scene {
  49621. /** @hidden */
  49622. _gamepadManager: Nullable<GamepadManager>;
  49623. /**
  49624. * Gets the gamepad manager associated with the scene
  49625. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49626. */
  49627. gamepadManager: GamepadManager;
  49628. }
  49629. /**
  49630. * Interface representing a free camera inputs manager
  49631. */
  49632. interface FreeCameraInputsManager {
  49633. /**
  49634. * Adds gamepad input support to the FreeCameraInputsManager.
  49635. * @returns the FreeCameraInputsManager
  49636. */
  49637. addGamepad(): FreeCameraInputsManager;
  49638. }
  49639. /**
  49640. * Interface representing an arc rotate camera inputs manager
  49641. */
  49642. interface ArcRotateCameraInputsManager {
  49643. /**
  49644. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49645. * @returns the camera inputs manager
  49646. */
  49647. addGamepad(): ArcRotateCameraInputsManager;
  49648. }
  49649. /**
  49650. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49651. */
  49652. export class GamepadSystemSceneComponent implements ISceneComponent {
  49653. /**
  49654. * The component name helpfull to identify the component in the list of scene components.
  49655. */
  49656. readonly name: string;
  49657. /**
  49658. * The scene the component belongs to.
  49659. */
  49660. scene: Scene;
  49661. /**
  49662. * Creates a new instance of the component for the given scene
  49663. * @param scene Defines the scene to register the component in
  49664. */
  49665. constructor(scene: Scene);
  49666. /**
  49667. * Registers the component in a given scene
  49668. */
  49669. register(): void;
  49670. /**
  49671. * Rebuilds the elements related to this component in case of
  49672. * context lost for instance.
  49673. */
  49674. rebuild(): void;
  49675. /**
  49676. * Disposes the component and the associated ressources
  49677. */
  49678. dispose(): void;
  49679. private _beforeCameraUpdate;
  49680. }
  49681. }
  49682. declare module BABYLON {
  49683. /**
  49684. * 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,
  49685. * which still works and will still be found in many Playgrounds.
  49686. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49687. */
  49688. export class UniversalCamera extends TouchCamera {
  49689. /**
  49690. * Defines the gamepad rotation sensiblity.
  49691. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49692. */
  49693. get gamepadAngularSensibility(): number;
  49694. set gamepadAngularSensibility(value: number);
  49695. /**
  49696. * Defines the gamepad move sensiblity.
  49697. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49698. */
  49699. get gamepadMoveSensibility(): number;
  49700. set gamepadMoveSensibility(value: number);
  49701. /**
  49702. * 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,
  49703. * which still works and will still be found in many Playgrounds.
  49704. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49705. * @param name Define the name of the camera in the scene
  49706. * @param position Define the start position of the camera in the scene
  49707. * @param scene Define the scene the camera belongs to
  49708. */
  49709. constructor(name: string, position: Vector3, scene: Scene);
  49710. /**
  49711. * Gets the current object class name.
  49712. * @return the class name
  49713. */
  49714. getClassName(): string;
  49715. }
  49716. }
  49717. declare module BABYLON {
  49718. /**
  49719. * This represents a FPS type of camera. This is only here for back compat purpose.
  49720. * Please use the UniversalCamera instead as both are identical.
  49721. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49722. */
  49723. export class GamepadCamera extends UniversalCamera {
  49724. /**
  49725. * Instantiates a new Gamepad Camera
  49726. * This represents a FPS type of camera. This is only here for back compat purpose.
  49727. * Please use the UniversalCamera instead as both are identical.
  49728. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49729. * @param name Define the name of the camera in the scene
  49730. * @param position Define the start position of the camera in the scene
  49731. * @param scene Define the scene the camera belongs to
  49732. */
  49733. constructor(name: string, position: Vector3, scene: Scene);
  49734. /**
  49735. * Gets the current object class name.
  49736. * @return the class name
  49737. */
  49738. getClassName(): string;
  49739. }
  49740. }
  49741. declare module BABYLON {
  49742. /** @hidden */
  49743. export var passPixelShader: {
  49744. name: string;
  49745. shader: string;
  49746. };
  49747. }
  49748. declare module BABYLON {
  49749. /** @hidden */
  49750. export var passCubePixelShader: {
  49751. name: string;
  49752. shader: string;
  49753. };
  49754. }
  49755. declare module BABYLON {
  49756. /**
  49757. * PassPostProcess which produces an output the same as it's input
  49758. */
  49759. export class PassPostProcess extends PostProcess {
  49760. /**
  49761. * Gets a string identifying the name of the class
  49762. * @returns "PassPostProcess" string
  49763. */
  49764. getClassName(): string;
  49765. /**
  49766. * Creates the PassPostProcess
  49767. * @param name The name of the effect.
  49768. * @param options The required width/height ratio to downsize to before computing the render pass.
  49769. * @param camera The camera to apply the render pass to.
  49770. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49771. * @param engine The engine which the post process will be applied. (default: current engine)
  49772. * @param reusable If the post process can be reused on the same frame. (default: false)
  49773. * @param textureType The type of texture to be used when performing the post processing.
  49774. * @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)
  49775. */
  49776. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49777. /** @hidden */
  49778. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49779. }
  49780. /**
  49781. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49782. */
  49783. export class PassCubePostProcess extends PostProcess {
  49784. private _face;
  49785. /**
  49786. * Gets or sets the cube face to display.
  49787. * * 0 is +X
  49788. * * 1 is -X
  49789. * * 2 is +Y
  49790. * * 3 is -Y
  49791. * * 4 is +Z
  49792. * * 5 is -Z
  49793. */
  49794. get face(): number;
  49795. set face(value: number);
  49796. /**
  49797. * Gets a string identifying the name of the class
  49798. * @returns "PassCubePostProcess" string
  49799. */
  49800. getClassName(): string;
  49801. /**
  49802. * Creates the PassCubePostProcess
  49803. * @param name The name of the effect.
  49804. * @param options The required width/height ratio to downsize to before computing the render pass.
  49805. * @param camera The camera to apply the render pass to.
  49806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49807. * @param engine The engine which the post process will be applied. (default: current engine)
  49808. * @param reusable If the post process can be reused on the same frame. (default: false)
  49809. * @param textureType The type of texture to be used when performing the post processing.
  49810. * @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)
  49811. */
  49812. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49813. /** @hidden */
  49814. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49815. }
  49816. }
  49817. declare module BABYLON {
  49818. /** @hidden */
  49819. export var anaglyphPixelShader: {
  49820. name: string;
  49821. shader: string;
  49822. };
  49823. }
  49824. declare module BABYLON {
  49825. /**
  49826. * Postprocess used to generate anaglyphic rendering
  49827. */
  49828. export class AnaglyphPostProcess extends PostProcess {
  49829. private _passedProcess;
  49830. /**
  49831. * Gets a string identifying the name of the class
  49832. * @returns "AnaglyphPostProcess" string
  49833. */
  49834. getClassName(): string;
  49835. /**
  49836. * Creates a new AnaglyphPostProcess
  49837. * @param name defines postprocess name
  49838. * @param options defines creation options or target ratio scale
  49839. * @param rigCameras defines cameras using this postprocess
  49840. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49841. * @param engine defines hosting engine
  49842. * @param reusable defines if the postprocess will be reused multiple times per frame
  49843. */
  49844. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49845. }
  49846. }
  49847. declare module BABYLON {
  49848. /**
  49849. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49850. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49851. */
  49852. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49853. /**
  49854. * Creates a new AnaglyphArcRotateCamera
  49855. * @param name defines camera name
  49856. * @param alpha defines alpha angle (in radians)
  49857. * @param beta defines beta angle (in radians)
  49858. * @param radius defines radius
  49859. * @param target defines camera target
  49860. * @param interaxialDistance defines distance between each color axis
  49861. * @param scene defines the hosting scene
  49862. */
  49863. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49864. /**
  49865. * Gets camera class name
  49866. * @returns AnaglyphArcRotateCamera
  49867. */
  49868. getClassName(): string;
  49869. }
  49870. }
  49871. declare module BABYLON {
  49872. /**
  49873. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49874. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49875. */
  49876. export class AnaglyphFreeCamera extends FreeCamera {
  49877. /**
  49878. * Creates a new AnaglyphFreeCamera
  49879. * @param name defines camera name
  49880. * @param position defines initial position
  49881. * @param interaxialDistance defines distance between each color axis
  49882. * @param scene defines the hosting scene
  49883. */
  49884. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49885. /**
  49886. * Gets camera class name
  49887. * @returns AnaglyphFreeCamera
  49888. */
  49889. getClassName(): string;
  49890. }
  49891. }
  49892. declare module BABYLON {
  49893. /**
  49894. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49895. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49896. */
  49897. export class AnaglyphGamepadCamera extends GamepadCamera {
  49898. /**
  49899. * Creates a new AnaglyphGamepadCamera
  49900. * @param name defines camera name
  49901. * @param position defines initial position
  49902. * @param interaxialDistance defines distance between each color axis
  49903. * @param scene defines the hosting scene
  49904. */
  49905. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49906. /**
  49907. * Gets camera class name
  49908. * @returns AnaglyphGamepadCamera
  49909. */
  49910. getClassName(): string;
  49911. }
  49912. }
  49913. declare module BABYLON {
  49914. /**
  49915. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49916. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49917. */
  49918. export class AnaglyphUniversalCamera extends UniversalCamera {
  49919. /**
  49920. * Creates a new AnaglyphUniversalCamera
  49921. * @param name defines camera name
  49922. * @param position defines initial position
  49923. * @param interaxialDistance defines distance between each color axis
  49924. * @param scene defines the hosting scene
  49925. */
  49926. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49927. /**
  49928. * Gets camera class name
  49929. * @returns AnaglyphUniversalCamera
  49930. */
  49931. getClassName(): string;
  49932. }
  49933. }
  49934. declare module BABYLON {
  49935. /**
  49936. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49937. * @see https://doc.babylonjs.com/features/cameras
  49938. */
  49939. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49940. /**
  49941. * Creates a new StereoscopicArcRotateCamera
  49942. * @param name defines camera name
  49943. * @param alpha defines alpha angle (in radians)
  49944. * @param beta defines beta angle (in radians)
  49945. * @param radius defines radius
  49946. * @param target defines camera target
  49947. * @param interaxialDistance defines distance between each color axis
  49948. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49949. * @param scene defines the hosting scene
  49950. */
  49951. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49952. /**
  49953. * Gets camera class name
  49954. * @returns StereoscopicArcRotateCamera
  49955. */
  49956. getClassName(): string;
  49957. }
  49958. }
  49959. declare module BABYLON {
  49960. /**
  49961. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49962. * @see https://doc.babylonjs.com/features/cameras
  49963. */
  49964. export class StereoscopicFreeCamera extends FreeCamera {
  49965. /**
  49966. * Creates a new StereoscopicFreeCamera
  49967. * @param name defines camera name
  49968. * @param position defines initial position
  49969. * @param interaxialDistance defines distance between each color axis
  49970. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49971. * @param scene defines the hosting scene
  49972. */
  49973. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49974. /**
  49975. * Gets camera class name
  49976. * @returns StereoscopicFreeCamera
  49977. */
  49978. getClassName(): string;
  49979. }
  49980. }
  49981. declare module BABYLON {
  49982. /**
  49983. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49984. * @see https://doc.babylonjs.com/features/cameras
  49985. */
  49986. export class StereoscopicGamepadCamera extends GamepadCamera {
  49987. /**
  49988. * Creates a new StereoscopicGamepadCamera
  49989. * @param name defines camera name
  49990. * @param position defines initial position
  49991. * @param interaxialDistance defines distance between each color axis
  49992. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49993. * @param scene defines the hosting scene
  49994. */
  49995. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49996. /**
  49997. * Gets camera class name
  49998. * @returns StereoscopicGamepadCamera
  49999. */
  50000. getClassName(): string;
  50001. }
  50002. }
  50003. declare module BABYLON {
  50004. /**
  50005. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  50006. * @see https://doc.babylonjs.com/features/cameras
  50007. */
  50008. export class StereoscopicUniversalCamera extends UniversalCamera {
  50009. /**
  50010. * Creates a new StereoscopicUniversalCamera
  50011. * @param name defines camera name
  50012. * @param position defines initial position
  50013. * @param interaxialDistance defines distance between each color axis
  50014. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  50015. * @param scene defines the hosting scene
  50016. */
  50017. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  50018. /**
  50019. * Gets camera class name
  50020. * @returns StereoscopicUniversalCamera
  50021. */
  50022. getClassName(): string;
  50023. }
  50024. }
  50025. declare module BABYLON {
  50026. /**
  50027. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  50028. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  50029. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  50030. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  50031. */
  50032. export class VirtualJoysticksCamera extends FreeCamera {
  50033. /**
  50034. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  50035. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  50036. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  50037. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  50038. * @param name Define the name of the camera in the scene
  50039. * @param position Define the start position of the camera in the scene
  50040. * @param scene Define the scene the camera belongs to
  50041. */
  50042. constructor(name: string, position: Vector3, scene: Scene);
  50043. /**
  50044. * Gets the current object class name.
  50045. * @return the class name
  50046. */
  50047. getClassName(): string;
  50048. }
  50049. }
  50050. declare module BABYLON {
  50051. /**
  50052. * This represents all the required metrics to create a VR camera.
  50053. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  50054. */
  50055. export class VRCameraMetrics {
  50056. /**
  50057. * Define the horizontal resolution off the screen.
  50058. */
  50059. hResolution: number;
  50060. /**
  50061. * Define the vertical resolution off the screen.
  50062. */
  50063. vResolution: number;
  50064. /**
  50065. * Define the horizontal screen size.
  50066. */
  50067. hScreenSize: number;
  50068. /**
  50069. * Define the vertical screen size.
  50070. */
  50071. vScreenSize: number;
  50072. /**
  50073. * Define the vertical screen center position.
  50074. */
  50075. vScreenCenter: number;
  50076. /**
  50077. * Define the distance of the eyes to the screen.
  50078. */
  50079. eyeToScreenDistance: number;
  50080. /**
  50081. * Define the distance between both lenses
  50082. */
  50083. lensSeparationDistance: number;
  50084. /**
  50085. * Define the distance between both viewer's eyes.
  50086. */
  50087. interpupillaryDistance: number;
  50088. /**
  50089. * Define the distortion factor of the VR postprocess.
  50090. * Please, touch with care.
  50091. */
  50092. distortionK: number[];
  50093. /**
  50094. * Define the chromatic aberration correction factors for the VR post process.
  50095. */
  50096. chromaAbCorrection: number[];
  50097. /**
  50098. * Define the scale factor of the post process.
  50099. * The smaller the better but the slower.
  50100. */
  50101. postProcessScaleFactor: number;
  50102. /**
  50103. * Define an offset for the lens center.
  50104. */
  50105. lensCenterOffset: number;
  50106. /**
  50107. * Define if the current vr camera should compensate the distortion of the lense or not.
  50108. */
  50109. compensateDistortion: boolean;
  50110. /**
  50111. * Defines if multiview should be enabled when rendering (Default: false)
  50112. */
  50113. multiviewEnabled: boolean;
  50114. /**
  50115. * Gets the rendering aspect ratio based on the provided resolutions.
  50116. */
  50117. get aspectRatio(): number;
  50118. /**
  50119. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  50120. */
  50121. get aspectRatioFov(): number;
  50122. /**
  50123. * @hidden
  50124. */
  50125. get leftHMatrix(): Matrix;
  50126. /**
  50127. * @hidden
  50128. */
  50129. get rightHMatrix(): Matrix;
  50130. /**
  50131. * @hidden
  50132. */
  50133. get leftPreViewMatrix(): Matrix;
  50134. /**
  50135. * @hidden
  50136. */
  50137. get rightPreViewMatrix(): Matrix;
  50138. /**
  50139. * Get the default VRMetrics based on the most generic setup.
  50140. * @returns the default vr metrics
  50141. */
  50142. static GetDefault(): VRCameraMetrics;
  50143. }
  50144. }
  50145. declare module BABYLON {
  50146. /** @hidden */
  50147. export var vrDistortionCorrectionPixelShader: {
  50148. name: string;
  50149. shader: string;
  50150. };
  50151. }
  50152. declare module BABYLON {
  50153. /**
  50154. * VRDistortionCorrectionPostProcess used for mobile VR
  50155. */
  50156. export class VRDistortionCorrectionPostProcess extends PostProcess {
  50157. private _isRightEye;
  50158. private _distortionFactors;
  50159. private _postProcessScaleFactor;
  50160. private _lensCenterOffset;
  50161. private _scaleIn;
  50162. private _scaleFactor;
  50163. private _lensCenter;
  50164. /**
  50165. * Gets a string identifying the name of the class
  50166. * @returns "VRDistortionCorrectionPostProcess" string
  50167. */
  50168. getClassName(): string;
  50169. /**
  50170. * Initializes the VRDistortionCorrectionPostProcess
  50171. * @param name The name of the effect.
  50172. * @param camera The camera to apply the render pass to.
  50173. * @param isRightEye If this is for the right eye distortion
  50174. * @param vrMetrics All the required metrics for the VR camera
  50175. */
  50176. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  50177. }
  50178. }
  50179. declare module BABYLON {
  50180. /**
  50181. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  50182. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50183. */
  50184. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  50185. /**
  50186. * Creates a new VRDeviceOrientationArcRotateCamera
  50187. * @param name defines camera name
  50188. * @param alpha defines the camera rotation along the logitudinal axis
  50189. * @param beta defines the camera rotation along the latitudinal axis
  50190. * @param radius defines the camera distance from its target
  50191. * @param target defines the camera target
  50192. * @param scene defines the scene the camera belongs to
  50193. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50194. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50195. */
  50196. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50197. /**
  50198. * Gets camera class name
  50199. * @returns VRDeviceOrientationArcRotateCamera
  50200. */
  50201. getClassName(): string;
  50202. }
  50203. }
  50204. declare module BABYLON {
  50205. /**
  50206. * Camera used to simulate VR rendering (based on FreeCamera)
  50207. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50208. */
  50209. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  50210. /**
  50211. * Creates a new VRDeviceOrientationFreeCamera
  50212. * @param name defines camera name
  50213. * @param position defines the start position of the camera
  50214. * @param scene defines the scene the camera belongs to
  50215. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50216. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50217. */
  50218. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50219. /**
  50220. * Gets camera class name
  50221. * @returns VRDeviceOrientationFreeCamera
  50222. */
  50223. getClassName(): string;
  50224. }
  50225. }
  50226. declare module BABYLON {
  50227. /**
  50228. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  50229. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50230. */
  50231. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  50232. /**
  50233. * Creates a new VRDeviceOrientationGamepadCamera
  50234. * @param name defines camera name
  50235. * @param position defines the start position of the camera
  50236. * @param scene defines the scene the camera belongs to
  50237. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50238. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50239. */
  50240. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50241. /**
  50242. * Gets camera class name
  50243. * @returns VRDeviceOrientationGamepadCamera
  50244. */
  50245. getClassName(): string;
  50246. }
  50247. }
  50248. declare module BABYLON {
  50249. /**
  50250. * A class extending Texture allowing drawing on a texture
  50251. * @see https://doc.babylonjs.com/how_to/dynamictexture
  50252. */
  50253. export class DynamicTexture extends Texture {
  50254. private _generateMipMaps;
  50255. private _canvas;
  50256. private _context;
  50257. /**
  50258. * Creates a DynamicTexture
  50259. * @param name defines the name of the texture
  50260. * @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
  50261. * @param scene defines the scene where you want the texture
  50262. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  50263. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  50264. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  50265. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  50266. */
  50267. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  50268. /**
  50269. * Get the current class name of the texture useful for serialization or dynamic coding.
  50270. * @returns "DynamicTexture"
  50271. */
  50272. getClassName(): string;
  50273. /**
  50274. * Gets the current state of canRescale
  50275. */
  50276. get canRescale(): boolean;
  50277. private _recreate;
  50278. /**
  50279. * Scales the texture
  50280. * @param ratio the scale factor to apply to both width and height
  50281. */
  50282. scale(ratio: number): void;
  50283. /**
  50284. * Resizes the texture
  50285. * @param width the new width
  50286. * @param height the new height
  50287. */
  50288. scaleTo(width: number, height: number): void;
  50289. /**
  50290. * Gets the context of the canvas used by the texture
  50291. * @returns the canvas context of the dynamic texture
  50292. */
  50293. getContext(): CanvasRenderingContext2D;
  50294. /**
  50295. * Clears the texture
  50296. */
  50297. clear(): void;
  50298. /**
  50299. * Updates the texture
  50300. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50301. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  50302. */
  50303. update(invertY?: boolean, premulAlpha?: boolean): void;
  50304. /**
  50305. * Draws text onto the texture
  50306. * @param text defines the text to be drawn
  50307. * @param x defines the placement of the text from the left
  50308. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  50309. * @param font defines the font to be used with font-style, font-size, font-name
  50310. * @param color defines the color used for the text
  50311. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  50312. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50313. * @param update defines whether texture is immediately update (default is true)
  50314. */
  50315. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  50316. /**
  50317. * Clones the texture
  50318. * @returns the clone of the texture.
  50319. */
  50320. clone(): DynamicTexture;
  50321. /**
  50322. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  50323. * @returns a serialized dynamic texture object
  50324. */
  50325. serialize(): any;
  50326. private _IsCanvasElement;
  50327. /** @hidden */
  50328. _rebuild(): void;
  50329. }
  50330. }
  50331. declare module BABYLON {
  50332. /**
  50333. * Class containing static functions to help procedurally build meshes
  50334. */
  50335. export class GroundBuilder {
  50336. /**
  50337. * Creates a ground mesh
  50338. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50339. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50341. * @param name defines the name of the mesh
  50342. * @param options defines the options used to create the mesh
  50343. * @param scene defines the hosting scene
  50344. * @returns the ground mesh
  50345. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50346. */
  50347. static CreateGround(name: string, options: {
  50348. width?: number;
  50349. height?: number;
  50350. subdivisions?: number;
  50351. subdivisionsX?: number;
  50352. subdivisionsY?: number;
  50353. updatable?: boolean;
  50354. }, scene: any): Mesh;
  50355. /**
  50356. * Creates a tiled ground mesh
  50357. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50358. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50359. * * 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
  50360. * * 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
  50361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50362. * @param name defines the name of the mesh
  50363. * @param options defines the options used to create the mesh
  50364. * @param scene defines the hosting scene
  50365. * @returns the tiled ground mesh
  50366. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50367. */
  50368. static CreateTiledGround(name: string, options: {
  50369. xmin: number;
  50370. zmin: number;
  50371. xmax: number;
  50372. zmax: number;
  50373. subdivisions?: {
  50374. w: number;
  50375. h: number;
  50376. };
  50377. precision?: {
  50378. w: number;
  50379. h: number;
  50380. };
  50381. updatable?: boolean;
  50382. }, scene?: Nullable<Scene>): Mesh;
  50383. /**
  50384. * Creates a ground mesh from a height map
  50385. * * The parameter `url` sets the URL of the height map image resource.
  50386. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50387. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50388. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50389. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50390. * * 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.
  50391. * * 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).
  50392. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50394. * @param name defines the name of the mesh
  50395. * @param url defines the url to the height map
  50396. * @param options defines the options used to create the mesh
  50397. * @param scene defines the hosting scene
  50398. * @returns the ground mesh
  50399. * @see https://doc.babylonjs.com/babylon101/height_map
  50400. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50401. */
  50402. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50403. width?: number;
  50404. height?: number;
  50405. subdivisions?: number;
  50406. minHeight?: number;
  50407. maxHeight?: number;
  50408. colorFilter?: Color3;
  50409. alphaFilter?: number;
  50410. updatable?: boolean;
  50411. onReady?: (mesh: GroundMesh) => void;
  50412. }, scene?: Nullable<Scene>): GroundMesh;
  50413. }
  50414. }
  50415. declare module BABYLON {
  50416. /**
  50417. * Class containing static functions to help procedurally build meshes
  50418. */
  50419. export class TorusBuilder {
  50420. /**
  50421. * Creates a torus mesh
  50422. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50423. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50424. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50426. * * 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
  50427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50428. * @param name defines the name of the mesh
  50429. * @param options defines the options used to create the mesh
  50430. * @param scene defines the hosting scene
  50431. * @returns the torus mesh
  50432. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50433. */
  50434. static CreateTorus(name: string, options: {
  50435. diameter?: number;
  50436. thickness?: number;
  50437. tessellation?: number;
  50438. updatable?: boolean;
  50439. sideOrientation?: number;
  50440. frontUVs?: Vector4;
  50441. backUVs?: Vector4;
  50442. }, scene: any): Mesh;
  50443. }
  50444. }
  50445. declare module BABYLON {
  50446. /**
  50447. * Class containing static functions to help procedurally build meshes
  50448. */
  50449. export class CylinderBuilder {
  50450. /**
  50451. * Creates a cylinder or a cone mesh
  50452. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50453. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50454. * * 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.
  50455. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50456. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50457. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50458. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50459. * * 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).
  50460. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50461. * * 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).
  50462. * * 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
  50463. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50464. * * 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
  50465. * * 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.
  50466. * * If `enclose` is false, a ring surface is one element.
  50467. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50468. * * 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
  50469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50470. * * 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
  50471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50472. * @param name defines the name of the mesh
  50473. * @param options defines the options used to create the mesh
  50474. * @param scene defines the hosting scene
  50475. * @returns the cylinder mesh
  50476. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50477. */
  50478. static CreateCylinder(name: string, options: {
  50479. height?: number;
  50480. diameterTop?: number;
  50481. diameterBottom?: number;
  50482. diameter?: number;
  50483. tessellation?: number;
  50484. subdivisions?: number;
  50485. arc?: number;
  50486. faceColors?: Color4[];
  50487. faceUV?: Vector4[];
  50488. updatable?: boolean;
  50489. hasRings?: boolean;
  50490. enclose?: boolean;
  50491. cap?: number;
  50492. sideOrientation?: number;
  50493. frontUVs?: Vector4;
  50494. backUVs?: Vector4;
  50495. }, scene: any): Mesh;
  50496. }
  50497. }
  50498. declare module BABYLON {
  50499. /**
  50500. * States of the webXR experience
  50501. */
  50502. export enum WebXRState {
  50503. /**
  50504. * Transitioning to being in XR mode
  50505. */
  50506. ENTERING_XR = 0,
  50507. /**
  50508. * Transitioning to non XR mode
  50509. */
  50510. EXITING_XR = 1,
  50511. /**
  50512. * In XR mode and presenting
  50513. */
  50514. IN_XR = 2,
  50515. /**
  50516. * Not entered XR mode
  50517. */
  50518. NOT_IN_XR = 3
  50519. }
  50520. /**
  50521. * The state of the XR camera's tracking
  50522. */
  50523. export enum WebXRTrackingState {
  50524. /**
  50525. * No transformation received, device is not being tracked
  50526. */
  50527. NOT_TRACKING = 0,
  50528. /**
  50529. * Tracking lost - using emulated position
  50530. */
  50531. TRACKING_LOST = 1,
  50532. /**
  50533. * Transformation tracking works normally
  50534. */
  50535. TRACKING = 2
  50536. }
  50537. /**
  50538. * Abstraction of the XR render target
  50539. */
  50540. export interface WebXRRenderTarget extends IDisposable {
  50541. /**
  50542. * xrpresent context of the canvas which can be used to display/mirror xr content
  50543. */
  50544. canvasContext: WebGLRenderingContext;
  50545. /**
  50546. * xr layer for the canvas
  50547. */
  50548. xrLayer: Nullable<XRWebGLLayer>;
  50549. /**
  50550. * Initializes the xr layer for the session
  50551. * @param xrSession xr session
  50552. * @returns a promise that will resolve once the XR Layer has been created
  50553. */
  50554. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50555. }
  50556. }
  50557. declare module BABYLON {
  50558. /**
  50559. * COnfiguration object for WebXR output canvas
  50560. */
  50561. export class WebXRManagedOutputCanvasOptions {
  50562. /**
  50563. * An optional canvas in case you wish to create it yourself and provide it here.
  50564. * If not provided, a new canvas will be created
  50565. */
  50566. canvasElement?: HTMLCanvasElement;
  50567. /**
  50568. * Options for this XR Layer output
  50569. */
  50570. canvasOptions?: XRWebGLLayerInit;
  50571. /**
  50572. * CSS styling for a newly created canvas (if not provided)
  50573. */
  50574. newCanvasCssStyle?: string;
  50575. /**
  50576. * Get the default values of the configuration object
  50577. * @param engine defines the engine to use (can be null)
  50578. * @returns default values of this configuration object
  50579. */
  50580. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50581. }
  50582. /**
  50583. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50584. */
  50585. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50586. private _options;
  50587. private _canvas;
  50588. private _engine;
  50589. private _originalCanvasSize;
  50590. /**
  50591. * Rendering context of the canvas which can be used to display/mirror xr content
  50592. */
  50593. canvasContext: WebGLRenderingContext;
  50594. /**
  50595. * xr layer for the canvas
  50596. */
  50597. xrLayer: Nullable<XRWebGLLayer>;
  50598. /**
  50599. * Obseervers registered here will be triggered when the xr layer was initialized
  50600. */
  50601. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50602. /**
  50603. * Initializes the canvas to be added/removed upon entering/exiting xr
  50604. * @param _xrSessionManager The XR Session manager
  50605. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50606. */
  50607. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50608. /**
  50609. * Disposes of the object
  50610. */
  50611. dispose(): void;
  50612. /**
  50613. * Initializes the xr layer for the session
  50614. * @param xrSession xr session
  50615. * @returns a promise that will resolve once the XR Layer has been created
  50616. */
  50617. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50618. private _addCanvas;
  50619. private _removeCanvas;
  50620. private _setCanvasSize;
  50621. private _setManagedOutputCanvas;
  50622. }
  50623. }
  50624. declare module BABYLON {
  50625. /**
  50626. * Manages an XRSession to work with Babylon's engine
  50627. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50628. */
  50629. export class WebXRSessionManager implements IDisposable {
  50630. /** The scene which the session should be created for */
  50631. scene: Scene;
  50632. private _referenceSpace;
  50633. private _rttProvider;
  50634. private _sessionEnded;
  50635. private _xrNavigator;
  50636. private baseLayer;
  50637. /**
  50638. * The base reference space from which the session started. good if you want to reset your
  50639. * reference space
  50640. */
  50641. baseReferenceSpace: XRReferenceSpace;
  50642. /**
  50643. * Current XR frame
  50644. */
  50645. currentFrame: Nullable<XRFrame>;
  50646. /** WebXR timestamp updated every frame */
  50647. currentTimestamp: number;
  50648. /**
  50649. * Used just in case of a failure to initialize an immersive session.
  50650. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50651. */
  50652. defaultHeightCompensation: number;
  50653. /**
  50654. * Fires every time a new xrFrame arrives which can be used to update the camera
  50655. */
  50656. onXRFrameObservable: Observable<XRFrame>;
  50657. /**
  50658. * Fires when the reference space changed
  50659. */
  50660. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50661. /**
  50662. * Fires when the xr session is ended either by the device or manually done
  50663. */
  50664. onXRSessionEnded: Observable<any>;
  50665. /**
  50666. * Fires when the xr session is ended either by the device or manually done
  50667. */
  50668. onXRSessionInit: Observable<XRSession>;
  50669. /**
  50670. * Underlying xr session
  50671. */
  50672. session: XRSession;
  50673. /**
  50674. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50675. * or get the offset the player is currently at.
  50676. */
  50677. viewerReferenceSpace: XRReferenceSpace;
  50678. /**
  50679. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50680. * @param scene The scene which the session should be created for
  50681. */
  50682. constructor(
  50683. /** The scene which the session should be created for */
  50684. scene: Scene);
  50685. /**
  50686. * The current reference space used in this session. This reference space can constantly change!
  50687. * It is mainly used to offset the camera's position.
  50688. */
  50689. get referenceSpace(): XRReferenceSpace;
  50690. /**
  50691. * Set a new reference space and triggers the observable
  50692. */
  50693. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50694. /**
  50695. * Disposes of the session manager
  50696. */
  50697. dispose(): void;
  50698. /**
  50699. * Stops the xrSession and restores the render loop
  50700. * @returns Promise which resolves after it exits XR
  50701. */
  50702. exitXRAsync(): Promise<void>;
  50703. /**
  50704. * Gets the correct render target texture to be rendered this frame for this eye
  50705. * @param eye the eye for which to get the render target
  50706. * @returns the render target for the specified eye
  50707. */
  50708. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50709. /**
  50710. * Creates a WebXRRenderTarget object for the XR session
  50711. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50712. * @param options optional options to provide when creating a new render target
  50713. * @returns a WebXR render target to which the session can render
  50714. */
  50715. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50716. /**
  50717. * Initializes the manager
  50718. * After initialization enterXR can be called to start an XR session
  50719. * @returns Promise which resolves after it is initialized
  50720. */
  50721. initializeAsync(): Promise<void>;
  50722. /**
  50723. * Initializes an xr session
  50724. * @param xrSessionMode mode to initialize
  50725. * @param xrSessionInit defines optional and required values to pass to the session builder
  50726. * @returns a promise which will resolve once the session has been initialized
  50727. */
  50728. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50729. /**
  50730. * Checks if a session would be supported for the creation options specified
  50731. * @param sessionMode session mode to check if supported eg. immersive-vr
  50732. * @returns A Promise that resolves to true if supported and false if not
  50733. */
  50734. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50735. /**
  50736. * Resets the reference space to the one started the session
  50737. */
  50738. resetReferenceSpace(): void;
  50739. /**
  50740. * Starts rendering to the xr layer
  50741. */
  50742. runXRRenderLoop(): void;
  50743. /**
  50744. * Sets the reference space on the xr session
  50745. * @param referenceSpaceType space to set
  50746. * @returns a promise that will resolve once the reference space has been set
  50747. */
  50748. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50749. /**
  50750. * Updates the render state of the session
  50751. * @param state state to set
  50752. * @returns a promise that resolves once the render state has been updated
  50753. */
  50754. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50755. /**
  50756. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50757. * @param sessionMode defines the session to test
  50758. * @returns a promise with boolean as final value
  50759. */
  50760. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50761. private _createRenderTargetTexture;
  50762. }
  50763. }
  50764. declare module BABYLON {
  50765. /**
  50766. * WebXR Camera which holds the views for the xrSession
  50767. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50768. */
  50769. export class WebXRCamera extends FreeCamera {
  50770. private _xrSessionManager;
  50771. private _firstFrame;
  50772. private _referenceQuaternion;
  50773. private _referencedPosition;
  50774. private _xrInvPositionCache;
  50775. private _xrInvQuaternionCache;
  50776. private _trackingState;
  50777. /**
  50778. * Observable raised before camera teleportation
  50779. */
  50780. onBeforeCameraTeleport: Observable<Vector3>;
  50781. /**
  50782. * Observable raised after camera teleportation
  50783. */
  50784. onAfterCameraTeleport: Observable<Vector3>;
  50785. /**
  50786. * Notifies when the camera's tracking state has changed.
  50787. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50788. */
  50789. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50790. /**
  50791. * Should position compensation execute on first frame.
  50792. * This is used when copying the position from a native (non XR) camera
  50793. */
  50794. compensateOnFirstFrame: boolean;
  50795. /**
  50796. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50797. * @param name the name of the camera
  50798. * @param scene the scene to add the camera to
  50799. * @param _xrSessionManager a constructed xr session manager
  50800. */
  50801. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50802. /**
  50803. * Get the current XR tracking state of the camera
  50804. */
  50805. get trackingState(): WebXRTrackingState;
  50806. private _setTrackingState;
  50807. /**
  50808. * Return the user's height, unrelated to the current ground.
  50809. * This will be the y position of this camera, when ground level is 0.
  50810. */
  50811. get realWorldHeight(): number;
  50812. /** @hidden */
  50813. _updateForDualEyeDebugging(): void;
  50814. /**
  50815. * Sets this camera's transformation based on a non-vr camera
  50816. * @param otherCamera the non-vr camera to copy the transformation from
  50817. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50818. */
  50819. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50820. /**
  50821. * Gets the current instance class name ("WebXRCamera").
  50822. * @returns the class name
  50823. */
  50824. getClassName(): string;
  50825. private _rotate180;
  50826. private _updateFromXRSession;
  50827. private _updateNumberOfRigCameras;
  50828. private _updateReferenceSpace;
  50829. private _updateReferenceSpaceOffset;
  50830. }
  50831. }
  50832. declare module BABYLON {
  50833. /**
  50834. * Defining the interface required for a (webxr) feature
  50835. */
  50836. export interface IWebXRFeature extends IDisposable {
  50837. /**
  50838. * Is this feature attached
  50839. */
  50840. attached: boolean;
  50841. /**
  50842. * Should auto-attach be disabled?
  50843. */
  50844. disableAutoAttach: boolean;
  50845. /**
  50846. * Attach the feature to the session
  50847. * Will usually be called by the features manager
  50848. *
  50849. * @param force should attachment be forced (even when already attached)
  50850. * @returns true if successful.
  50851. */
  50852. attach(force?: boolean): boolean;
  50853. /**
  50854. * Detach the feature from the session
  50855. * Will usually be called by the features manager
  50856. *
  50857. * @returns true if successful.
  50858. */
  50859. detach(): boolean;
  50860. /**
  50861. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50862. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50863. *
  50864. * @returns whether or not the feature is compatible in this environment
  50865. */
  50866. isCompatible(): boolean;
  50867. /**
  50868. * Was this feature disposed;
  50869. */
  50870. isDisposed: boolean;
  50871. /**
  50872. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50873. */
  50874. xrNativeFeatureName?: string;
  50875. /**
  50876. * A list of (Babylon WebXR) features this feature depends on
  50877. */
  50878. dependsOn?: string[];
  50879. }
  50880. /**
  50881. * A list of the currently available features without referencing them
  50882. */
  50883. export class WebXRFeatureName {
  50884. /**
  50885. * The name of the anchor system feature
  50886. */
  50887. static readonly ANCHOR_SYSTEM: string;
  50888. /**
  50889. * The name of the background remover feature
  50890. */
  50891. static readonly BACKGROUND_REMOVER: string;
  50892. /**
  50893. * The name of the hit test feature
  50894. */
  50895. static readonly HIT_TEST: string;
  50896. /**
  50897. * physics impostors for xr controllers feature
  50898. */
  50899. static readonly PHYSICS_CONTROLLERS: string;
  50900. /**
  50901. * The name of the plane detection feature
  50902. */
  50903. static readonly PLANE_DETECTION: string;
  50904. /**
  50905. * The name of the pointer selection feature
  50906. */
  50907. static readonly POINTER_SELECTION: string;
  50908. /**
  50909. * The name of the teleportation feature
  50910. */
  50911. static readonly TELEPORTATION: string;
  50912. /**
  50913. * The name of the feature points feature.
  50914. */
  50915. static readonly FEATURE_POINTS: string;
  50916. /**
  50917. * The name of the hand tracking feature.
  50918. */
  50919. static readonly HAND_TRACKING: string;
  50920. }
  50921. /**
  50922. * Defining the constructor of a feature. Used to register the modules.
  50923. */
  50924. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50925. /**
  50926. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50927. * It is mainly used in AR sessions.
  50928. *
  50929. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50930. */
  50931. export class WebXRFeaturesManager implements IDisposable {
  50932. private _xrSessionManager;
  50933. private static readonly _AvailableFeatures;
  50934. private _features;
  50935. /**
  50936. * constructs a new features manages.
  50937. *
  50938. * @param _xrSessionManager an instance of WebXRSessionManager
  50939. */
  50940. constructor(_xrSessionManager: WebXRSessionManager);
  50941. /**
  50942. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50943. * Mainly used internally.
  50944. *
  50945. * @param featureName the name of the feature to register
  50946. * @param constructorFunction the function used to construct the module
  50947. * @param version the (babylon) version of the module
  50948. * @param stable is that a stable version of this module
  50949. */
  50950. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50951. /**
  50952. * Returns a constructor of a specific feature.
  50953. *
  50954. * @param featureName the name of the feature to construct
  50955. * @param version the version of the feature to load
  50956. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50957. * @param options optional options provided to the module.
  50958. * @returns a function that, when called, will return a new instance of this feature
  50959. */
  50960. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50961. /**
  50962. * Can be used to return the list of features currently registered
  50963. *
  50964. * @returns an Array of available features
  50965. */
  50966. static GetAvailableFeatures(): string[];
  50967. /**
  50968. * Gets the versions available for a specific feature
  50969. * @param featureName the name of the feature
  50970. * @returns an array with the available versions
  50971. */
  50972. static GetAvailableVersions(featureName: string): string[];
  50973. /**
  50974. * Return the latest unstable version of this feature
  50975. * @param featureName the name of the feature to search
  50976. * @returns the version number. if not found will return -1
  50977. */
  50978. static GetLatestVersionOfFeature(featureName: string): number;
  50979. /**
  50980. * Return the latest stable version of this feature
  50981. * @param featureName the name of the feature to search
  50982. * @returns the version number. if not found will return -1
  50983. */
  50984. static GetStableVersionOfFeature(featureName: string): number;
  50985. /**
  50986. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50987. * Can be used during a session to start a feature
  50988. * @param featureName the name of feature to attach
  50989. */
  50990. attachFeature(featureName: string): void;
  50991. /**
  50992. * Can be used inside a session or when the session ends to detach a specific feature
  50993. * @param featureName the name of the feature to detach
  50994. */
  50995. detachFeature(featureName: string): void;
  50996. /**
  50997. * Used to disable an already-enabled feature
  50998. * The feature will be disposed and will be recreated once enabled.
  50999. * @param featureName the feature to disable
  51000. * @returns true if disable was successful
  51001. */
  51002. disableFeature(featureName: string | {
  51003. Name: string;
  51004. }): boolean;
  51005. /**
  51006. * dispose this features manager
  51007. */
  51008. dispose(): void;
  51009. /**
  51010. * 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.
  51011. * 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.
  51012. *
  51013. * @param featureName the name of the feature to load or the class of the feature
  51014. * @param version optional version to load. if not provided the latest version will be enabled
  51015. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  51016. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  51017. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  51018. * @returns a new constructed feature or throws an error if feature not found.
  51019. */
  51020. enableFeature(featureName: string | {
  51021. Name: string;
  51022. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  51023. /**
  51024. * get the implementation of an enabled feature.
  51025. * @param featureName the name of the feature to load
  51026. * @returns the feature class, if found
  51027. */
  51028. getEnabledFeature(featureName: string): IWebXRFeature;
  51029. /**
  51030. * Get the list of enabled features
  51031. * @returns an array of enabled features
  51032. */
  51033. getEnabledFeatures(): string[];
  51034. /**
  51035. * This function will exten the session creation configuration object with enabled features.
  51036. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  51037. * according to the defined "required" variable, provided during enableFeature call
  51038. * @param xrSessionInit the xr Session init object to extend
  51039. *
  51040. * @returns an extended XRSessionInit object
  51041. */
  51042. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  51043. }
  51044. }
  51045. declare module BABYLON {
  51046. /**
  51047. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  51048. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  51049. */
  51050. export class WebXRExperienceHelper implements IDisposable {
  51051. private scene;
  51052. private _nonVRCamera;
  51053. private _originalSceneAutoClear;
  51054. private _supported;
  51055. /**
  51056. * Camera used to render xr content
  51057. */
  51058. camera: WebXRCamera;
  51059. /** A features manager for this xr session */
  51060. featuresManager: WebXRFeaturesManager;
  51061. /**
  51062. * Observers registered here will be triggered after the camera's initial transformation is set
  51063. * This can be used to set a different ground level or an extra rotation.
  51064. *
  51065. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  51066. * to the position set after this observable is done executing.
  51067. */
  51068. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  51069. /**
  51070. * Fires when the state of the experience helper has changed
  51071. */
  51072. onStateChangedObservable: Observable<WebXRState>;
  51073. /** Session manager used to keep track of xr session */
  51074. sessionManager: WebXRSessionManager;
  51075. /**
  51076. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  51077. */
  51078. state: WebXRState;
  51079. /**
  51080. * Creates a WebXRExperienceHelper
  51081. * @param scene The scene the helper should be created in
  51082. */
  51083. private constructor();
  51084. /**
  51085. * Creates the experience helper
  51086. * @param scene the scene to attach the experience helper to
  51087. * @returns a promise for the experience helper
  51088. */
  51089. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  51090. /**
  51091. * Disposes of the experience helper
  51092. */
  51093. dispose(): void;
  51094. /**
  51095. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  51096. * @param sessionMode options for the XR session
  51097. * @param referenceSpaceType frame of reference of the XR session
  51098. * @param renderTarget the output canvas that will be used to enter XR mode
  51099. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  51100. * @returns promise that resolves after xr mode has entered
  51101. */
  51102. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  51103. /**
  51104. * Exits XR mode and returns the scene to its original state
  51105. * @returns promise that resolves after xr mode has exited
  51106. */
  51107. exitXRAsync(): Promise<void>;
  51108. private _nonXRToXRCamera;
  51109. private _setState;
  51110. }
  51111. }
  51112. declare module BABYLON {
  51113. /**
  51114. * X-Y values for axes in WebXR
  51115. */
  51116. export interface IWebXRMotionControllerAxesValue {
  51117. /**
  51118. * The value of the x axis
  51119. */
  51120. x: number;
  51121. /**
  51122. * The value of the y-axis
  51123. */
  51124. y: number;
  51125. }
  51126. /**
  51127. * changed / previous values for the values of this component
  51128. */
  51129. export interface IWebXRMotionControllerComponentChangesValues<T> {
  51130. /**
  51131. * current (this frame) value
  51132. */
  51133. current: T;
  51134. /**
  51135. * previous (last change) value
  51136. */
  51137. previous: T;
  51138. }
  51139. /**
  51140. * Represents changes in the component between current frame and last values recorded
  51141. */
  51142. export interface IWebXRMotionControllerComponentChanges {
  51143. /**
  51144. * will be populated with previous and current values if axes changed
  51145. */
  51146. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  51147. /**
  51148. * will be populated with previous and current values if pressed changed
  51149. */
  51150. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51151. /**
  51152. * will be populated with previous and current values if touched changed
  51153. */
  51154. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51155. /**
  51156. * will be populated with previous and current values if value changed
  51157. */
  51158. value?: IWebXRMotionControllerComponentChangesValues<number>;
  51159. }
  51160. /**
  51161. * This class represents a single component (for example button or thumbstick) of a motion controller
  51162. */
  51163. export class WebXRControllerComponent implements IDisposable {
  51164. /**
  51165. * the id of this component
  51166. */
  51167. id: string;
  51168. /**
  51169. * the type of the component
  51170. */
  51171. type: MotionControllerComponentType;
  51172. private _buttonIndex;
  51173. private _axesIndices;
  51174. private _axes;
  51175. private _changes;
  51176. private _currentValue;
  51177. private _hasChanges;
  51178. private _pressed;
  51179. private _touched;
  51180. /**
  51181. * button component type
  51182. */
  51183. static BUTTON_TYPE: MotionControllerComponentType;
  51184. /**
  51185. * squeeze component type
  51186. */
  51187. static SQUEEZE_TYPE: MotionControllerComponentType;
  51188. /**
  51189. * Thumbstick component type
  51190. */
  51191. static THUMBSTICK_TYPE: MotionControllerComponentType;
  51192. /**
  51193. * Touchpad component type
  51194. */
  51195. static TOUCHPAD_TYPE: MotionControllerComponentType;
  51196. /**
  51197. * trigger component type
  51198. */
  51199. static TRIGGER_TYPE: MotionControllerComponentType;
  51200. /**
  51201. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  51202. * the axes data changes
  51203. */
  51204. onAxisValueChangedObservable: Observable<{
  51205. x: number;
  51206. y: number;
  51207. }>;
  51208. /**
  51209. * Observers registered here will be triggered when the state of a button changes
  51210. * State change is either pressed / touched / value
  51211. */
  51212. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  51213. /**
  51214. * Creates a new component for a motion controller.
  51215. * It is created by the motion controller itself
  51216. *
  51217. * @param id the id of this component
  51218. * @param type the type of the component
  51219. * @param _buttonIndex index in the buttons array of the gamepad
  51220. * @param _axesIndices indices of the values in the axes array of the gamepad
  51221. */
  51222. constructor(
  51223. /**
  51224. * the id of this component
  51225. */
  51226. id: string,
  51227. /**
  51228. * the type of the component
  51229. */
  51230. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  51231. /**
  51232. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  51233. */
  51234. get axes(): IWebXRMotionControllerAxesValue;
  51235. /**
  51236. * Get the changes. Elements will be populated only if they changed with their previous and current value
  51237. */
  51238. get changes(): IWebXRMotionControllerComponentChanges;
  51239. /**
  51240. * Return whether or not the component changed the last frame
  51241. */
  51242. get hasChanges(): boolean;
  51243. /**
  51244. * is the button currently pressed
  51245. */
  51246. get pressed(): boolean;
  51247. /**
  51248. * is the button currently touched
  51249. */
  51250. get touched(): boolean;
  51251. /**
  51252. * Get the current value of this component
  51253. */
  51254. get value(): number;
  51255. /**
  51256. * Dispose this component
  51257. */
  51258. dispose(): void;
  51259. /**
  51260. * Are there axes correlating to this component
  51261. * @return true is axes data is available
  51262. */
  51263. isAxes(): boolean;
  51264. /**
  51265. * Is this component a button (hence - pressable)
  51266. * @returns true if can be pressed
  51267. */
  51268. isButton(): boolean;
  51269. /**
  51270. * update this component using the gamepad object it is in. Called on every frame
  51271. * @param nativeController the native gamepad controller object
  51272. */
  51273. update(nativeController: IMinimalMotionControllerObject): void;
  51274. }
  51275. }
  51276. declare module BABYLON {
  51277. /**
  51278. * Type used for the success callback of ImportMesh
  51279. */
  51280. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  51281. /**
  51282. * Interface used for the result of ImportMeshAsync
  51283. */
  51284. export interface ISceneLoaderAsyncResult {
  51285. /**
  51286. * The array of loaded meshes
  51287. */
  51288. readonly meshes: AbstractMesh[];
  51289. /**
  51290. * The array of loaded particle systems
  51291. */
  51292. readonly particleSystems: IParticleSystem[];
  51293. /**
  51294. * The array of loaded skeletons
  51295. */
  51296. readonly skeletons: Skeleton[];
  51297. /**
  51298. * The array of loaded animation groups
  51299. */
  51300. readonly animationGroups: AnimationGroup[];
  51301. /**
  51302. * The array of loaded transform nodes
  51303. */
  51304. readonly transformNodes: TransformNode[];
  51305. /**
  51306. * The array of loaded geometries
  51307. */
  51308. readonly geometries: Geometry[];
  51309. /**
  51310. * The array of loaded lights
  51311. */
  51312. readonly lights: Light[];
  51313. }
  51314. /**
  51315. * Interface used to represent data loading progression
  51316. */
  51317. export interface ISceneLoaderProgressEvent {
  51318. /**
  51319. * Defines if data length to load can be evaluated
  51320. */
  51321. readonly lengthComputable: boolean;
  51322. /**
  51323. * Defines the loaded data length
  51324. */
  51325. readonly loaded: number;
  51326. /**
  51327. * Defines the data length to load
  51328. */
  51329. readonly total: number;
  51330. }
  51331. /**
  51332. * Interface used by SceneLoader plugins to define supported file extensions
  51333. */
  51334. export interface ISceneLoaderPluginExtensions {
  51335. /**
  51336. * Defines the list of supported extensions
  51337. */
  51338. [extension: string]: {
  51339. isBinary: boolean;
  51340. };
  51341. }
  51342. /**
  51343. * Interface used by SceneLoader plugin factory
  51344. */
  51345. export interface ISceneLoaderPluginFactory {
  51346. /**
  51347. * Defines the name of the factory
  51348. */
  51349. name: string;
  51350. /**
  51351. * Function called to create a new plugin
  51352. * @return the new plugin
  51353. */
  51354. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  51355. /**
  51356. * The callback that returns true if the data can be directly loaded.
  51357. * @param data string containing the file data
  51358. * @returns if the data can be loaded directly
  51359. */
  51360. canDirectLoad?(data: string): boolean;
  51361. }
  51362. /**
  51363. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  51364. */
  51365. export interface ISceneLoaderPluginBase {
  51366. /**
  51367. * The friendly name of this plugin.
  51368. */
  51369. name: string;
  51370. /**
  51371. * The file extensions supported by this plugin.
  51372. */
  51373. extensions: string | ISceneLoaderPluginExtensions;
  51374. /**
  51375. * The callback called when loading from a url.
  51376. * @param scene scene loading this url
  51377. * @param url url to load
  51378. * @param onSuccess callback called when the file successfully loads
  51379. * @param onProgress callback called while file is loading (if the server supports this mode)
  51380. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51381. * @param onError callback called when the file fails to load
  51382. * @returns a file request object
  51383. */
  51384. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51385. /**
  51386. * The callback called when loading from a file object.
  51387. * @param scene scene loading this file
  51388. * @param file defines the file to load
  51389. * @param onSuccess defines the callback to call when data is loaded
  51390. * @param onProgress defines the callback to call during loading process
  51391. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51392. * @param onError defines the callback to call when an error occurs
  51393. * @returns a file request object
  51394. */
  51395. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51396. /**
  51397. * The callback that returns true if the data can be directly loaded.
  51398. * @param data string containing the file data
  51399. * @returns if the data can be loaded directly
  51400. */
  51401. canDirectLoad?(data: string): boolean;
  51402. /**
  51403. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51404. * @param scene scene loading this data
  51405. * @param data string containing the data
  51406. * @returns data to pass to the plugin
  51407. */
  51408. directLoad?(scene: Scene, data: string): any;
  51409. /**
  51410. * The callback that allows custom handling of the root url based on the response url.
  51411. * @param rootUrl the original root url
  51412. * @param responseURL the response url if available
  51413. * @returns the new root url
  51414. */
  51415. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51416. }
  51417. /**
  51418. * Interface used to define a SceneLoader plugin
  51419. */
  51420. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51421. /**
  51422. * Import meshes into a scene.
  51423. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51424. * @param scene The scene to import into
  51425. * @param data The data to import
  51426. * @param rootUrl The root url for scene and resources
  51427. * @param meshes The meshes array to import into
  51428. * @param particleSystems The particle systems array to import into
  51429. * @param skeletons The skeletons array to import into
  51430. * @param onError The callback when import fails
  51431. * @returns True if successful or false otherwise
  51432. */
  51433. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51434. /**
  51435. * Load into a scene.
  51436. * @param scene The scene to load into
  51437. * @param data The data to import
  51438. * @param rootUrl The root url for scene and resources
  51439. * @param onError The callback when import fails
  51440. * @returns True if successful or false otherwise
  51441. */
  51442. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51443. /**
  51444. * Load into an asset container.
  51445. * @param scene The scene to load into
  51446. * @param data The data to import
  51447. * @param rootUrl The root url for scene and resources
  51448. * @param onError The callback when import fails
  51449. * @returns The loaded asset container
  51450. */
  51451. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51452. }
  51453. /**
  51454. * Interface used to define an async SceneLoader plugin
  51455. */
  51456. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51457. /**
  51458. * Import meshes into a scene.
  51459. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51460. * @param scene The scene to import into
  51461. * @param data The data to import
  51462. * @param rootUrl The root url for scene and resources
  51463. * @param onProgress The callback when the load progresses
  51464. * @param fileName Defines the name of the file to load
  51465. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  51466. */
  51467. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  51468. /**
  51469. * Load into a scene.
  51470. * @param scene The scene to load into
  51471. * @param data The data to import
  51472. * @param rootUrl The root url for scene and resources
  51473. * @param onProgress The callback when the load progresses
  51474. * @param fileName Defines the name of the file to load
  51475. * @returns Nothing
  51476. */
  51477. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51478. /**
  51479. * Load into an asset container.
  51480. * @param scene The scene to load into
  51481. * @param data The data to import
  51482. * @param rootUrl The root url for scene and resources
  51483. * @param onProgress The callback when the load progresses
  51484. * @param fileName Defines the name of the file to load
  51485. * @returns The loaded asset container
  51486. */
  51487. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51488. }
  51489. /**
  51490. * Mode that determines how to handle old animation groups before loading new ones.
  51491. */
  51492. export enum SceneLoaderAnimationGroupLoadingMode {
  51493. /**
  51494. * Reset all old animations to initial state then dispose them.
  51495. */
  51496. Clean = 0,
  51497. /**
  51498. * Stop all old animations.
  51499. */
  51500. Stop = 1,
  51501. /**
  51502. * Restart old animations from first frame.
  51503. */
  51504. Sync = 2,
  51505. /**
  51506. * Old animations remains untouched.
  51507. */
  51508. NoSync = 3
  51509. }
  51510. /**
  51511. * Defines a plugin registered by the SceneLoader
  51512. */
  51513. interface IRegisteredPlugin {
  51514. /**
  51515. * Defines the plugin to use
  51516. */
  51517. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51518. /**
  51519. * Defines if the plugin supports binary data
  51520. */
  51521. isBinary: boolean;
  51522. }
  51523. /**
  51524. * Class used to load scene from various file formats using registered plugins
  51525. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51526. */
  51527. export class SceneLoader {
  51528. /**
  51529. * No logging while loading
  51530. */
  51531. static readonly NO_LOGGING: number;
  51532. /**
  51533. * Minimal logging while loading
  51534. */
  51535. static readonly MINIMAL_LOGGING: number;
  51536. /**
  51537. * Summary logging while loading
  51538. */
  51539. static readonly SUMMARY_LOGGING: number;
  51540. /**
  51541. * Detailled logging while loading
  51542. */
  51543. static readonly DETAILED_LOGGING: number;
  51544. /**
  51545. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51546. */
  51547. static get ForceFullSceneLoadingForIncremental(): boolean;
  51548. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51549. /**
  51550. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51551. */
  51552. static get ShowLoadingScreen(): boolean;
  51553. static set ShowLoadingScreen(value: boolean);
  51554. /**
  51555. * Defines the current logging level (while loading the scene)
  51556. * @ignorenaming
  51557. */
  51558. static get loggingLevel(): number;
  51559. static set loggingLevel(value: number);
  51560. /**
  51561. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51562. */
  51563. static get CleanBoneMatrixWeights(): boolean;
  51564. static set CleanBoneMatrixWeights(value: boolean);
  51565. /**
  51566. * Event raised when a plugin is used to load a scene
  51567. */
  51568. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51569. private static _registeredPlugins;
  51570. private static _showingLoadingScreen;
  51571. /**
  51572. * Gets the default plugin (used to load Babylon files)
  51573. * @returns the .babylon plugin
  51574. */
  51575. static GetDefaultPlugin(): IRegisteredPlugin;
  51576. private static _GetPluginForExtension;
  51577. private static _GetPluginForDirectLoad;
  51578. private static _GetPluginForFilename;
  51579. private static _GetDirectLoad;
  51580. private static _LoadData;
  51581. private static _GetFileInfo;
  51582. /**
  51583. * Gets a plugin that can load the given extension
  51584. * @param extension defines the extension to load
  51585. * @returns a plugin or null if none works
  51586. */
  51587. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51588. /**
  51589. * Gets a boolean indicating that the given extension can be loaded
  51590. * @param extension defines the extension to load
  51591. * @returns true if the extension is supported
  51592. */
  51593. static IsPluginForExtensionAvailable(extension: string): boolean;
  51594. /**
  51595. * Adds a new plugin to the list of registered plugins
  51596. * @param plugin defines the plugin to add
  51597. */
  51598. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51599. /**
  51600. * Import meshes into a scene
  51601. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51602. * @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)
  51603. * @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)
  51604. * @param scene the instance of BABYLON.Scene to append to
  51605. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51606. * @param onProgress a callback with a progress event for each file being loaded
  51607. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51608. * @param pluginExtension the extension used to determine the plugin
  51609. * @returns The loaded plugin
  51610. */
  51611. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51612. /**
  51613. * Import meshes into a scene
  51614. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51615. * @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)
  51616. * @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)
  51617. * @param scene the instance of BABYLON.Scene to append to
  51618. * @param onProgress a callback with a progress event for each file being loaded
  51619. * @param pluginExtension the extension used to determine the plugin
  51620. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51621. */
  51622. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  51623. /**
  51624. * Load a scene
  51625. * @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)
  51626. * @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)
  51627. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51628. * @param onSuccess a callback with the scene when import succeeds
  51629. * @param onProgress a callback with a progress event for each file being loaded
  51630. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51631. * @param pluginExtension the extension used to determine the plugin
  51632. * @returns The loaded plugin
  51633. */
  51634. 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>;
  51635. /**
  51636. * Load a scene
  51637. * @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)
  51638. * @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)
  51639. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51640. * @param onProgress a callback with a progress event for each file being loaded
  51641. * @param pluginExtension the extension used to determine the plugin
  51642. * @returns The loaded scene
  51643. */
  51644. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51645. /**
  51646. * Append a scene
  51647. * @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)
  51648. * @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)
  51649. * @param scene is the instance of BABYLON.Scene to append to
  51650. * @param onSuccess a callback with the scene when import succeeds
  51651. * @param onProgress a callback with a progress event for each file being loaded
  51652. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51653. * @param pluginExtension the extension used to determine the plugin
  51654. * @returns The loaded plugin
  51655. */
  51656. 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>;
  51657. /**
  51658. * Append a scene
  51659. * @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)
  51660. * @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)
  51661. * @param scene is the instance of BABYLON.Scene to append to
  51662. * @param onProgress a callback with a progress event for each file being loaded
  51663. * @param pluginExtension the extension used to determine the plugin
  51664. * @returns The given scene
  51665. */
  51666. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51667. /**
  51668. * Load a scene into an asset container
  51669. * @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)
  51670. * @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)
  51671. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51672. * @param onSuccess a callback with the scene when import succeeds
  51673. * @param onProgress a callback with a progress event for each file being loaded
  51674. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51675. * @param pluginExtension the extension used to determine the plugin
  51676. * @returns The loaded plugin
  51677. */
  51678. 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>;
  51679. /**
  51680. * Load a scene into an asset container
  51681. * @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)
  51682. * @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)
  51683. * @param scene is the instance of Scene to append to
  51684. * @param onProgress a callback with a progress event for each file being loaded
  51685. * @param pluginExtension the extension used to determine the plugin
  51686. * @returns The loaded asset container
  51687. */
  51688. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51689. /**
  51690. * Import animations from a file into a scene
  51691. * @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)
  51692. * @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)
  51693. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51694. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51695. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51696. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51697. * @param onSuccess a callback with the scene when import succeeds
  51698. * @param onProgress a callback with a progress event for each file being loaded
  51699. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51700. * @param pluginExtension the extension used to determine the plugin
  51701. */
  51702. 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;
  51703. /**
  51704. * Import animations from a file into a scene
  51705. * @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)
  51706. * @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)
  51707. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51708. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51709. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51710. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51711. * @param onSuccess a callback with the scene when import succeeds
  51712. * @param onProgress a callback with a progress event for each file being loaded
  51713. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51714. * @param pluginExtension the extension used to determine the plugin
  51715. * @returns the updated scene with imported animations
  51716. */
  51717. 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>;
  51718. }
  51719. }
  51720. declare module BABYLON {
  51721. /**
  51722. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51723. */
  51724. export type MotionControllerHandedness = "none" | "left" | "right";
  51725. /**
  51726. * The type of components available in motion controllers.
  51727. * This is not the name of the component.
  51728. */
  51729. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51730. /**
  51731. * The state of a controller component
  51732. */
  51733. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51734. /**
  51735. * The schema of motion controller layout.
  51736. * No object will be initialized using this interface
  51737. * This is used just to define the profile.
  51738. */
  51739. export interface IMotionControllerLayout {
  51740. /**
  51741. * Path to load the assets. Usually relative to the base path
  51742. */
  51743. assetPath: string;
  51744. /**
  51745. * Available components (unsorted)
  51746. */
  51747. components: {
  51748. /**
  51749. * A map of component Ids
  51750. */
  51751. [componentId: string]: {
  51752. /**
  51753. * The type of input the component outputs
  51754. */
  51755. type: MotionControllerComponentType;
  51756. /**
  51757. * The indices of this component in the gamepad object
  51758. */
  51759. gamepadIndices: {
  51760. /**
  51761. * Index of button
  51762. */
  51763. button?: number;
  51764. /**
  51765. * If available, index of x-axis
  51766. */
  51767. xAxis?: number;
  51768. /**
  51769. * If available, index of y-axis
  51770. */
  51771. yAxis?: number;
  51772. };
  51773. /**
  51774. * The mesh's root node name
  51775. */
  51776. rootNodeName: string;
  51777. /**
  51778. * Animation definitions for this model
  51779. */
  51780. visualResponses: {
  51781. [stateKey: string]: {
  51782. /**
  51783. * What property will be animated
  51784. */
  51785. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51786. /**
  51787. * What states influence this visual response
  51788. */
  51789. states: MotionControllerComponentStateType[];
  51790. /**
  51791. * Type of animation - movement or visibility
  51792. */
  51793. valueNodeProperty: "transform" | "visibility";
  51794. /**
  51795. * Base node name to move. Its position will be calculated according to the min and max nodes
  51796. */
  51797. valueNodeName?: string;
  51798. /**
  51799. * Minimum movement node
  51800. */
  51801. minNodeName?: string;
  51802. /**
  51803. * Max movement node
  51804. */
  51805. maxNodeName?: string;
  51806. };
  51807. };
  51808. /**
  51809. * If touch enabled, what is the name of node to display user feedback
  51810. */
  51811. touchPointNodeName?: string;
  51812. };
  51813. };
  51814. /**
  51815. * Is it xr standard mapping or not
  51816. */
  51817. gamepadMapping: "" | "xr-standard";
  51818. /**
  51819. * Base root node of this entire model
  51820. */
  51821. rootNodeName: string;
  51822. /**
  51823. * Defines the main button component id
  51824. */
  51825. selectComponentId: string;
  51826. }
  51827. /**
  51828. * A definition for the layout map in the input profile
  51829. */
  51830. export interface IMotionControllerLayoutMap {
  51831. /**
  51832. * Layouts with handedness type as a key
  51833. */
  51834. [handedness: string]: IMotionControllerLayout;
  51835. }
  51836. /**
  51837. * The XR Input profile schema
  51838. * Profiles can be found here:
  51839. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51840. */
  51841. export interface IMotionControllerProfile {
  51842. /**
  51843. * fallback profiles for this profileId
  51844. */
  51845. fallbackProfileIds: string[];
  51846. /**
  51847. * The layout map, with handedness as key
  51848. */
  51849. layouts: IMotionControllerLayoutMap;
  51850. /**
  51851. * The id of this profile
  51852. * correlates to the profile(s) in the xrInput.profiles array
  51853. */
  51854. profileId: string;
  51855. }
  51856. /**
  51857. * A helper-interface for the 3 meshes needed for controller button animation
  51858. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51859. */
  51860. export interface IMotionControllerButtonMeshMap {
  51861. /**
  51862. * the mesh that defines the pressed value mesh position.
  51863. * This is used to find the max-position of this button
  51864. */
  51865. pressedMesh: AbstractMesh;
  51866. /**
  51867. * the mesh that defines the unpressed value mesh position.
  51868. * This is used to find the min (or initial) position of this button
  51869. */
  51870. unpressedMesh: AbstractMesh;
  51871. /**
  51872. * The mesh that will be changed when value changes
  51873. */
  51874. valueMesh: AbstractMesh;
  51875. }
  51876. /**
  51877. * A helper-interface for the 3 meshes needed for controller axis animation.
  51878. * This will be expanded when touchpad animations are fully supported
  51879. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51880. */
  51881. export interface IMotionControllerMeshMap {
  51882. /**
  51883. * the mesh that defines the maximum value mesh position.
  51884. */
  51885. maxMesh?: AbstractMesh;
  51886. /**
  51887. * the mesh that defines the minimum value mesh position.
  51888. */
  51889. minMesh?: AbstractMesh;
  51890. /**
  51891. * The mesh that will be changed when axis value changes
  51892. */
  51893. valueMesh?: AbstractMesh;
  51894. }
  51895. /**
  51896. * The elements needed for change-detection of the gamepad objects in motion controllers
  51897. */
  51898. export interface IMinimalMotionControllerObject {
  51899. /**
  51900. * Available axes of this controller
  51901. */
  51902. axes: number[];
  51903. /**
  51904. * An array of available buttons
  51905. */
  51906. buttons: Array<{
  51907. /**
  51908. * Value of the button/trigger
  51909. */
  51910. value: number;
  51911. /**
  51912. * If the button/trigger is currently touched
  51913. */
  51914. touched: boolean;
  51915. /**
  51916. * If the button/trigger is currently pressed
  51917. */
  51918. pressed: boolean;
  51919. }>;
  51920. /**
  51921. * EXPERIMENTAL haptic support.
  51922. */
  51923. hapticActuators?: Array<{
  51924. pulse: (value: number, duration: number) => Promise<boolean>;
  51925. }>;
  51926. }
  51927. /**
  51928. * An Abstract Motion controller
  51929. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51930. * Each component has an observable to check for changes in value and state
  51931. */
  51932. export abstract class WebXRAbstractMotionController implements IDisposable {
  51933. protected scene: Scene;
  51934. protected layout: IMotionControllerLayout;
  51935. /**
  51936. * The gamepad object correlating to this controller
  51937. */
  51938. gamepadObject: IMinimalMotionControllerObject;
  51939. /**
  51940. * handedness (left/right/none) of this controller
  51941. */
  51942. handedness: MotionControllerHandedness;
  51943. private _initComponent;
  51944. private _modelReady;
  51945. /**
  51946. * A map of components (WebXRControllerComponent) in this motion controller
  51947. * Components have a ComponentType and can also have both button and axis definitions
  51948. */
  51949. readonly components: {
  51950. [id: string]: WebXRControllerComponent;
  51951. };
  51952. /**
  51953. * Disable the model's animation. Can be set at any time.
  51954. */
  51955. disableAnimation: boolean;
  51956. /**
  51957. * Observers registered here will be triggered when the model of this controller is done loading
  51958. */
  51959. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51960. /**
  51961. * The profile id of this motion controller
  51962. */
  51963. abstract profileId: string;
  51964. /**
  51965. * The root mesh of the model. It is null if the model was not yet initialized
  51966. */
  51967. rootMesh: Nullable<AbstractMesh>;
  51968. /**
  51969. * constructs a new abstract motion controller
  51970. * @param scene the scene to which the model of the controller will be added
  51971. * @param layout The profile layout to load
  51972. * @param gamepadObject The gamepad object correlating to this controller
  51973. * @param handedness handedness (left/right/none) of this controller
  51974. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51975. */
  51976. constructor(scene: Scene, layout: IMotionControllerLayout,
  51977. /**
  51978. * The gamepad object correlating to this controller
  51979. */
  51980. gamepadObject: IMinimalMotionControllerObject,
  51981. /**
  51982. * handedness (left/right/none) of this controller
  51983. */
  51984. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51985. /**
  51986. * Dispose this controller, the model mesh and all its components
  51987. */
  51988. dispose(): void;
  51989. /**
  51990. * Returns all components of specific type
  51991. * @param type the type to search for
  51992. * @return an array of components with this type
  51993. */
  51994. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51995. /**
  51996. * get a component based an its component id as defined in layout.components
  51997. * @param id the id of the component
  51998. * @returns the component correlates to the id or undefined if not found
  51999. */
  52000. getComponent(id: string): WebXRControllerComponent;
  52001. /**
  52002. * Get the list of components available in this motion controller
  52003. * @returns an array of strings correlating to available components
  52004. */
  52005. getComponentIds(): string[];
  52006. /**
  52007. * Get the first component of specific type
  52008. * @param type type of component to find
  52009. * @return a controller component or null if not found
  52010. */
  52011. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  52012. /**
  52013. * Get the main (Select) component of this controller as defined in the layout
  52014. * @returns the main component of this controller
  52015. */
  52016. getMainComponent(): WebXRControllerComponent;
  52017. /**
  52018. * Loads the model correlating to this controller
  52019. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  52020. * @returns A promise fulfilled with the result of the model loading
  52021. */
  52022. loadModel(): Promise<boolean>;
  52023. /**
  52024. * Update this model using the current XRFrame
  52025. * @param xrFrame the current xr frame to use and update the model
  52026. */
  52027. updateFromXRFrame(xrFrame: XRFrame): void;
  52028. /**
  52029. * Backwards compatibility due to a deeply-integrated typo
  52030. */
  52031. get handness(): XREye;
  52032. /**
  52033. * Pulse (vibrate) this controller
  52034. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  52035. * Consecutive calls to this function will cancel the last pulse call
  52036. *
  52037. * @param value the strength of the pulse in 0.0...1.0 range
  52038. * @param duration Duration of the pulse in milliseconds
  52039. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  52040. * @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
  52041. */
  52042. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  52043. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  52044. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  52045. /**
  52046. * Moves the axis on the controller mesh based on its current state
  52047. * @param axis the index of the axis
  52048. * @param axisValue the value of the axis which determines the meshes new position
  52049. * @hidden
  52050. */
  52051. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  52052. /**
  52053. * Update the model itself with the current frame data
  52054. * @param xrFrame the frame to use for updating the model mesh
  52055. */
  52056. protected updateModel(xrFrame: XRFrame): void;
  52057. /**
  52058. * Get the filename and path for this controller's model
  52059. * @returns a map of filename and path
  52060. */
  52061. protected abstract _getFilenameAndPath(): {
  52062. filename: string;
  52063. path: string;
  52064. };
  52065. /**
  52066. * This function is called before the mesh is loaded. It checks for loading constraints.
  52067. * For example, this function can check if the GLB loader is available
  52068. * If this function returns false, the generic controller will be loaded instead
  52069. * @returns Is the client ready to load the mesh
  52070. */
  52071. protected abstract _getModelLoadingConstraints(): boolean;
  52072. /**
  52073. * This function will be called after the model was successfully loaded and can be used
  52074. * for mesh transformations before it is available for the user
  52075. * @param meshes the loaded meshes
  52076. */
  52077. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  52078. /**
  52079. * Set the root mesh for this controller. Important for the WebXR controller class
  52080. * @param meshes the loaded meshes
  52081. */
  52082. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  52083. /**
  52084. * A function executed each frame that updates the mesh (if needed)
  52085. * @param xrFrame the current xrFrame
  52086. */
  52087. protected abstract _updateModel(xrFrame: XRFrame): void;
  52088. private _getGenericFilenameAndPath;
  52089. private _getGenericParentMesh;
  52090. }
  52091. }
  52092. declare module BABYLON {
  52093. /**
  52094. * A generic trigger-only motion controller for WebXR
  52095. */
  52096. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  52097. /**
  52098. * Static version of the profile id of this controller
  52099. */
  52100. static ProfileId: string;
  52101. profileId: string;
  52102. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  52103. protected _getFilenameAndPath(): {
  52104. filename: string;
  52105. path: string;
  52106. };
  52107. protected _getModelLoadingConstraints(): boolean;
  52108. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  52109. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52110. protected _updateModel(): void;
  52111. }
  52112. }
  52113. declare module BABYLON {
  52114. /**
  52115. * Class containing static functions to help procedurally build meshes
  52116. */
  52117. export class SphereBuilder {
  52118. /**
  52119. * Creates a sphere mesh
  52120. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52121. * * 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`)
  52122. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52123. * * 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
  52124. * * 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)
  52125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52126. * * 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
  52127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52128. * @param name defines the name of the mesh
  52129. * @param options defines the options used to create the mesh
  52130. * @param scene defines the hosting scene
  52131. * @returns the sphere mesh
  52132. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52133. */
  52134. static CreateSphere(name: string, options: {
  52135. segments?: number;
  52136. diameter?: number;
  52137. diameterX?: number;
  52138. diameterY?: number;
  52139. diameterZ?: number;
  52140. arc?: number;
  52141. slice?: number;
  52142. sideOrientation?: number;
  52143. frontUVs?: Vector4;
  52144. backUVs?: Vector4;
  52145. updatable?: boolean;
  52146. }, scene?: Nullable<Scene>): Mesh;
  52147. }
  52148. }
  52149. declare module BABYLON {
  52150. /**
  52151. * A profiled motion controller has its profile loaded from an online repository.
  52152. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  52153. */
  52154. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  52155. private _repositoryUrl;
  52156. private _buttonMeshMapping;
  52157. private _touchDots;
  52158. /**
  52159. * The profile ID of this controller. Will be populated when the controller initializes.
  52160. */
  52161. profileId: string;
  52162. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  52163. dispose(): void;
  52164. protected _getFilenameAndPath(): {
  52165. filename: string;
  52166. path: string;
  52167. };
  52168. protected _getModelLoadingConstraints(): boolean;
  52169. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  52170. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52171. protected _updateModel(_xrFrame: XRFrame): void;
  52172. }
  52173. }
  52174. declare module BABYLON {
  52175. /**
  52176. * A construction function type to create a new controller based on an xrInput object
  52177. */
  52178. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  52179. /**
  52180. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  52181. *
  52182. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  52183. * it should be replaced with auto-loaded controllers.
  52184. *
  52185. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  52186. */
  52187. export class WebXRMotionControllerManager {
  52188. private static _AvailableControllers;
  52189. private static _Fallbacks;
  52190. private static _ProfileLoadingPromises;
  52191. private static _ProfilesList;
  52192. /**
  52193. * The base URL of the online controller repository. Can be changed at any time.
  52194. */
  52195. static BaseRepositoryUrl: string;
  52196. /**
  52197. * Which repository gets priority - local or online
  52198. */
  52199. static PrioritizeOnlineRepository: boolean;
  52200. /**
  52201. * Use the online repository, or use only locally-defined controllers
  52202. */
  52203. static UseOnlineRepository: boolean;
  52204. /**
  52205. * Clear the cache used for profile loading and reload when requested again
  52206. */
  52207. static ClearProfilesCache(): void;
  52208. /**
  52209. * Register the default fallbacks.
  52210. * This function is called automatically when this file is imported.
  52211. */
  52212. static DefaultFallbacks(): void;
  52213. /**
  52214. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  52215. * @param profileId the profile to which a fallback needs to be found
  52216. * @return an array with corresponding fallback profiles
  52217. */
  52218. static FindFallbackWithProfileId(profileId: string): string[];
  52219. /**
  52220. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  52221. * The order of search:
  52222. *
  52223. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  52224. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  52225. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  52226. * 4) return the generic trigger controller if none were found
  52227. *
  52228. * @param xrInput the xrInput to which a new controller is initialized
  52229. * @param scene the scene to which the model will be added
  52230. * @param forceProfile force a certain profile for this controller
  52231. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  52232. */
  52233. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  52234. /**
  52235. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  52236. *
  52237. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  52238. *
  52239. * @param type the profile type to register
  52240. * @param constructFunction the function to be called when loading this profile
  52241. */
  52242. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  52243. /**
  52244. * Register a fallback to a specific profile.
  52245. * @param profileId the profileId that will receive the fallbacks
  52246. * @param fallbacks A list of fallback profiles
  52247. */
  52248. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  52249. /**
  52250. * Will update the list of profiles available in the repository
  52251. * @return a promise that resolves to a map of profiles available online
  52252. */
  52253. static UpdateProfilesList(): Promise<{
  52254. [profile: string]: string;
  52255. }>;
  52256. private static _LoadProfileFromRepository;
  52257. private static _LoadProfilesFromAvailableControllers;
  52258. }
  52259. }
  52260. declare module BABYLON {
  52261. /**
  52262. * Configuration options for the WebXR controller creation
  52263. */
  52264. export interface IWebXRControllerOptions {
  52265. /**
  52266. * Should the controller mesh be animated when a user interacts with it
  52267. * The pressed buttons / thumbstick and touchpad animations will be disabled
  52268. */
  52269. disableMotionControllerAnimation?: boolean;
  52270. /**
  52271. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  52272. */
  52273. doNotLoadControllerMesh?: boolean;
  52274. /**
  52275. * Force a specific controller type for this controller.
  52276. * This can be used when creating your own profile or when testing different controllers
  52277. */
  52278. forceControllerProfile?: string;
  52279. /**
  52280. * Defines a rendering group ID for meshes that will be loaded.
  52281. * This is for the default controllers only.
  52282. */
  52283. renderingGroupId?: number;
  52284. }
  52285. /**
  52286. * Represents an XR controller
  52287. */
  52288. export class WebXRInputSource {
  52289. private _scene;
  52290. /** The underlying input source for the controller */
  52291. inputSource: XRInputSource;
  52292. private _options;
  52293. private _tmpVector;
  52294. private _uniqueId;
  52295. private _disposed;
  52296. /**
  52297. * 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
  52298. */
  52299. grip?: AbstractMesh;
  52300. /**
  52301. * If available, this is the gamepad object related to this controller.
  52302. * Using this object it is possible to get click events and trackpad changes of the
  52303. * webxr controller that is currently being used.
  52304. */
  52305. motionController?: WebXRAbstractMotionController;
  52306. /**
  52307. * Event that fires when the controller is removed/disposed.
  52308. * The object provided as event data is this controller, after associated assets were disposed.
  52309. * uniqueId is still available.
  52310. */
  52311. onDisposeObservable: Observable<WebXRInputSource>;
  52312. /**
  52313. * Will be triggered when the mesh associated with the motion controller is done loading.
  52314. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  52315. * A shortened version of controller -> motion controller -> on mesh loaded.
  52316. */
  52317. onMeshLoadedObservable: Observable<AbstractMesh>;
  52318. /**
  52319. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  52320. */
  52321. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  52322. /**
  52323. * Pointer which can be used to select objects or attach a visible laser to
  52324. */
  52325. pointer: AbstractMesh;
  52326. /**
  52327. * Creates the input source object
  52328. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  52329. * @param _scene the scene which the controller should be associated to
  52330. * @param inputSource the underlying input source for the controller
  52331. * @param _options options for this controller creation
  52332. */
  52333. constructor(_scene: Scene,
  52334. /** The underlying input source for the controller */
  52335. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  52336. /**
  52337. * Get this controllers unique id
  52338. */
  52339. get uniqueId(): string;
  52340. /**
  52341. * Disposes of the object
  52342. */
  52343. dispose(): void;
  52344. /**
  52345. * Gets a world space ray coming from the pointer or grip
  52346. * @param result the resulting ray
  52347. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  52348. */
  52349. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  52350. /**
  52351. * Updates the controller pose based on the given XRFrame
  52352. * @param xrFrame xr frame to update the pose with
  52353. * @param referenceSpace reference space to use
  52354. */
  52355. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  52356. }
  52357. }
  52358. declare module BABYLON {
  52359. /**
  52360. * The schema for initialization options of the XR Input class
  52361. */
  52362. export interface IWebXRInputOptions {
  52363. /**
  52364. * If set to true no model will be automatically loaded
  52365. */
  52366. doNotLoadControllerMeshes?: boolean;
  52367. /**
  52368. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52369. * If not found, the xr input profile data will be used.
  52370. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52371. */
  52372. forceInputProfile?: string;
  52373. /**
  52374. * Do not send a request to the controller repository to load the profile.
  52375. *
  52376. * Instead, use the controllers available in babylon itself.
  52377. */
  52378. disableOnlineControllerRepository?: boolean;
  52379. /**
  52380. * A custom URL for the controllers repository
  52381. */
  52382. customControllersRepositoryURL?: string;
  52383. /**
  52384. * Should the controller model's components not move according to the user input
  52385. */
  52386. disableControllerAnimation?: boolean;
  52387. /**
  52388. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52389. */
  52390. controllerOptions?: IWebXRControllerOptions;
  52391. }
  52392. /**
  52393. * XR input used to track XR inputs such as controllers/rays
  52394. */
  52395. export class WebXRInput implements IDisposable {
  52396. /**
  52397. * the xr session manager for this session
  52398. */
  52399. xrSessionManager: WebXRSessionManager;
  52400. /**
  52401. * the WebXR camera for this session. Mainly used for teleportation
  52402. */
  52403. xrCamera: WebXRCamera;
  52404. private readonly options;
  52405. /**
  52406. * XR controllers being tracked
  52407. */
  52408. controllers: Array<WebXRInputSource>;
  52409. private _frameObserver;
  52410. private _sessionEndedObserver;
  52411. private _sessionInitObserver;
  52412. /**
  52413. * Event when a controller has been connected/added
  52414. */
  52415. onControllerAddedObservable: Observable<WebXRInputSource>;
  52416. /**
  52417. * Event when a controller has been removed/disconnected
  52418. */
  52419. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52420. /**
  52421. * Initializes the WebXRInput
  52422. * @param xrSessionManager the xr session manager for this session
  52423. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52424. * @param options = initialization options for this xr input
  52425. */
  52426. constructor(
  52427. /**
  52428. * the xr session manager for this session
  52429. */
  52430. xrSessionManager: WebXRSessionManager,
  52431. /**
  52432. * the WebXR camera for this session. Mainly used for teleportation
  52433. */
  52434. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52435. private _onInputSourcesChange;
  52436. private _addAndRemoveControllers;
  52437. /**
  52438. * Disposes of the object
  52439. */
  52440. dispose(): void;
  52441. }
  52442. }
  52443. declare module BABYLON {
  52444. /**
  52445. * This is the base class for all WebXR features.
  52446. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52447. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52448. */
  52449. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52450. protected _xrSessionManager: WebXRSessionManager;
  52451. private _attached;
  52452. private _removeOnDetach;
  52453. /**
  52454. * Is this feature disposed?
  52455. */
  52456. isDisposed: boolean;
  52457. /**
  52458. * Should auto-attach be disabled?
  52459. */
  52460. disableAutoAttach: boolean;
  52461. /**
  52462. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52463. */
  52464. xrNativeFeatureName: string;
  52465. /**
  52466. * Construct a new (abstract) WebXR feature
  52467. * @param _xrSessionManager the xr session manager for this feature
  52468. */
  52469. constructor(_xrSessionManager: WebXRSessionManager);
  52470. /**
  52471. * Is this feature attached
  52472. */
  52473. get attached(): boolean;
  52474. /**
  52475. * attach this feature
  52476. *
  52477. * @param force should attachment be forced (even when already attached)
  52478. * @returns true if successful, false is failed or already attached
  52479. */
  52480. attach(force?: boolean): boolean;
  52481. /**
  52482. * detach this feature.
  52483. *
  52484. * @returns true if successful, false if failed or already detached
  52485. */
  52486. detach(): boolean;
  52487. /**
  52488. * Dispose this feature and all of the resources attached
  52489. */
  52490. dispose(): void;
  52491. /**
  52492. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52493. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52494. *
  52495. * @returns whether or not the feature is compatible in this environment
  52496. */
  52497. isCompatible(): boolean;
  52498. /**
  52499. * This is used to register callbacks that will automatically be removed when detach is called.
  52500. * @param observable the observable to which the observer will be attached
  52501. * @param callback the callback to register
  52502. */
  52503. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52504. /**
  52505. * Code in this function will be executed on each xrFrame received from the browser.
  52506. * This function will not execute after the feature is detached.
  52507. * @param _xrFrame the current frame
  52508. */
  52509. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52510. }
  52511. }
  52512. declare module BABYLON {
  52513. /**
  52514. * Renders a layer on top of an existing scene
  52515. */
  52516. export class UtilityLayerRenderer implements IDisposable {
  52517. /** the original scene that will be rendered on top of */
  52518. originalScene: Scene;
  52519. private _pointerCaptures;
  52520. private _lastPointerEvents;
  52521. private static _DefaultUtilityLayer;
  52522. private static _DefaultKeepDepthUtilityLayer;
  52523. private _sharedGizmoLight;
  52524. private _renderCamera;
  52525. /**
  52526. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52527. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52528. * @returns the camera that is used when rendering the utility layer
  52529. */
  52530. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52531. /**
  52532. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52533. * @param cam the camera that should be used when rendering the utility layer
  52534. */
  52535. setRenderCamera(cam: Nullable<Camera>): void;
  52536. /**
  52537. * @hidden
  52538. * Light which used by gizmos to get light shading
  52539. */
  52540. _getSharedGizmoLight(): HemisphericLight;
  52541. /**
  52542. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52543. */
  52544. pickUtilitySceneFirst: boolean;
  52545. /**
  52546. * 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)
  52547. */
  52548. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52549. /**
  52550. * 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)
  52551. */
  52552. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52553. /**
  52554. * The scene that is rendered on top of the original scene
  52555. */
  52556. utilityLayerScene: Scene;
  52557. /**
  52558. * If the utility layer should automatically be rendered on top of existing scene
  52559. */
  52560. shouldRender: boolean;
  52561. /**
  52562. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52563. */
  52564. onlyCheckPointerDownEvents: boolean;
  52565. /**
  52566. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52567. */
  52568. processAllEvents: boolean;
  52569. /**
  52570. * Observable raised when the pointer move from the utility layer scene to the main scene
  52571. */
  52572. onPointerOutObservable: Observable<number>;
  52573. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52574. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52575. private _afterRenderObserver;
  52576. private _sceneDisposeObserver;
  52577. private _originalPointerObserver;
  52578. /**
  52579. * Instantiates a UtilityLayerRenderer
  52580. * @param originalScene the original scene that will be rendered on top of
  52581. * @param handleEvents boolean indicating if the utility layer should handle events
  52582. */
  52583. constructor(
  52584. /** the original scene that will be rendered on top of */
  52585. originalScene: Scene, handleEvents?: boolean);
  52586. private _notifyObservers;
  52587. /**
  52588. * Renders the utility layers scene on top of the original scene
  52589. */
  52590. render(): void;
  52591. /**
  52592. * Disposes of the renderer
  52593. */
  52594. dispose(): void;
  52595. private _updateCamera;
  52596. }
  52597. }
  52598. declare module BABYLON {
  52599. /**
  52600. * Options interface for the pointer selection module
  52601. */
  52602. export interface IWebXRControllerPointerSelectionOptions {
  52603. /**
  52604. * if provided, this scene will be used to render meshes.
  52605. */
  52606. customUtilityLayerScene?: Scene;
  52607. /**
  52608. * 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)
  52609. * If not disabled, the last picked point will be used to execute a pointer up event
  52610. * If disabled, pointer up event will be triggered right after the pointer down event.
  52611. * Used in screen and gaze target ray mode only
  52612. */
  52613. disablePointerUpOnTouchOut: boolean;
  52614. /**
  52615. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52616. */
  52617. forceGazeMode: boolean;
  52618. /**
  52619. * 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
  52620. * to start a new countdown to the pointer down event.
  52621. * Defaults to 1.
  52622. */
  52623. gazeModePointerMovedFactor?: number;
  52624. /**
  52625. * Different button type to use instead of the main component
  52626. */
  52627. overrideButtonId?: string;
  52628. /**
  52629. * use this rendering group id for the meshes (optional)
  52630. */
  52631. renderingGroupId?: number;
  52632. /**
  52633. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52634. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52635. * 3000 means 3 seconds between pointing at something and selecting it
  52636. */
  52637. timeToSelect?: number;
  52638. /**
  52639. * Should meshes created here be added to a utility layer or the main scene
  52640. */
  52641. useUtilityLayer?: boolean;
  52642. /**
  52643. * Optional WebXR camera to be used for gaze selection
  52644. */
  52645. gazeCamera?: WebXRCamera;
  52646. /**
  52647. * the xr input to use with this pointer selection
  52648. */
  52649. xrInput: WebXRInput;
  52650. /**
  52651. * Should the scene pointerX and pointerY update be disabled
  52652. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52653. * Disable in VR, if not needed.
  52654. * The first rig camera (left eye) will be used to calculate the projection
  52655. */
  52656. disableScenePointerVectorUpdate: boolean;
  52657. /**
  52658. * Enable pointer selection on all controllers instead of switching between them
  52659. */
  52660. enablePointerSelectionOnAllControllers?: boolean;
  52661. /**
  52662. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52663. * If switch is enabled, it will still allow the user to switch between the different controllers
  52664. */
  52665. preferredHandedness?: XRHandedness;
  52666. /**
  52667. * Disable switching the pointer selection from one controller to the other.
  52668. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  52669. */
  52670. disableSwitchOnClick?: boolean;
  52671. /**
  52672. * The maximum distance of the pointer selection feature. Defaults to 100.
  52673. */
  52674. maxPointerDistance?: number;
  52675. }
  52676. /**
  52677. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52678. */
  52679. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52680. private readonly _options;
  52681. private static _idCounter;
  52682. private _attachController;
  52683. private _controllers;
  52684. private _scene;
  52685. private _tmpVectorForPickCompare;
  52686. private _attachedController;
  52687. /**
  52688. * The module's name
  52689. */
  52690. static readonly Name: string;
  52691. /**
  52692. * The (Babylon) version of this module.
  52693. * This is an integer representing the implementation version.
  52694. * This number does not correspond to the WebXR specs version
  52695. */
  52696. static readonly Version: number;
  52697. /**
  52698. * Disable lighting on the laser pointer (so it will always be visible)
  52699. */
  52700. disablePointerLighting: boolean;
  52701. /**
  52702. * Disable lighting on the selection mesh (so it will always be visible)
  52703. */
  52704. disableSelectionMeshLighting: boolean;
  52705. /**
  52706. * Should the laser pointer be displayed
  52707. */
  52708. displayLaserPointer: boolean;
  52709. /**
  52710. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52711. */
  52712. displaySelectionMesh: boolean;
  52713. /**
  52714. * This color will be set to the laser pointer when selection is triggered
  52715. */
  52716. laserPointerPickedColor: Color3;
  52717. /**
  52718. * Default color of the laser pointer
  52719. */
  52720. laserPointerDefaultColor: Color3;
  52721. /**
  52722. * default color of the selection ring
  52723. */
  52724. selectionMeshDefaultColor: Color3;
  52725. /**
  52726. * This color will be applied to the selection ring when selection is triggered
  52727. */
  52728. selectionMeshPickedColor: Color3;
  52729. /**
  52730. * Optional filter to be used for ray selection. This predicate shares behavior with
  52731. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52732. */
  52733. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52734. /**
  52735. * constructs a new background remover module
  52736. * @param _xrSessionManager the session manager for this module
  52737. * @param _options read-only options to be used in this module
  52738. */
  52739. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52740. /**
  52741. * attach this feature
  52742. * Will usually be called by the features manager
  52743. *
  52744. * @returns true if successful.
  52745. */
  52746. attach(): boolean;
  52747. /**
  52748. * detach this feature.
  52749. * Will usually be called by the features manager
  52750. *
  52751. * @returns true if successful.
  52752. */
  52753. detach(): boolean;
  52754. /**
  52755. * Will get the mesh under a specific pointer.
  52756. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52757. * @param controllerId the controllerId to check
  52758. * @returns The mesh under pointer or null if no mesh is under the pointer
  52759. */
  52760. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52761. /**
  52762. * Get the xr controller that correlates to the pointer id in the pointer event
  52763. *
  52764. * @param id the pointer id to search for
  52765. * @returns the controller that correlates to this id or null if not found
  52766. */
  52767. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52768. private _identityMatrix;
  52769. private _screenCoordinatesRef;
  52770. private _viewportRef;
  52771. protected _onXRFrame(_xrFrame: XRFrame): void;
  52772. private _attachGazeMode;
  52773. private _attachScreenRayMode;
  52774. private _attachTrackedPointerRayMode;
  52775. private _convertNormalToDirectionOfRay;
  52776. private _detachController;
  52777. private _generateNewMeshPair;
  52778. private _pickingMoved;
  52779. private _updatePointerDistance;
  52780. /** @hidden */
  52781. get lasterPointerDefaultColor(): Color3;
  52782. }
  52783. }
  52784. declare module BABYLON {
  52785. /**
  52786. * Button which can be used to enter a different mode of XR
  52787. */
  52788. export class WebXREnterExitUIButton {
  52789. /** button element */
  52790. element: HTMLElement;
  52791. /** XR initialization options for the button */
  52792. sessionMode: XRSessionMode;
  52793. /** Reference space type */
  52794. referenceSpaceType: XRReferenceSpaceType;
  52795. /**
  52796. * Creates a WebXREnterExitUIButton
  52797. * @param element button element
  52798. * @param sessionMode XR initialization session mode
  52799. * @param referenceSpaceType the type of reference space to be used
  52800. */
  52801. constructor(
  52802. /** button element */
  52803. element: HTMLElement,
  52804. /** XR initialization options for the button */
  52805. sessionMode: XRSessionMode,
  52806. /** Reference space type */
  52807. referenceSpaceType: XRReferenceSpaceType);
  52808. /**
  52809. * Extendable function which can be used to update the button's visuals when the state changes
  52810. * @param activeButton the current active button in the UI
  52811. */
  52812. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52813. }
  52814. /**
  52815. * Options to create the webXR UI
  52816. */
  52817. export class WebXREnterExitUIOptions {
  52818. /**
  52819. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52820. */
  52821. customButtons?: Array<WebXREnterExitUIButton>;
  52822. /**
  52823. * A reference space type to use when creating the default button.
  52824. * Default is local-floor
  52825. */
  52826. referenceSpaceType?: XRReferenceSpaceType;
  52827. /**
  52828. * Context to enter xr with
  52829. */
  52830. renderTarget?: Nullable<WebXRRenderTarget>;
  52831. /**
  52832. * A session mode to use when creating the default button.
  52833. * Default is immersive-vr
  52834. */
  52835. sessionMode?: XRSessionMode;
  52836. /**
  52837. * A list of optional features to init the session with
  52838. */
  52839. optionalFeatures?: string[];
  52840. /**
  52841. * A list of optional features to init the session with
  52842. */
  52843. requiredFeatures?: string[];
  52844. /**
  52845. * If defined, this function will be executed if the UI encounters an error when entering XR
  52846. */
  52847. onError?: (error: any) => void;
  52848. }
  52849. /**
  52850. * UI to allow the user to enter/exit XR mode
  52851. */
  52852. export class WebXREnterExitUI implements IDisposable {
  52853. private scene;
  52854. /** version of the options passed to this UI */
  52855. options: WebXREnterExitUIOptions;
  52856. private _activeButton;
  52857. private _buttons;
  52858. /**
  52859. * The HTML Div Element to which buttons are added.
  52860. */
  52861. readonly overlay: HTMLDivElement;
  52862. /**
  52863. * Fired every time the active button is changed.
  52864. *
  52865. * When xr is entered via a button that launches xr that button will be the callback parameter
  52866. *
  52867. * When exiting xr the callback parameter will be null)
  52868. */
  52869. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52870. /**
  52871. *
  52872. * @param scene babylon scene object to use
  52873. * @param options (read-only) version of the options passed to this UI
  52874. */
  52875. private constructor();
  52876. /**
  52877. * Creates UI to allow the user to enter/exit XR mode
  52878. * @param scene the scene to add the ui to
  52879. * @param helper the xr experience helper to enter/exit xr with
  52880. * @param options options to configure the UI
  52881. * @returns the created ui
  52882. */
  52883. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52884. /**
  52885. * Disposes of the XR UI component
  52886. */
  52887. dispose(): void;
  52888. private _updateButtons;
  52889. }
  52890. }
  52891. declare module BABYLON {
  52892. /**
  52893. * Class containing static functions to help procedurally build meshes
  52894. */
  52895. export class LinesBuilder {
  52896. /**
  52897. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52898. * * 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
  52899. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52900. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52901. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52902. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52903. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52904. * * 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
  52905. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52908. * @param name defines the name of the new line system
  52909. * @param options defines the options used to create the line system
  52910. * @param scene defines the hosting scene
  52911. * @returns a new line system mesh
  52912. */
  52913. static CreateLineSystem(name: string, options: {
  52914. lines: Vector3[][];
  52915. updatable?: boolean;
  52916. instance?: Nullable<LinesMesh>;
  52917. colors?: Nullable<Color4[][]>;
  52918. useVertexAlpha?: boolean;
  52919. }, scene: Nullable<Scene>): LinesMesh;
  52920. /**
  52921. * Creates a line mesh
  52922. * 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
  52923. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52924. * * The parameter `points` is an array successive Vector3
  52925. * * 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
  52926. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52927. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52928. * * When updating an instance, remember that only point positions can change, not the number of points
  52929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52931. * @param name defines the name of the new line system
  52932. * @param options defines the options used to create the line system
  52933. * @param scene defines the hosting scene
  52934. * @returns a new line mesh
  52935. */
  52936. static CreateLines(name: string, options: {
  52937. points: Vector3[];
  52938. updatable?: boolean;
  52939. instance?: Nullable<LinesMesh>;
  52940. colors?: Color4[];
  52941. useVertexAlpha?: boolean;
  52942. }, scene?: Nullable<Scene>): LinesMesh;
  52943. /**
  52944. * Creates a dashed line mesh
  52945. * * 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
  52946. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52947. * * The parameter `points` is an array successive Vector3
  52948. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52949. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52950. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52951. * * 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
  52952. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52953. * * When updating an instance, remember that only point positions can change, not the number of points
  52954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52955. * @param name defines the name of the mesh
  52956. * @param options defines the options used to create the mesh
  52957. * @param scene defines the hosting scene
  52958. * @returns the dashed line mesh
  52959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52960. */
  52961. static CreateDashedLines(name: string, options: {
  52962. points: Vector3[];
  52963. dashSize?: number;
  52964. gapSize?: number;
  52965. dashNb?: number;
  52966. updatable?: boolean;
  52967. instance?: LinesMesh;
  52968. useVertexAlpha?: boolean;
  52969. }, scene?: Nullable<Scene>): LinesMesh;
  52970. }
  52971. }
  52972. declare module BABYLON {
  52973. /**
  52974. * Construction options for a timer
  52975. */
  52976. export interface ITimerOptions<T> {
  52977. /**
  52978. * Time-to-end
  52979. */
  52980. timeout: number;
  52981. /**
  52982. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52983. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52984. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52985. */
  52986. contextObservable: Observable<T>;
  52987. /**
  52988. * Optional parameters when adding an observer to the observable
  52989. */
  52990. observableParameters?: {
  52991. mask?: number;
  52992. insertFirst?: boolean;
  52993. scope?: any;
  52994. };
  52995. /**
  52996. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52997. */
  52998. breakCondition?: (data?: ITimerData<T>) => boolean;
  52999. /**
  53000. * Will be triggered when the time condition has met
  53001. */
  53002. onEnded?: (data: ITimerData<any>) => void;
  53003. /**
  53004. * Will be triggered when the break condition has met (prematurely ended)
  53005. */
  53006. onAborted?: (data: ITimerData<any>) => void;
  53007. /**
  53008. * Optional function to execute on each tick (or count)
  53009. */
  53010. onTick?: (data: ITimerData<any>) => void;
  53011. }
  53012. /**
  53013. * An interface defining the data sent by the timer
  53014. */
  53015. export interface ITimerData<T> {
  53016. /**
  53017. * When did it start
  53018. */
  53019. startTime: number;
  53020. /**
  53021. * Time now
  53022. */
  53023. currentTime: number;
  53024. /**
  53025. * Time passed since started
  53026. */
  53027. deltaTime: number;
  53028. /**
  53029. * How much is completed, in [0.0...1.0].
  53030. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  53031. */
  53032. completeRate: number;
  53033. /**
  53034. * What the registered observable sent in the last count
  53035. */
  53036. payload: T;
  53037. }
  53038. /**
  53039. * The current state of the timer
  53040. */
  53041. export enum TimerState {
  53042. /**
  53043. * Timer initialized, not yet started
  53044. */
  53045. INIT = 0,
  53046. /**
  53047. * Timer started and counting
  53048. */
  53049. STARTED = 1,
  53050. /**
  53051. * Timer ended (whether aborted or time reached)
  53052. */
  53053. ENDED = 2
  53054. }
  53055. /**
  53056. * A simple version of the timer. Will take options and start the timer immediately after calling it
  53057. *
  53058. * @param options options with which to initialize this timer
  53059. */
  53060. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  53061. /**
  53062. * An advanced implementation of a timer class
  53063. */
  53064. export class AdvancedTimer<T = any> implements IDisposable {
  53065. /**
  53066. * Will notify each time the timer calculates the remaining time
  53067. */
  53068. onEachCountObservable: Observable<ITimerData<T>>;
  53069. /**
  53070. * Will trigger when the timer was aborted due to the break condition
  53071. */
  53072. onTimerAbortedObservable: Observable<ITimerData<T>>;
  53073. /**
  53074. * Will trigger when the timer ended successfully
  53075. */
  53076. onTimerEndedObservable: Observable<ITimerData<T>>;
  53077. /**
  53078. * Will trigger when the timer state has changed
  53079. */
  53080. onStateChangedObservable: Observable<TimerState>;
  53081. private _observer;
  53082. private _contextObservable;
  53083. private _observableParameters;
  53084. private _startTime;
  53085. private _timer;
  53086. private _state;
  53087. private _breakCondition;
  53088. private _timeToEnd;
  53089. private _breakOnNextTick;
  53090. /**
  53091. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  53092. * @param options construction options for this advanced timer
  53093. */
  53094. constructor(options: ITimerOptions<T>);
  53095. /**
  53096. * set a breaking condition for this timer. Default is to never break during count
  53097. * @param predicate the new break condition. Returns true to break, false otherwise
  53098. */
  53099. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  53100. /**
  53101. * Reset ALL associated observables in this advanced timer
  53102. */
  53103. clearObservables(): void;
  53104. /**
  53105. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  53106. *
  53107. * @param timeToEnd how much time to measure until timer ended
  53108. */
  53109. start(timeToEnd?: number): void;
  53110. /**
  53111. * Will force a stop on the next tick.
  53112. */
  53113. stop(): void;
  53114. /**
  53115. * Dispose this timer, clearing all resources
  53116. */
  53117. dispose(): void;
  53118. private _setState;
  53119. private _tick;
  53120. private _stop;
  53121. }
  53122. }
  53123. declare module BABYLON {
  53124. /**
  53125. * The options container for the teleportation module
  53126. */
  53127. export interface IWebXRTeleportationOptions {
  53128. /**
  53129. * if provided, this scene will be used to render meshes.
  53130. */
  53131. customUtilityLayerScene?: Scene;
  53132. /**
  53133. * Values to configure the default target mesh
  53134. */
  53135. defaultTargetMeshOptions?: {
  53136. /**
  53137. * Fill color of the teleportation area
  53138. */
  53139. teleportationFillColor?: string;
  53140. /**
  53141. * Border color for the teleportation area
  53142. */
  53143. teleportationBorderColor?: string;
  53144. /**
  53145. * Disable the mesh's animation sequence
  53146. */
  53147. disableAnimation?: boolean;
  53148. /**
  53149. * Disable lighting on the material or the ring and arrow
  53150. */
  53151. disableLighting?: boolean;
  53152. /**
  53153. * Override the default material of the torus and arrow
  53154. */
  53155. torusArrowMaterial?: Material;
  53156. };
  53157. /**
  53158. * A list of meshes to use as floor meshes.
  53159. * Meshes can be added and removed after initializing the feature using the
  53160. * addFloorMesh and removeFloorMesh functions
  53161. * If empty, rotation will still work
  53162. */
  53163. floorMeshes?: AbstractMesh[];
  53164. /**
  53165. * use this rendering group id for the meshes (optional)
  53166. */
  53167. renderingGroupId?: number;
  53168. /**
  53169. * Should teleportation move only to snap points
  53170. */
  53171. snapPointsOnly?: boolean;
  53172. /**
  53173. * An array of points to which the teleportation will snap to.
  53174. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  53175. */
  53176. snapPositions?: Vector3[];
  53177. /**
  53178. * How close should the teleportation ray be in order to snap to position.
  53179. * Default to 0.8 units (meters)
  53180. */
  53181. snapToPositionRadius?: number;
  53182. /**
  53183. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  53184. * If you want to support rotation, make sure your mesh has a direction indicator.
  53185. *
  53186. * When left untouched, the default mesh will be initialized.
  53187. */
  53188. teleportationTargetMesh?: AbstractMesh;
  53189. /**
  53190. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  53191. */
  53192. timeToTeleport?: number;
  53193. /**
  53194. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  53195. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  53196. */
  53197. useMainComponentOnly?: boolean;
  53198. /**
  53199. * Should meshes created here be added to a utility layer or the main scene
  53200. */
  53201. useUtilityLayer?: boolean;
  53202. /**
  53203. * Babylon XR Input class for controller
  53204. */
  53205. xrInput: WebXRInput;
  53206. /**
  53207. * Meshes that the teleportation ray cannot go through
  53208. */
  53209. pickBlockerMeshes?: AbstractMesh[];
  53210. /**
  53211. * Should teleport work only on a specific hand?
  53212. */
  53213. forceHandedness?: XRHandedness;
  53214. /**
  53215. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  53216. */
  53217. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  53218. }
  53219. /**
  53220. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  53221. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  53222. * the input of the attached controllers.
  53223. */
  53224. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  53225. private _options;
  53226. private _controllers;
  53227. private _currentTeleportationControllerId;
  53228. private _floorMeshes;
  53229. private _quadraticBezierCurve;
  53230. private _selectionFeature;
  53231. private _snapToPositions;
  53232. private _snappedToPoint;
  53233. private _teleportationRingMaterial?;
  53234. private _tmpRay;
  53235. private _tmpVector;
  53236. private _tmpQuaternion;
  53237. /**
  53238. * The module's name
  53239. */
  53240. static readonly Name: string;
  53241. /**
  53242. * The (Babylon) version of this module.
  53243. * This is an integer representing the implementation version.
  53244. * This number does not correspond to the webxr specs version
  53245. */
  53246. static readonly Version: number;
  53247. /**
  53248. * Is movement backwards enabled
  53249. */
  53250. backwardsMovementEnabled: boolean;
  53251. /**
  53252. * Distance to travel when moving backwards
  53253. */
  53254. backwardsTeleportationDistance: number;
  53255. /**
  53256. * The distance from the user to the inspection point in the direction of the controller
  53257. * A higher number will allow the user to move further
  53258. * defaults to 5 (meters, in xr units)
  53259. */
  53260. parabolicCheckRadius: number;
  53261. /**
  53262. * Should the module support parabolic ray on top of direct ray
  53263. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  53264. * Very helpful when moving between floors / different heights
  53265. */
  53266. parabolicRayEnabled: boolean;
  53267. /**
  53268. * The second type of ray - straight line.
  53269. * Should it be enabled or should the parabolic line be the only one.
  53270. */
  53271. straightRayEnabled: boolean;
  53272. /**
  53273. * How much rotation should be applied when rotating right and left
  53274. */
  53275. rotationAngle: number;
  53276. private _rotationEnabled;
  53277. /**
  53278. * Is rotation enabled when moving forward?
  53279. * Disabling this feature will prevent the user from deciding the direction when teleporting
  53280. */
  53281. get rotationEnabled(): boolean;
  53282. /**
  53283. * Sets wether rotation is enabled or not
  53284. * @param enabled is rotation enabled when teleportation is shown
  53285. */
  53286. set rotationEnabled(enabled: boolean);
  53287. /**
  53288. * Exposes the currently set teleportation target mesh.
  53289. */
  53290. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  53291. /**
  53292. * constructs a new anchor system
  53293. * @param _xrSessionManager an instance of WebXRSessionManager
  53294. * @param _options configuration object for this feature
  53295. */
  53296. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  53297. /**
  53298. * Get the snapPointsOnly flag
  53299. */
  53300. get snapPointsOnly(): boolean;
  53301. /**
  53302. * Sets the snapPointsOnly flag
  53303. * @param snapToPoints should teleportation be exclusively to snap points
  53304. */
  53305. set snapPointsOnly(snapToPoints: boolean);
  53306. /**
  53307. * Add a new mesh to the floor meshes array
  53308. * @param mesh the mesh to use as floor mesh
  53309. */
  53310. addFloorMesh(mesh: AbstractMesh): void;
  53311. /**
  53312. * Add a new snap-to point to fix teleportation to this position
  53313. * @param newSnapPoint The new Snap-To point
  53314. */
  53315. addSnapPoint(newSnapPoint: Vector3): void;
  53316. attach(): boolean;
  53317. detach(): boolean;
  53318. dispose(): void;
  53319. /**
  53320. * Remove a mesh from the floor meshes array
  53321. * @param mesh the mesh to remove
  53322. */
  53323. removeFloorMesh(mesh: AbstractMesh): void;
  53324. /**
  53325. * Remove a mesh from the floor meshes array using its name
  53326. * @param name the mesh name to remove
  53327. */
  53328. removeFloorMeshByName(name: string): void;
  53329. /**
  53330. * 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
  53331. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  53332. * @returns was the point found and removed or not
  53333. */
  53334. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  53335. /**
  53336. * This function sets a selection feature that will be disabled when
  53337. * the forward ray is shown and will be reattached when hidden.
  53338. * This is used to remove the selection rays when moving.
  53339. * @param selectionFeature the feature to disable when forward movement is enabled
  53340. */
  53341. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  53342. protected _onXRFrame(_xrFrame: XRFrame): void;
  53343. private _attachController;
  53344. private _createDefaultTargetMesh;
  53345. private _detachController;
  53346. private _findClosestSnapPointWithRadius;
  53347. private _setTargetMeshPosition;
  53348. private _setTargetMeshVisibility;
  53349. private _showParabolicPath;
  53350. private _teleportForward;
  53351. }
  53352. }
  53353. declare module BABYLON {
  53354. /**
  53355. * Options for the default xr helper
  53356. */
  53357. export class WebXRDefaultExperienceOptions {
  53358. /**
  53359. * Enable or disable default UI to enter XR
  53360. */
  53361. disableDefaultUI?: boolean;
  53362. /**
  53363. * Should teleportation not initialize. defaults to false.
  53364. */
  53365. disableTeleportation?: boolean;
  53366. /**
  53367. * Floor meshes that will be used for teleport
  53368. */
  53369. floorMeshes?: Array<AbstractMesh>;
  53370. /**
  53371. * If set to true, the first frame will not be used to reset position
  53372. * The first frame is mainly used when copying transformation from the old camera
  53373. * Mainly used in AR
  53374. */
  53375. ignoreNativeCameraTransformation?: boolean;
  53376. /**
  53377. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  53378. */
  53379. inputOptions?: IWebXRInputOptions;
  53380. /**
  53381. * optional configuration for the output canvas
  53382. */
  53383. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53384. /**
  53385. * optional UI options. This can be used among other to change session mode and reference space type
  53386. */
  53387. uiOptions?: WebXREnterExitUIOptions;
  53388. /**
  53389. * When loading teleportation and pointer select, use stable versions instead of latest.
  53390. */
  53391. useStablePlugins?: boolean;
  53392. /**
  53393. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53394. */
  53395. renderingGroupId?: number;
  53396. /**
  53397. * A list of optional features to init the session with
  53398. * If set to true, all features we support will be added
  53399. */
  53400. optionalFeatures?: boolean | string[];
  53401. }
  53402. /**
  53403. * Default experience which provides a similar setup to the previous webVRExperience
  53404. */
  53405. export class WebXRDefaultExperience {
  53406. /**
  53407. * Base experience
  53408. */
  53409. baseExperience: WebXRExperienceHelper;
  53410. /**
  53411. * Enables ui for entering/exiting xr
  53412. */
  53413. enterExitUI: WebXREnterExitUI;
  53414. /**
  53415. * Input experience extension
  53416. */
  53417. input: WebXRInput;
  53418. /**
  53419. * Enables laser pointer and selection
  53420. */
  53421. pointerSelection: WebXRControllerPointerSelection;
  53422. /**
  53423. * Default target xr should render to
  53424. */
  53425. renderTarget: WebXRRenderTarget;
  53426. /**
  53427. * Enables teleportation
  53428. */
  53429. teleportation: WebXRMotionControllerTeleportation;
  53430. private constructor();
  53431. /**
  53432. * Creates the default xr experience
  53433. * @param scene scene
  53434. * @param options options for basic configuration
  53435. * @returns resulting WebXRDefaultExperience
  53436. */
  53437. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53438. /**
  53439. * DIsposes of the experience helper
  53440. */
  53441. dispose(): void;
  53442. }
  53443. }
  53444. declare module BABYLON {
  53445. /**
  53446. * Options to modify the vr teleportation behavior.
  53447. */
  53448. export interface VRTeleportationOptions {
  53449. /**
  53450. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53451. */
  53452. floorMeshName?: string;
  53453. /**
  53454. * A list of meshes to be used as the teleportation floor. (default: empty)
  53455. */
  53456. floorMeshes?: Mesh[];
  53457. /**
  53458. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53459. */
  53460. teleportationMode?: number;
  53461. /**
  53462. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53463. */
  53464. teleportationTime?: number;
  53465. /**
  53466. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53467. */
  53468. teleportationSpeed?: number;
  53469. /**
  53470. * The easing function used in the animation or null for Linear. (default CircleEase)
  53471. */
  53472. easingFunction?: EasingFunction;
  53473. }
  53474. /**
  53475. * Options to modify the vr experience helper's behavior.
  53476. */
  53477. export interface VRExperienceHelperOptions extends WebVROptions {
  53478. /**
  53479. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53480. */
  53481. createDeviceOrientationCamera?: boolean;
  53482. /**
  53483. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53484. */
  53485. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53486. /**
  53487. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53488. */
  53489. laserToggle?: boolean;
  53490. /**
  53491. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53492. */
  53493. floorMeshes?: Mesh[];
  53494. /**
  53495. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53496. */
  53497. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53498. /**
  53499. * Defines if WebXR should be used instead of WebVR (if available)
  53500. */
  53501. useXR?: boolean;
  53502. }
  53503. /**
  53504. * Event containing information after VR has been entered
  53505. */
  53506. export class OnAfterEnteringVRObservableEvent {
  53507. /**
  53508. * If entering vr was successful
  53509. */
  53510. success: boolean;
  53511. }
  53512. /**
  53513. * Helps to quickly add VR support to an existing scene.
  53514. * See https://doc.babylonjs.com/how_to/webvr_helper
  53515. */
  53516. export class VRExperienceHelper {
  53517. /** Options to modify the vr experience helper's behavior. */
  53518. webVROptions: VRExperienceHelperOptions;
  53519. private _scene;
  53520. private _position;
  53521. private _btnVR;
  53522. private _btnVRDisplayed;
  53523. private _webVRsupported;
  53524. private _webVRready;
  53525. private _webVRrequesting;
  53526. private _webVRpresenting;
  53527. private _hasEnteredVR;
  53528. private _fullscreenVRpresenting;
  53529. private _inputElement;
  53530. private _webVRCamera;
  53531. private _vrDeviceOrientationCamera;
  53532. private _deviceOrientationCamera;
  53533. private _existingCamera;
  53534. private _onKeyDown;
  53535. private _onVrDisplayPresentChange;
  53536. private _onVRDisplayChanged;
  53537. private _onVRRequestPresentStart;
  53538. private _onVRRequestPresentComplete;
  53539. /**
  53540. * 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)
  53541. */
  53542. enableGazeEvenWhenNoPointerLock: boolean;
  53543. /**
  53544. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53545. */
  53546. exitVROnDoubleTap: boolean;
  53547. /**
  53548. * Observable raised right before entering VR.
  53549. */
  53550. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53551. /**
  53552. * Observable raised when entering VR has completed.
  53553. */
  53554. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53555. /**
  53556. * Observable raised when exiting VR.
  53557. */
  53558. onExitingVRObservable: Observable<VRExperienceHelper>;
  53559. /**
  53560. * Observable raised when controller mesh is loaded.
  53561. */
  53562. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53563. /** Return this.onEnteringVRObservable
  53564. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53565. */
  53566. get onEnteringVR(): Observable<VRExperienceHelper>;
  53567. /** Return this.onExitingVRObservable
  53568. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53569. */
  53570. get onExitingVR(): Observable<VRExperienceHelper>;
  53571. /** Return this.onControllerMeshLoadedObservable
  53572. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53573. */
  53574. get onControllerMeshLoaded(): Observable<WebVRController>;
  53575. private _rayLength;
  53576. private _useCustomVRButton;
  53577. private _teleportationRequested;
  53578. private _teleportActive;
  53579. private _floorMeshName;
  53580. private _floorMeshesCollection;
  53581. private _teleportationMode;
  53582. private _teleportationTime;
  53583. private _teleportationSpeed;
  53584. private _teleportationEasing;
  53585. private _rotationAllowed;
  53586. private _teleportBackwardsVector;
  53587. private _teleportationTarget;
  53588. private _isDefaultTeleportationTarget;
  53589. private _postProcessMove;
  53590. private _teleportationFillColor;
  53591. private _teleportationBorderColor;
  53592. private _rotationAngle;
  53593. private _haloCenter;
  53594. private _cameraGazer;
  53595. private _padSensibilityUp;
  53596. private _padSensibilityDown;
  53597. private _leftController;
  53598. private _rightController;
  53599. private _gazeColor;
  53600. private _laserColor;
  53601. private _pickedLaserColor;
  53602. private _pickedGazeColor;
  53603. /**
  53604. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53605. */
  53606. onNewMeshSelected: Observable<AbstractMesh>;
  53607. /**
  53608. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53609. * This observable will provide the mesh and the controller used to select the mesh
  53610. */
  53611. onMeshSelectedWithController: Observable<{
  53612. mesh: AbstractMesh;
  53613. controller: WebVRController;
  53614. }>;
  53615. /**
  53616. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53617. */
  53618. onNewMeshPicked: Observable<PickingInfo>;
  53619. private _circleEase;
  53620. /**
  53621. * Observable raised before camera teleportation
  53622. */
  53623. onBeforeCameraTeleport: Observable<Vector3>;
  53624. /**
  53625. * Observable raised after camera teleportation
  53626. */
  53627. onAfterCameraTeleport: Observable<Vector3>;
  53628. /**
  53629. * Observable raised when current selected mesh gets unselected
  53630. */
  53631. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53632. private _raySelectionPredicate;
  53633. /**
  53634. * To be optionaly changed by user to define custom ray selection
  53635. */
  53636. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53637. /**
  53638. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53639. */
  53640. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53641. /**
  53642. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53643. */
  53644. teleportationEnabled: boolean;
  53645. private _defaultHeight;
  53646. private _teleportationInitialized;
  53647. private _interactionsEnabled;
  53648. private _interactionsRequested;
  53649. private _displayGaze;
  53650. private _displayLaserPointer;
  53651. /**
  53652. * The mesh used to display where the user is going to teleport.
  53653. */
  53654. get teleportationTarget(): Mesh;
  53655. /**
  53656. * Sets the mesh to be used to display where the user is going to teleport.
  53657. */
  53658. set teleportationTarget(value: Mesh);
  53659. /**
  53660. * 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
  53661. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53662. * See https://doc.babylonjs.com/resources/baking_transformations
  53663. */
  53664. get gazeTrackerMesh(): Mesh;
  53665. set gazeTrackerMesh(value: Mesh);
  53666. /**
  53667. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53668. */
  53669. updateGazeTrackerScale: boolean;
  53670. /**
  53671. * If the gaze trackers color should be updated when selecting meshes
  53672. */
  53673. updateGazeTrackerColor: boolean;
  53674. /**
  53675. * If the controller laser color should be updated when selecting meshes
  53676. */
  53677. updateControllerLaserColor: boolean;
  53678. /**
  53679. * The gaze tracking mesh corresponding to the left controller
  53680. */
  53681. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53682. /**
  53683. * The gaze tracking mesh corresponding to the right controller
  53684. */
  53685. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53686. /**
  53687. * If the ray of the gaze should be displayed.
  53688. */
  53689. get displayGaze(): boolean;
  53690. /**
  53691. * Sets if the ray of the gaze should be displayed.
  53692. */
  53693. set displayGaze(value: boolean);
  53694. /**
  53695. * If the ray of the LaserPointer should be displayed.
  53696. */
  53697. get displayLaserPointer(): boolean;
  53698. /**
  53699. * Sets if the ray of the LaserPointer should be displayed.
  53700. */
  53701. set displayLaserPointer(value: boolean);
  53702. /**
  53703. * The deviceOrientationCamera used as the camera when not in VR.
  53704. */
  53705. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53706. /**
  53707. * Based on the current WebVR support, returns the current VR camera used.
  53708. */
  53709. get currentVRCamera(): Nullable<Camera>;
  53710. /**
  53711. * The webVRCamera which is used when in VR.
  53712. */
  53713. get webVRCamera(): WebVRFreeCamera;
  53714. /**
  53715. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53716. */
  53717. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53718. /**
  53719. * The html button that is used to trigger entering into VR.
  53720. */
  53721. get vrButton(): Nullable<HTMLButtonElement>;
  53722. private get _teleportationRequestInitiated();
  53723. /**
  53724. * Defines whether or not Pointer lock should be requested when switching to
  53725. * full screen.
  53726. */
  53727. requestPointerLockOnFullScreen: boolean;
  53728. /**
  53729. * If asking to force XR, this will be populated with the default xr experience
  53730. */
  53731. xr: WebXRDefaultExperience;
  53732. /**
  53733. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53734. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53735. */
  53736. xrTestDone: boolean;
  53737. /**
  53738. * Instantiates a VRExperienceHelper.
  53739. * Helps to quickly add VR support to an existing scene.
  53740. * @param scene The scene the VRExperienceHelper belongs to.
  53741. * @param webVROptions Options to modify the vr experience helper's behavior.
  53742. */
  53743. constructor(scene: Scene,
  53744. /** Options to modify the vr experience helper's behavior. */
  53745. webVROptions?: VRExperienceHelperOptions);
  53746. private completeVRInit;
  53747. private _onDefaultMeshLoaded;
  53748. private _onResize;
  53749. private _onFullscreenChange;
  53750. /**
  53751. * Gets a value indicating if we are currently in VR mode.
  53752. */
  53753. get isInVRMode(): boolean;
  53754. private onVrDisplayPresentChange;
  53755. private onVRDisplayChanged;
  53756. private moveButtonToBottomRight;
  53757. private displayVRButton;
  53758. private updateButtonVisibility;
  53759. private _cachedAngularSensibility;
  53760. /**
  53761. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53762. * Otherwise, will use the fullscreen API.
  53763. */
  53764. enterVR(): void;
  53765. /**
  53766. * Attempt to exit VR, or fullscreen.
  53767. */
  53768. exitVR(): void;
  53769. /**
  53770. * The position of the vr experience helper.
  53771. */
  53772. get position(): Vector3;
  53773. /**
  53774. * Sets the position of the vr experience helper.
  53775. */
  53776. set position(value: Vector3);
  53777. /**
  53778. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53779. */
  53780. enableInteractions(): void;
  53781. private get _noControllerIsActive();
  53782. private beforeRender;
  53783. private _isTeleportationFloor;
  53784. /**
  53785. * Adds a floor mesh to be used for teleportation.
  53786. * @param floorMesh the mesh to be used for teleportation.
  53787. */
  53788. addFloorMesh(floorMesh: Mesh): void;
  53789. /**
  53790. * Removes a floor mesh from being used for teleportation.
  53791. * @param floorMesh the mesh to be removed.
  53792. */
  53793. removeFloorMesh(floorMesh: Mesh): void;
  53794. /**
  53795. * Enables interactions and teleportation using the VR controllers and gaze.
  53796. * @param vrTeleportationOptions options to modify teleportation behavior.
  53797. */
  53798. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53799. private _onNewGamepadConnected;
  53800. private _tryEnableInteractionOnController;
  53801. private _onNewGamepadDisconnected;
  53802. private _enableInteractionOnController;
  53803. private _checkTeleportWithRay;
  53804. private _checkRotate;
  53805. private _checkTeleportBackwards;
  53806. private _enableTeleportationOnController;
  53807. private _createTeleportationCircles;
  53808. private _displayTeleportationTarget;
  53809. private _hideTeleportationTarget;
  53810. private _rotateCamera;
  53811. private _moveTeleportationSelectorTo;
  53812. private _workingVector;
  53813. private _workingQuaternion;
  53814. private _workingMatrix;
  53815. /**
  53816. * Time Constant Teleportation Mode
  53817. */
  53818. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53819. /**
  53820. * Speed Constant Teleportation Mode
  53821. */
  53822. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53823. /**
  53824. * Teleports the users feet to the desired location
  53825. * @param location The location where the user's feet should be placed
  53826. */
  53827. teleportCamera(location: Vector3): void;
  53828. private _convertNormalToDirectionOfRay;
  53829. private _castRayAndSelectObject;
  53830. private _notifySelectedMeshUnselected;
  53831. /**
  53832. * Permanently set new colors for the laser pointer
  53833. * @param color the new laser color
  53834. * @param pickedColor the new laser color when picked mesh detected
  53835. */
  53836. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53837. /**
  53838. * Set lighting enabled / disabled on the laser pointer of both controllers
  53839. * @param enabled should the lighting be enabled on the laser pointer
  53840. */
  53841. setLaserLightingState(enabled?: boolean): void;
  53842. /**
  53843. * Permanently set new colors for the gaze pointer
  53844. * @param color the new gaze color
  53845. * @param pickedColor the new gaze color when picked mesh detected
  53846. */
  53847. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53848. /**
  53849. * Sets the color of the laser ray from the vr controllers.
  53850. * @param color new color for the ray.
  53851. */
  53852. changeLaserColor(color: Color3): void;
  53853. /**
  53854. * Sets the color of the ray from the vr headsets gaze.
  53855. * @param color new color for the ray.
  53856. */
  53857. changeGazeColor(color: Color3): void;
  53858. /**
  53859. * Exits VR and disposes of the vr experience helper
  53860. */
  53861. dispose(): void;
  53862. /**
  53863. * Gets the name of the VRExperienceHelper class
  53864. * @returns "VRExperienceHelper"
  53865. */
  53866. getClassName(): string;
  53867. }
  53868. }
  53869. declare module BABYLON {
  53870. /**
  53871. * Contains an array of blocks representing the octree
  53872. */
  53873. export interface IOctreeContainer<T> {
  53874. /**
  53875. * Blocks within the octree
  53876. */
  53877. blocks: Array<OctreeBlock<T>>;
  53878. }
  53879. /**
  53880. * Class used to store a cell in an octree
  53881. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53882. */
  53883. export class OctreeBlock<T> {
  53884. /**
  53885. * Gets the content of the current block
  53886. */
  53887. entries: T[];
  53888. /**
  53889. * Gets the list of block children
  53890. */
  53891. blocks: Array<OctreeBlock<T>>;
  53892. private _depth;
  53893. private _maxDepth;
  53894. private _capacity;
  53895. private _minPoint;
  53896. private _maxPoint;
  53897. private _boundingVectors;
  53898. private _creationFunc;
  53899. /**
  53900. * Creates a new block
  53901. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53902. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53903. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53904. * @param depth defines the current depth of this block in the octree
  53905. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53906. * @param creationFunc defines a callback to call when an element is added to the block
  53907. */
  53908. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53909. /**
  53910. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53911. */
  53912. get capacity(): number;
  53913. /**
  53914. * Gets the minimum vector (in world space) of the block's bounding box
  53915. */
  53916. get minPoint(): Vector3;
  53917. /**
  53918. * Gets the maximum vector (in world space) of the block's bounding box
  53919. */
  53920. get maxPoint(): Vector3;
  53921. /**
  53922. * Add a new element to this block
  53923. * @param entry defines the element to add
  53924. */
  53925. addEntry(entry: T): void;
  53926. /**
  53927. * Remove an element from this block
  53928. * @param entry defines the element to remove
  53929. */
  53930. removeEntry(entry: T): void;
  53931. /**
  53932. * Add an array of elements to this block
  53933. * @param entries defines the array of elements to add
  53934. */
  53935. addEntries(entries: T[]): void;
  53936. /**
  53937. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53938. * @param frustumPlanes defines the frustum planes to test
  53939. * @param selection defines the array to store current content if selection is positive
  53940. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53941. */
  53942. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53943. /**
  53944. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53945. * @param sphereCenter defines the bounding sphere center
  53946. * @param sphereRadius defines the bounding sphere radius
  53947. * @param selection defines the array to store current content if selection is positive
  53948. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53949. */
  53950. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53951. /**
  53952. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53953. * @param ray defines the ray to test with
  53954. * @param selection defines the array to store current content if selection is positive
  53955. */
  53956. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53957. /**
  53958. * Subdivide the content into child blocks (this block will then be empty)
  53959. */
  53960. createInnerBlocks(): void;
  53961. /**
  53962. * @hidden
  53963. */
  53964. 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;
  53965. }
  53966. }
  53967. declare module BABYLON {
  53968. /**
  53969. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53970. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53971. */
  53972. export class Octree<T> {
  53973. /** 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.) */
  53974. maxDepth: number;
  53975. /**
  53976. * Blocks within the octree containing objects
  53977. */
  53978. blocks: Array<OctreeBlock<T>>;
  53979. /**
  53980. * Content stored in the octree
  53981. */
  53982. dynamicContent: T[];
  53983. private _maxBlockCapacity;
  53984. private _selectionContent;
  53985. private _creationFunc;
  53986. /**
  53987. * Creates a octree
  53988. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53989. * @param creationFunc function to be used to instatiate the octree
  53990. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53991. * @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.)
  53992. */
  53993. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53994. /** 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.) */
  53995. maxDepth?: number);
  53996. /**
  53997. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53998. * @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);
  53999. * @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);
  54000. * @param entries meshes to be added to the octree blocks
  54001. */
  54002. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  54003. /**
  54004. * Adds a mesh to the octree
  54005. * @param entry Mesh to add to the octree
  54006. */
  54007. addMesh(entry: T): void;
  54008. /**
  54009. * Remove an element from the octree
  54010. * @param entry defines the element to remove
  54011. */
  54012. removeMesh(entry: T): void;
  54013. /**
  54014. * Selects an array of meshes within the frustum
  54015. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  54016. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  54017. * @returns array of meshes within the frustum
  54018. */
  54019. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  54020. /**
  54021. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  54022. * @param sphereCenter defines the bounding sphere center
  54023. * @param sphereRadius defines the bounding sphere radius
  54024. * @param allowDuplicate defines if the selection array can contains duplicated entries
  54025. * @returns an array of objects that intersect the sphere
  54026. */
  54027. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  54028. /**
  54029. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  54030. * @param ray defines the ray to test with
  54031. * @returns array of intersected objects
  54032. */
  54033. intersectsRay(ray: Ray): SmartArray<T>;
  54034. /**
  54035. * Adds a mesh into the octree block if it intersects the block
  54036. */
  54037. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  54038. /**
  54039. * Adds a submesh into the octree block if it intersects the block
  54040. */
  54041. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  54042. }
  54043. }
  54044. declare module BABYLON {
  54045. interface Scene {
  54046. /**
  54047. * @hidden
  54048. * Backing Filed
  54049. */
  54050. _selectionOctree: Octree<AbstractMesh>;
  54051. /**
  54052. * Gets the octree used to boost mesh selection (picking)
  54053. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54054. */
  54055. selectionOctree: Octree<AbstractMesh>;
  54056. /**
  54057. * Creates or updates the octree used to boost selection (picking)
  54058. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54059. * @param maxCapacity defines the maximum capacity per leaf
  54060. * @param maxDepth defines the maximum depth of the octree
  54061. * @returns an octree of AbstractMesh
  54062. */
  54063. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  54064. }
  54065. interface AbstractMesh {
  54066. /**
  54067. * @hidden
  54068. * Backing Field
  54069. */
  54070. _submeshesOctree: Octree<SubMesh>;
  54071. /**
  54072. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  54073. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  54074. * @param maxCapacity defines the maximum size of each block (64 by default)
  54075. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  54076. * @returns the new octree
  54077. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  54078. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54079. */
  54080. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  54081. }
  54082. /**
  54083. * Defines the octree scene component responsible to manage any octrees
  54084. * in a given scene.
  54085. */
  54086. export class OctreeSceneComponent {
  54087. /**
  54088. * The component name help to identify the component in the list of scene components.
  54089. */
  54090. readonly name: string;
  54091. /**
  54092. * The scene the component belongs to.
  54093. */
  54094. scene: Scene;
  54095. /**
  54096. * Indicates if the meshes have been checked to make sure they are isEnabled()
  54097. */
  54098. readonly checksIsEnabled: boolean;
  54099. /**
  54100. * Creates a new instance of the component for the given scene
  54101. * @param scene Defines the scene to register the component in
  54102. */
  54103. constructor(scene: Scene);
  54104. /**
  54105. * Registers the component in a given scene
  54106. */
  54107. register(): void;
  54108. /**
  54109. * Return the list of active meshes
  54110. * @returns the list of active meshes
  54111. */
  54112. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  54113. /**
  54114. * Return the list of active sub meshes
  54115. * @param mesh The mesh to get the candidates sub meshes from
  54116. * @returns the list of active sub meshes
  54117. */
  54118. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  54119. private _tempRay;
  54120. /**
  54121. * Return the list of sub meshes intersecting with a given local ray
  54122. * @param mesh defines the mesh to find the submesh for
  54123. * @param localRay defines the ray in local space
  54124. * @returns the list of intersecting sub meshes
  54125. */
  54126. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  54127. /**
  54128. * Return the list of sub meshes colliding with a collider
  54129. * @param mesh defines the mesh to find the submesh for
  54130. * @param collider defines the collider to evaluate the collision against
  54131. * @returns the list of colliding sub meshes
  54132. */
  54133. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  54134. /**
  54135. * Rebuilds the elements related to this component in case of
  54136. * context lost for instance.
  54137. */
  54138. rebuild(): void;
  54139. /**
  54140. * Disposes the component and the associated ressources.
  54141. */
  54142. dispose(): void;
  54143. }
  54144. }
  54145. declare module BABYLON {
  54146. /**
  54147. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  54148. */
  54149. export interface GizmoAxisCache {
  54150. /** Mesh used to runder the Gizmo */
  54151. gizmoMeshes: Mesh[];
  54152. /** Mesh used to detect user interaction with Gizmo */
  54153. colliderMeshes: Mesh[];
  54154. /** Material used to inicate color of gizmo mesh */
  54155. material: StandardMaterial;
  54156. /** Material used to inicate hover state of the Gizmo */
  54157. hoverMaterial: StandardMaterial;
  54158. /** Material used to inicate disabled state of the Gizmo */
  54159. disableMaterial: StandardMaterial;
  54160. /** Used to indicate Active state of the Gizmo */
  54161. active: boolean;
  54162. }
  54163. /**
  54164. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  54165. */
  54166. export class Gizmo implements IDisposable {
  54167. /** The utility layer the gizmo will be added to */
  54168. gizmoLayer: UtilityLayerRenderer;
  54169. /**
  54170. * The root mesh of the gizmo
  54171. */
  54172. _rootMesh: Mesh;
  54173. private _attachedMesh;
  54174. private _attachedNode;
  54175. /**
  54176. * Ratio for the scale of the gizmo (Default: 1)
  54177. */
  54178. protected _scaleRatio: number;
  54179. /**
  54180. * boolean updated by pointermove when a gizmo mesh is hovered
  54181. */
  54182. protected _isHovered: boolean;
  54183. /**
  54184. * Ratio for the scale of the gizmo (Default: 1)
  54185. */
  54186. set scaleRatio(value: number);
  54187. get scaleRatio(): number;
  54188. /**
  54189. * True when the mouse pointer is hovered a gizmo mesh
  54190. */
  54191. get isHovered(): boolean;
  54192. /**
  54193. * If a custom mesh has been set (Default: false)
  54194. */
  54195. protected _customMeshSet: boolean;
  54196. /**
  54197. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  54198. * * When set, interactions will be enabled
  54199. */
  54200. get attachedMesh(): Nullable<AbstractMesh>;
  54201. set attachedMesh(value: Nullable<AbstractMesh>);
  54202. /**
  54203. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  54204. * * When set, interactions will be enabled
  54205. */
  54206. get attachedNode(): Nullable<Node>;
  54207. set attachedNode(value: Nullable<Node>);
  54208. /**
  54209. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54210. * @param mesh The mesh to replace the default mesh of the gizmo
  54211. */
  54212. setCustomMesh(mesh: Mesh): void;
  54213. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  54214. /**
  54215. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  54216. */
  54217. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54218. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54219. /**
  54220. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  54221. */
  54222. updateGizmoPositionToMatchAttachedMesh: boolean;
  54223. /**
  54224. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  54225. */
  54226. updateScale: boolean;
  54227. protected _interactionsEnabled: boolean;
  54228. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54229. private _beforeRenderObserver;
  54230. private _tempQuaternion;
  54231. private _tempVector;
  54232. private _tempVector2;
  54233. private _tempMatrix1;
  54234. private _tempMatrix2;
  54235. private _rightHandtoLeftHandMatrix;
  54236. /**
  54237. * Creates a gizmo
  54238. * @param gizmoLayer The utility layer the gizmo will be added to
  54239. */
  54240. constructor(
  54241. /** The utility layer the gizmo will be added to */
  54242. gizmoLayer?: UtilityLayerRenderer);
  54243. /**
  54244. * Updates the gizmo to match the attached mesh's position/rotation
  54245. */
  54246. protected _update(): void;
  54247. /**
  54248. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  54249. * @param value Node, TransformNode or mesh
  54250. */
  54251. protected _matrixChanged(): void;
  54252. /**
  54253. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  54254. * @param gizmoLayer The utility layer the gizmo will be added to
  54255. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54256. * @returns {Observer<PointerInfo>} pointerObserver
  54257. */
  54258. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  54259. /**
  54260. * Disposes of the gizmo
  54261. */
  54262. dispose(): void;
  54263. }
  54264. }
  54265. declare module BABYLON {
  54266. /**
  54267. * Single plane drag gizmo
  54268. */
  54269. export class PlaneDragGizmo extends Gizmo {
  54270. /**
  54271. * Drag behavior responsible for the gizmos dragging interactions
  54272. */
  54273. dragBehavior: PointerDragBehavior;
  54274. private _pointerObserver;
  54275. /**
  54276. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54277. */
  54278. snapDistance: number;
  54279. /**
  54280. * Event that fires each time the gizmo snaps to a new location.
  54281. * * snapDistance is the the change in distance
  54282. */
  54283. onSnapObservable: Observable<{
  54284. snapDistance: number;
  54285. }>;
  54286. private _gizmoMesh;
  54287. private _coloredMaterial;
  54288. private _hoverMaterial;
  54289. private _disableMaterial;
  54290. private _isEnabled;
  54291. private _parent;
  54292. private _dragging;
  54293. /** @hidden */
  54294. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  54295. /**
  54296. * Creates a PlaneDragGizmo
  54297. * @param gizmoLayer The utility layer the gizmo will be added to
  54298. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  54299. * @param color The color of the gizmo
  54300. */
  54301. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  54302. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54303. /**
  54304. * If the gizmo is enabled
  54305. */
  54306. set isEnabled(value: boolean);
  54307. get isEnabled(): boolean;
  54308. /**
  54309. * Disposes of the gizmo
  54310. */
  54311. dispose(): void;
  54312. }
  54313. }
  54314. declare module BABYLON {
  54315. /**
  54316. * Single plane rotation gizmo
  54317. */
  54318. export class PlaneRotationGizmo extends Gizmo {
  54319. /**
  54320. * Drag behavior responsible for the gizmos dragging interactions
  54321. */
  54322. dragBehavior: PointerDragBehavior;
  54323. private _pointerObserver;
  54324. /**
  54325. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54326. */
  54327. snapDistance: number;
  54328. /**
  54329. * Event that fires each time the gizmo snaps to a new location.
  54330. * * snapDistance is the the change in distance
  54331. */
  54332. onSnapObservable: Observable<{
  54333. snapDistance: number;
  54334. }>;
  54335. private _isEnabled;
  54336. private _parent;
  54337. private _coloredMaterial;
  54338. private _hoverMaterial;
  54339. private _disableMaterial;
  54340. private _gizmoMesh;
  54341. private _rotationCircle;
  54342. private _dragging;
  54343. private static _CircleConstants;
  54344. /**
  54345. * Creates a PlaneRotationGizmo
  54346. * @param gizmoLayer The utility layer the gizmo will be added to
  54347. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54348. * @param color The color of the gizmo
  54349. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54350. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54351. * @param thickness display gizmo axis thickness
  54352. */
  54353. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  54354. /** Create Geometry for Gizmo */
  54355. private _createGizmoMesh;
  54356. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54357. private setupRotationCircle;
  54358. private updateRotationPath;
  54359. private updateRotationCircle;
  54360. /**
  54361. * If the gizmo is enabled
  54362. */
  54363. set isEnabled(value: boolean);
  54364. get isEnabled(): boolean;
  54365. /**
  54366. * Disposes of the gizmo
  54367. */
  54368. dispose(): void;
  54369. }
  54370. }
  54371. declare module BABYLON {
  54372. /**
  54373. * Gizmo that enables rotating a mesh along 3 axis
  54374. */
  54375. export class RotationGizmo extends Gizmo {
  54376. /**
  54377. * Internal gizmo used for interactions on the x axis
  54378. */
  54379. xGizmo: PlaneRotationGizmo;
  54380. /**
  54381. * Internal gizmo used for interactions on the y axis
  54382. */
  54383. yGizmo: PlaneRotationGizmo;
  54384. /**
  54385. * Internal gizmo used for interactions on the z axis
  54386. */
  54387. zGizmo: PlaneRotationGizmo;
  54388. /** Fires an event when any of it's sub gizmos are dragged */
  54389. onDragStartObservable: Observable<unknown>;
  54390. /** Fires an event when any of it's sub gizmos are released from dragging */
  54391. onDragEndObservable: Observable<unknown>;
  54392. private _meshAttached;
  54393. private _nodeAttached;
  54394. private _observables;
  54395. /** Node Caching for quick lookup */
  54396. private _gizmoAxisCache;
  54397. get attachedMesh(): Nullable<AbstractMesh>;
  54398. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54399. get attachedNode(): Nullable<Node>;
  54400. set attachedNode(node: Nullable<Node>);
  54401. protected _checkBillboardTransform(): void;
  54402. /**
  54403. * True when the mouse pointer is hovering a gizmo mesh
  54404. */
  54405. get isHovered(): boolean;
  54406. /**
  54407. * Creates a RotationGizmo
  54408. * @param gizmoLayer The utility layer the gizmo will be added to
  54409. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54410. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54411. * @param thickness display gizmo axis thickness
  54412. */
  54413. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  54414. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54415. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54416. /**
  54417. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54418. */
  54419. set snapDistance(value: number);
  54420. get snapDistance(): number;
  54421. /**
  54422. * Ratio for the scale of the gizmo (Default: 1)
  54423. */
  54424. set scaleRatio(value: number);
  54425. get scaleRatio(): number;
  54426. /**
  54427. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54428. * @param mesh Axis gizmo mesh
  54429. * @param cache Gizmo axis definition used for reactive gizmo UI
  54430. */
  54431. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54432. /**
  54433. * Disposes of the gizmo
  54434. */
  54435. dispose(): void;
  54436. /**
  54437. * CustomMeshes are not supported by this gizmo
  54438. * @param mesh The mesh to replace the default mesh of the gizmo
  54439. */
  54440. setCustomMesh(mesh: Mesh): void;
  54441. }
  54442. }
  54443. declare module BABYLON {
  54444. /**
  54445. * Class containing static functions to help procedurally build meshes
  54446. */
  54447. export class PolyhedronBuilder {
  54448. /**
  54449. * Creates a polyhedron mesh
  54450. * * 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
  54451. * * The parameter `size` (positive float, default 1) sets the polygon size
  54452. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54453. * * 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`
  54454. * * 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
  54455. * * 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)`)
  54456. * * 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
  54457. * * 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
  54458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54459. * * 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
  54460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54461. * @param name defines the name of the mesh
  54462. * @param options defines the options used to create the mesh
  54463. * @param scene defines the hosting scene
  54464. * @returns the polyhedron mesh
  54465. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54466. */
  54467. static CreatePolyhedron(name: string, options: {
  54468. type?: number;
  54469. size?: number;
  54470. sizeX?: number;
  54471. sizeY?: number;
  54472. sizeZ?: number;
  54473. custom?: any;
  54474. faceUV?: Vector4[];
  54475. faceColors?: Color4[];
  54476. flat?: boolean;
  54477. updatable?: boolean;
  54478. sideOrientation?: number;
  54479. frontUVs?: Vector4;
  54480. backUVs?: Vector4;
  54481. }, scene?: Nullable<Scene>): Mesh;
  54482. }
  54483. }
  54484. declare module BABYLON {
  54485. /**
  54486. * Class containing static functions to help procedurally build meshes
  54487. */
  54488. export class BoxBuilder {
  54489. /**
  54490. * Creates a box mesh
  54491. * * The parameter `size` sets the size (float) of each box side (default 1)
  54492. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54493. * * 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)
  54494. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54496. * * 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
  54497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54498. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54499. * @param name defines the name of the mesh
  54500. * @param options defines the options used to create the mesh
  54501. * @param scene defines the hosting scene
  54502. * @returns the box mesh
  54503. */
  54504. static CreateBox(name: string, options: {
  54505. size?: number;
  54506. width?: number;
  54507. height?: number;
  54508. depth?: number;
  54509. faceUV?: Vector4[];
  54510. faceColors?: Color4[];
  54511. sideOrientation?: number;
  54512. frontUVs?: Vector4;
  54513. backUVs?: Vector4;
  54514. wrap?: boolean;
  54515. topBaseAt?: number;
  54516. bottomBaseAt?: number;
  54517. updatable?: boolean;
  54518. }, scene?: Nullable<Scene>): Mesh;
  54519. }
  54520. }
  54521. declare module BABYLON {
  54522. /**
  54523. * Single axis scale gizmo
  54524. */
  54525. export class AxisScaleGizmo extends Gizmo {
  54526. /**
  54527. * Drag behavior responsible for the gizmos dragging interactions
  54528. */
  54529. dragBehavior: PointerDragBehavior;
  54530. private _pointerObserver;
  54531. /**
  54532. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54533. */
  54534. snapDistance: number;
  54535. /**
  54536. * Event that fires each time the gizmo snaps to a new location.
  54537. * * snapDistance is the the change in distance
  54538. */
  54539. onSnapObservable: Observable<{
  54540. snapDistance: number;
  54541. }>;
  54542. /**
  54543. * If the scaling operation should be done on all axis (default: false)
  54544. */
  54545. uniformScaling: boolean;
  54546. /**
  54547. * Custom sensitivity value for the drag strength
  54548. */
  54549. sensitivity: number;
  54550. private _isEnabled;
  54551. private _parent;
  54552. private _gizmoMesh;
  54553. private _coloredMaterial;
  54554. private _hoverMaterial;
  54555. private _disableMaterial;
  54556. private _dragging;
  54557. private _tmpVector;
  54558. private _tmpMatrix;
  54559. private _tmpMatrix2;
  54560. /**
  54561. * Creates an AxisScaleGizmo
  54562. * @param gizmoLayer The utility layer the gizmo will be added to
  54563. * @param dragAxis The axis which the gizmo will be able to scale on
  54564. * @param color The color of the gizmo
  54565. * @param thickness display gizmo axis thickness
  54566. */
  54567. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  54568. /** Create Geometry for Gizmo */
  54569. private _createGizmoMesh;
  54570. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54571. /**
  54572. * If the gizmo is enabled
  54573. */
  54574. set isEnabled(value: boolean);
  54575. get isEnabled(): boolean;
  54576. /**
  54577. * Disposes of the gizmo
  54578. */
  54579. dispose(): void;
  54580. /**
  54581. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54582. * @param mesh The mesh to replace the default mesh of the gizmo
  54583. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54584. */
  54585. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54586. }
  54587. }
  54588. declare module BABYLON {
  54589. /**
  54590. * Gizmo that enables scaling a mesh along 3 axis
  54591. */
  54592. export class ScaleGizmo extends Gizmo {
  54593. /**
  54594. * Internal gizmo used for interactions on the x axis
  54595. */
  54596. xGizmo: AxisScaleGizmo;
  54597. /**
  54598. * Internal gizmo used for interactions on the y axis
  54599. */
  54600. yGizmo: AxisScaleGizmo;
  54601. /**
  54602. * Internal gizmo used for interactions on the z axis
  54603. */
  54604. zGizmo: AxisScaleGizmo;
  54605. /**
  54606. * Internal gizmo used to scale all axis equally
  54607. */
  54608. uniformScaleGizmo: AxisScaleGizmo;
  54609. private _meshAttached;
  54610. private _nodeAttached;
  54611. private _snapDistance;
  54612. private _uniformScalingMesh;
  54613. private _octahedron;
  54614. private _sensitivity;
  54615. private _coloredMaterial;
  54616. private _hoverMaterial;
  54617. private _disableMaterial;
  54618. private _observables;
  54619. /** Node Caching for quick lookup */
  54620. private _gizmoAxisCache;
  54621. /** Fires an event when any of it's sub gizmos are dragged */
  54622. onDragStartObservable: Observable<unknown>;
  54623. /** Fires an event when any of it's sub gizmos are released from dragging */
  54624. onDragEndObservable: Observable<unknown>;
  54625. get attachedMesh(): Nullable<AbstractMesh>;
  54626. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54627. get attachedNode(): Nullable<Node>;
  54628. set attachedNode(node: Nullable<Node>);
  54629. /**
  54630. * True when the mouse pointer is hovering a gizmo mesh
  54631. */
  54632. get isHovered(): boolean;
  54633. /**
  54634. * Creates a ScaleGizmo
  54635. * @param gizmoLayer The utility layer the gizmo will be added to
  54636. * @param thickness display gizmo axis thickness
  54637. */
  54638. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54639. /** Create Geometry for Gizmo */
  54640. private _createUniformScaleMesh;
  54641. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54642. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54643. /**
  54644. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54645. */
  54646. set snapDistance(value: number);
  54647. get snapDistance(): number;
  54648. /**
  54649. * Ratio for the scale of the gizmo (Default: 1)
  54650. */
  54651. set scaleRatio(value: number);
  54652. get scaleRatio(): number;
  54653. /**
  54654. * Sensitivity factor for dragging (Default: 1)
  54655. */
  54656. set sensitivity(value: number);
  54657. get sensitivity(): number;
  54658. /**
  54659. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54660. * @param mesh Axis gizmo mesh
  54661. * @param cache Gizmo axis definition used for reactive gizmo UI
  54662. */
  54663. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54664. /**
  54665. * Disposes of the gizmo
  54666. */
  54667. dispose(): void;
  54668. }
  54669. }
  54670. declare module BABYLON {
  54671. /**
  54672. * Bounding box gizmo
  54673. */
  54674. export class BoundingBoxGizmo extends Gizmo {
  54675. private _lineBoundingBox;
  54676. private _rotateSpheresParent;
  54677. private _scaleBoxesParent;
  54678. private _boundingDimensions;
  54679. private _renderObserver;
  54680. private _pointerObserver;
  54681. private _scaleDragSpeed;
  54682. private _tmpQuaternion;
  54683. private _tmpVector;
  54684. private _tmpRotationMatrix;
  54685. /**
  54686. * 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)
  54687. */
  54688. ignoreChildren: boolean;
  54689. /**
  54690. * 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)
  54691. */
  54692. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54693. /**
  54694. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54695. */
  54696. rotationSphereSize: number;
  54697. /**
  54698. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54699. */
  54700. scaleBoxSize: number;
  54701. /**
  54702. * 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)
  54703. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  54704. */
  54705. fixedDragMeshScreenSize: boolean;
  54706. /**
  54707. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  54708. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  54709. */
  54710. fixedDragMeshBoundsSize: boolean;
  54711. /**
  54712. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54713. */
  54714. fixedDragMeshScreenSizeDistanceFactor: number;
  54715. /**
  54716. * Fired when a rotation sphere or scale box is dragged
  54717. */
  54718. onDragStartObservable: Observable<{}>;
  54719. /**
  54720. * Fired when a scale box is dragged
  54721. */
  54722. onScaleBoxDragObservable: Observable<{}>;
  54723. /**
  54724. * Fired when a scale box drag is ended
  54725. */
  54726. onScaleBoxDragEndObservable: Observable<{}>;
  54727. /**
  54728. * Fired when a rotation sphere is dragged
  54729. */
  54730. onRotationSphereDragObservable: Observable<{}>;
  54731. /**
  54732. * Fired when a rotation sphere drag is ended
  54733. */
  54734. onRotationSphereDragEndObservable: Observable<{}>;
  54735. /**
  54736. * 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)
  54737. */
  54738. scalePivot: Nullable<Vector3>;
  54739. /**
  54740. * Mesh used as a pivot to rotate the attached node
  54741. */
  54742. private _anchorMesh;
  54743. private _existingMeshScale;
  54744. private _dragMesh;
  54745. private pointerDragBehavior;
  54746. private coloredMaterial;
  54747. private hoverColoredMaterial;
  54748. /**
  54749. * Sets the color of the bounding box gizmo
  54750. * @param color the color to set
  54751. */
  54752. setColor(color: Color3): void;
  54753. /**
  54754. * Creates an BoundingBoxGizmo
  54755. * @param gizmoLayer The utility layer the gizmo will be added to
  54756. * @param color The color of the gizmo
  54757. */
  54758. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54759. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  54760. private _selectNode;
  54761. /**
  54762. * Updates the bounding box information for the Gizmo
  54763. */
  54764. updateBoundingBox(): void;
  54765. private _updateRotationSpheres;
  54766. private _updateScaleBoxes;
  54767. /**
  54768. * Enables rotation on the specified axis and disables rotation on the others
  54769. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54770. */
  54771. setEnabledRotationAxis(axis: string): void;
  54772. /**
  54773. * Enables/disables scaling
  54774. * @param enable if scaling should be enabled
  54775. * @param homogeneousScaling defines if scaling should only be homogeneous
  54776. */
  54777. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54778. private _updateDummy;
  54779. /**
  54780. * Enables a pointer drag behavior on the bounding box of the gizmo
  54781. */
  54782. enableDragBehavior(): void;
  54783. /**
  54784. * Disposes of the gizmo
  54785. */
  54786. dispose(): void;
  54787. /**
  54788. * 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)
  54789. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54790. * @returns the bounding box mesh with the passed in mesh as a child
  54791. */
  54792. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54793. /**
  54794. * CustomMeshes are not supported by this gizmo
  54795. * @param mesh The mesh to replace the default mesh of the gizmo
  54796. */
  54797. setCustomMesh(mesh: Mesh): void;
  54798. }
  54799. }
  54800. declare module BABYLON {
  54801. /**
  54802. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54803. */
  54804. export class GizmoManager implements IDisposable {
  54805. private scene;
  54806. /**
  54807. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54808. */
  54809. gizmos: {
  54810. positionGizmo: Nullable<PositionGizmo>;
  54811. rotationGizmo: Nullable<RotationGizmo>;
  54812. scaleGizmo: Nullable<ScaleGizmo>;
  54813. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54814. };
  54815. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54816. clearGizmoOnEmptyPointerEvent: boolean;
  54817. /** Fires an event when the manager is attached to a mesh */
  54818. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54819. /** Fires an event when the manager is attached to a node */
  54820. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54821. private _gizmosEnabled;
  54822. private _pointerObservers;
  54823. private _attachedMesh;
  54824. private _attachedNode;
  54825. private _boundingBoxColor;
  54826. private _defaultUtilityLayer;
  54827. private _defaultKeepDepthUtilityLayer;
  54828. private _thickness;
  54829. /** Node Caching for quick lookup */
  54830. private _gizmoAxisCache;
  54831. /**
  54832. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54833. */
  54834. boundingBoxDragBehavior: SixDofDragBehavior;
  54835. /**
  54836. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54837. */
  54838. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54839. /**
  54840. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54841. */
  54842. attachableNodes: Nullable<Array<Node>>;
  54843. /**
  54844. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54845. */
  54846. usePointerToAttachGizmos: boolean;
  54847. /**
  54848. * Utility layer that the bounding box gizmo belongs to
  54849. */
  54850. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54851. /**
  54852. * Utility layer that all gizmos besides bounding box belong to
  54853. */
  54854. get utilityLayer(): UtilityLayerRenderer;
  54855. /**
  54856. * True when the mouse pointer is hovering a gizmo mesh
  54857. */
  54858. get isHovered(): boolean;
  54859. /**
  54860. * Instatiates a gizmo manager
  54861. * @param scene the scene to overlay the gizmos on top of
  54862. * @param thickness display gizmo axis thickness
  54863. * @param utilityLayer the layer where gizmos are rendered
  54864. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  54865. */
  54866. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  54867. /**
  54868. * Subscribes to pointer down events, for attaching and detaching mesh
  54869. * @param scene The sceme layer the observer will be added to
  54870. */
  54871. private _attachToMeshPointerObserver;
  54872. /**
  54873. * Attaches a set of gizmos to the specified mesh
  54874. * @param mesh The mesh the gizmo's should be attached to
  54875. */
  54876. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54877. /**
  54878. * Attaches a set of gizmos to the specified node
  54879. * @param node The node the gizmo's should be attached to
  54880. */
  54881. attachToNode(node: Nullable<Node>): void;
  54882. /**
  54883. * If the position gizmo is enabled
  54884. */
  54885. set positionGizmoEnabled(value: boolean);
  54886. get positionGizmoEnabled(): boolean;
  54887. /**
  54888. * If the rotation gizmo is enabled
  54889. */
  54890. set rotationGizmoEnabled(value: boolean);
  54891. get rotationGizmoEnabled(): boolean;
  54892. /**
  54893. * If the scale gizmo is enabled
  54894. */
  54895. set scaleGizmoEnabled(value: boolean);
  54896. get scaleGizmoEnabled(): boolean;
  54897. /**
  54898. * If the boundingBox gizmo is enabled
  54899. */
  54900. set boundingBoxGizmoEnabled(value: boolean);
  54901. get boundingBoxGizmoEnabled(): boolean;
  54902. /**
  54903. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54904. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54905. */
  54906. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  54907. /**
  54908. * Disposes of the gizmo manager
  54909. */
  54910. dispose(): void;
  54911. }
  54912. }
  54913. declare module BABYLON {
  54914. /**
  54915. * Gizmo that enables dragging a mesh along 3 axis
  54916. */
  54917. export class PositionGizmo extends Gizmo {
  54918. /**
  54919. * Internal gizmo used for interactions on the x axis
  54920. */
  54921. xGizmo: AxisDragGizmo;
  54922. /**
  54923. * Internal gizmo used for interactions on the y axis
  54924. */
  54925. yGizmo: AxisDragGizmo;
  54926. /**
  54927. * Internal gizmo used for interactions on the z axis
  54928. */
  54929. zGizmo: AxisDragGizmo;
  54930. /**
  54931. * Internal gizmo used for interactions on the yz plane
  54932. */
  54933. xPlaneGizmo: PlaneDragGizmo;
  54934. /**
  54935. * Internal gizmo used for interactions on the xz plane
  54936. */
  54937. yPlaneGizmo: PlaneDragGizmo;
  54938. /**
  54939. * Internal gizmo used for interactions on the xy plane
  54940. */
  54941. zPlaneGizmo: PlaneDragGizmo;
  54942. /**
  54943. * private variables
  54944. */
  54945. private _meshAttached;
  54946. private _nodeAttached;
  54947. private _snapDistance;
  54948. private _observables;
  54949. /** Node Caching for quick lookup */
  54950. private _gizmoAxisCache;
  54951. /** Fires an event when any of it's sub gizmos are dragged */
  54952. onDragStartObservable: Observable<unknown>;
  54953. /** Fires an event when any of it's sub gizmos are released from dragging */
  54954. onDragEndObservable: Observable<unknown>;
  54955. /**
  54956. * If set to true, planar drag is enabled
  54957. */
  54958. private _planarGizmoEnabled;
  54959. get attachedMesh(): Nullable<AbstractMesh>;
  54960. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54961. get attachedNode(): Nullable<Node>;
  54962. set attachedNode(node: Nullable<Node>);
  54963. /**
  54964. * True when the mouse pointer is hovering a gizmo mesh
  54965. */
  54966. get isHovered(): boolean;
  54967. /**
  54968. * Creates a PositionGizmo
  54969. * @param gizmoLayer The utility layer the gizmo will be added to
  54970. @param thickness display gizmo axis thickness
  54971. */
  54972. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54973. /**
  54974. * If the planar drag gizmo is enabled
  54975. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  54976. */
  54977. set planarGizmoEnabled(value: boolean);
  54978. get planarGizmoEnabled(): boolean;
  54979. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54980. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54981. /**
  54982. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54983. */
  54984. set snapDistance(value: number);
  54985. get snapDistance(): number;
  54986. /**
  54987. * Ratio for the scale of the gizmo (Default: 1)
  54988. */
  54989. set scaleRatio(value: number);
  54990. get scaleRatio(): number;
  54991. /**
  54992. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54993. * @param mesh Axis gizmo mesh
  54994. * @param cache Gizmo axis definition used for reactive gizmo UI
  54995. */
  54996. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54997. /**
  54998. * Disposes of the gizmo
  54999. */
  55000. dispose(): void;
  55001. /**
  55002. * CustomMeshes are not supported by this gizmo
  55003. * @param mesh The mesh to replace the default mesh of the gizmo
  55004. */
  55005. setCustomMesh(mesh: Mesh): void;
  55006. }
  55007. }
  55008. declare module BABYLON {
  55009. /**
  55010. * Single axis drag gizmo
  55011. */
  55012. export class AxisDragGizmo extends Gizmo {
  55013. /**
  55014. * Drag behavior responsible for the gizmos dragging interactions
  55015. */
  55016. dragBehavior: PointerDragBehavior;
  55017. private _pointerObserver;
  55018. /**
  55019. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55020. */
  55021. snapDistance: number;
  55022. /**
  55023. * Event that fires each time the gizmo snaps to a new location.
  55024. * * snapDistance is the the change in distance
  55025. */
  55026. onSnapObservable: Observable<{
  55027. snapDistance: number;
  55028. }>;
  55029. private _isEnabled;
  55030. private _parent;
  55031. private _gizmoMesh;
  55032. private _coloredMaterial;
  55033. private _hoverMaterial;
  55034. private _disableMaterial;
  55035. private _dragging;
  55036. /** @hidden */
  55037. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  55038. /** @hidden */
  55039. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55040. /**
  55041. * Creates an AxisDragGizmo
  55042. * @param gizmoLayer The utility layer the gizmo will be added to
  55043. * @param dragAxis The axis which the gizmo will be able to drag on
  55044. * @param color The color of the gizmo
  55045. * @param thickness display gizmo axis thickness
  55046. */
  55047. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55048. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55049. /**
  55050. * If the gizmo is enabled
  55051. */
  55052. set isEnabled(value: boolean);
  55053. get isEnabled(): boolean;
  55054. /**
  55055. * Disposes of the gizmo
  55056. */
  55057. dispose(): void;
  55058. }
  55059. }
  55060. declare module BABYLON.Debug {
  55061. /**
  55062. * The Axes viewer will show 3 axes in a specific point in space
  55063. */
  55064. export class AxesViewer {
  55065. private _xAxis;
  55066. private _yAxis;
  55067. private _zAxis;
  55068. private _scaleLinesFactor;
  55069. private _instanced;
  55070. /**
  55071. * Gets the hosting scene
  55072. */
  55073. scene: Nullable<Scene>;
  55074. /**
  55075. * Gets or sets a number used to scale line length
  55076. */
  55077. scaleLines: number;
  55078. /** Gets the node hierarchy used to render x-axis */
  55079. get xAxis(): TransformNode;
  55080. /** Gets the node hierarchy used to render y-axis */
  55081. get yAxis(): TransformNode;
  55082. /** Gets the node hierarchy used to render z-axis */
  55083. get zAxis(): TransformNode;
  55084. /**
  55085. * Creates a new AxesViewer
  55086. * @param scene defines the hosting scene
  55087. * @param scaleLines defines a number used to scale line length (1 by default)
  55088. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55089. * @param xAxis defines the node hierarchy used to render the x-axis
  55090. * @param yAxis defines the node hierarchy used to render the y-axis
  55091. * @param zAxis defines the node hierarchy used to render the z-axis
  55092. */
  55093. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55094. /**
  55095. * Force the viewer to update
  55096. * @param position defines the position of the viewer
  55097. * @param xaxis defines the x axis of the viewer
  55098. * @param yaxis defines the y axis of the viewer
  55099. * @param zaxis defines the z axis of the viewer
  55100. */
  55101. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55102. /**
  55103. * Creates an instance of this axes viewer.
  55104. * @returns a new axes viewer with instanced meshes
  55105. */
  55106. createInstance(): AxesViewer;
  55107. /** Releases resources */
  55108. dispose(): void;
  55109. private static _SetRenderingGroupId;
  55110. }
  55111. }
  55112. declare module BABYLON.Debug {
  55113. /**
  55114. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55115. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55116. */
  55117. export class BoneAxesViewer extends AxesViewer {
  55118. /**
  55119. * Gets or sets the target mesh where to display the axes viewer
  55120. */
  55121. mesh: Nullable<Mesh>;
  55122. /**
  55123. * Gets or sets the target bone where to display the axes viewer
  55124. */
  55125. bone: Nullable<Bone>;
  55126. /** Gets current position */
  55127. pos: Vector3;
  55128. /** Gets direction of X axis */
  55129. xaxis: Vector3;
  55130. /** Gets direction of Y axis */
  55131. yaxis: Vector3;
  55132. /** Gets direction of Z axis */
  55133. zaxis: Vector3;
  55134. /**
  55135. * Creates a new BoneAxesViewer
  55136. * @param scene defines the hosting scene
  55137. * @param bone defines the target bone
  55138. * @param mesh defines the target mesh
  55139. * @param scaleLines defines a scaling factor for line length (1 by default)
  55140. */
  55141. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  55142. /**
  55143. * Force the viewer to update
  55144. */
  55145. update(): void;
  55146. /** Releases resources */
  55147. dispose(): void;
  55148. }
  55149. }
  55150. declare module BABYLON {
  55151. /**
  55152. * Interface used to define scene explorer extensibility option
  55153. */
  55154. export interface IExplorerExtensibilityOption {
  55155. /**
  55156. * Define the option label
  55157. */
  55158. label: string;
  55159. /**
  55160. * Defines the action to execute on click
  55161. */
  55162. action: (entity: any) => void;
  55163. }
  55164. /**
  55165. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55166. */
  55167. export interface IExplorerExtensibilityGroup {
  55168. /**
  55169. * Defines a predicate to test if a given type mut be extended
  55170. */
  55171. predicate: (entity: any) => boolean;
  55172. /**
  55173. * Gets the list of options added to a type
  55174. */
  55175. entries: IExplorerExtensibilityOption[];
  55176. }
  55177. /**
  55178. * Interface used to define the options to use to create the Inspector
  55179. */
  55180. export interface IInspectorOptions {
  55181. /**
  55182. * Display in overlay mode (default: false)
  55183. */
  55184. overlay?: boolean;
  55185. /**
  55186. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55187. */
  55188. globalRoot?: HTMLElement;
  55189. /**
  55190. * Display the Scene explorer
  55191. */
  55192. showExplorer?: boolean;
  55193. /**
  55194. * Display the property inspector
  55195. */
  55196. showInspector?: boolean;
  55197. /**
  55198. * Display in embed mode (both panes on the right)
  55199. */
  55200. embedMode?: boolean;
  55201. /**
  55202. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  55203. */
  55204. handleResize?: boolean;
  55205. /**
  55206. * Allow the panes to popup (default: true)
  55207. */
  55208. enablePopup?: boolean;
  55209. /**
  55210. * Allow the panes to be closed by users (default: true)
  55211. */
  55212. enableClose?: boolean;
  55213. /**
  55214. * Optional list of extensibility entries
  55215. */
  55216. explorerExtensibility?: IExplorerExtensibilityGroup[];
  55217. /**
  55218. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  55219. */
  55220. inspectorURL?: string;
  55221. /**
  55222. * Optional initial tab (default to DebugLayerTab.Properties)
  55223. */
  55224. initialTab?: DebugLayerTab;
  55225. }
  55226. interface Scene {
  55227. /**
  55228. * @hidden
  55229. * Backing field
  55230. */
  55231. _debugLayer: DebugLayer;
  55232. /**
  55233. * Gets the debug layer (aka Inspector) associated with the scene
  55234. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55235. */
  55236. debugLayer: DebugLayer;
  55237. }
  55238. /**
  55239. * Enum of inspector action tab
  55240. */
  55241. export enum DebugLayerTab {
  55242. /**
  55243. * Properties tag (default)
  55244. */
  55245. Properties = 0,
  55246. /**
  55247. * Debug tab
  55248. */
  55249. Debug = 1,
  55250. /**
  55251. * Statistics tab
  55252. */
  55253. Statistics = 2,
  55254. /**
  55255. * Tools tab
  55256. */
  55257. Tools = 3,
  55258. /**
  55259. * Settings tab
  55260. */
  55261. Settings = 4
  55262. }
  55263. /**
  55264. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55265. * what is happening in your scene
  55266. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55267. */
  55268. export class DebugLayer {
  55269. /**
  55270. * Define the url to get the inspector script from.
  55271. * By default it uses the babylonjs CDN.
  55272. * @ignoreNaming
  55273. */
  55274. static InspectorURL: string;
  55275. private _scene;
  55276. private BJSINSPECTOR;
  55277. private _onPropertyChangedObservable?;
  55278. /**
  55279. * Observable triggered when a property is changed through the inspector.
  55280. */
  55281. get onPropertyChangedObservable(): any;
  55282. /**
  55283. * Instantiates a new debug layer.
  55284. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55285. * what is happening in your scene
  55286. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55287. * @param scene Defines the scene to inspect
  55288. */
  55289. constructor(scene: Scene);
  55290. /** Creates the inspector window. */
  55291. private _createInspector;
  55292. /**
  55293. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  55294. * @param entity defines the entity to select
  55295. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  55296. */
  55297. select(entity: any, lineContainerTitles?: string | string[]): void;
  55298. /** Get the inspector from bundle or global */
  55299. private _getGlobalInspector;
  55300. /**
  55301. * Get if the inspector is visible or not.
  55302. * @returns true if visible otherwise, false
  55303. */
  55304. isVisible(): boolean;
  55305. /**
  55306. * Hide the inspector and close its window.
  55307. */
  55308. hide(): void;
  55309. /**
  55310. * Update the scene in the inspector
  55311. */
  55312. setAsActiveScene(): void;
  55313. /**
  55314. * Launch the debugLayer.
  55315. * @param config Define the configuration of the inspector
  55316. * @return a promise fulfilled when the debug layer is visible
  55317. */
  55318. show(config?: IInspectorOptions): Promise<DebugLayer>;
  55319. }
  55320. }
  55321. declare module BABYLON.Debug {
  55322. /**
  55323. * Used to show the physics impostor around the specific mesh
  55324. */
  55325. export class PhysicsViewer {
  55326. /** @hidden */
  55327. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  55328. /** @hidden */
  55329. protected _meshes: Array<Nullable<AbstractMesh>>;
  55330. /** @hidden */
  55331. protected _scene: Nullable<Scene>;
  55332. /** @hidden */
  55333. protected _numMeshes: number;
  55334. /** @hidden */
  55335. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  55336. private _renderFunction;
  55337. private _utilityLayer;
  55338. private _debugBoxMesh;
  55339. private _debugSphereMesh;
  55340. private _debugCylinderMesh;
  55341. private _debugMaterial;
  55342. private _debugMeshMeshes;
  55343. /**
  55344. * Creates a new PhysicsViewer
  55345. * @param scene defines the hosting scene
  55346. */
  55347. constructor(scene: Scene);
  55348. /** @hidden */
  55349. protected _updateDebugMeshes(): void;
  55350. /**
  55351. * Renders a specified physic impostor
  55352. * @param impostor defines the impostor to render
  55353. * @param targetMesh defines the mesh represented by the impostor
  55354. * @returns the new debug mesh used to render the impostor
  55355. */
  55356. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  55357. /**
  55358. * Hides a specified physic impostor
  55359. * @param impostor defines the impostor to hide
  55360. */
  55361. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  55362. private _getDebugMaterial;
  55363. private _getDebugBoxMesh;
  55364. private _getDebugSphereMesh;
  55365. private _getDebugCylinderMesh;
  55366. private _getDebugMeshMesh;
  55367. private _getDebugMesh;
  55368. /** Releases all resources */
  55369. dispose(): void;
  55370. }
  55371. }
  55372. declare module BABYLON {
  55373. /**
  55374. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55375. * in order to better appreciate the issue one might have.
  55376. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55377. */
  55378. export class RayHelper {
  55379. /**
  55380. * Defines the ray we are currently tryin to visualize.
  55381. */
  55382. ray: Nullable<Ray>;
  55383. private _renderPoints;
  55384. private _renderLine;
  55385. private _renderFunction;
  55386. private _scene;
  55387. private _onAfterRenderObserver;
  55388. private _onAfterStepObserver;
  55389. private _attachedToMesh;
  55390. private _meshSpaceDirection;
  55391. private _meshSpaceOrigin;
  55392. /**
  55393. * Helper function to create a colored helper in a scene in one line.
  55394. * @param ray Defines the ray we are currently tryin to visualize
  55395. * @param scene Defines the scene the ray is used in
  55396. * @param color Defines the color we want to see the ray in
  55397. * @returns The newly created ray helper.
  55398. */
  55399. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  55400. /**
  55401. * Instantiate a new ray helper.
  55402. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55403. * in order to better appreciate the issue one might have.
  55404. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55405. * @param ray Defines the ray we are currently tryin to visualize
  55406. */
  55407. constructor(ray: Ray);
  55408. /**
  55409. * Shows the ray we are willing to debug.
  55410. * @param scene Defines the scene the ray needs to be rendered in
  55411. * @param color Defines the color the ray needs to be rendered in
  55412. */
  55413. show(scene: Scene, color?: Color3): void;
  55414. /**
  55415. * Hides the ray we are debugging.
  55416. */
  55417. hide(): void;
  55418. private _render;
  55419. /**
  55420. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  55421. * @param mesh Defines the mesh we want the helper attached to
  55422. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  55423. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  55424. * @param length Defines the length of the ray
  55425. */
  55426. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  55427. /**
  55428. * Detach the ray helper from the mesh it has previously been attached to.
  55429. */
  55430. detachFromMesh(): void;
  55431. private _updateToMesh;
  55432. /**
  55433. * Dispose the helper and release its associated resources.
  55434. */
  55435. dispose(): void;
  55436. }
  55437. }
  55438. declare module BABYLON {
  55439. /**
  55440. * Defines the options associated with the creation of a SkeletonViewer.
  55441. */
  55442. export interface ISkeletonViewerOptions {
  55443. /** Should the system pause animations before building the Viewer? */
  55444. pauseAnimations: boolean;
  55445. /** Should the system return the skeleton to rest before building? */
  55446. returnToRest: boolean;
  55447. /** public Display Mode of the Viewer */
  55448. displayMode: number;
  55449. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55450. displayOptions: ISkeletonViewerDisplayOptions;
  55451. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55452. computeBonesUsingShaders: boolean;
  55453. /** Flag ignore non weighted bones */
  55454. useAllBones: boolean;
  55455. }
  55456. /**
  55457. * Defines how to display the various bone meshes for the viewer.
  55458. */
  55459. export interface ISkeletonViewerDisplayOptions {
  55460. /** How far down to start tapering the bone spurs */
  55461. midStep?: number;
  55462. /** How big is the midStep? */
  55463. midStepFactor?: number;
  55464. /** Base for the Sphere Size */
  55465. sphereBaseSize?: number;
  55466. /** The ratio of the sphere to the longest bone in units */
  55467. sphereScaleUnit?: number;
  55468. /** Ratio for the Sphere Size */
  55469. sphereFactor?: number;
  55470. /** Whether a spur should attach its far end to the child bone position */
  55471. spurFollowsChild?: boolean;
  55472. /** Whether to show local axes or not */
  55473. showLocalAxes?: boolean;
  55474. /** Length of each local axis */
  55475. localAxesSize?: number;
  55476. }
  55477. /**
  55478. * Defines the constructor options for the BoneWeight Shader.
  55479. */
  55480. export interface IBoneWeightShaderOptions {
  55481. /** Skeleton to Map */
  55482. skeleton: Skeleton;
  55483. /** Colors for Uninfluenced bones */
  55484. colorBase?: Color3;
  55485. /** Colors for 0.0-0.25 Weight bones */
  55486. colorZero?: Color3;
  55487. /** Color for 0.25-0.5 Weight Influence */
  55488. colorQuarter?: Color3;
  55489. /** Color for 0.5-0.75 Weight Influence */
  55490. colorHalf?: Color3;
  55491. /** Color for 0.75-1 Weight Influence */
  55492. colorFull?: Color3;
  55493. /** Color for Zero Weight Influence */
  55494. targetBoneIndex?: number;
  55495. }
  55496. /**
  55497. * Simple structure of the gradient steps for the Color Map.
  55498. */
  55499. export interface ISkeletonMapShaderColorMapKnot {
  55500. /** Color of the Knot */
  55501. color: Color3;
  55502. /** Location of the Knot */
  55503. location: number;
  55504. }
  55505. /**
  55506. * Defines the constructor options for the SkeletonMap Shader.
  55507. */
  55508. export interface ISkeletonMapShaderOptions {
  55509. /** Skeleton to Map */
  55510. skeleton: Skeleton;
  55511. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  55512. colorMap?: ISkeletonMapShaderColorMapKnot[];
  55513. }
  55514. }
  55515. declare module BABYLON {
  55516. /**
  55517. * Class containing static functions to help procedurally build meshes
  55518. */
  55519. export class RibbonBuilder {
  55520. /**
  55521. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55522. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55523. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55524. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55525. * * 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
  55526. * * 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
  55527. * * 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
  55528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55529. * * 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
  55530. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55531. * * 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
  55532. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55533. * * 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
  55534. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55536. * @param name defines the name of the mesh
  55537. * @param options defines the options used to create the mesh
  55538. * @param scene defines the hosting scene
  55539. * @returns the ribbon mesh
  55540. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55541. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55542. */
  55543. static CreateRibbon(name: string, options: {
  55544. pathArray: Vector3[][];
  55545. closeArray?: boolean;
  55546. closePath?: boolean;
  55547. offset?: number;
  55548. updatable?: boolean;
  55549. sideOrientation?: number;
  55550. frontUVs?: Vector4;
  55551. backUVs?: Vector4;
  55552. instance?: Mesh;
  55553. invertUV?: boolean;
  55554. uvs?: Vector2[];
  55555. colors?: Color4[];
  55556. }, scene?: Nullable<Scene>): Mesh;
  55557. }
  55558. }
  55559. declare module BABYLON {
  55560. /**
  55561. * Class containing static functions to help procedurally build meshes
  55562. */
  55563. export class ShapeBuilder {
  55564. /**
  55565. * 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.
  55566. * * 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.
  55567. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55568. * * 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.
  55569. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55570. * * 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
  55571. * * 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
  55572. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55574. * * 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
  55575. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55577. * @param name defines the name of the mesh
  55578. * @param options defines the options used to create the mesh
  55579. * @param scene defines the hosting scene
  55580. * @returns the extruded shape mesh
  55581. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55582. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55583. */
  55584. static ExtrudeShape(name: string, options: {
  55585. shape: Vector3[];
  55586. path: Vector3[];
  55587. scale?: number;
  55588. rotation?: number;
  55589. cap?: number;
  55590. updatable?: boolean;
  55591. sideOrientation?: number;
  55592. frontUVs?: Vector4;
  55593. backUVs?: Vector4;
  55594. instance?: Mesh;
  55595. invertUV?: boolean;
  55596. }, scene?: Nullable<Scene>): Mesh;
  55597. /**
  55598. * Creates an custom extruded shape mesh.
  55599. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55600. * * 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.
  55601. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55602. * * 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
  55603. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55604. * * 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
  55605. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55606. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55607. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55608. * * 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
  55609. * * 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
  55610. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55612. * * 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
  55613. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55615. * @param name defines the name of the mesh
  55616. * @param options defines the options used to create the mesh
  55617. * @param scene defines the hosting scene
  55618. * @returns the custom extruded shape mesh
  55619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55620. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55621. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55622. */
  55623. static ExtrudeShapeCustom(name: string, options: {
  55624. shape: Vector3[];
  55625. path: Vector3[];
  55626. scaleFunction?: any;
  55627. rotationFunction?: any;
  55628. ribbonCloseArray?: boolean;
  55629. ribbonClosePath?: boolean;
  55630. cap?: number;
  55631. updatable?: boolean;
  55632. sideOrientation?: number;
  55633. frontUVs?: Vector4;
  55634. backUVs?: Vector4;
  55635. instance?: Mesh;
  55636. invertUV?: boolean;
  55637. }, scene?: Nullable<Scene>): Mesh;
  55638. private static _ExtrudeShapeGeneric;
  55639. }
  55640. }
  55641. declare module BABYLON.Debug {
  55642. /**
  55643. * Class used to render a debug view of a given skeleton
  55644. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  55645. */
  55646. export class SkeletonViewer {
  55647. /** defines the skeleton to render */
  55648. skeleton: Skeleton;
  55649. /** defines the mesh attached to the skeleton */
  55650. mesh: AbstractMesh;
  55651. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55652. autoUpdateBonesMatrices: boolean;
  55653. /** defines the rendering group id to use with the viewer */
  55654. renderingGroupId: number;
  55655. /** is the options for the viewer */
  55656. options: Partial<ISkeletonViewerOptions>;
  55657. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  55658. static readonly DISPLAY_LINES: number;
  55659. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  55660. static readonly DISPLAY_SPHERES: number;
  55661. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  55662. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  55663. /** public static method to create a BoneWeight Shader
  55664. * @param options The constructor options
  55665. * @param scene The scene that the shader is scoped to
  55666. * @returns The created ShaderMaterial
  55667. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  55668. */
  55669. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  55670. /** public static method to create a BoneWeight Shader
  55671. * @param options The constructor options
  55672. * @param scene The scene that the shader is scoped to
  55673. * @returns The created ShaderMaterial
  55674. */
  55675. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  55676. /** private static method to create a BoneWeight Shader
  55677. * @param size The size of the buffer to create (usually the bone count)
  55678. * @param colorMap The gradient data to generate
  55679. * @param scene The scene that the shader is scoped to
  55680. * @returns an Array of floats from the color gradient values
  55681. */
  55682. private static _CreateBoneMapColorBuffer;
  55683. /** If SkeletonViewer scene scope. */
  55684. private _scene;
  55685. /** Gets or sets the color used to render the skeleton */
  55686. color: Color3;
  55687. /** Array of the points of the skeleton fo the line view. */
  55688. private _debugLines;
  55689. /** The SkeletonViewers Mesh. */
  55690. private _debugMesh;
  55691. /** The local axes Meshes. */
  55692. private _localAxes;
  55693. /** If SkeletonViewer is enabled. */
  55694. private _isEnabled;
  55695. /** If SkeletonViewer is ready. */
  55696. private _ready;
  55697. /** SkeletonViewer render observable. */
  55698. private _obs;
  55699. /** The Utility Layer to render the gizmos in. */
  55700. private _utilityLayer;
  55701. private _boneIndices;
  55702. /** Gets the Scene. */
  55703. get scene(): Scene;
  55704. /** Gets the utilityLayer. */
  55705. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  55706. /** Checks Ready Status. */
  55707. get isReady(): Boolean;
  55708. /** Sets Ready Status. */
  55709. set ready(value: boolean);
  55710. /** Gets the debugMesh */
  55711. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  55712. /** Sets the debugMesh */
  55713. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  55714. /** Gets the displayMode */
  55715. get displayMode(): number;
  55716. /** Sets the displayMode */
  55717. set displayMode(value: number);
  55718. /**
  55719. * Creates a new SkeletonViewer
  55720. * @param skeleton defines the skeleton to render
  55721. * @param mesh defines the mesh attached to the skeleton
  55722. * @param scene defines the hosting scene
  55723. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  55724. * @param renderingGroupId defines the rendering group id to use with the viewer
  55725. * @param options All of the extra constructor options for the SkeletonViewer
  55726. */
  55727. constructor(
  55728. /** defines the skeleton to render */
  55729. skeleton: Skeleton,
  55730. /** defines the mesh attached to the skeleton */
  55731. mesh: AbstractMesh,
  55732. /** The Scene scope*/
  55733. scene: Scene,
  55734. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55735. autoUpdateBonesMatrices?: boolean,
  55736. /** defines the rendering group id to use with the viewer */
  55737. renderingGroupId?: number,
  55738. /** is the options for the viewer */
  55739. options?: Partial<ISkeletonViewerOptions>);
  55740. /** The Dynamic bindings for the update functions */
  55741. private _bindObs;
  55742. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  55743. update(): void;
  55744. /** Gets or sets a boolean indicating if the viewer is enabled */
  55745. set isEnabled(value: boolean);
  55746. get isEnabled(): boolean;
  55747. private _getBonePosition;
  55748. private _getLinesForBonesWithLength;
  55749. private _getLinesForBonesNoLength;
  55750. /** function to revert the mesh and scene back to the initial state. */
  55751. private _revert;
  55752. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  55753. private _getAbsoluteBindPoseToRef;
  55754. /** function to build and bind sphere joint points and spur bone representations. */
  55755. private _buildSpheresAndSpurs;
  55756. private _buildLocalAxes;
  55757. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  55758. private _displayLinesUpdate;
  55759. /** Changes the displayMode of the skeleton viewer
  55760. * @param mode The displayMode numerical value
  55761. */
  55762. changeDisplayMode(mode: number): void;
  55763. /** Sets a display option of the skeleton viewer
  55764. *
  55765. * | Option | Type | Default | Description |
  55766. * | ---------------- | ------- | ------- | ----------- |
  55767. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55768. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55769. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55770. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55771. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  55772. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  55773. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  55774. *
  55775. * @param option String of the option name
  55776. * @param value The numerical option value
  55777. */
  55778. changeDisplayOptions(option: string, value: number): void;
  55779. /** Release associated resources */
  55780. dispose(): void;
  55781. }
  55782. }
  55783. declare module BABYLON {
  55784. /**
  55785. * Enum for Device Types
  55786. */
  55787. export enum DeviceType {
  55788. /** Generic */
  55789. Generic = 0,
  55790. /** Keyboard */
  55791. Keyboard = 1,
  55792. /** Mouse */
  55793. Mouse = 2,
  55794. /** Touch Pointers */
  55795. Touch = 3,
  55796. /** PS4 Dual Shock */
  55797. DualShock = 4,
  55798. /** Xbox */
  55799. Xbox = 5,
  55800. /** Switch Controller */
  55801. Switch = 6
  55802. }
  55803. /**
  55804. * Enum for All Pointers (Touch/Mouse)
  55805. */
  55806. export enum PointerInput {
  55807. /** Horizontal Axis */
  55808. Horizontal = 0,
  55809. /** Vertical Axis */
  55810. Vertical = 1,
  55811. /** Left Click or Touch */
  55812. LeftClick = 2,
  55813. /** Middle Click */
  55814. MiddleClick = 3,
  55815. /** Right Click */
  55816. RightClick = 4,
  55817. /** Browser Back */
  55818. BrowserBack = 5,
  55819. /** Browser Forward */
  55820. BrowserForward = 6
  55821. }
  55822. /**
  55823. * Enum for Dual Shock Gamepad
  55824. */
  55825. export enum DualShockInput {
  55826. /** Cross */
  55827. Cross = 0,
  55828. /** Circle */
  55829. Circle = 1,
  55830. /** Square */
  55831. Square = 2,
  55832. /** Triangle */
  55833. Triangle = 3,
  55834. /** L1 */
  55835. L1 = 4,
  55836. /** R1 */
  55837. R1 = 5,
  55838. /** L2 */
  55839. L2 = 6,
  55840. /** R2 */
  55841. R2 = 7,
  55842. /** Share */
  55843. Share = 8,
  55844. /** Options */
  55845. Options = 9,
  55846. /** L3 */
  55847. L3 = 10,
  55848. /** R3 */
  55849. R3 = 11,
  55850. /** DPadUp */
  55851. DPadUp = 12,
  55852. /** DPadDown */
  55853. DPadDown = 13,
  55854. /** DPadLeft */
  55855. DPadLeft = 14,
  55856. /** DRight */
  55857. DPadRight = 15,
  55858. /** Home */
  55859. Home = 16,
  55860. /** TouchPad */
  55861. TouchPad = 17,
  55862. /** LStickXAxis */
  55863. LStickXAxis = 18,
  55864. /** LStickYAxis */
  55865. LStickYAxis = 19,
  55866. /** RStickXAxis */
  55867. RStickXAxis = 20,
  55868. /** RStickYAxis */
  55869. RStickYAxis = 21
  55870. }
  55871. /**
  55872. * Enum for Xbox Gamepad
  55873. */
  55874. export enum XboxInput {
  55875. /** A */
  55876. A = 0,
  55877. /** B */
  55878. B = 1,
  55879. /** X */
  55880. X = 2,
  55881. /** Y */
  55882. Y = 3,
  55883. /** LB */
  55884. LB = 4,
  55885. /** RB */
  55886. RB = 5,
  55887. /** LT */
  55888. LT = 6,
  55889. /** RT */
  55890. RT = 7,
  55891. /** Back */
  55892. Back = 8,
  55893. /** Start */
  55894. Start = 9,
  55895. /** LS */
  55896. LS = 10,
  55897. /** RS */
  55898. RS = 11,
  55899. /** DPadUp */
  55900. DPadUp = 12,
  55901. /** DPadDown */
  55902. DPadDown = 13,
  55903. /** DPadLeft */
  55904. DPadLeft = 14,
  55905. /** DRight */
  55906. DPadRight = 15,
  55907. /** Home */
  55908. Home = 16,
  55909. /** LStickXAxis */
  55910. LStickXAxis = 17,
  55911. /** LStickYAxis */
  55912. LStickYAxis = 18,
  55913. /** RStickXAxis */
  55914. RStickXAxis = 19,
  55915. /** RStickYAxis */
  55916. RStickYAxis = 20
  55917. }
  55918. /**
  55919. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  55920. */
  55921. export enum SwitchInput {
  55922. /** B */
  55923. B = 0,
  55924. /** A */
  55925. A = 1,
  55926. /** Y */
  55927. Y = 2,
  55928. /** X */
  55929. X = 3,
  55930. /** L */
  55931. L = 4,
  55932. /** R */
  55933. R = 5,
  55934. /** ZL */
  55935. ZL = 6,
  55936. /** ZR */
  55937. ZR = 7,
  55938. /** Minus */
  55939. Minus = 8,
  55940. /** Plus */
  55941. Plus = 9,
  55942. /** LS */
  55943. LS = 10,
  55944. /** RS */
  55945. RS = 11,
  55946. /** DPadUp */
  55947. DPadUp = 12,
  55948. /** DPadDown */
  55949. DPadDown = 13,
  55950. /** DPadLeft */
  55951. DPadLeft = 14,
  55952. /** DRight */
  55953. DPadRight = 15,
  55954. /** Home */
  55955. Home = 16,
  55956. /** Capture */
  55957. Capture = 17,
  55958. /** LStickXAxis */
  55959. LStickXAxis = 18,
  55960. /** LStickYAxis */
  55961. LStickYAxis = 19,
  55962. /** RStickXAxis */
  55963. RStickXAxis = 20,
  55964. /** RStickYAxis */
  55965. RStickYAxis = 21
  55966. }
  55967. }
  55968. declare module BABYLON {
  55969. /**
  55970. * This class will take all inputs from Keyboard, Pointer, and
  55971. * any Gamepads and provide a polling system that all devices
  55972. * will use. This class assumes that there will only be one
  55973. * pointer device and one keyboard.
  55974. */
  55975. export class DeviceInputSystem implements IDisposable {
  55976. /**
  55977. * Returns onDeviceConnected callback property
  55978. * @returns Callback with function to execute when a device is connected
  55979. */
  55980. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55981. /**
  55982. * Sets callback function when a device is connected and executes against all connected devices
  55983. * @param callback Function to execute when a device is connected
  55984. */
  55985. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55986. /**
  55987. * Callback to be triggered when a device is disconnected
  55988. */
  55989. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55990. /**
  55991. * Callback to be triggered when event driven input is updated
  55992. */
  55993. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55994. private _inputs;
  55995. private _gamepads;
  55996. private _keyboardActive;
  55997. private _pointerActive;
  55998. private _elementToAttachTo;
  55999. private _keyboardDownEvent;
  56000. private _keyboardUpEvent;
  56001. private _pointerMoveEvent;
  56002. private _pointerDownEvent;
  56003. private _pointerUpEvent;
  56004. private _gamepadConnectedEvent;
  56005. private _gamepadDisconnectedEvent;
  56006. private _onDeviceConnected;
  56007. private static _MAX_KEYCODES;
  56008. private static _MAX_POINTER_INPUTS;
  56009. private constructor();
  56010. /**
  56011. * Creates a new DeviceInputSystem instance
  56012. * @param engine Engine to pull input element from
  56013. * @returns The new instance
  56014. */
  56015. static Create(engine: Engine): DeviceInputSystem;
  56016. /**
  56017. * Checks for current device input value, given an id and input index
  56018. * @param deviceName Id of connected device
  56019. * @param inputIndex Index of device input
  56020. * @returns Current value of input
  56021. */
  56022. /**
  56023. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  56024. * @param deviceType Enum specifiying device type
  56025. * @param deviceSlot "Slot" or index that device is referenced in
  56026. * @param inputIndex Id of input to be checked
  56027. * @returns Current value of input
  56028. */
  56029. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  56030. /**
  56031. * Dispose of all the eventlisteners
  56032. */
  56033. dispose(): void;
  56034. /**
  56035. * Checks for existing connections to devices and register them, if necessary
  56036. * Currently handles gamepads and mouse
  56037. */
  56038. private _checkForConnectedDevices;
  56039. /**
  56040. * Add a gamepad to the DeviceInputSystem
  56041. * @param gamepad A single DOM Gamepad object
  56042. */
  56043. private _addGamePad;
  56044. /**
  56045. * Add pointer device to DeviceInputSystem
  56046. * @param deviceType Type of Pointer to add
  56047. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  56048. * @param currentX Current X at point of adding
  56049. * @param currentY Current Y at point of adding
  56050. */
  56051. private _addPointerDevice;
  56052. /**
  56053. * Add device and inputs to device array
  56054. * @param deviceType Enum specifiying device type
  56055. * @param deviceSlot "Slot" or index that device is referenced in
  56056. * @param numberOfInputs Number of input entries to create for given device
  56057. */
  56058. private _registerDevice;
  56059. /**
  56060. * Given a specific device name, remove that device from the device map
  56061. * @param deviceType Enum specifiying device type
  56062. * @param deviceSlot "Slot" or index that device is referenced in
  56063. */
  56064. private _unregisterDevice;
  56065. /**
  56066. * Handle all actions that come from keyboard interaction
  56067. */
  56068. private _handleKeyActions;
  56069. /**
  56070. * Handle all actions that come from pointer interaction
  56071. */
  56072. private _handlePointerActions;
  56073. /**
  56074. * Handle all actions that come from gamepad interaction
  56075. */
  56076. private _handleGamepadActions;
  56077. /**
  56078. * Update all non-event based devices with each frame
  56079. * @param deviceType Enum specifiying device type
  56080. * @param deviceSlot "Slot" or index that device is referenced in
  56081. * @param inputIndex Id of input to be checked
  56082. */
  56083. private _updateDevice;
  56084. /**
  56085. * Gets DeviceType from the device name
  56086. * @param deviceName Name of Device from DeviceInputSystem
  56087. * @returns DeviceType enum value
  56088. */
  56089. private _getGamepadDeviceType;
  56090. }
  56091. }
  56092. declare module BABYLON {
  56093. /**
  56094. * Type to handle enforcement of inputs
  56095. */
  56096. 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;
  56097. }
  56098. declare module BABYLON {
  56099. /**
  56100. * Class that handles all input for a specific device
  56101. */
  56102. export class DeviceSource<T extends DeviceType> {
  56103. /** Type of device */
  56104. readonly deviceType: DeviceType;
  56105. /** "Slot" or index that device is referenced in */
  56106. readonly deviceSlot: number;
  56107. /**
  56108. * Observable to handle device input changes per device
  56109. */
  56110. readonly onInputChangedObservable: Observable<{
  56111. inputIndex: DeviceInput<T>;
  56112. previousState: Nullable<number>;
  56113. currentState: Nullable<number>;
  56114. }>;
  56115. private readonly _deviceInputSystem;
  56116. /**
  56117. * Default Constructor
  56118. * @param deviceInputSystem Reference to DeviceInputSystem
  56119. * @param deviceType Type of device
  56120. * @param deviceSlot "Slot" or index that device is referenced in
  56121. */
  56122. constructor(deviceInputSystem: DeviceInputSystem,
  56123. /** Type of device */
  56124. deviceType: DeviceType,
  56125. /** "Slot" or index that device is referenced in */
  56126. deviceSlot?: number);
  56127. /**
  56128. * Get input for specific input
  56129. * @param inputIndex index of specific input on device
  56130. * @returns Input value from DeviceInputSystem
  56131. */
  56132. getInput(inputIndex: DeviceInput<T>): number;
  56133. }
  56134. /**
  56135. * Class to keep track of devices
  56136. */
  56137. export class DeviceSourceManager implements IDisposable {
  56138. /**
  56139. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  56140. */
  56141. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  56142. /**
  56143. * Observable to be triggered when after a device is disconnected
  56144. */
  56145. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  56146. private readonly _devices;
  56147. private readonly _firstDevice;
  56148. private readonly _deviceInputSystem;
  56149. /**
  56150. * Default Constructor
  56151. * @param engine engine to pull input element from
  56152. */
  56153. constructor(engine: Engine);
  56154. /**
  56155. * Gets a DeviceSource, given a type and slot
  56156. * @param deviceType Enum specifying device type
  56157. * @param deviceSlot "Slot" or index that device is referenced in
  56158. * @returns DeviceSource object
  56159. */
  56160. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  56161. /**
  56162. * Gets an array of DeviceSource objects for a given device type
  56163. * @param deviceType Enum specifying device type
  56164. * @returns Array of DeviceSource objects
  56165. */
  56166. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  56167. /**
  56168. * Returns a read-only list of all available devices
  56169. * @returns Read-only array with active devices
  56170. */
  56171. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  56172. /**
  56173. * Dispose of DeviceInputSystem and other parts
  56174. */
  56175. dispose(): void;
  56176. /**
  56177. * Function to add device name to device list
  56178. * @param deviceType Enum specifying device type
  56179. * @param deviceSlot "Slot" or index that device is referenced in
  56180. */
  56181. private _addDevice;
  56182. /**
  56183. * Function to remove device name to device list
  56184. * @param deviceType Enum specifying device type
  56185. * @param deviceSlot "Slot" or index that device is referenced in
  56186. */
  56187. private _removeDevice;
  56188. /**
  56189. * Updates array storing first connected device of each type
  56190. * @param type Type of Device
  56191. */
  56192. private _updateFirstDevices;
  56193. }
  56194. }
  56195. declare module BABYLON {
  56196. /**
  56197. * Options to create the null engine
  56198. */
  56199. export class NullEngineOptions {
  56200. /**
  56201. * Render width (Default: 512)
  56202. */
  56203. renderWidth: number;
  56204. /**
  56205. * Render height (Default: 256)
  56206. */
  56207. renderHeight: number;
  56208. /**
  56209. * Texture size (Default: 512)
  56210. */
  56211. textureSize: number;
  56212. /**
  56213. * If delta time between frames should be constant
  56214. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56215. */
  56216. deterministicLockstep: boolean;
  56217. /**
  56218. * Maximum about of steps between frames (Default: 4)
  56219. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56220. */
  56221. lockstepMaxSteps: number;
  56222. /**
  56223. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  56224. */
  56225. useHighPrecisionMatrix?: boolean;
  56226. }
  56227. /**
  56228. * The null engine class provides support for headless version of babylon.js.
  56229. * This can be used in server side scenario or for testing purposes
  56230. */
  56231. export class NullEngine extends Engine {
  56232. private _options;
  56233. /**
  56234. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  56235. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56236. * @returns true if engine is in deterministic lock step mode
  56237. */
  56238. isDeterministicLockStep(): boolean;
  56239. /**
  56240. * Gets the max steps when engine is running in deterministic lock step
  56241. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56242. * @returns the max steps
  56243. */
  56244. getLockstepMaxSteps(): number;
  56245. /**
  56246. * Gets the current hardware scaling level.
  56247. * By default the hardware scaling level is computed from the window device ratio.
  56248. * 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.
  56249. * @returns a number indicating the current hardware scaling level
  56250. */
  56251. getHardwareScalingLevel(): number;
  56252. constructor(options?: NullEngineOptions);
  56253. /**
  56254. * Creates a vertex buffer
  56255. * @param vertices the data for the vertex buffer
  56256. * @returns the new WebGL static buffer
  56257. */
  56258. createVertexBuffer(vertices: FloatArray): DataBuffer;
  56259. /**
  56260. * Creates a new index buffer
  56261. * @param indices defines the content of the index buffer
  56262. * @param updatable defines if the index buffer must be updatable
  56263. * @returns a new webGL buffer
  56264. */
  56265. createIndexBuffer(indices: IndicesArray): DataBuffer;
  56266. /**
  56267. * Clear the current render buffer or the current render target (if any is set up)
  56268. * @param color defines the color to use
  56269. * @param backBuffer defines if the back buffer must be cleared
  56270. * @param depth defines if the depth buffer must be cleared
  56271. * @param stencil defines if the stencil buffer must be cleared
  56272. */
  56273. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56274. /**
  56275. * Gets the current render width
  56276. * @param useScreen defines if screen size must be used (or the current render target if any)
  56277. * @returns a number defining the current render width
  56278. */
  56279. getRenderWidth(useScreen?: boolean): number;
  56280. /**
  56281. * Gets the current render height
  56282. * @param useScreen defines if screen size must be used (or the current render target if any)
  56283. * @returns a number defining the current render height
  56284. */
  56285. getRenderHeight(useScreen?: boolean): number;
  56286. /**
  56287. * Set the WebGL's viewport
  56288. * @param viewport defines the viewport element to be used
  56289. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  56290. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  56291. */
  56292. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  56293. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  56294. /**
  56295. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  56296. * @param pipelineContext defines the pipeline context to use
  56297. * @param uniformsNames defines the list of uniform names
  56298. * @returns an array of webGL uniform locations
  56299. */
  56300. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  56301. /**
  56302. * Gets the lsit of active attributes for a given webGL program
  56303. * @param pipelineContext defines the pipeline context to use
  56304. * @param attributesNames defines the list of attribute names to get
  56305. * @returns an array of indices indicating the offset of each attribute
  56306. */
  56307. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56308. /**
  56309. * Binds an effect to the webGL context
  56310. * @param effect defines the effect to bind
  56311. */
  56312. bindSamplers(effect: Effect): void;
  56313. /**
  56314. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  56315. * @param effect defines the effect to activate
  56316. */
  56317. enableEffect(effect: Effect): void;
  56318. /**
  56319. * Set various states to the webGL context
  56320. * @param culling defines backface culling state
  56321. * @param zOffset defines the value to apply to zOffset (0 by default)
  56322. * @param force defines if states must be applied even if cache is up to date
  56323. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  56324. */
  56325. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56326. /**
  56327. * Set the value of an uniform to an array of int32
  56328. * @param uniform defines the webGL uniform location where to store the value
  56329. * @param array defines the array of int32 to store
  56330. * @returns true if value was set
  56331. */
  56332. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56333. /**
  56334. * Set the value of an uniform to an array of int32 (stored as vec2)
  56335. * @param uniform defines the webGL uniform location where to store the value
  56336. * @param array defines the array of int32 to store
  56337. * @returns true if value was set
  56338. */
  56339. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56340. /**
  56341. * Set the value of an uniform to an array of int32 (stored as vec3)
  56342. * @param uniform defines the webGL uniform location where to store the value
  56343. * @param array defines the array of int32 to store
  56344. * @returns true if value was set
  56345. */
  56346. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56347. /**
  56348. * Set the value of an uniform to an array of int32 (stored as vec4)
  56349. * @param uniform defines the webGL uniform location where to store the value
  56350. * @param array defines the array of int32 to store
  56351. * @returns true if value was set
  56352. */
  56353. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56354. /**
  56355. * Set the value of an uniform to an array of float32
  56356. * @param uniform defines the webGL uniform location where to store the value
  56357. * @param array defines the array of float32 to store
  56358. * @returns true if value was set
  56359. */
  56360. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56361. /**
  56362. * Set the value of an uniform to an array of float32 (stored as vec2)
  56363. * @param uniform defines the webGL uniform location where to store the value
  56364. * @param array defines the array of float32 to store
  56365. * @returns true if value was set
  56366. */
  56367. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56368. /**
  56369. * Set the value of an uniform to an array of float32 (stored as vec3)
  56370. * @param uniform defines the webGL uniform location where to store the value
  56371. * @param array defines the array of float32 to store
  56372. * @returns true if value was set
  56373. */
  56374. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56375. /**
  56376. * Set the value of an uniform to an array of float32 (stored as vec4)
  56377. * @param uniform defines the webGL uniform location where to store the value
  56378. * @param array defines the array of float32 to store
  56379. * @returns true if value was set
  56380. */
  56381. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56382. /**
  56383. * Set the value of an uniform to an array of number
  56384. * @param uniform defines the webGL uniform location where to store the value
  56385. * @param array defines the array of number to store
  56386. * @returns true if value was set
  56387. */
  56388. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56389. /**
  56390. * Set the value of an uniform to an array of number (stored as vec2)
  56391. * @param uniform defines the webGL uniform location where to store the value
  56392. * @param array defines the array of number to store
  56393. * @returns true if value was set
  56394. */
  56395. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56396. /**
  56397. * Set the value of an uniform to an array of number (stored as vec3)
  56398. * @param uniform defines the webGL uniform location where to store the value
  56399. * @param array defines the array of number to store
  56400. * @returns true if value was set
  56401. */
  56402. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56403. /**
  56404. * Set the value of an uniform to an array of number (stored as vec4)
  56405. * @param uniform defines the webGL uniform location where to store the value
  56406. * @param array defines the array of number to store
  56407. * @returns true if value was set
  56408. */
  56409. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56410. /**
  56411. * Set the value of an uniform to an array of float32 (stored as matrices)
  56412. * @param uniform defines the webGL uniform location where to store the value
  56413. * @param matrices defines the array of float32 to store
  56414. * @returns true if value was set
  56415. */
  56416. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56417. /**
  56418. * Set the value of an uniform to a matrix (3x3)
  56419. * @param uniform defines the webGL uniform location where to store the value
  56420. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  56421. * @returns true if value was set
  56422. */
  56423. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56424. /**
  56425. * Set the value of an uniform to a matrix (2x2)
  56426. * @param uniform defines the webGL uniform location where to store the value
  56427. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  56428. * @returns true if value was set
  56429. */
  56430. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56431. /**
  56432. * Set the value of an uniform to a number (float)
  56433. * @param uniform defines the webGL uniform location where to store the value
  56434. * @param value defines the float number to store
  56435. * @returns true if value was set
  56436. */
  56437. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56438. /**
  56439. * Set the value of an uniform to a vec2
  56440. * @param uniform defines the webGL uniform location where to store the value
  56441. * @param x defines the 1st component of the value
  56442. * @param y defines the 2nd component of the value
  56443. * @returns true if value was set
  56444. */
  56445. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56446. /**
  56447. * Set the value of an uniform to a vec3
  56448. * @param uniform defines the webGL uniform location where to store the value
  56449. * @param x defines the 1st component of the value
  56450. * @param y defines the 2nd component of the value
  56451. * @param z defines the 3rd component of the value
  56452. * @returns true if value was set
  56453. */
  56454. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56455. /**
  56456. * Set the value of an uniform to a boolean
  56457. * @param uniform defines the webGL uniform location where to store the value
  56458. * @param bool defines the boolean to store
  56459. * @returns true if value was set
  56460. */
  56461. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  56462. /**
  56463. * Set the value of an uniform to a vec4
  56464. * @param uniform defines the webGL uniform location where to store the value
  56465. * @param x defines the 1st component of the value
  56466. * @param y defines the 2nd component of the value
  56467. * @param z defines the 3rd component of the value
  56468. * @param w defines the 4th component of the value
  56469. * @returns true if value was set
  56470. */
  56471. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56472. /**
  56473. * Sets the current alpha mode
  56474. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  56475. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56476. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56477. */
  56478. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56479. /**
  56480. * Bind webGl buffers directly to the webGL context
  56481. * @param vertexBuffers defines the vertex buffer to bind
  56482. * @param indexBuffer defines the index buffer to bind
  56483. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  56484. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  56485. * @param effect defines the effect associated with the vertex buffer
  56486. */
  56487. bindBuffers(vertexBuffers: {
  56488. [key: string]: VertexBuffer;
  56489. }, indexBuffer: DataBuffer, effect: Effect): void;
  56490. /**
  56491. * Force the entire cache to be cleared
  56492. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  56493. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  56494. */
  56495. wipeCaches(bruteForce?: boolean): void;
  56496. /**
  56497. * Send a draw order
  56498. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  56499. * @param indexStart defines the starting index
  56500. * @param indexCount defines the number of index to draw
  56501. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56502. */
  56503. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  56504. /**
  56505. * Draw a list of indexed primitives
  56506. * @param fillMode defines the primitive to use
  56507. * @param indexStart defines the starting index
  56508. * @param indexCount defines the number of index to draw
  56509. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56510. */
  56511. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56512. /**
  56513. * Draw a list of unindexed primitives
  56514. * @param fillMode defines the primitive to use
  56515. * @param verticesStart defines the index of first vertex to draw
  56516. * @param verticesCount defines the count of vertices to draw
  56517. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56518. */
  56519. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56520. /** @hidden */
  56521. _createTexture(): WebGLTexture;
  56522. /** @hidden */
  56523. _releaseTexture(texture: InternalTexture): void;
  56524. /**
  56525. * Usually called from Texture.ts.
  56526. * Passed information to create a WebGLTexture
  56527. * @param urlArg defines a value which contains one of the following:
  56528. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56529. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56530. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56531. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56532. * @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)
  56533. * @param scene needed for loading to the correct scene
  56534. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56535. * @param onLoad optional callback to be called upon successful completion
  56536. * @param onError optional callback to be called upon failure
  56537. * @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
  56538. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56539. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56540. * @param forcedExtension defines the extension to use to pick the right loader
  56541. * @param mimeType defines an optional mime type
  56542. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56543. */
  56544. 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;
  56545. /**
  56546. * Creates a new render target texture
  56547. * @param size defines the size of the texture
  56548. * @param options defines the options used to create the texture
  56549. * @returns a new render target texture stored in an InternalTexture
  56550. */
  56551. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  56552. /**
  56553. * Update the sampling mode of a given texture
  56554. * @param samplingMode defines the required sampling mode
  56555. * @param texture defines the texture to update
  56556. */
  56557. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56558. /**
  56559. * Binds the frame buffer to the specified texture.
  56560. * @param texture The texture to render to or null for the default canvas
  56561. * @param faceIndex The face of the texture to render to in case of cube texture
  56562. * @param requiredWidth The width of the target to render to
  56563. * @param requiredHeight The height of the target to render to
  56564. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  56565. * @param lodLevel defines le lod level to bind to the frame buffer
  56566. */
  56567. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56568. /**
  56569. * Unbind the current render target texture from the webGL context
  56570. * @param texture defines the render target texture to unbind
  56571. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  56572. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  56573. */
  56574. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56575. /**
  56576. * Creates a dynamic vertex buffer
  56577. * @param vertices the data for the dynamic vertex buffer
  56578. * @returns the new WebGL dynamic buffer
  56579. */
  56580. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  56581. /**
  56582. * Update the content of a dynamic texture
  56583. * @param texture defines the texture to update
  56584. * @param canvas defines the canvas containing the source
  56585. * @param invertY defines if data must be stored with Y axis inverted
  56586. * @param premulAlpha defines if alpha is stored as premultiplied
  56587. * @param format defines the format of the data
  56588. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56589. */
  56590. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56591. /**
  56592. * Gets a boolean indicating if all created effects are ready
  56593. * @returns true if all effects are ready
  56594. */
  56595. areAllEffectsReady(): boolean;
  56596. /**
  56597. * @hidden
  56598. * Get the current error code of the webGL context
  56599. * @returns the error code
  56600. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  56601. */
  56602. getError(): number;
  56603. /** @hidden */
  56604. _getUnpackAlignement(): number;
  56605. /** @hidden */
  56606. _unpackFlipY(value: boolean): void;
  56607. /**
  56608. * Update a dynamic index buffer
  56609. * @param indexBuffer defines the target index buffer
  56610. * @param indices defines the data to update
  56611. * @param offset defines the offset in the target index buffer where update should start
  56612. */
  56613. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  56614. /**
  56615. * Updates a dynamic vertex buffer.
  56616. * @param vertexBuffer the vertex buffer to update
  56617. * @param vertices the data used to update the vertex buffer
  56618. * @param byteOffset the byte offset of the data (optional)
  56619. * @param byteLength the byte length of the data (optional)
  56620. */
  56621. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  56622. /** @hidden */
  56623. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  56624. /** @hidden */
  56625. _bindTexture(channel: number, texture: InternalTexture): void;
  56626. protected _deleteBuffer(buffer: WebGLBuffer): void;
  56627. /**
  56628. * 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
  56629. */
  56630. releaseEffects(): void;
  56631. displayLoadingUI(): void;
  56632. hideLoadingUI(): void;
  56633. /** @hidden */
  56634. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56635. /** @hidden */
  56636. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56637. /** @hidden */
  56638. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56639. /** @hidden */
  56640. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56641. }
  56642. }
  56643. declare module BABYLON {
  56644. /**
  56645. * @hidden
  56646. **/
  56647. export class _TimeToken {
  56648. _startTimeQuery: Nullable<WebGLQuery>;
  56649. _endTimeQuery: Nullable<WebGLQuery>;
  56650. _timeElapsedQuery: Nullable<WebGLQuery>;
  56651. _timeElapsedQueryEnded: boolean;
  56652. }
  56653. }
  56654. declare module BABYLON {
  56655. /** @hidden */
  56656. export class _OcclusionDataStorage {
  56657. /** @hidden */
  56658. occlusionInternalRetryCounter: number;
  56659. /** @hidden */
  56660. isOcclusionQueryInProgress: boolean;
  56661. /** @hidden */
  56662. isOccluded: boolean;
  56663. /** @hidden */
  56664. occlusionRetryCount: number;
  56665. /** @hidden */
  56666. occlusionType: number;
  56667. /** @hidden */
  56668. occlusionQueryAlgorithmType: number;
  56669. }
  56670. interface Engine {
  56671. /**
  56672. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  56673. * @return the new query
  56674. */
  56675. createQuery(): WebGLQuery;
  56676. /**
  56677. * Delete and release a webGL query
  56678. * @param query defines the query to delete
  56679. * @return the current engine
  56680. */
  56681. deleteQuery(query: WebGLQuery): Engine;
  56682. /**
  56683. * Check if a given query has resolved and got its value
  56684. * @param query defines the query to check
  56685. * @returns true if the query got its value
  56686. */
  56687. isQueryResultAvailable(query: WebGLQuery): boolean;
  56688. /**
  56689. * Gets the value of a given query
  56690. * @param query defines the query to check
  56691. * @returns the value of the query
  56692. */
  56693. getQueryResult(query: WebGLQuery): number;
  56694. /**
  56695. * Initiates an occlusion query
  56696. * @param algorithmType defines the algorithm to use
  56697. * @param query defines the query to use
  56698. * @returns the current engine
  56699. * @see https://doc.babylonjs.com/features/occlusionquery
  56700. */
  56701. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  56702. /**
  56703. * Ends an occlusion query
  56704. * @see https://doc.babylonjs.com/features/occlusionquery
  56705. * @param algorithmType defines the algorithm to use
  56706. * @returns the current engine
  56707. */
  56708. endOcclusionQuery(algorithmType: number): Engine;
  56709. /**
  56710. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  56711. * Please note that only one query can be issued at a time
  56712. * @returns a time token used to track the time span
  56713. */
  56714. startTimeQuery(): Nullable<_TimeToken>;
  56715. /**
  56716. * Ends a time query
  56717. * @param token defines the token used to measure the time span
  56718. * @returns the time spent (in ns)
  56719. */
  56720. endTimeQuery(token: _TimeToken): int;
  56721. /** @hidden */
  56722. _currentNonTimestampToken: Nullable<_TimeToken>;
  56723. /** @hidden */
  56724. _createTimeQuery(): WebGLQuery;
  56725. /** @hidden */
  56726. _deleteTimeQuery(query: WebGLQuery): void;
  56727. /** @hidden */
  56728. _getGlAlgorithmType(algorithmType: number): number;
  56729. /** @hidden */
  56730. _getTimeQueryResult(query: WebGLQuery): any;
  56731. /** @hidden */
  56732. _getTimeQueryAvailability(query: WebGLQuery): any;
  56733. }
  56734. interface AbstractMesh {
  56735. /**
  56736. * Backing filed
  56737. * @hidden
  56738. */
  56739. __occlusionDataStorage: _OcclusionDataStorage;
  56740. /**
  56741. * Access property
  56742. * @hidden
  56743. */
  56744. _occlusionDataStorage: _OcclusionDataStorage;
  56745. /**
  56746. * 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.
  56747. * The default value is -1 which means don't break the query and wait till the result
  56748. * @see https://doc.babylonjs.com/features/occlusionquery
  56749. */
  56750. occlusionRetryCount: number;
  56751. /**
  56752. * 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:
  56753. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  56754. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  56755. * * 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.
  56756. * @see https://doc.babylonjs.com/features/occlusionquery
  56757. */
  56758. occlusionType: number;
  56759. /**
  56760. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  56761. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  56762. * * 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.
  56763. * @see https://doc.babylonjs.com/features/occlusionquery
  56764. */
  56765. occlusionQueryAlgorithmType: number;
  56766. /**
  56767. * 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
  56768. * @see https://doc.babylonjs.com/features/occlusionquery
  56769. */
  56770. isOccluded: boolean;
  56771. /**
  56772. * Flag to check the progress status of the query
  56773. * @see https://doc.babylonjs.com/features/occlusionquery
  56774. */
  56775. isOcclusionQueryInProgress: boolean;
  56776. }
  56777. }
  56778. declare module BABYLON {
  56779. /** @hidden */
  56780. export var _forceTransformFeedbackToBundle: boolean;
  56781. interface Engine {
  56782. /**
  56783. * Creates a webGL transform feedback object
  56784. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  56785. * @returns the webGL transform feedback object
  56786. */
  56787. createTransformFeedback(): WebGLTransformFeedback;
  56788. /**
  56789. * Delete a webGL transform feedback object
  56790. * @param value defines the webGL transform feedback object to delete
  56791. */
  56792. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  56793. /**
  56794. * Bind a webGL transform feedback object to the webgl context
  56795. * @param value defines the webGL transform feedback object to bind
  56796. */
  56797. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  56798. /**
  56799. * Begins a transform feedback operation
  56800. * @param usePoints defines if points or triangles must be used
  56801. */
  56802. beginTransformFeedback(usePoints: boolean): void;
  56803. /**
  56804. * Ends a transform feedback operation
  56805. */
  56806. endTransformFeedback(): void;
  56807. /**
  56808. * Specify the varyings to use with transform feedback
  56809. * @param program defines the associated webGL program
  56810. * @param value defines the list of strings representing the varying names
  56811. */
  56812. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  56813. /**
  56814. * Bind a webGL buffer for a transform feedback operation
  56815. * @param value defines the webGL buffer to bind
  56816. */
  56817. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  56818. }
  56819. }
  56820. declare module BABYLON {
  56821. /**
  56822. * Class used to define an additional view for the engine
  56823. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56824. */
  56825. export class EngineView {
  56826. /** Defines the canvas where to render the view */
  56827. target: HTMLCanvasElement;
  56828. /** Defines an optional camera used to render the view (will use active camera else) */
  56829. camera?: Camera;
  56830. }
  56831. interface Engine {
  56832. /**
  56833. * Gets or sets the HTML element to use for attaching events
  56834. */
  56835. inputElement: Nullable<HTMLElement>;
  56836. /**
  56837. * Gets the current engine view
  56838. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56839. */
  56840. activeView: Nullable<EngineView>;
  56841. /** Gets or sets the list of views */
  56842. views: EngineView[];
  56843. /**
  56844. * Register a new child canvas
  56845. * @param canvas defines the canvas to register
  56846. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  56847. * @returns the associated view
  56848. */
  56849. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  56850. /**
  56851. * Remove a registered child canvas
  56852. * @param canvas defines the canvas to remove
  56853. * @returns the current engine
  56854. */
  56855. unRegisterView(canvas: HTMLCanvasElement): Engine;
  56856. }
  56857. }
  56858. declare module BABYLON {
  56859. interface Engine {
  56860. /** @hidden */
  56861. _excludedCompressedTextures: string[];
  56862. /** @hidden */
  56863. _textureFormatInUse: string;
  56864. /**
  56865. * Gets the list of texture formats supported
  56866. */
  56867. readonly texturesSupported: Array<string>;
  56868. /**
  56869. * Gets the texture format in use
  56870. */
  56871. readonly textureFormatInUse: Nullable<string>;
  56872. /**
  56873. * Set the compressed texture extensions or file names to skip.
  56874. *
  56875. * @param skippedFiles defines the list of those texture files you want to skip
  56876. * Example: [".dds", ".env", "myfile.png"]
  56877. */
  56878. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  56879. /**
  56880. * Set the compressed texture format to use, based on the formats you have, and the formats
  56881. * supported by the hardware / browser.
  56882. *
  56883. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  56884. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  56885. * to API arguments needed to compressed textures. This puts the burden on the container
  56886. * generator to house the arcane code for determining these for current & future formats.
  56887. *
  56888. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56889. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56890. *
  56891. * Note: The result of this call is not taken into account when a texture is base64.
  56892. *
  56893. * @param formatsAvailable defines the list of those format families you have created
  56894. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  56895. *
  56896. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  56897. * @returns The extension selected.
  56898. */
  56899. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  56900. }
  56901. }
  56902. declare module BABYLON {
  56903. /** @hidden */
  56904. export var rgbdEncodePixelShader: {
  56905. name: string;
  56906. shader: string;
  56907. };
  56908. }
  56909. declare module BABYLON {
  56910. /**
  56911. * Raw texture data and descriptor sufficient for WebGL texture upload
  56912. */
  56913. export interface EnvironmentTextureInfo {
  56914. /**
  56915. * Version of the environment map
  56916. */
  56917. version: number;
  56918. /**
  56919. * Width of image
  56920. */
  56921. width: number;
  56922. /**
  56923. * Irradiance information stored in the file.
  56924. */
  56925. irradiance: any;
  56926. /**
  56927. * Specular information stored in the file.
  56928. */
  56929. specular: any;
  56930. }
  56931. /**
  56932. * Defines One Image in the file. It requires only the position in the file
  56933. * as well as the length.
  56934. */
  56935. interface BufferImageData {
  56936. /**
  56937. * Length of the image data.
  56938. */
  56939. length: number;
  56940. /**
  56941. * Position of the data from the null terminator delimiting the end of the JSON.
  56942. */
  56943. position: number;
  56944. }
  56945. /**
  56946. * Defines the specular data enclosed in the file.
  56947. * This corresponds to the version 1 of the data.
  56948. */
  56949. export interface EnvironmentTextureSpecularInfoV1 {
  56950. /**
  56951. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  56952. */
  56953. specularDataPosition?: number;
  56954. /**
  56955. * This contains all the images data needed to reconstruct the cubemap.
  56956. */
  56957. mipmaps: Array<BufferImageData>;
  56958. /**
  56959. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  56960. */
  56961. lodGenerationScale: number;
  56962. }
  56963. /**
  56964. * Sets of helpers addressing the serialization and deserialization of environment texture
  56965. * stored in a BabylonJS env file.
  56966. * Those files are usually stored as .env files.
  56967. */
  56968. export class EnvironmentTextureTools {
  56969. /**
  56970. * Magic number identifying the env file.
  56971. */
  56972. private static _MagicBytes;
  56973. /**
  56974. * Gets the environment info from an env file.
  56975. * @param data The array buffer containing the .env bytes.
  56976. * @returns the environment file info (the json header) if successfully parsed.
  56977. */
  56978. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56979. /**
  56980. * Creates an environment texture from a loaded cube texture.
  56981. * @param texture defines the cube texture to convert in env file
  56982. * @return a promise containing the environment data if succesfull.
  56983. */
  56984. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56985. /**
  56986. * Creates a JSON representation of the spherical data.
  56987. * @param texture defines the texture containing the polynomials
  56988. * @return the JSON representation of the spherical info
  56989. */
  56990. private static _CreateEnvTextureIrradiance;
  56991. /**
  56992. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56993. * @param data the image data
  56994. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56995. * @return the views described by info providing access to the underlying buffer
  56996. */
  56997. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  56998. /**
  56999. * Uploads the texture info contained in the env file to the GPU.
  57000. * @param texture defines the internal texture to upload to
  57001. * @param data defines the data to load
  57002. * @param info defines the texture info retrieved through the GetEnvInfo method
  57003. * @returns a promise
  57004. */
  57005. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  57006. private static _OnImageReadyAsync;
  57007. /**
  57008. * Uploads the levels of image data to the GPU.
  57009. * @param texture defines the internal texture to upload to
  57010. * @param imageData defines the array buffer views of image data [mipmap][face]
  57011. * @returns a promise
  57012. */
  57013. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  57014. /**
  57015. * Uploads spherical polynomials information to the texture.
  57016. * @param texture defines the texture we are trying to upload the information to
  57017. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  57018. */
  57019. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  57020. /** @hidden */
  57021. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57022. }
  57023. }
  57024. declare module BABYLON {
  57025. /**
  57026. * Class used to inline functions in shader code
  57027. */
  57028. export class ShaderCodeInliner {
  57029. private static readonly _RegexpFindFunctionNameAndType;
  57030. private _sourceCode;
  57031. private _functionDescr;
  57032. private _numMaxIterations;
  57033. /** Gets or sets the token used to mark the functions to inline */
  57034. inlineToken: string;
  57035. /** Gets or sets the debug mode */
  57036. debug: boolean;
  57037. /** Gets the code after the inlining process */
  57038. get code(): string;
  57039. /**
  57040. * Initializes the inliner
  57041. * @param sourceCode shader code source to inline
  57042. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  57043. */
  57044. constructor(sourceCode: string, numMaxIterations?: number);
  57045. /**
  57046. * Start the processing of the shader code
  57047. */
  57048. processCode(): void;
  57049. private _collectFunctions;
  57050. private _processInlining;
  57051. private _extractBetweenMarkers;
  57052. private _skipWhitespaces;
  57053. private _removeComments;
  57054. private _replaceFunctionCallsByCode;
  57055. private _findBackward;
  57056. private _escapeRegExp;
  57057. private _replaceNames;
  57058. }
  57059. }
  57060. declare module BABYLON {
  57061. /**
  57062. * Container for accessors for natively-stored mesh data buffers.
  57063. */
  57064. class NativeDataBuffer extends DataBuffer {
  57065. /**
  57066. * Accessor value used to identify/retrieve a natively-stored index buffer.
  57067. */
  57068. nativeIndexBuffer?: any;
  57069. /**
  57070. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  57071. */
  57072. nativeVertexBuffer?: any;
  57073. }
  57074. /** @hidden */
  57075. class NativeTexture extends InternalTexture {
  57076. getInternalTexture(): InternalTexture;
  57077. getViewCount(): number;
  57078. }
  57079. /** @hidden */
  57080. export class NativeEngine extends Engine {
  57081. private readonly _native;
  57082. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  57083. private readonly INVALID_HANDLE;
  57084. private _boundBuffersVertexArray;
  57085. private _currentDepthTest;
  57086. getHardwareScalingLevel(): number;
  57087. constructor();
  57088. dispose(): void;
  57089. /**
  57090. * Can be used to override the current requestAnimationFrame requester.
  57091. * @hidden
  57092. */
  57093. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  57094. /**
  57095. * Override default engine behavior.
  57096. * @param color
  57097. * @param backBuffer
  57098. * @param depth
  57099. * @param stencil
  57100. */
  57101. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  57102. /**
  57103. * Gets host document
  57104. * @returns the host document object
  57105. */
  57106. getHostDocument(): Nullable<Document>;
  57107. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57108. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  57109. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  57110. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  57111. [key: string]: VertexBuffer;
  57112. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57113. bindBuffers(vertexBuffers: {
  57114. [key: string]: VertexBuffer;
  57115. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57116. recordVertexArrayObject(vertexBuffers: {
  57117. [key: string]: VertexBuffer;
  57118. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  57119. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57120. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57121. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57122. /**
  57123. * Draw a list of indexed primitives
  57124. * @param fillMode defines the primitive to use
  57125. * @param indexStart defines the starting index
  57126. * @param indexCount defines the number of index to draw
  57127. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57128. */
  57129. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57130. /**
  57131. * Draw a list of unindexed primitives
  57132. * @param fillMode defines the primitive to use
  57133. * @param verticesStart defines the index of first vertex to draw
  57134. * @param verticesCount defines the count of vertices to draw
  57135. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57136. */
  57137. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57138. createPipelineContext(): IPipelineContext;
  57139. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  57140. /** @hidden */
  57141. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  57142. /** @hidden */
  57143. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  57144. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57145. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57146. protected _setProgram(program: WebGLProgram): void;
  57147. _releaseEffect(effect: Effect): void;
  57148. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  57149. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  57150. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  57151. bindSamplers(effect: Effect): void;
  57152. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  57153. getRenderWidth(useScreen?: boolean): number;
  57154. getRenderHeight(useScreen?: boolean): number;
  57155. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  57156. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57157. /**
  57158. * Set the z offset to apply to current rendering
  57159. * @param value defines the offset to apply
  57160. */
  57161. setZOffset(value: number): void;
  57162. /**
  57163. * Gets the current value of the zOffset
  57164. * @returns the current zOffset state
  57165. */
  57166. getZOffset(): number;
  57167. /**
  57168. * Enable or disable depth buffering
  57169. * @param enable defines the state to set
  57170. */
  57171. setDepthBuffer(enable: boolean): void;
  57172. /**
  57173. * Gets a boolean indicating if depth writing is enabled
  57174. * @returns the current depth writing state
  57175. */
  57176. getDepthWrite(): boolean;
  57177. setDepthFunctionToGreater(): void;
  57178. setDepthFunctionToGreaterOrEqual(): void;
  57179. setDepthFunctionToLess(): void;
  57180. setDepthFunctionToLessOrEqual(): void;
  57181. /**
  57182. * Enable or disable depth writing
  57183. * @param enable defines the state to set
  57184. */
  57185. setDepthWrite(enable: boolean): void;
  57186. /**
  57187. * Enable or disable color writing
  57188. * @param enable defines the state to set
  57189. */
  57190. setColorWrite(enable: boolean): void;
  57191. /**
  57192. * Gets a boolean indicating if color writing is enabled
  57193. * @returns the current color writing state
  57194. */
  57195. getColorWrite(): boolean;
  57196. /**
  57197. * Sets alpha constants used by some alpha blending modes
  57198. * @param r defines the red component
  57199. * @param g defines the green component
  57200. * @param b defines the blue component
  57201. * @param a defines the alpha component
  57202. */
  57203. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  57204. /**
  57205. * Sets the current alpha mode
  57206. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  57207. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57208. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57209. */
  57210. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57211. /**
  57212. * Gets the current alpha mode
  57213. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57214. * @returns the current alpha mode
  57215. */
  57216. getAlphaMode(): number;
  57217. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  57218. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57219. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57220. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57221. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57222. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57223. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57224. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57225. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57226. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57227. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57228. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57229. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57230. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57231. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57232. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57233. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57234. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57235. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57236. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57237. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  57238. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  57239. wipeCaches(bruteForce?: boolean): void;
  57240. _createTexture(): WebGLTexture;
  57241. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  57242. /**
  57243. * Update the content of a dynamic texture
  57244. * @param texture defines the texture to update
  57245. * @param canvas defines the canvas containing the source
  57246. * @param invertY defines if data must be stored with Y axis inverted
  57247. * @param premulAlpha defines if alpha is stored as premultiplied
  57248. * @param format defines the format of the data
  57249. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57250. */
  57251. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57252. /**
  57253. * Usually called from Texture.ts.
  57254. * Passed information to create a WebGLTexture
  57255. * @param url defines a value which contains one of the following:
  57256. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57257. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57258. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57259. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57260. * @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)
  57261. * @param scene needed for loading to the correct scene
  57262. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57263. * @param onLoad optional callback to be called upon successful completion
  57264. * @param onError optional callback to be called upon failure
  57265. * @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
  57266. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57267. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57268. * @param forcedExtension defines the extension to use to pick the right loader
  57269. * @param mimeType defines an optional mime type
  57270. * @param loaderOptions options to be passed to the loader
  57271. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57272. */
  57273. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  57274. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  57275. _releaseFramebufferObjects(texture: InternalTexture): void;
  57276. /**
  57277. * Creates a cube texture
  57278. * @param rootUrl defines the url where the files to load is located
  57279. * @param scene defines the current scene
  57280. * @param files defines the list of files to load (1 per face)
  57281. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  57282. * @param onLoad defines an optional callback raised when the texture is loaded
  57283. * @param onError defines an optional callback raised if there is an issue to load the texture
  57284. * @param format defines the format of the data
  57285. * @param forcedExtension defines the extension to use to pick the right loader
  57286. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  57287. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57288. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57289. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  57290. * @returns the cube texture as an InternalTexture
  57291. */
  57292. 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;
  57293. createRenderTargetTexture(size: number | {
  57294. width: number;
  57295. height: number;
  57296. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  57297. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57298. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57299. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57300. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  57301. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  57302. /**
  57303. * Updates a dynamic vertex buffer.
  57304. * @param vertexBuffer the vertex buffer to update
  57305. * @param data the data used to update the vertex buffer
  57306. * @param byteOffset the byte offset of the data (optional)
  57307. * @param byteLength the byte length of the data (optional)
  57308. */
  57309. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  57310. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  57311. private _updateAnisotropicLevel;
  57312. private _getAddressMode;
  57313. /** @hidden */
  57314. _bindTexture(channel: number, texture: InternalTexture): void;
  57315. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  57316. releaseEffects(): void;
  57317. /** @hidden */
  57318. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57319. /** @hidden */
  57320. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57321. /** @hidden */
  57322. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57323. /** @hidden */
  57324. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57325. private _getNativeSamplingMode;
  57326. private _getNativeTextureFormat;
  57327. private _getNativeAlphaMode;
  57328. private _getNativeAttribType;
  57329. }
  57330. }
  57331. declare module BABYLON {
  57332. /**
  57333. * Gather the list of clipboard event types as constants.
  57334. */
  57335. export class ClipboardEventTypes {
  57336. /**
  57337. * The clipboard event is fired when a copy command is active (pressed).
  57338. */
  57339. static readonly COPY: number;
  57340. /**
  57341. * The clipboard event is fired when a cut command is active (pressed).
  57342. */
  57343. static readonly CUT: number;
  57344. /**
  57345. * The clipboard event is fired when a paste command is active (pressed).
  57346. */
  57347. static readonly PASTE: number;
  57348. }
  57349. /**
  57350. * This class is used to store clipboard related info for the onClipboardObservable event.
  57351. */
  57352. export class ClipboardInfo {
  57353. /**
  57354. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57355. */
  57356. type: number;
  57357. /**
  57358. * Defines the related dom event
  57359. */
  57360. event: ClipboardEvent;
  57361. /**
  57362. *Creates an instance of ClipboardInfo.
  57363. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  57364. * @param event Defines the related dom event
  57365. */
  57366. constructor(
  57367. /**
  57368. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57369. */
  57370. type: number,
  57371. /**
  57372. * Defines the related dom event
  57373. */
  57374. event: ClipboardEvent);
  57375. /**
  57376. * Get the clipboard event's type from the keycode.
  57377. * @param keyCode Defines the keyCode for the current keyboard event.
  57378. * @return {number}
  57379. */
  57380. static GetTypeFromCharacter(keyCode: number): number;
  57381. }
  57382. }
  57383. declare module BABYLON {
  57384. /**
  57385. * Google Daydream controller
  57386. */
  57387. export class DaydreamController extends WebVRController {
  57388. /**
  57389. * Base Url for the controller model.
  57390. */
  57391. static MODEL_BASE_URL: string;
  57392. /**
  57393. * File name for the controller model.
  57394. */
  57395. static MODEL_FILENAME: string;
  57396. /**
  57397. * Gamepad Id prefix used to identify Daydream Controller.
  57398. */
  57399. static readonly GAMEPAD_ID_PREFIX: string;
  57400. /**
  57401. * Creates a new DaydreamController from a gamepad
  57402. * @param vrGamepad the gamepad that the controller should be created from
  57403. */
  57404. constructor(vrGamepad: any);
  57405. /**
  57406. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57407. * @param scene scene in which to add meshes
  57408. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57409. */
  57410. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57411. /**
  57412. * Called once for each button that changed state since the last frame
  57413. * @param buttonIdx Which button index changed
  57414. * @param state New state of the button
  57415. * @param changes Which properties on the state changed since last frame
  57416. */
  57417. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57418. }
  57419. }
  57420. declare module BABYLON {
  57421. /**
  57422. * Gear VR Controller
  57423. */
  57424. export class GearVRController extends WebVRController {
  57425. /**
  57426. * Base Url for the controller model.
  57427. */
  57428. static MODEL_BASE_URL: string;
  57429. /**
  57430. * File name for the controller model.
  57431. */
  57432. static MODEL_FILENAME: string;
  57433. /**
  57434. * Gamepad Id prefix used to identify this controller.
  57435. */
  57436. static readonly GAMEPAD_ID_PREFIX: string;
  57437. private readonly _buttonIndexToObservableNameMap;
  57438. /**
  57439. * Creates a new GearVRController from a gamepad
  57440. * @param vrGamepad the gamepad that the controller should be created from
  57441. */
  57442. constructor(vrGamepad: any);
  57443. /**
  57444. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57445. * @param scene scene in which to add meshes
  57446. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57447. */
  57448. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57449. /**
  57450. * Called once for each button that changed state since the last frame
  57451. * @param buttonIdx Which button index changed
  57452. * @param state New state of the button
  57453. * @param changes Which properties on the state changed since last frame
  57454. */
  57455. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57456. }
  57457. }
  57458. declare module BABYLON {
  57459. /**
  57460. * Generic Controller
  57461. */
  57462. export class GenericController extends WebVRController {
  57463. /**
  57464. * Base Url for the controller model.
  57465. */
  57466. static readonly MODEL_BASE_URL: string;
  57467. /**
  57468. * File name for the controller model.
  57469. */
  57470. static readonly MODEL_FILENAME: string;
  57471. /**
  57472. * Creates a new GenericController from a gamepad
  57473. * @param vrGamepad the gamepad that the controller should be created from
  57474. */
  57475. constructor(vrGamepad: any);
  57476. /**
  57477. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57478. * @param scene scene in which to add meshes
  57479. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57480. */
  57481. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57482. /**
  57483. * Called once for each button that changed state since the last frame
  57484. * @param buttonIdx Which button index changed
  57485. * @param state New state of the button
  57486. * @param changes Which properties on the state changed since last frame
  57487. */
  57488. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57489. }
  57490. }
  57491. declare module BABYLON {
  57492. /**
  57493. * Oculus Touch Controller
  57494. */
  57495. export class OculusTouchController extends WebVRController {
  57496. /**
  57497. * Base Url for the controller model.
  57498. */
  57499. static MODEL_BASE_URL: string;
  57500. /**
  57501. * File name for the left controller model.
  57502. */
  57503. static MODEL_LEFT_FILENAME: string;
  57504. /**
  57505. * File name for the right controller model.
  57506. */
  57507. static MODEL_RIGHT_FILENAME: string;
  57508. /**
  57509. * Base Url for the Quest controller model.
  57510. */
  57511. static QUEST_MODEL_BASE_URL: string;
  57512. /**
  57513. * @hidden
  57514. * If the controllers are running on a device that needs the updated Quest controller models
  57515. */
  57516. static _IsQuest: boolean;
  57517. /**
  57518. * Fired when the secondary trigger on this controller is modified
  57519. */
  57520. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  57521. /**
  57522. * Fired when the thumb rest on this controller is modified
  57523. */
  57524. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  57525. /**
  57526. * Creates a new OculusTouchController from a gamepad
  57527. * @param vrGamepad the gamepad that the controller should be created from
  57528. */
  57529. constructor(vrGamepad: any);
  57530. /**
  57531. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57532. * @param scene scene in which to add meshes
  57533. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57534. */
  57535. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57536. /**
  57537. * Fired when the A button on this controller is modified
  57538. */
  57539. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57540. /**
  57541. * Fired when the B button on this controller is modified
  57542. */
  57543. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57544. /**
  57545. * Fired when the X button on this controller is modified
  57546. */
  57547. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57548. /**
  57549. * Fired when the Y button on this controller is modified
  57550. */
  57551. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57552. /**
  57553. * Called once for each button that changed state since the last frame
  57554. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  57555. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  57556. * 2) secondary trigger (same)
  57557. * 3) A (right) X (left), touch, pressed = value
  57558. * 4) B / Y
  57559. * 5) thumb rest
  57560. * @param buttonIdx Which button index changed
  57561. * @param state New state of the button
  57562. * @param changes Which properties on the state changed since last frame
  57563. */
  57564. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57565. }
  57566. }
  57567. declare module BABYLON {
  57568. /**
  57569. * Vive Controller
  57570. */
  57571. export class ViveController extends WebVRController {
  57572. /**
  57573. * Base Url for the controller model.
  57574. */
  57575. static MODEL_BASE_URL: string;
  57576. /**
  57577. * File name for the controller model.
  57578. */
  57579. static MODEL_FILENAME: string;
  57580. /**
  57581. * Creates a new ViveController from a gamepad
  57582. * @param vrGamepad the gamepad that the controller should be created from
  57583. */
  57584. constructor(vrGamepad: any);
  57585. /**
  57586. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57587. * @param scene scene in which to add meshes
  57588. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57589. */
  57590. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57591. /**
  57592. * Fired when the left button on this controller is modified
  57593. */
  57594. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57595. /**
  57596. * Fired when the right button on this controller is modified
  57597. */
  57598. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57599. /**
  57600. * Fired when the menu button on this controller is modified
  57601. */
  57602. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57603. /**
  57604. * Called once for each button that changed state since the last frame
  57605. * Vive mapping:
  57606. * 0: touchpad
  57607. * 1: trigger
  57608. * 2: left AND right buttons
  57609. * 3: menu button
  57610. * @param buttonIdx Which button index changed
  57611. * @param state New state of the button
  57612. * @param changes Which properties on the state changed since last frame
  57613. */
  57614. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57615. }
  57616. }
  57617. declare module BABYLON {
  57618. /**
  57619. * Defines the WindowsMotionController object that the state of the windows motion controller
  57620. */
  57621. export class WindowsMotionController extends WebVRController {
  57622. /**
  57623. * The base url used to load the left and right controller models
  57624. */
  57625. static MODEL_BASE_URL: string;
  57626. /**
  57627. * The name of the left controller model file
  57628. */
  57629. static MODEL_LEFT_FILENAME: string;
  57630. /**
  57631. * The name of the right controller model file
  57632. */
  57633. static MODEL_RIGHT_FILENAME: string;
  57634. /**
  57635. * The controller name prefix for this controller type
  57636. */
  57637. static readonly GAMEPAD_ID_PREFIX: string;
  57638. /**
  57639. * The controller id pattern for this controller type
  57640. */
  57641. private static readonly GAMEPAD_ID_PATTERN;
  57642. private _loadedMeshInfo;
  57643. protected readonly _mapping: {
  57644. buttons: string[];
  57645. buttonMeshNames: {
  57646. trigger: string;
  57647. menu: string;
  57648. grip: string;
  57649. thumbstick: string;
  57650. trackpad: string;
  57651. };
  57652. buttonObservableNames: {
  57653. trigger: string;
  57654. menu: string;
  57655. grip: string;
  57656. thumbstick: string;
  57657. trackpad: string;
  57658. };
  57659. axisMeshNames: string[];
  57660. pointingPoseMeshName: string;
  57661. };
  57662. /**
  57663. * Fired when the trackpad on this controller is clicked
  57664. */
  57665. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57666. /**
  57667. * Fired when the trackpad on this controller is modified
  57668. */
  57669. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57670. /**
  57671. * The current x and y values of this controller's trackpad
  57672. */
  57673. trackpad: StickValues;
  57674. /**
  57675. * Creates a new WindowsMotionController from a gamepad
  57676. * @param vrGamepad the gamepad that the controller should be created from
  57677. */
  57678. constructor(vrGamepad: any);
  57679. /**
  57680. * Fired when the trigger on this controller is modified
  57681. */
  57682. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57683. /**
  57684. * Fired when the menu button on this controller is modified
  57685. */
  57686. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57687. /**
  57688. * Fired when the grip button on this controller is modified
  57689. */
  57690. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57691. /**
  57692. * Fired when the thumbstick button on this controller is modified
  57693. */
  57694. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57695. /**
  57696. * Fired when the touchpad button on this controller is modified
  57697. */
  57698. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57699. /**
  57700. * Fired when the touchpad values on this controller are modified
  57701. */
  57702. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  57703. protected _updateTrackpad(): void;
  57704. /**
  57705. * Called once per frame by the engine.
  57706. */
  57707. update(): void;
  57708. /**
  57709. * Called once for each button that changed state since the last frame
  57710. * @param buttonIdx Which button index changed
  57711. * @param state New state of the button
  57712. * @param changes Which properties on the state changed since last frame
  57713. */
  57714. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57715. /**
  57716. * Moves the buttons on the controller mesh based on their current state
  57717. * @param buttonName the name of the button to move
  57718. * @param buttonValue the value of the button which determines the buttons new position
  57719. */
  57720. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  57721. /**
  57722. * Moves the axis on the controller mesh based on its current state
  57723. * @param axis the index of the axis
  57724. * @param axisValue the value of the axis which determines the meshes new position
  57725. * @hidden
  57726. */
  57727. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  57728. /**
  57729. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57730. * @param scene scene in which to add meshes
  57731. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57732. */
  57733. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  57734. /**
  57735. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  57736. * can be transformed by button presses and axes values, based on this._mapping.
  57737. *
  57738. * @param scene scene in which the meshes exist
  57739. * @param meshes list of meshes that make up the controller model to process
  57740. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  57741. */
  57742. private processModel;
  57743. private createMeshInfo;
  57744. /**
  57745. * Gets the ray of the controller in the direction the controller is pointing
  57746. * @param length the length the resulting ray should be
  57747. * @returns a ray in the direction the controller is pointing
  57748. */
  57749. getForwardRay(length?: number): Ray;
  57750. /**
  57751. * Disposes of the controller
  57752. */
  57753. dispose(): void;
  57754. }
  57755. /**
  57756. * This class represents a new windows motion controller in XR.
  57757. */
  57758. export class XRWindowsMotionController extends WindowsMotionController {
  57759. /**
  57760. * Changing the original WIndowsMotionController mapping to fir the new mapping
  57761. */
  57762. protected readonly _mapping: {
  57763. buttons: string[];
  57764. buttonMeshNames: {
  57765. trigger: string;
  57766. menu: string;
  57767. grip: string;
  57768. thumbstick: string;
  57769. trackpad: string;
  57770. };
  57771. buttonObservableNames: {
  57772. trigger: string;
  57773. menu: string;
  57774. grip: string;
  57775. thumbstick: string;
  57776. trackpad: string;
  57777. };
  57778. axisMeshNames: string[];
  57779. pointingPoseMeshName: string;
  57780. };
  57781. /**
  57782. * Construct a new XR-Based windows motion controller
  57783. *
  57784. * @param gamepadInfo the gamepad object from the browser
  57785. */
  57786. constructor(gamepadInfo: any);
  57787. /**
  57788. * holds the thumbstick values (X,Y)
  57789. */
  57790. thumbstickValues: StickValues;
  57791. /**
  57792. * Fired when the thumbstick on this controller is clicked
  57793. */
  57794. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  57795. /**
  57796. * Fired when the thumbstick on this controller is modified
  57797. */
  57798. onThumbstickValuesChangedObservable: Observable<StickValues>;
  57799. /**
  57800. * Fired when the touchpad button on this controller is modified
  57801. */
  57802. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57803. /**
  57804. * Fired when the touchpad values on this controller are modified
  57805. */
  57806. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57807. /**
  57808. * Fired when the thumbstick button on this controller is modified
  57809. * here to prevent breaking changes
  57810. */
  57811. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57812. /**
  57813. * updating the thumbstick(!) and not the trackpad.
  57814. * This is named this way due to the difference between WebVR and XR and to avoid
  57815. * changing the parent class.
  57816. */
  57817. protected _updateTrackpad(): void;
  57818. /**
  57819. * Disposes the class with joy
  57820. */
  57821. dispose(): void;
  57822. }
  57823. }
  57824. declare module BABYLON {
  57825. /**
  57826. * A directional light is defined by a direction (what a surprise!).
  57827. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57828. * 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.
  57829. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57830. */
  57831. export class DirectionalLight extends ShadowLight {
  57832. private _shadowFrustumSize;
  57833. /**
  57834. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57835. */
  57836. get shadowFrustumSize(): number;
  57837. /**
  57838. * Specifies a fix frustum size for the shadow generation.
  57839. */
  57840. set shadowFrustumSize(value: number);
  57841. private _shadowOrthoScale;
  57842. /**
  57843. * Gets the shadow projection scale against the optimal computed one.
  57844. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57845. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57846. */
  57847. get shadowOrthoScale(): number;
  57848. /**
  57849. * Sets the shadow projection scale against the optimal computed one.
  57850. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57851. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57852. */
  57853. set shadowOrthoScale(value: number);
  57854. /**
  57855. * Automatically compute the projection matrix to best fit (including all the casters)
  57856. * on each frame.
  57857. */
  57858. autoUpdateExtends: boolean;
  57859. /**
  57860. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57861. * on each frame. autoUpdateExtends must be set to true for this to work
  57862. */
  57863. autoCalcShadowZBounds: boolean;
  57864. private _orthoLeft;
  57865. private _orthoRight;
  57866. private _orthoTop;
  57867. private _orthoBottom;
  57868. /**
  57869. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57870. * The directional light is emitted from everywhere in the given direction.
  57871. * It can cast shadows.
  57872. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57873. * @param name The friendly name of the light
  57874. * @param direction The direction of the light
  57875. * @param scene The scene the light belongs to
  57876. */
  57877. constructor(name: string, direction: Vector3, scene: Scene);
  57878. /**
  57879. * Returns the string "DirectionalLight".
  57880. * @return The class name
  57881. */
  57882. getClassName(): string;
  57883. /**
  57884. * Returns the integer 1.
  57885. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57886. */
  57887. getTypeID(): number;
  57888. /**
  57889. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57890. * Returns the DirectionalLight Shadow projection matrix.
  57891. */
  57892. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57893. /**
  57894. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57895. * Returns the DirectionalLight Shadow projection matrix.
  57896. */
  57897. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57898. /**
  57899. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57900. * Returns the DirectionalLight Shadow projection matrix.
  57901. */
  57902. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57903. protected _buildUniformLayout(): void;
  57904. /**
  57905. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57906. * @param effect The effect to update
  57907. * @param lightIndex The index of the light in the effect to update
  57908. * @returns The directional light
  57909. */
  57910. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57911. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57912. /**
  57913. * Gets the minZ used for shadow according to both the scene and the light.
  57914. *
  57915. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57916. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57917. * @param activeCamera The camera we are returning the min for
  57918. * @returns the depth min z
  57919. */
  57920. getDepthMinZ(activeCamera: Camera): number;
  57921. /**
  57922. * Gets the maxZ used for shadow according to both the scene and the light.
  57923. *
  57924. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57925. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57926. * @param activeCamera The camera we are returning the max for
  57927. * @returns the depth max z
  57928. */
  57929. getDepthMaxZ(activeCamera: Camera): number;
  57930. /**
  57931. * Prepares the list of defines specific to the light type.
  57932. * @param defines the list of defines
  57933. * @param lightIndex defines the index of the light for the effect
  57934. */
  57935. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57936. }
  57937. }
  57938. declare module BABYLON {
  57939. /**
  57940. * Class containing static functions to help procedurally build meshes
  57941. */
  57942. export class HemisphereBuilder {
  57943. /**
  57944. * Creates a hemisphere mesh
  57945. * @param name defines the name of the mesh
  57946. * @param options defines the options used to create the mesh
  57947. * @param scene defines the hosting scene
  57948. * @returns the hemisphere mesh
  57949. */
  57950. static CreateHemisphere(name: string, options: {
  57951. segments?: number;
  57952. diameter?: number;
  57953. sideOrientation?: number;
  57954. }, scene: any): Mesh;
  57955. }
  57956. }
  57957. declare module BABYLON {
  57958. /**
  57959. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57960. * These values define a cone of light starting from the position, emitting toward the direction.
  57961. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57962. * and the exponent defines the speed of the decay of the light with distance (reach).
  57963. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57964. */
  57965. export class SpotLight extends ShadowLight {
  57966. private _angle;
  57967. private _innerAngle;
  57968. private _cosHalfAngle;
  57969. private _lightAngleScale;
  57970. private _lightAngleOffset;
  57971. /**
  57972. * Gets the cone angle of the spot light in Radians.
  57973. */
  57974. get angle(): number;
  57975. /**
  57976. * Sets the cone angle of the spot light in Radians.
  57977. */
  57978. set angle(value: number);
  57979. /**
  57980. * Only used in gltf falloff mode, this defines the angle where
  57981. * the directional falloff will start before cutting at angle which could be seen
  57982. * as outer angle.
  57983. */
  57984. get innerAngle(): number;
  57985. /**
  57986. * Only used in gltf falloff mode, this defines the angle where
  57987. * the directional falloff will start before cutting at angle which could be seen
  57988. * as outer angle.
  57989. */
  57990. set innerAngle(value: number);
  57991. private _shadowAngleScale;
  57992. /**
  57993. * Allows scaling the angle of the light for shadow generation only.
  57994. */
  57995. get shadowAngleScale(): number;
  57996. /**
  57997. * Allows scaling the angle of the light for shadow generation only.
  57998. */
  57999. set shadowAngleScale(value: number);
  58000. /**
  58001. * The light decay speed with the distance from the emission spot.
  58002. */
  58003. exponent: number;
  58004. private _projectionTextureMatrix;
  58005. /**
  58006. * Allows reading the projecton texture
  58007. */
  58008. get projectionTextureMatrix(): Matrix;
  58009. protected _projectionTextureLightNear: number;
  58010. /**
  58011. * Gets the near clip of the Spotlight for texture projection.
  58012. */
  58013. get projectionTextureLightNear(): number;
  58014. /**
  58015. * Sets the near clip of the Spotlight for texture projection.
  58016. */
  58017. set projectionTextureLightNear(value: number);
  58018. protected _projectionTextureLightFar: number;
  58019. /**
  58020. * Gets the far clip of the Spotlight for texture projection.
  58021. */
  58022. get projectionTextureLightFar(): number;
  58023. /**
  58024. * Sets the far clip of the Spotlight for texture projection.
  58025. */
  58026. set projectionTextureLightFar(value: number);
  58027. protected _projectionTextureUpDirection: Vector3;
  58028. /**
  58029. * Gets the Up vector of the Spotlight for texture projection.
  58030. */
  58031. get projectionTextureUpDirection(): Vector3;
  58032. /**
  58033. * Sets the Up vector of the Spotlight for texture projection.
  58034. */
  58035. set projectionTextureUpDirection(value: Vector3);
  58036. private _projectionTexture;
  58037. /**
  58038. * Gets the projection texture of the light.
  58039. */
  58040. get projectionTexture(): Nullable<BaseTexture>;
  58041. /**
  58042. * Sets the projection texture of the light.
  58043. */
  58044. set projectionTexture(value: Nullable<BaseTexture>);
  58045. private static _IsProceduralTexture;
  58046. private static _IsTexture;
  58047. private _projectionTextureViewLightDirty;
  58048. private _projectionTextureProjectionLightDirty;
  58049. private _projectionTextureDirty;
  58050. private _projectionTextureViewTargetVector;
  58051. private _projectionTextureViewLightMatrix;
  58052. private _projectionTextureProjectionLightMatrix;
  58053. private _projectionTextureScalingMatrix;
  58054. /**
  58055. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  58056. * It can cast shadows.
  58057. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58058. * @param name The light friendly name
  58059. * @param position The position of the spot light in the scene
  58060. * @param direction The direction of the light in the scene
  58061. * @param angle The cone angle of the light in Radians
  58062. * @param exponent The light decay speed with the distance from the emission spot
  58063. * @param scene The scene the lights belongs to
  58064. */
  58065. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  58066. /**
  58067. * Returns the string "SpotLight".
  58068. * @returns the class name
  58069. */
  58070. getClassName(): string;
  58071. /**
  58072. * Returns the integer 2.
  58073. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58074. */
  58075. getTypeID(): number;
  58076. /**
  58077. * Overrides the direction setter to recompute the projection texture view light Matrix.
  58078. */
  58079. protected _setDirection(value: Vector3): void;
  58080. /**
  58081. * Overrides the position setter to recompute the projection texture view light Matrix.
  58082. */
  58083. protected _setPosition(value: Vector3): void;
  58084. /**
  58085. * 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.
  58086. * Returns the SpotLight.
  58087. */
  58088. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58089. protected _computeProjectionTextureViewLightMatrix(): void;
  58090. protected _computeProjectionTextureProjectionLightMatrix(): void;
  58091. /**
  58092. * Main function for light texture projection matrix computing.
  58093. */
  58094. protected _computeProjectionTextureMatrix(): void;
  58095. protected _buildUniformLayout(): void;
  58096. private _computeAngleValues;
  58097. /**
  58098. * Sets the passed Effect "effect" with the Light textures.
  58099. * @param effect The effect to update
  58100. * @param lightIndex The index of the light in the effect to update
  58101. * @returns The light
  58102. */
  58103. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  58104. /**
  58105. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  58106. * @param effect The effect to update
  58107. * @param lightIndex The index of the light in the effect to update
  58108. * @returns The spot light
  58109. */
  58110. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  58111. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58112. /**
  58113. * Disposes the light and the associated resources.
  58114. */
  58115. dispose(): void;
  58116. /**
  58117. * Prepares the list of defines specific to the light type.
  58118. * @param defines the list of defines
  58119. * @param lightIndex defines the index of the light for the effect
  58120. */
  58121. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58122. }
  58123. }
  58124. declare module BABYLON {
  58125. /**
  58126. * Gizmo that enables viewing a light
  58127. */
  58128. export class LightGizmo extends Gizmo {
  58129. private _lightMesh;
  58130. private _material;
  58131. private _cachedPosition;
  58132. private _cachedForward;
  58133. private _attachedMeshParent;
  58134. private _pointerObserver;
  58135. /**
  58136. * Event that fires each time the gizmo is clicked
  58137. */
  58138. onClickedObservable: Observable<Light>;
  58139. /**
  58140. * Creates a LightGizmo
  58141. * @param gizmoLayer The utility layer the gizmo will be added to
  58142. */
  58143. constructor(gizmoLayer?: UtilityLayerRenderer);
  58144. private _light;
  58145. /**
  58146. * The light that the gizmo is attached to
  58147. */
  58148. set light(light: Nullable<Light>);
  58149. get light(): Nullable<Light>;
  58150. /**
  58151. * Gets the material used to render the light gizmo
  58152. */
  58153. get material(): StandardMaterial;
  58154. /**
  58155. * @hidden
  58156. * Updates the gizmo to match the attached mesh's position/rotation
  58157. */
  58158. protected _update(): void;
  58159. private static _Scale;
  58160. /**
  58161. * Creates the lines for a light mesh
  58162. */
  58163. private static _CreateLightLines;
  58164. /**
  58165. * Disposes of the light gizmo
  58166. */
  58167. dispose(): void;
  58168. private static _CreateHemisphericLightMesh;
  58169. private static _CreatePointLightMesh;
  58170. private static _CreateSpotLightMesh;
  58171. private static _CreateDirectionalLightMesh;
  58172. }
  58173. }
  58174. declare module BABYLON {
  58175. /**
  58176. * Gizmo that enables viewing a camera
  58177. */
  58178. export class CameraGizmo extends Gizmo {
  58179. private _cameraMesh;
  58180. private _cameraLinesMesh;
  58181. private _material;
  58182. private _pointerObserver;
  58183. /**
  58184. * Event that fires each time the gizmo is clicked
  58185. */
  58186. onClickedObservable: Observable<Camera>;
  58187. /**
  58188. * Creates a CameraGizmo
  58189. * @param gizmoLayer The utility layer the gizmo will be added to
  58190. */
  58191. constructor(gizmoLayer?: UtilityLayerRenderer);
  58192. private _camera;
  58193. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  58194. get displayFrustum(): boolean;
  58195. set displayFrustum(value: boolean);
  58196. /**
  58197. * The camera that the gizmo is attached to
  58198. */
  58199. set camera(camera: Nullable<Camera>);
  58200. get camera(): Nullable<Camera>;
  58201. /**
  58202. * Gets the material used to render the camera gizmo
  58203. */
  58204. get material(): StandardMaterial;
  58205. /**
  58206. * @hidden
  58207. * Updates the gizmo to match the attached mesh's position/rotation
  58208. */
  58209. protected _update(): void;
  58210. private static _Scale;
  58211. private _invProjection;
  58212. /**
  58213. * Disposes of the camera gizmo
  58214. */
  58215. dispose(): void;
  58216. private static _CreateCameraMesh;
  58217. private static _CreateCameraFrustum;
  58218. }
  58219. }
  58220. declare module BABYLON {
  58221. /** @hidden */
  58222. export var backgroundFragmentDeclaration: {
  58223. name: string;
  58224. shader: string;
  58225. };
  58226. }
  58227. declare module BABYLON {
  58228. /** @hidden */
  58229. export var backgroundUboDeclaration: {
  58230. name: string;
  58231. shader: string;
  58232. };
  58233. }
  58234. declare module BABYLON {
  58235. /** @hidden */
  58236. export var backgroundPixelShader: {
  58237. name: string;
  58238. shader: string;
  58239. };
  58240. }
  58241. declare module BABYLON {
  58242. /** @hidden */
  58243. export var backgroundVertexDeclaration: {
  58244. name: string;
  58245. shader: string;
  58246. };
  58247. }
  58248. declare module BABYLON {
  58249. /** @hidden */
  58250. export var backgroundVertexShader: {
  58251. name: string;
  58252. shader: string;
  58253. };
  58254. }
  58255. declare module BABYLON {
  58256. /**
  58257. * Background material used to create an efficient environement around your scene.
  58258. */
  58259. export class BackgroundMaterial extends PushMaterial {
  58260. /**
  58261. * Standard reflectance value at parallel view angle.
  58262. */
  58263. static StandardReflectance0: number;
  58264. /**
  58265. * Standard reflectance value at grazing angle.
  58266. */
  58267. static StandardReflectance90: number;
  58268. protected _primaryColor: Color3;
  58269. /**
  58270. * Key light Color (multiply against the environement texture)
  58271. */
  58272. primaryColor: Color3;
  58273. protected __perceptualColor: Nullable<Color3>;
  58274. /**
  58275. * Experimental Internal Use Only.
  58276. *
  58277. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  58278. * This acts as a helper to set the primary color to a more "human friendly" value.
  58279. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  58280. * output color as close as possible from the chosen value.
  58281. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  58282. * part of lighting setup.)
  58283. */
  58284. get _perceptualColor(): Nullable<Color3>;
  58285. set _perceptualColor(value: Nullable<Color3>);
  58286. protected _primaryColorShadowLevel: float;
  58287. /**
  58288. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  58289. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  58290. */
  58291. get primaryColorShadowLevel(): float;
  58292. set primaryColorShadowLevel(value: float);
  58293. protected _primaryColorHighlightLevel: float;
  58294. /**
  58295. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  58296. * The primary color is used at the level chosen to define what the white area would look.
  58297. */
  58298. get primaryColorHighlightLevel(): float;
  58299. set primaryColorHighlightLevel(value: float);
  58300. protected _reflectionTexture: Nullable<BaseTexture>;
  58301. /**
  58302. * Reflection Texture used in the material.
  58303. * Should be author in a specific way for the best result (refer to the documentation).
  58304. */
  58305. reflectionTexture: Nullable<BaseTexture>;
  58306. protected _reflectionBlur: float;
  58307. /**
  58308. * Reflection Texture level of blur.
  58309. *
  58310. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  58311. * texture twice.
  58312. */
  58313. reflectionBlur: float;
  58314. protected _diffuseTexture: Nullable<BaseTexture>;
  58315. /**
  58316. * Diffuse Texture used in the material.
  58317. * Should be author in a specific way for the best result (refer to the documentation).
  58318. */
  58319. diffuseTexture: Nullable<BaseTexture>;
  58320. protected _shadowLights: Nullable<IShadowLight[]>;
  58321. /**
  58322. * Specify the list of lights casting shadow on the material.
  58323. * All scene shadow lights will be included if null.
  58324. */
  58325. shadowLights: Nullable<IShadowLight[]>;
  58326. protected _shadowLevel: float;
  58327. /**
  58328. * Helps adjusting the shadow to a softer level if required.
  58329. * 0 means black shadows and 1 means no shadows.
  58330. */
  58331. shadowLevel: float;
  58332. protected _sceneCenter: Vector3;
  58333. /**
  58334. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  58335. * It is usually zero but might be interesting to modify according to your setup.
  58336. */
  58337. sceneCenter: Vector3;
  58338. protected _opacityFresnel: boolean;
  58339. /**
  58340. * This helps specifying that the material is falling off to the sky box at grazing angle.
  58341. * This helps ensuring a nice transition when the camera goes under the ground.
  58342. */
  58343. opacityFresnel: boolean;
  58344. protected _reflectionFresnel: boolean;
  58345. /**
  58346. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  58347. * This helps adding a mirror texture on the ground.
  58348. */
  58349. reflectionFresnel: boolean;
  58350. protected _reflectionFalloffDistance: number;
  58351. /**
  58352. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  58353. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  58354. */
  58355. reflectionFalloffDistance: number;
  58356. protected _reflectionAmount: number;
  58357. /**
  58358. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  58359. */
  58360. reflectionAmount: number;
  58361. protected _reflectionReflectance0: number;
  58362. /**
  58363. * This specifies the weight of the reflection at grazing angle.
  58364. */
  58365. reflectionReflectance0: number;
  58366. protected _reflectionReflectance90: number;
  58367. /**
  58368. * This specifies the weight of the reflection at a perpendicular point of view.
  58369. */
  58370. reflectionReflectance90: number;
  58371. /**
  58372. * Sets the reflection reflectance fresnel values according to the default standard
  58373. * empirically know to work well :-)
  58374. */
  58375. set reflectionStandardFresnelWeight(value: number);
  58376. protected _useRGBColor: boolean;
  58377. /**
  58378. * Helps to directly use the maps channels instead of their level.
  58379. */
  58380. useRGBColor: boolean;
  58381. protected _enableNoise: boolean;
  58382. /**
  58383. * This helps reducing the banding effect that could occur on the background.
  58384. */
  58385. enableNoise: boolean;
  58386. /**
  58387. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58388. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  58389. * Recommended to be keep at 1.0 except for special cases.
  58390. */
  58391. get fovMultiplier(): number;
  58392. set fovMultiplier(value: number);
  58393. private _fovMultiplier;
  58394. /**
  58395. * Enable the FOV adjustment feature controlled by fovMultiplier.
  58396. */
  58397. useEquirectangularFOV: boolean;
  58398. private _maxSimultaneousLights;
  58399. /**
  58400. * Number of Simultaneous lights allowed on the material.
  58401. */
  58402. maxSimultaneousLights: int;
  58403. private _shadowOnly;
  58404. /**
  58405. * Make the material only render shadows
  58406. */
  58407. shadowOnly: boolean;
  58408. /**
  58409. * Default configuration related to image processing available in the Background Material.
  58410. */
  58411. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58412. /**
  58413. * Keep track of the image processing observer to allow dispose and replace.
  58414. */
  58415. private _imageProcessingObserver;
  58416. /**
  58417. * Attaches a new image processing configuration to the PBR Material.
  58418. * @param configuration (if null the scene configuration will be use)
  58419. */
  58420. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58421. /**
  58422. * Gets the image processing configuration used either in this material.
  58423. */
  58424. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  58425. /**
  58426. * Sets the Default image processing configuration used either in the this material.
  58427. *
  58428. * If sets to null, the scene one is in use.
  58429. */
  58430. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  58431. /**
  58432. * Gets wether the color curves effect is enabled.
  58433. */
  58434. get cameraColorCurvesEnabled(): boolean;
  58435. /**
  58436. * Sets wether the color curves effect is enabled.
  58437. */
  58438. set cameraColorCurvesEnabled(value: boolean);
  58439. /**
  58440. * Gets wether the color grading effect is enabled.
  58441. */
  58442. get cameraColorGradingEnabled(): boolean;
  58443. /**
  58444. * Gets wether the color grading effect is enabled.
  58445. */
  58446. set cameraColorGradingEnabled(value: boolean);
  58447. /**
  58448. * Gets wether tonemapping is enabled or not.
  58449. */
  58450. get cameraToneMappingEnabled(): boolean;
  58451. /**
  58452. * Sets wether tonemapping is enabled or not
  58453. */
  58454. set cameraToneMappingEnabled(value: boolean);
  58455. /**
  58456. * The camera exposure used on this material.
  58457. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58458. * This corresponds to a photographic exposure.
  58459. */
  58460. get cameraExposure(): float;
  58461. /**
  58462. * The camera exposure used on this material.
  58463. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58464. * This corresponds to a photographic exposure.
  58465. */
  58466. set cameraExposure(value: float);
  58467. /**
  58468. * Gets The camera contrast used on this material.
  58469. */
  58470. get cameraContrast(): float;
  58471. /**
  58472. * Sets The camera contrast used on this material.
  58473. */
  58474. set cameraContrast(value: float);
  58475. /**
  58476. * Gets the Color Grading 2D Lookup Texture.
  58477. */
  58478. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58479. /**
  58480. * Sets the Color Grading 2D Lookup Texture.
  58481. */
  58482. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58483. /**
  58484. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58485. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58486. * 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;
  58487. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58488. */
  58489. get cameraColorCurves(): Nullable<ColorCurves>;
  58490. /**
  58491. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58492. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58493. * 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;
  58494. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58495. */
  58496. set cameraColorCurves(value: Nullable<ColorCurves>);
  58497. /**
  58498. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58499. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58500. */
  58501. switchToBGR: boolean;
  58502. private _renderTargets;
  58503. private _reflectionControls;
  58504. private _white;
  58505. private _primaryShadowColor;
  58506. private _primaryHighlightColor;
  58507. /**
  58508. * Instantiates a Background Material in the given scene
  58509. * @param name The friendly name of the material
  58510. * @param scene The scene to add the material to
  58511. */
  58512. constructor(name: string, scene: Scene);
  58513. /**
  58514. * Gets a boolean indicating that current material needs to register RTT
  58515. */
  58516. get hasRenderTargetTextures(): boolean;
  58517. /**
  58518. * The entire material has been created in order to prevent overdraw.
  58519. * @returns false
  58520. */
  58521. needAlphaTesting(): boolean;
  58522. /**
  58523. * The entire material has been created in order to prevent overdraw.
  58524. * @returns true if blending is enable
  58525. */
  58526. needAlphaBlending(): boolean;
  58527. /**
  58528. * Checks wether the material is ready to be rendered for a given mesh.
  58529. * @param mesh The mesh to render
  58530. * @param subMesh The submesh to check against
  58531. * @param useInstances Specify wether or not the material is used with instances
  58532. * @returns true if all the dependencies are ready (Textures, Effects...)
  58533. */
  58534. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58535. /**
  58536. * Compute the primary color according to the chosen perceptual color.
  58537. */
  58538. private _computePrimaryColorFromPerceptualColor;
  58539. /**
  58540. * Compute the highlights and shadow colors according to their chosen levels.
  58541. */
  58542. private _computePrimaryColors;
  58543. /**
  58544. * Build the uniform buffer used in the material.
  58545. */
  58546. buildUniformLayout(): void;
  58547. /**
  58548. * Unbind the material.
  58549. */
  58550. unbind(): void;
  58551. /**
  58552. * Bind only the world matrix to the material.
  58553. * @param world The world matrix to bind.
  58554. */
  58555. bindOnlyWorldMatrix(world: Matrix): void;
  58556. /**
  58557. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58558. * @param world The world matrix to bind.
  58559. * @param subMesh The submesh to bind for.
  58560. */
  58561. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58562. /**
  58563. * Checks to see if a texture is used in the material.
  58564. * @param texture - Base texture to use.
  58565. * @returns - Boolean specifying if a texture is used in the material.
  58566. */
  58567. hasTexture(texture: BaseTexture): boolean;
  58568. /**
  58569. * Dispose the material.
  58570. * @param forceDisposeEffect Force disposal of the associated effect.
  58571. * @param forceDisposeTextures Force disposal of the associated textures.
  58572. */
  58573. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58574. /**
  58575. * Clones the material.
  58576. * @param name The cloned name.
  58577. * @returns The cloned material.
  58578. */
  58579. clone(name: string): BackgroundMaterial;
  58580. /**
  58581. * Serializes the current material to its JSON representation.
  58582. * @returns The JSON representation.
  58583. */
  58584. serialize(): any;
  58585. /**
  58586. * Gets the class name of the material
  58587. * @returns "BackgroundMaterial"
  58588. */
  58589. getClassName(): string;
  58590. /**
  58591. * Parse a JSON input to create back a background material.
  58592. * @param source The JSON data to parse
  58593. * @param scene The scene to create the parsed material in
  58594. * @param rootUrl The root url of the assets the material depends upon
  58595. * @returns the instantiated BackgroundMaterial.
  58596. */
  58597. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58598. }
  58599. }
  58600. declare module BABYLON {
  58601. /**
  58602. * Represents the different options available during the creation of
  58603. * a Environment helper.
  58604. *
  58605. * This can control the default ground, skybox and image processing setup of your scene.
  58606. */
  58607. export interface IEnvironmentHelperOptions {
  58608. /**
  58609. * Specifies whether or not to create a ground.
  58610. * True by default.
  58611. */
  58612. createGround: boolean;
  58613. /**
  58614. * Specifies the ground size.
  58615. * 15 by default.
  58616. */
  58617. groundSize: number;
  58618. /**
  58619. * The texture used on the ground for the main color.
  58620. * Comes from the BabylonJS CDN by default.
  58621. *
  58622. * Remarks: Can be either a texture or a url.
  58623. */
  58624. groundTexture: string | BaseTexture;
  58625. /**
  58626. * The color mixed in the ground texture by default.
  58627. * BabylonJS clearColor by default.
  58628. */
  58629. groundColor: Color3;
  58630. /**
  58631. * Specifies the ground opacity.
  58632. * 1 by default.
  58633. */
  58634. groundOpacity: number;
  58635. /**
  58636. * Enables the ground to receive shadows.
  58637. * True by default.
  58638. */
  58639. enableGroundShadow: boolean;
  58640. /**
  58641. * Helps preventing the shadow to be fully black on the ground.
  58642. * 0.5 by default.
  58643. */
  58644. groundShadowLevel: number;
  58645. /**
  58646. * Creates a mirror texture attach to the ground.
  58647. * false by default.
  58648. */
  58649. enableGroundMirror: boolean;
  58650. /**
  58651. * Specifies the ground mirror size ratio.
  58652. * 0.3 by default as the default kernel is 64.
  58653. */
  58654. groundMirrorSizeRatio: number;
  58655. /**
  58656. * Specifies the ground mirror blur kernel size.
  58657. * 64 by default.
  58658. */
  58659. groundMirrorBlurKernel: number;
  58660. /**
  58661. * Specifies the ground mirror visibility amount.
  58662. * 1 by default
  58663. */
  58664. groundMirrorAmount: number;
  58665. /**
  58666. * Specifies the ground mirror reflectance weight.
  58667. * This uses the standard weight of the background material to setup the fresnel effect
  58668. * of the mirror.
  58669. * 1 by default.
  58670. */
  58671. groundMirrorFresnelWeight: number;
  58672. /**
  58673. * Specifies the ground mirror Falloff distance.
  58674. * This can helps reducing the size of the reflection.
  58675. * 0 by Default.
  58676. */
  58677. groundMirrorFallOffDistance: number;
  58678. /**
  58679. * Specifies the ground mirror texture type.
  58680. * Unsigned Int by Default.
  58681. */
  58682. groundMirrorTextureType: number;
  58683. /**
  58684. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58685. * the shown objects.
  58686. */
  58687. groundYBias: number;
  58688. /**
  58689. * Specifies whether or not to create a skybox.
  58690. * True by default.
  58691. */
  58692. createSkybox: boolean;
  58693. /**
  58694. * Specifies the skybox size.
  58695. * 20 by default.
  58696. */
  58697. skyboxSize: number;
  58698. /**
  58699. * The texture used on the skybox for the main color.
  58700. * Comes from the BabylonJS CDN by default.
  58701. *
  58702. * Remarks: Can be either a texture or a url.
  58703. */
  58704. skyboxTexture: string | BaseTexture;
  58705. /**
  58706. * The color mixed in the skybox texture by default.
  58707. * BabylonJS clearColor by default.
  58708. */
  58709. skyboxColor: Color3;
  58710. /**
  58711. * The background rotation around the Y axis of the scene.
  58712. * This helps aligning the key lights of your scene with the background.
  58713. * 0 by default.
  58714. */
  58715. backgroundYRotation: number;
  58716. /**
  58717. * Compute automatically the size of the elements to best fit with the scene.
  58718. */
  58719. sizeAuto: boolean;
  58720. /**
  58721. * Default position of the rootMesh if autoSize is not true.
  58722. */
  58723. rootPosition: Vector3;
  58724. /**
  58725. * Sets up the image processing in the scene.
  58726. * true by default.
  58727. */
  58728. setupImageProcessing: boolean;
  58729. /**
  58730. * The texture used as your environment texture in the scene.
  58731. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58732. *
  58733. * Remarks: Can be either a texture or a url.
  58734. */
  58735. environmentTexture: string | BaseTexture;
  58736. /**
  58737. * The value of the exposure to apply to the scene.
  58738. * 0.6 by default if setupImageProcessing is true.
  58739. */
  58740. cameraExposure: number;
  58741. /**
  58742. * The value of the contrast to apply to the scene.
  58743. * 1.6 by default if setupImageProcessing is true.
  58744. */
  58745. cameraContrast: number;
  58746. /**
  58747. * Specifies whether or not tonemapping should be enabled in the scene.
  58748. * true by default if setupImageProcessing is true.
  58749. */
  58750. toneMappingEnabled: boolean;
  58751. }
  58752. /**
  58753. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58754. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58755. * It also helps with the default setup of your imageProcessing configuration.
  58756. */
  58757. export class EnvironmentHelper {
  58758. /**
  58759. * Default ground texture URL.
  58760. */
  58761. private static _groundTextureCDNUrl;
  58762. /**
  58763. * Default skybox texture URL.
  58764. */
  58765. private static _skyboxTextureCDNUrl;
  58766. /**
  58767. * Default environment texture URL.
  58768. */
  58769. private static _environmentTextureCDNUrl;
  58770. /**
  58771. * Creates the default options for the helper.
  58772. */
  58773. private static _getDefaultOptions;
  58774. private _rootMesh;
  58775. /**
  58776. * Gets the root mesh created by the helper.
  58777. */
  58778. get rootMesh(): Mesh;
  58779. private _skybox;
  58780. /**
  58781. * Gets the skybox created by the helper.
  58782. */
  58783. get skybox(): Nullable<Mesh>;
  58784. private _skyboxTexture;
  58785. /**
  58786. * Gets the skybox texture created by the helper.
  58787. */
  58788. get skyboxTexture(): Nullable<BaseTexture>;
  58789. private _skyboxMaterial;
  58790. /**
  58791. * Gets the skybox material created by the helper.
  58792. */
  58793. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58794. private _ground;
  58795. /**
  58796. * Gets the ground mesh created by the helper.
  58797. */
  58798. get ground(): Nullable<Mesh>;
  58799. private _groundTexture;
  58800. /**
  58801. * Gets the ground texture created by the helper.
  58802. */
  58803. get groundTexture(): Nullable<BaseTexture>;
  58804. private _groundMirror;
  58805. /**
  58806. * Gets the ground mirror created by the helper.
  58807. */
  58808. get groundMirror(): Nullable<MirrorTexture>;
  58809. /**
  58810. * Gets the ground mirror render list to helps pushing the meshes
  58811. * you wish in the ground reflection.
  58812. */
  58813. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58814. private _groundMaterial;
  58815. /**
  58816. * Gets the ground material created by the helper.
  58817. */
  58818. get groundMaterial(): Nullable<BackgroundMaterial>;
  58819. /**
  58820. * Stores the creation options.
  58821. */
  58822. private readonly _scene;
  58823. private _options;
  58824. /**
  58825. * This observable will be notified with any error during the creation of the environment,
  58826. * mainly texture creation errors.
  58827. */
  58828. onErrorObservable: Observable<{
  58829. message?: string;
  58830. exception?: any;
  58831. }>;
  58832. /**
  58833. * constructor
  58834. * @param options Defines the options we want to customize the helper
  58835. * @param scene The scene to add the material to
  58836. */
  58837. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58838. /**
  58839. * Updates the background according to the new options
  58840. * @param options
  58841. */
  58842. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58843. /**
  58844. * Sets the primary color of all the available elements.
  58845. * @param color the main color to affect to the ground and the background
  58846. */
  58847. setMainColor(color: Color3): void;
  58848. /**
  58849. * Setup the image processing according to the specified options.
  58850. */
  58851. private _setupImageProcessing;
  58852. /**
  58853. * Setup the environment texture according to the specified options.
  58854. */
  58855. private _setupEnvironmentTexture;
  58856. /**
  58857. * Setup the background according to the specified options.
  58858. */
  58859. private _setupBackground;
  58860. /**
  58861. * Get the scene sizes according to the setup.
  58862. */
  58863. private _getSceneSize;
  58864. /**
  58865. * Setup the ground according to the specified options.
  58866. */
  58867. private _setupGround;
  58868. /**
  58869. * Setup the ground material according to the specified options.
  58870. */
  58871. private _setupGroundMaterial;
  58872. /**
  58873. * Setup the ground diffuse texture according to the specified options.
  58874. */
  58875. private _setupGroundDiffuseTexture;
  58876. /**
  58877. * Setup the ground mirror texture according to the specified options.
  58878. */
  58879. private _setupGroundMirrorTexture;
  58880. /**
  58881. * Setup the ground to receive the mirror texture.
  58882. */
  58883. private _setupMirrorInGroundMaterial;
  58884. /**
  58885. * Setup the skybox according to the specified options.
  58886. */
  58887. private _setupSkybox;
  58888. /**
  58889. * Setup the skybox material according to the specified options.
  58890. */
  58891. private _setupSkyboxMaterial;
  58892. /**
  58893. * Setup the skybox reflection texture according to the specified options.
  58894. */
  58895. private _setupSkyboxReflectionTexture;
  58896. private _errorHandler;
  58897. /**
  58898. * Dispose all the elements created by the Helper.
  58899. */
  58900. dispose(): void;
  58901. }
  58902. }
  58903. declare module BABYLON {
  58904. /**
  58905. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58906. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58907. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58908. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58909. */
  58910. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58911. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58912. /**
  58913. * Define the source as a Monoscopic panoramic 360/180.
  58914. */
  58915. static readonly MODE_MONOSCOPIC: number;
  58916. /**
  58917. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58918. */
  58919. static readonly MODE_TOPBOTTOM: number;
  58920. /**
  58921. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58922. */
  58923. static readonly MODE_SIDEBYSIDE: number;
  58924. private _halfDome;
  58925. private _crossEye;
  58926. protected _useDirectMapping: boolean;
  58927. /**
  58928. * The texture being displayed on the sphere
  58929. */
  58930. protected _texture: T;
  58931. /**
  58932. * Gets the texture being displayed on the sphere
  58933. */
  58934. get texture(): T;
  58935. /**
  58936. * Sets the texture being displayed on the sphere
  58937. */
  58938. set texture(newTexture: T);
  58939. /**
  58940. * The skybox material
  58941. */
  58942. protected _material: BackgroundMaterial;
  58943. /**
  58944. * The surface used for the dome
  58945. */
  58946. protected _mesh: Mesh;
  58947. /**
  58948. * Gets the mesh used for the dome.
  58949. */
  58950. get mesh(): Mesh;
  58951. /**
  58952. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58953. */
  58954. private _halfDomeMask;
  58955. /**
  58956. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58957. * Also see the options.resolution property.
  58958. */
  58959. get fovMultiplier(): number;
  58960. set fovMultiplier(value: number);
  58961. protected _textureMode: number;
  58962. /**
  58963. * Gets or set the current texture mode for the texture. It can be:
  58964. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58965. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58966. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58967. */
  58968. get textureMode(): number;
  58969. /**
  58970. * Sets the current texture mode for the texture. It can be:
  58971. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58972. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58973. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58974. */
  58975. set textureMode(value: number);
  58976. /**
  58977. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58978. */
  58979. get halfDome(): boolean;
  58980. /**
  58981. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58982. */
  58983. set halfDome(enabled: boolean);
  58984. /**
  58985. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58986. */
  58987. set crossEye(enabled: boolean);
  58988. /**
  58989. * Is it a cross-eye texture?
  58990. */
  58991. get crossEye(): boolean;
  58992. /**
  58993. * The background material of this dome.
  58994. */
  58995. get material(): BackgroundMaterial;
  58996. /**
  58997. * Oberserver used in Stereoscopic VR Mode.
  58998. */
  58999. private _onBeforeCameraRenderObserver;
  59000. /**
  59001. * Observable raised when an error occured while loading the 360 image
  59002. */
  59003. onLoadErrorObservable: Observable<string>;
  59004. /**
  59005. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  59006. * @param name Element's name, child elements will append suffixes for their own names.
  59007. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  59008. * @param options An object containing optional or exposed sub element properties
  59009. */
  59010. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  59011. resolution?: number;
  59012. clickToPlay?: boolean;
  59013. autoPlay?: boolean;
  59014. loop?: boolean;
  59015. size?: number;
  59016. poster?: string;
  59017. faceForward?: boolean;
  59018. useDirectMapping?: boolean;
  59019. halfDomeMode?: boolean;
  59020. crossEyeMode?: boolean;
  59021. generateMipMaps?: boolean;
  59022. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  59023. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  59024. protected _changeTextureMode(value: number): void;
  59025. /**
  59026. * Releases resources associated with this node.
  59027. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59028. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59029. */
  59030. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59031. }
  59032. }
  59033. declare module BABYLON {
  59034. /**
  59035. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  59036. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  59037. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  59038. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59039. */
  59040. export class PhotoDome extends TextureDome<Texture> {
  59041. /**
  59042. * Define the image as a Monoscopic panoramic 360 image.
  59043. */
  59044. static readonly MODE_MONOSCOPIC: number;
  59045. /**
  59046. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  59047. */
  59048. static readonly MODE_TOPBOTTOM: number;
  59049. /**
  59050. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  59051. */
  59052. static readonly MODE_SIDEBYSIDE: number;
  59053. /**
  59054. * Gets or sets the texture being displayed on the sphere
  59055. */
  59056. get photoTexture(): Texture;
  59057. /**
  59058. * sets the texture being displayed on the sphere
  59059. */
  59060. set photoTexture(value: Texture);
  59061. /**
  59062. * Gets the current video mode for the video. It can be:
  59063. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59064. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59065. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59066. */
  59067. get imageMode(): number;
  59068. /**
  59069. * Sets the current video mode for the video. It can be:
  59070. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59071. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59072. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59073. */
  59074. set imageMode(value: number);
  59075. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  59076. }
  59077. }
  59078. declare module BABYLON {
  59079. /**
  59080. * Direct draw surface info
  59081. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59082. */
  59083. export interface DDSInfo {
  59084. /**
  59085. * Width of the texture
  59086. */
  59087. width: number;
  59088. /**
  59089. * Width of the texture
  59090. */
  59091. height: number;
  59092. /**
  59093. * Number of Mipmaps for the texture
  59094. * @see https://en.wikipedia.org/wiki/Mipmap
  59095. */
  59096. mipmapCount: number;
  59097. /**
  59098. * If the textures format is a known fourCC format
  59099. * @see https://www.fourcc.org/
  59100. */
  59101. isFourCC: boolean;
  59102. /**
  59103. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59104. */
  59105. isRGB: boolean;
  59106. /**
  59107. * If the texture is a lumincance format
  59108. */
  59109. isLuminance: boolean;
  59110. /**
  59111. * If this is a cube texture
  59112. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59113. */
  59114. isCube: boolean;
  59115. /**
  59116. * If the texture is a compressed format eg. FOURCC_DXT1
  59117. */
  59118. isCompressed: boolean;
  59119. /**
  59120. * The dxgiFormat of the texture
  59121. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59122. */
  59123. dxgiFormat: number;
  59124. /**
  59125. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59126. */
  59127. textureType: number;
  59128. /**
  59129. * Sphericle polynomial created for the dds texture
  59130. */
  59131. sphericalPolynomial?: SphericalPolynomial;
  59132. }
  59133. /**
  59134. * Class used to provide DDS decompression tools
  59135. */
  59136. export class DDSTools {
  59137. /**
  59138. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59139. */
  59140. static StoreLODInAlphaChannel: boolean;
  59141. /**
  59142. * Gets DDS information from an array buffer
  59143. * @param data defines the array buffer view to read data from
  59144. * @returns the DDS information
  59145. */
  59146. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59147. private static _FloatView;
  59148. private static _Int32View;
  59149. private static _ToHalfFloat;
  59150. private static _FromHalfFloat;
  59151. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59152. private static _GetHalfFloatRGBAArrayBuffer;
  59153. private static _GetFloatRGBAArrayBuffer;
  59154. private static _GetFloatAsUIntRGBAArrayBuffer;
  59155. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59156. private static _GetRGBAArrayBuffer;
  59157. private static _ExtractLongWordOrder;
  59158. private static _GetRGBArrayBuffer;
  59159. private static _GetLuminanceArrayBuffer;
  59160. /**
  59161. * Uploads DDS Levels to a Babylon Texture
  59162. * @hidden
  59163. */
  59164. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59165. }
  59166. interface ThinEngine {
  59167. /**
  59168. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59169. * @param rootUrl defines the url where the file to load is located
  59170. * @param scene defines the current scene
  59171. * @param lodScale defines scale to apply to the mip map selection
  59172. * @param lodOffset defines offset to apply to the mip map selection
  59173. * @param onLoad defines an optional callback raised when the texture is loaded
  59174. * @param onError defines an optional callback raised if there is an issue to load the texture
  59175. * @param format defines the format of the data
  59176. * @param forcedExtension defines the extension to use to pick the right loader
  59177. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59178. * @returns the cube texture as an InternalTexture
  59179. */
  59180. 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;
  59181. }
  59182. }
  59183. declare module BABYLON {
  59184. /**
  59185. * Implementation of the DDS Texture Loader.
  59186. * @hidden
  59187. */
  59188. export class _DDSTextureLoader implements IInternalTextureLoader {
  59189. /**
  59190. * Defines wether the loader supports cascade loading the different faces.
  59191. */
  59192. readonly supportCascades: boolean;
  59193. /**
  59194. * This returns if the loader support the current file information.
  59195. * @param extension defines the file extension of the file being loaded
  59196. * @returns true if the loader can load the specified file
  59197. */
  59198. canLoad(extension: string): boolean;
  59199. /**
  59200. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59201. * @param data contains the texture data
  59202. * @param texture defines the BabylonJS internal texture
  59203. * @param createPolynomials will be true if polynomials have been requested
  59204. * @param onLoad defines the callback to trigger once the texture is ready
  59205. * @param onError defines the callback to trigger in case of error
  59206. */
  59207. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59208. /**
  59209. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59210. * @param data contains the texture data
  59211. * @param texture defines the BabylonJS internal texture
  59212. * @param callback defines the method to call once ready to upload
  59213. */
  59214. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59215. }
  59216. }
  59217. declare module BABYLON {
  59218. /**
  59219. * Implementation of the ENV Texture Loader.
  59220. * @hidden
  59221. */
  59222. export class _ENVTextureLoader implements IInternalTextureLoader {
  59223. /**
  59224. * Defines wether the loader supports cascade loading the different faces.
  59225. */
  59226. readonly supportCascades: boolean;
  59227. /**
  59228. * This returns if the loader support the current file information.
  59229. * @param extension defines the file extension of the file being loaded
  59230. * @returns true if the loader can load the specified file
  59231. */
  59232. canLoad(extension: string): boolean;
  59233. /**
  59234. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59235. * @param data contains the texture data
  59236. * @param texture defines the BabylonJS internal texture
  59237. * @param createPolynomials will be true if polynomials have been requested
  59238. * @param onLoad defines the callback to trigger once the texture is ready
  59239. * @param onError defines the callback to trigger in case of error
  59240. */
  59241. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59242. /**
  59243. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59244. * @param data contains the texture data
  59245. * @param texture defines the BabylonJS internal texture
  59246. * @param callback defines the method to call once ready to upload
  59247. */
  59248. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59249. }
  59250. }
  59251. declare module BABYLON {
  59252. /**
  59253. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59254. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59255. */
  59256. export class KhronosTextureContainer {
  59257. /** contents of the KTX container file */
  59258. data: ArrayBufferView;
  59259. private static HEADER_LEN;
  59260. private static COMPRESSED_2D;
  59261. private static COMPRESSED_3D;
  59262. private static TEX_2D;
  59263. private static TEX_3D;
  59264. /**
  59265. * Gets the openGL type
  59266. */
  59267. glType: number;
  59268. /**
  59269. * Gets the openGL type size
  59270. */
  59271. glTypeSize: number;
  59272. /**
  59273. * Gets the openGL format
  59274. */
  59275. glFormat: number;
  59276. /**
  59277. * Gets the openGL internal format
  59278. */
  59279. glInternalFormat: number;
  59280. /**
  59281. * Gets the base internal format
  59282. */
  59283. glBaseInternalFormat: number;
  59284. /**
  59285. * Gets image width in pixel
  59286. */
  59287. pixelWidth: number;
  59288. /**
  59289. * Gets image height in pixel
  59290. */
  59291. pixelHeight: number;
  59292. /**
  59293. * Gets image depth in pixels
  59294. */
  59295. pixelDepth: number;
  59296. /**
  59297. * Gets the number of array elements
  59298. */
  59299. numberOfArrayElements: number;
  59300. /**
  59301. * Gets the number of faces
  59302. */
  59303. numberOfFaces: number;
  59304. /**
  59305. * Gets the number of mipmap levels
  59306. */
  59307. numberOfMipmapLevels: number;
  59308. /**
  59309. * Gets the bytes of key value data
  59310. */
  59311. bytesOfKeyValueData: number;
  59312. /**
  59313. * Gets the load type
  59314. */
  59315. loadType: number;
  59316. /**
  59317. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59318. */
  59319. isInvalid: boolean;
  59320. /**
  59321. * Creates a new KhronosTextureContainer
  59322. * @param data contents of the KTX container file
  59323. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59324. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59325. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59326. */
  59327. constructor(
  59328. /** contents of the KTX container file */
  59329. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59330. /**
  59331. * Uploads KTX content to a Babylon Texture.
  59332. * It is assumed that the texture has already been created & is currently bound
  59333. * @hidden
  59334. */
  59335. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59336. private _upload2DCompressedLevels;
  59337. /**
  59338. * Checks if the given data starts with a KTX file identifier.
  59339. * @param data the data to check
  59340. * @returns true if the data is a KTX file or false otherwise
  59341. */
  59342. static IsValid(data: ArrayBufferView): boolean;
  59343. }
  59344. }
  59345. declare module BABYLON {
  59346. /**
  59347. * Helper class to push actions to a pool of workers.
  59348. */
  59349. export class WorkerPool implements IDisposable {
  59350. private _workerInfos;
  59351. private _pendingActions;
  59352. /**
  59353. * Constructor
  59354. * @param workers Array of workers to use for actions
  59355. */
  59356. constructor(workers: Array<Worker>);
  59357. /**
  59358. * Terminates all workers and clears any pending actions.
  59359. */
  59360. dispose(): void;
  59361. /**
  59362. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59363. * pended until a worker has completed its action.
  59364. * @param action The action to perform. Call onComplete when the action is complete.
  59365. */
  59366. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59367. private _execute;
  59368. }
  59369. }
  59370. declare module BABYLON {
  59371. /**
  59372. * Class for loading KTX2 files
  59373. */
  59374. export class KhronosTextureContainer2 {
  59375. private static _WorkerPoolPromise?;
  59376. private static _Initialized;
  59377. private static _Ktx2Decoder;
  59378. /**
  59379. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  59380. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  59381. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  59382. * Urls you can change:
  59383. * URLConfig.jsDecoderModule
  59384. * URLConfig.wasmUASTCToASTC
  59385. * URLConfig.wasmUASTCToBC7
  59386. * URLConfig.wasmUASTCToRGBA_UNORM
  59387. * URLConfig.wasmUASTCToRGBA_SRGB
  59388. * URLConfig.jsMSCTranscoder
  59389. * URLConfig.wasmMSCTranscoder
  59390. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  59391. */
  59392. static URLConfig: {
  59393. jsDecoderModule: string;
  59394. wasmUASTCToASTC: null;
  59395. wasmUASTCToBC7: null;
  59396. wasmUASTCToRGBA_UNORM: null;
  59397. wasmUASTCToRGBA_SRGB: null;
  59398. jsMSCTranscoder: null;
  59399. wasmMSCTranscoder: null;
  59400. };
  59401. /**
  59402. * Default number of workers used to handle data decoding
  59403. */
  59404. static DefaultNumWorkers: number;
  59405. private static GetDefaultNumWorkers;
  59406. private _engine;
  59407. private static _CreateWorkerPool;
  59408. /**
  59409. * Constructor
  59410. * @param engine The engine to use
  59411. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59412. */
  59413. constructor(engine: ThinEngine, numWorkers?: number);
  59414. /** @hidden */
  59415. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  59416. /**
  59417. * Stop all async operations and release resources.
  59418. */
  59419. dispose(): void;
  59420. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  59421. /**
  59422. * Checks if the given data starts with a KTX2 file identifier.
  59423. * @param data the data to check
  59424. * @returns true if the data is a KTX2 file or false otherwise
  59425. */
  59426. static IsValid(data: ArrayBufferView): boolean;
  59427. }
  59428. }
  59429. declare module BABYLON {
  59430. /**
  59431. * Implementation of the KTX Texture Loader.
  59432. * @hidden
  59433. */
  59434. export class _KTXTextureLoader implements IInternalTextureLoader {
  59435. /**
  59436. * Defines wether the loader supports cascade loading the different faces.
  59437. */
  59438. readonly supportCascades: boolean;
  59439. /**
  59440. * This returns if the loader support the current file information.
  59441. * @param extension defines the file extension of the file being loaded
  59442. * @param mimeType defines the optional mime type of the file being loaded
  59443. * @returns true if the loader can load the specified file
  59444. */
  59445. canLoad(extension: string, mimeType?: string): boolean;
  59446. /**
  59447. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59448. * @param data contains the texture data
  59449. * @param texture defines the BabylonJS internal texture
  59450. * @param createPolynomials will be true if polynomials have been requested
  59451. * @param onLoad defines the callback to trigger once the texture is ready
  59452. * @param onError defines the callback to trigger in case of error
  59453. */
  59454. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59455. /**
  59456. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59457. * @param data contains the texture data
  59458. * @param texture defines the BabylonJS internal texture
  59459. * @param callback defines the method to call once ready to upload
  59460. */
  59461. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  59462. }
  59463. }
  59464. declare module BABYLON {
  59465. /** @hidden */
  59466. export var _forceSceneHelpersToBundle: boolean;
  59467. interface Scene {
  59468. /**
  59469. * Creates a default light for the scene.
  59470. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59471. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59472. */
  59473. createDefaultLight(replace?: boolean): void;
  59474. /**
  59475. * Creates a default camera for the scene.
  59476. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59477. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59478. * @param replace has default false, when true replaces the active camera in the scene
  59479. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59480. */
  59481. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59482. /**
  59483. * Creates a default camera and a default light.
  59484. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59485. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59486. * @param replace has the default false, when true replaces the active camera/light in the scene
  59487. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59488. */
  59489. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59490. /**
  59491. * Creates a new sky box
  59492. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59493. * @param environmentTexture defines the texture to use as environment texture
  59494. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59495. * @param scale defines the overall scale of the skybox
  59496. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59497. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59498. * @returns a new mesh holding the sky box
  59499. */
  59500. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59501. /**
  59502. * Creates a new environment
  59503. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59504. * @param options defines the options you can use to configure the environment
  59505. * @returns the new EnvironmentHelper
  59506. */
  59507. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59508. /**
  59509. * Creates a new VREXperienceHelper
  59510. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59511. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59512. * @returns a new VREXperienceHelper
  59513. */
  59514. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59515. /**
  59516. * Creates a new WebXRDefaultExperience
  59517. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59518. * @param options experience options
  59519. * @returns a promise for a new WebXRDefaultExperience
  59520. */
  59521. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59522. }
  59523. }
  59524. declare module BABYLON {
  59525. /**
  59526. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59527. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59528. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59529. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59530. */
  59531. export class VideoDome extends TextureDome<VideoTexture> {
  59532. /**
  59533. * Define the video source as a Monoscopic panoramic 360 video.
  59534. */
  59535. static readonly MODE_MONOSCOPIC: number;
  59536. /**
  59537. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59538. */
  59539. static readonly MODE_TOPBOTTOM: number;
  59540. /**
  59541. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59542. */
  59543. static readonly MODE_SIDEBYSIDE: number;
  59544. /**
  59545. * Get the video texture associated with this video dome
  59546. */
  59547. get videoTexture(): VideoTexture;
  59548. /**
  59549. * Get the video mode of this dome
  59550. */
  59551. get videoMode(): number;
  59552. /**
  59553. * Set the video mode of this dome.
  59554. * @see textureMode
  59555. */
  59556. set videoMode(value: number);
  59557. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59558. }
  59559. }
  59560. declare module BABYLON {
  59561. /**
  59562. * This class can be used to get instrumentation data from a Babylon engine
  59563. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59564. */
  59565. export class EngineInstrumentation implements IDisposable {
  59566. /**
  59567. * Define the instrumented engine.
  59568. */
  59569. engine: Engine;
  59570. private _captureGPUFrameTime;
  59571. private _gpuFrameTimeToken;
  59572. private _gpuFrameTime;
  59573. private _captureShaderCompilationTime;
  59574. private _shaderCompilationTime;
  59575. private _onBeginFrameObserver;
  59576. private _onEndFrameObserver;
  59577. private _onBeforeShaderCompilationObserver;
  59578. private _onAfterShaderCompilationObserver;
  59579. /**
  59580. * Gets the perf counter used for GPU frame time
  59581. */
  59582. get gpuFrameTimeCounter(): PerfCounter;
  59583. /**
  59584. * Gets the GPU frame time capture status
  59585. */
  59586. get captureGPUFrameTime(): boolean;
  59587. /**
  59588. * Enable or disable the GPU frame time capture
  59589. */
  59590. set captureGPUFrameTime(value: boolean);
  59591. /**
  59592. * Gets the perf counter used for shader compilation time
  59593. */
  59594. get shaderCompilationTimeCounter(): PerfCounter;
  59595. /**
  59596. * Gets the shader compilation time capture status
  59597. */
  59598. get captureShaderCompilationTime(): boolean;
  59599. /**
  59600. * Enable or disable the shader compilation time capture
  59601. */
  59602. set captureShaderCompilationTime(value: boolean);
  59603. /**
  59604. * Instantiates a new engine instrumentation.
  59605. * This class can be used to get instrumentation data from a Babylon engine
  59606. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59607. * @param engine Defines the engine to instrument
  59608. */
  59609. constructor(
  59610. /**
  59611. * Define the instrumented engine.
  59612. */
  59613. engine: Engine);
  59614. /**
  59615. * Dispose and release associated resources.
  59616. */
  59617. dispose(): void;
  59618. }
  59619. }
  59620. declare module BABYLON {
  59621. /**
  59622. * This class can be used to get instrumentation data from a Babylon engine
  59623. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59624. */
  59625. export class SceneInstrumentation implements IDisposable {
  59626. /**
  59627. * Defines the scene to instrument
  59628. */
  59629. scene: Scene;
  59630. private _captureActiveMeshesEvaluationTime;
  59631. private _activeMeshesEvaluationTime;
  59632. private _captureRenderTargetsRenderTime;
  59633. private _renderTargetsRenderTime;
  59634. private _captureFrameTime;
  59635. private _frameTime;
  59636. private _captureRenderTime;
  59637. private _renderTime;
  59638. private _captureInterFrameTime;
  59639. private _interFrameTime;
  59640. private _captureParticlesRenderTime;
  59641. private _particlesRenderTime;
  59642. private _captureSpritesRenderTime;
  59643. private _spritesRenderTime;
  59644. private _capturePhysicsTime;
  59645. private _physicsTime;
  59646. private _captureAnimationsTime;
  59647. private _animationsTime;
  59648. private _captureCameraRenderTime;
  59649. private _cameraRenderTime;
  59650. private _onBeforeActiveMeshesEvaluationObserver;
  59651. private _onAfterActiveMeshesEvaluationObserver;
  59652. private _onBeforeRenderTargetsRenderObserver;
  59653. private _onAfterRenderTargetsRenderObserver;
  59654. private _onAfterRenderObserver;
  59655. private _onBeforeDrawPhaseObserver;
  59656. private _onAfterDrawPhaseObserver;
  59657. private _onBeforeAnimationsObserver;
  59658. private _onBeforeParticlesRenderingObserver;
  59659. private _onAfterParticlesRenderingObserver;
  59660. private _onBeforeSpritesRenderingObserver;
  59661. private _onAfterSpritesRenderingObserver;
  59662. private _onBeforePhysicsObserver;
  59663. private _onAfterPhysicsObserver;
  59664. private _onAfterAnimationsObserver;
  59665. private _onBeforeCameraRenderObserver;
  59666. private _onAfterCameraRenderObserver;
  59667. /**
  59668. * Gets the perf counter used for active meshes evaluation time
  59669. */
  59670. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59671. /**
  59672. * Gets the active meshes evaluation time capture status
  59673. */
  59674. get captureActiveMeshesEvaluationTime(): boolean;
  59675. /**
  59676. * Enable or disable the active meshes evaluation time capture
  59677. */
  59678. set captureActiveMeshesEvaluationTime(value: boolean);
  59679. /**
  59680. * Gets the perf counter used for render targets render time
  59681. */
  59682. get renderTargetsRenderTimeCounter(): PerfCounter;
  59683. /**
  59684. * Gets the render targets render time capture status
  59685. */
  59686. get captureRenderTargetsRenderTime(): boolean;
  59687. /**
  59688. * Enable or disable the render targets render time capture
  59689. */
  59690. set captureRenderTargetsRenderTime(value: boolean);
  59691. /**
  59692. * Gets the perf counter used for particles render time
  59693. */
  59694. get particlesRenderTimeCounter(): PerfCounter;
  59695. /**
  59696. * Gets the particles render time capture status
  59697. */
  59698. get captureParticlesRenderTime(): boolean;
  59699. /**
  59700. * Enable or disable the particles render time capture
  59701. */
  59702. set captureParticlesRenderTime(value: boolean);
  59703. /**
  59704. * Gets the perf counter used for sprites render time
  59705. */
  59706. get spritesRenderTimeCounter(): PerfCounter;
  59707. /**
  59708. * Gets the sprites render time capture status
  59709. */
  59710. get captureSpritesRenderTime(): boolean;
  59711. /**
  59712. * Enable or disable the sprites render time capture
  59713. */
  59714. set captureSpritesRenderTime(value: boolean);
  59715. /**
  59716. * Gets the perf counter used for physics time
  59717. */
  59718. get physicsTimeCounter(): PerfCounter;
  59719. /**
  59720. * Gets the physics time capture status
  59721. */
  59722. get capturePhysicsTime(): boolean;
  59723. /**
  59724. * Enable or disable the physics time capture
  59725. */
  59726. set capturePhysicsTime(value: boolean);
  59727. /**
  59728. * Gets the perf counter used for animations time
  59729. */
  59730. get animationsTimeCounter(): PerfCounter;
  59731. /**
  59732. * Gets the animations time capture status
  59733. */
  59734. get captureAnimationsTime(): boolean;
  59735. /**
  59736. * Enable or disable the animations time capture
  59737. */
  59738. set captureAnimationsTime(value: boolean);
  59739. /**
  59740. * Gets the perf counter used for frame time capture
  59741. */
  59742. get frameTimeCounter(): PerfCounter;
  59743. /**
  59744. * Gets the frame time capture status
  59745. */
  59746. get captureFrameTime(): boolean;
  59747. /**
  59748. * Enable or disable the frame time capture
  59749. */
  59750. set captureFrameTime(value: boolean);
  59751. /**
  59752. * Gets the perf counter used for inter-frames time capture
  59753. */
  59754. get interFrameTimeCounter(): PerfCounter;
  59755. /**
  59756. * Gets the inter-frames time capture status
  59757. */
  59758. get captureInterFrameTime(): boolean;
  59759. /**
  59760. * Enable or disable the inter-frames time capture
  59761. */
  59762. set captureInterFrameTime(value: boolean);
  59763. /**
  59764. * Gets the perf counter used for render time capture
  59765. */
  59766. get renderTimeCounter(): PerfCounter;
  59767. /**
  59768. * Gets the render time capture status
  59769. */
  59770. get captureRenderTime(): boolean;
  59771. /**
  59772. * Enable or disable the render time capture
  59773. */
  59774. set captureRenderTime(value: boolean);
  59775. /**
  59776. * Gets the perf counter used for camera render time capture
  59777. */
  59778. get cameraRenderTimeCounter(): PerfCounter;
  59779. /**
  59780. * Gets the camera render time capture status
  59781. */
  59782. get captureCameraRenderTime(): boolean;
  59783. /**
  59784. * Enable or disable the camera render time capture
  59785. */
  59786. set captureCameraRenderTime(value: boolean);
  59787. /**
  59788. * Gets the perf counter used for draw calls
  59789. */
  59790. get drawCallsCounter(): PerfCounter;
  59791. /**
  59792. * Instantiates a new scene instrumentation.
  59793. * This class can be used to get instrumentation data from a Babylon engine
  59794. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59795. * @param scene Defines the scene to instrument
  59796. */
  59797. constructor(
  59798. /**
  59799. * Defines the scene to instrument
  59800. */
  59801. scene: Scene);
  59802. /**
  59803. * Dispose and release associated resources.
  59804. */
  59805. dispose(): void;
  59806. }
  59807. }
  59808. declare module BABYLON {
  59809. /** @hidden */
  59810. export var glowMapGenerationPixelShader: {
  59811. name: string;
  59812. shader: string;
  59813. };
  59814. }
  59815. declare module BABYLON {
  59816. /** @hidden */
  59817. export var glowMapGenerationVertexShader: {
  59818. name: string;
  59819. shader: string;
  59820. };
  59821. }
  59822. declare module BABYLON {
  59823. /**
  59824. * Effect layer options. This helps customizing the behaviour
  59825. * of the effect layer.
  59826. */
  59827. export interface IEffectLayerOptions {
  59828. /**
  59829. * Multiplication factor apply to the canvas size to compute the render target size
  59830. * used to generated the objects (the smaller the faster).
  59831. */
  59832. mainTextureRatio: number;
  59833. /**
  59834. * Enforces a fixed size texture to ensure effect stability across devices.
  59835. */
  59836. mainTextureFixedSize?: number;
  59837. /**
  59838. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59839. */
  59840. alphaBlendingMode: number;
  59841. /**
  59842. * The camera attached to the layer.
  59843. */
  59844. camera: Nullable<Camera>;
  59845. /**
  59846. * The rendering group to draw the layer in.
  59847. */
  59848. renderingGroupId: number;
  59849. }
  59850. /**
  59851. * The effect layer Helps adding post process effect blended with the main pass.
  59852. *
  59853. * This can be for instance use to generate glow or higlight effects on the scene.
  59854. *
  59855. * The effect layer class can not be used directly and is intented to inherited from to be
  59856. * customized per effects.
  59857. */
  59858. export abstract class EffectLayer {
  59859. private _vertexBuffers;
  59860. private _indexBuffer;
  59861. private _cachedDefines;
  59862. private _effectLayerMapGenerationEffect;
  59863. private _effectLayerOptions;
  59864. private _mergeEffect;
  59865. protected _scene: Scene;
  59866. protected _engine: Engine;
  59867. protected _maxSize: number;
  59868. protected _mainTextureDesiredSize: ISize;
  59869. protected _mainTexture: RenderTargetTexture;
  59870. protected _shouldRender: boolean;
  59871. protected _postProcesses: PostProcess[];
  59872. protected _textures: BaseTexture[];
  59873. protected _emissiveTextureAndColor: {
  59874. texture: Nullable<BaseTexture>;
  59875. color: Color4;
  59876. };
  59877. /**
  59878. * The name of the layer
  59879. */
  59880. name: string;
  59881. /**
  59882. * The clear color of the texture used to generate the glow map.
  59883. */
  59884. neutralColor: Color4;
  59885. /**
  59886. * Specifies whether the highlight layer is enabled or not.
  59887. */
  59888. isEnabled: boolean;
  59889. /**
  59890. * Gets the camera attached to the layer.
  59891. */
  59892. get camera(): Nullable<Camera>;
  59893. /**
  59894. * Gets the rendering group id the layer should render in.
  59895. */
  59896. get renderingGroupId(): number;
  59897. set renderingGroupId(renderingGroupId: number);
  59898. /**
  59899. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59900. */
  59901. disableBoundingBoxesFromEffectLayer: boolean;
  59902. /**
  59903. * An event triggered when the effect layer has been disposed.
  59904. */
  59905. onDisposeObservable: Observable<EffectLayer>;
  59906. /**
  59907. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59908. */
  59909. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59910. /**
  59911. * An event triggered when the generated texture is being merged in the scene.
  59912. */
  59913. onBeforeComposeObservable: Observable<EffectLayer>;
  59914. /**
  59915. * An event triggered when the mesh is rendered into the effect render target.
  59916. */
  59917. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59918. /**
  59919. * An event triggered after the mesh has been rendered into the effect render target.
  59920. */
  59921. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59922. /**
  59923. * An event triggered when the generated texture has been merged in the scene.
  59924. */
  59925. onAfterComposeObservable: Observable<EffectLayer>;
  59926. /**
  59927. * An event triggered when the efffect layer changes its size.
  59928. */
  59929. onSizeChangedObservable: Observable<EffectLayer>;
  59930. /** @hidden */
  59931. static _SceneComponentInitialization: (scene: Scene) => void;
  59932. /**
  59933. * Instantiates a new effect Layer and references it in the scene.
  59934. * @param name The name of the layer
  59935. * @param scene The scene to use the layer in
  59936. */
  59937. constructor(
  59938. /** The Friendly of the effect in the scene */
  59939. name: string, scene: Scene);
  59940. /**
  59941. * Get the effect name of the layer.
  59942. * @return The effect name
  59943. */
  59944. abstract getEffectName(): string;
  59945. /**
  59946. * Checks for the readiness of the element composing the layer.
  59947. * @param subMesh the mesh to check for
  59948. * @param useInstances specify whether or not to use instances to render the mesh
  59949. * @return true if ready otherwise, false
  59950. */
  59951. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59952. /**
  59953. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59954. * @returns true if the effect requires stencil during the main canvas render pass.
  59955. */
  59956. abstract needStencil(): boolean;
  59957. /**
  59958. * Create the merge effect. This is the shader use to blit the information back
  59959. * to the main canvas at the end of the scene rendering.
  59960. * @returns The effect containing the shader used to merge the effect on the main canvas
  59961. */
  59962. protected abstract _createMergeEffect(): Effect;
  59963. /**
  59964. * Creates the render target textures and post processes used in the effect layer.
  59965. */
  59966. protected abstract _createTextureAndPostProcesses(): void;
  59967. /**
  59968. * Implementation specific of rendering the generating effect on the main canvas.
  59969. * @param effect The effect used to render through
  59970. */
  59971. protected abstract _internalRender(effect: Effect): void;
  59972. /**
  59973. * Sets the required values for both the emissive texture and and the main color.
  59974. */
  59975. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59976. /**
  59977. * Free any resources and references associated to a mesh.
  59978. * Internal use
  59979. * @param mesh The mesh to free.
  59980. */
  59981. abstract _disposeMesh(mesh: Mesh): void;
  59982. /**
  59983. * Serializes this layer (Glow or Highlight for example)
  59984. * @returns a serialized layer object
  59985. */
  59986. abstract serialize?(): any;
  59987. /**
  59988. * Initializes the effect layer with the required options.
  59989. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59990. */
  59991. protected _init(options: Partial<IEffectLayerOptions>): void;
  59992. /**
  59993. * Generates the index buffer of the full screen quad blending to the main canvas.
  59994. */
  59995. private _generateIndexBuffer;
  59996. /**
  59997. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59998. */
  59999. private _generateVertexBuffer;
  60000. /**
  60001. * Sets the main texture desired size which is the closest power of two
  60002. * of the engine canvas size.
  60003. */
  60004. private _setMainTextureSize;
  60005. /**
  60006. * Creates the main texture for the effect layer.
  60007. */
  60008. protected _createMainTexture(): void;
  60009. /**
  60010. * Adds specific effects defines.
  60011. * @param defines The defines to add specifics to.
  60012. */
  60013. protected _addCustomEffectDefines(defines: string[]): void;
  60014. /**
  60015. * Checks for the readiness of the element composing the layer.
  60016. * @param subMesh the mesh to check for
  60017. * @param useInstances specify whether or not to use instances to render the mesh
  60018. * @param emissiveTexture the associated emissive texture used to generate the glow
  60019. * @return true if ready otherwise, false
  60020. */
  60021. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60022. /**
  60023. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60024. */
  60025. render(): void;
  60026. /**
  60027. * Determine if a given mesh will be used in the current effect.
  60028. * @param mesh mesh to test
  60029. * @returns true if the mesh will be used
  60030. */
  60031. hasMesh(mesh: AbstractMesh): boolean;
  60032. /**
  60033. * Returns true if the layer contains information to display, otherwise false.
  60034. * @returns true if the glow layer should be rendered
  60035. */
  60036. shouldRender(): boolean;
  60037. /**
  60038. * Returns true if the mesh should render, otherwise false.
  60039. * @param mesh The mesh to render
  60040. * @returns true if it should render otherwise false
  60041. */
  60042. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60043. /**
  60044. * Returns true if the mesh can be rendered, otherwise false.
  60045. * @param mesh The mesh to render
  60046. * @param material The material used on the mesh
  60047. * @returns true if it can be rendered otherwise false
  60048. */
  60049. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60050. /**
  60051. * Returns true if the mesh should render, otherwise false.
  60052. * @param mesh The mesh to render
  60053. * @returns true if it should render otherwise false
  60054. */
  60055. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60056. /**
  60057. * Renders the submesh passed in parameter to the generation map.
  60058. */
  60059. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60060. /**
  60061. * Defines whether the current material of the mesh should be use to render the effect.
  60062. * @param mesh defines the current mesh to render
  60063. */
  60064. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60065. /**
  60066. * Rebuild the required buffers.
  60067. * @hidden Internal use only.
  60068. */
  60069. _rebuild(): void;
  60070. /**
  60071. * Dispose only the render target textures and post process.
  60072. */
  60073. private _disposeTextureAndPostProcesses;
  60074. /**
  60075. * Dispose the highlight layer and free resources.
  60076. */
  60077. dispose(): void;
  60078. /**
  60079. * Gets the class name of the effect layer
  60080. * @returns the string with the class name of the effect layer
  60081. */
  60082. getClassName(): string;
  60083. /**
  60084. * Creates an effect layer from parsed effect layer data
  60085. * @param parsedEffectLayer defines effect layer data
  60086. * @param scene defines the current scene
  60087. * @param rootUrl defines the root URL containing the effect layer information
  60088. * @returns a parsed effect Layer
  60089. */
  60090. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60091. }
  60092. }
  60093. declare module BABYLON {
  60094. interface AbstractScene {
  60095. /**
  60096. * The list of effect layers (highlights/glow) added to the scene
  60097. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60098. * @see https://doc.babylonjs.com/how_to/glow_layer
  60099. */
  60100. effectLayers: Array<EffectLayer>;
  60101. /**
  60102. * Removes the given effect layer from this scene.
  60103. * @param toRemove defines the effect layer to remove
  60104. * @returns the index of the removed effect layer
  60105. */
  60106. removeEffectLayer(toRemove: EffectLayer): number;
  60107. /**
  60108. * Adds the given effect layer to this scene
  60109. * @param newEffectLayer defines the effect layer to add
  60110. */
  60111. addEffectLayer(newEffectLayer: EffectLayer): void;
  60112. }
  60113. /**
  60114. * Defines the layer scene component responsible to manage any effect layers
  60115. * in a given scene.
  60116. */
  60117. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60118. /**
  60119. * The component name helpfull to identify the component in the list of scene components.
  60120. */
  60121. readonly name: string;
  60122. /**
  60123. * The scene the component belongs to.
  60124. */
  60125. scene: Scene;
  60126. private _engine;
  60127. private _renderEffects;
  60128. private _needStencil;
  60129. private _previousStencilState;
  60130. /**
  60131. * Creates a new instance of the component for the given scene
  60132. * @param scene Defines the scene to register the component in
  60133. */
  60134. constructor(scene: Scene);
  60135. /**
  60136. * Registers the component in a given scene
  60137. */
  60138. register(): void;
  60139. /**
  60140. * Rebuilds the elements related to this component in case of
  60141. * context lost for instance.
  60142. */
  60143. rebuild(): void;
  60144. /**
  60145. * Serializes the component data to the specified json object
  60146. * @param serializationObject The object to serialize to
  60147. */
  60148. serialize(serializationObject: any): void;
  60149. /**
  60150. * Adds all the elements from the container to the scene
  60151. * @param container the container holding the elements
  60152. */
  60153. addFromContainer(container: AbstractScene): void;
  60154. /**
  60155. * Removes all the elements in the container from the scene
  60156. * @param container contains the elements to remove
  60157. * @param dispose if the removed element should be disposed (default: false)
  60158. */
  60159. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60160. /**
  60161. * Disposes the component and the associated ressources.
  60162. */
  60163. dispose(): void;
  60164. private _isReadyForMesh;
  60165. private _renderMainTexture;
  60166. private _setStencil;
  60167. private _setStencilBack;
  60168. private _draw;
  60169. private _drawCamera;
  60170. private _drawRenderingGroup;
  60171. }
  60172. }
  60173. declare module BABYLON {
  60174. /** @hidden */
  60175. export var glowMapMergePixelShader: {
  60176. name: string;
  60177. shader: string;
  60178. };
  60179. }
  60180. declare module BABYLON {
  60181. /** @hidden */
  60182. export var glowMapMergeVertexShader: {
  60183. name: string;
  60184. shader: string;
  60185. };
  60186. }
  60187. declare module BABYLON {
  60188. interface AbstractScene {
  60189. /**
  60190. * Return a the first highlight layer of the scene with a given name.
  60191. * @param name The name of the highlight layer to look for.
  60192. * @return The highlight layer if found otherwise null.
  60193. */
  60194. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60195. }
  60196. /**
  60197. * Glow layer options. This helps customizing the behaviour
  60198. * of the glow layer.
  60199. */
  60200. export interface IGlowLayerOptions {
  60201. /**
  60202. * Multiplication factor apply to the canvas size to compute the render target size
  60203. * used to generated the glowing objects (the smaller the faster).
  60204. */
  60205. mainTextureRatio: number;
  60206. /**
  60207. * Enforces a fixed size texture to ensure resize independant blur.
  60208. */
  60209. mainTextureFixedSize?: number;
  60210. /**
  60211. * How big is the kernel of the blur texture.
  60212. */
  60213. blurKernelSize: number;
  60214. /**
  60215. * The camera attached to the layer.
  60216. */
  60217. camera: Nullable<Camera>;
  60218. /**
  60219. * Enable MSAA by chosing the number of samples.
  60220. */
  60221. mainTextureSamples?: number;
  60222. /**
  60223. * The rendering group to draw the layer in.
  60224. */
  60225. renderingGroupId: number;
  60226. }
  60227. /**
  60228. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60229. *
  60230. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60231. *
  60232. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60233. */
  60234. export class GlowLayer extends EffectLayer {
  60235. /**
  60236. * Effect Name of the layer.
  60237. */
  60238. static readonly EffectName: string;
  60239. /**
  60240. * The default blur kernel size used for the glow.
  60241. */
  60242. static DefaultBlurKernelSize: number;
  60243. /**
  60244. * The default texture size ratio used for the glow.
  60245. */
  60246. static DefaultTextureRatio: number;
  60247. /**
  60248. * Sets the kernel size of the blur.
  60249. */
  60250. set blurKernelSize(value: number);
  60251. /**
  60252. * Gets the kernel size of the blur.
  60253. */
  60254. get blurKernelSize(): number;
  60255. /**
  60256. * Sets the glow intensity.
  60257. */
  60258. set intensity(value: number);
  60259. /**
  60260. * Gets the glow intensity.
  60261. */
  60262. get intensity(): number;
  60263. private _options;
  60264. private _intensity;
  60265. private _horizontalBlurPostprocess1;
  60266. private _verticalBlurPostprocess1;
  60267. private _horizontalBlurPostprocess2;
  60268. private _verticalBlurPostprocess2;
  60269. private _blurTexture1;
  60270. private _blurTexture2;
  60271. private _postProcesses1;
  60272. private _postProcesses2;
  60273. private _includedOnlyMeshes;
  60274. private _excludedMeshes;
  60275. private _meshesUsingTheirOwnMaterials;
  60276. /**
  60277. * Callback used to let the user override the color selection on a per mesh basis
  60278. */
  60279. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60280. /**
  60281. * Callback used to let the user override the texture selection on a per mesh basis
  60282. */
  60283. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60284. /**
  60285. * Instantiates a new glow Layer and references it to the scene.
  60286. * @param name The name of the layer
  60287. * @param scene The scene to use the layer in
  60288. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60289. */
  60290. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60291. /**
  60292. * Get the effect name of the layer.
  60293. * @return The effect name
  60294. */
  60295. getEffectName(): string;
  60296. /**
  60297. * Create the merge effect. This is the shader use to blit the information back
  60298. * to the main canvas at the end of the scene rendering.
  60299. */
  60300. protected _createMergeEffect(): Effect;
  60301. /**
  60302. * Creates the render target textures and post processes used in the glow layer.
  60303. */
  60304. protected _createTextureAndPostProcesses(): void;
  60305. /**
  60306. * Checks for the readiness of the element composing the layer.
  60307. * @param subMesh the mesh to check for
  60308. * @param useInstances specify wether or not to use instances to render the mesh
  60309. * @param emissiveTexture the associated emissive texture used to generate the glow
  60310. * @return true if ready otherwise, false
  60311. */
  60312. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60313. /**
  60314. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60315. */
  60316. needStencil(): boolean;
  60317. /**
  60318. * Returns true if the mesh can be rendered, otherwise false.
  60319. * @param mesh The mesh to render
  60320. * @param material The material used on the mesh
  60321. * @returns true if it can be rendered otherwise false
  60322. */
  60323. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60324. /**
  60325. * Implementation specific of rendering the generating effect on the main canvas.
  60326. * @param effect The effect used to render through
  60327. */
  60328. protected _internalRender(effect: Effect): void;
  60329. /**
  60330. * Sets the required values for both the emissive texture and and the main color.
  60331. */
  60332. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60333. /**
  60334. * Returns true if the mesh should render, otherwise false.
  60335. * @param mesh The mesh to render
  60336. * @returns true if it should render otherwise false
  60337. */
  60338. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60339. /**
  60340. * Adds specific effects defines.
  60341. * @param defines The defines to add specifics to.
  60342. */
  60343. protected _addCustomEffectDefines(defines: string[]): void;
  60344. /**
  60345. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60346. * @param mesh The mesh to exclude from the glow layer
  60347. */
  60348. addExcludedMesh(mesh: Mesh): void;
  60349. /**
  60350. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60351. * @param mesh The mesh to remove
  60352. */
  60353. removeExcludedMesh(mesh: Mesh): void;
  60354. /**
  60355. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60356. * @param mesh The mesh to include in the glow layer
  60357. */
  60358. addIncludedOnlyMesh(mesh: Mesh): void;
  60359. /**
  60360. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60361. * @param mesh The mesh to remove
  60362. */
  60363. removeIncludedOnlyMesh(mesh: Mesh): void;
  60364. /**
  60365. * Determine if a given mesh will be used in the glow layer
  60366. * @param mesh The mesh to test
  60367. * @returns true if the mesh will be highlighted by the current glow layer
  60368. */
  60369. hasMesh(mesh: AbstractMesh): boolean;
  60370. /**
  60371. * Defines whether the current material of the mesh should be use to render the effect.
  60372. * @param mesh defines the current mesh to render
  60373. */
  60374. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60375. /**
  60376. * Add a mesh to be rendered through its own material and not with emissive only.
  60377. * @param mesh The mesh for which we need to use its material
  60378. */
  60379. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60380. /**
  60381. * Remove a mesh from being rendered through its own material and not with emissive only.
  60382. * @param mesh The mesh for which we need to not use its material
  60383. */
  60384. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60385. /**
  60386. * Free any resources and references associated to a mesh.
  60387. * Internal use
  60388. * @param mesh The mesh to free.
  60389. * @hidden
  60390. */
  60391. _disposeMesh(mesh: Mesh): void;
  60392. /**
  60393. * Gets the class name of the effect layer
  60394. * @returns the string with the class name of the effect layer
  60395. */
  60396. getClassName(): string;
  60397. /**
  60398. * Serializes this glow layer
  60399. * @returns a serialized glow layer object
  60400. */
  60401. serialize(): any;
  60402. /**
  60403. * Creates a Glow Layer from parsed glow layer data
  60404. * @param parsedGlowLayer defines glow layer data
  60405. * @param scene defines the current scene
  60406. * @param rootUrl defines the root URL containing the glow layer information
  60407. * @returns a parsed Glow Layer
  60408. */
  60409. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60410. }
  60411. }
  60412. declare module BABYLON {
  60413. /** @hidden */
  60414. export var glowBlurPostProcessPixelShader: {
  60415. name: string;
  60416. shader: string;
  60417. };
  60418. }
  60419. declare module BABYLON {
  60420. interface AbstractScene {
  60421. /**
  60422. * Return a the first highlight layer of the scene with a given name.
  60423. * @param name The name of the highlight layer to look for.
  60424. * @return The highlight layer if found otherwise null.
  60425. */
  60426. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60427. }
  60428. /**
  60429. * Highlight layer options. This helps customizing the behaviour
  60430. * of the highlight layer.
  60431. */
  60432. export interface IHighlightLayerOptions {
  60433. /**
  60434. * Multiplication factor apply to the canvas size to compute the render target size
  60435. * used to generated the glowing objects (the smaller the faster).
  60436. */
  60437. mainTextureRatio: number;
  60438. /**
  60439. * Enforces a fixed size texture to ensure resize independant blur.
  60440. */
  60441. mainTextureFixedSize?: number;
  60442. /**
  60443. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60444. * of the picture to blur (the smaller the faster).
  60445. */
  60446. blurTextureSizeRatio: number;
  60447. /**
  60448. * How big in texel of the blur texture is the vertical blur.
  60449. */
  60450. blurVerticalSize: number;
  60451. /**
  60452. * How big in texel of the blur texture is the horizontal blur.
  60453. */
  60454. blurHorizontalSize: number;
  60455. /**
  60456. * Alpha blending mode used to apply the blur. Default is combine.
  60457. */
  60458. alphaBlendingMode: number;
  60459. /**
  60460. * The camera attached to the layer.
  60461. */
  60462. camera: Nullable<Camera>;
  60463. /**
  60464. * Should we display highlight as a solid stroke?
  60465. */
  60466. isStroke?: boolean;
  60467. /**
  60468. * The rendering group to draw the layer in.
  60469. */
  60470. renderingGroupId: number;
  60471. }
  60472. /**
  60473. * The highlight layer Helps adding a glow effect around a mesh.
  60474. *
  60475. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60476. * glowy meshes to your scene.
  60477. *
  60478. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60479. */
  60480. export class HighlightLayer extends EffectLayer {
  60481. name: string;
  60482. /**
  60483. * Effect Name of the highlight layer.
  60484. */
  60485. static readonly EffectName: string;
  60486. /**
  60487. * The neutral color used during the preparation of the glow effect.
  60488. * This is black by default as the blend operation is a blend operation.
  60489. */
  60490. static NeutralColor: Color4;
  60491. /**
  60492. * Stencil value used for glowing meshes.
  60493. */
  60494. static GlowingMeshStencilReference: number;
  60495. /**
  60496. * Stencil value used for the other meshes in the scene.
  60497. */
  60498. static NormalMeshStencilReference: number;
  60499. /**
  60500. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60501. */
  60502. innerGlow: boolean;
  60503. /**
  60504. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60505. */
  60506. outerGlow: boolean;
  60507. /**
  60508. * Specifies the horizontal size of the blur.
  60509. */
  60510. set blurHorizontalSize(value: number);
  60511. /**
  60512. * Specifies the vertical size of the blur.
  60513. */
  60514. set blurVerticalSize(value: number);
  60515. /**
  60516. * Gets the horizontal size of the blur.
  60517. */
  60518. get blurHorizontalSize(): number;
  60519. /**
  60520. * Gets the vertical size of the blur.
  60521. */
  60522. get blurVerticalSize(): number;
  60523. /**
  60524. * An event triggered when the highlight layer is being blurred.
  60525. */
  60526. onBeforeBlurObservable: Observable<HighlightLayer>;
  60527. /**
  60528. * An event triggered when the highlight layer has been blurred.
  60529. */
  60530. onAfterBlurObservable: Observable<HighlightLayer>;
  60531. private _instanceGlowingMeshStencilReference;
  60532. private _options;
  60533. private _downSamplePostprocess;
  60534. private _horizontalBlurPostprocess;
  60535. private _verticalBlurPostprocess;
  60536. private _blurTexture;
  60537. private _meshes;
  60538. private _excludedMeshes;
  60539. /**
  60540. * Instantiates a new highlight Layer and references it to the scene..
  60541. * @param name The name of the layer
  60542. * @param scene The scene to use the layer in
  60543. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60544. */
  60545. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60546. /**
  60547. * Get the effect name of the layer.
  60548. * @return The effect name
  60549. */
  60550. getEffectName(): string;
  60551. /**
  60552. * Create the merge effect. This is the shader use to blit the information back
  60553. * to the main canvas at the end of the scene rendering.
  60554. */
  60555. protected _createMergeEffect(): Effect;
  60556. /**
  60557. * Creates the render target textures and post processes used in the highlight layer.
  60558. */
  60559. protected _createTextureAndPostProcesses(): void;
  60560. /**
  60561. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60562. */
  60563. needStencil(): boolean;
  60564. /**
  60565. * Checks for the readiness of the element composing the layer.
  60566. * @param subMesh the mesh to check for
  60567. * @param useInstances specify wether or not to use instances to render the mesh
  60568. * @param emissiveTexture the associated emissive texture used to generate the glow
  60569. * @return true if ready otherwise, false
  60570. */
  60571. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60572. /**
  60573. * Implementation specific of rendering the generating effect on the main canvas.
  60574. * @param effect The effect used to render through
  60575. */
  60576. protected _internalRender(effect: Effect): void;
  60577. /**
  60578. * Returns true if the layer contains information to display, otherwise false.
  60579. */
  60580. shouldRender(): boolean;
  60581. /**
  60582. * Returns true if the mesh should render, otherwise false.
  60583. * @param mesh The mesh to render
  60584. * @returns true if it should render otherwise false
  60585. */
  60586. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60587. /**
  60588. * Returns true if the mesh can be rendered, otherwise false.
  60589. * @param mesh The mesh to render
  60590. * @param material The material used on the mesh
  60591. * @returns true if it can be rendered otherwise false
  60592. */
  60593. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60594. /**
  60595. * Adds specific effects defines.
  60596. * @param defines The defines to add specifics to.
  60597. */
  60598. protected _addCustomEffectDefines(defines: string[]): void;
  60599. /**
  60600. * Sets the required values for both the emissive texture and and the main color.
  60601. */
  60602. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60603. /**
  60604. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60605. * @param mesh The mesh to exclude from the highlight layer
  60606. */
  60607. addExcludedMesh(mesh: Mesh): void;
  60608. /**
  60609. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60610. * @param mesh The mesh to highlight
  60611. */
  60612. removeExcludedMesh(mesh: Mesh): void;
  60613. /**
  60614. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60615. * @param mesh mesh to test
  60616. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60617. */
  60618. hasMesh(mesh: AbstractMesh): boolean;
  60619. /**
  60620. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60621. * @param mesh The mesh to highlight
  60622. * @param color The color of the highlight
  60623. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60624. */
  60625. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60626. /**
  60627. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60628. * @param mesh The mesh to highlight
  60629. */
  60630. removeMesh(mesh: Mesh): void;
  60631. /**
  60632. * Remove all the meshes currently referenced in the highlight layer
  60633. */
  60634. removeAllMeshes(): void;
  60635. /**
  60636. * Force the stencil to the normal expected value for none glowing parts
  60637. */
  60638. private _defaultStencilReference;
  60639. /**
  60640. * Free any resources and references associated to a mesh.
  60641. * Internal use
  60642. * @param mesh The mesh to free.
  60643. * @hidden
  60644. */
  60645. _disposeMesh(mesh: Mesh): void;
  60646. /**
  60647. * Dispose the highlight layer and free resources.
  60648. */
  60649. dispose(): void;
  60650. /**
  60651. * Gets the class name of the effect layer
  60652. * @returns the string with the class name of the effect layer
  60653. */
  60654. getClassName(): string;
  60655. /**
  60656. * Serializes this Highlight layer
  60657. * @returns a serialized Highlight layer object
  60658. */
  60659. serialize(): any;
  60660. /**
  60661. * Creates a Highlight layer from parsed Highlight layer data
  60662. * @param parsedHightlightLayer defines the Highlight layer data
  60663. * @param scene defines the current scene
  60664. * @param rootUrl defines the root URL containing the Highlight layer information
  60665. * @returns a parsed Highlight layer
  60666. */
  60667. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60668. }
  60669. }
  60670. declare module BABYLON {
  60671. interface AbstractScene {
  60672. /**
  60673. * The list of layers (background and foreground) of the scene
  60674. */
  60675. layers: Array<Layer>;
  60676. }
  60677. /**
  60678. * Defines the layer scene component responsible to manage any layers
  60679. * in a given scene.
  60680. */
  60681. export class LayerSceneComponent implements ISceneComponent {
  60682. /**
  60683. * The component name helpfull to identify the component in the list of scene components.
  60684. */
  60685. readonly name: string;
  60686. /**
  60687. * The scene the component belongs to.
  60688. */
  60689. scene: Scene;
  60690. private _engine;
  60691. /**
  60692. * Creates a new instance of the component for the given scene
  60693. * @param scene Defines the scene to register the component in
  60694. */
  60695. constructor(scene: Scene);
  60696. /**
  60697. * Registers the component in a given scene
  60698. */
  60699. register(): void;
  60700. /**
  60701. * Rebuilds the elements related to this component in case of
  60702. * context lost for instance.
  60703. */
  60704. rebuild(): void;
  60705. /**
  60706. * Disposes the component and the associated ressources.
  60707. */
  60708. dispose(): void;
  60709. private _draw;
  60710. private _drawCameraPredicate;
  60711. private _drawCameraBackground;
  60712. private _drawCameraForeground;
  60713. private _drawRenderTargetPredicate;
  60714. private _drawRenderTargetBackground;
  60715. private _drawRenderTargetForeground;
  60716. /**
  60717. * Adds all the elements from the container to the scene
  60718. * @param container the container holding the elements
  60719. */
  60720. addFromContainer(container: AbstractScene): void;
  60721. /**
  60722. * Removes all the elements in the container from the scene
  60723. * @param container contains the elements to remove
  60724. * @param dispose if the removed element should be disposed (default: false)
  60725. */
  60726. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60727. }
  60728. }
  60729. declare module BABYLON {
  60730. /** @hidden */
  60731. export var layerPixelShader: {
  60732. name: string;
  60733. shader: string;
  60734. };
  60735. }
  60736. declare module BABYLON {
  60737. /** @hidden */
  60738. export var layerVertexShader: {
  60739. name: string;
  60740. shader: string;
  60741. };
  60742. }
  60743. declare module BABYLON {
  60744. /**
  60745. * This represents a full screen 2d layer.
  60746. * This can be useful to display a picture in the background of your scene for instance.
  60747. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60748. */
  60749. export class Layer {
  60750. /**
  60751. * Define the name of the layer.
  60752. */
  60753. name: string;
  60754. /**
  60755. * Define the texture the layer should display.
  60756. */
  60757. texture: Nullable<Texture>;
  60758. /**
  60759. * Is the layer in background or foreground.
  60760. */
  60761. isBackground: boolean;
  60762. /**
  60763. * Define the color of the layer (instead of texture).
  60764. */
  60765. color: Color4;
  60766. /**
  60767. * Define the scale of the layer in order to zoom in out of the texture.
  60768. */
  60769. scale: Vector2;
  60770. /**
  60771. * Define an offset for the layer in order to shift the texture.
  60772. */
  60773. offset: Vector2;
  60774. /**
  60775. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60776. */
  60777. alphaBlendingMode: number;
  60778. /**
  60779. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60780. * Alpha test will not mix with the background color in case of transparency.
  60781. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60782. */
  60783. alphaTest: boolean;
  60784. /**
  60785. * Define a mask to restrict the layer to only some of the scene cameras.
  60786. */
  60787. layerMask: number;
  60788. /**
  60789. * Define the list of render target the layer is visible into.
  60790. */
  60791. renderTargetTextures: RenderTargetTexture[];
  60792. /**
  60793. * Define if the layer is only used in renderTarget or if it also
  60794. * renders in the main frame buffer of the canvas.
  60795. */
  60796. renderOnlyInRenderTargetTextures: boolean;
  60797. private _scene;
  60798. private _vertexBuffers;
  60799. private _indexBuffer;
  60800. private _effect;
  60801. private _previousDefines;
  60802. /**
  60803. * An event triggered when the layer is disposed.
  60804. */
  60805. onDisposeObservable: Observable<Layer>;
  60806. private _onDisposeObserver;
  60807. /**
  60808. * Back compatibility with callback before the onDisposeObservable existed.
  60809. * The set callback will be triggered when the layer has been disposed.
  60810. */
  60811. set onDispose(callback: () => void);
  60812. /**
  60813. * An event triggered before rendering the scene
  60814. */
  60815. onBeforeRenderObservable: Observable<Layer>;
  60816. private _onBeforeRenderObserver;
  60817. /**
  60818. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60819. * The set callback will be triggered just before rendering the layer.
  60820. */
  60821. set onBeforeRender(callback: () => void);
  60822. /**
  60823. * An event triggered after rendering the scene
  60824. */
  60825. onAfterRenderObservable: Observable<Layer>;
  60826. private _onAfterRenderObserver;
  60827. /**
  60828. * Back compatibility with callback before the onAfterRenderObservable existed.
  60829. * The set callback will be triggered just after rendering the layer.
  60830. */
  60831. set onAfterRender(callback: () => void);
  60832. /**
  60833. * Instantiates a new layer.
  60834. * This represents a full screen 2d layer.
  60835. * This can be useful to display a picture in the background of your scene for instance.
  60836. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60837. * @param name Define the name of the layer in the scene
  60838. * @param imgUrl Define the url of the texture to display in the layer
  60839. * @param scene Define the scene the layer belongs to
  60840. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60841. * @param color Defines a color for the layer
  60842. */
  60843. constructor(
  60844. /**
  60845. * Define the name of the layer.
  60846. */
  60847. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60848. private _createIndexBuffer;
  60849. /** @hidden */
  60850. _rebuild(): void;
  60851. /**
  60852. * Renders the layer in the scene.
  60853. */
  60854. render(): void;
  60855. /**
  60856. * Disposes and releases the associated ressources.
  60857. */
  60858. dispose(): void;
  60859. }
  60860. }
  60861. declare module BABYLON {
  60862. /** @hidden */
  60863. export var lensFlarePixelShader: {
  60864. name: string;
  60865. shader: string;
  60866. };
  60867. }
  60868. declare module BABYLON {
  60869. /** @hidden */
  60870. export var lensFlareVertexShader: {
  60871. name: string;
  60872. shader: string;
  60873. };
  60874. }
  60875. declare module BABYLON {
  60876. /**
  60877. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60878. * It is usually composed of several `lensFlare`.
  60879. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60880. */
  60881. export class LensFlareSystem {
  60882. /**
  60883. * Define the name of the lens flare system
  60884. */
  60885. name: string;
  60886. /**
  60887. * List of lens flares used in this system.
  60888. */
  60889. lensFlares: LensFlare[];
  60890. /**
  60891. * Define a limit from the border the lens flare can be visible.
  60892. */
  60893. borderLimit: number;
  60894. /**
  60895. * Define a viewport border we do not want to see the lens flare in.
  60896. */
  60897. viewportBorder: number;
  60898. /**
  60899. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60900. */
  60901. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60902. /**
  60903. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60904. */
  60905. layerMask: number;
  60906. /**
  60907. * Define the id of the lens flare system in the scene.
  60908. * (equal to name by default)
  60909. */
  60910. id: string;
  60911. private _scene;
  60912. private _emitter;
  60913. private _vertexBuffers;
  60914. private _indexBuffer;
  60915. private _effect;
  60916. private _positionX;
  60917. private _positionY;
  60918. private _isEnabled;
  60919. /** @hidden */
  60920. static _SceneComponentInitialization: (scene: Scene) => void;
  60921. /**
  60922. * Instantiates a lens flare system.
  60923. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60924. * It is usually composed of several `lensFlare`.
  60925. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60926. * @param name Define the name of the lens flare system in the scene
  60927. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60928. * @param scene Define the scene the lens flare system belongs to
  60929. */
  60930. constructor(
  60931. /**
  60932. * Define the name of the lens flare system
  60933. */
  60934. name: string, emitter: any, scene: Scene);
  60935. /**
  60936. * Define if the lens flare system is enabled.
  60937. */
  60938. get isEnabled(): boolean;
  60939. set isEnabled(value: boolean);
  60940. /**
  60941. * Get the scene the effects belongs to.
  60942. * @returns the scene holding the lens flare system
  60943. */
  60944. getScene(): Scene;
  60945. /**
  60946. * Get the emitter of the lens flare system.
  60947. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60948. * @returns the emitter of the lens flare system
  60949. */
  60950. getEmitter(): any;
  60951. /**
  60952. * Set the emitter of the lens flare system.
  60953. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60954. * @param newEmitter Define the new emitter of the system
  60955. */
  60956. setEmitter(newEmitter: any): void;
  60957. /**
  60958. * Get the lens flare system emitter position.
  60959. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60960. * @returns the position
  60961. */
  60962. getEmitterPosition(): Vector3;
  60963. /**
  60964. * @hidden
  60965. */
  60966. computeEffectivePosition(globalViewport: Viewport): boolean;
  60967. /** @hidden */
  60968. _isVisible(): boolean;
  60969. /**
  60970. * @hidden
  60971. */
  60972. render(): boolean;
  60973. /**
  60974. * Dispose and release the lens flare with its associated resources.
  60975. */
  60976. dispose(): void;
  60977. /**
  60978. * Parse a lens flare system from a JSON repressentation
  60979. * @param parsedLensFlareSystem Define the JSON to parse
  60980. * @param scene Define the scene the parsed system should be instantiated in
  60981. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60982. * @returns the parsed system
  60983. */
  60984. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60985. /**
  60986. * Serialize the current Lens Flare System into a JSON representation.
  60987. * @returns the serialized JSON
  60988. */
  60989. serialize(): any;
  60990. }
  60991. }
  60992. declare module BABYLON {
  60993. /**
  60994. * This represents one of the lens effect in a `lensFlareSystem`.
  60995. * It controls one of the indiviual texture used in the effect.
  60996. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60997. */
  60998. export class LensFlare {
  60999. /**
  61000. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61001. */
  61002. size: number;
  61003. /**
  61004. * 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.
  61005. */
  61006. position: number;
  61007. /**
  61008. * Define the lens color.
  61009. */
  61010. color: Color3;
  61011. /**
  61012. * Define the lens texture.
  61013. */
  61014. texture: Nullable<Texture>;
  61015. /**
  61016. * Define the alpha mode to render this particular lens.
  61017. */
  61018. alphaMode: number;
  61019. private _system;
  61020. /**
  61021. * Creates a new Lens Flare.
  61022. * This represents one of the lens effect in a `lensFlareSystem`.
  61023. * It controls one of the indiviual texture used in the effect.
  61024. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61025. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61026. * @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.
  61027. * @param color Define the lens color
  61028. * @param imgUrl Define the lens texture url
  61029. * @param system Define the `lensFlareSystem` this flare is part of
  61030. * @returns The newly created Lens Flare
  61031. */
  61032. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61033. /**
  61034. * Instantiates a new Lens Flare.
  61035. * This represents one of the lens effect in a `lensFlareSystem`.
  61036. * It controls one of the indiviual texture used in the effect.
  61037. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61038. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61039. * @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.
  61040. * @param color Define the lens color
  61041. * @param imgUrl Define the lens texture url
  61042. * @param system Define the `lensFlareSystem` this flare is part of
  61043. */
  61044. constructor(
  61045. /**
  61046. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61047. */
  61048. size: number,
  61049. /**
  61050. * 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.
  61051. */
  61052. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61053. /**
  61054. * Dispose and release the lens flare with its associated resources.
  61055. */
  61056. dispose(): void;
  61057. }
  61058. }
  61059. declare module BABYLON {
  61060. interface AbstractScene {
  61061. /**
  61062. * The list of lens flare system added to the scene
  61063. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61064. */
  61065. lensFlareSystems: Array<LensFlareSystem>;
  61066. /**
  61067. * Removes the given lens flare system from this scene.
  61068. * @param toRemove The lens flare system to remove
  61069. * @returns The index of the removed lens flare system
  61070. */
  61071. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61072. /**
  61073. * Adds the given lens flare system to this scene
  61074. * @param newLensFlareSystem The lens flare system to add
  61075. */
  61076. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61077. /**
  61078. * Gets a lens flare system using its name
  61079. * @param name defines the name to look for
  61080. * @returns the lens flare system or null if not found
  61081. */
  61082. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61083. /**
  61084. * Gets a lens flare system using its id
  61085. * @param id defines the id to look for
  61086. * @returns the lens flare system or null if not found
  61087. */
  61088. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61089. }
  61090. /**
  61091. * Defines the lens flare scene component responsible to manage any lens flares
  61092. * in a given scene.
  61093. */
  61094. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61095. /**
  61096. * The component name helpfull to identify the component in the list of scene components.
  61097. */
  61098. readonly name: string;
  61099. /**
  61100. * The scene the component belongs to.
  61101. */
  61102. scene: Scene;
  61103. /**
  61104. * Creates a new instance of the component for the given scene
  61105. * @param scene Defines the scene to register the component in
  61106. */
  61107. constructor(scene: Scene);
  61108. /**
  61109. * Registers the component in a given scene
  61110. */
  61111. register(): void;
  61112. /**
  61113. * Rebuilds the elements related to this component in case of
  61114. * context lost for instance.
  61115. */
  61116. rebuild(): void;
  61117. /**
  61118. * Adds all the elements from the container to the scene
  61119. * @param container the container holding the elements
  61120. */
  61121. addFromContainer(container: AbstractScene): void;
  61122. /**
  61123. * Removes all the elements in the container from the scene
  61124. * @param container contains the elements to remove
  61125. * @param dispose if the removed element should be disposed (default: false)
  61126. */
  61127. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61128. /**
  61129. * Serializes the component data to the specified json object
  61130. * @param serializationObject The object to serialize to
  61131. */
  61132. serialize(serializationObject: any): void;
  61133. /**
  61134. * Disposes the component and the associated ressources.
  61135. */
  61136. dispose(): void;
  61137. private _draw;
  61138. }
  61139. }
  61140. declare module BABYLON {
  61141. /** @hidden */
  61142. export var depthPixelShader: {
  61143. name: string;
  61144. shader: string;
  61145. };
  61146. }
  61147. declare module BABYLON {
  61148. /** @hidden */
  61149. export var depthVertexShader: {
  61150. name: string;
  61151. shader: string;
  61152. };
  61153. }
  61154. declare module BABYLON {
  61155. /**
  61156. * This represents a depth renderer in Babylon.
  61157. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61158. */
  61159. export class DepthRenderer {
  61160. private _scene;
  61161. private _depthMap;
  61162. private _effect;
  61163. private readonly _storeNonLinearDepth;
  61164. private readonly _clearColor;
  61165. /** Get if the depth renderer is using packed depth or not */
  61166. readonly isPacked: boolean;
  61167. private _cachedDefines;
  61168. private _camera;
  61169. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61170. enabled: boolean;
  61171. /**
  61172. * Specifiess that the depth renderer will only be used within
  61173. * the camera it is created for.
  61174. * This can help forcing its rendering during the camera processing.
  61175. */
  61176. useOnlyInActiveCamera: boolean;
  61177. /** @hidden */
  61178. static _SceneComponentInitialization: (scene: Scene) => void;
  61179. /**
  61180. * Instantiates a depth renderer
  61181. * @param scene The scene the renderer belongs to
  61182. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61183. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61184. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61185. */
  61186. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61187. /**
  61188. * Creates the depth rendering effect and checks if the effect is ready.
  61189. * @param subMesh The submesh to be used to render the depth map of
  61190. * @param useInstances If multiple world instances should be used
  61191. * @returns if the depth renderer is ready to render the depth map
  61192. */
  61193. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61194. /**
  61195. * Gets the texture which the depth map will be written to.
  61196. * @returns The depth map texture
  61197. */
  61198. getDepthMap(): RenderTargetTexture;
  61199. /**
  61200. * Disposes of the depth renderer.
  61201. */
  61202. dispose(): void;
  61203. }
  61204. }
  61205. declare module BABYLON {
  61206. /** @hidden */
  61207. export var minmaxReduxPixelShader: {
  61208. name: string;
  61209. shader: string;
  61210. };
  61211. }
  61212. declare module BABYLON {
  61213. /**
  61214. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61215. * and maximum values from all values of the texture.
  61216. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61217. * The source values are read from the red channel of the texture.
  61218. */
  61219. export class MinMaxReducer {
  61220. /**
  61221. * Observable triggered when the computation has been performed
  61222. */
  61223. onAfterReductionPerformed: Observable<{
  61224. min: number;
  61225. max: number;
  61226. }>;
  61227. protected _camera: Camera;
  61228. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61229. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61230. protected _postProcessManager: PostProcessManager;
  61231. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61232. protected _forceFullscreenViewport: boolean;
  61233. /**
  61234. * Creates a min/max reducer
  61235. * @param camera The camera to use for the post processes
  61236. */
  61237. constructor(camera: Camera);
  61238. /**
  61239. * Gets the texture used to read the values from.
  61240. */
  61241. get sourceTexture(): Nullable<RenderTargetTexture>;
  61242. /**
  61243. * Sets the source texture to read the values from.
  61244. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61245. * because in such textures '1' value must not be taken into account to compute the maximum
  61246. * as this value is used to clear the texture.
  61247. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61248. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61249. * @param depthRedux Indicates if the texture is a depth texture or not
  61250. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61251. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61252. */
  61253. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61254. /**
  61255. * Defines the refresh rate of the computation.
  61256. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61257. */
  61258. get refreshRate(): number;
  61259. set refreshRate(value: number);
  61260. protected _activated: boolean;
  61261. /**
  61262. * Gets the activation status of the reducer
  61263. */
  61264. get activated(): boolean;
  61265. /**
  61266. * Activates the reduction computation.
  61267. * When activated, the observers registered in onAfterReductionPerformed are
  61268. * called after the compuation is performed
  61269. */
  61270. activate(): void;
  61271. /**
  61272. * Deactivates the reduction computation.
  61273. */
  61274. deactivate(): void;
  61275. /**
  61276. * Disposes the min/max reducer
  61277. * @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.
  61278. */
  61279. dispose(disposeAll?: boolean): void;
  61280. }
  61281. }
  61282. declare module BABYLON {
  61283. /**
  61284. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61285. */
  61286. export class DepthReducer extends MinMaxReducer {
  61287. private _depthRenderer;
  61288. private _depthRendererId;
  61289. /**
  61290. * Gets the depth renderer used for the computation.
  61291. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61292. */
  61293. get depthRenderer(): Nullable<DepthRenderer>;
  61294. /**
  61295. * Creates a depth reducer
  61296. * @param camera The camera used to render the depth texture
  61297. */
  61298. constructor(camera: Camera);
  61299. /**
  61300. * Sets the depth renderer to use to generate the depth map
  61301. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61302. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61303. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61304. */
  61305. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61306. /** @hidden */
  61307. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61308. /**
  61309. * Activates the reduction computation.
  61310. * When activated, the observers registered in onAfterReductionPerformed are
  61311. * called after the compuation is performed
  61312. */
  61313. activate(): void;
  61314. /**
  61315. * Deactivates the reduction computation.
  61316. */
  61317. deactivate(): void;
  61318. /**
  61319. * Disposes the depth reducer
  61320. * @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.
  61321. */
  61322. dispose(disposeAll?: boolean): void;
  61323. }
  61324. }
  61325. declare module BABYLON {
  61326. /**
  61327. * A CSM implementation allowing casting shadows on large scenes.
  61328. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61329. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61330. */
  61331. export class CascadedShadowGenerator extends ShadowGenerator {
  61332. private static readonly frustumCornersNDCSpace;
  61333. /**
  61334. * Name of the CSM class
  61335. */
  61336. static CLASSNAME: string;
  61337. /**
  61338. * Defines the default number of cascades used by the CSM.
  61339. */
  61340. static readonly DEFAULT_CASCADES_COUNT: number;
  61341. /**
  61342. * Defines the minimum number of cascades used by the CSM.
  61343. */
  61344. static readonly MIN_CASCADES_COUNT: number;
  61345. /**
  61346. * Defines the maximum number of cascades used by the CSM.
  61347. */
  61348. static readonly MAX_CASCADES_COUNT: number;
  61349. protected _validateFilter(filter: number): number;
  61350. /**
  61351. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61352. */
  61353. penumbraDarkness: number;
  61354. private _numCascades;
  61355. /**
  61356. * Gets or set the number of cascades used by the CSM.
  61357. */
  61358. get numCascades(): number;
  61359. set numCascades(value: number);
  61360. /**
  61361. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61362. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61363. */
  61364. stabilizeCascades: boolean;
  61365. private _freezeShadowCastersBoundingInfo;
  61366. private _freezeShadowCastersBoundingInfoObservable;
  61367. /**
  61368. * Enables or disables the shadow casters bounding info computation.
  61369. * If your shadow casters don't move, you can disable this feature.
  61370. * If it is enabled, the bounding box computation is done every frame.
  61371. */
  61372. get freezeShadowCastersBoundingInfo(): boolean;
  61373. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61374. private _scbiMin;
  61375. private _scbiMax;
  61376. protected _computeShadowCastersBoundingInfo(): void;
  61377. protected _shadowCastersBoundingInfo: BoundingInfo;
  61378. /**
  61379. * Gets or sets the shadow casters bounding info.
  61380. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61381. * so that the system won't overwrite the bounds you provide
  61382. */
  61383. get shadowCastersBoundingInfo(): BoundingInfo;
  61384. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61385. protected _breaksAreDirty: boolean;
  61386. protected _minDistance: number;
  61387. protected _maxDistance: number;
  61388. /**
  61389. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61390. *
  61391. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61392. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61393. * @param min minimal distance for the breaks (default to 0.)
  61394. * @param max maximal distance for the breaks (default to 1.)
  61395. */
  61396. setMinMaxDistance(min: number, max: number): void;
  61397. /** Gets the minimal distance used in the cascade break computation */
  61398. get minDistance(): number;
  61399. /** Gets the maximal distance used in the cascade break computation */
  61400. get maxDistance(): number;
  61401. /**
  61402. * Gets the class name of that object
  61403. * @returns "CascadedShadowGenerator"
  61404. */
  61405. getClassName(): string;
  61406. private _cascadeMinExtents;
  61407. private _cascadeMaxExtents;
  61408. /**
  61409. * Gets a cascade minimum extents
  61410. * @param cascadeIndex index of the cascade
  61411. * @returns the minimum cascade extents
  61412. */
  61413. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61414. /**
  61415. * Gets a cascade maximum extents
  61416. * @param cascadeIndex index of the cascade
  61417. * @returns the maximum cascade extents
  61418. */
  61419. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61420. private _cascades;
  61421. private _currentLayer;
  61422. private _viewSpaceFrustumsZ;
  61423. private _viewMatrices;
  61424. private _projectionMatrices;
  61425. private _transformMatrices;
  61426. private _transformMatricesAsArray;
  61427. private _frustumLengths;
  61428. private _lightSizeUVCorrection;
  61429. private _depthCorrection;
  61430. private _frustumCornersWorldSpace;
  61431. private _frustumCenter;
  61432. private _shadowCameraPos;
  61433. private _shadowMaxZ;
  61434. /**
  61435. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61436. * It defaults to camera.maxZ
  61437. */
  61438. get shadowMaxZ(): number;
  61439. /**
  61440. * Sets the shadow max z distance.
  61441. */
  61442. set shadowMaxZ(value: number);
  61443. protected _debug: boolean;
  61444. /**
  61445. * Gets or sets the debug flag.
  61446. * When enabled, the cascades are materialized by different colors on the screen.
  61447. */
  61448. get debug(): boolean;
  61449. set debug(dbg: boolean);
  61450. private _depthClamp;
  61451. /**
  61452. * Gets or sets the depth clamping value.
  61453. *
  61454. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61455. * to account for the shadow casters far away.
  61456. *
  61457. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61458. */
  61459. get depthClamp(): boolean;
  61460. set depthClamp(value: boolean);
  61461. private _cascadeBlendPercentage;
  61462. /**
  61463. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61464. * It defaults to 0.1 (10% blending).
  61465. */
  61466. get cascadeBlendPercentage(): number;
  61467. set cascadeBlendPercentage(value: number);
  61468. private _lambda;
  61469. /**
  61470. * Gets or set the lambda parameter.
  61471. * This parameter is used to split the camera frustum and create the cascades.
  61472. * 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.
  61473. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61474. */
  61475. get lambda(): number;
  61476. set lambda(value: number);
  61477. /**
  61478. * Gets the view matrix corresponding to a given cascade
  61479. * @param cascadeNum cascade to retrieve the view matrix from
  61480. * @returns the cascade view matrix
  61481. */
  61482. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61483. /**
  61484. * Gets the projection matrix corresponding to a given cascade
  61485. * @param cascadeNum cascade to retrieve the projection matrix from
  61486. * @returns the cascade projection matrix
  61487. */
  61488. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61489. /**
  61490. * Gets the transformation matrix corresponding to a given cascade
  61491. * @param cascadeNum cascade to retrieve the transformation matrix from
  61492. * @returns the cascade transformation matrix
  61493. */
  61494. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61495. private _depthRenderer;
  61496. /**
  61497. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61498. *
  61499. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61500. *
  61501. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61502. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61503. * @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
  61504. */
  61505. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61506. private _depthReducer;
  61507. private _autoCalcDepthBounds;
  61508. /**
  61509. * Gets or sets the autoCalcDepthBounds property.
  61510. *
  61511. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61512. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61513. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61514. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61515. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61516. */
  61517. get autoCalcDepthBounds(): boolean;
  61518. set autoCalcDepthBounds(value: boolean);
  61519. /**
  61520. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61521. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61522. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61523. * for setting the refresh rate on the renderer yourself!
  61524. */
  61525. get autoCalcDepthBoundsRefreshRate(): number;
  61526. set autoCalcDepthBoundsRefreshRate(value: number);
  61527. /**
  61528. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61529. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61530. * you change the camera near/far planes!
  61531. */
  61532. splitFrustum(): void;
  61533. private _splitFrustum;
  61534. private _computeMatrices;
  61535. private _computeFrustumInWorldSpace;
  61536. private _computeCascadeFrustum;
  61537. /**
  61538. * Support test.
  61539. */
  61540. static get IsSupported(): boolean;
  61541. /** @hidden */
  61542. static _SceneComponentInitialization: (scene: Scene) => void;
  61543. /**
  61544. * Creates a Cascaded Shadow Generator object.
  61545. * A ShadowGenerator is the required tool to use the shadows.
  61546. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61547. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61548. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61549. * @param light The directional light object generating the shadows.
  61550. * @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.
  61551. */
  61552. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61553. protected _initializeGenerator(): void;
  61554. protected _createTargetRenderTexture(): void;
  61555. protected _initializeShadowMap(): void;
  61556. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61557. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61558. /**
  61559. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61560. * @param defines Defines of the material we want to update
  61561. * @param lightIndex Index of the light in the enabled light list of the material
  61562. */
  61563. prepareDefines(defines: any, lightIndex: number): void;
  61564. /**
  61565. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61566. * defined in the generator but impacting the effect).
  61567. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61568. * @param effect The effect we are binfing the information for
  61569. */
  61570. bindShadowLight(lightIndex: string, effect: Effect): void;
  61571. /**
  61572. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61573. * (eq to view projection * shadow projection matrices)
  61574. * @returns The transform matrix used to create the shadow map
  61575. */
  61576. getTransformMatrix(): Matrix;
  61577. /**
  61578. * Disposes the ShadowGenerator.
  61579. * Returns nothing.
  61580. */
  61581. dispose(): void;
  61582. /**
  61583. * Serializes the shadow generator setup to a json object.
  61584. * @returns The serialized JSON object
  61585. */
  61586. serialize(): any;
  61587. /**
  61588. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61589. * @param parsedShadowGenerator The JSON object to parse
  61590. * @param scene The scene to create the shadow map for
  61591. * @returns The parsed shadow generator
  61592. */
  61593. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61594. }
  61595. }
  61596. declare module BABYLON {
  61597. /**
  61598. * Defines the shadow generator component responsible to manage any shadow generators
  61599. * in a given scene.
  61600. */
  61601. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61602. /**
  61603. * The component name helpfull to identify the component in the list of scene components.
  61604. */
  61605. readonly name: string;
  61606. /**
  61607. * The scene the component belongs to.
  61608. */
  61609. scene: Scene;
  61610. /**
  61611. * Creates a new instance of the component for the given scene
  61612. * @param scene Defines the scene to register the component in
  61613. */
  61614. constructor(scene: Scene);
  61615. /**
  61616. * Registers the component in a given scene
  61617. */
  61618. register(): void;
  61619. /**
  61620. * Rebuilds the elements related to this component in case of
  61621. * context lost for instance.
  61622. */
  61623. rebuild(): void;
  61624. /**
  61625. * Serializes the component data to the specified json object
  61626. * @param serializationObject The object to serialize to
  61627. */
  61628. serialize(serializationObject: any): void;
  61629. /**
  61630. * Adds all the elements from the container to the scene
  61631. * @param container the container holding the elements
  61632. */
  61633. addFromContainer(container: AbstractScene): void;
  61634. /**
  61635. * Removes all the elements in the container from the scene
  61636. * @param container contains the elements to remove
  61637. * @param dispose if the removed element should be disposed (default: false)
  61638. */
  61639. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61640. /**
  61641. * Rebuilds the elements related to this component in case of
  61642. * context lost for instance.
  61643. */
  61644. dispose(): void;
  61645. private _gatherRenderTargets;
  61646. }
  61647. }
  61648. declare module BABYLON {
  61649. /**
  61650. * A point light is a light defined by an unique point in world space.
  61651. * The light is emitted in every direction from this point.
  61652. * A good example of a point light is a standard light bulb.
  61653. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61654. */
  61655. export class PointLight extends ShadowLight {
  61656. private _shadowAngle;
  61657. /**
  61658. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61659. * This specifies what angle the shadow will use to be created.
  61660. *
  61661. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61662. */
  61663. get shadowAngle(): number;
  61664. /**
  61665. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61666. * This specifies what angle the shadow will use to be created.
  61667. *
  61668. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61669. */
  61670. set shadowAngle(value: number);
  61671. /**
  61672. * Gets the direction if it has been set.
  61673. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61674. */
  61675. get direction(): Vector3;
  61676. /**
  61677. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61678. */
  61679. set direction(value: Vector3);
  61680. /**
  61681. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61682. * A PointLight emits the light in every direction.
  61683. * It can cast shadows.
  61684. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61685. * ```javascript
  61686. * var pointLight = new PointLight("pl", camera.position, scene);
  61687. * ```
  61688. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61689. * @param name The light friendly name
  61690. * @param position The position of the point light in the scene
  61691. * @param scene The scene the lights belongs to
  61692. */
  61693. constructor(name: string, position: Vector3, scene: Scene);
  61694. /**
  61695. * Returns the string "PointLight"
  61696. * @returns the class name
  61697. */
  61698. getClassName(): string;
  61699. /**
  61700. * Returns the integer 0.
  61701. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61702. */
  61703. getTypeID(): number;
  61704. /**
  61705. * Specifies wether or not the shadowmap should be a cube texture.
  61706. * @returns true if the shadowmap needs to be a cube texture.
  61707. */
  61708. needCube(): boolean;
  61709. /**
  61710. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61711. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61712. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61713. */
  61714. getShadowDirection(faceIndex?: number): Vector3;
  61715. /**
  61716. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61717. * - fov = PI / 2
  61718. * - aspect ratio : 1.0
  61719. * - z-near and far equal to the active camera minZ and maxZ.
  61720. * Returns the PointLight.
  61721. */
  61722. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61723. protected _buildUniformLayout(): void;
  61724. /**
  61725. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61726. * @param effect The effect to update
  61727. * @param lightIndex The index of the light in the effect to update
  61728. * @returns The point light
  61729. */
  61730. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61731. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61732. /**
  61733. * Prepares the list of defines specific to the light type.
  61734. * @param defines the list of defines
  61735. * @param lightIndex defines the index of the light for the effect
  61736. */
  61737. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61738. }
  61739. }
  61740. declare module BABYLON {
  61741. /**
  61742. * Header information of HDR texture files.
  61743. */
  61744. export interface HDRInfo {
  61745. /**
  61746. * The height of the texture in pixels.
  61747. */
  61748. height: number;
  61749. /**
  61750. * The width of the texture in pixels.
  61751. */
  61752. width: number;
  61753. /**
  61754. * The index of the beginning of the data in the binary file.
  61755. */
  61756. dataPosition: number;
  61757. }
  61758. /**
  61759. * This groups tools to convert HDR texture to native colors array.
  61760. */
  61761. export class HDRTools {
  61762. private static Ldexp;
  61763. private static Rgbe2float;
  61764. private static readStringLine;
  61765. /**
  61766. * Reads header information from an RGBE texture stored in a native array.
  61767. * More information on this format are available here:
  61768. * https://en.wikipedia.org/wiki/RGBE_image_format
  61769. *
  61770. * @param uint8array The binary file stored in native array.
  61771. * @return The header information.
  61772. */
  61773. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61774. /**
  61775. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61776. * This RGBE texture needs to store the information as a panorama.
  61777. *
  61778. * More information on this format are available here:
  61779. * https://en.wikipedia.org/wiki/RGBE_image_format
  61780. *
  61781. * @param buffer The binary file stored in an array buffer.
  61782. * @param size The expected size of the extracted cubemap.
  61783. * @return The Cube Map information.
  61784. */
  61785. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61786. /**
  61787. * Returns the pixels data extracted from an RGBE texture.
  61788. * This pixels will be stored left to right up to down in the R G B order in one array.
  61789. *
  61790. * More information on this format are available here:
  61791. * https://en.wikipedia.org/wiki/RGBE_image_format
  61792. *
  61793. * @param uint8array The binary file stored in an array buffer.
  61794. * @param hdrInfo The header information of the file.
  61795. * @return The pixels data in RGB right to left up to down order.
  61796. */
  61797. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61798. private static RGBE_ReadPixels_RLE;
  61799. private static RGBE_ReadPixels_NOT_RLE;
  61800. }
  61801. }
  61802. declare module BABYLON {
  61803. /**
  61804. * Effect Render Options
  61805. */
  61806. export interface IEffectRendererOptions {
  61807. /**
  61808. * Defines the vertices positions.
  61809. */
  61810. positions?: number[];
  61811. /**
  61812. * Defines the indices.
  61813. */
  61814. indices?: number[];
  61815. }
  61816. /**
  61817. * Helper class to render one or more effects.
  61818. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61819. */
  61820. export class EffectRenderer {
  61821. private engine;
  61822. private static _DefaultOptions;
  61823. private _vertexBuffers;
  61824. private _indexBuffer;
  61825. private _fullscreenViewport;
  61826. /**
  61827. * Creates an effect renderer
  61828. * @param engine the engine to use for rendering
  61829. * @param options defines the options of the effect renderer
  61830. */
  61831. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61832. /**
  61833. * Sets the current viewport in normalized coordinates 0-1
  61834. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61835. */
  61836. setViewport(viewport?: Viewport): void;
  61837. /**
  61838. * Binds the embedded attributes buffer to the effect.
  61839. * @param effect Defines the effect to bind the attributes for
  61840. */
  61841. bindBuffers(effect: Effect): void;
  61842. /**
  61843. * Sets the current effect wrapper to use during draw.
  61844. * The effect needs to be ready before calling this api.
  61845. * This also sets the default full screen position attribute.
  61846. * @param effectWrapper Defines the effect to draw with
  61847. */
  61848. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61849. /**
  61850. * Restores engine states
  61851. */
  61852. restoreStates(): void;
  61853. /**
  61854. * Draws a full screen quad.
  61855. */
  61856. draw(): void;
  61857. private isRenderTargetTexture;
  61858. /**
  61859. * renders one or more effects to a specified texture
  61860. * @param effectWrapper the effect to renderer
  61861. * @param outputTexture texture to draw to, if null it will render to the screen.
  61862. */
  61863. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61864. /**
  61865. * Disposes of the effect renderer
  61866. */
  61867. dispose(): void;
  61868. }
  61869. /**
  61870. * Options to create an EffectWrapper
  61871. */
  61872. interface EffectWrapperCreationOptions {
  61873. /**
  61874. * Engine to use to create the effect
  61875. */
  61876. engine: ThinEngine;
  61877. /**
  61878. * Fragment shader for the effect
  61879. */
  61880. fragmentShader: string;
  61881. /**
  61882. * Use the shader store instead of direct source code
  61883. */
  61884. useShaderStore?: boolean;
  61885. /**
  61886. * Vertex shader for the effect
  61887. */
  61888. vertexShader?: string;
  61889. /**
  61890. * Attributes to use in the shader
  61891. */
  61892. attributeNames?: Array<string>;
  61893. /**
  61894. * Uniforms to use in the shader
  61895. */
  61896. uniformNames?: Array<string>;
  61897. /**
  61898. * Texture sampler names to use in the shader
  61899. */
  61900. samplerNames?: Array<string>;
  61901. /**
  61902. * Defines to use in the shader
  61903. */
  61904. defines?: Array<string>;
  61905. /**
  61906. * Callback when effect is compiled
  61907. */
  61908. onCompiled?: Nullable<(effect: Effect) => void>;
  61909. /**
  61910. * The friendly name of the effect displayed in Spector.
  61911. */
  61912. name?: string;
  61913. }
  61914. /**
  61915. * Wraps an effect to be used for rendering
  61916. */
  61917. export class EffectWrapper {
  61918. /**
  61919. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61920. */
  61921. onApplyObservable: Observable<{}>;
  61922. /**
  61923. * The underlying effect
  61924. */
  61925. effect: Effect;
  61926. /**
  61927. * Creates an effect to be renderer
  61928. * @param creationOptions options to create the effect
  61929. */
  61930. constructor(creationOptions: EffectWrapperCreationOptions);
  61931. /**
  61932. * Disposes of the effect wrapper
  61933. */
  61934. dispose(): void;
  61935. }
  61936. }
  61937. declare module BABYLON {
  61938. /** @hidden */
  61939. export var hdrFilteringVertexShader: {
  61940. name: string;
  61941. shader: string;
  61942. };
  61943. }
  61944. declare module BABYLON {
  61945. /** @hidden */
  61946. export var hdrFilteringPixelShader: {
  61947. name: string;
  61948. shader: string;
  61949. };
  61950. }
  61951. declare module BABYLON {
  61952. /**
  61953. * Options for texture filtering
  61954. */
  61955. interface IHDRFilteringOptions {
  61956. /**
  61957. * Scales pixel intensity for the input HDR map.
  61958. */
  61959. hdrScale?: number;
  61960. /**
  61961. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61962. */
  61963. quality?: number;
  61964. }
  61965. /**
  61966. * Filters HDR maps to get correct renderings of PBR reflections
  61967. */
  61968. export class HDRFiltering {
  61969. private _engine;
  61970. private _effectRenderer;
  61971. private _effectWrapper;
  61972. private _lodGenerationOffset;
  61973. private _lodGenerationScale;
  61974. /**
  61975. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61976. * you care about baking speed.
  61977. */
  61978. quality: number;
  61979. /**
  61980. * Scales pixel intensity for the input HDR map.
  61981. */
  61982. hdrScale: number;
  61983. /**
  61984. * Instantiates HDR filter for reflection maps
  61985. *
  61986. * @param engine Thin engine
  61987. * @param options Options
  61988. */
  61989. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61990. private _createRenderTarget;
  61991. private _prefilterInternal;
  61992. private _createEffect;
  61993. /**
  61994. * Get a value indicating if the filter is ready to be used
  61995. * @param texture Texture to filter
  61996. * @returns true if the filter is ready
  61997. */
  61998. isReady(texture: BaseTexture): boolean;
  61999. /**
  62000. * Prefilters a cube texture to have mipmap levels representing roughness values.
  62001. * Prefiltering will be invoked at the end of next rendering pass.
  62002. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  62003. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  62004. * @param texture Texture to filter
  62005. * @param onFinished Callback when filtering is done
  62006. * @return Promise called when prefiltering is done
  62007. */
  62008. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  62009. }
  62010. }
  62011. declare module BABYLON {
  62012. /**
  62013. * This represents a texture coming from an HDR input.
  62014. *
  62015. * The only supported format is currently panorama picture stored in RGBE format.
  62016. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62017. */
  62018. export class HDRCubeTexture extends BaseTexture {
  62019. private static _facesMapping;
  62020. private _generateHarmonics;
  62021. private _noMipmap;
  62022. private _prefilterOnLoad;
  62023. private _textureMatrix;
  62024. private _size;
  62025. private _onLoad;
  62026. private _onError;
  62027. /**
  62028. * The texture URL.
  62029. */
  62030. url: string;
  62031. protected _isBlocking: boolean;
  62032. /**
  62033. * Sets wether or not the texture is blocking during loading.
  62034. */
  62035. set isBlocking(value: boolean);
  62036. /**
  62037. * Gets wether or not the texture is blocking during loading.
  62038. */
  62039. get isBlocking(): boolean;
  62040. protected _rotationY: number;
  62041. /**
  62042. * Sets texture matrix rotation angle around Y axis in radians.
  62043. */
  62044. set rotationY(value: number);
  62045. /**
  62046. * Gets texture matrix rotation angle around Y axis radians.
  62047. */
  62048. get rotationY(): number;
  62049. /**
  62050. * Gets or sets the center of the bounding box associated with the cube texture
  62051. * It must define where the camera used to render the texture was set
  62052. */
  62053. boundingBoxPosition: Vector3;
  62054. private _boundingBoxSize;
  62055. /**
  62056. * Gets or sets the size of the bounding box associated with the cube texture
  62057. * When defined, the cubemap will switch to local mode
  62058. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62059. * @example https://www.babylonjs-playground.com/#RNASML
  62060. */
  62061. set boundingBoxSize(value: Vector3);
  62062. get boundingBoxSize(): Vector3;
  62063. /**
  62064. * Instantiates an HDRTexture from the following parameters.
  62065. *
  62066. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62067. * @param sceneOrEngine The scene or engine the texture will be used in
  62068. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62069. * @param noMipmap Forces to not generate the mipmap if true
  62070. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62071. * @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)
  62072. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62073. */
  62074. 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>);
  62075. /**
  62076. * Get the current class name of the texture useful for serialization or dynamic coding.
  62077. * @returns "HDRCubeTexture"
  62078. */
  62079. getClassName(): string;
  62080. /**
  62081. * Occurs when the file is raw .hdr file.
  62082. */
  62083. private loadTexture;
  62084. clone(): HDRCubeTexture;
  62085. delayLoad(): void;
  62086. /**
  62087. * Get the texture reflection matrix used to rotate/transform the reflection.
  62088. * @returns the reflection matrix
  62089. */
  62090. getReflectionTextureMatrix(): Matrix;
  62091. /**
  62092. * Set the texture reflection matrix used to rotate/transform the reflection.
  62093. * @param value Define the reflection matrix to set
  62094. */
  62095. setReflectionTextureMatrix(value: Matrix): void;
  62096. /**
  62097. * Parses a JSON representation of an HDR Texture in order to create the texture
  62098. * @param parsedTexture Define the JSON representation
  62099. * @param scene Define the scene the texture should be created in
  62100. * @param rootUrl Define the root url in case we need to load relative dependencies
  62101. * @returns the newly created texture after parsing
  62102. */
  62103. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62104. serialize(): any;
  62105. }
  62106. }
  62107. declare module BABYLON {
  62108. /**
  62109. * Class used to control physics engine
  62110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62111. */
  62112. export class PhysicsEngine implements IPhysicsEngine {
  62113. private _physicsPlugin;
  62114. /**
  62115. * Global value used to control the smallest number supported by the simulation
  62116. */
  62117. static Epsilon: number;
  62118. private _impostors;
  62119. private _joints;
  62120. private _subTimeStep;
  62121. /**
  62122. * Gets the gravity vector used by the simulation
  62123. */
  62124. gravity: Vector3;
  62125. /**
  62126. * Factory used to create the default physics plugin.
  62127. * @returns The default physics plugin
  62128. */
  62129. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62130. /**
  62131. * Creates a new Physics Engine
  62132. * @param gravity defines the gravity vector used by the simulation
  62133. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62134. */
  62135. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62136. /**
  62137. * Sets the gravity vector used by the simulation
  62138. * @param gravity defines the gravity vector to use
  62139. */
  62140. setGravity(gravity: Vector3): void;
  62141. /**
  62142. * Set the time step of the physics engine.
  62143. * Default is 1/60.
  62144. * To slow it down, enter 1/600 for example.
  62145. * To speed it up, 1/30
  62146. * @param newTimeStep defines the new timestep to apply to this world.
  62147. */
  62148. setTimeStep(newTimeStep?: number): void;
  62149. /**
  62150. * Get the time step of the physics engine.
  62151. * @returns the current time step
  62152. */
  62153. getTimeStep(): number;
  62154. /**
  62155. * Set the sub time step of the physics engine.
  62156. * Default is 0 meaning there is no sub steps
  62157. * To increase physics resolution precision, set a small value (like 1 ms)
  62158. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62159. */
  62160. setSubTimeStep(subTimeStep?: number): void;
  62161. /**
  62162. * Get the sub time step of the physics engine.
  62163. * @returns the current sub time step
  62164. */
  62165. getSubTimeStep(): number;
  62166. /**
  62167. * Release all resources
  62168. */
  62169. dispose(): void;
  62170. /**
  62171. * Gets the name of the current physics plugin
  62172. * @returns the name of the plugin
  62173. */
  62174. getPhysicsPluginName(): string;
  62175. /**
  62176. * Adding a new impostor for the impostor tracking.
  62177. * This will be done by the impostor itself.
  62178. * @param impostor the impostor to add
  62179. */
  62180. addImpostor(impostor: PhysicsImpostor): void;
  62181. /**
  62182. * Remove an impostor from the engine.
  62183. * This impostor and its mesh will not longer be updated by the physics engine.
  62184. * @param impostor the impostor to remove
  62185. */
  62186. removeImpostor(impostor: PhysicsImpostor): void;
  62187. /**
  62188. * Add a joint to the physics engine
  62189. * @param mainImpostor defines the main impostor to which the joint is added.
  62190. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62191. * @param joint defines the joint that will connect both impostors.
  62192. */
  62193. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62194. /**
  62195. * Removes a joint from the simulation
  62196. * @param mainImpostor defines the impostor used with the joint
  62197. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62198. * @param joint defines the joint to remove
  62199. */
  62200. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62201. /**
  62202. * Called by the scene. No need to call it.
  62203. * @param delta defines the timespam between frames
  62204. */
  62205. _step(delta: number): void;
  62206. /**
  62207. * Gets the current plugin used to run the simulation
  62208. * @returns current plugin
  62209. */
  62210. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62211. /**
  62212. * Gets the list of physic impostors
  62213. * @returns an array of PhysicsImpostor
  62214. */
  62215. getImpostors(): Array<PhysicsImpostor>;
  62216. /**
  62217. * Gets the impostor for a physics enabled object
  62218. * @param object defines the object impersonated by the impostor
  62219. * @returns the PhysicsImpostor or null if not found
  62220. */
  62221. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62222. /**
  62223. * Gets the impostor for a physics body object
  62224. * @param body defines physics body used by the impostor
  62225. * @returns the PhysicsImpostor or null if not found
  62226. */
  62227. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62228. /**
  62229. * Does a raycast in the physics world
  62230. * @param from when should the ray start?
  62231. * @param to when should the ray end?
  62232. * @returns PhysicsRaycastResult
  62233. */
  62234. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62235. }
  62236. }
  62237. declare module BABYLON {
  62238. /** @hidden */
  62239. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62240. private _useDeltaForWorldStep;
  62241. world: any;
  62242. name: string;
  62243. private _physicsMaterials;
  62244. private _fixedTimeStep;
  62245. private _cannonRaycastResult;
  62246. private _raycastResult;
  62247. private _physicsBodysToRemoveAfterStep;
  62248. private _firstFrame;
  62249. BJSCANNON: any;
  62250. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62251. setGravity(gravity: Vector3): void;
  62252. setTimeStep(timeStep: number): void;
  62253. getTimeStep(): number;
  62254. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62255. private _removeMarkedPhysicsBodiesFromWorld;
  62256. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62257. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62258. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62259. private _processChildMeshes;
  62260. removePhysicsBody(impostor: PhysicsImpostor): void;
  62261. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62262. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62263. private _addMaterial;
  62264. private _checkWithEpsilon;
  62265. private _createShape;
  62266. private _createHeightmap;
  62267. private _minus90X;
  62268. private _plus90X;
  62269. private _tmpPosition;
  62270. private _tmpDeltaPosition;
  62271. private _tmpUnityRotation;
  62272. private _updatePhysicsBodyTransformation;
  62273. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62274. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62275. isSupported(): boolean;
  62276. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62277. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62278. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62279. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62280. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62281. getBodyMass(impostor: PhysicsImpostor): number;
  62282. getBodyFriction(impostor: PhysicsImpostor): number;
  62283. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62284. getBodyRestitution(impostor: PhysicsImpostor): number;
  62285. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62286. sleepBody(impostor: PhysicsImpostor): void;
  62287. wakeUpBody(impostor: PhysicsImpostor): void;
  62288. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62289. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62290. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62291. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62292. getRadius(impostor: PhysicsImpostor): number;
  62293. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62294. dispose(): void;
  62295. private _extendNamespace;
  62296. /**
  62297. * Does a raycast in the physics world
  62298. * @param from when should the ray start?
  62299. * @param to when should the ray end?
  62300. * @returns PhysicsRaycastResult
  62301. */
  62302. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62303. }
  62304. }
  62305. declare module BABYLON {
  62306. /** @hidden */
  62307. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62308. private _useDeltaForWorldStep;
  62309. world: any;
  62310. name: string;
  62311. BJSOIMO: any;
  62312. private _raycastResult;
  62313. private _fixedTimeStep;
  62314. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62315. setGravity(gravity: Vector3): void;
  62316. setTimeStep(timeStep: number): void;
  62317. getTimeStep(): number;
  62318. private _tmpImpostorsArray;
  62319. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62320. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62321. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62322. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62323. private _tmpPositionVector;
  62324. removePhysicsBody(impostor: PhysicsImpostor): void;
  62325. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62326. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62327. isSupported(): boolean;
  62328. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62329. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62330. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62331. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62332. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62333. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62334. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62335. getBodyMass(impostor: PhysicsImpostor): number;
  62336. getBodyFriction(impostor: PhysicsImpostor): number;
  62337. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62338. getBodyRestitution(impostor: PhysicsImpostor): number;
  62339. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62340. sleepBody(impostor: PhysicsImpostor): void;
  62341. wakeUpBody(impostor: PhysicsImpostor): void;
  62342. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62343. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62344. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62345. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62346. getRadius(impostor: PhysicsImpostor): number;
  62347. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62348. dispose(): void;
  62349. /**
  62350. * Does a raycast in the physics world
  62351. * @param from when should the ray start?
  62352. * @param to when should the ray end?
  62353. * @returns PhysicsRaycastResult
  62354. */
  62355. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62356. }
  62357. }
  62358. declare module BABYLON {
  62359. /**
  62360. * AmmoJS Physics plugin
  62361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62362. * @see https://github.com/kripken/ammo.js/
  62363. */
  62364. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62365. private _useDeltaForWorldStep;
  62366. /**
  62367. * Reference to the Ammo library
  62368. */
  62369. bjsAMMO: any;
  62370. /**
  62371. * Created ammoJS world which physics bodies are added to
  62372. */
  62373. world: any;
  62374. /**
  62375. * Name of the plugin
  62376. */
  62377. name: string;
  62378. private _timeStep;
  62379. private _fixedTimeStep;
  62380. private _maxSteps;
  62381. private _tmpQuaternion;
  62382. private _tmpAmmoTransform;
  62383. private _tmpAmmoQuaternion;
  62384. private _tmpAmmoConcreteContactResultCallback;
  62385. private _collisionConfiguration;
  62386. private _dispatcher;
  62387. private _overlappingPairCache;
  62388. private _solver;
  62389. private _softBodySolver;
  62390. private _tmpAmmoVectorA;
  62391. private _tmpAmmoVectorB;
  62392. private _tmpAmmoVectorC;
  62393. private _tmpAmmoVectorD;
  62394. private _tmpContactCallbackResult;
  62395. private _tmpAmmoVectorRCA;
  62396. private _tmpAmmoVectorRCB;
  62397. private _raycastResult;
  62398. private _tmpContactPoint;
  62399. private static readonly DISABLE_COLLISION_FLAG;
  62400. private static readonly KINEMATIC_FLAG;
  62401. private static readonly DISABLE_DEACTIVATION_FLAG;
  62402. /**
  62403. * Initializes the ammoJS plugin
  62404. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62405. * @param ammoInjection can be used to inject your own ammo reference
  62406. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62407. */
  62408. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62409. /**
  62410. * Sets the gravity of the physics world (m/(s^2))
  62411. * @param gravity Gravity to set
  62412. */
  62413. setGravity(gravity: Vector3): void;
  62414. /**
  62415. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62416. * @param timeStep timestep to use in seconds
  62417. */
  62418. setTimeStep(timeStep: number): void;
  62419. /**
  62420. * 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)
  62421. * @param fixedTimeStep fixedTimeStep to use in seconds
  62422. */
  62423. setFixedTimeStep(fixedTimeStep: number): void;
  62424. /**
  62425. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62426. * @param maxSteps the maximum number of steps by the physics engine per frame
  62427. */
  62428. setMaxSteps(maxSteps: number): void;
  62429. /**
  62430. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62431. * @returns the current timestep in seconds
  62432. */
  62433. getTimeStep(): number;
  62434. /**
  62435. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62436. */
  62437. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62438. private _isImpostorInContact;
  62439. private _isImpostorPairInContact;
  62440. private _stepSimulation;
  62441. /**
  62442. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62443. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62444. * After the step the babylon meshes are set to the position of the physics imposters
  62445. * @param delta amount of time to step forward
  62446. * @param impostors array of imposters to update before/after the step
  62447. */
  62448. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62449. /**
  62450. * Update babylon mesh to match physics world object
  62451. * @param impostor imposter to match
  62452. */
  62453. private _afterSoftStep;
  62454. /**
  62455. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62456. * @param impostor imposter to match
  62457. */
  62458. private _ropeStep;
  62459. /**
  62460. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62461. * @param impostor imposter to match
  62462. */
  62463. private _softbodyOrClothStep;
  62464. private _tmpMatrix;
  62465. /**
  62466. * Applies an impulse on the imposter
  62467. * @param impostor imposter to apply impulse to
  62468. * @param force amount of force to be applied to the imposter
  62469. * @param contactPoint the location to apply the impulse on the imposter
  62470. */
  62471. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62472. /**
  62473. * Applies a force on the imposter
  62474. * @param impostor imposter to apply force
  62475. * @param force amount of force to be applied to the imposter
  62476. * @param contactPoint the location to apply the force on the imposter
  62477. */
  62478. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62479. /**
  62480. * Creates a physics body using the plugin
  62481. * @param impostor the imposter to create the physics body on
  62482. */
  62483. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62484. /**
  62485. * Removes the physics body from the imposter and disposes of the body's memory
  62486. * @param impostor imposter to remove the physics body from
  62487. */
  62488. removePhysicsBody(impostor: PhysicsImpostor): void;
  62489. /**
  62490. * Generates a joint
  62491. * @param impostorJoint the imposter joint to create the joint with
  62492. */
  62493. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62494. /**
  62495. * Removes a joint
  62496. * @param impostorJoint the imposter joint to remove the joint from
  62497. */
  62498. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62499. private _addMeshVerts;
  62500. /**
  62501. * Initialise the soft body vertices to match its object's (mesh) vertices
  62502. * Softbody vertices (nodes) are in world space and to match this
  62503. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62504. * @param impostor to create the softbody for
  62505. */
  62506. private _softVertexData;
  62507. /**
  62508. * Create an impostor's soft body
  62509. * @param impostor to create the softbody for
  62510. */
  62511. private _createSoftbody;
  62512. /**
  62513. * Create cloth for an impostor
  62514. * @param impostor to create the softbody for
  62515. */
  62516. private _createCloth;
  62517. /**
  62518. * Create rope for an impostor
  62519. * @param impostor to create the softbody for
  62520. */
  62521. private _createRope;
  62522. /**
  62523. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62524. * @param impostor to create the custom physics shape for
  62525. */
  62526. private _createCustom;
  62527. private _addHullVerts;
  62528. private _createShape;
  62529. /**
  62530. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62531. * @param impostor imposter containing the physics body and babylon object
  62532. */
  62533. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62534. /**
  62535. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62536. * @param impostor imposter containing the physics body and babylon object
  62537. * @param newPosition new position
  62538. * @param newRotation new rotation
  62539. */
  62540. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62541. /**
  62542. * If this plugin is supported
  62543. * @returns true if its supported
  62544. */
  62545. isSupported(): boolean;
  62546. /**
  62547. * Sets the linear velocity of the physics body
  62548. * @param impostor imposter to set the velocity on
  62549. * @param velocity velocity to set
  62550. */
  62551. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62552. /**
  62553. * Sets the angular velocity of the physics body
  62554. * @param impostor imposter to set the velocity on
  62555. * @param velocity velocity to set
  62556. */
  62557. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62558. /**
  62559. * gets the linear velocity
  62560. * @param impostor imposter to get linear velocity from
  62561. * @returns linear velocity
  62562. */
  62563. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62564. /**
  62565. * gets the angular velocity
  62566. * @param impostor imposter to get angular velocity from
  62567. * @returns angular velocity
  62568. */
  62569. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62570. /**
  62571. * Sets the mass of physics body
  62572. * @param impostor imposter to set the mass on
  62573. * @param mass mass to set
  62574. */
  62575. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62576. /**
  62577. * Gets the mass of the physics body
  62578. * @param impostor imposter to get the mass from
  62579. * @returns mass
  62580. */
  62581. getBodyMass(impostor: PhysicsImpostor): number;
  62582. /**
  62583. * Gets friction of the impostor
  62584. * @param impostor impostor to get friction from
  62585. * @returns friction value
  62586. */
  62587. getBodyFriction(impostor: PhysicsImpostor): number;
  62588. /**
  62589. * Sets friction of the impostor
  62590. * @param impostor impostor to set friction on
  62591. * @param friction friction value
  62592. */
  62593. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62594. /**
  62595. * Gets restitution of the impostor
  62596. * @param impostor impostor to get restitution from
  62597. * @returns restitution value
  62598. */
  62599. getBodyRestitution(impostor: PhysicsImpostor): number;
  62600. /**
  62601. * Sets resitution of the impostor
  62602. * @param impostor impostor to set resitution on
  62603. * @param restitution resitution value
  62604. */
  62605. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62606. /**
  62607. * Gets pressure inside the impostor
  62608. * @param impostor impostor to get pressure from
  62609. * @returns pressure value
  62610. */
  62611. getBodyPressure(impostor: PhysicsImpostor): number;
  62612. /**
  62613. * Sets pressure inside a soft body impostor
  62614. * Cloth and rope must remain 0 pressure
  62615. * @param impostor impostor to set pressure on
  62616. * @param pressure pressure value
  62617. */
  62618. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62619. /**
  62620. * Gets stiffness of the impostor
  62621. * @param impostor impostor to get stiffness from
  62622. * @returns pressure value
  62623. */
  62624. getBodyStiffness(impostor: PhysicsImpostor): number;
  62625. /**
  62626. * Sets stiffness of the impostor
  62627. * @param impostor impostor to set stiffness on
  62628. * @param stiffness stiffness value from 0 to 1
  62629. */
  62630. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62631. /**
  62632. * Gets velocityIterations of the impostor
  62633. * @param impostor impostor to get velocity iterations from
  62634. * @returns velocityIterations value
  62635. */
  62636. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62637. /**
  62638. * Sets velocityIterations of the impostor
  62639. * @param impostor impostor to set velocity iterations on
  62640. * @param velocityIterations velocityIterations value
  62641. */
  62642. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62643. /**
  62644. * Gets positionIterations of the impostor
  62645. * @param impostor impostor to get position iterations from
  62646. * @returns positionIterations value
  62647. */
  62648. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62649. /**
  62650. * Sets positionIterations of the impostor
  62651. * @param impostor impostor to set position on
  62652. * @param positionIterations positionIterations value
  62653. */
  62654. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62655. /**
  62656. * Append an anchor to a cloth object
  62657. * @param impostor is the cloth impostor to add anchor to
  62658. * @param otherImpostor is the rigid impostor to anchor to
  62659. * @param width ratio across width from 0 to 1
  62660. * @param height ratio up height from 0 to 1
  62661. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62662. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62663. */
  62664. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62665. /**
  62666. * Append an hook to a rope object
  62667. * @param impostor is the rope impostor to add hook to
  62668. * @param otherImpostor is the rigid impostor to hook to
  62669. * @param length ratio along the rope from 0 to 1
  62670. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62671. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62672. */
  62673. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62674. /**
  62675. * Sleeps the physics body and stops it from being active
  62676. * @param impostor impostor to sleep
  62677. */
  62678. sleepBody(impostor: PhysicsImpostor): void;
  62679. /**
  62680. * Activates the physics body
  62681. * @param impostor impostor to activate
  62682. */
  62683. wakeUpBody(impostor: PhysicsImpostor): void;
  62684. /**
  62685. * Updates the distance parameters of the joint
  62686. * @param joint joint to update
  62687. * @param maxDistance maximum distance of the joint
  62688. * @param minDistance minimum distance of the joint
  62689. */
  62690. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62691. /**
  62692. * Sets a motor on the joint
  62693. * @param joint joint to set motor on
  62694. * @param speed speed of the motor
  62695. * @param maxForce maximum force of the motor
  62696. * @param motorIndex index of the motor
  62697. */
  62698. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62699. /**
  62700. * Sets the motors limit
  62701. * @param joint joint to set limit on
  62702. * @param upperLimit upper limit
  62703. * @param lowerLimit lower limit
  62704. */
  62705. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62706. /**
  62707. * Syncs the position and rotation of a mesh with the impostor
  62708. * @param mesh mesh to sync
  62709. * @param impostor impostor to update the mesh with
  62710. */
  62711. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62712. /**
  62713. * Gets the radius of the impostor
  62714. * @param impostor impostor to get radius from
  62715. * @returns the radius
  62716. */
  62717. getRadius(impostor: PhysicsImpostor): number;
  62718. /**
  62719. * Gets the box size of the impostor
  62720. * @param impostor impostor to get box size from
  62721. * @param result the resulting box size
  62722. */
  62723. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62724. /**
  62725. * Disposes of the impostor
  62726. */
  62727. dispose(): void;
  62728. /**
  62729. * Does a raycast in the physics world
  62730. * @param from when should the ray start?
  62731. * @param to when should the ray end?
  62732. * @returns PhysicsRaycastResult
  62733. */
  62734. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62735. }
  62736. }
  62737. declare module BABYLON {
  62738. interface AbstractScene {
  62739. /**
  62740. * The list of reflection probes added to the scene
  62741. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62742. */
  62743. reflectionProbes: Array<ReflectionProbe>;
  62744. /**
  62745. * Removes the given reflection probe from this scene.
  62746. * @param toRemove The reflection probe to remove
  62747. * @returns The index of the removed reflection probe
  62748. */
  62749. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62750. /**
  62751. * Adds the given reflection probe to this scene.
  62752. * @param newReflectionProbe The reflection probe to add
  62753. */
  62754. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62755. }
  62756. /**
  62757. * Class used to generate realtime reflection / refraction cube textures
  62758. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62759. */
  62760. export class ReflectionProbe {
  62761. /** defines the name of the probe */
  62762. name: string;
  62763. private _scene;
  62764. private _renderTargetTexture;
  62765. private _projectionMatrix;
  62766. private _viewMatrix;
  62767. private _target;
  62768. private _add;
  62769. private _attachedMesh;
  62770. private _invertYAxis;
  62771. /** Gets or sets probe position (center of the cube map) */
  62772. position: Vector3;
  62773. /**
  62774. * Creates a new reflection probe
  62775. * @param name defines the name of the probe
  62776. * @param size defines the texture resolution (for each face)
  62777. * @param scene defines the hosting scene
  62778. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62779. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62780. */
  62781. constructor(
  62782. /** defines the name of the probe */
  62783. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62784. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62785. get samples(): number;
  62786. set samples(value: number);
  62787. /** Gets or sets the refresh rate to use (on every frame by default) */
  62788. get refreshRate(): number;
  62789. set refreshRate(value: number);
  62790. /**
  62791. * Gets the hosting scene
  62792. * @returns a Scene
  62793. */
  62794. getScene(): Scene;
  62795. /** Gets the internal CubeTexture used to render to */
  62796. get cubeTexture(): RenderTargetTexture;
  62797. /** Gets the list of meshes to render */
  62798. get renderList(): Nullable<AbstractMesh[]>;
  62799. /**
  62800. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62801. * @param mesh defines the mesh to attach to
  62802. */
  62803. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62804. /**
  62805. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62806. * @param renderingGroupId The rendering group id corresponding to its index
  62807. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62808. */
  62809. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62810. /**
  62811. * Clean all associated resources
  62812. */
  62813. dispose(): void;
  62814. /**
  62815. * Converts the reflection probe information to a readable string for debug purpose.
  62816. * @param fullDetails Supports for multiple levels of logging within scene loading
  62817. * @returns the human readable reflection probe info
  62818. */
  62819. toString(fullDetails?: boolean): string;
  62820. /**
  62821. * Get the class name of the relfection probe.
  62822. * @returns "ReflectionProbe"
  62823. */
  62824. getClassName(): string;
  62825. /**
  62826. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62827. * @returns The JSON representation of the texture
  62828. */
  62829. serialize(): any;
  62830. /**
  62831. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62832. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62833. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62834. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62835. * @returns The parsed reflection probe if successful
  62836. */
  62837. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62838. }
  62839. }
  62840. declare module BABYLON {
  62841. /** @hidden */
  62842. export var _BabylonLoaderRegistered: boolean;
  62843. /**
  62844. * Helps setting up some configuration for the babylon file loader.
  62845. */
  62846. export class BabylonFileLoaderConfiguration {
  62847. /**
  62848. * The loader does not allow injecting custom physix engine into the plugins.
  62849. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62850. * So you could set this variable to your engine import to make it work.
  62851. */
  62852. static LoaderInjectedPhysicsEngine: any;
  62853. }
  62854. }
  62855. declare module BABYLON {
  62856. /**
  62857. * A material to use for fast depth-only rendering.
  62858. */
  62859. export class OcclusionMaterial extends ShaderMaterial {
  62860. constructor(name: string, scene: Scene);
  62861. }
  62862. }
  62863. declare module BABYLON {
  62864. /**
  62865. * The Physically based simple base material of BJS.
  62866. *
  62867. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62868. * It is used as the base class for both the specGloss and metalRough conventions.
  62869. */
  62870. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62871. /**
  62872. * Number of Simultaneous lights allowed on the material.
  62873. */
  62874. maxSimultaneousLights: number;
  62875. /**
  62876. * If sets to true, disables all the lights affecting the material.
  62877. */
  62878. disableLighting: boolean;
  62879. /**
  62880. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62881. */
  62882. environmentTexture: BaseTexture;
  62883. /**
  62884. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62885. */
  62886. invertNormalMapX: boolean;
  62887. /**
  62888. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62889. */
  62890. invertNormalMapY: boolean;
  62891. /**
  62892. * Normal map used in the model.
  62893. */
  62894. normalTexture: BaseTexture;
  62895. /**
  62896. * Emissivie color used to self-illuminate the model.
  62897. */
  62898. emissiveColor: Color3;
  62899. /**
  62900. * Emissivie texture used to self-illuminate the model.
  62901. */
  62902. emissiveTexture: BaseTexture;
  62903. /**
  62904. * Occlusion Channel Strenght.
  62905. */
  62906. occlusionStrength: number;
  62907. /**
  62908. * Occlusion Texture of the material (adding extra occlusion effects).
  62909. */
  62910. occlusionTexture: BaseTexture;
  62911. /**
  62912. * Defines the alpha limits in alpha test mode.
  62913. */
  62914. alphaCutOff: number;
  62915. /**
  62916. * Gets the current double sided mode.
  62917. */
  62918. get doubleSided(): boolean;
  62919. /**
  62920. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62921. */
  62922. set doubleSided(value: boolean);
  62923. /**
  62924. * Stores the pre-calculated light information of a mesh in a texture.
  62925. */
  62926. lightmapTexture: BaseTexture;
  62927. /**
  62928. * If true, the light map contains occlusion information instead of lighting info.
  62929. */
  62930. useLightmapAsShadowmap: boolean;
  62931. /**
  62932. * Instantiates a new PBRMaterial instance.
  62933. *
  62934. * @param name The material name
  62935. * @param scene The scene the material will be use in.
  62936. */
  62937. constructor(name: string, scene: Scene);
  62938. getClassName(): string;
  62939. }
  62940. }
  62941. declare module BABYLON {
  62942. /**
  62943. * The PBR material of BJS following the metal roughness convention.
  62944. *
  62945. * This fits to the PBR convention in the GLTF definition:
  62946. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62947. */
  62948. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62949. /**
  62950. * The base color has two different interpretations depending on the value of metalness.
  62951. * When the material is a metal, the base color is the specific measured reflectance value
  62952. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62953. * of the material.
  62954. */
  62955. baseColor: Color3;
  62956. /**
  62957. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62958. * well as opacity information in the alpha channel.
  62959. */
  62960. baseTexture: BaseTexture;
  62961. /**
  62962. * Specifies the metallic scalar value of the material.
  62963. * Can also be used to scale the metalness values of the metallic texture.
  62964. */
  62965. metallic: number;
  62966. /**
  62967. * Specifies the roughness scalar value of the material.
  62968. * Can also be used to scale the roughness values of the metallic texture.
  62969. */
  62970. roughness: number;
  62971. /**
  62972. * Texture containing both the metallic value in the B channel and the
  62973. * roughness value in the G channel to keep better precision.
  62974. */
  62975. metallicRoughnessTexture: BaseTexture;
  62976. /**
  62977. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62978. *
  62979. * @param name The material name
  62980. * @param scene The scene the material will be use in.
  62981. */
  62982. constructor(name: string, scene: Scene);
  62983. /**
  62984. * Return the currrent class name of the material.
  62985. */
  62986. getClassName(): string;
  62987. /**
  62988. * Makes a duplicate of the current material.
  62989. * @param name - name to use for the new material.
  62990. */
  62991. clone(name: string): PBRMetallicRoughnessMaterial;
  62992. /**
  62993. * Serialize the material to a parsable JSON object.
  62994. */
  62995. serialize(): any;
  62996. /**
  62997. * Parses a JSON object correponding to the serialize function.
  62998. */
  62999. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63000. }
  63001. }
  63002. declare module BABYLON {
  63003. /**
  63004. * The PBR material of BJS following the specular glossiness convention.
  63005. *
  63006. * This fits to the PBR convention in the GLTF definition:
  63007. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63008. */
  63009. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63010. /**
  63011. * Specifies the diffuse color of the material.
  63012. */
  63013. diffuseColor: Color3;
  63014. /**
  63015. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63016. * channel.
  63017. */
  63018. diffuseTexture: BaseTexture;
  63019. /**
  63020. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63021. */
  63022. specularColor: Color3;
  63023. /**
  63024. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63025. */
  63026. glossiness: number;
  63027. /**
  63028. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63029. */
  63030. specularGlossinessTexture: BaseTexture;
  63031. /**
  63032. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63033. *
  63034. * @param name The material name
  63035. * @param scene The scene the material will be use in.
  63036. */
  63037. constructor(name: string, scene: Scene);
  63038. /**
  63039. * Return the currrent class name of the material.
  63040. */
  63041. getClassName(): string;
  63042. /**
  63043. * Makes a duplicate of the current material.
  63044. * @param name - name to use for the new material.
  63045. */
  63046. clone(name: string): PBRSpecularGlossinessMaterial;
  63047. /**
  63048. * Serialize the material to a parsable JSON object.
  63049. */
  63050. serialize(): any;
  63051. /**
  63052. * Parses a JSON object correponding to the serialize function.
  63053. */
  63054. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63055. }
  63056. }
  63057. declare module BABYLON {
  63058. /**
  63059. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63060. * It can help converting any input color in a desired output one. This can then be used to create effects
  63061. * from sepia, black and white to sixties or futuristic rendering...
  63062. *
  63063. * The only supported format is currently 3dl.
  63064. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63065. */
  63066. export class ColorGradingTexture extends BaseTexture {
  63067. /**
  63068. * The texture URL.
  63069. */
  63070. url: string;
  63071. /**
  63072. * Empty line regex stored for GC.
  63073. */
  63074. private static _noneEmptyLineRegex;
  63075. private _textureMatrix;
  63076. private _onLoad;
  63077. /**
  63078. * Instantiates a ColorGradingTexture from the following parameters.
  63079. *
  63080. * @param url The location of the color gradind data (currently only supporting 3dl)
  63081. * @param sceneOrEngine The scene or engine the texture will be used in
  63082. * @param onLoad defines a callback triggered when the texture has been loaded
  63083. */
  63084. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63085. /**
  63086. * Fires the onload event from the constructor if requested.
  63087. */
  63088. private _triggerOnLoad;
  63089. /**
  63090. * Returns the texture matrix used in most of the material.
  63091. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63092. */
  63093. getTextureMatrix(): Matrix;
  63094. /**
  63095. * Occurs when the file being loaded is a .3dl LUT file.
  63096. */
  63097. private load3dlTexture;
  63098. /**
  63099. * Starts the loading process of the texture.
  63100. */
  63101. private loadTexture;
  63102. /**
  63103. * Clones the color gradind texture.
  63104. */
  63105. clone(): ColorGradingTexture;
  63106. /**
  63107. * Called during delayed load for textures.
  63108. */
  63109. delayLoad(): void;
  63110. /**
  63111. * Parses a color grading texture serialized by Babylon.
  63112. * @param parsedTexture The texture information being parsedTexture
  63113. * @param scene The scene to load the texture in
  63114. * @param rootUrl The root url of the data assets to load
  63115. * @return A color gradind texture
  63116. */
  63117. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63118. /**
  63119. * Serializes the LUT texture to json format.
  63120. */
  63121. serialize(): any;
  63122. }
  63123. }
  63124. declare module BABYLON {
  63125. /**
  63126. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63127. */
  63128. export class EquiRectangularCubeTexture extends BaseTexture {
  63129. /** The six faces of the cube. */
  63130. private static _FacesMapping;
  63131. private _noMipmap;
  63132. private _onLoad;
  63133. private _onError;
  63134. /** The size of the cubemap. */
  63135. private _size;
  63136. /** The buffer of the image. */
  63137. private _buffer;
  63138. /** The width of the input image. */
  63139. private _width;
  63140. /** The height of the input image. */
  63141. private _height;
  63142. /** The URL to the image. */
  63143. url: string;
  63144. /**
  63145. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63146. * @param url The location of the image
  63147. * @param scene The scene the texture will be used in
  63148. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63149. * @param noMipmap Forces to not generate the mipmap if true
  63150. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63151. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63152. * @param onLoad — defines a callback called when texture is loaded
  63153. * @param onError — defines a callback called if there is an error
  63154. */
  63155. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63156. /**
  63157. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63158. */
  63159. private loadImage;
  63160. /**
  63161. * Convert the image buffer into a cubemap and create a CubeTexture.
  63162. */
  63163. private loadTexture;
  63164. /**
  63165. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63166. * @param buffer The ArrayBuffer that should be converted.
  63167. * @returns The buffer as Float32Array.
  63168. */
  63169. private getFloat32ArrayFromArrayBuffer;
  63170. /**
  63171. * Get the current class name of the texture useful for serialization or dynamic coding.
  63172. * @returns "EquiRectangularCubeTexture"
  63173. */
  63174. getClassName(): string;
  63175. /**
  63176. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63177. * @returns A clone of the current EquiRectangularCubeTexture.
  63178. */
  63179. clone(): EquiRectangularCubeTexture;
  63180. }
  63181. }
  63182. declare module BABYLON {
  63183. /**
  63184. * Defines the options related to the creation of an HtmlElementTexture
  63185. */
  63186. export interface IHtmlElementTextureOptions {
  63187. /**
  63188. * Defines wether mip maps should be created or not.
  63189. */
  63190. generateMipMaps?: boolean;
  63191. /**
  63192. * Defines the sampling mode of the texture.
  63193. */
  63194. samplingMode?: number;
  63195. /**
  63196. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63197. */
  63198. engine: Nullable<ThinEngine>;
  63199. /**
  63200. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63201. */
  63202. scene: Nullable<Scene>;
  63203. }
  63204. /**
  63205. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63206. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63207. * is automatically managed.
  63208. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63209. * in your application.
  63210. *
  63211. * As the update is not automatic, you need to call them manually.
  63212. */
  63213. export class HtmlElementTexture extends BaseTexture {
  63214. /**
  63215. * The texture URL.
  63216. */
  63217. element: HTMLVideoElement | HTMLCanvasElement;
  63218. private static readonly DefaultOptions;
  63219. private _textureMatrix;
  63220. private _isVideo;
  63221. private _generateMipMaps;
  63222. private _samplingMode;
  63223. /**
  63224. * Instantiates a HtmlElementTexture from the following parameters.
  63225. *
  63226. * @param name Defines the name of the texture
  63227. * @param element Defines the video or canvas the texture is filled with
  63228. * @param options Defines the other none mandatory texture creation options
  63229. */
  63230. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63231. private _createInternalTexture;
  63232. /**
  63233. * Returns the texture matrix used in most of the material.
  63234. */
  63235. getTextureMatrix(): Matrix;
  63236. /**
  63237. * Updates the content of the texture.
  63238. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63239. */
  63240. update(invertY?: Nullable<boolean>): void;
  63241. }
  63242. }
  63243. declare module BABYLON {
  63244. /**
  63245. * Based on jsTGALoader - Javascript loader for TGA file
  63246. * By Vincent Thibault
  63247. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63248. */
  63249. export class TGATools {
  63250. private static _TYPE_INDEXED;
  63251. private static _TYPE_RGB;
  63252. private static _TYPE_GREY;
  63253. private static _TYPE_RLE_INDEXED;
  63254. private static _TYPE_RLE_RGB;
  63255. private static _TYPE_RLE_GREY;
  63256. private static _ORIGIN_MASK;
  63257. private static _ORIGIN_SHIFT;
  63258. private static _ORIGIN_BL;
  63259. private static _ORIGIN_BR;
  63260. private static _ORIGIN_UL;
  63261. private static _ORIGIN_UR;
  63262. /**
  63263. * Gets the header of a TGA file
  63264. * @param data defines the TGA data
  63265. * @returns the header
  63266. */
  63267. static GetTGAHeader(data: Uint8Array): any;
  63268. /**
  63269. * Uploads TGA content to a Babylon Texture
  63270. * @hidden
  63271. */
  63272. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63273. /** @hidden */
  63274. 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;
  63275. /** @hidden */
  63276. 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;
  63277. /** @hidden */
  63278. 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;
  63279. /** @hidden */
  63280. 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;
  63281. /** @hidden */
  63282. 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;
  63283. /** @hidden */
  63284. 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;
  63285. }
  63286. }
  63287. declare module BABYLON {
  63288. /**
  63289. * Implementation of the TGA Texture Loader.
  63290. * @hidden
  63291. */
  63292. export class _TGATextureLoader implements IInternalTextureLoader {
  63293. /**
  63294. * Defines wether the loader supports cascade loading the different faces.
  63295. */
  63296. readonly supportCascades: boolean;
  63297. /**
  63298. * This returns if the loader support the current file information.
  63299. * @param extension defines the file extension of the file being loaded
  63300. * @returns true if the loader can load the specified file
  63301. */
  63302. canLoad(extension: string): boolean;
  63303. /**
  63304. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63305. * @param data contains the texture data
  63306. * @param texture defines the BabylonJS internal texture
  63307. * @param createPolynomials will be true if polynomials have been requested
  63308. * @param onLoad defines the callback to trigger once the texture is ready
  63309. * @param onError defines the callback to trigger in case of error
  63310. */
  63311. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63312. /**
  63313. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63314. * @param data contains the texture data
  63315. * @param texture defines the BabylonJS internal texture
  63316. * @param callback defines the method to call once ready to upload
  63317. */
  63318. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63319. }
  63320. }
  63321. declare module BABYLON {
  63322. /**
  63323. * Info about the .basis files
  63324. */
  63325. class BasisFileInfo {
  63326. /**
  63327. * If the file has alpha
  63328. */
  63329. hasAlpha: boolean;
  63330. /**
  63331. * Info about each image of the basis file
  63332. */
  63333. images: Array<{
  63334. levels: Array<{
  63335. width: number;
  63336. height: number;
  63337. transcodedPixels: ArrayBufferView;
  63338. }>;
  63339. }>;
  63340. }
  63341. /**
  63342. * Result of transcoding a basis file
  63343. */
  63344. class TranscodeResult {
  63345. /**
  63346. * Info about the .basis file
  63347. */
  63348. fileInfo: BasisFileInfo;
  63349. /**
  63350. * Format to use when loading the file
  63351. */
  63352. format: number;
  63353. }
  63354. /**
  63355. * Configuration options for the Basis transcoder
  63356. */
  63357. export class BasisTranscodeConfiguration {
  63358. /**
  63359. * Supported compression formats used to determine the supported output format of the transcoder
  63360. */
  63361. supportedCompressionFormats?: {
  63362. /**
  63363. * etc1 compression format
  63364. */
  63365. etc1?: boolean;
  63366. /**
  63367. * s3tc compression format
  63368. */
  63369. s3tc?: boolean;
  63370. /**
  63371. * pvrtc compression format
  63372. */
  63373. pvrtc?: boolean;
  63374. /**
  63375. * etc2 compression format
  63376. */
  63377. etc2?: boolean;
  63378. };
  63379. /**
  63380. * If mipmap levels should be loaded for transcoded images (Default: true)
  63381. */
  63382. loadMipmapLevels?: boolean;
  63383. /**
  63384. * Index of a single image to load (Default: all images)
  63385. */
  63386. loadSingleImage?: number;
  63387. }
  63388. /**
  63389. * Used to load .Basis files
  63390. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63391. */
  63392. export class BasisTools {
  63393. private static _IgnoreSupportedFormats;
  63394. /**
  63395. * URL to use when loading the basis transcoder
  63396. */
  63397. static JSModuleURL: string;
  63398. /**
  63399. * URL to use when loading the wasm module for the transcoder
  63400. */
  63401. static WasmModuleURL: string;
  63402. /**
  63403. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63404. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63405. * @returns internal format corresponding to the Basis format
  63406. */
  63407. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63408. private static _WorkerPromise;
  63409. private static _Worker;
  63410. private static _actionId;
  63411. private static _CreateWorkerAsync;
  63412. /**
  63413. * Transcodes a loaded image file to compressed pixel data
  63414. * @param data image data to transcode
  63415. * @param config configuration options for the transcoding
  63416. * @returns a promise resulting in the transcoded image
  63417. */
  63418. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63419. /**
  63420. * Loads a texture from the transcode result
  63421. * @param texture texture load to
  63422. * @param transcodeResult the result of transcoding the basis file to load from
  63423. */
  63424. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63425. }
  63426. }
  63427. declare module BABYLON {
  63428. /**
  63429. * Loader for .basis file format
  63430. */
  63431. export class _BasisTextureLoader implements IInternalTextureLoader {
  63432. /**
  63433. * Defines whether the loader supports cascade loading the different faces.
  63434. */
  63435. readonly supportCascades: boolean;
  63436. /**
  63437. * This returns if the loader support the current file information.
  63438. * @param extension defines the file extension of the file being loaded
  63439. * @returns true if the loader can load the specified file
  63440. */
  63441. canLoad(extension: string): boolean;
  63442. /**
  63443. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63444. * @param data contains the texture data
  63445. * @param texture defines the BabylonJS internal texture
  63446. * @param createPolynomials will be true if polynomials have been requested
  63447. * @param onLoad defines the callback to trigger once the texture is ready
  63448. * @param onError defines the callback to trigger in case of error
  63449. */
  63450. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63451. /**
  63452. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63453. * @param data contains the texture data
  63454. * @param texture defines the BabylonJS internal texture
  63455. * @param callback defines the method to call once ready to upload
  63456. */
  63457. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63458. }
  63459. }
  63460. declare module BABYLON {
  63461. /**
  63462. * Defines the basic options interface of a TexturePacker Frame
  63463. */
  63464. export interface ITexturePackerFrame {
  63465. /**
  63466. * The frame ID
  63467. */
  63468. id: number;
  63469. /**
  63470. * The frames Scale
  63471. */
  63472. scale: Vector2;
  63473. /**
  63474. * The Frames offset
  63475. */
  63476. offset: Vector2;
  63477. }
  63478. /**
  63479. * This is a support class for frame Data on texture packer sets.
  63480. */
  63481. export class TexturePackerFrame implements ITexturePackerFrame {
  63482. /**
  63483. * The frame ID
  63484. */
  63485. id: number;
  63486. /**
  63487. * The frames Scale
  63488. */
  63489. scale: Vector2;
  63490. /**
  63491. * The Frames offset
  63492. */
  63493. offset: Vector2;
  63494. /**
  63495. * Initializes a texture package frame.
  63496. * @param id The numerical frame identifier
  63497. * @param scale Scalar Vector2 for UV frame
  63498. * @param offset Vector2 for the frame position in UV units.
  63499. * @returns TexturePackerFrame
  63500. */
  63501. constructor(id: number, scale: Vector2, offset: Vector2);
  63502. }
  63503. }
  63504. declare module BABYLON {
  63505. /**
  63506. * Defines the basic options interface of a TexturePacker
  63507. */
  63508. export interface ITexturePackerOptions {
  63509. /**
  63510. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63511. */
  63512. map?: string[];
  63513. /**
  63514. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63515. */
  63516. uvsIn?: string;
  63517. /**
  63518. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63519. */
  63520. uvsOut?: string;
  63521. /**
  63522. * number representing the layout style. Defaults to LAYOUT_STRIP
  63523. */
  63524. layout?: number;
  63525. /**
  63526. * number of columns if using custom column count layout(2). This defaults to 4.
  63527. */
  63528. colnum?: number;
  63529. /**
  63530. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63531. */
  63532. updateInputMeshes?: boolean;
  63533. /**
  63534. * boolean flag to dispose all the source textures. Defaults to true.
  63535. */
  63536. disposeSources?: boolean;
  63537. /**
  63538. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63539. */
  63540. fillBlanks?: boolean;
  63541. /**
  63542. * string value representing the context fill style color. Defaults to 'black'.
  63543. */
  63544. customFillColor?: string;
  63545. /**
  63546. * Width and Height Value of each Frame in the TexturePacker Sets
  63547. */
  63548. frameSize?: number;
  63549. /**
  63550. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63551. */
  63552. paddingRatio?: number;
  63553. /**
  63554. * Number that declares the fill method for the padding gutter.
  63555. */
  63556. paddingMode?: number;
  63557. /**
  63558. * If in SUBUV_COLOR padding mode what color to use.
  63559. */
  63560. paddingColor?: Color3 | Color4;
  63561. }
  63562. /**
  63563. * Defines the basic interface of a TexturePacker JSON File
  63564. */
  63565. export interface ITexturePackerJSON {
  63566. /**
  63567. * The frame ID
  63568. */
  63569. name: string;
  63570. /**
  63571. * The base64 channel data
  63572. */
  63573. sets: any;
  63574. /**
  63575. * The options of the Packer
  63576. */
  63577. options: ITexturePackerOptions;
  63578. /**
  63579. * The frame data of the Packer
  63580. */
  63581. frames: Array<number>;
  63582. }
  63583. /**
  63584. * This is a support class that generates a series of packed texture sets.
  63585. * @see https://doc.babylonjs.com/babylon101/materials
  63586. */
  63587. export class TexturePacker {
  63588. /** Packer Layout Constant 0 */
  63589. static readonly LAYOUT_STRIP: number;
  63590. /** Packer Layout Constant 1 */
  63591. static readonly LAYOUT_POWER2: number;
  63592. /** Packer Layout Constant 2 */
  63593. static readonly LAYOUT_COLNUM: number;
  63594. /** Packer Layout Constant 0 */
  63595. static readonly SUBUV_WRAP: number;
  63596. /** Packer Layout Constant 1 */
  63597. static readonly SUBUV_EXTEND: number;
  63598. /** Packer Layout Constant 2 */
  63599. static readonly SUBUV_COLOR: number;
  63600. /** The Name of the Texture Package */
  63601. name: string;
  63602. /** The scene scope of the TexturePacker */
  63603. scene: Scene;
  63604. /** The Meshes to target */
  63605. meshes: AbstractMesh[];
  63606. /** Arguments passed with the Constructor */
  63607. options: ITexturePackerOptions;
  63608. /** The promise that is started upon initialization */
  63609. promise: Nullable<Promise<TexturePacker | string>>;
  63610. /** The Container object for the channel sets that are generated */
  63611. sets: object;
  63612. /** The Container array for the frames that are generated */
  63613. frames: TexturePackerFrame[];
  63614. /** The expected number of textures the system is parsing. */
  63615. private _expecting;
  63616. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63617. private _paddingValue;
  63618. /**
  63619. * Initializes a texture package series from an array of meshes or a single mesh.
  63620. * @param name The name of the package
  63621. * @param meshes The target meshes to compose the package from
  63622. * @param options The arguments that texture packer should follow while building.
  63623. * @param scene The scene which the textures are scoped to.
  63624. * @returns TexturePacker
  63625. */
  63626. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63627. /**
  63628. * Starts the package process
  63629. * @param resolve The promises resolution function
  63630. * @returns TexturePacker
  63631. */
  63632. private _createFrames;
  63633. /**
  63634. * Calculates the Size of the Channel Sets
  63635. * @returns Vector2
  63636. */
  63637. private _calculateSize;
  63638. /**
  63639. * Calculates the UV data for the frames.
  63640. * @param baseSize the base frameSize
  63641. * @param padding the base frame padding
  63642. * @param dtSize size of the Dynamic Texture for that channel
  63643. * @param dtUnits is 1/dtSize
  63644. * @param update flag to update the input meshes
  63645. */
  63646. private _calculateMeshUVFrames;
  63647. /**
  63648. * Calculates the frames Offset.
  63649. * @param index of the frame
  63650. * @returns Vector2
  63651. */
  63652. private _getFrameOffset;
  63653. /**
  63654. * Updates a Mesh to the frame data
  63655. * @param mesh that is the target
  63656. * @param frameID or the frame index
  63657. */
  63658. private _updateMeshUV;
  63659. /**
  63660. * Updates a Meshes materials to use the texture packer channels
  63661. * @param m is the mesh to target
  63662. * @param force all channels on the packer to be set.
  63663. */
  63664. private _updateTextureReferences;
  63665. /**
  63666. * Public method to set a Mesh to a frame
  63667. * @param m that is the target
  63668. * @param frameID or the frame index
  63669. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63670. */
  63671. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63672. /**
  63673. * Starts the async promise to compile the texture packer.
  63674. * @returns Promise<void>
  63675. */
  63676. processAsync(): Promise<void>;
  63677. /**
  63678. * Disposes all textures associated with this packer
  63679. */
  63680. dispose(): void;
  63681. /**
  63682. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63683. * @param imageType is the image type to use.
  63684. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63685. */
  63686. download(imageType?: string, quality?: number): void;
  63687. /**
  63688. * Public method to load a texturePacker JSON file.
  63689. * @param data of the JSON file in string format.
  63690. */
  63691. updateFromJSON(data: string): void;
  63692. }
  63693. }
  63694. declare module BABYLON {
  63695. /**
  63696. * 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.
  63697. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63698. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63699. */
  63700. export class CustomProceduralTexture extends ProceduralTexture {
  63701. private _animate;
  63702. private _time;
  63703. private _config;
  63704. private _texturePath;
  63705. /**
  63706. * Instantiates a new Custom Procedural Texture.
  63707. * 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.
  63708. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63709. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63710. * @param name Define the name of the texture
  63711. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63712. * @param size Define the size of the texture to create
  63713. * @param scene Define the scene the texture belongs to
  63714. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63715. * @param generateMipMaps Define if the texture should creates mip maps or not
  63716. */
  63717. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63718. private _loadJson;
  63719. /**
  63720. * Is the texture ready to be used ? (rendered at least once)
  63721. * @returns true if ready, otherwise, false.
  63722. */
  63723. isReady(): boolean;
  63724. /**
  63725. * Render the texture to its associated render target.
  63726. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63727. */
  63728. render(useCameraPostProcess?: boolean): void;
  63729. /**
  63730. * Update the list of dependant textures samplers in the shader.
  63731. */
  63732. updateTextures(): void;
  63733. /**
  63734. * Update the uniform values of the procedural texture in the shader.
  63735. */
  63736. updateShaderUniforms(): void;
  63737. /**
  63738. * Define if the texture animates or not.
  63739. */
  63740. get animate(): boolean;
  63741. set animate(value: boolean);
  63742. }
  63743. }
  63744. declare module BABYLON {
  63745. /** @hidden */
  63746. export var noisePixelShader: {
  63747. name: string;
  63748. shader: string;
  63749. };
  63750. }
  63751. declare module BABYLON {
  63752. /**
  63753. * Class used to generate noise procedural textures
  63754. */
  63755. export class NoiseProceduralTexture extends ProceduralTexture {
  63756. /** Gets or sets the start time (default is 0) */
  63757. time: number;
  63758. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63759. brightness: number;
  63760. /** Defines the number of octaves to process */
  63761. octaves: number;
  63762. /** Defines the level of persistence (0.8 by default) */
  63763. persistence: number;
  63764. /** Gets or sets animation speed factor (default is 1) */
  63765. animationSpeedFactor: number;
  63766. /**
  63767. * Creates a new NoiseProceduralTexture
  63768. * @param name defines the name fo the texture
  63769. * @param size defines the size of the texture (default is 256)
  63770. * @param scene defines the hosting scene
  63771. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63772. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63773. */
  63774. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63775. private _updateShaderUniforms;
  63776. protected _getDefines(): string;
  63777. /** Generate the current state of the procedural texture */
  63778. render(useCameraPostProcess?: boolean): void;
  63779. /**
  63780. * Serializes this noise procedural texture
  63781. * @returns a serialized noise procedural texture object
  63782. */
  63783. serialize(): any;
  63784. /**
  63785. * Clone the texture.
  63786. * @returns the cloned texture
  63787. */
  63788. clone(): NoiseProceduralTexture;
  63789. /**
  63790. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63791. * @param parsedTexture defines parsed texture data
  63792. * @param scene defines the current scene
  63793. * @param rootUrl defines the root URL containing noise procedural texture information
  63794. * @returns a parsed NoiseProceduralTexture
  63795. */
  63796. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63797. }
  63798. }
  63799. declare module BABYLON {
  63800. /**
  63801. * Raw cube texture where the raw buffers are passed in
  63802. */
  63803. export class RawCubeTexture extends CubeTexture {
  63804. /**
  63805. * Creates a cube texture where the raw buffers are passed in.
  63806. * @param scene defines the scene the texture is attached to
  63807. * @param data defines the array of data to use to create each face
  63808. * @param size defines the size of the textures
  63809. * @param format defines the format of the data
  63810. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63811. * @param generateMipMaps defines if the engine should generate the mip levels
  63812. * @param invertY defines if data must be stored with Y axis inverted
  63813. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63814. * @param compression defines the compression used (null by default)
  63815. */
  63816. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63817. /**
  63818. * Updates the raw cube texture.
  63819. * @param data defines the data to store
  63820. * @param format defines the data format
  63821. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63822. * @param invertY defines if data must be stored with Y axis inverted
  63823. * @param compression defines the compression used (null by default)
  63824. * @param level defines which level of the texture to update
  63825. */
  63826. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63827. /**
  63828. * Updates a raw cube texture with RGBD encoded data.
  63829. * @param data defines the array of data [mipmap][face] to use to create each face
  63830. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63831. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63832. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63833. * @returns a promsie that resolves when the operation is complete
  63834. */
  63835. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63836. /**
  63837. * Clones the raw cube texture.
  63838. * @return a new cube texture
  63839. */
  63840. clone(): CubeTexture;
  63841. /** @hidden */
  63842. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63843. }
  63844. }
  63845. declare module BABYLON {
  63846. /**
  63847. * Class used to store 2D array textures containing user data
  63848. */
  63849. export class RawTexture2DArray extends Texture {
  63850. /** Gets or sets the texture format to use */
  63851. format: number;
  63852. /**
  63853. * Create a new RawTexture2DArray
  63854. * @param data defines the data of the texture
  63855. * @param width defines the width of the texture
  63856. * @param height defines the height of the texture
  63857. * @param depth defines the number of layers of the texture
  63858. * @param format defines the texture format to use
  63859. * @param scene defines the hosting scene
  63860. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63861. * @param invertY defines if texture must be stored with Y axis inverted
  63862. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63863. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63864. */
  63865. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63866. /** Gets or sets the texture format to use */
  63867. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63868. /**
  63869. * Update the texture with new data
  63870. * @param data defines the data to store in the texture
  63871. */
  63872. update(data: ArrayBufferView): void;
  63873. }
  63874. }
  63875. declare module BABYLON {
  63876. /**
  63877. * Class used to store 3D textures containing user data
  63878. */
  63879. export class RawTexture3D extends Texture {
  63880. /** Gets or sets the texture format to use */
  63881. format: number;
  63882. /**
  63883. * Create a new RawTexture3D
  63884. * @param data defines the data of the texture
  63885. * @param width defines the width of the texture
  63886. * @param height defines the height of the texture
  63887. * @param depth defines the depth of the texture
  63888. * @param format defines the texture format to use
  63889. * @param scene defines the hosting scene
  63890. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63891. * @param invertY defines if texture must be stored with Y axis inverted
  63892. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63893. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63894. */
  63895. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63896. /** Gets or sets the texture format to use */
  63897. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63898. /**
  63899. * Update the texture with new data
  63900. * @param data defines the data to store in the texture
  63901. */
  63902. update(data: ArrayBufferView): void;
  63903. }
  63904. }
  63905. declare module BABYLON {
  63906. /**
  63907. * Creates a refraction texture used by refraction channel of the standard material.
  63908. * It is like a mirror but to see through a material.
  63909. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63910. */
  63911. export class RefractionTexture extends RenderTargetTexture {
  63912. /**
  63913. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63914. * 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.
  63915. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63916. */
  63917. refractionPlane: Plane;
  63918. /**
  63919. * Define how deep under the surface we should see.
  63920. */
  63921. depth: number;
  63922. /**
  63923. * Creates a refraction texture used by refraction channel of the standard material.
  63924. * It is like a mirror but to see through a material.
  63925. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63926. * @param name Define the texture name
  63927. * @param size Define the size of the underlying texture
  63928. * @param scene Define the scene the refraction belongs to
  63929. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63930. */
  63931. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63932. /**
  63933. * Clone the refraction texture.
  63934. * @returns the cloned texture
  63935. */
  63936. clone(): RefractionTexture;
  63937. /**
  63938. * Serialize the texture to a JSON representation you could use in Parse later on
  63939. * @returns the serialized JSON representation
  63940. */
  63941. serialize(): any;
  63942. }
  63943. }
  63944. declare module BABYLON {
  63945. /**
  63946. * Block used to add support for vertex skinning (bones)
  63947. */
  63948. export class BonesBlock extends NodeMaterialBlock {
  63949. /**
  63950. * Creates a new BonesBlock
  63951. * @param name defines the block name
  63952. */
  63953. constructor(name: string);
  63954. /**
  63955. * Initialize the block and prepare the context for build
  63956. * @param state defines the state that will be used for the build
  63957. */
  63958. initialize(state: NodeMaterialBuildState): void;
  63959. /**
  63960. * Gets the current class name
  63961. * @returns the class name
  63962. */
  63963. getClassName(): string;
  63964. /**
  63965. * Gets the matrix indices input component
  63966. */
  63967. get matricesIndices(): NodeMaterialConnectionPoint;
  63968. /**
  63969. * Gets the matrix weights input component
  63970. */
  63971. get matricesWeights(): NodeMaterialConnectionPoint;
  63972. /**
  63973. * Gets the extra matrix indices input component
  63974. */
  63975. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63976. /**
  63977. * Gets the extra matrix weights input component
  63978. */
  63979. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the world input component
  63982. */
  63983. get world(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the output component
  63986. */
  63987. get output(): NodeMaterialConnectionPoint;
  63988. autoConfigure(material: NodeMaterial): void;
  63989. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63990. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63991. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63992. protected _buildBlock(state: NodeMaterialBuildState): this;
  63993. }
  63994. }
  63995. declare module BABYLON {
  63996. /**
  63997. * Block used to add support for instances
  63998. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63999. */
  64000. export class InstancesBlock extends NodeMaterialBlock {
  64001. /**
  64002. * Creates a new InstancesBlock
  64003. * @param name defines the block name
  64004. */
  64005. constructor(name: string);
  64006. /**
  64007. * Gets the current class name
  64008. * @returns the class name
  64009. */
  64010. getClassName(): string;
  64011. /**
  64012. * Gets the first world row input component
  64013. */
  64014. get world0(): NodeMaterialConnectionPoint;
  64015. /**
  64016. * Gets the second world row input component
  64017. */
  64018. get world1(): NodeMaterialConnectionPoint;
  64019. /**
  64020. * Gets the third world row input component
  64021. */
  64022. get world2(): NodeMaterialConnectionPoint;
  64023. /**
  64024. * Gets the forth world row input component
  64025. */
  64026. get world3(): NodeMaterialConnectionPoint;
  64027. /**
  64028. * Gets the world input component
  64029. */
  64030. get world(): NodeMaterialConnectionPoint;
  64031. /**
  64032. * Gets the output component
  64033. */
  64034. get output(): NodeMaterialConnectionPoint;
  64035. /**
  64036. * Gets the isntanceID component
  64037. */
  64038. get instanceID(): NodeMaterialConnectionPoint;
  64039. autoConfigure(material: NodeMaterial): void;
  64040. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64041. protected _buildBlock(state: NodeMaterialBuildState): this;
  64042. }
  64043. }
  64044. declare module BABYLON {
  64045. /**
  64046. * Block used to add morph targets support to vertex shader
  64047. */
  64048. export class MorphTargetsBlock extends NodeMaterialBlock {
  64049. private _repeatableContentAnchor;
  64050. /**
  64051. * Create a new MorphTargetsBlock
  64052. * @param name defines the block name
  64053. */
  64054. constructor(name: string);
  64055. /**
  64056. * Gets the current class name
  64057. * @returns the class name
  64058. */
  64059. getClassName(): string;
  64060. /**
  64061. * Gets the position input component
  64062. */
  64063. get position(): NodeMaterialConnectionPoint;
  64064. /**
  64065. * Gets the normal input component
  64066. */
  64067. get normal(): NodeMaterialConnectionPoint;
  64068. /**
  64069. * Gets the tangent input component
  64070. */
  64071. get tangent(): NodeMaterialConnectionPoint;
  64072. /**
  64073. * Gets the tangent input component
  64074. */
  64075. get uv(): NodeMaterialConnectionPoint;
  64076. /**
  64077. * Gets the position output component
  64078. */
  64079. get positionOutput(): NodeMaterialConnectionPoint;
  64080. /**
  64081. * Gets the normal output component
  64082. */
  64083. get normalOutput(): NodeMaterialConnectionPoint;
  64084. /**
  64085. * Gets the tangent output component
  64086. */
  64087. get tangentOutput(): NodeMaterialConnectionPoint;
  64088. /**
  64089. * Gets the tangent output component
  64090. */
  64091. get uvOutput(): NodeMaterialConnectionPoint;
  64092. initialize(state: NodeMaterialBuildState): void;
  64093. autoConfigure(material: NodeMaterial): void;
  64094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64095. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64096. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64097. protected _buildBlock(state: NodeMaterialBuildState): this;
  64098. }
  64099. }
  64100. declare module BABYLON {
  64101. /**
  64102. * Block used to get data information from a light
  64103. */
  64104. export class LightInformationBlock extends NodeMaterialBlock {
  64105. private _lightDataUniformName;
  64106. private _lightColorUniformName;
  64107. private _lightTypeDefineName;
  64108. /**
  64109. * Gets or sets the light associated with this block
  64110. */
  64111. light: Nullable<Light>;
  64112. /**
  64113. * Creates a new LightInformationBlock
  64114. * @param name defines the block name
  64115. */
  64116. constructor(name: string);
  64117. /**
  64118. * Gets the current class name
  64119. * @returns the class name
  64120. */
  64121. getClassName(): string;
  64122. /**
  64123. * Gets the world position input component
  64124. */
  64125. get worldPosition(): NodeMaterialConnectionPoint;
  64126. /**
  64127. * Gets the direction output component
  64128. */
  64129. get direction(): NodeMaterialConnectionPoint;
  64130. /**
  64131. * Gets the direction output component
  64132. */
  64133. get color(): NodeMaterialConnectionPoint;
  64134. /**
  64135. * Gets the direction output component
  64136. */
  64137. get intensity(): NodeMaterialConnectionPoint;
  64138. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64140. protected _buildBlock(state: NodeMaterialBuildState): this;
  64141. serialize(): any;
  64142. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64143. }
  64144. }
  64145. declare module BABYLON {
  64146. /**
  64147. * Block used to add image processing support to fragment shader
  64148. */
  64149. export class ImageProcessingBlock extends NodeMaterialBlock {
  64150. /**
  64151. * Create a new ImageProcessingBlock
  64152. * @param name defines the block name
  64153. */
  64154. constructor(name: string);
  64155. /**
  64156. * Gets the current class name
  64157. * @returns the class name
  64158. */
  64159. getClassName(): string;
  64160. /**
  64161. * Gets the color input component
  64162. */
  64163. get color(): NodeMaterialConnectionPoint;
  64164. /**
  64165. * Gets the output component
  64166. */
  64167. get output(): NodeMaterialConnectionPoint;
  64168. /**
  64169. * Initialize the block and prepare the context for build
  64170. * @param state defines the state that will be used for the build
  64171. */
  64172. initialize(state: NodeMaterialBuildState): void;
  64173. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64174. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64175. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64176. protected _buildBlock(state: NodeMaterialBuildState): this;
  64177. }
  64178. }
  64179. declare module BABYLON {
  64180. /**
  64181. * Block used to pertub normals based on a normal map
  64182. */
  64183. export class PerturbNormalBlock extends NodeMaterialBlock {
  64184. private _tangentSpaceParameterName;
  64185. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64186. invertX: boolean;
  64187. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64188. invertY: boolean;
  64189. /**
  64190. * Create a new PerturbNormalBlock
  64191. * @param name defines the block name
  64192. */
  64193. constructor(name: string);
  64194. /**
  64195. * Gets the current class name
  64196. * @returns the class name
  64197. */
  64198. getClassName(): string;
  64199. /**
  64200. * Gets the world position input component
  64201. */
  64202. get worldPosition(): NodeMaterialConnectionPoint;
  64203. /**
  64204. * Gets the world normal input component
  64205. */
  64206. get worldNormal(): NodeMaterialConnectionPoint;
  64207. /**
  64208. * Gets the world tangent input component
  64209. */
  64210. get worldTangent(): NodeMaterialConnectionPoint;
  64211. /**
  64212. * Gets the uv input component
  64213. */
  64214. get uv(): NodeMaterialConnectionPoint;
  64215. /**
  64216. * Gets the normal map color input component
  64217. */
  64218. get normalMapColor(): NodeMaterialConnectionPoint;
  64219. /**
  64220. * Gets the strength input component
  64221. */
  64222. get strength(): NodeMaterialConnectionPoint;
  64223. /**
  64224. * Gets the output component
  64225. */
  64226. get output(): NodeMaterialConnectionPoint;
  64227. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64228. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64229. autoConfigure(material: NodeMaterial): void;
  64230. protected _buildBlock(state: NodeMaterialBuildState): this;
  64231. protected _dumpPropertiesCode(): string;
  64232. serialize(): any;
  64233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64234. }
  64235. }
  64236. declare module BABYLON {
  64237. /**
  64238. * Block used to discard a pixel if a value is smaller than a cutoff
  64239. */
  64240. export class DiscardBlock extends NodeMaterialBlock {
  64241. /**
  64242. * Create a new DiscardBlock
  64243. * @param name defines the block name
  64244. */
  64245. constructor(name: string);
  64246. /**
  64247. * Gets the current class name
  64248. * @returns the class name
  64249. */
  64250. getClassName(): string;
  64251. /**
  64252. * Gets the color input component
  64253. */
  64254. get value(): NodeMaterialConnectionPoint;
  64255. /**
  64256. * Gets the cutoff input component
  64257. */
  64258. get cutoff(): NodeMaterialConnectionPoint;
  64259. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64260. }
  64261. }
  64262. declare module BABYLON {
  64263. /**
  64264. * Block used to test if the fragment shader is front facing
  64265. */
  64266. export class FrontFacingBlock extends NodeMaterialBlock {
  64267. /**
  64268. * Creates a new FrontFacingBlock
  64269. * @param name defines the block name
  64270. */
  64271. constructor(name: string);
  64272. /**
  64273. * Gets the current class name
  64274. * @returns the class name
  64275. */
  64276. getClassName(): string;
  64277. /**
  64278. * Gets the output component
  64279. */
  64280. get output(): NodeMaterialConnectionPoint;
  64281. protected _buildBlock(state: NodeMaterialBuildState): this;
  64282. }
  64283. }
  64284. declare module BABYLON {
  64285. /**
  64286. * Block used to get the derivative value on x and y of a given input
  64287. */
  64288. export class DerivativeBlock extends NodeMaterialBlock {
  64289. /**
  64290. * Create a new DerivativeBlock
  64291. * @param name defines the block name
  64292. */
  64293. constructor(name: string);
  64294. /**
  64295. * Gets the current class name
  64296. * @returns the class name
  64297. */
  64298. getClassName(): string;
  64299. /**
  64300. * Gets the input component
  64301. */
  64302. get input(): NodeMaterialConnectionPoint;
  64303. /**
  64304. * Gets the derivative output on x
  64305. */
  64306. get dx(): NodeMaterialConnectionPoint;
  64307. /**
  64308. * Gets the derivative output on y
  64309. */
  64310. get dy(): NodeMaterialConnectionPoint;
  64311. protected _buildBlock(state: NodeMaterialBuildState): this;
  64312. }
  64313. }
  64314. declare module BABYLON {
  64315. /**
  64316. * Block used to make gl_FragCoord available
  64317. */
  64318. export class FragCoordBlock extends NodeMaterialBlock {
  64319. /**
  64320. * Creates a new FragCoordBlock
  64321. * @param name defines the block name
  64322. */
  64323. constructor(name: string);
  64324. /**
  64325. * Gets the current class name
  64326. * @returns the class name
  64327. */
  64328. getClassName(): string;
  64329. /**
  64330. * Gets the xy component
  64331. */
  64332. get xy(): NodeMaterialConnectionPoint;
  64333. /**
  64334. * Gets the xyz component
  64335. */
  64336. get xyz(): NodeMaterialConnectionPoint;
  64337. /**
  64338. * Gets the xyzw component
  64339. */
  64340. get xyzw(): NodeMaterialConnectionPoint;
  64341. /**
  64342. * Gets the x component
  64343. */
  64344. get x(): NodeMaterialConnectionPoint;
  64345. /**
  64346. * Gets the y component
  64347. */
  64348. get y(): NodeMaterialConnectionPoint;
  64349. /**
  64350. * Gets the z component
  64351. */
  64352. get z(): NodeMaterialConnectionPoint;
  64353. /**
  64354. * Gets the w component
  64355. */
  64356. get output(): NodeMaterialConnectionPoint;
  64357. protected writeOutputs(state: NodeMaterialBuildState): string;
  64358. protected _buildBlock(state: NodeMaterialBuildState): this;
  64359. }
  64360. }
  64361. declare module BABYLON {
  64362. /**
  64363. * Block used to get the screen sizes
  64364. */
  64365. export class ScreenSizeBlock extends NodeMaterialBlock {
  64366. private _varName;
  64367. private _scene;
  64368. /**
  64369. * Creates a new ScreenSizeBlock
  64370. * @param name defines the block name
  64371. */
  64372. constructor(name: string);
  64373. /**
  64374. * Gets the current class name
  64375. * @returns the class name
  64376. */
  64377. getClassName(): string;
  64378. /**
  64379. * Gets the xy component
  64380. */
  64381. get xy(): NodeMaterialConnectionPoint;
  64382. /**
  64383. * Gets the x component
  64384. */
  64385. get x(): NodeMaterialConnectionPoint;
  64386. /**
  64387. * Gets the y component
  64388. */
  64389. get y(): NodeMaterialConnectionPoint;
  64390. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64391. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64392. protected _buildBlock(state: NodeMaterialBuildState): this;
  64393. }
  64394. }
  64395. declare module BABYLON {
  64396. /**
  64397. * Block used to add support for scene fog
  64398. */
  64399. export class FogBlock extends NodeMaterialBlock {
  64400. private _fogDistanceName;
  64401. private _fogParameters;
  64402. /**
  64403. * Create a new FogBlock
  64404. * @param name defines the block name
  64405. */
  64406. constructor(name: string);
  64407. /**
  64408. * Gets the current class name
  64409. * @returns the class name
  64410. */
  64411. getClassName(): string;
  64412. /**
  64413. * Gets the world position input component
  64414. */
  64415. get worldPosition(): NodeMaterialConnectionPoint;
  64416. /**
  64417. * Gets the view input component
  64418. */
  64419. get view(): NodeMaterialConnectionPoint;
  64420. /**
  64421. * Gets the color input component
  64422. */
  64423. get input(): NodeMaterialConnectionPoint;
  64424. /**
  64425. * Gets the fog color input component
  64426. */
  64427. get fogColor(): NodeMaterialConnectionPoint;
  64428. /**
  64429. * Gets the output component
  64430. */
  64431. get output(): NodeMaterialConnectionPoint;
  64432. autoConfigure(material: NodeMaterial): void;
  64433. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64434. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64435. protected _buildBlock(state: NodeMaterialBuildState): this;
  64436. }
  64437. }
  64438. declare module BABYLON {
  64439. /**
  64440. * Block used to add light in the fragment shader
  64441. */
  64442. export class LightBlock extends NodeMaterialBlock {
  64443. private _lightId;
  64444. /**
  64445. * Gets or sets the light associated with this block
  64446. */
  64447. light: Nullable<Light>;
  64448. /**
  64449. * Create a new LightBlock
  64450. * @param name defines the block name
  64451. */
  64452. constructor(name: string);
  64453. /**
  64454. * Gets the current class name
  64455. * @returns the class name
  64456. */
  64457. getClassName(): string;
  64458. /**
  64459. * Gets the world position input component
  64460. */
  64461. get worldPosition(): NodeMaterialConnectionPoint;
  64462. /**
  64463. * Gets the world normal input component
  64464. */
  64465. get worldNormal(): NodeMaterialConnectionPoint;
  64466. /**
  64467. * Gets the camera (or eye) position component
  64468. */
  64469. get cameraPosition(): NodeMaterialConnectionPoint;
  64470. /**
  64471. * Gets the glossiness component
  64472. */
  64473. get glossiness(): NodeMaterialConnectionPoint;
  64474. /**
  64475. * Gets the glossinness power component
  64476. */
  64477. get glossPower(): NodeMaterialConnectionPoint;
  64478. /**
  64479. * Gets the diffuse color component
  64480. */
  64481. get diffuseColor(): NodeMaterialConnectionPoint;
  64482. /**
  64483. * Gets the specular color component
  64484. */
  64485. get specularColor(): NodeMaterialConnectionPoint;
  64486. /**
  64487. * Gets the view matrix component
  64488. */
  64489. get view(): NodeMaterialConnectionPoint;
  64490. /**
  64491. * Gets the diffuse output component
  64492. */
  64493. get diffuseOutput(): NodeMaterialConnectionPoint;
  64494. /**
  64495. * Gets the specular output component
  64496. */
  64497. get specularOutput(): NodeMaterialConnectionPoint;
  64498. /**
  64499. * Gets the shadow output component
  64500. */
  64501. get shadow(): NodeMaterialConnectionPoint;
  64502. autoConfigure(material: NodeMaterial): void;
  64503. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64504. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64505. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64506. private _injectVertexCode;
  64507. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64508. serialize(): any;
  64509. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64510. }
  64511. }
  64512. declare module BABYLON {
  64513. /**
  64514. * Block used to read a reflection texture from a sampler
  64515. */
  64516. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64517. /**
  64518. * Create a new ReflectionTextureBlock
  64519. * @param name defines the block name
  64520. */
  64521. constructor(name: string);
  64522. /**
  64523. * Gets the current class name
  64524. * @returns the class name
  64525. */
  64526. getClassName(): string;
  64527. /**
  64528. * Gets the world position input component
  64529. */
  64530. get position(): NodeMaterialConnectionPoint;
  64531. /**
  64532. * Gets the world position input component
  64533. */
  64534. get worldPosition(): NodeMaterialConnectionPoint;
  64535. /**
  64536. * Gets the world normal input component
  64537. */
  64538. get worldNormal(): NodeMaterialConnectionPoint;
  64539. /**
  64540. * Gets the world input component
  64541. */
  64542. get world(): NodeMaterialConnectionPoint;
  64543. /**
  64544. * Gets the camera (or eye) position component
  64545. */
  64546. get cameraPosition(): NodeMaterialConnectionPoint;
  64547. /**
  64548. * Gets the view input component
  64549. */
  64550. get view(): NodeMaterialConnectionPoint;
  64551. /**
  64552. * Gets the rgb output component
  64553. */
  64554. get rgb(): NodeMaterialConnectionPoint;
  64555. /**
  64556. * Gets the rgba output component
  64557. */
  64558. get rgba(): NodeMaterialConnectionPoint;
  64559. /**
  64560. * Gets the r output component
  64561. */
  64562. get r(): NodeMaterialConnectionPoint;
  64563. /**
  64564. * Gets the g output component
  64565. */
  64566. get g(): NodeMaterialConnectionPoint;
  64567. /**
  64568. * Gets the b output component
  64569. */
  64570. get b(): NodeMaterialConnectionPoint;
  64571. /**
  64572. * Gets the a output component
  64573. */
  64574. get a(): NodeMaterialConnectionPoint;
  64575. autoConfigure(material: NodeMaterial): void;
  64576. protected _buildBlock(state: NodeMaterialBuildState): this;
  64577. }
  64578. }
  64579. declare module BABYLON {
  64580. /**
  64581. * Block used to add 2 vectors
  64582. */
  64583. export class AddBlock extends NodeMaterialBlock {
  64584. /**
  64585. * Creates a new AddBlock
  64586. * @param name defines the block name
  64587. */
  64588. constructor(name: string);
  64589. /**
  64590. * Gets the current class name
  64591. * @returns the class name
  64592. */
  64593. getClassName(): string;
  64594. /**
  64595. * Gets the left operand input component
  64596. */
  64597. get left(): NodeMaterialConnectionPoint;
  64598. /**
  64599. * Gets the right operand input component
  64600. */
  64601. get right(): NodeMaterialConnectionPoint;
  64602. /**
  64603. * Gets the output component
  64604. */
  64605. get output(): NodeMaterialConnectionPoint;
  64606. protected _buildBlock(state: NodeMaterialBuildState): this;
  64607. }
  64608. }
  64609. declare module BABYLON {
  64610. /**
  64611. * Block used to scale a vector by a float
  64612. */
  64613. export class ScaleBlock extends NodeMaterialBlock {
  64614. /**
  64615. * Creates a new ScaleBlock
  64616. * @param name defines the block name
  64617. */
  64618. constructor(name: string);
  64619. /**
  64620. * Gets the current class name
  64621. * @returns the class name
  64622. */
  64623. getClassName(): string;
  64624. /**
  64625. * Gets the input component
  64626. */
  64627. get input(): NodeMaterialConnectionPoint;
  64628. /**
  64629. * Gets the factor input component
  64630. */
  64631. get factor(): NodeMaterialConnectionPoint;
  64632. /**
  64633. * Gets the output component
  64634. */
  64635. get output(): NodeMaterialConnectionPoint;
  64636. protected _buildBlock(state: NodeMaterialBuildState): this;
  64637. }
  64638. }
  64639. declare module BABYLON {
  64640. /**
  64641. * Block used to clamp a float
  64642. */
  64643. export class ClampBlock extends NodeMaterialBlock {
  64644. /** Gets or sets the minimum range */
  64645. minimum: number;
  64646. /** Gets or sets the maximum range */
  64647. maximum: number;
  64648. /**
  64649. * Creates a new ClampBlock
  64650. * @param name defines the block name
  64651. */
  64652. constructor(name: string);
  64653. /**
  64654. * Gets the current class name
  64655. * @returns the class name
  64656. */
  64657. getClassName(): string;
  64658. /**
  64659. * Gets the value input component
  64660. */
  64661. get value(): NodeMaterialConnectionPoint;
  64662. /**
  64663. * Gets the output component
  64664. */
  64665. get output(): NodeMaterialConnectionPoint;
  64666. protected _buildBlock(state: NodeMaterialBuildState): this;
  64667. protected _dumpPropertiesCode(): string;
  64668. serialize(): any;
  64669. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64670. }
  64671. }
  64672. declare module BABYLON {
  64673. /**
  64674. * Block used to apply a cross product between 2 vectors
  64675. */
  64676. export class CrossBlock extends NodeMaterialBlock {
  64677. /**
  64678. * Creates a new CrossBlock
  64679. * @param name defines the block name
  64680. */
  64681. constructor(name: string);
  64682. /**
  64683. * Gets the current class name
  64684. * @returns the class name
  64685. */
  64686. getClassName(): string;
  64687. /**
  64688. * Gets the left operand input component
  64689. */
  64690. get left(): NodeMaterialConnectionPoint;
  64691. /**
  64692. * Gets the right operand input component
  64693. */
  64694. get right(): NodeMaterialConnectionPoint;
  64695. /**
  64696. * Gets the output component
  64697. */
  64698. get output(): NodeMaterialConnectionPoint;
  64699. protected _buildBlock(state: NodeMaterialBuildState): this;
  64700. }
  64701. }
  64702. declare module BABYLON {
  64703. /**
  64704. * Block used to apply a dot product between 2 vectors
  64705. */
  64706. export class DotBlock extends NodeMaterialBlock {
  64707. /**
  64708. * Creates a new DotBlock
  64709. * @param name defines the block name
  64710. */
  64711. constructor(name: string);
  64712. /**
  64713. * Gets the current class name
  64714. * @returns the class name
  64715. */
  64716. getClassName(): string;
  64717. /**
  64718. * Gets the left operand input component
  64719. */
  64720. get left(): NodeMaterialConnectionPoint;
  64721. /**
  64722. * Gets the right operand input component
  64723. */
  64724. get right(): NodeMaterialConnectionPoint;
  64725. /**
  64726. * Gets the output component
  64727. */
  64728. get output(): NodeMaterialConnectionPoint;
  64729. protected _buildBlock(state: NodeMaterialBuildState): this;
  64730. }
  64731. }
  64732. declare module BABYLON {
  64733. /**
  64734. * Block used to normalize a vector
  64735. */
  64736. export class NormalizeBlock extends NodeMaterialBlock {
  64737. /**
  64738. * Creates a new NormalizeBlock
  64739. * @param name defines the block name
  64740. */
  64741. constructor(name: string);
  64742. /**
  64743. * Gets the current class name
  64744. * @returns the class name
  64745. */
  64746. getClassName(): string;
  64747. /**
  64748. * Gets the input component
  64749. */
  64750. get input(): NodeMaterialConnectionPoint;
  64751. /**
  64752. * Gets the output component
  64753. */
  64754. get output(): NodeMaterialConnectionPoint;
  64755. protected _buildBlock(state: NodeMaterialBuildState): this;
  64756. }
  64757. }
  64758. declare module BABYLON {
  64759. /**
  64760. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64761. */
  64762. export class ColorMergerBlock extends NodeMaterialBlock {
  64763. /**
  64764. * Create a new ColorMergerBlock
  64765. * @param name defines the block name
  64766. */
  64767. constructor(name: string);
  64768. /**
  64769. * Gets the current class name
  64770. * @returns the class name
  64771. */
  64772. getClassName(): string;
  64773. /**
  64774. * Gets the rgb component (input)
  64775. */
  64776. get rgbIn(): NodeMaterialConnectionPoint;
  64777. /**
  64778. * Gets the r component (input)
  64779. */
  64780. get r(): NodeMaterialConnectionPoint;
  64781. /**
  64782. * Gets the g component (input)
  64783. */
  64784. get g(): NodeMaterialConnectionPoint;
  64785. /**
  64786. * Gets the b component (input)
  64787. */
  64788. get b(): NodeMaterialConnectionPoint;
  64789. /**
  64790. * Gets the a component (input)
  64791. */
  64792. get a(): NodeMaterialConnectionPoint;
  64793. /**
  64794. * Gets the rgba component (output)
  64795. */
  64796. get rgba(): NodeMaterialConnectionPoint;
  64797. /**
  64798. * Gets the rgb component (output)
  64799. */
  64800. get rgbOut(): NodeMaterialConnectionPoint;
  64801. /**
  64802. * Gets the rgb component (output)
  64803. * @deprecated Please use rgbOut instead.
  64804. */
  64805. get rgb(): NodeMaterialConnectionPoint;
  64806. protected _buildBlock(state: NodeMaterialBuildState): this;
  64807. }
  64808. }
  64809. declare module BABYLON {
  64810. /**
  64811. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64812. */
  64813. export class VectorSplitterBlock extends NodeMaterialBlock {
  64814. /**
  64815. * Create a new VectorSplitterBlock
  64816. * @param name defines the block name
  64817. */
  64818. constructor(name: string);
  64819. /**
  64820. * Gets the current class name
  64821. * @returns the class name
  64822. */
  64823. getClassName(): string;
  64824. /**
  64825. * Gets the xyzw component (input)
  64826. */
  64827. get xyzw(): NodeMaterialConnectionPoint;
  64828. /**
  64829. * Gets the xyz component (input)
  64830. */
  64831. get xyzIn(): NodeMaterialConnectionPoint;
  64832. /**
  64833. * Gets the xy component (input)
  64834. */
  64835. get xyIn(): NodeMaterialConnectionPoint;
  64836. /**
  64837. * Gets the xyz component (output)
  64838. */
  64839. get xyzOut(): NodeMaterialConnectionPoint;
  64840. /**
  64841. * Gets the xy component (output)
  64842. */
  64843. get xyOut(): NodeMaterialConnectionPoint;
  64844. /**
  64845. * Gets the x component (output)
  64846. */
  64847. get x(): NodeMaterialConnectionPoint;
  64848. /**
  64849. * Gets the y component (output)
  64850. */
  64851. get y(): NodeMaterialConnectionPoint;
  64852. /**
  64853. * Gets the z component (output)
  64854. */
  64855. get z(): NodeMaterialConnectionPoint;
  64856. /**
  64857. * Gets the w component (output)
  64858. */
  64859. get w(): NodeMaterialConnectionPoint;
  64860. protected _inputRename(name: string): string;
  64861. protected _outputRename(name: string): string;
  64862. protected _buildBlock(state: NodeMaterialBuildState): this;
  64863. }
  64864. }
  64865. declare module BABYLON {
  64866. /**
  64867. * Block used to lerp between 2 values
  64868. */
  64869. export class LerpBlock extends NodeMaterialBlock {
  64870. /**
  64871. * Creates a new LerpBlock
  64872. * @param name defines the block name
  64873. */
  64874. constructor(name: string);
  64875. /**
  64876. * Gets the current class name
  64877. * @returns the class name
  64878. */
  64879. getClassName(): string;
  64880. /**
  64881. * Gets the left operand input component
  64882. */
  64883. get left(): NodeMaterialConnectionPoint;
  64884. /**
  64885. * Gets the right operand input component
  64886. */
  64887. get right(): NodeMaterialConnectionPoint;
  64888. /**
  64889. * Gets the gradient operand input component
  64890. */
  64891. get gradient(): NodeMaterialConnectionPoint;
  64892. /**
  64893. * Gets the output component
  64894. */
  64895. get output(): NodeMaterialConnectionPoint;
  64896. protected _buildBlock(state: NodeMaterialBuildState): this;
  64897. }
  64898. }
  64899. declare module BABYLON {
  64900. /**
  64901. * Block used to divide 2 vectors
  64902. */
  64903. export class DivideBlock extends NodeMaterialBlock {
  64904. /**
  64905. * Creates a new DivideBlock
  64906. * @param name defines the block name
  64907. */
  64908. constructor(name: string);
  64909. /**
  64910. * Gets the current class name
  64911. * @returns the class name
  64912. */
  64913. getClassName(): string;
  64914. /**
  64915. * Gets the left operand input component
  64916. */
  64917. get left(): NodeMaterialConnectionPoint;
  64918. /**
  64919. * Gets the right operand input component
  64920. */
  64921. get right(): NodeMaterialConnectionPoint;
  64922. /**
  64923. * Gets the output component
  64924. */
  64925. get output(): NodeMaterialConnectionPoint;
  64926. protected _buildBlock(state: NodeMaterialBuildState): this;
  64927. }
  64928. }
  64929. declare module BABYLON {
  64930. /**
  64931. * Block used to subtract 2 vectors
  64932. */
  64933. export class SubtractBlock extends NodeMaterialBlock {
  64934. /**
  64935. * Creates a new SubtractBlock
  64936. * @param name defines the block name
  64937. */
  64938. constructor(name: string);
  64939. /**
  64940. * Gets the current class name
  64941. * @returns the class name
  64942. */
  64943. getClassName(): string;
  64944. /**
  64945. * Gets the left operand input component
  64946. */
  64947. get left(): NodeMaterialConnectionPoint;
  64948. /**
  64949. * Gets the right operand input component
  64950. */
  64951. get right(): NodeMaterialConnectionPoint;
  64952. /**
  64953. * Gets the output component
  64954. */
  64955. get output(): NodeMaterialConnectionPoint;
  64956. protected _buildBlock(state: NodeMaterialBuildState): this;
  64957. }
  64958. }
  64959. declare module BABYLON {
  64960. /**
  64961. * Block used to step a value
  64962. */
  64963. export class StepBlock extends NodeMaterialBlock {
  64964. /**
  64965. * Creates a new StepBlock
  64966. * @param name defines the block name
  64967. */
  64968. constructor(name: string);
  64969. /**
  64970. * Gets the current class name
  64971. * @returns the class name
  64972. */
  64973. getClassName(): string;
  64974. /**
  64975. * Gets the value operand input component
  64976. */
  64977. get value(): NodeMaterialConnectionPoint;
  64978. /**
  64979. * Gets the edge operand input component
  64980. */
  64981. get edge(): NodeMaterialConnectionPoint;
  64982. /**
  64983. * Gets the output component
  64984. */
  64985. get output(): NodeMaterialConnectionPoint;
  64986. protected _buildBlock(state: NodeMaterialBuildState): this;
  64987. }
  64988. }
  64989. declare module BABYLON {
  64990. /**
  64991. * Block used to get the opposite (1 - x) of a value
  64992. */
  64993. export class OneMinusBlock extends NodeMaterialBlock {
  64994. /**
  64995. * Creates a new OneMinusBlock
  64996. * @param name defines the block name
  64997. */
  64998. constructor(name: string);
  64999. /**
  65000. * Gets the current class name
  65001. * @returns the class name
  65002. */
  65003. getClassName(): string;
  65004. /**
  65005. * Gets the input component
  65006. */
  65007. get input(): NodeMaterialConnectionPoint;
  65008. /**
  65009. * Gets the output component
  65010. */
  65011. get output(): NodeMaterialConnectionPoint;
  65012. protected _buildBlock(state: NodeMaterialBuildState): this;
  65013. }
  65014. }
  65015. declare module BABYLON {
  65016. /**
  65017. * Block used to get the view direction
  65018. */
  65019. export class ViewDirectionBlock extends NodeMaterialBlock {
  65020. /**
  65021. * Creates a new ViewDirectionBlock
  65022. * @param name defines the block name
  65023. */
  65024. constructor(name: string);
  65025. /**
  65026. * Gets the current class name
  65027. * @returns the class name
  65028. */
  65029. getClassName(): string;
  65030. /**
  65031. * Gets the world position component
  65032. */
  65033. get worldPosition(): NodeMaterialConnectionPoint;
  65034. /**
  65035. * Gets the camera position component
  65036. */
  65037. get cameraPosition(): NodeMaterialConnectionPoint;
  65038. /**
  65039. * Gets the output component
  65040. */
  65041. get output(): NodeMaterialConnectionPoint;
  65042. autoConfigure(material: NodeMaterial): void;
  65043. protected _buildBlock(state: NodeMaterialBuildState): this;
  65044. }
  65045. }
  65046. declare module BABYLON {
  65047. /**
  65048. * Block used to compute fresnel value
  65049. */
  65050. export class FresnelBlock extends NodeMaterialBlock {
  65051. /**
  65052. * Create a new FresnelBlock
  65053. * @param name defines the block name
  65054. */
  65055. constructor(name: string);
  65056. /**
  65057. * Gets the current class name
  65058. * @returns the class name
  65059. */
  65060. getClassName(): string;
  65061. /**
  65062. * Gets the world normal input component
  65063. */
  65064. get worldNormal(): NodeMaterialConnectionPoint;
  65065. /**
  65066. * Gets the view direction input component
  65067. */
  65068. get viewDirection(): NodeMaterialConnectionPoint;
  65069. /**
  65070. * Gets the bias input component
  65071. */
  65072. get bias(): NodeMaterialConnectionPoint;
  65073. /**
  65074. * Gets the camera (or eye) position component
  65075. */
  65076. get power(): NodeMaterialConnectionPoint;
  65077. /**
  65078. * Gets the fresnel output component
  65079. */
  65080. get fresnel(): NodeMaterialConnectionPoint;
  65081. autoConfigure(material: NodeMaterial): void;
  65082. protected _buildBlock(state: NodeMaterialBuildState): this;
  65083. }
  65084. }
  65085. declare module BABYLON {
  65086. /**
  65087. * Block used to get the max of 2 values
  65088. */
  65089. export class MaxBlock extends NodeMaterialBlock {
  65090. /**
  65091. * Creates a new MaxBlock
  65092. * @param name defines the block name
  65093. */
  65094. constructor(name: string);
  65095. /**
  65096. * Gets the current class name
  65097. * @returns the class name
  65098. */
  65099. getClassName(): string;
  65100. /**
  65101. * Gets the left operand input component
  65102. */
  65103. get left(): NodeMaterialConnectionPoint;
  65104. /**
  65105. * Gets the right operand input component
  65106. */
  65107. get right(): NodeMaterialConnectionPoint;
  65108. /**
  65109. * Gets the output component
  65110. */
  65111. get output(): NodeMaterialConnectionPoint;
  65112. protected _buildBlock(state: NodeMaterialBuildState): this;
  65113. }
  65114. }
  65115. declare module BABYLON {
  65116. /**
  65117. * Block used to get the min of 2 values
  65118. */
  65119. export class MinBlock extends NodeMaterialBlock {
  65120. /**
  65121. * Creates a new MinBlock
  65122. * @param name defines the block name
  65123. */
  65124. constructor(name: string);
  65125. /**
  65126. * Gets the current class name
  65127. * @returns the class name
  65128. */
  65129. getClassName(): string;
  65130. /**
  65131. * Gets the left operand input component
  65132. */
  65133. get left(): NodeMaterialConnectionPoint;
  65134. /**
  65135. * Gets the right operand input component
  65136. */
  65137. get right(): NodeMaterialConnectionPoint;
  65138. /**
  65139. * Gets the output component
  65140. */
  65141. get output(): NodeMaterialConnectionPoint;
  65142. protected _buildBlock(state: NodeMaterialBuildState): this;
  65143. }
  65144. }
  65145. declare module BABYLON {
  65146. /**
  65147. * Block used to get the distance between 2 values
  65148. */
  65149. export class DistanceBlock extends NodeMaterialBlock {
  65150. /**
  65151. * Creates a new DistanceBlock
  65152. * @param name defines the block name
  65153. */
  65154. constructor(name: string);
  65155. /**
  65156. * Gets the current class name
  65157. * @returns the class name
  65158. */
  65159. getClassName(): string;
  65160. /**
  65161. * Gets the left operand input component
  65162. */
  65163. get left(): NodeMaterialConnectionPoint;
  65164. /**
  65165. * Gets the right operand input component
  65166. */
  65167. get right(): NodeMaterialConnectionPoint;
  65168. /**
  65169. * Gets the output component
  65170. */
  65171. get output(): NodeMaterialConnectionPoint;
  65172. protected _buildBlock(state: NodeMaterialBuildState): this;
  65173. }
  65174. }
  65175. declare module BABYLON {
  65176. /**
  65177. * Block used to get the length of a vector
  65178. */
  65179. export class LengthBlock extends NodeMaterialBlock {
  65180. /**
  65181. * Creates a new LengthBlock
  65182. * @param name defines the block name
  65183. */
  65184. constructor(name: string);
  65185. /**
  65186. * Gets the current class name
  65187. * @returns the class name
  65188. */
  65189. getClassName(): string;
  65190. /**
  65191. * Gets the value input component
  65192. */
  65193. get value(): NodeMaterialConnectionPoint;
  65194. /**
  65195. * Gets the output component
  65196. */
  65197. get output(): NodeMaterialConnectionPoint;
  65198. protected _buildBlock(state: NodeMaterialBuildState): this;
  65199. }
  65200. }
  65201. declare module BABYLON {
  65202. /**
  65203. * Block used to get negative version of a value (i.e. x * -1)
  65204. */
  65205. export class NegateBlock extends NodeMaterialBlock {
  65206. /**
  65207. * Creates a new NegateBlock
  65208. * @param name defines the block name
  65209. */
  65210. constructor(name: string);
  65211. /**
  65212. * Gets the current class name
  65213. * @returns the class name
  65214. */
  65215. getClassName(): string;
  65216. /**
  65217. * Gets the value input component
  65218. */
  65219. get value(): NodeMaterialConnectionPoint;
  65220. /**
  65221. * Gets the output component
  65222. */
  65223. get output(): NodeMaterialConnectionPoint;
  65224. protected _buildBlock(state: NodeMaterialBuildState): this;
  65225. }
  65226. }
  65227. declare module BABYLON {
  65228. /**
  65229. * Block used to get the value of the first parameter raised to the power of the second
  65230. */
  65231. export class PowBlock extends NodeMaterialBlock {
  65232. /**
  65233. * Creates a new PowBlock
  65234. * @param name defines the block name
  65235. */
  65236. constructor(name: string);
  65237. /**
  65238. * Gets the current class name
  65239. * @returns the class name
  65240. */
  65241. getClassName(): string;
  65242. /**
  65243. * Gets the value operand input component
  65244. */
  65245. get value(): NodeMaterialConnectionPoint;
  65246. /**
  65247. * Gets the power operand input component
  65248. */
  65249. get power(): NodeMaterialConnectionPoint;
  65250. /**
  65251. * Gets the output component
  65252. */
  65253. get output(): NodeMaterialConnectionPoint;
  65254. protected _buildBlock(state: NodeMaterialBuildState): this;
  65255. }
  65256. }
  65257. declare module BABYLON {
  65258. /**
  65259. * Block used to get a random number
  65260. */
  65261. export class RandomNumberBlock extends NodeMaterialBlock {
  65262. /**
  65263. * Creates a new RandomNumberBlock
  65264. * @param name defines the block name
  65265. */
  65266. constructor(name: string);
  65267. /**
  65268. * Gets the current class name
  65269. * @returns the class name
  65270. */
  65271. getClassName(): string;
  65272. /**
  65273. * Gets the seed input component
  65274. */
  65275. get seed(): NodeMaterialConnectionPoint;
  65276. /**
  65277. * Gets the output component
  65278. */
  65279. get output(): NodeMaterialConnectionPoint;
  65280. protected _buildBlock(state: NodeMaterialBuildState): this;
  65281. }
  65282. }
  65283. declare module BABYLON {
  65284. /**
  65285. * Block used to compute arc tangent of 2 values
  65286. */
  65287. export class ArcTan2Block extends NodeMaterialBlock {
  65288. /**
  65289. * Creates a new ArcTan2Block
  65290. * @param name defines the block name
  65291. */
  65292. constructor(name: string);
  65293. /**
  65294. * Gets the current class name
  65295. * @returns the class name
  65296. */
  65297. getClassName(): string;
  65298. /**
  65299. * Gets the x operand input component
  65300. */
  65301. get x(): NodeMaterialConnectionPoint;
  65302. /**
  65303. * Gets the y operand input component
  65304. */
  65305. get y(): NodeMaterialConnectionPoint;
  65306. /**
  65307. * Gets the output component
  65308. */
  65309. get output(): NodeMaterialConnectionPoint;
  65310. protected _buildBlock(state: NodeMaterialBuildState): this;
  65311. }
  65312. }
  65313. declare module BABYLON {
  65314. /**
  65315. * Block used to smooth step a value
  65316. */
  65317. export class SmoothStepBlock extends NodeMaterialBlock {
  65318. /**
  65319. * Creates a new SmoothStepBlock
  65320. * @param name defines the block name
  65321. */
  65322. constructor(name: string);
  65323. /**
  65324. * Gets the current class name
  65325. * @returns the class name
  65326. */
  65327. getClassName(): string;
  65328. /**
  65329. * Gets the value operand input component
  65330. */
  65331. get value(): NodeMaterialConnectionPoint;
  65332. /**
  65333. * Gets the first edge operand input component
  65334. */
  65335. get edge0(): NodeMaterialConnectionPoint;
  65336. /**
  65337. * Gets the second edge operand input component
  65338. */
  65339. get edge1(): NodeMaterialConnectionPoint;
  65340. /**
  65341. * Gets the output component
  65342. */
  65343. get output(): NodeMaterialConnectionPoint;
  65344. protected _buildBlock(state: NodeMaterialBuildState): this;
  65345. }
  65346. }
  65347. declare module BABYLON {
  65348. /**
  65349. * Block used to get the reciprocal (1 / x) of a value
  65350. */
  65351. export class ReciprocalBlock extends NodeMaterialBlock {
  65352. /**
  65353. * Creates a new ReciprocalBlock
  65354. * @param name defines the block name
  65355. */
  65356. constructor(name: string);
  65357. /**
  65358. * Gets the current class name
  65359. * @returns the class name
  65360. */
  65361. getClassName(): string;
  65362. /**
  65363. * Gets the input component
  65364. */
  65365. get input(): NodeMaterialConnectionPoint;
  65366. /**
  65367. * Gets the output component
  65368. */
  65369. get output(): NodeMaterialConnectionPoint;
  65370. protected _buildBlock(state: NodeMaterialBuildState): this;
  65371. }
  65372. }
  65373. declare module BABYLON {
  65374. /**
  65375. * Block used to replace a color by another one
  65376. */
  65377. export class ReplaceColorBlock extends NodeMaterialBlock {
  65378. /**
  65379. * Creates a new ReplaceColorBlock
  65380. * @param name defines the block name
  65381. */
  65382. constructor(name: string);
  65383. /**
  65384. * Gets the current class name
  65385. * @returns the class name
  65386. */
  65387. getClassName(): string;
  65388. /**
  65389. * Gets the value input component
  65390. */
  65391. get value(): NodeMaterialConnectionPoint;
  65392. /**
  65393. * Gets the reference input component
  65394. */
  65395. get reference(): NodeMaterialConnectionPoint;
  65396. /**
  65397. * Gets the distance input component
  65398. */
  65399. get distance(): NodeMaterialConnectionPoint;
  65400. /**
  65401. * Gets the replacement input component
  65402. */
  65403. get replacement(): NodeMaterialConnectionPoint;
  65404. /**
  65405. * Gets the output component
  65406. */
  65407. get output(): NodeMaterialConnectionPoint;
  65408. protected _buildBlock(state: NodeMaterialBuildState): this;
  65409. }
  65410. }
  65411. declare module BABYLON {
  65412. /**
  65413. * Block used to posterize a value
  65414. * @see https://en.wikipedia.org/wiki/Posterization
  65415. */
  65416. export class PosterizeBlock extends NodeMaterialBlock {
  65417. /**
  65418. * Creates a new PosterizeBlock
  65419. * @param name defines the block name
  65420. */
  65421. constructor(name: string);
  65422. /**
  65423. * Gets the current class name
  65424. * @returns the class name
  65425. */
  65426. getClassName(): string;
  65427. /**
  65428. * Gets the value input component
  65429. */
  65430. get value(): NodeMaterialConnectionPoint;
  65431. /**
  65432. * Gets the steps input component
  65433. */
  65434. get steps(): NodeMaterialConnectionPoint;
  65435. /**
  65436. * Gets the output component
  65437. */
  65438. get output(): NodeMaterialConnectionPoint;
  65439. protected _buildBlock(state: NodeMaterialBuildState): this;
  65440. }
  65441. }
  65442. declare module BABYLON {
  65443. /**
  65444. * Operations supported by the Wave block
  65445. */
  65446. export enum WaveBlockKind {
  65447. /** SawTooth */
  65448. SawTooth = 0,
  65449. /** Square */
  65450. Square = 1,
  65451. /** Triangle */
  65452. Triangle = 2
  65453. }
  65454. /**
  65455. * Block used to apply wave operation to floats
  65456. */
  65457. export class WaveBlock extends NodeMaterialBlock {
  65458. /**
  65459. * Gets or sets the kibnd of wave to be applied by the block
  65460. */
  65461. kind: WaveBlockKind;
  65462. /**
  65463. * Creates a new WaveBlock
  65464. * @param name defines the block name
  65465. */
  65466. constructor(name: string);
  65467. /**
  65468. * Gets the current class name
  65469. * @returns the class name
  65470. */
  65471. getClassName(): string;
  65472. /**
  65473. * Gets the input component
  65474. */
  65475. get input(): NodeMaterialConnectionPoint;
  65476. /**
  65477. * Gets the output component
  65478. */
  65479. get output(): NodeMaterialConnectionPoint;
  65480. protected _buildBlock(state: NodeMaterialBuildState): this;
  65481. serialize(): any;
  65482. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65483. }
  65484. }
  65485. declare module BABYLON {
  65486. /**
  65487. * Class used to store a color step for the GradientBlock
  65488. */
  65489. export class GradientBlockColorStep {
  65490. private _step;
  65491. /**
  65492. * Gets value indicating which step this color is associated with (between 0 and 1)
  65493. */
  65494. get step(): number;
  65495. /**
  65496. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65497. */
  65498. set step(val: number);
  65499. private _color;
  65500. /**
  65501. * Gets the color associated with this step
  65502. */
  65503. get color(): Color3;
  65504. /**
  65505. * Sets the color associated with this step
  65506. */
  65507. set color(val: Color3);
  65508. /**
  65509. * Creates a new GradientBlockColorStep
  65510. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65511. * @param color defines the color associated with this step
  65512. */
  65513. constructor(step: number, color: Color3);
  65514. }
  65515. /**
  65516. * Block used to return a color from a gradient based on an input value between 0 and 1
  65517. */
  65518. export class GradientBlock extends NodeMaterialBlock {
  65519. /**
  65520. * Gets or sets the list of color steps
  65521. */
  65522. colorSteps: GradientBlockColorStep[];
  65523. /** Gets an observable raised when the value is changed */
  65524. onValueChangedObservable: Observable<GradientBlock>;
  65525. /** calls observable when the value is changed*/
  65526. colorStepsUpdated(): void;
  65527. /**
  65528. * Creates a new GradientBlock
  65529. * @param name defines the block name
  65530. */
  65531. constructor(name: string);
  65532. /**
  65533. * Gets the current class name
  65534. * @returns the class name
  65535. */
  65536. getClassName(): string;
  65537. /**
  65538. * Gets the gradient input component
  65539. */
  65540. get gradient(): NodeMaterialConnectionPoint;
  65541. /**
  65542. * Gets the output component
  65543. */
  65544. get output(): NodeMaterialConnectionPoint;
  65545. private _writeColorConstant;
  65546. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65547. serialize(): any;
  65548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65549. protected _dumpPropertiesCode(): string;
  65550. }
  65551. }
  65552. declare module BABYLON {
  65553. /**
  65554. * Block used to normalize lerp between 2 values
  65555. */
  65556. export class NLerpBlock extends NodeMaterialBlock {
  65557. /**
  65558. * Creates a new NLerpBlock
  65559. * @param name defines the block name
  65560. */
  65561. constructor(name: string);
  65562. /**
  65563. * Gets the current class name
  65564. * @returns the class name
  65565. */
  65566. getClassName(): string;
  65567. /**
  65568. * Gets the left operand input component
  65569. */
  65570. get left(): NodeMaterialConnectionPoint;
  65571. /**
  65572. * Gets the right operand input component
  65573. */
  65574. get right(): NodeMaterialConnectionPoint;
  65575. /**
  65576. * Gets the gradient operand input component
  65577. */
  65578. get gradient(): NodeMaterialConnectionPoint;
  65579. /**
  65580. * Gets the output component
  65581. */
  65582. get output(): NodeMaterialConnectionPoint;
  65583. protected _buildBlock(state: NodeMaterialBuildState): this;
  65584. }
  65585. }
  65586. declare module BABYLON {
  65587. /**
  65588. * block used to Generate a Worley Noise 3D Noise Pattern
  65589. */
  65590. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65591. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65592. manhattanDistance: boolean;
  65593. /**
  65594. * Creates a new WorleyNoise3DBlock
  65595. * @param name defines the block name
  65596. */
  65597. constructor(name: string);
  65598. /**
  65599. * Gets the current class name
  65600. * @returns the class name
  65601. */
  65602. getClassName(): string;
  65603. /**
  65604. * Gets the seed input component
  65605. */
  65606. get seed(): NodeMaterialConnectionPoint;
  65607. /**
  65608. * Gets the jitter input component
  65609. */
  65610. get jitter(): NodeMaterialConnectionPoint;
  65611. /**
  65612. * Gets the output component
  65613. */
  65614. get output(): NodeMaterialConnectionPoint;
  65615. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65616. /**
  65617. * Exposes the properties to the UI?
  65618. */
  65619. protected _dumpPropertiesCode(): string;
  65620. /**
  65621. * Exposes the properties to the Seralize?
  65622. */
  65623. serialize(): any;
  65624. /**
  65625. * Exposes the properties to the deseralize?
  65626. */
  65627. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65628. }
  65629. }
  65630. declare module BABYLON {
  65631. /**
  65632. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65633. */
  65634. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65635. /**
  65636. * Creates a new SimplexPerlin3DBlock
  65637. * @param name defines the block name
  65638. */
  65639. constructor(name: string);
  65640. /**
  65641. * Gets the current class name
  65642. * @returns the class name
  65643. */
  65644. getClassName(): string;
  65645. /**
  65646. * Gets the seed operand input component
  65647. */
  65648. get seed(): NodeMaterialConnectionPoint;
  65649. /**
  65650. * Gets the output component
  65651. */
  65652. get output(): NodeMaterialConnectionPoint;
  65653. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65654. }
  65655. }
  65656. declare module BABYLON {
  65657. /**
  65658. * Block used to blend normals
  65659. */
  65660. export class NormalBlendBlock extends NodeMaterialBlock {
  65661. /**
  65662. * Creates a new NormalBlendBlock
  65663. * @param name defines the block name
  65664. */
  65665. constructor(name: string);
  65666. /**
  65667. * Gets the current class name
  65668. * @returns the class name
  65669. */
  65670. getClassName(): string;
  65671. /**
  65672. * Gets the first input component
  65673. */
  65674. get normalMap0(): NodeMaterialConnectionPoint;
  65675. /**
  65676. * Gets the second input component
  65677. */
  65678. get normalMap1(): NodeMaterialConnectionPoint;
  65679. /**
  65680. * Gets the output component
  65681. */
  65682. get output(): NodeMaterialConnectionPoint;
  65683. protected _buildBlock(state: NodeMaterialBuildState): this;
  65684. }
  65685. }
  65686. declare module BABYLON {
  65687. /**
  65688. * Block used to rotate a 2d vector by a given angle
  65689. */
  65690. export class Rotate2dBlock extends NodeMaterialBlock {
  65691. /**
  65692. * Creates a new Rotate2dBlock
  65693. * @param name defines the block name
  65694. */
  65695. constructor(name: string);
  65696. /**
  65697. * Gets the current class name
  65698. * @returns the class name
  65699. */
  65700. getClassName(): string;
  65701. /**
  65702. * Gets the input vector
  65703. */
  65704. get input(): NodeMaterialConnectionPoint;
  65705. /**
  65706. * Gets the input angle
  65707. */
  65708. get angle(): NodeMaterialConnectionPoint;
  65709. /**
  65710. * Gets the output component
  65711. */
  65712. get output(): NodeMaterialConnectionPoint;
  65713. autoConfigure(material: NodeMaterial): void;
  65714. protected _buildBlock(state: NodeMaterialBuildState): this;
  65715. }
  65716. }
  65717. declare module BABYLON {
  65718. /**
  65719. * Block used to get the reflected vector from a direction and a normal
  65720. */
  65721. export class ReflectBlock extends NodeMaterialBlock {
  65722. /**
  65723. * Creates a new ReflectBlock
  65724. * @param name defines the block name
  65725. */
  65726. constructor(name: string);
  65727. /**
  65728. * Gets the current class name
  65729. * @returns the class name
  65730. */
  65731. getClassName(): string;
  65732. /**
  65733. * Gets the incident component
  65734. */
  65735. get incident(): NodeMaterialConnectionPoint;
  65736. /**
  65737. * Gets the normal component
  65738. */
  65739. get normal(): NodeMaterialConnectionPoint;
  65740. /**
  65741. * Gets the output component
  65742. */
  65743. get output(): NodeMaterialConnectionPoint;
  65744. protected _buildBlock(state: NodeMaterialBuildState): this;
  65745. }
  65746. }
  65747. declare module BABYLON {
  65748. /**
  65749. * Block used to get the refracted vector from a direction and a normal
  65750. */
  65751. export class RefractBlock extends NodeMaterialBlock {
  65752. /**
  65753. * Creates a new RefractBlock
  65754. * @param name defines the block name
  65755. */
  65756. constructor(name: string);
  65757. /**
  65758. * Gets the current class name
  65759. * @returns the class name
  65760. */
  65761. getClassName(): string;
  65762. /**
  65763. * Gets the incident component
  65764. */
  65765. get incident(): NodeMaterialConnectionPoint;
  65766. /**
  65767. * Gets the normal component
  65768. */
  65769. get normal(): NodeMaterialConnectionPoint;
  65770. /**
  65771. * Gets the index of refraction component
  65772. */
  65773. get ior(): NodeMaterialConnectionPoint;
  65774. /**
  65775. * Gets the output component
  65776. */
  65777. get output(): NodeMaterialConnectionPoint;
  65778. protected _buildBlock(state: NodeMaterialBuildState): this;
  65779. }
  65780. }
  65781. declare module BABYLON {
  65782. /**
  65783. * Block used to desaturate a color
  65784. */
  65785. export class DesaturateBlock extends NodeMaterialBlock {
  65786. /**
  65787. * Creates a new DesaturateBlock
  65788. * @param name defines the block name
  65789. */
  65790. constructor(name: string);
  65791. /**
  65792. * Gets the current class name
  65793. * @returns the class name
  65794. */
  65795. getClassName(): string;
  65796. /**
  65797. * Gets the color operand input component
  65798. */
  65799. get color(): NodeMaterialConnectionPoint;
  65800. /**
  65801. * Gets the level operand input component
  65802. */
  65803. get level(): NodeMaterialConnectionPoint;
  65804. /**
  65805. * Gets the output component
  65806. */
  65807. get output(): NodeMaterialConnectionPoint;
  65808. protected _buildBlock(state: NodeMaterialBuildState): this;
  65809. }
  65810. }
  65811. declare module BABYLON {
  65812. /**
  65813. * Block used to implement the reflection module of the PBR material
  65814. */
  65815. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65816. /** @hidden */
  65817. _defineLODReflectionAlpha: string;
  65818. /** @hidden */
  65819. _defineLinearSpecularReflection: string;
  65820. private _vEnvironmentIrradianceName;
  65821. /** @hidden */
  65822. _vReflectionMicrosurfaceInfosName: string;
  65823. /** @hidden */
  65824. _vReflectionInfosName: string;
  65825. /** @hidden */
  65826. _vReflectionFilteringInfoName: string;
  65827. private _scene;
  65828. /**
  65829. * The properties below are set by the main PBR block prior to calling methods of this class.
  65830. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65831. * It's less burden on the user side in the editor part.
  65832. */
  65833. /** @hidden */
  65834. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65835. /** @hidden */
  65836. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65837. /** @hidden */
  65838. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65839. /** @hidden */
  65840. viewConnectionPoint: NodeMaterialConnectionPoint;
  65841. /**
  65842. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65843. * diffuse part of the IBL.
  65844. */
  65845. useSphericalHarmonics: boolean;
  65846. /**
  65847. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65848. */
  65849. forceIrradianceInFragment: boolean;
  65850. /**
  65851. * Create a new ReflectionBlock
  65852. * @param name defines the block name
  65853. */
  65854. constructor(name: string);
  65855. /**
  65856. * Gets the current class name
  65857. * @returns the class name
  65858. */
  65859. getClassName(): string;
  65860. /**
  65861. * Gets the position input component
  65862. */
  65863. get position(): NodeMaterialConnectionPoint;
  65864. /**
  65865. * Gets the world position input component
  65866. */
  65867. get worldPosition(): NodeMaterialConnectionPoint;
  65868. /**
  65869. * Gets the world normal input component
  65870. */
  65871. get worldNormal(): NodeMaterialConnectionPoint;
  65872. /**
  65873. * Gets the world input component
  65874. */
  65875. get world(): NodeMaterialConnectionPoint;
  65876. /**
  65877. * Gets the camera (or eye) position component
  65878. */
  65879. get cameraPosition(): NodeMaterialConnectionPoint;
  65880. /**
  65881. * Gets the view input component
  65882. */
  65883. get view(): NodeMaterialConnectionPoint;
  65884. /**
  65885. * Gets the color input component
  65886. */
  65887. get color(): NodeMaterialConnectionPoint;
  65888. /**
  65889. * Gets the reflection object output component
  65890. */
  65891. get reflection(): NodeMaterialConnectionPoint;
  65892. /**
  65893. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65894. */
  65895. get hasTexture(): boolean;
  65896. /**
  65897. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65898. */
  65899. get reflectionColor(): string;
  65900. protected _getTexture(): Nullable<BaseTexture>;
  65901. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65902. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65903. /**
  65904. * Gets the code to inject in the vertex shader
  65905. * @param state current state of the node material building
  65906. * @returns the shader code
  65907. */
  65908. handleVertexSide(state: NodeMaterialBuildState): string;
  65909. /**
  65910. * Gets the main code of the block (fragment side)
  65911. * @param state current state of the node material building
  65912. * @param normalVarName name of the existing variable corresponding to the normal
  65913. * @returns the shader code
  65914. */
  65915. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65916. protected _buildBlock(state: NodeMaterialBuildState): this;
  65917. protected _dumpPropertiesCode(): string;
  65918. serialize(): any;
  65919. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65920. }
  65921. }
  65922. declare module BABYLON {
  65923. /**
  65924. * Block used to implement the sheen module of the PBR material
  65925. */
  65926. export class SheenBlock extends NodeMaterialBlock {
  65927. /**
  65928. * Create a new SheenBlock
  65929. * @param name defines the block name
  65930. */
  65931. constructor(name: string);
  65932. /**
  65933. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65934. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65935. * making it easier to setup and tweak the effect
  65936. */
  65937. albedoScaling: boolean;
  65938. /**
  65939. * Defines if the sheen is linked to the sheen color.
  65940. */
  65941. linkSheenWithAlbedo: boolean;
  65942. /**
  65943. * Initialize the block and prepare the context for build
  65944. * @param state defines the state that will be used for the build
  65945. */
  65946. initialize(state: NodeMaterialBuildState): void;
  65947. /**
  65948. * Gets the current class name
  65949. * @returns the class name
  65950. */
  65951. getClassName(): string;
  65952. /**
  65953. * Gets the intensity input component
  65954. */
  65955. get intensity(): NodeMaterialConnectionPoint;
  65956. /**
  65957. * Gets the color input component
  65958. */
  65959. get color(): NodeMaterialConnectionPoint;
  65960. /**
  65961. * Gets the roughness input component
  65962. */
  65963. get roughness(): NodeMaterialConnectionPoint;
  65964. /**
  65965. * Gets the sheen object output component
  65966. */
  65967. get sheen(): NodeMaterialConnectionPoint;
  65968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65969. /**
  65970. * Gets the main code of the block (fragment side)
  65971. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65972. * @returns the shader code
  65973. */
  65974. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65975. protected _buildBlock(state: NodeMaterialBuildState): this;
  65976. protected _dumpPropertiesCode(): string;
  65977. serialize(): any;
  65978. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65979. }
  65980. }
  65981. declare module BABYLON {
  65982. /**
  65983. * Block used to implement the anisotropy module of the PBR material
  65984. */
  65985. export class AnisotropyBlock extends NodeMaterialBlock {
  65986. /**
  65987. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65988. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65989. * It's less burden on the user side in the editor part.
  65990. */
  65991. /** @hidden */
  65992. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65993. /** @hidden */
  65994. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65995. /**
  65996. * Create a new AnisotropyBlock
  65997. * @param name defines the block name
  65998. */
  65999. constructor(name: string);
  66000. /**
  66001. * Initialize the block and prepare the context for build
  66002. * @param state defines the state that will be used for the build
  66003. */
  66004. initialize(state: NodeMaterialBuildState): void;
  66005. /**
  66006. * Gets the current class name
  66007. * @returns the class name
  66008. */
  66009. getClassName(): string;
  66010. /**
  66011. * Gets the intensity input component
  66012. */
  66013. get intensity(): NodeMaterialConnectionPoint;
  66014. /**
  66015. * Gets the direction input component
  66016. */
  66017. get direction(): NodeMaterialConnectionPoint;
  66018. /**
  66019. * Gets the uv input component
  66020. */
  66021. get uv(): NodeMaterialConnectionPoint;
  66022. /**
  66023. * Gets the worldTangent input component
  66024. */
  66025. get worldTangent(): NodeMaterialConnectionPoint;
  66026. /**
  66027. * Gets the anisotropy object output component
  66028. */
  66029. get anisotropy(): NodeMaterialConnectionPoint;
  66030. private _generateTBNSpace;
  66031. /**
  66032. * Gets the main code of the block (fragment side)
  66033. * @param state current state of the node material building
  66034. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66035. * @returns the shader code
  66036. */
  66037. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66039. protected _buildBlock(state: NodeMaterialBuildState): this;
  66040. }
  66041. }
  66042. declare module BABYLON {
  66043. /**
  66044. * Block used to implement the clear coat module of the PBR material
  66045. */
  66046. export class ClearCoatBlock extends NodeMaterialBlock {
  66047. private _scene;
  66048. /**
  66049. * Create a new ClearCoatBlock
  66050. * @param name defines the block name
  66051. */
  66052. constructor(name: string);
  66053. /**
  66054. * Defines if the F0 value should be remapped to account for the interface change in the material.
  66055. */
  66056. remapF0OnInterfaceChange: boolean;
  66057. /**
  66058. * Initialize the block and prepare the context for build
  66059. * @param state defines the state that will be used for the build
  66060. */
  66061. initialize(state: NodeMaterialBuildState): void;
  66062. /**
  66063. * Gets the current class name
  66064. * @returns the class name
  66065. */
  66066. getClassName(): string;
  66067. /**
  66068. * Gets the intensity input component
  66069. */
  66070. get intensity(): NodeMaterialConnectionPoint;
  66071. /**
  66072. * Gets the roughness input component
  66073. */
  66074. get roughness(): NodeMaterialConnectionPoint;
  66075. /**
  66076. * Gets the ior input component
  66077. */
  66078. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66079. /**
  66080. * Gets the bump texture input component
  66081. */
  66082. get normalMapColor(): NodeMaterialConnectionPoint;
  66083. /**
  66084. * Gets the uv input component
  66085. */
  66086. get uv(): NodeMaterialConnectionPoint;
  66087. /**
  66088. * Gets the tint color input component
  66089. */
  66090. get tintColor(): NodeMaterialConnectionPoint;
  66091. /**
  66092. * Gets the tint "at distance" input component
  66093. */
  66094. get tintAtDistance(): NodeMaterialConnectionPoint;
  66095. /**
  66096. * Gets the tint thickness input component
  66097. */
  66098. get tintThickness(): NodeMaterialConnectionPoint;
  66099. /**
  66100. * Gets the world tangent input component
  66101. */
  66102. get worldTangent(): NodeMaterialConnectionPoint;
  66103. /**
  66104. * Gets the clear coat object output component
  66105. */
  66106. get clearcoat(): NodeMaterialConnectionPoint;
  66107. autoConfigure(material: NodeMaterial): void;
  66108. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66109. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66110. private _generateTBNSpace;
  66111. /**
  66112. * Gets the main code of the block (fragment side)
  66113. * @param state current state of the node material building
  66114. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66115. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66116. * @param worldPosVarName name of the variable holding the world position
  66117. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66118. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66119. * @param worldNormalVarName name of the variable holding the world normal
  66120. * @returns the shader code
  66121. */
  66122. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66123. protected _buildBlock(state: NodeMaterialBuildState): this;
  66124. protected _dumpPropertiesCode(): string;
  66125. serialize(): any;
  66126. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66127. }
  66128. }
  66129. declare module BABYLON {
  66130. /**
  66131. * Block used to implement the sub surface module of the PBR material
  66132. */
  66133. export class SubSurfaceBlock extends NodeMaterialBlock {
  66134. /**
  66135. * Create a new SubSurfaceBlock
  66136. * @param name defines the block name
  66137. */
  66138. constructor(name: string);
  66139. /**
  66140. * Initialize the block and prepare the context for build
  66141. * @param state defines the state that will be used for the build
  66142. */
  66143. initialize(state: NodeMaterialBuildState): void;
  66144. /**
  66145. * Gets the current class name
  66146. * @returns the class name
  66147. */
  66148. getClassName(): string;
  66149. /**
  66150. * Gets the thickness component
  66151. */
  66152. get thickness(): NodeMaterialConnectionPoint;
  66153. /**
  66154. * Gets the tint color input component
  66155. */
  66156. get tintColor(): NodeMaterialConnectionPoint;
  66157. /**
  66158. * Gets the translucency intensity input component
  66159. */
  66160. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66161. /**
  66162. * Gets the translucency diffusion distance input component
  66163. */
  66164. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  66165. /**
  66166. * Gets the refraction object parameters
  66167. */
  66168. get refraction(): NodeMaterialConnectionPoint;
  66169. /**
  66170. * Gets the sub surface object output component
  66171. */
  66172. get subsurface(): NodeMaterialConnectionPoint;
  66173. autoConfigure(material: NodeMaterial): void;
  66174. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66175. /**
  66176. * Gets the main code of the block (fragment side)
  66177. * @param state current state of the node material building
  66178. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66179. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66180. * @param worldPosVarName name of the variable holding the world position
  66181. * @returns the shader code
  66182. */
  66183. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66184. protected _buildBlock(state: NodeMaterialBuildState): this;
  66185. }
  66186. }
  66187. declare module BABYLON {
  66188. /**
  66189. * Block used to implement the PBR metallic/roughness model
  66190. */
  66191. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66192. /**
  66193. * Gets or sets the light associated with this block
  66194. */
  66195. light: Nullable<Light>;
  66196. private _lightId;
  66197. private _scene;
  66198. private _environmentBRDFTexture;
  66199. private _environmentBrdfSamplerName;
  66200. private _vNormalWName;
  66201. private _invertNormalName;
  66202. private _metallicReflectanceColor;
  66203. private _metallicF0Factor;
  66204. private _vMetallicReflectanceFactorsName;
  66205. /**
  66206. * Create a new ReflectionBlock
  66207. * @param name defines the block name
  66208. */
  66209. constructor(name: string);
  66210. /**
  66211. * Intensity of the direct lights e.g. the four lights available in your scene.
  66212. * This impacts both the direct diffuse and specular highlights.
  66213. */
  66214. directIntensity: number;
  66215. /**
  66216. * Intensity of the environment e.g. how much the environment will light the object
  66217. * either through harmonics for rough material or through the refelction for shiny ones.
  66218. */
  66219. environmentIntensity: number;
  66220. /**
  66221. * This is a special control allowing the reduction of the specular highlights coming from the
  66222. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66223. */
  66224. specularIntensity: number;
  66225. /**
  66226. * Defines the falloff type used in this material.
  66227. * It by default is Physical.
  66228. */
  66229. lightFalloff: number;
  66230. /**
  66231. * Specifies that alpha test should be used
  66232. */
  66233. useAlphaTest: boolean;
  66234. /**
  66235. * Defines the alpha limits in alpha test mode.
  66236. */
  66237. alphaTestCutoff: number;
  66238. /**
  66239. * Specifies that alpha blending should be used
  66240. */
  66241. useAlphaBlending: boolean;
  66242. /**
  66243. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66244. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66245. */
  66246. useRadianceOverAlpha: boolean;
  66247. /**
  66248. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66249. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66250. */
  66251. useSpecularOverAlpha: boolean;
  66252. /**
  66253. * Enables specular anti aliasing in the PBR shader.
  66254. * It will both interacts on the Geometry for analytical and IBL lighting.
  66255. * It also prefilter the roughness map based on the bump values.
  66256. */
  66257. enableSpecularAntiAliasing: boolean;
  66258. /**
  66259. * Enables realtime filtering on the texture.
  66260. */
  66261. realTimeFiltering: boolean;
  66262. /**
  66263. * Quality switch for realtime filtering
  66264. */
  66265. realTimeFilteringQuality: number;
  66266. /**
  66267. * Defines if the material uses energy conservation.
  66268. */
  66269. useEnergyConservation: boolean;
  66270. /**
  66271. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66272. * too much the area relying on ambient texture to define their ambient occlusion.
  66273. */
  66274. useRadianceOcclusion: boolean;
  66275. /**
  66276. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66277. * makes the reflect vector face the model (under horizon).
  66278. */
  66279. useHorizonOcclusion: boolean;
  66280. /**
  66281. * If set to true, no lighting calculations will be applied.
  66282. */
  66283. unlit: boolean;
  66284. /**
  66285. * Force normal to face away from face.
  66286. */
  66287. forceNormalForward: boolean;
  66288. /**
  66289. * Defines the material debug mode.
  66290. * It helps seeing only some components of the material while troubleshooting.
  66291. */
  66292. debugMode: number;
  66293. /**
  66294. * Specify from where on screen the debug mode should start.
  66295. * The value goes from -1 (full screen) to 1 (not visible)
  66296. * It helps with side by side comparison against the final render
  66297. * This defaults to 0
  66298. */
  66299. debugLimit: number;
  66300. /**
  66301. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66302. * You can use the factor to better multiply the final value.
  66303. */
  66304. debugFactor: number;
  66305. /**
  66306. * Initialize the block and prepare the context for build
  66307. * @param state defines the state that will be used for the build
  66308. */
  66309. initialize(state: NodeMaterialBuildState): void;
  66310. /**
  66311. * Gets the current class name
  66312. * @returns the class name
  66313. */
  66314. getClassName(): string;
  66315. /**
  66316. * Gets the world position input component
  66317. */
  66318. get worldPosition(): NodeMaterialConnectionPoint;
  66319. /**
  66320. * Gets the world normal input component
  66321. */
  66322. get worldNormal(): NodeMaterialConnectionPoint;
  66323. /**
  66324. * Gets the view matrix parameter
  66325. */
  66326. get view(): NodeMaterialConnectionPoint;
  66327. /**
  66328. * Gets the camera position input component
  66329. */
  66330. get cameraPosition(): NodeMaterialConnectionPoint;
  66331. /**
  66332. * Gets the perturbed normal input component
  66333. */
  66334. get perturbedNormal(): NodeMaterialConnectionPoint;
  66335. /**
  66336. * Gets the base color input component
  66337. */
  66338. get baseColor(): NodeMaterialConnectionPoint;
  66339. /**
  66340. * Gets the metallic input component
  66341. */
  66342. get metallic(): NodeMaterialConnectionPoint;
  66343. /**
  66344. * Gets the roughness input component
  66345. */
  66346. get roughness(): NodeMaterialConnectionPoint;
  66347. /**
  66348. * Gets the ambient occlusion input component
  66349. */
  66350. get ambientOcc(): NodeMaterialConnectionPoint;
  66351. /**
  66352. * Gets the opacity input component
  66353. */
  66354. get opacity(): NodeMaterialConnectionPoint;
  66355. /**
  66356. * Gets the index of refraction input component
  66357. */
  66358. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66359. /**
  66360. * Gets the ambient color input component
  66361. */
  66362. get ambientColor(): NodeMaterialConnectionPoint;
  66363. /**
  66364. * Gets the reflection object parameters
  66365. */
  66366. get reflection(): NodeMaterialConnectionPoint;
  66367. /**
  66368. * Gets the clear coat object parameters
  66369. */
  66370. get clearcoat(): NodeMaterialConnectionPoint;
  66371. /**
  66372. * Gets the sheen object parameters
  66373. */
  66374. get sheen(): NodeMaterialConnectionPoint;
  66375. /**
  66376. * Gets the sub surface object parameters
  66377. */
  66378. get subsurface(): NodeMaterialConnectionPoint;
  66379. /**
  66380. * Gets the anisotropy object parameters
  66381. */
  66382. get anisotropy(): NodeMaterialConnectionPoint;
  66383. /**
  66384. * Gets the ambient output component
  66385. */
  66386. get ambientClr(): NodeMaterialConnectionPoint;
  66387. /**
  66388. * Gets the diffuse output component
  66389. */
  66390. get diffuseDir(): NodeMaterialConnectionPoint;
  66391. /**
  66392. * Gets the specular output component
  66393. */
  66394. get specularDir(): NodeMaterialConnectionPoint;
  66395. /**
  66396. * Gets the clear coat output component
  66397. */
  66398. get clearcoatDir(): NodeMaterialConnectionPoint;
  66399. /**
  66400. * Gets the sheen output component
  66401. */
  66402. get sheenDir(): NodeMaterialConnectionPoint;
  66403. /**
  66404. * Gets the indirect diffuse output component
  66405. */
  66406. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66407. /**
  66408. * Gets the indirect specular output component
  66409. */
  66410. get specularIndirect(): NodeMaterialConnectionPoint;
  66411. /**
  66412. * Gets the indirect clear coat output component
  66413. */
  66414. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66415. /**
  66416. * Gets the indirect sheen output component
  66417. */
  66418. get sheenIndirect(): NodeMaterialConnectionPoint;
  66419. /**
  66420. * Gets the refraction output component
  66421. */
  66422. get refraction(): NodeMaterialConnectionPoint;
  66423. /**
  66424. * Gets the global lighting output component
  66425. */
  66426. get lighting(): NodeMaterialConnectionPoint;
  66427. /**
  66428. * Gets the shadow output component
  66429. */
  66430. get shadow(): NodeMaterialConnectionPoint;
  66431. /**
  66432. * Gets the alpha output component
  66433. */
  66434. get alpha(): NodeMaterialConnectionPoint;
  66435. autoConfigure(material: NodeMaterial): void;
  66436. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66437. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66438. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66439. private _injectVertexCode;
  66440. private _getAlbedoOpacityCode;
  66441. private _getAmbientOcclusionCode;
  66442. private _getReflectivityCode;
  66443. protected _buildBlock(state: NodeMaterialBuildState): this;
  66444. protected _dumpPropertiesCode(): string;
  66445. serialize(): any;
  66446. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66447. }
  66448. }
  66449. declare module BABYLON {
  66450. /**
  66451. * Block used to compute value of one parameter modulo another
  66452. */
  66453. export class ModBlock extends NodeMaterialBlock {
  66454. /**
  66455. * Creates a new ModBlock
  66456. * @param name defines the block name
  66457. */
  66458. constructor(name: string);
  66459. /**
  66460. * Gets the current class name
  66461. * @returns the class name
  66462. */
  66463. getClassName(): string;
  66464. /**
  66465. * Gets the left operand input component
  66466. */
  66467. get left(): NodeMaterialConnectionPoint;
  66468. /**
  66469. * Gets the right operand input component
  66470. */
  66471. get right(): NodeMaterialConnectionPoint;
  66472. /**
  66473. * Gets the output component
  66474. */
  66475. get output(): NodeMaterialConnectionPoint;
  66476. protected _buildBlock(state: NodeMaterialBuildState): this;
  66477. }
  66478. }
  66479. declare module BABYLON {
  66480. /**
  66481. * Configuration for Draco compression
  66482. */
  66483. export interface IDracoCompressionConfiguration {
  66484. /**
  66485. * Configuration for the decoder.
  66486. */
  66487. decoder: {
  66488. /**
  66489. * The url to the WebAssembly module.
  66490. */
  66491. wasmUrl?: string;
  66492. /**
  66493. * The url to the WebAssembly binary.
  66494. */
  66495. wasmBinaryUrl?: string;
  66496. /**
  66497. * The url to the fallback JavaScript module.
  66498. */
  66499. fallbackUrl?: string;
  66500. };
  66501. }
  66502. /**
  66503. * Draco compression (https://google.github.io/draco/)
  66504. *
  66505. * This class wraps the Draco module.
  66506. *
  66507. * **Encoder**
  66508. *
  66509. * The encoder is not currently implemented.
  66510. *
  66511. * **Decoder**
  66512. *
  66513. * 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.
  66514. *
  66515. * To update the configuration, use the following code:
  66516. * ```javascript
  66517. * DracoCompression.Configuration = {
  66518. * decoder: {
  66519. * wasmUrl: "<url to the WebAssembly library>",
  66520. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66521. * fallbackUrl: "<url to the fallback JavaScript library>",
  66522. * }
  66523. * };
  66524. * ```
  66525. *
  66526. * 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.
  66527. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66528. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66529. *
  66530. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66531. * ```javascript
  66532. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66533. * ```
  66534. *
  66535. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66536. */
  66537. export class DracoCompression implements IDisposable {
  66538. private _workerPoolPromise?;
  66539. private _decoderModulePromise?;
  66540. /**
  66541. * The configuration. Defaults to the following urls:
  66542. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66543. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66544. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66545. */
  66546. static Configuration: IDracoCompressionConfiguration;
  66547. /**
  66548. * Returns true if the decoder configuration is available.
  66549. */
  66550. static get DecoderAvailable(): boolean;
  66551. /**
  66552. * Default number of workers to create when creating the draco compression object.
  66553. */
  66554. static DefaultNumWorkers: number;
  66555. private static GetDefaultNumWorkers;
  66556. private static _Default;
  66557. /**
  66558. * Default instance for the draco compression object.
  66559. */
  66560. static get Default(): DracoCompression;
  66561. /**
  66562. * Constructor
  66563. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66564. */
  66565. constructor(numWorkers?: number);
  66566. /**
  66567. * Stop all async operations and release resources.
  66568. */
  66569. dispose(): void;
  66570. /**
  66571. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66572. * @returns a promise that resolves when ready
  66573. */
  66574. whenReadyAsync(): Promise<void>;
  66575. /**
  66576. * Decode Draco compressed mesh data to vertex data.
  66577. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66578. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66579. * @returns A promise that resolves with the decoded vertex data
  66580. */
  66581. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66582. [kind: string]: number;
  66583. }): Promise<VertexData>;
  66584. }
  66585. }
  66586. declare module BABYLON {
  66587. /**
  66588. * Class for building Constructive Solid Geometry
  66589. */
  66590. export class CSG {
  66591. private polygons;
  66592. /**
  66593. * The world matrix
  66594. */
  66595. matrix: Matrix;
  66596. /**
  66597. * Stores the position
  66598. */
  66599. position: Vector3;
  66600. /**
  66601. * Stores the rotation
  66602. */
  66603. rotation: Vector3;
  66604. /**
  66605. * Stores the rotation quaternion
  66606. */
  66607. rotationQuaternion: Nullable<Quaternion>;
  66608. /**
  66609. * Stores the scaling vector
  66610. */
  66611. scaling: Vector3;
  66612. /**
  66613. * Convert the Mesh to CSG
  66614. * @param mesh The Mesh to convert to CSG
  66615. * @returns A new CSG from the Mesh
  66616. */
  66617. static FromMesh(mesh: Mesh): CSG;
  66618. /**
  66619. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66620. * @param polygons Polygons used to construct a CSG solid
  66621. */
  66622. private static FromPolygons;
  66623. /**
  66624. * Clones, or makes a deep copy, of the CSG
  66625. * @returns A new CSG
  66626. */
  66627. clone(): CSG;
  66628. /**
  66629. * Unions this CSG with another CSG
  66630. * @param csg The CSG to union against this CSG
  66631. * @returns The unioned CSG
  66632. */
  66633. union(csg: CSG): CSG;
  66634. /**
  66635. * Unions this CSG with another CSG in place
  66636. * @param csg The CSG to union against this CSG
  66637. */
  66638. unionInPlace(csg: CSG): void;
  66639. /**
  66640. * Subtracts this CSG with another CSG
  66641. * @param csg The CSG to subtract against this CSG
  66642. * @returns A new CSG
  66643. */
  66644. subtract(csg: CSG): CSG;
  66645. /**
  66646. * Subtracts this CSG with another CSG in place
  66647. * @param csg The CSG to subtact against this CSG
  66648. */
  66649. subtractInPlace(csg: CSG): void;
  66650. /**
  66651. * Intersect this CSG with another CSG
  66652. * @param csg The CSG to intersect against this CSG
  66653. * @returns A new CSG
  66654. */
  66655. intersect(csg: CSG): CSG;
  66656. /**
  66657. * Intersects this CSG with another CSG in place
  66658. * @param csg The CSG to intersect against this CSG
  66659. */
  66660. intersectInPlace(csg: CSG): void;
  66661. /**
  66662. * Return a new CSG solid with solid and empty space switched. This solid is
  66663. * not modified.
  66664. * @returns A new CSG solid with solid and empty space switched
  66665. */
  66666. inverse(): CSG;
  66667. /**
  66668. * Inverses the CSG in place
  66669. */
  66670. inverseInPlace(): void;
  66671. /**
  66672. * This is used to keep meshes transformations so they can be restored
  66673. * when we build back a Babylon Mesh
  66674. * NB : All CSG operations are performed in world coordinates
  66675. * @param csg The CSG to copy the transform attributes from
  66676. * @returns This CSG
  66677. */
  66678. copyTransformAttributes(csg: CSG): CSG;
  66679. /**
  66680. * Build Raw mesh from CSG
  66681. * Coordinates here are in world space
  66682. * @param name The name of the mesh geometry
  66683. * @param scene The Scene
  66684. * @param keepSubMeshes Specifies if the submeshes should be kept
  66685. * @returns A new Mesh
  66686. */
  66687. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66688. /**
  66689. * Build Mesh from CSG taking material and transforms into account
  66690. * @param name The name of the Mesh
  66691. * @param material The material of the Mesh
  66692. * @param scene The Scene
  66693. * @param keepSubMeshes Specifies if submeshes should be kept
  66694. * @returns The new Mesh
  66695. */
  66696. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66697. }
  66698. }
  66699. declare module BABYLON {
  66700. /**
  66701. * Class used to create a trail following a mesh
  66702. */
  66703. export class TrailMesh extends Mesh {
  66704. private _generator;
  66705. private _autoStart;
  66706. private _running;
  66707. private _diameter;
  66708. private _length;
  66709. private _sectionPolygonPointsCount;
  66710. private _sectionVectors;
  66711. private _sectionNormalVectors;
  66712. private _beforeRenderObserver;
  66713. /**
  66714. * @constructor
  66715. * @param name The value used by scene.getMeshByName() to do a lookup.
  66716. * @param generator The mesh or transform node to generate a trail.
  66717. * @param scene The scene to add this mesh to.
  66718. * @param diameter Diameter of trailing mesh. Default is 1.
  66719. * @param length Length of trailing mesh. Default is 60.
  66720. * @param autoStart Automatically start trailing mesh. Default true.
  66721. */
  66722. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66723. /**
  66724. * "TrailMesh"
  66725. * @returns "TrailMesh"
  66726. */
  66727. getClassName(): string;
  66728. private _createMesh;
  66729. /**
  66730. * Start trailing mesh.
  66731. */
  66732. start(): void;
  66733. /**
  66734. * Stop trailing mesh.
  66735. */
  66736. stop(): void;
  66737. /**
  66738. * Update trailing mesh geometry.
  66739. */
  66740. update(): void;
  66741. /**
  66742. * Returns a new TrailMesh object.
  66743. * @param name is a string, the name given to the new mesh
  66744. * @param newGenerator use new generator object for cloned trail mesh
  66745. * @returns a new mesh
  66746. */
  66747. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66748. /**
  66749. * Serializes this trail mesh
  66750. * @param serializationObject object to write serialization to
  66751. */
  66752. serialize(serializationObject: any): void;
  66753. /**
  66754. * Parses a serialized trail mesh
  66755. * @param parsedMesh the serialized mesh
  66756. * @param scene the scene to create the trail mesh in
  66757. * @returns the created trail mesh
  66758. */
  66759. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66760. }
  66761. }
  66762. declare module BABYLON {
  66763. /**
  66764. * Class containing static functions to help procedurally build meshes
  66765. */
  66766. export class TiledBoxBuilder {
  66767. /**
  66768. * Creates a box mesh
  66769. * 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)
  66770. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66772. * * 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
  66773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66774. * @param name defines the name of the mesh
  66775. * @param options defines the options used to create the mesh
  66776. * @param scene defines the hosting scene
  66777. * @returns the box mesh
  66778. */
  66779. static CreateTiledBox(name: string, options: {
  66780. pattern?: number;
  66781. width?: number;
  66782. height?: number;
  66783. depth?: number;
  66784. tileSize?: number;
  66785. tileWidth?: number;
  66786. tileHeight?: number;
  66787. alignHorizontal?: number;
  66788. alignVertical?: number;
  66789. faceUV?: Vector4[];
  66790. faceColors?: Color4[];
  66791. sideOrientation?: number;
  66792. updatable?: boolean;
  66793. }, scene?: Nullable<Scene>): Mesh;
  66794. }
  66795. }
  66796. declare module BABYLON {
  66797. /**
  66798. * Class containing static functions to help procedurally build meshes
  66799. */
  66800. export class TorusKnotBuilder {
  66801. /**
  66802. * Creates a torus knot mesh
  66803. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66804. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66805. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66806. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66808. * * 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
  66809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66810. * @param name defines the name of the mesh
  66811. * @param options defines the options used to create the mesh
  66812. * @param scene defines the hosting scene
  66813. * @returns the torus knot mesh
  66814. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66815. */
  66816. static CreateTorusKnot(name: string, options: {
  66817. radius?: number;
  66818. tube?: number;
  66819. radialSegments?: number;
  66820. tubularSegments?: number;
  66821. p?: number;
  66822. q?: number;
  66823. updatable?: boolean;
  66824. sideOrientation?: number;
  66825. frontUVs?: Vector4;
  66826. backUVs?: Vector4;
  66827. }, scene: any): Mesh;
  66828. }
  66829. }
  66830. declare module BABYLON {
  66831. /**
  66832. * Polygon
  66833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66834. */
  66835. export class Polygon {
  66836. /**
  66837. * Creates a rectangle
  66838. * @param xmin bottom X coord
  66839. * @param ymin bottom Y coord
  66840. * @param xmax top X coord
  66841. * @param ymax top Y coord
  66842. * @returns points that make the resulting rectation
  66843. */
  66844. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66845. /**
  66846. * Creates a circle
  66847. * @param radius radius of circle
  66848. * @param cx scale in x
  66849. * @param cy scale in y
  66850. * @param numberOfSides number of sides that make up the circle
  66851. * @returns points that make the resulting circle
  66852. */
  66853. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66854. /**
  66855. * Creates a polygon from input string
  66856. * @param input Input polygon data
  66857. * @returns the parsed points
  66858. */
  66859. static Parse(input: string): Vector2[];
  66860. /**
  66861. * Starts building a polygon from x and y coordinates
  66862. * @param x x coordinate
  66863. * @param y y coordinate
  66864. * @returns the started path2
  66865. */
  66866. static StartingAt(x: number, y: number): Path2;
  66867. }
  66868. /**
  66869. * Builds a polygon
  66870. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66871. */
  66872. export class PolygonMeshBuilder {
  66873. private _points;
  66874. private _outlinepoints;
  66875. private _holes;
  66876. private _name;
  66877. private _scene;
  66878. private _epoints;
  66879. private _eholes;
  66880. private _addToepoint;
  66881. /**
  66882. * Babylon reference to the earcut plugin.
  66883. */
  66884. bjsEarcut: any;
  66885. /**
  66886. * Creates a PolygonMeshBuilder
  66887. * @param name name of the builder
  66888. * @param contours Path of the polygon
  66889. * @param scene scene to add to when creating the mesh
  66890. * @param earcutInjection can be used to inject your own earcut reference
  66891. */
  66892. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66893. /**
  66894. * Adds a whole within the polygon
  66895. * @param hole Array of points defining the hole
  66896. * @returns this
  66897. */
  66898. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66899. /**
  66900. * Creates the polygon
  66901. * @param updatable If the mesh should be updatable
  66902. * @param depth The depth of the mesh created
  66903. * @returns the created mesh
  66904. */
  66905. build(updatable?: boolean, depth?: number): Mesh;
  66906. /**
  66907. * Creates the polygon
  66908. * @param depth The depth of the mesh created
  66909. * @returns the created VertexData
  66910. */
  66911. buildVertexData(depth?: number): VertexData;
  66912. /**
  66913. * Adds a side to the polygon
  66914. * @param positions points that make the polygon
  66915. * @param normals normals of the polygon
  66916. * @param uvs uvs of the polygon
  66917. * @param indices indices of the polygon
  66918. * @param bounds bounds of the polygon
  66919. * @param points points of the polygon
  66920. * @param depth depth of the polygon
  66921. * @param flip flip of the polygon
  66922. */
  66923. private addSide;
  66924. }
  66925. }
  66926. declare module BABYLON {
  66927. /**
  66928. * Class containing static functions to help procedurally build meshes
  66929. */
  66930. export class PolygonBuilder {
  66931. /**
  66932. * Creates a polygon mesh
  66933. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66934. * * 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
  66935. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66937. * * 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)
  66938. * * Remember you can only change the shape positions, not their number when updating a polygon
  66939. * @param name defines the name of the mesh
  66940. * @param options defines the options used to create the mesh
  66941. * @param scene defines the hosting scene
  66942. * @param earcutInjection can be used to inject your own earcut reference
  66943. * @returns the polygon mesh
  66944. */
  66945. static CreatePolygon(name: string, options: {
  66946. shape: Vector3[];
  66947. holes?: Vector3[][];
  66948. depth?: number;
  66949. faceUV?: Vector4[];
  66950. faceColors?: Color4[];
  66951. updatable?: boolean;
  66952. sideOrientation?: number;
  66953. frontUVs?: Vector4;
  66954. backUVs?: Vector4;
  66955. wrap?: boolean;
  66956. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66957. /**
  66958. * Creates an extruded polygon mesh, with depth in the Y direction.
  66959. * * 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)
  66960. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66961. * @param name defines the name of the mesh
  66962. * @param options defines the options used to create the mesh
  66963. * @param scene defines the hosting scene
  66964. * @param earcutInjection can be used to inject your own earcut reference
  66965. * @returns the polygon mesh
  66966. */
  66967. static ExtrudePolygon(name: string, options: {
  66968. shape: Vector3[];
  66969. holes?: Vector3[][];
  66970. depth?: number;
  66971. faceUV?: Vector4[];
  66972. faceColors?: Color4[];
  66973. updatable?: boolean;
  66974. sideOrientation?: number;
  66975. frontUVs?: Vector4;
  66976. backUVs?: Vector4;
  66977. wrap?: boolean;
  66978. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66979. }
  66980. }
  66981. declare module BABYLON {
  66982. /**
  66983. * Class containing static functions to help procedurally build meshes
  66984. */
  66985. export class LatheBuilder {
  66986. /**
  66987. * Creates lathe mesh.
  66988. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66989. * * 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
  66990. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66991. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66992. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66993. * * 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
  66994. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66995. * * 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
  66996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66997. * * 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
  66998. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67000. * @param name defines the name of the mesh
  67001. * @param options defines the options used to create the mesh
  67002. * @param scene defines the hosting scene
  67003. * @returns the lathe mesh
  67004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67005. */
  67006. static CreateLathe(name: string, options: {
  67007. shape: Vector3[];
  67008. radius?: number;
  67009. tessellation?: number;
  67010. clip?: number;
  67011. arc?: number;
  67012. closed?: boolean;
  67013. updatable?: boolean;
  67014. sideOrientation?: number;
  67015. frontUVs?: Vector4;
  67016. backUVs?: Vector4;
  67017. cap?: number;
  67018. invertUV?: boolean;
  67019. }, scene?: Nullable<Scene>): Mesh;
  67020. }
  67021. }
  67022. declare module BABYLON {
  67023. /**
  67024. * Class containing static functions to help procedurally build meshes
  67025. */
  67026. export class TiledPlaneBuilder {
  67027. /**
  67028. * Creates a tiled plane mesh
  67029. * * The parameter `pattern` will, depending on value, do nothing or
  67030. * * * flip (reflect about central vertical) alternate tiles across and up
  67031. * * * flip every tile on alternate rows
  67032. * * * rotate (180 degs) alternate tiles across and up
  67033. * * * rotate every tile on alternate rows
  67034. * * * flip and rotate alternate tiles across and up
  67035. * * * flip and rotate every tile on alternate rows
  67036. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67037. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67038. * * 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
  67039. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67040. * * 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)
  67041. * * 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)
  67042. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67043. * @param name defines the name of the mesh
  67044. * @param options defines the options used to create the mesh
  67045. * @param scene defines the hosting scene
  67046. * @returns the box mesh
  67047. */
  67048. static CreateTiledPlane(name: string, options: {
  67049. pattern?: number;
  67050. tileSize?: number;
  67051. tileWidth?: number;
  67052. tileHeight?: number;
  67053. size?: number;
  67054. width?: number;
  67055. height?: number;
  67056. alignHorizontal?: number;
  67057. alignVertical?: number;
  67058. sideOrientation?: number;
  67059. frontUVs?: Vector4;
  67060. backUVs?: Vector4;
  67061. updatable?: boolean;
  67062. }, scene?: Nullable<Scene>): Mesh;
  67063. }
  67064. }
  67065. declare module BABYLON {
  67066. /**
  67067. * Class containing static functions to help procedurally build meshes
  67068. */
  67069. export class TubeBuilder {
  67070. /**
  67071. * Creates a tube mesh.
  67072. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67073. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67074. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67075. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67076. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67077. * * 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)
  67078. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67079. * * 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
  67080. * * 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
  67081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67082. * * 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
  67083. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67085. * @param name defines the name of the mesh
  67086. * @param options defines the options used to create the mesh
  67087. * @param scene defines the hosting scene
  67088. * @returns the tube mesh
  67089. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67090. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67091. */
  67092. static CreateTube(name: string, options: {
  67093. path: Vector3[];
  67094. radius?: number;
  67095. tessellation?: number;
  67096. radiusFunction?: {
  67097. (i: number, distance: number): number;
  67098. };
  67099. cap?: number;
  67100. arc?: number;
  67101. updatable?: boolean;
  67102. sideOrientation?: number;
  67103. frontUVs?: Vector4;
  67104. backUVs?: Vector4;
  67105. instance?: Mesh;
  67106. invertUV?: boolean;
  67107. }, scene?: Nullable<Scene>): Mesh;
  67108. }
  67109. }
  67110. declare module BABYLON {
  67111. /**
  67112. * Class containing static functions to help procedurally build meshes
  67113. */
  67114. export class IcoSphereBuilder {
  67115. /**
  67116. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67117. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67118. * * 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`)
  67119. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67120. * * 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
  67121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67122. * * 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
  67123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67124. * @param name defines the name of the mesh
  67125. * @param options defines the options used to create the mesh
  67126. * @param scene defines the hosting scene
  67127. * @returns the icosahedron mesh
  67128. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67129. */
  67130. static CreateIcoSphere(name: string, options: {
  67131. radius?: number;
  67132. radiusX?: number;
  67133. radiusY?: number;
  67134. radiusZ?: number;
  67135. flat?: boolean;
  67136. subdivisions?: number;
  67137. sideOrientation?: number;
  67138. frontUVs?: Vector4;
  67139. backUVs?: Vector4;
  67140. updatable?: boolean;
  67141. }, scene?: Nullable<Scene>): Mesh;
  67142. }
  67143. }
  67144. declare module BABYLON {
  67145. /**
  67146. * Class containing static functions to help procedurally build meshes
  67147. */
  67148. export class DecalBuilder {
  67149. /**
  67150. * Creates a decal mesh.
  67151. * 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
  67152. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67153. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67154. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67155. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67156. * @param name defines the name of the mesh
  67157. * @param sourceMesh defines the mesh where the decal must be applied
  67158. * @param options defines the options used to create the mesh
  67159. * @param scene defines the hosting scene
  67160. * @returns the decal mesh
  67161. * @see https://doc.babylonjs.com/how_to/decals
  67162. */
  67163. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67164. position?: Vector3;
  67165. normal?: Vector3;
  67166. size?: Vector3;
  67167. angle?: number;
  67168. }): Mesh;
  67169. }
  67170. }
  67171. declare module BABYLON {
  67172. /**
  67173. * Class containing static functions to help procedurally build meshes
  67174. */
  67175. export class MeshBuilder {
  67176. /**
  67177. * Creates a box mesh
  67178. * * The parameter `size` sets the size (float) of each box side (default 1)
  67179. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67180. * * 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)
  67181. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67183. * * 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
  67184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67185. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67186. * @param name defines the name of the mesh
  67187. * @param options defines the options used to create the mesh
  67188. * @param scene defines the hosting scene
  67189. * @returns the box mesh
  67190. */
  67191. static CreateBox(name: string, options: {
  67192. size?: number;
  67193. width?: number;
  67194. height?: number;
  67195. depth?: number;
  67196. faceUV?: Vector4[];
  67197. faceColors?: Color4[];
  67198. sideOrientation?: number;
  67199. frontUVs?: Vector4;
  67200. backUVs?: Vector4;
  67201. wrap?: boolean;
  67202. topBaseAt?: number;
  67203. bottomBaseAt?: number;
  67204. updatable?: boolean;
  67205. }, scene?: Nullable<Scene>): Mesh;
  67206. /**
  67207. * Creates a tiled box mesh
  67208. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67210. * @param name defines the name of the mesh
  67211. * @param options defines the options used to create the mesh
  67212. * @param scene defines the hosting scene
  67213. * @returns the tiled box mesh
  67214. */
  67215. static CreateTiledBox(name: string, options: {
  67216. pattern?: number;
  67217. size?: number;
  67218. width?: number;
  67219. height?: number;
  67220. depth: number;
  67221. tileSize?: number;
  67222. tileWidth?: number;
  67223. tileHeight?: number;
  67224. faceUV?: Vector4[];
  67225. faceColors?: Color4[];
  67226. alignHorizontal?: number;
  67227. alignVertical?: number;
  67228. sideOrientation?: number;
  67229. updatable?: boolean;
  67230. }, scene?: Nullable<Scene>): Mesh;
  67231. /**
  67232. * Creates a sphere mesh
  67233. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67234. * * 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`)
  67235. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67236. * * 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
  67237. * * 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)
  67238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67239. * * 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
  67240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67241. * @param name defines the name of the mesh
  67242. * @param options defines the options used to create the mesh
  67243. * @param scene defines the hosting scene
  67244. * @returns the sphere mesh
  67245. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67246. */
  67247. static CreateSphere(name: string, options: {
  67248. segments?: number;
  67249. diameter?: number;
  67250. diameterX?: number;
  67251. diameterY?: number;
  67252. diameterZ?: number;
  67253. arc?: number;
  67254. slice?: number;
  67255. sideOrientation?: number;
  67256. frontUVs?: Vector4;
  67257. backUVs?: Vector4;
  67258. updatable?: boolean;
  67259. }, scene?: Nullable<Scene>): Mesh;
  67260. /**
  67261. * Creates a plane polygonal mesh. By default, this is a disc
  67262. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67263. * * 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
  67264. * * 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
  67265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67266. * * 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
  67267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67268. * @param name defines the name of the mesh
  67269. * @param options defines the options used to create the mesh
  67270. * @param scene defines the hosting scene
  67271. * @returns the plane polygonal mesh
  67272. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67273. */
  67274. static CreateDisc(name: string, options: {
  67275. radius?: number;
  67276. tessellation?: number;
  67277. arc?: number;
  67278. updatable?: boolean;
  67279. sideOrientation?: number;
  67280. frontUVs?: Vector4;
  67281. backUVs?: Vector4;
  67282. }, scene?: Nullable<Scene>): Mesh;
  67283. /**
  67284. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67285. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67286. * * 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`)
  67287. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67288. * * 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
  67289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67290. * * 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
  67291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67292. * @param name defines the name of the mesh
  67293. * @param options defines the options used to create the mesh
  67294. * @param scene defines the hosting scene
  67295. * @returns the icosahedron mesh
  67296. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67297. */
  67298. static CreateIcoSphere(name: string, options: {
  67299. radius?: number;
  67300. radiusX?: number;
  67301. radiusY?: number;
  67302. radiusZ?: number;
  67303. flat?: boolean;
  67304. subdivisions?: number;
  67305. sideOrientation?: number;
  67306. frontUVs?: Vector4;
  67307. backUVs?: Vector4;
  67308. updatable?: boolean;
  67309. }, scene?: Nullable<Scene>): Mesh;
  67310. /**
  67311. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67312. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67313. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67314. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67315. * * 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
  67316. * * 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
  67317. * * 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
  67318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67319. * * 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
  67320. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67321. * * 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
  67322. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67323. * * 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
  67324. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67326. * @param name defines the name of the mesh
  67327. * @param options defines the options used to create the mesh
  67328. * @param scene defines the hosting scene
  67329. * @returns the ribbon mesh
  67330. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67331. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67332. */
  67333. static CreateRibbon(name: string, options: {
  67334. pathArray: Vector3[][];
  67335. closeArray?: boolean;
  67336. closePath?: boolean;
  67337. offset?: number;
  67338. updatable?: boolean;
  67339. sideOrientation?: number;
  67340. frontUVs?: Vector4;
  67341. backUVs?: Vector4;
  67342. instance?: Mesh;
  67343. invertUV?: boolean;
  67344. uvs?: Vector2[];
  67345. colors?: Color4[];
  67346. }, scene?: Nullable<Scene>): Mesh;
  67347. /**
  67348. * Creates a cylinder or a cone mesh
  67349. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67350. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67351. * * 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.
  67352. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67353. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67354. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67355. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67356. * * 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).
  67357. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67358. * * 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).
  67359. * * 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
  67360. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67361. * * 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
  67362. * * 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.
  67363. * * If `enclose` is false, a ring surface is one element.
  67364. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67365. * * 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
  67366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67367. * * 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
  67368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67369. * @param name defines the name of the mesh
  67370. * @param options defines the options used to create the mesh
  67371. * @param scene defines the hosting scene
  67372. * @returns the cylinder mesh
  67373. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67374. */
  67375. static CreateCylinder(name: string, options: {
  67376. height?: number;
  67377. diameterTop?: number;
  67378. diameterBottom?: number;
  67379. diameter?: number;
  67380. tessellation?: number;
  67381. subdivisions?: number;
  67382. arc?: number;
  67383. faceColors?: Color4[];
  67384. faceUV?: Vector4[];
  67385. updatable?: boolean;
  67386. hasRings?: boolean;
  67387. enclose?: boolean;
  67388. cap?: number;
  67389. sideOrientation?: number;
  67390. frontUVs?: Vector4;
  67391. backUVs?: Vector4;
  67392. }, scene?: Nullable<Scene>): Mesh;
  67393. /**
  67394. * Creates a torus mesh
  67395. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67396. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67397. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67399. * * 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
  67400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67401. * @param name defines the name of the mesh
  67402. * @param options defines the options used to create the mesh
  67403. * @param scene defines the hosting scene
  67404. * @returns the torus mesh
  67405. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67406. */
  67407. static CreateTorus(name: string, options: {
  67408. diameter?: number;
  67409. thickness?: number;
  67410. tessellation?: number;
  67411. updatable?: boolean;
  67412. sideOrientation?: number;
  67413. frontUVs?: Vector4;
  67414. backUVs?: Vector4;
  67415. }, scene?: Nullable<Scene>): Mesh;
  67416. /**
  67417. * Creates a torus knot mesh
  67418. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67419. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67420. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67421. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67423. * * 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
  67424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67425. * @param name defines the name of the mesh
  67426. * @param options defines the options used to create the mesh
  67427. * @param scene defines the hosting scene
  67428. * @returns the torus knot mesh
  67429. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67430. */
  67431. static CreateTorusKnot(name: string, options: {
  67432. radius?: number;
  67433. tube?: number;
  67434. radialSegments?: number;
  67435. tubularSegments?: number;
  67436. p?: number;
  67437. q?: number;
  67438. updatable?: boolean;
  67439. sideOrientation?: number;
  67440. frontUVs?: Vector4;
  67441. backUVs?: Vector4;
  67442. }, scene?: Nullable<Scene>): Mesh;
  67443. /**
  67444. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67445. * * 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
  67446. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67447. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67448. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67449. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67450. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67451. * * 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
  67452. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67454. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67455. * @param name defines the name of the new line system
  67456. * @param options defines the options used to create the line system
  67457. * @param scene defines the hosting scene
  67458. * @returns a new line system mesh
  67459. */
  67460. static CreateLineSystem(name: string, options: {
  67461. lines: Vector3[][];
  67462. updatable?: boolean;
  67463. instance?: Nullable<LinesMesh>;
  67464. colors?: Nullable<Color4[][]>;
  67465. useVertexAlpha?: boolean;
  67466. }, scene: Nullable<Scene>): LinesMesh;
  67467. /**
  67468. * Creates a line mesh
  67469. * 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
  67470. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67471. * * The parameter `points` is an array successive Vector3
  67472. * * 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
  67473. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67474. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67475. * * When updating an instance, remember that only point positions can change, not the number of points
  67476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67477. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67478. * @param name defines the name of the new line system
  67479. * @param options defines the options used to create the line system
  67480. * @param scene defines the hosting scene
  67481. * @returns a new line mesh
  67482. */
  67483. static CreateLines(name: string, options: {
  67484. points: Vector3[];
  67485. updatable?: boolean;
  67486. instance?: Nullable<LinesMesh>;
  67487. colors?: Color4[];
  67488. useVertexAlpha?: boolean;
  67489. }, scene?: Nullable<Scene>): LinesMesh;
  67490. /**
  67491. * Creates a dashed line mesh
  67492. * * 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
  67493. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67494. * * The parameter `points` is an array successive Vector3
  67495. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67496. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67497. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67498. * * 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
  67499. * * When updating an instance, remember that only point positions can change, not the number of points
  67500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67501. * @param name defines the name of the mesh
  67502. * @param options defines the options used to create the mesh
  67503. * @param scene defines the hosting scene
  67504. * @returns the dashed line mesh
  67505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67506. */
  67507. static CreateDashedLines(name: string, options: {
  67508. points: Vector3[];
  67509. dashSize?: number;
  67510. gapSize?: number;
  67511. dashNb?: number;
  67512. updatable?: boolean;
  67513. instance?: LinesMesh;
  67514. }, scene?: Nullable<Scene>): LinesMesh;
  67515. /**
  67516. * 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.
  67517. * * 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.
  67518. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67519. * * 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.
  67520. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67521. * * 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
  67522. * * 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
  67523. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67525. * * 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
  67526. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67528. * @param name defines the name of the mesh
  67529. * @param options defines the options used to create the mesh
  67530. * @param scene defines the hosting scene
  67531. * @returns the extruded shape mesh
  67532. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67533. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67534. */
  67535. static ExtrudeShape(name: string, options: {
  67536. shape: Vector3[];
  67537. path: Vector3[];
  67538. scale?: number;
  67539. rotation?: number;
  67540. cap?: number;
  67541. updatable?: boolean;
  67542. sideOrientation?: number;
  67543. frontUVs?: Vector4;
  67544. backUVs?: Vector4;
  67545. instance?: Mesh;
  67546. invertUV?: boolean;
  67547. }, scene?: Nullable<Scene>): Mesh;
  67548. /**
  67549. * Creates an custom extruded shape mesh.
  67550. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67551. * * 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.
  67552. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67553. * * 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
  67554. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67555. * * 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
  67556. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67557. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67558. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67559. * * 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
  67560. * * 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
  67561. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67563. * * 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
  67564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67566. * @param name defines the name of the mesh
  67567. * @param options defines the options used to create the mesh
  67568. * @param scene defines the hosting scene
  67569. * @returns the custom extruded shape mesh
  67570. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67571. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67572. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67573. */
  67574. static ExtrudeShapeCustom(name: string, options: {
  67575. shape: Vector3[];
  67576. path: Vector3[];
  67577. scaleFunction?: any;
  67578. rotationFunction?: any;
  67579. ribbonCloseArray?: boolean;
  67580. ribbonClosePath?: boolean;
  67581. cap?: number;
  67582. updatable?: boolean;
  67583. sideOrientation?: number;
  67584. frontUVs?: Vector4;
  67585. backUVs?: Vector4;
  67586. instance?: Mesh;
  67587. invertUV?: boolean;
  67588. }, scene?: Nullable<Scene>): Mesh;
  67589. /**
  67590. * Creates lathe mesh.
  67591. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67592. * * 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
  67593. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67594. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67595. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67596. * * 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
  67597. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67598. * * 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
  67599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67600. * * 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
  67601. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67603. * @param name defines the name of the mesh
  67604. * @param options defines the options used to create the mesh
  67605. * @param scene defines the hosting scene
  67606. * @returns the lathe mesh
  67607. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67608. */
  67609. static CreateLathe(name: string, options: {
  67610. shape: Vector3[];
  67611. radius?: number;
  67612. tessellation?: number;
  67613. clip?: number;
  67614. arc?: number;
  67615. closed?: boolean;
  67616. updatable?: boolean;
  67617. sideOrientation?: number;
  67618. frontUVs?: Vector4;
  67619. backUVs?: Vector4;
  67620. cap?: number;
  67621. invertUV?: boolean;
  67622. }, scene?: Nullable<Scene>): Mesh;
  67623. /**
  67624. * Creates a tiled plane mesh
  67625. * * You can set a limited pattern arrangement with the tiles
  67626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67627. * * 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
  67628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67629. * @param name defines the name of the mesh
  67630. * @param options defines the options used to create the mesh
  67631. * @param scene defines the hosting scene
  67632. * @returns the plane mesh
  67633. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67634. */
  67635. static CreateTiledPlane(name: string, options: {
  67636. pattern?: number;
  67637. tileSize?: number;
  67638. tileWidth?: number;
  67639. tileHeight?: number;
  67640. size?: number;
  67641. width?: number;
  67642. height?: number;
  67643. alignHorizontal?: number;
  67644. alignVertical?: number;
  67645. sideOrientation?: number;
  67646. frontUVs?: Vector4;
  67647. backUVs?: Vector4;
  67648. updatable?: boolean;
  67649. }, scene?: Nullable<Scene>): Mesh;
  67650. /**
  67651. * Creates a plane mesh
  67652. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67653. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67654. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67656. * * 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
  67657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67658. * @param name defines the name of the mesh
  67659. * @param options defines the options used to create the mesh
  67660. * @param scene defines the hosting scene
  67661. * @returns the plane mesh
  67662. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67663. */
  67664. static CreatePlane(name: string, options: {
  67665. size?: number;
  67666. width?: number;
  67667. height?: number;
  67668. sideOrientation?: number;
  67669. frontUVs?: Vector4;
  67670. backUVs?: Vector4;
  67671. updatable?: boolean;
  67672. sourcePlane?: Plane;
  67673. }, scene?: Nullable<Scene>): Mesh;
  67674. /**
  67675. * Creates a ground mesh
  67676. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67677. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67679. * @param name defines the name of the mesh
  67680. * @param options defines the options used to create the mesh
  67681. * @param scene defines the hosting scene
  67682. * @returns the ground mesh
  67683. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67684. */
  67685. static CreateGround(name: string, options: {
  67686. width?: number;
  67687. height?: number;
  67688. subdivisions?: number;
  67689. subdivisionsX?: number;
  67690. subdivisionsY?: number;
  67691. updatable?: boolean;
  67692. }, scene?: Nullable<Scene>): Mesh;
  67693. /**
  67694. * Creates a tiled ground mesh
  67695. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67696. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67697. * * 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
  67698. * * 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
  67699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67700. * @param name defines the name of the mesh
  67701. * @param options defines the options used to create the mesh
  67702. * @param scene defines the hosting scene
  67703. * @returns the tiled ground mesh
  67704. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67705. */
  67706. static CreateTiledGround(name: string, options: {
  67707. xmin: number;
  67708. zmin: number;
  67709. xmax: number;
  67710. zmax: number;
  67711. subdivisions?: {
  67712. w: number;
  67713. h: number;
  67714. };
  67715. precision?: {
  67716. w: number;
  67717. h: number;
  67718. };
  67719. updatable?: boolean;
  67720. }, scene?: Nullable<Scene>): Mesh;
  67721. /**
  67722. * Creates a ground mesh from a height map
  67723. * * The parameter `url` sets the URL of the height map image resource.
  67724. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67725. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67726. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67727. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67728. * * 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.
  67729. * * 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).
  67730. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67732. * @param name defines the name of the mesh
  67733. * @param url defines the url to the height map
  67734. * @param options defines the options used to create the mesh
  67735. * @param scene defines the hosting scene
  67736. * @returns the ground mesh
  67737. * @see https://doc.babylonjs.com/babylon101/height_map
  67738. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67739. */
  67740. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67741. width?: number;
  67742. height?: number;
  67743. subdivisions?: number;
  67744. minHeight?: number;
  67745. maxHeight?: number;
  67746. colorFilter?: Color3;
  67747. alphaFilter?: number;
  67748. updatable?: boolean;
  67749. onReady?: (mesh: GroundMesh) => void;
  67750. }, scene?: Nullable<Scene>): GroundMesh;
  67751. /**
  67752. * Creates a polygon mesh
  67753. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67754. * * 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
  67755. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67757. * * 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)
  67758. * * Remember you can only change the shape positions, not their number when updating a polygon
  67759. * @param name defines the name of the mesh
  67760. * @param options defines the options used to create the mesh
  67761. * @param scene defines the hosting scene
  67762. * @param earcutInjection can be used to inject your own earcut reference
  67763. * @returns the polygon mesh
  67764. */
  67765. static CreatePolygon(name: string, options: {
  67766. shape: Vector3[];
  67767. holes?: Vector3[][];
  67768. depth?: number;
  67769. faceUV?: Vector4[];
  67770. faceColors?: Color4[];
  67771. updatable?: boolean;
  67772. sideOrientation?: number;
  67773. frontUVs?: Vector4;
  67774. backUVs?: Vector4;
  67775. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67776. /**
  67777. * Creates an extruded polygon mesh, with depth in the Y direction.
  67778. * * 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)
  67779. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67780. * @param name defines the name of the mesh
  67781. * @param options defines the options used to create the mesh
  67782. * @param scene defines the hosting scene
  67783. * @param earcutInjection can be used to inject your own earcut reference
  67784. * @returns the polygon mesh
  67785. */
  67786. static ExtrudePolygon(name: string, options: {
  67787. shape: Vector3[];
  67788. holes?: Vector3[][];
  67789. depth?: number;
  67790. faceUV?: Vector4[];
  67791. faceColors?: Color4[];
  67792. updatable?: boolean;
  67793. sideOrientation?: number;
  67794. frontUVs?: Vector4;
  67795. backUVs?: Vector4;
  67796. wrap?: boolean;
  67797. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67798. /**
  67799. * Creates a tube mesh.
  67800. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67801. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67802. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67803. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67804. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67805. * * 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)
  67806. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67807. * * 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
  67808. * * 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
  67809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67810. * * 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
  67811. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67813. * @param name defines the name of the mesh
  67814. * @param options defines the options used to create the mesh
  67815. * @param scene defines the hosting scene
  67816. * @returns the tube mesh
  67817. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67818. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67819. */
  67820. static CreateTube(name: string, options: {
  67821. path: Vector3[];
  67822. radius?: number;
  67823. tessellation?: number;
  67824. radiusFunction?: {
  67825. (i: number, distance: number): number;
  67826. };
  67827. cap?: number;
  67828. arc?: number;
  67829. updatable?: boolean;
  67830. sideOrientation?: number;
  67831. frontUVs?: Vector4;
  67832. backUVs?: Vector4;
  67833. instance?: Mesh;
  67834. invertUV?: boolean;
  67835. }, scene?: Nullable<Scene>): Mesh;
  67836. /**
  67837. * Creates a polyhedron mesh
  67838. * * 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
  67839. * * The parameter `size` (positive float, default 1) sets the polygon size
  67840. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67841. * * 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`
  67842. * * 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
  67843. * * 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)`)
  67844. * * 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
  67845. * * 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
  67846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67847. * * 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
  67848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67849. * @param name defines the name of the mesh
  67850. * @param options defines the options used to create the mesh
  67851. * @param scene defines the hosting scene
  67852. * @returns the polyhedron mesh
  67853. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67854. */
  67855. static CreatePolyhedron(name: string, options: {
  67856. type?: number;
  67857. size?: number;
  67858. sizeX?: number;
  67859. sizeY?: number;
  67860. sizeZ?: number;
  67861. custom?: any;
  67862. faceUV?: Vector4[];
  67863. faceColors?: Color4[];
  67864. flat?: boolean;
  67865. updatable?: boolean;
  67866. sideOrientation?: number;
  67867. frontUVs?: Vector4;
  67868. backUVs?: Vector4;
  67869. }, scene?: Nullable<Scene>): Mesh;
  67870. /**
  67871. * Creates a decal mesh.
  67872. * 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
  67873. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67874. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67875. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67876. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67877. * @param name defines the name of the mesh
  67878. * @param sourceMesh defines the mesh where the decal must be applied
  67879. * @param options defines the options used to create the mesh
  67880. * @param scene defines the hosting scene
  67881. * @returns the decal mesh
  67882. * @see https://doc.babylonjs.com/how_to/decals
  67883. */
  67884. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67885. position?: Vector3;
  67886. normal?: Vector3;
  67887. size?: Vector3;
  67888. angle?: number;
  67889. }): Mesh;
  67890. /**
  67891. * Creates a Capsule Mesh
  67892. * @param name defines the name of the mesh.
  67893. * @param options the constructors options used to shape the mesh.
  67894. * @param scene defines the scene the mesh is scoped to.
  67895. * @returns the capsule mesh
  67896. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67897. */
  67898. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67899. }
  67900. }
  67901. declare module BABYLON {
  67902. /**
  67903. * A simplifier interface for future simplification implementations
  67904. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67905. */
  67906. export interface ISimplifier {
  67907. /**
  67908. * Simplification of a given mesh according to the given settings.
  67909. * Since this requires computation, it is assumed that the function runs async.
  67910. * @param settings The settings of the simplification, including quality and distance
  67911. * @param successCallback A callback that will be called after the mesh was simplified.
  67912. * @param errorCallback in case of an error, this callback will be called. optional.
  67913. */
  67914. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67915. }
  67916. /**
  67917. * Expected simplification settings.
  67918. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67919. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67920. */
  67921. export interface ISimplificationSettings {
  67922. /**
  67923. * Gets or sets the expected quality
  67924. */
  67925. quality: number;
  67926. /**
  67927. * Gets or sets the distance when this optimized version should be used
  67928. */
  67929. distance: number;
  67930. /**
  67931. * Gets an already optimized mesh
  67932. */
  67933. optimizeMesh?: boolean;
  67934. }
  67935. /**
  67936. * Class used to specify simplification options
  67937. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67938. */
  67939. export class SimplificationSettings implements ISimplificationSettings {
  67940. /** expected quality */
  67941. quality: number;
  67942. /** distance when this optimized version should be used */
  67943. distance: number;
  67944. /** already optimized mesh */
  67945. optimizeMesh?: boolean | undefined;
  67946. /**
  67947. * Creates a SimplificationSettings
  67948. * @param quality expected quality
  67949. * @param distance distance when this optimized version should be used
  67950. * @param optimizeMesh already optimized mesh
  67951. */
  67952. constructor(
  67953. /** expected quality */
  67954. quality: number,
  67955. /** distance when this optimized version should be used */
  67956. distance: number,
  67957. /** already optimized mesh */
  67958. optimizeMesh?: boolean | undefined);
  67959. }
  67960. /**
  67961. * Interface used to define a simplification task
  67962. */
  67963. export interface ISimplificationTask {
  67964. /**
  67965. * Array of settings
  67966. */
  67967. settings: Array<ISimplificationSettings>;
  67968. /**
  67969. * Simplification type
  67970. */
  67971. simplificationType: SimplificationType;
  67972. /**
  67973. * Mesh to simplify
  67974. */
  67975. mesh: Mesh;
  67976. /**
  67977. * Callback called on success
  67978. */
  67979. successCallback?: () => void;
  67980. /**
  67981. * Defines if parallel processing can be used
  67982. */
  67983. parallelProcessing: boolean;
  67984. }
  67985. /**
  67986. * Queue used to order the simplification tasks
  67987. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67988. */
  67989. export class SimplificationQueue {
  67990. private _simplificationArray;
  67991. /**
  67992. * Gets a boolean indicating that the process is still running
  67993. */
  67994. running: boolean;
  67995. /**
  67996. * Creates a new queue
  67997. */
  67998. constructor();
  67999. /**
  68000. * Adds a new simplification task
  68001. * @param task defines a task to add
  68002. */
  68003. addTask(task: ISimplificationTask): void;
  68004. /**
  68005. * Execute next task
  68006. */
  68007. executeNext(): void;
  68008. /**
  68009. * Execute a simplification task
  68010. * @param task defines the task to run
  68011. */
  68012. runSimplification(task: ISimplificationTask): void;
  68013. private getSimplifier;
  68014. }
  68015. /**
  68016. * The implemented types of simplification
  68017. * At the moment only Quadratic Error Decimation is implemented
  68018. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68019. */
  68020. export enum SimplificationType {
  68021. /** Quadratic error decimation */
  68022. QUADRATIC = 0
  68023. }
  68024. /**
  68025. * An implementation of the Quadratic Error simplification algorithm.
  68026. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68027. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68028. * @author RaananW
  68029. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68030. */
  68031. export class QuadraticErrorSimplification implements ISimplifier {
  68032. private _mesh;
  68033. private triangles;
  68034. private vertices;
  68035. private references;
  68036. private _reconstructedMesh;
  68037. /** Gets or sets the number pf sync interations */
  68038. syncIterations: number;
  68039. /** Gets or sets the aggressiveness of the simplifier */
  68040. aggressiveness: number;
  68041. /** Gets or sets the number of allowed iterations for decimation */
  68042. decimationIterations: number;
  68043. /** Gets or sets the espilon to use for bounding box computation */
  68044. boundingBoxEpsilon: number;
  68045. /**
  68046. * Creates a new QuadraticErrorSimplification
  68047. * @param _mesh defines the target mesh
  68048. */
  68049. constructor(_mesh: Mesh);
  68050. /**
  68051. * Simplification of a given mesh according to the given settings.
  68052. * Since this requires computation, it is assumed that the function runs async.
  68053. * @param settings The settings of the simplification, including quality and distance
  68054. * @param successCallback A callback that will be called after the mesh was simplified.
  68055. */
  68056. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68057. private runDecimation;
  68058. private initWithMesh;
  68059. private init;
  68060. private reconstructMesh;
  68061. private initDecimatedMesh;
  68062. private isFlipped;
  68063. private updateTriangles;
  68064. private identifyBorder;
  68065. private updateMesh;
  68066. private vertexError;
  68067. private calculateError;
  68068. }
  68069. }
  68070. declare module BABYLON {
  68071. interface Scene {
  68072. /** @hidden (Backing field) */
  68073. _simplificationQueue: SimplificationQueue;
  68074. /**
  68075. * Gets or sets the simplification queue attached to the scene
  68076. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68077. */
  68078. simplificationQueue: SimplificationQueue;
  68079. }
  68080. interface Mesh {
  68081. /**
  68082. * Simplify the mesh according to the given array of settings.
  68083. * Function will return immediately and will simplify async
  68084. * @param settings a collection of simplification settings
  68085. * @param parallelProcessing should all levels calculate parallel or one after the other
  68086. * @param simplificationType the type of simplification to run
  68087. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68088. * @returns the current mesh
  68089. */
  68090. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68091. }
  68092. /**
  68093. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68094. * created in a scene
  68095. */
  68096. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68097. /**
  68098. * The component name helpfull to identify the component in the list of scene components.
  68099. */
  68100. readonly name: string;
  68101. /**
  68102. * The scene the component belongs to.
  68103. */
  68104. scene: Scene;
  68105. /**
  68106. * Creates a new instance of the component for the given scene
  68107. * @param scene Defines the scene to register the component in
  68108. */
  68109. constructor(scene: Scene);
  68110. /**
  68111. * Registers the component in a given scene
  68112. */
  68113. register(): void;
  68114. /**
  68115. * Rebuilds the elements related to this component in case of
  68116. * context lost for instance.
  68117. */
  68118. rebuild(): void;
  68119. /**
  68120. * Disposes the component and the associated ressources
  68121. */
  68122. dispose(): void;
  68123. private _beforeCameraUpdate;
  68124. }
  68125. }
  68126. declare module BABYLON {
  68127. interface Mesh {
  68128. /**
  68129. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  68130. */
  68131. thinInstanceEnablePicking: boolean;
  68132. /**
  68133. * Creates a new thin instance
  68134. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68135. * @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
  68136. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68137. */
  68138. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68139. /**
  68140. * Adds the transformation (matrix) of the current mesh as a thin instance
  68141. * @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
  68142. * @returns the thin instance index number
  68143. */
  68144. thinInstanceAddSelf(refresh: boolean): number;
  68145. /**
  68146. * Registers a custom attribute to be used with thin instances
  68147. * @param kind name of the attribute
  68148. * @param stride size in floats of the attribute
  68149. */
  68150. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68151. /**
  68152. * Sets the matrix of a thin instance
  68153. * @param index index of the thin instance
  68154. * @param matrix matrix to set
  68155. * @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
  68156. */
  68157. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68158. /**
  68159. * Sets the value of a custom attribute for a thin instance
  68160. * @param kind name of the attribute
  68161. * @param index index of the thin instance
  68162. * @param value value to set
  68163. * @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
  68164. */
  68165. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68166. /**
  68167. * 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.
  68168. */
  68169. thinInstanceCount: number;
  68170. /**
  68171. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68172. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68173. * @param buffer buffer to set
  68174. * @param stride size in floats of each value of the buffer
  68175. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68176. */
  68177. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68178. /**
  68179. * Gets the list of world matrices
  68180. * @return an array containing all the world matrices from the thin instances
  68181. */
  68182. thinInstanceGetWorldMatrices(): Matrix[];
  68183. /**
  68184. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68185. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68186. */
  68187. thinInstanceBufferUpdated(kind: string): void;
  68188. /**
  68189. * Applies a partial update to a buffer directly on the GPU
  68190. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  68191. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68192. * @param data the data to set in the GPU buffer
  68193. * @param offset the offset in the GPU buffer where to update the data
  68194. */
  68195. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  68196. /**
  68197. * Refreshes the bounding info, taking into account all the thin instances defined
  68198. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68199. */
  68200. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68201. /** @hidden */
  68202. _thinInstanceInitializeUserStorage(): void;
  68203. /** @hidden */
  68204. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68205. /** @hidden */
  68206. _userThinInstanceBuffersStorage: {
  68207. data: {
  68208. [key: string]: Float32Array;
  68209. };
  68210. sizes: {
  68211. [key: string]: number;
  68212. };
  68213. vertexBuffers: {
  68214. [key: string]: Nullable<VertexBuffer>;
  68215. };
  68216. strides: {
  68217. [key: string]: number;
  68218. };
  68219. };
  68220. }
  68221. }
  68222. declare module BABYLON {
  68223. /**
  68224. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68225. */
  68226. export interface INavigationEnginePlugin {
  68227. /**
  68228. * plugin name
  68229. */
  68230. name: string;
  68231. /**
  68232. * Creates a navigation mesh
  68233. * @param meshes array of all the geometry used to compute the navigatio mesh
  68234. * @param parameters bunch of parameters used to filter geometry
  68235. */
  68236. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68237. /**
  68238. * Create a navigation mesh debug mesh
  68239. * @param scene is where the mesh will be added
  68240. * @returns debug display mesh
  68241. */
  68242. createDebugNavMesh(scene: Scene): Mesh;
  68243. /**
  68244. * Get a navigation mesh constrained position, closest to the parameter position
  68245. * @param position world position
  68246. * @returns the closest point to position constrained by the navigation mesh
  68247. */
  68248. getClosestPoint(position: Vector3): Vector3;
  68249. /**
  68250. * Get a navigation mesh constrained position, closest to the parameter position
  68251. * @param position world position
  68252. * @param result output the closest point to position constrained by the navigation mesh
  68253. */
  68254. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68255. /**
  68256. * Get a navigation mesh constrained position, within a particular radius
  68257. * @param position world position
  68258. * @param maxRadius the maximum distance to the constrained world position
  68259. * @returns the closest point to position constrained by the navigation mesh
  68260. */
  68261. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68262. /**
  68263. * Get a navigation mesh constrained position, within a particular radius
  68264. * @param position world position
  68265. * @param maxRadius the maximum distance to the constrained world position
  68266. * @param result output the closest point to position constrained by the navigation mesh
  68267. */
  68268. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68269. /**
  68270. * Compute the final position from a segment made of destination-position
  68271. * @param position world position
  68272. * @param destination world position
  68273. * @returns the resulting point along the navmesh
  68274. */
  68275. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68276. /**
  68277. * Compute the final position from a segment made of destination-position
  68278. * @param position world position
  68279. * @param destination world position
  68280. * @param result output the resulting point along the navmesh
  68281. */
  68282. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68283. /**
  68284. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68285. * @param start world position
  68286. * @param end world position
  68287. * @returns array containing world position composing the path
  68288. */
  68289. computePath(start: Vector3, end: Vector3): Vector3[];
  68290. /**
  68291. * If this plugin is supported
  68292. * @returns true if plugin is supported
  68293. */
  68294. isSupported(): boolean;
  68295. /**
  68296. * Create a new Crowd so you can add agents
  68297. * @param maxAgents the maximum agent count in the crowd
  68298. * @param maxAgentRadius the maximum radius an agent can have
  68299. * @param scene to attach the crowd to
  68300. * @returns the crowd you can add agents to
  68301. */
  68302. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68303. /**
  68304. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68305. * The queries will try to find a solution within those bounds
  68306. * default is (1,1,1)
  68307. * @param extent x,y,z value that define the extent around the queries point of reference
  68308. */
  68309. setDefaultQueryExtent(extent: Vector3): void;
  68310. /**
  68311. * Get the Bounding box extent specified by setDefaultQueryExtent
  68312. * @returns the box extent values
  68313. */
  68314. getDefaultQueryExtent(): Vector3;
  68315. /**
  68316. * build the navmesh from a previously saved state using getNavmeshData
  68317. * @param data the Uint8Array returned by getNavmeshData
  68318. */
  68319. buildFromNavmeshData(data: Uint8Array): void;
  68320. /**
  68321. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68322. * @returns data the Uint8Array that can be saved and reused
  68323. */
  68324. getNavmeshData(): Uint8Array;
  68325. /**
  68326. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68327. * @param result output the box extent values
  68328. */
  68329. getDefaultQueryExtentToRef(result: Vector3): void;
  68330. /**
  68331. * Set the time step of the navigation tick update.
  68332. * Default is 1/60.
  68333. * A value of 0 will disable fixed time update
  68334. * @param newTimeStep the new timestep to apply to this world.
  68335. */
  68336. setTimeStep(newTimeStep: number): void;
  68337. /**
  68338. * Get the time step of the navigation tick update.
  68339. * @returns the current time step
  68340. */
  68341. getTimeStep(): number;
  68342. /**
  68343. * If delta time in navigation tick update is greater than the time step
  68344. * a number of sub iterations are done. If more iterations are need to reach deltatime
  68345. * they will be discarded.
  68346. * A value of 0 will set to no maximum and update will use as many substeps as needed
  68347. * @param newStepCount the maximum number of iterations
  68348. */
  68349. setMaximumSubStepCount(newStepCount: number): void;
  68350. /**
  68351. * Get the maximum number of iterations per navigation tick update
  68352. * @returns the maximum number of iterations
  68353. */
  68354. getMaximumSubStepCount(): number;
  68355. /**
  68356. * Release all resources
  68357. */
  68358. dispose(): void;
  68359. }
  68360. /**
  68361. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68362. */
  68363. export interface ICrowd {
  68364. /**
  68365. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68366. * You can attach anything to that node. The node position is updated in the scene update tick.
  68367. * @param pos world position that will be constrained by the navigation mesh
  68368. * @param parameters agent parameters
  68369. * @param transform hooked to the agent that will be update by the scene
  68370. * @returns agent index
  68371. */
  68372. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68373. /**
  68374. * Returns the agent position in world space
  68375. * @param index agent index returned by addAgent
  68376. * @returns world space position
  68377. */
  68378. getAgentPosition(index: number): Vector3;
  68379. /**
  68380. * Gets the agent position result in world space
  68381. * @param index agent index returned by addAgent
  68382. * @param result output world space position
  68383. */
  68384. getAgentPositionToRef(index: number, result: Vector3): void;
  68385. /**
  68386. * Gets the agent velocity in world space
  68387. * @param index agent index returned by addAgent
  68388. * @returns world space velocity
  68389. */
  68390. getAgentVelocity(index: number): Vector3;
  68391. /**
  68392. * Gets the agent velocity result in world space
  68393. * @param index agent index returned by addAgent
  68394. * @param result output world space velocity
  68395. */
  68396. getAgentVelocityToRef(index: number, result: Vector3): void;
  68397. /**
  68398. * Gets the agent next target point on the path
  68399. * @param index agent index returned by addAgent
  68400. * @returns world space position
  68401. */
  68402. getAgentNextTargetPath(index: number): Vector3;
  68403. /**
  68404. * Gets the agent state
  68405. * @param index agent index returned by addAgent
  68406. * @returns agent state
  68407. */
  68408. getAgentState(index: number): number;
  68409. /**
  68410. * returns true if the agent in over an off mesh link connection
  68411. * @param index agent index returned by addAgent
  68412. * @returns true if over an off mesh link connection
  68413. */
  68414. overOffmeshConnection(index: number): boolean;
  68415. /**
  68416. * Gets the agent next target point on the path
  68417. * @param index agent index returned by addAgent
  68418. * @param result output world space position
  68419. */
  68420. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68421. /**
  68422. * remove a particular agent previously created
  68423. * @param index agent index returned by addAgent
  68424. */
  68425. removeAgent(index: number): void;
  68426. /**
  68427. * get the list of all agents attached to this crowd
  68428. * @returns list of agent indices
  68429. */
  68430. getAgents(): number[];
  68431. /**
  68432. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68433. * @param deltaTime in seconds
  68434. */
  68435. update(deltaTime: number): void;
  68436. /**
  68437. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68438. * @param index agent index returned by addAgent
  68439. * @param destination targeted world position
  68440. */
  68441. agentGoto(index: number, destination: Vector3): void;
  68442. /**
  68443. * Teleport the agent to a new position
  68444. * @param index agent index returned by addAgent
  68445. * @param destination targeted world position
  68446. */
  68447. agentTeleport(index: number, destination: Vector3): void;
  68448. /**
  68449. * Update agent parameters
  68450. * @param index agent index returned by addAgent
  68451. * @param parameters agent parameters
  68452. */
  68453. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68454. /**
  68455. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68456. * The queries will try to find a solution within those bounds
  68457. * default is (1,1,1)
  68458. * @param extent x,y,z value that define the extent around the queries point of reference
  68459. */
  68460. setDefaultQueryExtent(extent: Vector3): void;
  68461. /**
  68462. * Get the Bounding box extent specified by setDefaultQueryExtent
  68463. * @returns the box extent values
  68464. */
  68465. getDefaultQueryExtent(): Vector3;
  68466. /**
  68467. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68468. * @param result output the box extent values
  68469. */
  68470. getDefaultQueryExtentToRef(result: Vector3): void;
  68471. /**
  68472. * Release all resources
  68473. */
  68474. dispose(): void;
  68475. }
  68476. /**
  68477. * Configures an agent
  68478. */
  68479. export interface IAgentParameters {
  68480. /**
  68481. * Agent radius. [Limit: >= 0]
  68482. */
  68483. radius: number;
  68484. /**
  68485. * Agent height. [Limit: > 0]
  68486. */
  68487. height: number;
  68488. /**
  68489. * Maximum allowed acceleration. [Limit: >= 0]
  68490. */
  68491. maxAcceleration: number;
  68492. /**
  68493. * Maximum allowed speed. [Limit: >= 0]
  68494. */
  68495. maxSpeed: number;
  68496. /**
  68497. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68498. */
  68499. collisionQueryRange: number;
  68500. /**
  68501. * The path visibility optimization range. [Limit: > 0]
  68502. */
  68503. pathOptimizationRange: number;
  68504. /**
  68505. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68506. */
  68507. separationWeight: number;
  68508. }
  68509. /**
  68510. * Configures the navigation mesh creation
  68511. */
  68512. export interface INavMeshParameters {
  68513. /**
  68514. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68515. */
  68516. cs: number;
  68517. /**
  68518. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68519. */
  68520. ch: number;
  68521. /**
  68522. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68523. */
  68524. walkableSlopeAngle: number;
  68525. /**
  68526. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68527. * be considered walkable. [Limit: >= 3] [Units: vx]
  68528. */
  68529. walkableHeight: number;
  68530. /**
  68531. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68532. */
  68533. walkableClimb: number;
  68534. /**
  68535. * The distance to erode/shrink the walkable area of the heightfield away from
  68536. * obstructions. [Limit: >=0] [Units: vx]
  68537. */
  68538. walkableRadius: number;
  68539. /**
  68540. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68541. */
  68542. maxEdgeLen: number;
  68543. /**
  68544. * The maximum distance a simplfied contour's border edges should deviate
  68545. * the original raw contour. [Limit: >=0] [Units: vx]
  68546. */
  68547. maxSimplificationError: number;
  68548. /**
  68549. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68550. */
  68551. minRegionArea: number;
  68552. /**
  68553. * Any regions with a span count smaller than this value will, if possible,
  68554. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68555. */
  68556. mergeRegionArea: number;
  68557. /**
  68558. * The maximum number of vertices allowed for polygons generated during the
  68559. * contour to polygon conversion process. [Limit: >= 3]
  68560. */
  68561. maxVertsPerPoly: number;
  68562. /**
  68563. * Sets the sampling distance to use when generating the detail mesh.
  68564. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68565. */
  68566. detailSampleDist: number;
  68567. /**
  68568. * The maximum distance the detail mesh surface should deviate from heightfield
  68569. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68570. */
  68571. detailSampleMaxError: number;
  68572. }
  68573. }
  68574. declare module BABYLON {
  68575. /**
  68576. * RecastJS navigation plugin
  68577. */
  68578. export class RecastJSPlugin implements INavigationEnginePlugin {
  68579. /**
  68580. * Reference to the Recast library
  68581. */
  68582. bjsRECAST: any;
  68583. /**
  68584. * plugin name
  68585. */
  68586. name: string;
  68587. /**
  68588. * the first navmesh created. We might extend this to support multiple navmeshes
  68589. */
  68590. navMesh: any;
  68591. private _maximumSubStepCount;
  68592. private _timeStep;
  68593. /**
  68594. * Initializes the recastJS plugin
  68595. * @param recastInjection can be used to inject your own recast reference
  68596. */
  68597. constructor(recastInjection?: any);
  68598. /**
  68599. * Set the time step of the navigation tick update.
  68600. * Default is 1/60.
  68601. * A value of 0 will disable fixed time update
  68602. * @param newTimeStep the new timestep to apply to this world.
  68603. */
  68604. setTimeStep(newTimeStep?: number): void;
  68605. /**
  68606. * Get the time step of the navigation tick update.
  68607. * @returns the current time step
  68608. */
  68609. getTimeStep(): number;
  68610. /**
  68611. * If delta time in navigation tick update is greater than the time step
  68612. * a number of sub iterations are done. If more iterations are need to reach deltatime
  68613. * they will be discarded.
  68614. * A value of 0 will set to no maximum and update will use as many substeps as needed
  68615. * @param newStepCount the maximum number of iterations
  68616. */
  68617. setMaximumSubStepCount(newStepCount?: number): void;
  68618. /**
  68619. * Get the maximum number of iterations per navigation tick update
  68620. * @returns the maximum number of iterations
  68621. */
  68622. getMaximumSubStepCount(): number;
  68623. /**
  68624. * Creates a navigation mesh
  68625. * @param meshes array of all the geometry used to compute the navigatio mesh
  68626. * @param parameters bunch of parameters used to filter geometry
  68627. */
  68628. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68629. /**
  68630. * Create a navigation mesh debug mesh
  68631. * @param scene is where the mesh will be added
  68632. * @returns debug display mesh
  68633. */
  68634. createDebugNavMesh(scene: Scene): Mesh;
  68635. /**
  68636. * Get a navigation mesh constrained position, closest to the parameter position
  68637. * @param position world position
  68638. * @returns the closest point to position constrained by the navigation mesh
  68639. */
  68640. getClosestPoint(position: Vector3): Vector3;
  68641. /**
  68642. * Get a navigation mesh constrained position, closest to the parameter position
  68643. * @param position world position
  68644. * @param result output the closest point to position constrained by the navigation mesh
  68645. */
  68646. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68647. /**
  68648. * Get a navigation mesh constrained position, within a particular radius
  68649. * @param position world position
  68650. * @param maxRadius the maximum distance to the constrained world position
  68651. * @returns the closest point to position constrained by the navigation mesh
  68652. */
  68653. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68654. /**
  68655. * Get a navigation mesh constrained position, within a particular radius
  68656. * @param position world position
  68657. * @param maxRadius the maximum distance to the constrained world position
  68658. * @param result output the closest point to position constrained by the navigation mesh
  68659. */
  68660. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68661. /**
  68662. * Compute the final position from a segment made of destination-position
  68663. * @param position world position
  68664. * @param destination world position
  68665. * @returns the resulting point along the navmesh
  68666. */
  68667. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68668. /**
  68669. * Compute the final position from a segment made of destination-position
  68670. * @param position world position
  68671. * @param destination world position
  68672. * @param result output the resulting point along the navmesh
  68673. */
  68674. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68675. /**
  68676. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68677. * @param start world position
  68678. * @param end world position
  68679. * @returns array containing world position composing the path
  68680. */
  68681. computePath(start: Vector3, end: Vector3): Vector3[];
  68682. /**
  68683. * Create a new Crowd so you can add agents
  68684. * @param maxAgents the maximum agent count in the crowd
  68685. * @param maxAgentRadius the maximum radius an agent can have
  68686. * @param scene to attach the crowd to
  68687. * @returns the crowd you can add agents to
  68688. */
  68689. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68690. /**
  68691. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68692. * The queries will try to find a solution within those bounds
  68693. * default is (1,1,1)
  68694. * @param extent x,y,z value that define the extent around the queries point of reference
  68695. */
  68696. setDefaultQueryExtent(extent: Vector3): void;
  68697. /**
  68698. * Get the Bounding box extent specified by setDefaultQueryExtent
  68699. * @returns the box extent values
  68700. */
  68701. getDefaultQueryExtent(): Vector3;
  68702. /**
  68703. * build the navmesh from a previously saved state using getNavmeshData
  68704. * @param data the Uint8Array returned by getNavmeshData
  68705. */
  68706. buildFromNavmeshData(data: Uint8Array): void;
  68707. /**
  68708. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68709. * @returns data the Uint8Array that can be saved and reused
  68710. */
  68711. getNavmeshData(): Uint8Array;
  68712. /**
  68713. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68714. * @param result output the box extent values
  68715. */
  68716. getDefaultQueryExtentToRef(result: Vector3): void;
  68717. /**
  68718. * Disposes
  68719. */
  68720. dispose(): void;
  68721. /**
  68722. * If this plugin is supported
  68723. * @returns true if plugin is supported
  68724. */
  68725. isSupported(): boolean;
  68726. }
  68727. /**
  68728. * Recast detour crowd implementation
  68729. */
  68730. export class RecastJSCrowd implements ICrowd {
  68731. /**
  68732. * Recast/detour plugin
  68733. */
  68734. bjsRECASTPlugin: RecastJSPlugin;
  68735. /**
  68736. * Link to the detour crowd
  68737. */
  68738. recastCrowd: any;
  68739. /**
  68740. * One transform per agent
  68741. */
  68742. transforms: TransformNode[];
  68743. /**
  68744. * All agents created
  68745. */
  68746. agents: number[];
  68747. /**
  68748. * Link to the scene is kept to unregister the crowd from the scene
  68749. */
  68750. private _scene;
  68751. /**
  68752. * Observer for crowd updates
  68753. */
  68754. private _onBeforeAnimationsObserver;
  68755. /**
  68756. * Constructor
  68757. * @param plugin recastJS plugin
  68758. * @param maxAgents the maximum agent count in the crowd
  68759. * @param maxAgentRadius the maximum radius an agent can have
  68760. * @param scene to attach the crowd to
  68761. * @returns the crowd you can add agents to
  68762. */
  68763. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68764. /**
  68765. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68766. * You can attach anything to that node. The node position is updated in the scene update tick.
  68767. * @param pos world position that will be constrained by the navigation mesh
  68768. * @param parameters agent parameters
  68769. * @param transform hooked to the agent that will be update by the scene
  68770. * @returns agent index
  68771. */
  68772. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68773. /**
  68774. * Returns the agent position in world space
  68775. * @param index agent index returned by addAgent
  68776. * @returns world space position
  68777. */
  68778. getAgentPosition(index: number): Vector3;
  68779. /**
  68780. * Returns the agent position result in world space
  68781. * @param index agent index returned by addAgent
  68782. * @param result output world space position
  68783. */
  68784. getAgentPositionToRef(index: number, result: Vector3): void;
  68785. /**
  68786. * Returns the agent velocity in world space
  68787. * @param index agent index returned by addAgent
  68788. * @returns world space velocity
  68789. */
  68790. getAgentVelocity(index: number): Vector3;
  68791. /**
  68792. * Returns the agent velocity result in world space
  68793. * @param index agent index returned by addAgent
  68794. * @param result output world space velocity
  68795. */
  68796. getAgentVelocityToRef(index: number, result: Vector3): void;
  68797. /**
  68798. * Returns the agent next target point on the path
  68799. * @param index agent index returned by addAgent
  68800. * @returns world space position
  68801. */
  68802. getAgentNextTargetPath(index: number): Vector3;
  68803. /**
  68804. * Returns the agent next target point on the path
  68805. * @param index agent index returned by addAgent
  68806. * @param result output world space position
  68807. */
  68808. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68809. /**
  68810. * Gets the agent state
  68811. * @param index agent index returned by addAgent
  68812. * @returns agent state
  68813. */
  68814. getAgentState(index: number): number;
  68815. /**
  68816. * returns true if the agent in over an off mesh link connection
  68817. * @param index agent index returned by addAgent
  68818. * @returns true if over an off mesh link connection
  68819. */
  68820. overOffmeshConnection(index: number): boolean;
  68821. /**
  68822. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68823. * @param index agent index returned by addAgent
  68824. * @param destination targeted world position
  68825. */
  68826. agentGoto(index: number, destination: Vector3): void;
  68827. /**
  68828. * Teleport the agent to a new position
  68829. * @param index agent index returned by addAgent
  68830. * @param destination targeted world position
  68831. */
  68832. agentTeleport(index: number, destination: Vector3): void;
  68833. /**
  68834. * Update agent parameters
  68835. * @param index agent index returned by addAgent
  68836. * @param parameters agent parameters
  68837. */
  68838. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68839. /**
  68840. * remove a particular agent previously created
  68841. * @param index agent index returned by addAgent
  68842. */
  68843. removeAgent(index: number): void;
  68844. /**
  68845. * get the list of all agents attached to this crowd
  68846. * @returns list of agent indices
  68847. */
  68848. getAgents(): number[];
  68849. /**
  68850. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68851. * @param deltaTime in seconds
  68852. */
  68853. update(deltaTime: number): void;
  68854. /**
  68855. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68856. * The queries will try to find a solution within those bounds
  68857. * default is (1,1,1)
  68858. * @param extent x,y,z value that define the extent around the queries point of reference
  68859. */
  68860. setDefaultQueryExtent(extent: Vector3): void;
  68861. /**
  68862. * Get the Bounding box extent specified by setDefaultQueryExtent
  68863. * @returns the box extent values
  68864. */
  68865. getDefaultQueryExtent(): Vector3;
  68866. /**
  68867. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68868. * @param result output the box extent values
  68869. */
  68870. getDefaultQueryExtentToRef(result: Vector3): void;
  68871. /**
  68872. * Release all resources
  68873. */
  68874. dispose(): void;
  68875. }
  68876. }
  68877. declare module BABYLON {
  68878. /**
  68879. * Class used to enable access to IndexedDB
  68880. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68881. */
  68882. export class Database implements IOfflineProvider {
  68883. private _callbackManifestChecked;
  68884. private _currentSceneUrl;
  68885. private _db;
  68886. private _enableSceneOffline;
  68887. private _enableTexturesOffline;
  68888. private _manifestVersionFound;
  68889. private _mustUpdateRessources;
  68890. private _hasReachedQuota;
  68891. private _isSupported;
  68892. private _idbFactory;
  68893. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68894. private static IsUASupportingBlobStorage;
  68895. /**
  68896. * Gets a boolean indicating if Database storate is enabled (off by default)
  68897. */
  68898. static IDBStorageEnabled: boolean;
  68899. /**
  68900. * Gets a boolean indicating if scene must be saved in the database
  68901. */
  68902. get enableSceneOffline(): boolean;
  68903. /**
  68904. * Gets a boolean indicating if textures must be saved in the database
  68905. */
  68906. get enableTexturesOffline(): boolean;
  68907. /**
  68908. * Creates a new Database
  68909. * @param urlToScene defines the url to load the scene
  68910. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68911. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68912. */
  68913. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68914. private static _ParseURL;
  68915. private static _ReturnFullUrlLocation;
  68916. private _checkManifestFile;
  68917. /**
  68918. * Open the database and make it available
  68919. * @param successCallback defines the callback to call on success
  68920. * @param errorCallback defines the callback to call on error
  68921. */
  68922. open(successCallback: () => void, errorCallback: () => void): void;
  68923. /**
  68924. * Loads an image from the database
  68925. * @param url defines the url to load from
  68926. * @param image defines the target DOM image
  68927. */
  68928. loadImage(url: string, image: HTMLImageElement): void;
  68929. private _loadImageFromDBAsync;
  68930. private _saveImageIntoDBAsync;
  68931. private _checkVersionFromDB;
  68932. private _loadVersionFromDBAsync;
  68933. private _saveVersionIntoDBAsync;
  68934. /**
  68935. * Loads a file from database
  68936. * @param url defines the URL to load from
  68937. * @param sceneLoaded defines a callback to call on success
  68938. * @param progressCallBack defines a callback to call when progress changed
  68939. * @param errorCallback defines a callback to call on error
  68940. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68941. */
  68942. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68943. private _loadFileAsync;
  68944. private _saveFileAsync;
  68945. /**
  68946. * Validates if xhr data is correct
  68947. * @param xhr defines the request to validate
  68948. * @param dataType defines the expected data type
  68949. * @returns true if data is correct
  68950. */
  68951. private static _ValidateXHRData;
  68952. }
  68953. }
  68954. declare module BABYLON {
  68955. /** @hidden */
  68956. export var gpuUpdateParticlesPixelShader: {
  68957. name: string;
  68958. shader: string;
  68959. };
  68960. }
  68961. declare module BABYLON {
  68962. /** @hidden */
  68963. export var gpuUpdateParticlesVertexShader: {
  68964. name: string;
  68965. shader: string;
  68966. };
  68967. }
  68968. declare module BABYLON {
  68969. /** @hidden */
  68970. export var clipPlaneFragmentDeclaration2: {
  68971. name: string;
  68972. shader: string;
  68973. };
  68974. }
  68975. declare module BABYLON {
  68976. /** @hidden */
  68977. export var gpuRenderParticlesPixelShader: {
  68978. name: string;
  68979. shader: string;
  68980. };
  68981. }
  68982. declare module BABYLON {
  68983. /** @hidden */
  68984. export var clipPlaneVertexDeclaration2: {
  68985. name: string;
  68986. shader: string;
  68987. };
  68988. }
  68989. declare module BABYLON {
  68990. /** @hidden */
  68991. export var gpuRenderParticlesVertexShader: {
  68992. name: string;
  68993. shader: string;
  68994. };
  68995. }
  68996. declare module BABYLON {
  68997. /**
  68998. * This represents a GPU particle system in Babylon
  68999. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69000. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69001. */
  69002. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69003. /**
  69004. * The layer mask we are rendering the particles through.
  69005. */
  69006. layerMask: number;
  69007. private _capacity;
  69008. private _activeCount;
  69009. private _currentActiveCount;
  69010. private _accumulatedCount;
  69011. private _renderEffect;
  69012. private _updateEffect;
  69013. private _buffer0;
  69014. private _buffer1;
  69015. private _spriteBuffer;
  69016. private _updateVAO;
  69017. private _renderVAO;
  69018. private _targetIndex;
  69019. private _sourceBuffer;
  69020. private _targetBuffer;
  69021. private _currentRenderId;
  69022. private _started;
  69023. private _stopped;
  69024. private _timeDelta;
  69025. private _randomTexture;
  69026. private _randomTexture2;
  69027. private _attributesStrideSize;
  69028. private _updateEffectOptions;
  69029. private _randomTextureSize;
  69030. private _actualFrame;
  69031. private _customEffect;
  69032. private readonly _rawTextureWidth;
  69033. /**
  69034. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69035. */
  69036. static get IsSupported(): boolean;
  69037. /**
  69038. * An event triggered when the system is disposed.
  69039. */
  69040. onDisposeObservable: Observable<IParticleSystem>;
  69041. /**
  69042. * An event triggered when the system is stopped
  69043. */
  69044. onStoppedObservable: Observable<IParticleSystem>;
  69045. /**
  69046. * Gets the maximum number of particles active at the same time.
  69047. * @returns The max number of active particles.
  69048. */
  69049. getCapacity(): number;
  69050. /**
  69051. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69052. * to override the particles.
  69053. */
  69054. forceDepthWrite: boolean;
  69055. /**
  69056. * Gets or set the number of active particles
  69057. */
  69058. get activeParticleCount(): number;
  69059. set activeParticleCount(value: number);
  69060. private _preWarmDone;
  69061. /**
  69062. * Specifies if the particles are updated in emitter local space or world space.
  69063. */
  69064. isLocal: boolean;
  69065. /** Gets or sets a matrix to use to compute projection */
  69066. defaultProjectionMatrix: Matrix;
  69067. /**
  69068. * Is this system ready to be used/rendered
  69069. * @return true if the system is ready
  69070. */
  69071. isReady(): boolean;
  69072. /**
  69073. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69074. * @returns True if it has been started, otherwise false.
  69075. */
  69076. isStarted(): boolean;
  69077. /**
  69078. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69079. * @returns True if it has been stopped, otherwise false.
  69080. */
  69081. isStopped(): boolean;
  69082. /**
  69083. * Gets a boolean indicating that the system is stopping
  69084. * @returns true if the system is currently stopping
  69085. */
  69086. isStopping(): boolean;
  69087. /**
  69088. * Gets the number of particles active at the same time.
  69089. * @returns The number of active particles.
  69090. */
  69091. getActiveCount(): number;
  69092. /**
  69093. * Starts the particle system and begins to emit
  69094. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69095. */
  69096. start(delay?: number): void;
  69097. /**
  69098. * Stops the particle system.
  69099. */
  69100. stop(): void;
  69101. /**
  69102. * Remove all active particles
  69103. */
  69104. reset(): void;
  69105. /**
  69106. * Returns the string "GPUParticleSystem"
  69107. * @returns a string containing the class name
  69108. */
  69109. getClassName(): string;
  69110. /**
  69111. * Gets the custom effect used to render the particles
  69112. * @param blendMode Blend mode for which the effect should be retrieved
  69113. * @returns The effect
  69114. */
  69115. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69116. /**
  69117. * Sets the custom effect used to render the particles
  69118. * @param effect The effect to set
  69119. * @param blendMode Blend mode for which the effect should be set
  69120. */
  69121. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69122. /** @hidden */
  69123. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69124. /**
  69125. * Observable that will be called just before the particles are drawn
  69126. */
  69127. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69128. /**
  69129. * Gets the name of the particle vertex shader
  69130. */
  69131. get vertexShaderName(): string;
  69132. private _colorGradientsTexture;
  69133. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69134. /**
  69135. * Adds a new color gradient
  69136. * @param gradient defines the gradient to use (between 0 and 1)
  69137. * @param color1 defines the color to affect to the specified gradient
  69138. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69139. * @returns the current particle system
  69140. */
  69141. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69142. private _refreshColorGradient;
  69143. /** Force the system to rebuild all gradients that need to be resync */
  69144. forceRefreshGradients(): void;
  69145. /**
  69146. * Remove a specific color gradient
  69147. * @param gradient defines the gradient to remove
  69148. * @returns the current particle system
  69149. */
  69150. removeColorGradient(gradient: number): GPUParticleSystem;
  69151. private _angularSpeedGradientsTexture;
  69152. private _sizeGradientsTexture;
  69153. private _velocityGradientsTexture;
  69154. private _limitVelocityGradientsTexture;
  69155. private _dragGradientsTexture;
  69156. private _addFactorGradient;
  69157. /**
  69158. * Adds a new size gradient
  69159. * @param gradient defines the gradient to use (between 0 and 1)
  69160. * @param factor defines the size factor to affect to the specified gradient
  69161. * @returns the current particle system
  69162. */
  69163. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69164. /**
  69165. * Remove a specific size gradient
  69166. * @param gradient defines the gradient to remove
  69167. * @returns the current particle system
  69168. */
  69169. removeSizeGradient(gradient: number): GPUParticleSystem;
  69170. private _refreshFactorGradient;
  69171. /**
  69172. * Adds a new angular speed gradient
  69173. * @param gradient defines the gradient to use (between 0 and 1)
  69174. * @param factor defines the angular speed to affect to the specified gradient
  69175. * @returns the current particle system
  69176. */
  69177. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69178. /**
  69179. * Remove a specific angular speed gradient
  69180. * @param gradient defines the gradient to remove
  69181. * @returns the current particle system
  69182. */
  69183. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69184. /**
  69185. * Adds a new velocity gradient
  69186. * @param gradient defines the gradient to use (between 0 and 1)
  69187. * @param factor defines the velocity to affect to the specified gradient
  69188. * @returns the current particle system
  69189. */
  69190. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69191. /**
  69192. * Remove a specific velocity gradient
  69193. * @param gradient defines the gradient to remove
  69194. * @returns the current particle system
  69195. */
  69196. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69197. /**
  69198. * Adds a new limit velocity gradient
  69199. * @param gradient defines the gradient to use (between 0 and 1)
  69200. * @param factor defines the limit velocity value to affect to the specified gradient
  69201. * @returns the current particle system
  69202. */
  69203. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69204. /**
  69205. * Remove a specific limit velocity gradient
  69206. * @param gradient defines the gradient to remove
  69207. * @returns the current particle system
  69208. */
  69209. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69210. /**
  69211. * Adds a new drag gradient
  69212. * @param gradient defines the gradient to use (between 0 and 1)
  69213. * @param factor defines the drag value to affect to the specified gradient
  69214. * @returns the current particle system
  69215. */
  69216. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69217. /**
  69218. * Remove a specific drag gradient
  69219. * @param gradient defines the gradient to remove
  69220. * @returns the current particle system
  69221. */
  69222. removeDragGradient(gradient: number): GPUParticleSystem;
  69223. /**
  69224. * Not supported by GPUParticleSystem
  69225. * @param gradient defines the gradient to use (between 0 and 1)
  69226. * @param factor defines the emit rate value to affect to the specified gradient
  69227. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69228. * @returns the current particle system
  69229. */
  69230. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69231. /**
  69232. * Not supported by GPUParticleSystem
  69233. * @param gradient defines the gradient to remove
  69234. * @returns the current particle system
  69235. */
  69236. removeEmitRateGradient(gradient: number): IParticleSystem;
  69237. /**
  69238. * Not supported by GPUParticleSystem
  69239. * @param gradient defines the gradient to use (between 0 and 1)
  69240. * @param factor defines the start size value to affect to the specified gradient
  69241. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69242. * @returns the current particle system
  69243. */
  69244. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69245. /**
  69246. * Not supported by GPUParticleSystem
  69247. * @param gradient defines the gradient to remove
  69248. * @returns the current particle system
  69249. */
  69250. removeStartSizeGradient(gradient: number): IParticleSystem;
  69251. /**
  69252. * Not supported by GPUParticleSystem
  69253. * @param gradient defines the gradient to use (between 0 and 1)
  69254. * @param min defines the color remap minimal range
  69255. * @param max defines the color remap maximal range
  69256. * @returns the current particle system
  69257. */
  69258. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69259. /**
  69260. * Not supported by GPUParticleSystem
  69261. * @param gradient defines the gradient to remove
  69262. * @returns the current particle system
  69263. */
  69264. removeColorRemapGradient(): IParticleSystem;
  69265. /**
  69266. * Not supported by GPUParticleSystem
  69267. * @param gradient defines the gradient to use (between 0 and 1)
  69268. * @param min defines the alpha remap minimal range
  69269. * @param max defines the alpha remap maximal range
  69270. * @returns the current particle system
  69271. */
  69272. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69273. /**
  69274. * Not supported by GPUParticleSystem
  69275. * @param gradient defines the gradient to remove
  69276. * @returns the current particle system
  69277. */
  69278. removeAlphaRemapGradient(): IParticleSystem;
  69279. /**
  69280. * Not supported by GPUParticleSystem
  69281. * @param gradient defines the gradient to use (between 0 and 1)
  69282. * @param color defines the color to affect to the specified gradient
  69283. * @returns the current particle system
  69284. */
  69285. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69286. /**
  69287. * Not supported by GPUParticleSystem
  69288. * @param gradient defines the gradient to remove
  69289. * @returns the current particle system
  69290. */
  69291. removeRampGradient(): IParticleSystem;
  69292. /**
  69293. * Not supported by GPUParticleSystem
  69294. * @returns the list of ramp gradients
  69295. */
  69296. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69297. /**
  69298. * Not supported by GPUParticleSystem
  69299. * Gets or sets a boolean indicating that ramp gradients must be used
  69300. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69301. */
  69302. get useRampGradients(): boolean;
  69303. set useRampGradients(value: boolean);
  69304. /**
  69305. * Not supported by GPUParticleSystem
  69306. * @param gradient defines the gradient to use (between 0 and 1)
  69307. * @param factor defines the life time factor to affect to the specified gradient
  69308. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69309. * @returns the current particle system
  69310. */
  69311. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69312. /**
  69313. * Not supported by GPUParticleSystem
  69314. * @param gradient defines the gradient to remove
  69315. * @returns the current particle system
  69316. */
  69317. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69318. /**
  69319. * Instantiates a GPU particle system.
  69320. * 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.
  69321. * @param name The name of the particle system
  69322. * @param options The options used to create the system
  69323. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  69324. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69325. * @param customEffect a custom effect used to change the way particles are rendered by default
  69326. */
  69327. constructor(name: string, options: Partial<{
  69328. capacity: number;
  69329. randomTextureSize: number;
  69330. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69331. protected _reset(): void;
  69332. private _createUpdateVAO;
  69333. private _createRenderVAO;
  69334. private _initialize;
  69335. /** @hidden */
  69336. _recreateUpdateEffect(): void;
  69337. private _getEffect;
  69338. /**
  69339. * Fill the defines array according to the current settings of the particle system
  69340. * @param defines Array to be updated
  69341. * @param blendMode blend mode to take into account when updating the array
  69342. */
  69343. fillDefines(defines: Array<string>, blendMode?: number): void;
  69344. /**
  69345. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69346. * @param uniforms Uniforms array to fill
  69347. * @param attributes Attributes array to fill
  69348. * @param samplers Samplers array to fill
  69349. */
  69350. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69351. /** @hidden */
  69352. _recreateRenderEffect(): Effect;
  69353. /**
  69354. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69355. * @param preWarm defines if we are in the pre-warmimg phase
  69356. */
  69357. animate(preWarm?: boolean): void;
  69358. private _createFactorGradientTexture;
  69359. private _createSizeGradientTexture;
  69360. private _createAngularSpeedGradientTexture;
  69361. private _createVelocityGradientTexture;
  69362. private _createLimitVelocityGradientTexture;
  69363. private _createDragGradientTexture;
  69364. private _createColorGradientTexture;
  69365. /**
  69366. * Renders the particle system in its current state
  69367. * @param preWarm defines if the system should only update the particles but not render them
  69368. * @returns the current number of particles
  69369. */
  69370. render(preWarm?: boolean): number;
  69371. /**
  69372. * Rebuilds the particle system
  69373. */
  69374. rebuild(): void;
  69375. private _releaseBuffers;
  69376. private _releaseVAOs;
  69377. /**
  69378. * Disposes the particle system and free the associated resources
  69379. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69380. */
  69381. dispose(disposeTexture?: boolean): void;
  69382. /**
  69383. * Clones the particle system.
  69384. * @param name The name of the cloned object
  69385. * @param newEmitter The new emitter to use
  69386. * @returns the cloned particle system
  69387. */
  69388. clone(name: string, newEmitter: any): GPUParticleSystem;
  69389. /**
  69390. * Serializes the particle system to a JSON object
  69391. * @param serializeTexture defines if the texture must be serialized as well
  69392. * @returns the JSON object
  69393. */
  69394. serialize(serializeTexture?: boolean): any;
  69395. /**
  69396. * Parses a JSON object to create a GPU particle system.
  69397. * @param parsedParticleSystem The JSON object to parse
  69398. * @param sceneOrEngine The scene or the engine to create the particle system in
  69399. * @param rootUrl The root url to use to load external dependencies like texture
  69400. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69401. * @returns the parsed GPU particle system
  69402. */
  69403. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69404. }
  69405. }
  69406. declare module BABYLON {
  69407. /**
  69408. * Represents a set of particle systems working together to create a specific effect
  69409. */
  69410. export class ParticleSystemSet implements IDisposable {
  69411. /**
  69412. * Gets or sets base Assets URL
  69413. */
  69414. static BaseAssetsUrl: string;
  69415. private _emitterCreationOptions;
  69416. private _emitterNode;
  69417. /**
  69418. * Gets the particle system list
  69419. */
  69420. systems: IParticleSystem[];
  69421. /**
  69422. * Gets the emitter node used with this set
  69423. */
  69424. get emitterNode(): Nullable<TransformNode>;
  69425. /**
  69426. * Creates a new emitter mesh as a sphere
  69427. * @param options defines the options used to create the sphere
  69428. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69429. * @param scene defines the hosting scene
  69430. */
  69431. setEmitterAsSphere(options: {
  69432. diameter: number;
  69433. segments: number;
  69434. color: Color3;
  69435. }, renderingGroupId: number, scene: Scene): void;
  69436. /**
  69437. * Starts all particle systems of the set
  69438. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69439. */
  69440. start(emitter?: AbstractMesh): void;
  69441. /**
  69442. * Release all associated resources
  69443. */
  69444. dispose(): void;
  69445. /**
  69446. * Serialize the set into a JSON compatible object
  69447. * @param serializeTexture defines if the texture must be serialized as well
  69448. * @returns a JSON compatible representation of the set
  69449. */
  69450. serialize(serializeTexture?: boolean): any;
  69451. /**
  69452. * Parse a new ParticleSystemSet from a serialized source
  69453. * @param data defines a JSON compatible representation of the set
  69454. * @param scene defines the hosting scene
  69455. * @param gpu defines if we want GPU particles or CPU particles
  69456. * @returns a new ParticleSystemSet
  69457. */
  69458. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69459. }
  69460. }
  69461. declare module BABYLON {
  69462. /**
  69463. * This class is made for on one-liner static method to help creating particle system set.
  69464. */
  69465. export class ParticleHelper {
  69466. /**
  69467. * Gets or sets base Assets URL
  69468. */
  69469. static BaseAssetsUrl: string;
  69470. /** Define the Url to load snippets */
  69471. static SnippetUrl: string;
  69472. /**
  69473. * Create a default particle system that you can tweak
  69474. * @param emitter defines the emitter to use
  69475. * @param capacity defines the system capacity (default is 500 particles)
  69476. * @param scene defines the hosting scene
  69477. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69478. * @returns the new Particle system
  69479. */
  69480. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69481. /**
  69482. * This is the main static method (one-liner) of this helper to create different particle systems
  69483. * @param type This string represents the type to the particle system to create
  69484. * @param scene The scene where the particle system should live
  69485. * @param gpu If the system will use gpu
  69486. * @returns the ParticleSystemSet created
  69487. */
  69488. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69489. /**
  69490. * Static function used to export a particle system to a ParticleSystemSet variable.
  69491. * Please note that the emitter shape is not exported
  69492. * @param systems defines the particle systems to export
  69493. * @returns the created particle system set
  69494. */
  69495. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69496. /**
  69497. * Creates a particle system from a snippet saved in a remote file
  69498. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69499. * @param url defines the url to load from
  69500. * @param scene defines the hosting scene
  69501. * @param gpu If the system will use gpu
  69502. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69503. * @returns a promise that will resolve to the new particle system
  69504. */
  69505. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69506. /**
  69507. * Creates a particle system from a snippet saved by the particle system editor
  69508. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69509. * @param scene defines the hosting scene
  69510. * @param gpu If the system will use gpu
  69511. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69512. * @returns a promise that will resolve to the new particle system
  69513. */
  69514. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69515. }
  69516. }
  69517. declare module BABYLON {
  69518. interface Engine {
  69519. /**
  69520. * Create an effect to use with particle systems.
  69521. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69522. * the particle system for which you want to create a custom effect in the last parameter
  69523. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69524. * @param uniformsNames defines a list of attribute names
  69525. * @param samplers defines an array of string used to represent textures
  69526. * @param defines defines the string containing the defines to use to compile the shaders
  69527. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69528. * @param onCompiled defines a function to call when the effect creation is successful
  69529. * @param onError defines a function to call when the effect creation has failed
  69530. * @param particleSystem the particle system you want to create the effect for
  69531. * @returns the new Effect
  69532. */
  69533. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69534. }
  69535. interface Mesh {
  69536. /**
  69537. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69538. * @returns an array of IParticleSystem
  69539. */
  69540. getEmittedParticleSystems(): IParticleSystem[];
  69541. /**
  69542. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69543. * @returns an array of IParticleSystem
  69544. */
  69545. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69546. }
  69547. }
  69548. declare module BABYLON {
  69549. /** Defines the 4 color options */
  69550. export enum PointColor {
  69551. /** color value */
  69552. Color = 2,
  69553. /** uv value */
  69554. UV = 1,
  69555. /** random value */
  69556. Random = 0,
  69557. /** stated value */
  69558. Stated = 3
  69559. }
  69560. /**
  69561. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69562. * 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.
  69563. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69564. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69565. *
  69566. * Full documentation here : TO BE ENTERED
  69567. */
  69568. export class PointsCloudSystem implements IDisposable {
  69569. /**
  69570. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69571. * Example : var p = SPS.particles[i];
  69572. */
  69573. particles: CloudPoint[];
  69574. /**
  69575. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69576. */
  69577. nbParticles: number;
  69578. /**
  69579. * This a counter for your own usage. It's not set by any SPS functions.
  69580. */
  69581. counter: number;
  69582. /**
  69583. * The PCS name. This name is also given to the underlying mesh.
  69584. */
  69585. name: string;
  69586. /**
  69587. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69588. */
  69589. mesh: Mesh;
  69590. /**
  69591. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69592. * Please read :
  69593. */
  69594. vars: any;
  69595. /**
  69596. * @hidden
  69597. */
  69598. _size: number;
  69599. private _scene;
  69600. private _promises;
  69601. private _positions;
  69602. private _indices;
  69603. private _normals;
  69604. private _colors;
  69605. private _uvs;
  69606. private _indices32;
  69607. private _positions32;
  69608. private _colors32;
  69609. private _uvs32;
  69610. private _updatable;
  69611. private _isVisibilityBoxLocked;
  69612. private _alwaysVisible;
  69613. private _groups;
  69614. private _groupCounter;
  69615. private _computeParticleColor;
  69616. private _computeParticleTexture;
  69617. private _computeParticleRotation;
  69618. private _computeBoundingBox;
  69619. private _isReady;
  69620. /**
  69621. * Creates a PCS (Points Cloud System) object
  69622. * @param name (String) is the PCS name, this will be the underlying mesh name
  69623. * @param pointSize (number) is the size for each point
  69624. * @param scene (Scene) is the scene in which the PCS is added
  69625. * @param options defines the options of the PCS e.g.
  69626. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69627. */
  69628. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69629. updatable?: boolean;
  69630. });
  69631. /**
  69632. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69633. * If no points were added to the PCS, the returned mesh is just a single point.
  69634. * @returns a promise for the created mesh
  69635. */
  69636. buildMeshAsync(): Promise<Mesh>;
  69637. /**
  69638. * @hidden
  69639. */
  69640. private _buildMesh;
  69641. private _addParticle;
  69642. private _randomUnitVector;
  69643. private _getColorIndicesForCoord;
  69644. private _setPointsColorOrUV;
  69645. private _colorFromTexture;
  69646. private _calculateDensity;
  69647. /**
  69648. * Adds points to the PCS in random positions within a unit sphere
  69649. * @param nb (positive integer) the number of particles to be created from this model
  69650. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69651. * @returns the number of groups in the system
  69652. */
  69653. addPoints(nb: number, pointFunction?: any): number;
  69654. /**
  69655. * Adds points to the PCS from the surface of the model shape
  69656. * @param mesh is any Mesh object that will be used as a surface model for the points
  69657. * @param nb (positive integer) the number of particles to be created from this model
  69658. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69659. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69660. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69661. * @returns the number of groups in the system
  69662. */
  69663. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69664. /**
  69665. * Adds points to the PCS inside the model shape
  69666. * @param mesh is any Mesh object that will be used as a surface model for the points
  69667. * @param nb (positive integer) the number of particles to be created from this model
  69668. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69669. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69670. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69671. * @returns the number of groups in the system
  69672. */
  69673. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69674. /**
  69675. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69676. * This method calls `updateParticle()` for each particle of the SPS.
  69677. * For an animated SPS, it is usually called within the render loop.
  69678. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69679. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69680. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69681. * @returns the PCS.
  69682. */
  69683. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69684. /**
  69685. * Disposes the PCS.
  69686. */
  69687. dispose(): void;
  69688. /**
  69689. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69690. * doc :
  69691. * @returns the PCS.
  69692. */
  69693. refreshVisibleSize(): PointsCloudSystem;
  69694. /**
  69695. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69696. * @param size the size (float) of the visibility box
  69697. * note : this doesn't lock the PCS mesh bounding box.
  69698. * doc :
  69699. */
  69700. setVisibilityBox(size: number): void;
  69701. /**
  69702. * Gets whether the PCS is always visible or not
  69703. * doc :
  69704. */
  69705. get isAlwaysVisible(): boolean;
  69706. /**
  69707. * Sets the PCS as always visible or not
  69708. * doc :
  69709. */
  69710. set isAlwaysVisible(val: boolean);
  69711. /**
  69712. * Tells to `setParticles()` to compute the particle rotations or not
  69713. * Default value : false. The PCS is faster when it's set to false
  69714. * Note : particle rotations are only applied to parent particles
  69715. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69716. */
  69717. set computeParticleRotation(val: boolean);
  69718. /**
  69719. * Tells to `setParticles()` to compute the particle colors or not.
  69720. * Default value : true. The PCS is faster when it's set to false.
  69721. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69722. */
  69723. set computeParticleColor(val: boolean);
  69724. set computeParticleTexture(val: boolean);
  69725. /**
  69726. * Gets if `setParticles()` computes the particle colors or not.
  69727. * Default value : false. The PCS is faster when it's set to false.
  69728. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69729. */
  69730. get computeParticleColor(): boolean;
  69731. /**
  69732. * Gets if `setParticles()` computes the particle textures or not.
  69733. * Default value : false. The PCS is faster when it's set to false.
  69734. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69735. */
  69736. get computeParticleTexture(): boolean;
  69737. /**
  69738. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69739. */
  69740. set computeBoundingBox(val: boolean);
  69741. /**
  69742. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69743. */
  69744. get computeBoundingBox(): boolean;
  69745. /**
  69746. * This function does nothing. It may be overwritten to set all the particle first values.
  69747. * The PCS doesn't call this function, you may have to call it by your own.
  69748. * doc :
  69749. */
  69750. initParticles(): void;
  69751. /**
  69752. * This function does nothing. It may be overwritten to recycle a particle
  69753. * The PCS doesn't call this function, you can to call it
  69754. * doc :
  69755. * @param particle The particle to recycle
  69756. * @returns the recycled particle
  69757. */
  69758. recycleParticle(particle: CloudPoint): CloudPoint;
  69759. /**
  69760. * Updates a particle : this function should be overwritten by the user.
  69761. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69762. * doc :
  69763. * @example : just set a particle position or velocity and recycle conditions
  69764. * @param particle The particle to update
  69765. * @returns the updated particle
  69766. */
  69767. updateParticle(particle: CloudPoint): CloudPoint;
  69768. /**
  69769. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69770. * This does nothing and may be overwritten by the user.
  69771. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69772. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69773. * @param update the boolean update value actually passed to setParticles()
  69774. */
  69775. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69776. /**
  69777. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69778. * This will be passed three parameters.
  69779. * This does nothing and may be overwritten by the user.
  69780. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69781. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69782. * @param update the boolean update value actually passed to setParticles()
  69783. */
  69784. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69785. }
  69786. }
  69787. declare module BABYLON {
  69788. /**
  69789. * Represents one particle of a points cloud system.
  69790. */
  69791. export class CloudPoint {
  69792. /**
  69793. * particle global index
  69794. */
  69795. idx: number;
  69796. /**
  69797. * The color of the particle
  69798. */
  69799. color: Nullable<Color4>;
  69800. /**
  69801. * The world space position of the particle.
  69802. */
  69803. position: Vector3;
  69804. /**
  69805. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69806. */
  69807. rotation: Vector3;
  69808. /**
  69809. * The world space rotation quaternion of the particle.
  69810. */
  69811. rotationQuaternion: Nullable<Quaternion>;
  69812. /**
  69813. * The uv of the particle.
  69814. */
  69815. uv: Nullable<Vector2>;
  69816. /**
  69817. * The current speed of the particle.
  69818. */
  69819. velocity: Vector3;
  69820. /**
  69821. * The pivot point in the particle local space.
  69822. */
  69823. pivot: Vector3;
  69824. /**
  69825. * Must the particle be translated from its pivot point in its local space ?
  69826. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69827. * Default : false
  69828. */
  69829. translateFromPivot: boolean;
  69830. /**
  69831. * Index of this particle in the global "positions" array (Internal use)
  69832. * @hidden
  69833. */
  69834. _pos: number;
  69835. /**
  69836. * @hidden Index of this particle in the global "indices" array (Internal use)
  69837. */
  69838. _ind: number;
  69839. /**
  69840. * Group this particle belongs to
  69841. */
  69842. _group: PointsGroup;
  69843. /**
  69844. * Group id of this particle
  69845. */
  69846. groupId: number;
  69847. /**
  69848. * Index of the particle in its group id (Internal use)
  69849. */
  69850. idxInGroup: number;
  69851. /**
  69852. * @hidden Particle BoundingInfo object (Internal use)
  69853. */
  69854. _boundingInfo: BoundingInfo;
  69855. /**
  69856. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69857. */
  69858. _pcs: PointsCloudSystem;
  69859. /**
  69860. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69861. */
  69862. _stillInvisible: boolean;
  69863. /**
  69864. * @hidden Last computed particle rotation matrix
  69865. */
  69866. _rotationMatrix: number[];
  69867. /**
  69868. * Parent particle Id, if any.
  69869. * Default null.
  69870. */
  69871. parentId: Nullable<number>;
  69872. /**
  69873. * @hidden Internal global position in the PCS.
  69874. */
  69875. _globalPosition: Vector3;
  69876. /**
  69877. * Creates a Point Cloud object.
  69878. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69879. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69880. * @param group (PointsGroup) is the group the particle belongs to
  69881. * @param groupId (integer) is the group identifier in the PCS.
  69882. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69883. * @param pcs defines the PCS it is associated to
  69884. */
  69885. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69886. /**
  69887. * get point size
  69888. */
  69889. get size(): Vector3;
  69890. /**
  69891. * Set point size
  69892. */
  69893. set size(scale: Vector3);
  69894. /**
  69895. * Legacy support, changed quaternion to rotationQuaternion
  69896. */
  69897. get quaternion(): Nullable<Quaternion>;
  69898. /**
  69899. * Legacy support, changed quaternion to rotationQuaternion
  69900. */
  69901. set quaternion(q: Nullable<Quaternion>);
  69902. /**
  69903. * Returns a boolean. True if the particle intersects a mesh, else false
  69904. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69905. * @param target is the object (point or mesh) what the intersection is computed against
  69906. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69907. * @returns true if it intersects
  69908. */
  69909. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69910. /**
  69911. * get the rotation matrix of the particle
  69912. * @hidden
  69913. */
  69914. getRotationMatrix(m: Matrix): void;
  69915. }
  69916. /**
  69917. * Represents a group of points in a points cloud system
  69918. * * PCS internal tool, don't use it manually.
  69919. */
  69920. export class PointsGroup {
  69921. /**
  69922. * The group id
  69923. * @hidden
  69924. */
  69925. groupID: number;
  69926. /**
  69927. * image data for group (internal use)
  69928. * @hidden
  69929. */
  69930. _groupImageData: Nullable<ArrayBufferView>;
  69931. /**
  69932. * Image Width (internal use)
  69933. * @hidden
  69934. */
  69935. _groupImgWidth: number;
  69936. /**
  69937. * Image Height (internal use)
  69938. * @hidden
  69939. */
  69940. _groupImgHeight: number;
  69941. /**
  69942. * Custom position function (internal use)
  69943. * @hidden
  69944. */
  69945. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69946. /**
  69947. * density per facet for surface points
  69948. * @hidden
  69949. */
  69950. _groupDensity: number[];
  69951. /**
  69952. * Only when points are colored by texture carries pointer to texture list array
  69953. * @hidden
  69954. */
  69955. _textureNb: number;
  69956. /**
  69957. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69958. * PCS internal tool, don't use it manually.
  69959. * @hidden
  69960. */
  69961. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69962. }
  69963. }
  69964. declare module BABYLON {
  69965. interface Scene {
  69966. /** @hidden (Backing field) */
  69967. _physicsEngine: Nullable<IPhysicsEngine>;
  69968. /** @hidden */
  69969. _physicsTimeAccumulator: number;
  69970. /**
  69971. * Gets the current physics engine
  69972. * @returns a IPhysicsEngine or null if none attached
  69973. */
  69974. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69975. /**
  69976. * Enables physics to the current scene
  69977. * @param gravity defines the scene's gravity for the physics engine
  69978. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69979. * @return a boolean indicating if the physics engine was initialized
  69980. */
  69981. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69982. /**
  69983. * Disables and disposes the physics engine associated with the scene
  69984. */
  69985. disablePhysicsEngine(): void;
  69986. /**
  69987. * Gets a boolean indicating if there is an active physics engine
  69988. * @returns a boolean indicating if there is an active physics engine
  69989. */
  69990. isPhysicsEnabled(): boolean;
  69991. /**
  69992. * Deletes a physics compound impostor
  69993. * @param compound defines the compound to delete
  69994. */
  69995. deleteCompoundImpostor(compound: any): void;
  69996. /**
  69997. * An event triggered when physic simulation is about to be run
  69998. */
  69999. onBeforePhysicsObservable: Observable<Scene>;
  70000. /**
  70001. * An event triggered when physic simulation has been done
  70002. */
  70003. onAfterPhysicsObservable: Observable<Scene>;
  70004. }
  70005. interface AbstractMesh {
  70006. /** @hidden */
  70007. _physicsImpostor: Nullable<PhysicsImpostor>;
  70008. /**
  70009. * Gets or sets impostor used for physic simulation
  70010. * @see https://doc.babylonjs.com/features/physics_engine
  70011. */
  70012. physicsImpostor: Nullable<PhysicsImpostor>;
  70013. /**
  70014. * Gets the current physics impostor
  70015. * @see https://doc.babylonjs.com/features/physics_engine
  70016. * @returns a physics impostor or null
  70017. */
  70018. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70019. /** Apply a physic impulse to the mesh
  70020. * @param force defines the force to apply
  70021. * @param contactPoint defines where to apply the force
  70022. * @returns the current mesh
  70023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  70024. */
  70025. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70026. /**
  70027. * Creates a physic joint between two meshes
  70028. * @param otherMesh defines the other mesh to use
  70029. * @param pivot1 defines the pivot to use on this mesh
  70030. * @param pivot2 defines the pivot to use on the other mesh
  70031. * @param options defines additional options (can be plugin dependent)
  70032. * @returns the current mesh
  70033. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70034. */
  70035. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70036. /** @hidden */
  70037. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70038. }
  70039. /**
  70040. * Defines the physics engine scene component responsible to manage a physics engine
  70041. */
  70042. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70043. /**
  70044. * The component name helpful to identify the component in the list of scene components.
  70045. */
  70046. readonly name: string;
  70047. /**
  70048. * The scene the component belongs to.
  70049. */
  70050. scene: Scene;
  70051. /**
  70052. * Creates a new instance of the component for the given scene
  70053. * @param scene Defines the scene to register the component in
  70054. */
  70055. constructor(scene: Scene);
  70056. /**
  70057. * Registers the component in a given scene
  70058. */
  70059. register(): void;
  70060. /**
  70061. * Rebuilds the elements related to this component in case of
  70062. * context lost for instance.
  70063. */
  70064. rebuild(): void;
  70065. /**
  70066. * Disposes the component and the associated ressources
  70067. */
  70068. dispose(): void;
  70069. }
  70070. }
  70071. declare module BABYLON {
  70072. /**
  70073. * A helper for physics simulations
  70074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70075. */
  70076. export class PhysicsHelper {
  70077. private _scene;
  70078. private _physicsEngine;
  70079. /**
  70080. * Initializes the Physics helper
  70081. * @param scene Babylon.js scene
  70082. */
  70083. constructor(scene: Scene);
  70084. /**
  70085. * Applies a radial explosion impulse
  70086. * @param origin the origin of the explosion
  70087. * @param radiusOrEventOptions the radius or the options of radial explosion
  70088. * @param strength the explosion strength
  70089. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70090. * @returns A physics radial explosion event, or null
  70091. */
  70092. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70093. /**
  70094. * Applies a radial explosion force
  70095. * @param origin the origin of the explosion
  70096. * @param radiusOrEventOptions the radius or the options of radial explosion
  70097. * @param strength the explosion strength
  70098. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70099. * @returns A physics radial explosion event, or null
  70100. */
  70101. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70102. /**
  70103. * Creates a gravitational field
  70104. * @param origin the origin of the explosion
  70105. * @param radiusOrEventOptions the radius or the options of radial explosion
  70106. * @param strength the explosion strength
  70107. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70108. * @returns A physics gravitational field event, or null
  70109. */
  70110. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70111. /**
  70112. * Creates a physics updraft event
  70113. * @param origin the origin of the updraft
  70114. * @param radiusOrEventOptions the radius or the options of the updraft
  70115. * @param strength the strength of the updraft
  70116. * @param height the height of the updraft
  70117. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70118. * @returns A physics updraft event, or null
  70119. */
  70120. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70121. /**
  70122. * Creates a physics vortex event
  70123. * @param origin the of the vortex
  70124. * @param radiusOrEventOptions the radius or the options of the vortex
  70125. * @param strength the strength of the vortex
  70126. * @param height the height of the vortex
  70127. * @returns a Physics vortex event, or null
  70128. * A physics vortex event or null
  70129. */
  70130. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70131. }
  70132. /**
  70133. * Represents a physics radial explosion event
  70134. */
  70135. class PhysicsRadialExplosionEvent {
  70136. private _scene;
  70137. private _options;
  70138. private _sphere;
  70139. private _dataFetched;
  70140. /**
  70141. * Initializes a radial explosioin event
  70142. * @param _scene BabylonJS scene
  70143. * @param _options The options for the vortex event
  70144. */
  70145. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70146. /**
  70147. * Returns the data related to the radial explosion event (sphere).
  70148. * @returns The radial explosion event data
  70149. */
  70150. getData(): PhysicsRadialExplosionEventData;
  70151. /**
  70152. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70153. * @param impostor A physics imposter
  70154. * @param origin the origin of the explosion
  70155. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70156. */
  70157. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70158. /**
  70159. * Triggers affecterd impostors callbacks
  70160. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70161. */
  70162. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70163. /**
  70164. * Disposes the sphere.
  70165. * @param force Specifies if the sphere should be disposed by force
  70166. */
  70167. dispose(force?: boolean): void;
  70168. /*** Helpers ***/
  70169. private _prepareSphere;
  70170. private _intersectsWithSphere;
  70171. }
  70172. /**
  70173. * Represents a gravitational field event
  70174. */
  70175. class PhysicsGravitationalFieldEvent {
  70176. private _physicsHelper;
  70177. private _scene;
  70178. private _origin;
  70179. private _options;
  70180. private _tickCallback;
  70181. private _sphere;
  70182. private _dataFetched;
  70183. /**
  70184. * Initializes the physics gravitational field event
  70185. * @param _physicsHelper A physics helper
  70186. * @param _scene BabylonJS scene
  70187. * @param _origin The origin position of the gravitational field event
  70188. * @param _options The options for the vortex event
  70189. */
  70190. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70191. /**
  70192. * Returns the data related to the gravitational field event (sphere).
  70193. * @returns A gravitational field event
  70194. */
  70195. getData(): PhysicsGravitationalFieldEventData;
  70196. /**
  70197. * Enables the gravitational field.
  70198. */
  70199. enable(): void;
  70200. /**
  70201. * Disables the gravitational field.
  70202. */
  70203. disable(): void;
  70204. /**
  70205. * Disposes the sphere.
  70206. * @param force The force to dispose from the gravitational field event
  70207. */
  70208. dispose(force?: boolean): void;
  70209. private _tick;
  70210. }
  70211. /**
  70212. * Represents a physics updraft event
  70213. */
  70214. class PhysicsUpdraftEvent {
  70215. private _scene;
  70216. private _origin;
  70217. private _options;
  70218. private _physicsEngine;
  70219. private _originTop;
  70220. private _originDirection;
  70221. private _tickCallback;
  70222. private _cylinder;
  70223. private _cylinderPosition;
  70224. private _dataFetched;
  70225. /**
  70226. * Initializes the physics updraft event
  70227. * @param _scene BabylonJS scene
  70228. * @param _origin The origin position of the updraft
  70229. * @param _options The options for the updraft event
  70230. */
  70231. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70232. /**
  70233. * Returns the data related to the updraft event (cylinder).
  70234. * @returns A physics updraft event
  70235. */
  70236. getData(): PhysicsUpdraftEventData;
  70237. /**
  70238. * Enables the updraft.
  70239. */
  70240. enable(): void;
  70241. /**
  70242. * Disables the updraft.
  70243. */
  70244. disable(): void;
  70245. /**
  70246. * Disposes the cylinder.
  70247. * @param force Specifies if the updraft should be disposed by force
  70248. */
  70249. dispose(force?: boolean): void;
  70250. private getImpostorHitData;
  70251. private _tick;
  70252. /*** Helpers ***/
  70253. private _prepareCylinder;
  70254. private _intersectsWithCylinder;
  70255. }
  70256. /**
  70257. * Represents a physics vortex event
  70258. */
  70259. class PhysicsVortexEvent {
  70260. private _scene;
  70261. private _origin;
  70262. private _options;
  70263. private _physicsEngine;
  70264. private _originTop;
  70265. private _tickCallback;
  70266. private _cylinder;
  70267. private _cylinderPosition;
  70268. private _dataFetched;
  70269. /**
  70270. * Initializes the physics vortex event
  70271. * @param _scene The BabylonJS scene
  70272. * @param _origin The origin position of the vortex
  70273. * @param _options The options for the vortex event
  70274. */
  70275. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70276. /**
  70277. * Returns the data related to the vortex event (cylinder).
  70278. * @returns The physics vortex event data
  70279. */
  70280. getData(): PhysicsVortexEventData;
  70281. /**
  70282. * Enables the vortex.
  70283. */
  70284. enable(): void;
  70285. /**
  70286. * Disables the cortex.
  70287. */
  70288. disable(): void;
  70289. /**
  70290. * Disposes the sphere.
  70291. * @param force
  70292. */
  70293. dispose(force?: boolean): void;
  70294. private getImpostorHitData;
  70295. private _tick;
  70296. /*** Helpers ***/
  70297. private _prepareCylinder;
  70298. private _intersectsWithCylinder;
  70299. }
  70300. /**
  70301. * Options fot the radial explosion event
  70302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70303. */
  70304. export class PhysicsRadialExplosionEventOptions {
  70305. /**
  70306. * The radius of the sphere for the radial explosion.
  70307. */
  70308. radius: number;
  70309. /**
  70310. * The strenth of the explosion.
  70311. */
  70312. strength: number;
  70313. /**
  70314. * The strenght of the force in correspondence to the distance of the affected object
  70315. */
  70316. falloff: PhysicsRadialImpulseFalloff;
  70317. /**
  70318. * Sphere options for the radial explosion.
  70319. */
  70320. sphere: {
  70321. segments: number;
  70322. diameter: number;
  70323. };
  70324. /**
  70325. * Sphere options for the radial explosion.
  70326. */
  70327. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70328. }
  70329. /**
  70330. * Options fot the updraft event
  70331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70332. */
  70333. export class PhysicsUpdraftEventOptions {
  70334. /**
  70335. * The radius of the cylinder for the vortex
  70336. */
  70337. radius: number;
  70338. /**
  70339. * The strenth of the updraft.
  70340. */
  70341. strength: number;
  70342. /**
  70343. * The height of the cylinder for the updraft.
  70344. */
  70345. height: number;
  70346. /**
  70347. * The mode for the the updraft.
  70348. */
  70349. updraftMode: PhysicsUpdraftMode;
  70350. }
  70351. /**
  70352. * Options fot the vortex event
  70353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70354. */
  70355. export class PhysicsVortexEventOptions {
  70356. /**
  70357. * The radius of the cylinder for the vortex
  70358. */
  70359. radius: number;
  70360. /**
  70361. * The strenth of the vortex.
  70362. */
  70363. strength: number;
  70364. /**
  70365. * The height of the cylinder for the vortex.
  70366. */
  70367. height: number;
  70368. /**
  70369. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70370. */
  70371. centripetalForceThreshold: number;
  70372. /**
  70373. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70374. */
  70375. centripetalForceMultiplier: number;
  70376. /**
  70377. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70378. */
  70379. centrifugalForceMultiplier: number;
  70380. /**
  70381. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70382. */
  70383. updraftForceMultiplier: number;
  70384. }
  70385. /**
  70386. * The strenght of the force in correspondence to the distance of the affected object
  70387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70388. */
  70389. export enum PhysicsRadialImpulseFalloff {
  70390. /** Defines that impulse is constant in strength across it's whole radius */
  70391. Constant = 0,
  70392. /** Defines that impulse gets weaker if it's further from the origin */
  70393. Linear = 1
  70394. }
  70395. /**
  70396. * The strength of the force in correspondence to the distance of the affected object
  70397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70398. */
  70399. export enum PhysicsUpdraftMode {
  70400. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70401. Center = 0,
  70402. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70403. Perpendicular = 1
  70404. }
  70405. /**
  70406. * Interface for a physics hit data
  70407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70408. */
  70409. export interface PhysicsHitData {
  70410. /**
  70411. * The force applied at the contact point
  70412. */
  70413. force: Vector3;
  70414. /**
  70415. * The contact point
  70416. */
  70417. contactPoint: Vector3;
  70418. /**
  70419. * The distance from the origin to the contact point
  70420. */
  70421. distanceFromOrigin: number;
  70422. }
  70423. /**
  70424. * Interface for radial explosion event data
  70425. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70426. */
  70427. export interface PhysicsRadialExplosionEventData {
  70428. /**
  70429. * A sphere used for the radial explosion event
  70430. */
  70431. sphere: Mesh;
  70432. }
  70433. /**
  70434. * Interface for gravitational field event data
  70435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70436. */
  70437. export interface PhysicsGravitationalFieldEventData {
  70438. /**
  70439. * A sphere mesh used for the gravitational field event
  70440. */
  70441. sphere: Mesh;
  70442. }
  70443. /**
  70444. * Interface for updraft event data
  70445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70446. */
  70447. export interface PhysicsUpdraftEventData {
  70448. /**
  70449. * A cylinder used for the updraft event
  70450. */
  70451. cylinder: Mesh;
  70452. }
  70453. /**
  70454. * Interface for vortex event data
  70455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70456. */
  70457. export interface PhysicsVortexEventData {
  70458. /**
  70459. * A cylinder used for the vortex event
  70460. */
  70461. cylinder: Mesh;
  70462. }
  70463. /**
  70464. * Interface for an affected physics impostor
  70465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70466. */
  70467. export interface PhysicsAffectedImpostorWithData {
  70468. /**
  70469. * The impostor affected by the effect
  70470. */
  70471. impostor: PhysicsImpostor;
  70472. /**
  70473. * The data about the hit/horce from the explosion
  70474. */
  70475. hitData: PhysicsHitData;
  70476. }
  70477. }
  70478. declare module BABYLON {
  70479. /** @hidden */
  70480. export var blackAndWhitePixelShader: {
  70481. name: string;
  70482. shader: string;
  70483. };
  70484. }
  70485. declare module BABYLON {
  70486. /**
  70487. * Post process used to render in black and white
  70488. */
  70489. export class BlackAndWhitePostProcess extends PostProcess {
  70490. /**
  70491. * Linear about to convert he result to black and white (default: 1)
  70492. */
  70493. degree: number;
  70494. /**
  70495. * Gets a string identifying the name of the class
  70496. * @returns "BlackAndWhitePostProcess" string
  70497. */
  70498. getClassName(): string;
  70499. /**
  70500. * Creates a black and white post process
  70501. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70502. * @param name The name of the effect.
  70503. * @param options The required width/height ratio to downsize to before computing the render pass.
  70504. * @param camera The camera to apply the render pass to.
  70505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70506. * @param engine The engine which the post process will be applied. (default: current engine)
  70507. * @param reusable If the post process can be reused on the same frame. (default: false)
  70508. */
  70509. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70510. /** @hidden */
  70511. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70512. }
  70513. }
  70514. declare module BABYLON {
  70515. /**
  70516. * This represents a set of one or more post processes in Babylon.
  70517. * A post process can be used to apply a shader to a texture after it is rendered.
  70518. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70519. */
  70520. export class PostProcessRenderEffect {
  70521. private _postProcesses;
  70522. private _getPostProcesses;
  70523. private _singleInstance;
  70524. private _cameras;
  70525. private _indicesForCamera;
  70526. /**
  70527. * Name of the effect
  70528. * @hidden
  70529. */
  70530. _name: string;
  70531. /**
  70532. * Instantiates a post process render effect.
  70533. * A post process can be used to apply a shader to a texture after it is rendered.
  70534. * @param engine The engine the effect is tied to
  70535. * @param name The name of the effect
  70536. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70537. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70538. */
  70539. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70540. /**
  70541. * Checks if all the post processes in the effect are supported.
  70542. */
  70543. get isSupported(): boolean;
  70544. /**
  70545. * Updates the current state of the effect
  70546. * @hidden
  70547. */
  70548. _update(): void;
  70549. /**
  70550. * Attaches the effect on cameras
  70551. * @param cameras The camera to attach to.
  70552. * @hidden
  70553. */
  70554. _attachCameras(cameras: Camera): void;
  70555. /**
  70556. * Attaches the effect on cameras
  70557. * @param cameras The camera to attach to.
  70558. * @hidden
  70559. */
  70560. _attachCameras(cameras: Camera[]): void;
  70561. /**
  70562. * Detaches the effect on cameras
  70563. * @param cameras The camera to detatch from.
  70564. * @hidden
  70565. */
  70566. _detachCameras(cameras: Camera): void;
  70567. /**
  70568. * Detatches the effect on cameras
  70569. * @param cameras The camera to detatch from.
  70570. * @hidden
  70571. */
  70572. _detachCameras(cameras: Camera[]): void;
  70573. /**
  70574. * Enables the effect on given cameras
  70575. * @param cameras The camera to enable.
  70576. * @hidden
  70577. */
  70578. _enable(cameras: Camera): void;
  70579. /**
  70580. * Enables the effect on given cameras
  70581. * @param cameras The camera to enable.
  70582. * @hidden
  70583. */
  70584. _enable(cameras: Nullable<Camera[]>): void;
  70585. /**
  70586. * Disables the effect on the given cameras
  70587. * @param cameras The camera to disable.
  70588. * @hidden
  70589. */
  70590. _disable(cameras: Camera): void;
  70591. /**
  70592. * Disables the effect on the given cameras
  70593. * @param cameras The camera to disable.
  70594. * @hidden
  70595. */
  70596. _disable(cameras: Nullable<Camera[]>): void;
  70597. /**
  70598. * Gets a list of the post processes contained in the effect.
  70599. * @param camera The camera to get the post processes on.
  70600. * @returns The list of the post processes in the effect.
  70601. */
  70602. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70603. }
  70604. }
  70605. declare module BABYLON {
  70606. /** @hidden */
  70607. export var extractHighlightsPixelShader: {
  70608. name: string;
  70609. shader: string;
  70610. };
  70611. }
  70612. declare module BABYLON {
  70613. /**
  70614. * 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.
  70615. */
  70616. export class ExtractHighlightsPostProcess extends PostProcess {
  70617. /**
  70618. * The luminance threshold, pixels below this value will be set to black.
  70619. */
  70620. threshold: number;
  70621. /** @hidden */
  70622. _exposure: number;
  70623. /**
  70624. * Post process which has the input texture to be used when performing highlight extraction
  70625. * @hidden
  70626. */
  70627. _inputPostProcess: Nullable<PostProcess>;
  70628. /**
  70629. * Gets a string identifying the name of the class
  70630. * @returns "ExtractHighlightsPostProcess" string
  70631. */
  70632. getClassName(): string;
  70633. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70634. }
  70635. }
  70636. declare module BABYLON {
  70637. /** @hidden */
  70638. export var bloomMergePixelShader: {
  70639. name: string;
  70640. shader: string;
  70641. };
  70642. }
  70643. declare module BABYLON {
  70644. /**
  70645. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70646. */
  70647. export class BloomMergePostProcess extends PostProcess {
  70648. /** Weight of the bloom to be added to the original input. */
  70649. weight: number;
  70650. /**
  70651. * Gets a string identifying the name of the class
  70652. * @returns "BloomMergePostProcess" string
  70653. */
  70654. getClassName(): string;
  70655. /**
  70656. * Creates a new instance of @see BloomMergePostProcess
  70657. * @param name The name of the effect.
  70658. * @param originalFromInput Post process which's input will be used for the merge.
  70659. * @param blurred Blurred highlights post process which's output will be used.
  70660. * @param weight Weight of the bloom to be added to the original input.
  70661. * @param options The required width/height ratio to downsize to before computing the render pass.
  70662. * @param camera The camera to apply the render pass to.
  70663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70664. * @param engine The engine which the post process will be applied. (default: current engine)
  70665. * @param reusable If the post process can be reused on the same frame. (default: false)
  70666. * @param textureType Type of textures used when performing the post process. (default: 0)
  70667. * @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)
  70668. */
  70669. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70670. /** Weight of the bloom to be added to the original input. */
  70671. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70672. }
  70673. }
  70674. declare module BABYLON {
  70675. /**
  70676. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70677. */
  70678. export class BloomEffect extends PostProcessRenderEffect {
  70679. private bloomScale;
  70680. /**
  70681. * @hidden Internal
  70682. */
  70683. _effects: Array<PostProcess>;
  70684. /**
  70685. * @hidden Internal
  70686. */
  70687. _downscale: ExtractHighlightsPostProcess;
  70688. private _blurX;
  70689. private _blurY;
  70690. private _merge;
  70691. /**
  70692. * The luminance threshold to find bright areas of the image to bloom.
  70693. */
  70694. get threshold(): number;
  70695. set threshold(value: number);
  70696. /**
  70697. * The strength of the bloom.
  70698. */
  70699. get weight(): number;
  70700. set weight(value: number);
  70701. /**
  70702. * Specifies the size of the bloom blur kernel, relative to the final output size
  70703. */
  70704. get kernel(): number;
  70705. set kernel(value: number);
  70706. /**
  70707. * Creates a new instance of @see BloomEffect
  70708. * @param scene The scene the effect belongs to.
  70709. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70710. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70711. * @param bloomWeight The the strength of bloom.
  70712. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70713. * @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)
  70714. */
  70715. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70716. /**
  70717. * Disposes each of the internal effects for a given camera.
  70718. * @param camera The camera to dispose the effect on.
  70719. */
  70720. disposeEffects(camera: Camera): void;
  70721. /**
  70722. * @hidden Internal
  70723. */
  70724. _updateEffects(): void;
  70725. /**
  70726. * Internal
  70727. * @returns if all the contained post processes are ready.
  70728. * @hidden
  70729. */
  70730. _isReady(): boolean;
  70731. }
  70732. }
  70733. declare module BABYLON {
  70734. /** @hidden */
  70735. export var chromaticAberrationPixelShader: {
  70736. name: string;
  70737. shader: string;
  70738. };
  70739. }
  70740. declare module BABYLON {
  70741. /**
  70742. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70743. */
  70744. export class ChromaticAberrationPostProcess extends PostProcess {
  70745. /**
  70746. * The amount of seperation of rgb channels (default: 30)
  70747. */
  70748. aberrationAmount: number;
  70749. /**
  70750. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70751. */
  70752. radialIntensity: number;
  70753. /**
  70754. * 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))
  70755. */
  70756. direction: Vector2;
  70757. /**
  70758. * 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))
  70759. */
  70760. centerPosition: Vector2;
  70761. /** The width of the screen to apply the effect on */
  70762. screenWidth: number;
  70763. /** The height of the screen to apply the effect on */
  70764. screenHeight: number;
  70765. /**
  70766. * Gets a string identifying the name of the class
  70767. * @returns "ChromaticAberrationPostProcess" string
  70768. */
  70769. getClassName(): string;
  70770. /**
  70771. * Creates a new instance ChromaticAberrationPostProcess
  70772. * @param name The name of the effect.
  70773. * @param screenWidth The width of the screen to apply the effect on.
  70774. * @param screenHeight The height of the screen to apply the effect on.
  70775. * @param options The required width/height ratio to downsize to before computing the render pass.
  70776. * @param camera The camera to apply the render pass to.
  70777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70778. * @param engine The engine which the post process will be applied. (default: current engine)
  70779. * @param reusable If the post process can be reused on the same frame. (default: false)
  70780. * @param textureType Type of textures used when performing the post process. (default: 0)
  70781. * @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)
  70782. */
  70783. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70784. /** @hidden */
  70785. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70786. }
  70787. }
  70788. declare module BABYLON {
  70789. /** @hidden */
  70790. export var circleOfConfusionPixelShader: {
  70791. name: string;
  70792. shader: string;
  70793. };
  70794. }
  70795. declare module BABYLON {
  70796. /**
  70797. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70798. */
  70799. export class CircleOfConfusionPostProcess extends PostProcess {
  70800. /**
  70801. * 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.
  70802. */
  70803. lensSize: number;
  70804. /**
  70805. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70806. */
  70807. fStop: number;
  70808. /**
  70809. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70810. */
  70811. focusDistance: number;
  70812. /**
  70813. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70814. */
  70815. focalLength: number;
  70816. /**
  70817. * Gets a string identifying the name of the class
  70818. * @returns "CircleOfConfusionPostProcess" string
  70819. */
  70820. getClassName(): string;
  70821. private _depthTexture;
  70822. /**
  70823. * Creates a new instance CircleOfConfusionPostProcess
  70824. * @param name The name of the effect.
  70825. * @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.
  70826. * @param options The required width/height ratio to downsize to before computing the render pass.
  70827. * @param camera The camera to apply the render pass to.
  70828. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70829. * @param engine The engine which the post process will be applied. (default: current engine)
  70830. * @param reusable If the post process can be reused on the same frame. (default: false)
  70831. * @param textureType Type of textures used when performing the post process. (default: 0)
  70832. * @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)
  70833. */
  70834. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70835. /**
  70836. * 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.
  70837. */
  70838. set depthTexture(value: RenderTargetTexture);
  70839. }
  70840. }
  70841. declare module BABYLON {
  70842. /** @hidden */
  70843. export var colorCorrectionPixelShader: {
  70844. name: string;
  70845. shader: string;
  70846. };
  70847. }
  70848. declare module BABYLON {
  70849. /**
  70850. *
  70851. * This post-process allows the modification of rendered colors by using
  70852. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70853. *
  70854. * The object needs to be provided an url to a texture containing the color
  70855. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70856. * Use an image editing software to tweak the LUT to match your needs.
  70857. *
  70858. * For an example of a color LUT, see here:
  70859. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70860. * For explanations on color grading, see here:
  70861. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70862. *
  70863. */
  70864. export class ColorCorrectionPostProcess extends PostProcess {
  70865. private _colorTableTexture;
  70866. /**
  70867. * Gets the color table url used to create the LUT texture
  70868. */
  70869. colorTableUrl: string;
  70870. /**
  70871. * Gets a string identifying the name of the class
  70872. * @returns "ColorCorrectionPostProcess" string
  70873. */
  70874. getClassName(): string;
  70875. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70876. /** @hidden */
  70877. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70878. }
  70879. }
  70880. declare module BABYLON {
  70881. /** @hidden */
  70882. export var convolutionPixelShader: {
  70883. name: string;
  70884. shader: string;
  70885. };
  70886. }
  70887. declare module BABYLON {
  70888. /**
  70889. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70890. * input texture to perform effects such as edge detection or sharpening
  70891. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70892. */
  70893. export class ConvolutionPostProcess extends PostProcess {
  70894. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70895. kernel: number[];
  70896. /**
  70897. * Gets a string identifying the name of the class
  70898. * @returns "ConvolutionPostProcess" string
  70899. */
  70900. getClassName(): string;
  70901. /**
  70902. * Creates a new instance ConvolutionPostProcess
  70903. * @param name The name of the effect.
  70904. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70905. * @param options The required width/height ratio to downsize to before computing the render pass.
  70906. * @param camera The camera to apply the render pass to.
  70907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70908. * @param engine The engine which the post process will be applied. (default: current engine)
  70909. * @param reusable If the post process can be reused on the same frame. (default: false)
  70910. * @param textureType Type of textures used when performing the post process. (default: 0)
  70911. */
  70912. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70913. /** @hidden */
  70914. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70915. /**
  70916. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70917. */
  70918. static EdgeDetect0Kernel: number[];
  70919. /**
  70920. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70921. */
  70922. static EdgeDetect1Kernel: number[];
  70923. /**
  70924. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70925. */
  70926. static EdgeDetect2Kernel: number[];
  70927. /**
  70928. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70929. */
  70930. static SharpenKernel: number[];
  70931. /**
  70932. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70933. */
  70934. static EmbossKernel: number[];
  70935. /**
  70936. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70937. */
  70938. static GaussianKernel: number[];
  70939. }
  70940. }
  70941. declare module BABYLON {
  70942. /**
  70943. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70944. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70945. * based on samples that have a large difference in distance than the center pixel.
  70946. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70947. */
  70948. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70949. /**
  70950. * The direction the blur should be applied
  70951. */
  70952. direction: Vector2;
  70953. /**
  70954. * Gets a string identifying the name of the class
  70955. * @returns "DepthOfFieldBlurPostProcess" string
  70956. */
  70957. getClassName(): string;
  70958. /**
  70959. * Creates a new instance CircleOfConfusionPostProcess
  70960. * @param name The name of the effect.
  70961. * @param scene The scene the effect belongs to.
  70962. * @param direction The direction the blur should be applied.
  70963. * @param kernel The size of the kernel used to blur.
  70964. * @param options The required width/height ratio to downsize to before computing the render pass.
  70965. * @param camera The camera to apply the render pass to.
  70966. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70967. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70969. * @param engine The engine which the post process will be applied. (default: current engine)
  70970. * @param reusable If the post process can be reused on the same frame. (default: false)
  70971. * @param textureType Type of textures used when performing the post process. (default: 0)
  70972. * @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)
  70973. */
  70974. 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);
  70975. }
  70976. }
  70977. declare module BABYLON {
  70978. /** @hidden */
  70979. export var depthOfFieldMergePixelShader: {
  70980. name: string;
  70981. shader: string;
  70982. };
  70983. }
  70984. declare module BABYLON {
  70985. /**
  70986. * Options to be set when merging outputs from the default pipeline.
  70987. */
  70988. export class DepthOfFieldMergePostProcessOptions {
  70989. /**
  70990. * The original image to merge on top of
  70991. */
  70992. originalFromInput: PostProcess;
  70993. /**
  70994. * Parameters to perform the merge of the depth of field effect
  70995. */
  70996. depthOfField?: {
  70997. circleOfConfusion: PostProcess;
  70998. blurSteps: Array<PostProcess>;
  70999. };
  71000. /**
  71001. * Parameters to perform the merge of bloom effect
  71002. */
  71003. bloom?: {
  71004. blurred: PostProcess;
  71005. weight: number;
  71006. };
  71007. }
  71008. /**
  71009. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71010. */
  71011. export class DepthOfFieldMergePostProcess extends PostProcess {
  71012. private blurSteps;
  71013. /**
  71014. * Gets a string identifying the name of the class
  71015. * @returns "DepthOfFieldMergePostProcess" string
  71016. */
  71017. getClassName(): string;
  71018. /**
  71019. * Creates a new instance of DepthOfFieldMergePostProcess
  71020. * @param name The name of the effect.
  71021. * @param originalFromInput Post process which's input will be used for the merge.
  71022. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71023. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71024. * @param options The required width/height ratio to downsize to before computing the render pass.
  71025. * @param camera The camera to apply the render pass to.
  71026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71027. * @param engine The engine which the post process will be applied. (default: current engine)
  71028. * @param reusable If the post process can be reused on the same frame. (default: false)
  71029. * @param textureType Type of textures used when performing the post process. (default: 0)
  71030. * @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)
  71031. */
  71032. 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);
  71033. /**
  71034. * Updates the effect with the current post process compile time values and recompiles the shader.
  71035. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71036. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71037. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71038. * @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
  71039. * @param onCompiled Called when the shader has been compiled.
  71040. * @param onError Called if there is an error when compiling a shader.
  71041. */
  71042. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71043. }
  71044. }
  71045. declare module BABYLON {
  71046. /**
  71047. * Specifies the level of max blur that should be applied when using the depth of field effect
  71048. */
  71049. export enum DepthOfFieldEffectBlurLevel {
  71050. /**
  71051. * Subtle blur
  71052. */
  71053. Low = 0,
  71054. /**
  71055. * Medium blur
  71056. */
  71057. Medium = 1,
  71058. /**
  71059. * Large blur
  71060. */
  71061. High = 2
  71062. }
  71063. /**
  71064. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71065. */
  71066. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71067. private _circleOfConfusion;
  71068. /**
  71069. * @hidden Internal, blurs from high to low
  71070. */
  71071. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71072. private _depthOfFieldBlurY;
  71073. private _dofMerge;
  71074. /**
  71075. * @hidden Internal post processes in depth of field effect
  71076. */
  71077. _effects: Array<PostProcess>;
  71078. /**
  71079. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71080. */
  71081. set focalLength(value: number);
  71082. get focalLength(): number;
  71083. /**
  71084. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71085. */
  71086. set fStop(value: number);
  71087. get fStop(): number;
  71088. /**
  71089. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71090. */
  71091. set focusDistance(value: number);
  71092. get focusDistance(): number;
  71093. /**
  71094. * 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.
  71095. */
  71096. set lensSize(value: number);
  71097. get lensSize(): number;
  71098. /**
  71099. * Creates a new instance DepthOfFieldEffect
  71100. * @param scene The scene the effect belongs to.
  71101. * @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.
  71102. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71103. * @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)
  71104. */
  71105. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71106. /**
  71107. * Get the current class name of the current effet
  71108. * @returns "DepthOfFieldEffect"
  71109. */
  71110. getClassName(): string;
  71111. /**
  71112. * 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.
  71113. */
  71114. set depthTexture(value: RenderTargetTexture);
  71115. /**
  71116. * Disposes each of the internal effects for a given camera.
  71117. * @param camera The camera to dispose the effect on.
  71118. */
  71119. disposeEffects(camera: Camera): void;
  71120. /**
  71121. * @hidden Internal
  71122. */
  71123. _updateEffects(): void;
  71124. /**
  71125. * Internal
  71126. * @returns if all the contained post processes are ready.
  71127. * @hidden
  71128. */
  71129. _isReady(): boolean;
  71130. }
  71131. }
  71132. declare module BABYLON {
  71133. /** @hidden */
  71134. export var displayPassPixelShader: {
  71135. name: string;
  71136. shader: string;
  71137. };
  71138. }
  71139. declare module BABYLON {
  71140. /**
  71141. * DisplayPassPostProcess which produces an output the same as it's input
  71142. */
  71143. export class DisplayPassPostProcess extends PostProcess {
  71144. /**
  71145. * Gets a string identifying the name of the class
  71146. * @returns "DisplayPassPostProcess" string
  71147. */
  71148. getClassName(): string;
  71149. /**
  71150. * Creates the DisplayPassPostProcess
  71151. * @param name The name of the effect.
  71152. * @param options The required width/height ratio to downsize to before computing the render pass.
  71153. * @param camera The camera to apply the render pass to.
  71154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71155. * @param engine The engine which the post process will be applied. (default: current engine)
  71156. * @param reusable If the post process can be reused on the same frame. (default: false)
  71157. */
  71158. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71159. /** @hidden */
  71160. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  71161. }
  71162. }
  71163. declare module BABYLON {
  71164. /** @hidden */
  71165. export var filterPixelShader: {
  71166. name: string;
  71167. shader: string;
  71168. };
  71169. }
  71170. declare module BABYLON {
  71171. /**
  71172. * Applies a kernel filter to the image
  71173. */
  71174. export class FilterPostProcess extends PostProcess {
  71175. /** The matrix to be applied to the image */
  71176. kernelMatrix: Matrix;
  71177. /**
  71178. * Gets a string identifying the name of the class
  71179. * @returns "FilterPostProcess" string
  71180. */
  71181. getClassName(): string;
  71182. /**
  71183. *
  71184. * @param name The name of the effect.
  71185. * @param kernelMatrix The matrix to be applied to the image
  71186. * @param options The required width/height ratio to downsize to before computing the render pass.
  71187. * @param camera The camera to apply the render pass to.
  71188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71189. * @param engine The engine which the post process will be applied. (default: current engine)
  71190. * @param reusable If the post process can be reused on the same frame. (default: false)
  71191. */
  71192. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71193. /** @hidden */
  71194. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  71195. }
  71196. }
  71197. declare module BABYLON {
  71198. /** @hidden */
  71199. export var fxaaPixelShader: {
  71200. name: string;
  71201. shader: string;
  71202. };
  71203. }
  71204. declare module BABYLON {
  71205. /** @hidden */
  71206. export var fxaaVertexShader: {
  71207. name: string;
  71208. shader: string;
  71209. };
  71210. }
  71211. declare module BABYLON {
  71212. /**
  71213. * Fxaa post process
  71214. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71215. */
  71216. export class FxaaPostProcess extends PostProcess {
  71217. /**
  71218. * Gets a string identifying the name of the class
  71219. * @returns "FxaaPostProcess" string
  71220. */
  71221. getClassName(): string;
  71222. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71223. private _getDefines;
  71224. /** @hidden */
  71225. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  71226. }
  71227. }
  71228. declare module BABYLON {
  71229. /** @hidden */
  71230. export var grainPixelShader: {
  71231. name: string;
  71232. shader: string;
  71233. };
  71234. }
  71235. declare module BABYLON {
  71236. /**
  71237. * The GrainPostProcess adds noise to the image at mid luminance levels
  71238. */
  71239. export class GrainPostProcess extends PostProcess {
  71240. /**
  71241. * The intensity of the grain added (default: 30)
  71242. */
  71243. intensity: number;
  71244. /**
  71245. * If the grain should be randomized on every frame
  71246. */
  71247. animated: boolean;
  71248. /**
  71249. * Gets a string identifying the name of the class
  71250. * @returns "GrainPostProcess" string
  71251. */
  71252. getClassName(): string;
  71253. /**
  71254. * Creates a new instance of @see GrainPostProcess
  71255. * @param name The name of the effect.
  71256. * @param options The required width/height ratio to downsize to before computing the render pass.
  71257. * @param camera The camera to apply the render pass to.
  71258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71259. * @param engine The engine which the post process will be applied. (default: current engine)
  71260. * @param reusable If the post process can be reused on the same frame. (default: false)
  71261. * @param textureType Type of textures used when performing the post process. (default: 0)
  71262. * @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)
  71263. */
  71264. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71265. /** @hidden */
  71266. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  71267. }
  71268. }
  71269. declare module BABYLON {
  71270. /** @hidden */
  71271. export var highlightsPixelShader: {
  71272. name: string;
  71273. shader: string;
  71274. };
  71275. }
  71276. declare module BABYLON {
  71277. /**
  71278. * Extracts highlights from the image
  71279. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71280. */
  71281. export class HighlightsPostProcess extends PostProcess {
  71282. /**
  71283. * Gets a string identifying the name of the class
  71284. * @returns "HighlightsPostProcess" string
  71285. */
  71286. getClassName(): string;
  71287. /**
  71288. * Extracts highlights from the image
  71289. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71290. * @param name The name of the effect.
  71291. * @param options The required width/height ratio to downsize to before computing the render pass.
  71292. * @param camera The camera to apply the render pass to.
  71293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71294. * @param engine The engine which the post process will be applied. (default: current engine)
  71295. * @param reusable If the post process can be reused on the same frame. (default: false)
  71296. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71297. */
  71298. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71299. }
  71300. }
  71301. declare module BABYLON {
  71302. /**
  71303. * Contains all parameters needed for the prepass to perform
  71304. * motion blur
  71305. */
  71306. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  71307. /**
  71308. * Is motion blur enabled
  71309. */
  71310. enabled: boolean;
  71311. /**
  71312. * Name of the configuration
  71313. */
  71314. name: string;
  71315. /**
  71316. * Textures that should be present in the MRT for this effect to work
  71317. */
  71318. readonly texturesRequired: number[];
  71319. }
  71320. }
  71321. declare module BABYLON {
  71322. interface Scene {
  71323. /** @hidden (Backing field) */
  71324. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71325. /**
  71326. * Gets or Sets the current geometry buffer associated to the scene.
  71327. */
  71328. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71329. /**
  71330. * Enables a GeometryBufferRender and associates it with the scene
  71331. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71332. * @returns the GeometryBufferRenderer
  71333. */
  71334. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71335. /**
  71336. * Disables the GeometryBufferRender associated with the scene
  71337. */
  71338. disableGeometryBufferRenderer(): void;
  71339. }
  71340. /**
  71341. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71342. * in several rendering techniques.
  71343. */
  71344. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71345. /**
  71346. * The component name helpful to identify the component in the list of scene components.
  71347. */
  71348. readonly name: string;
  71349. /**
  71350. * The scene the component belongs to.
  71351. */
  71352. scene: Scene;
  71353. /**
  71354. * Creates a new instance of the component for the given scene
  71355. * @param scene Defines the scene to register the component in
  71356. */
  71357. constructor(scene: Scene);
  71358. /**
  71359. * Registers the component in a given scene
  71360. */
  71361. register(): void;
  71362. /**
  71363. * Rebuilds the elements related to this component in case of
  71364. * context lost for instance.
  71365. */
  71366. rebuild(): void;
  71367. /**
  71368. * Disposes the component and the associated ressources
  71369. */
  71370. dispose(): void;
  71371. private _gatherRenderTargets;
  71372. }
  71373. }
  71374. declare module BABYLON {
  71375. /** @hidden */
  71376. export var motionBlurPixelShader: {
  71377. name: string;
  71378. shader: string;
  71379. };
  71380. }
  71381. declare module BABYLON {
  71382. /**
  71383. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71384. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71385. * As an example, all you have to do is to create the post-process:
  71386. * var mb = new BABYLON.MotionBlurPostProcess(
  71387. * 'mb', // The name of the effect.
  71388. * scene, // The scene containing the objects to blur according to their velocity.
  71389. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71390. * camera // The camera to apply the render pass to.
  71391. * );
  71392. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71393. */
  71394. export class MotionBlurPostProcess extends PostProcess {
  71395. /**
  71396. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71397. */
  71398. motionStrength: number;
  71399. /**
  71400. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71401. */
  71402. get motionBlurSamples(): number;
  71403. /**
  71404. * Sets the number of iterations to be used for motion blur quality
  71405. */
  71406. set motionBlurSamples(samples: number);
  71407. private _motionBlurSamples;
  71408. /**
  71409. * Gets wether or not the motion blur post-process is in object based mode.
  71410. */
  71411. get isObjectBased(): boolean;
  71412. /**
  71413. * Sets wether or not the motion blur post-process is in object based mode.
  71414. */
  71415. set isObjectBased(value: boolean);
  71416. private _isObjectBased;
  71417. private _forceGeometryBuffer;
  71418. private _geometryBufferRenderer;
  71419. private _prePassRenderer;
  71420. private _invViewProjection;
  71421. private _previousViewProjection;
  71422. /**
  71423. * Gets a string identifying the name of the class
  71424. * @returns "MotionBlurPostProcess" string
  71425. */
  71426. getClassName(): string;
  71427. /**
  71428. * Creates a new instance MotionBlurPostProcess
  71429. * @param name The name of the effect.
  71430. * @param scene The scene containing the objects to blur according to their velocity.
  71431. * @param options The required width/height ratio to downsize to before computing the render pass.
  71432. * @param camera The camera to apply the render pass to.
  71433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71434. * @param engine The engine which the post process will be applied. (default: current engine)
  71435. * @param reusable If the post process can be reused on the same frame. (default: false)
  71436. * @param textureType Type of textures used when performing the post process. (default: 0)
  71437. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)
  71438. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71439. */
  71440. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71441. /**
  71442. * Excludes the given skinned mesh from computing bones velocities.
  71443. * 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.
  71444. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71445. */
  71446. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71447. /**
  71448. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71449. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71450. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71451. */
  71452. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71453. /**
  71454. * Disposes the post process.
  71455. * @param camera The camera to dispose the post process on.
  71456. */
  71457. dispose(camera?: Camera): void;
  71458. /**
  71459. * Called on the mode changed (object based or screen based).
  71460. */
  71461. private _applyMode;
  71462. /**
  71463. * Called on the effect is applied when the motion blur post-process is in object based mode.
  71464. */
  71465. private _onApplyObjectBased;
  71466. /**
  71467. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  71468. */
  71469. private _onApplyScreenBased;
  71470. /**
  71471. * Called on the effect must be updated (changed mode, samples count, etc.).
  71472. */
  71473. private _updateEffect;
  71474. /** @hidden */
  71475. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71476. }
  71477. }
  71478. declare module BABYLON {
  71479. /** @hidden */
  71480. export var refractionPixelShader: {
  71481. name: string;
  71482. shader: string;
  71483. };
  71484. }
  71485. declare module BABYLON {
  71486. /**
  71487. * Post process which applies a refractin texture
  71488. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71489. */
  71490. export class RefractionPostProcess extends PostProcess {
  71491. private _refTexture;
  71492. private _ownRefractionTexture;
  71493. /** the base color of the refraction (used to taint the rendering) */
  71494. color: Color3;
  71495. /** simulated refraction depth */
  71496. depth: number;
  71497. /** the coefficient of the base color (0 to remove base color tainting) */
  71498. colorLevel: number;
  71499. /** Gets the url used to load the refraction texture */
  71500. refractionTextureUrl: string;
  71501. /**
  71502. * Gets or sets the refraction texture
  71503. * Please note that you are responsible for disposing the texture if you set it manually
  71504. */
  71505. get refractionTexture(): Texture;
  71506. set refractionTexture(value: Texture);
  71507. /**
  71508. * Gets a string identifying the name of the class
  71509. * @returns "RefractionPostProcess" string
  71510. */
  71511. getClassName(): string;
  71512. /**
  71513. * Initializes the RefractionPostProcess
  71514. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71515. * @param name The name of the effect.
  71516. * @param refractionTextureUrl Url of the refraction texture to use
  71517. * @param color the base color of the refraction (used to taint the rendering)
  71518. * @param depth simulated refraction depth
  71519. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71520. * @param camera The camera to apply the render pass to.
  71521. * @param options The required width/height ratio to downsize to before computing the render pass.
  71522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71523. * @param engine The engine which the post process will be applied. (default: current engine)
  71524. * @param reusable If the post process can be reused on the same frame. (default: false)
  71525. */
  71526. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71527. /**
  71528. * Disposes of the post process
  71529. * @param camera Camera to dispose post process on
  71530. */
  71531. dispose(camera: Camera): void;
  71532. /** @hidden */
  71533. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71534. }
  71535. }
  71536. declare module BABYLON {
  71537. /** @hidden */
  71538. export var sharpenPixelShader: {
  71539. name: string;
  71540. shader: string;
  71541. };
  71542. }
  71543. declare module BABYLON {
  71544. /**
  71545. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71546. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71547. */
  71548. export class SharpenPostProcess extends PostProcess {
  71549. /**
  71550. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71551. */
  71552. colorAmount: number;
  71553. /**
  71554. * How much sharpness should be applied (default: 0.3)
  71555. */
  71556. edgeAmount: number;
  71557. /**
  71558. * Gets a string identifying the name of the class
  71559. * @returns "SharpenPostProcess" string
  71560. */
  71561. getClassName(): string;
  71562. /**
  71563. * Creates a new instance ConvolutionPostProcess
  71564. * @param name The name of the effect.
  71565. * @param options The required width/height ratio to downsize to before computing the render pass.
  71566. * @param camera The camera to apply the render pass to.
  71567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71568. * @param engine The engine which the post process will be applied. (default: current engine)
  71569. * @param reusable If the post process can be reused on the same frame. (default: false)
  71570. * @param textureType Type of textures used when performing the post process. (default: 0)
  71571. * @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)
  71572. */
  71573. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71574. /** @hidden */
  71575. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71576. }
  71577. }
  71578. declare module BABYLON {
  71579. /**
  71580. * PostProcessRenderPipeline
  71581. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71582. */
  71583. export class PostProcessRenderPipeline {
  71584. private engine;
  71585. private _renderEffects;
  71586. private _renderEffectsForIsolatedPass;
  71587. /**
  71588. * List of inspectable custom properties (used by the Inspector)
  71589. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71590. */
  71591. inspectableCustomProperties: IInspectable[];
  71592. /**
  71593. * @hidden
  71594. */
  71595. protected _cameras: Camera[];
  71596. /** @hidden */
  71597. _name: string;
  71598. /**
  71599. * Gets pipeline name
  71600. */
  71601. get name(): string;
  71602. /** Gets the list of attached cameras */
  71603. get cameras(): Camera[];
  71604. /**
  71605. * Initializes a PostProcessRenderPipeline
  71606. * @param engine engine to add the pipeline to
  71607. * @param name name of the pipeline
  71608. */
  71609. constructor(engine: Engine, name: string);
  71610. /**
  71611. * Gets the class name
  71612. * @returns "PostProcessRenderPipeline"
  71613. */
  71614. getClassName(): string;
  71615. /**
  71616. * If all the render effects in the pipeline are supported
  71617. */
  71618. get isSupported(): boolean;
  71619. /**
  71620. * Adds an effect to the pipeline
  71621. * @param renderEffect the effect to add
  71622. */
  71623. addEffect(renderEffect: PostProcessRenderEffect): void;
  71624. /** @hidden */
  71625. _rebuild(): void;
  71626. /** @hidden */
  71627. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71628. /** @hidden */
  71629. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71630. /** @hidden */
  71631. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71632. /** @hidden */
  71633. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71634. /** @hidden */
  71635. _attachCameras(cameras: Camera, unique: boolean): void;
  71636. /** @hidden */
  71637. _attachCameras(cameras: Camera[], unique: boolean): void;
  71638. /** @hidden */
  71639. _detachCameras(cameras: Camera): void;
  71640. /** @hidden */
  71641. _detachCameras(cameras: Nullable<Camera[]>): void;
  71642. /** @hidden */
  71643. _update(): void;
  71644. /** @hidden */
  71645. _reset(): void;
  71646. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71647. /**
  71648. * Sets the required values to the prepass renderer.
  71649. * @param prePassRenderer defines the prepass renderer to setup.
  71650. * @returns true if the pre pass is needed.
  71651. */
  71652. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71653. /**
  71654. * Disposes of the pipeline
  71655. */
  71656. dispose(): void;
  71657. }
  71658. }
  71659. declare module BABYLON {
  71660. /**
  71661. * PostProcessRenderPipelineManager class
  71662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71663. */
  71664. export class PostProcessRenderPipelineManager {
  71665. private _renderPipelines;
  71666. /**
  71667. * Initializes a PostProcessRenderPipelineManager
  71668. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71669. */
  71670. constructor();
  71671. /**
  71672. * Gets the list of supported render pipelines
  71673. */
  71674. get supportedPipelines(): PostProcessRenderPipeline[];
  71675. /**
  71676. * Adds a pipeline to the manager
  71677. * @param renderPipeline The pipeline to add
  71678. */
  71679. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71680. /**
  71681. * Attaches a camera to the pipeline
  71682. * @param renderPipelineName The name of the pipeline to attach to
  71683. * @param cameras the camera to attach
  71684. * @param unique if the camera can be attached multiple times to the pipeline
  71685. */
  71686. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71687. /**
  71688. * Detaches a camera from the pipeline
  71689. * @param renderPipelineName The name of the pipeline to detach from
  71690. * @param cameras the camera to detach
  71691. */
  71692. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71693. /**
  71694. * Enables an effect by name on a pipeline
  71695. * @param renderPipelineName the name of the pipeline to enable the effect in
  71696. * @param renderEffectName the name of the effect to enable
  71697. * @param cameras the cameras that the effect should be enabled on
  71698. */
  71699. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71700. /**
  71701. * Disables an effect by name on a pipeline
  71702. * @param renderPipelineName the name of the pipeline to disable the effect in
  71703. * @param renderEffectName the name of the effect to disable
  71704. * @param cameras the cameras that the effect should be disabled on
  71705. */
  71706. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71707. /**
  71708. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71709. */
  71710. update(): void;
  71711. /** @hidden */
  71712. _rebuild(): void;
  71713. /**
  71714. * Disposes of the manager and pipelines
  71715. */
  71716. dispose(): void;
  71717. }
  71718. }
  71719. declare module BABYLON {
  71720. interface Scene {
  71721. /** @hidden (Backing field) */
  71722. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71723. /**
  71724. * Gets the postprocess render pipeline manager
  71725. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71726. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71727. */
  71728. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71729. }
  71730. /**
  71731. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71732. */
  71733. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71734. /**
  71735. * The component name helpfull to identify the component in the list of scene components.
  71736. */
  71737. readonly name: string;
  71738. /**
  71739. * The scene the component belongs to.
  71740. */
  71741. scene: Scene;
  71742. /**
  71743. * Creates a new instance of the component for the given scene
  71744. * @param scene Defines the scene to register the component in
  71745. */
  71746. constructor(scene: Scene);
  71747. /**
  71748. * Registers the component in a given scene
  71749. */
  71750. register(): void;
  71751. /**
  71752. * Rebuilds the elements related to this component in case of
  71753. * context lost for instance.
  71754. */
  71755. rebuild(): void;
  71756. /**
  71757. * Disposes the component and the associated ressources
  71758. */
  71759. dispose(): void;
  71760. private _gatherRenderTargets;
  71761. }
  71762. }
  71763. declare module BABYLON {
  71764. /**
  71765. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71766. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71767. */
  71768. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71769. private _scene;
  71770. private _camerasToBeAttached;
  71771. /**
  71772. * ID of the sharpen post process,
  71773. */
  71774. private readonly SharpenPostProcessId;
  71775. /**
  71776. * @ignore
  71777. * ID of the image processing post process;
  71778. */
  71779. readonly ImageProcessingPostProcessId: string;
  71780. /**
  71781. * @ignore
  71782. * ID of the Fast Approximate Anti-Aliasing post process;
  71783. */
  71784. readonly FxaaPostProcessId: string;
  71785. /**
  71786. * ID of the chromatic aberration post process,
  71787. */
  71788. private readonly ChromaticAberrationPostProcessId;
  71789. /**
  71790. * ID of the grain post process
  71791. */
  71792. private readonly GrainPostProcessId;
  71793. /**
  71794. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71795. */
  71796. sharpen: SharpenPostProcess;
  71797. private _sharpenEffect;
  71798. private bloom;
  71799. /**
  71800. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71801. */
  71802. depthOfField: DepthOfFieldEffect;
  71803. /**
  71804. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71805. */
  71806. fxaa: FxaaPostProcess;
  71807. /**
  71808. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71809. */
  71810. imageProcessing: ImageProcessingPostProcess;
  71811. /**
  71812. * Chromatic aberration post process which will shift rgb colors in the image
  71813. */
  71814. chromaticAberration: ChromaticAberrationPostProcess;
  71815. private _chromaticAberrationEffect;
  71816. /**
  71817. * Grain post process which add noise to the image
  71818. */
  71819. grain: GrainPostProcess;
  71820. private _grainEffect;
  71821. /**
  71822. * Glow post process which adds a glow to emissive areas of the image
  71823. */
  71824. private _glowLayer;
  71825. /**
  71826. * Animations which can be used to tweak settings over a period of time
  71827. */
  71828. animations: Animation[];
  71829. private _imageProcessingConfigurationObserver;
  71830. private _sharpenEnabled;
  71831. private _bloomEnabled;
  71832. private _depthOfFieldEnabled;
  71833. private _depthOfFieldBlurLevel;
  71834. private _fxaaEnabled;
  71835. private _imageProcessingEnabled;
  71836. private _defaultPipelineTextureType;
  71837. private _bloomScale;
  71838. private _chromaticAberrationEnabled;
  71839. private _grainEnabled;
  71840. private _buildAllowed;
  71841. /**
  71842. * This is triggered each time the pipeline has been built.
  71843. */
  71844. onBuildObservable: Observable<DefaultRenderingPipeline>;
  71845. /**
  71846. * Gets active scene
  71847. */
  71848. get scene(): Scene;
  71849. /**
  71850. * Enable or disable the sharpen process from the pipeline
  71851. */
  71852. set sharpenEnabled(enabled: boolean);
  71853. get sharpenEnabled(): boolean;
  71854. private _resizeObserver;
  71855. private _hardwareScaleLevel;
  71856. private _bloomKernel;
  71857. /**
  71858. * Specifies the size of the bloom blur kernel, relative to the final output size
  71859. */
  71860. get bloomKernel(): number;
  71861. set bloomKernel(value: number);
  71862. /**
  71863. * Specifies the weight of the bloom in the final rendering
  71864. */
  71865. private _bloomWeight;
  71866. /**
  71867. * Specifies the luma threshold for the area that will be blurred by the bloom
  71868. */
  71869. private _bloomThreshold;
  71870. private _hdr;
  71871. /**
  71872. * The strength of the bloom.
  71873. */
  71874. set bloomWeight(value: number);
  71875. get bloomWeight(): number;
  71876. /**
  71877. * The strength of the bloom.
  71878. */
  71879. set bloomThreshold(value: number);
  71880. get bloomThreshold(): number;
  71881. /**
  71882. * The scale of the bloom, lower value will provide better performance.
  71883. */
  71884. set bloomScale(value: number);
  71885. get bloomScale(): number;
  71886. /**
  71887. * Enable or disable the bloom from the pipeline
  71888. */
  71889. set bloomEnabled(enabled: boolean);
  71890. get bloomEnabled(): boolean;
  71891. private _rebuildBloom;
  71892. /**
  71893. * If the depth of field is enabled.
  71894. */
  71895. get depthOfFieldEnabled(): boolean;
  71896. set depthOfFieldEnabled(enabled: boolean);
  71897. /**
  71898. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71899. */
  71900. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71901. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71902. /**
  71903. * If the anti aliasing is enabled.
  71904. */
  71905. set fxaaEnabled(enabled: boolean);
  71906. get fxaaEnabled(): boolean;
  71907. private _samples;
  71908. /**
  71909. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71910. */
  71911. set samples(sampleCount: number);
  71912. get samples(): number;
  71913. /**
  71914. * If image processing is enabled.
  71915. */
  71916. set imageProcessingEnabled(enabled: boolean);
  71917. get imageProcessingEnabled(): boolean;
  71918. /**
  71919. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71920. */
  71921. set glowLayerEnabled(enabled: boolean);
  71922. get glowLayerEnabled(): boolean;
  71923. /**
  71924. * Gets the glow layer (or null if not defined)
  71925. */
  71926. get glowLayer(): Nullable<GlowLayer>;
  71927. /**
  71928. * Enable or disable the chromaticAberration process from the pipeline
  71929. */
  71930. set chromaticAberrationEnabled(enabled: boolean);
  71931. get chromaticAberrationEnabled(): boolean;
  71932. /**
  71933. * Enable or disable the grain process from the pipeline
  71934. */
  71935. set grainEnabled(enabled: boolean);
  71936. get grainEnabled(): boolean;
  71937. /**
  71938. * @constructor
  71939. * @param name - The rendering pipeline name (default: "")
  71940. * @param hdr - If high dynamic range textures should be used (default: true)
  71941. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71942. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71943. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71944. */
  71945. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71946. /**
  71947. * Get the class name
  71948. * @returns "DefaultRenderingPipeline"
  71949. */
  71950. getClassName(): string;
  71951. /**
  71952. * Force the compilation of the entire pipeline.
  71953. */
  71954. prepare(): void;
  71955. private _hasCleared;
  71956. private _prevPostProcess;
  71957. private _prevPrevPostProcess;
  71958. private _setAutoClearAndTextureSharing;
  71959. private _depthOfFieldSceneObserver;
  71960. private _buildPipeline;
  71961. private _disposePostProcesses;
  71962. /**
  71963. * Adds a camera to the pipeline
  71964. * @param camera the camera to be added
  71965. */
  71966. addCamera(camera: Camera): void;
  71967. /**
  71968. * Removes a camera from the pipeline
  71969. * @param camera the camera to remove
  71970. */
  71971. removeCamera(camera: Camera): void;
  71972. /**
  71973. * Dispose of the pipeline and stop all post processes
  71974. */
  71975. dispose(): void;
  71976. /**
  71977. * Serialize the rendering pipeline (Used when exporting)
  71978. * @returns the serialized object
  71979. */
  71980. serialize(): any;
  71981. /**
  71982. * Parse the serialized pipeline
  71983. * @param source Source pipeline.
  71984. * @param scene The scene to load the pipeline to.
  71985. * @param rootUrl The URL of the serialized pipeline.
  71986. * @returns An instantiated pipeline from the serialized object.
  71987. */
  71988. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71989. }
  71990. }
  71991. declare module BABYLON {
  71992. /** @hidden */
  71993. export var lensHighlightsPixelShader: {
  71994. name: string;
  71995. shader: string;
  71996. };
  71997. }
  71998. declare module BABYLON {
  71999. /** @hidden */
  72000. export var depthOfFieldPixelShader: {
  72001. name: string;
  72002. shader: string;
  72003. };
  72004. }
  72005. declare module BABYLON {
  72006. /**
  72007. * BABYLON.JS Chromatic Aberration GLSL Shader
  72008. * Author: Olivier Guyot
  72009. * Separates very slightly R, G and B colors on the edges of the screen
  72010. * Inspired by Francois Tarlier & Martins Upitis
  72011. */
  72012. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72013. /**
  72014. * @ignore
  72015. * The chromatic aberration PostProcess id in the pipeline
  72016. */
  72017. LensChromaticAberrationEffect: string;
  72018. /**
  72019. * @ignore
  72020. * The highlights enhancing PostProcess id in the pipeline
  72021. */
  72022. HighlightsEnhancingEffect: string;
  72023. /**
  72024. * @ignore
  72025. * The depth-of-field PostProcess id in the pipeline
  72026. */
  72027. LensDepthOfFieldEffect: string;
  72028. private _scene;
  72029. private _depthTexture;
  72030. private _grainTexture;
  72031. private _chromaticAberrationPostProcess;
  72032. private _highlightsPostProcess;
  72033. private _depthOfFieldPostProcess;
  72034. private _edgeBlur;
  72035. private _grainAmount;
  72036. private _chromaticAberration;
  72037. private _distortion;
  72038. private _highlightsGain;
  72039. private _highlightsThreshold;
  72040. private _dofDistance;
  72041. private _dofAperture;
  72042. private _dofDarken;
  72043. private _dofPentagon;
  72044. private _blurNoise;
  72045. /**
  72046. * @constructor
  72047. *
  72048. * Effect parameters are as follow:
  72049. * {
  72050. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72051. * edge_blur: number; // from 0 to x (1 for realism)
  72052. * distortion: number; // from 0 to x (1 for realism)
  72053. * grain_amount: number; // from 0 to 1
  72054. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72055. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72056. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72057. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72058. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72059. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  72060. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  72061. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  72062. * }
  72063. * Note: if an effect parameter is unset, effect is disabled
  72064. *
  72065. * @param name The rendering pipeline name
  72066. * @param parameters - An object containing all parameters (see above)
  72067. * @param scene The scene linked to this pipeline
  72068. * @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)
  72069. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72070. */
  72071. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  72072. /**
  72073. * Get the class name
  72074. * @returns "LensRenderingPipeline"
  72075. */
  72076. getClassName(): string;
  72077. /**
  72078. * Gets associated scene
  72079. */
  72080. get scene(): Scene;
  72081. /**
  72082. * Gets or sets the edge blur
  72083. */
  72084. get edgeBlur(): number;
  72085. set edgeBlur(value: number);
  72086. /**
  72087. * Gets or sets the grain amount
  72088. */
  72089. get grainAmount(): number;
  72090. set grainAmount(value: number);
  72091. /**
  72092. * Gets or sets the chromatic aberration amount
  72093. */
  72094. get chromaticAberration(): number;
  72095. set chromaticAberration(value: number);
  72096. /**
  72097. * Gets or sets the depth of field aperture
  72098. */
  72099. get dofAperture(): number;
  72100. set dofAperture(value: number);
  72101. /**
  72102. * Gets or sets the edge distortion
  72103. */
  72104. get edgeDistortion(): number;
  72105. set edgeDistortion(value: number);
  72106. /**
  72107. * Gets or sets the depth of field distortion
  72108. */
  72109. get dofDistortion(): number;
  72110. set dofDistortion(value: number);
  72111. /**
  72112. * Gets or sets the darken out of focus amount
  72113. */
  72114. get darkenOutOfFocus(): number;
  72115. set darkenOutOfFocus(value: number);
  72116. /**
  72117. * Gets or sets a boolean indicating if blur noise is enabled
  72118. */
  72119. get blurNoise(): boolean;
  72120. set blurNoise(value: boolean);
  72121. /**
  72122. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  72123. */
  72124. get pentagonBokeh(): boolean;
  72125. set pentagonBokeh(value: boolean);
  72126. /**
  72127. * Gets or sets the highlight grain amount
  72128. */
  72129. get highlightsGain(): number;
  72130. set highlightsGain(value: number);
  72131. /**
  72132. * Gets or sets the highlight threshold
  72133. */
  72134. get highlightsThreshold(): number;
  72135. set highlightsThreshold(value: number);
  72136. /**
  72137. * Sets the amount of blur at the edges
  72138. * @param amount blur amount
  72139. */
  72140. setEdgeBlur(amount: number): void;
  72141. /**
  72142. * Sets edge blur to 0
  72143. */
  72144. disableEdgeBlur(): void;
  72145. /**
  72146. * Sets the amout of grain
  72147. * @param amount Amount of grain
  72148. */
  72149. setGrainAmount(amount: number): void;
  72150. /**
  72151. * Set grain amount to 0
  72152. */
  72153. disableGrain(): void;
  72154. /**
  72155. * Sets the chromatic aberration amount
  72156. * @param amount amount of chromatic aberration
  72157. */
  72158. setChromaticAberration(amount: number): void;
  72159. /**
  72160. * Sets chromatic aberration amount to 0
  72161. */
  72162. disableChromaticAberration(): void;
  72163. /**
  72164. * Sets the EdgeDistortion amount
  72165. * @param amount amount of EdgeDistortion
  72166. */
  72167. setEdgeDistortion(amount: number): void;
  72168. /**
  72169. * Sets edge distortion to 0
  72170. */
  72171. disableEdgeDistortion(): void;
  72172. /**
  72173. * Sets the FocusDistance amount
  72174. * @param amount amount of FocusDistance
  72175. */
  72176. setFocusDistance(amount: number): void;
  72177. /**
  72178. * Disables depth of field
  72179. */
  72180. disableDepthOfField(): void;
  72181. /**
  72182. * Sets the Aperture amount
  72183. * @param amount amount of Aperture
  72184. */
  72185. setAperture(amount: number): void;
  72186. /**
  72187. * Sets the DarkenOutOfFocus amount
  72188. * @param amount amount of DarkenOutOfFocus
  72189. */
  72190. setDarkenOutOfFocus(amount: number): void;
  72191. private _pentagonBokehIsEnabled;
  72192. /**
  72193. * Creates a pentagon bokeh effect
  72194. */
  72195. enablePentagonBokeh(): void;
  72196. /**
  72197. * Disables the pentagon bokeh effect
  72198. */
  72199. disablePentagonBokeh(): void;
  72200. /**
  72201. * Enables noise blur
  72202. */
  72203. enableNoiseBlur(): void;
  72204. /**
  72205. * Disables noise blur
  72206. */
  72207. disableNoiseBlur(): void;
  72208. /**
  72209. * Sets the HighlightsGain amount
  72210. * @param amount amount of HighlightsGain
  72211. */
  72212. setHighlightsGain(amount: number): void;
  72213. /**
  72214. * Sets the HighlightsThreshold amount
  72215. * @param amount amount of HighlightsThreshold
  72216. */
  72217. setHighlightsThreshold(amount: number): void;
  72218. /**
  72219. * Disables highlights
  72220. */
  72221. disableHighlights(): void;
  72222. /**
  72223. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72224. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72225. */
  72226. dispose(disableDepthRender?: boolean): void;
  72227. private _createChromaticAberrationPostProcess;
  72228. private _createHighlightsPostProcess;
  72229. private _createDepthOfFieldPostProcess;
  72230. private _createGrainTexture;
  72231. }
  72232. }
  72233. declare module BABYLON {
  72234. /**
  72235. * Contains all parameters needed for the prepass to perform
  72236. * screen space subsurface scattering
  72237. */
  72238. export class SSAO2Configuration implements PrePassEffectConfiguration {
  72239. /**
  72240. * Is subsurface enabled
  72241. */
  72242. enabled: boolean;
  72243. /**
  72244. * Name of the configuration
  72245. */
  72246. name: string;
  72247. /**
  72248. * Textures that should be present in the MRT for this effect to work
  72249. */
  72250. readonly texturesRequired: number[];
  72251. }
  72252. }
  72253. declare module BABYLON {
  72254. /** @hidden */
  72255. export var ssao2PixelShader: {
  72256. name: string;
  72257. shader: string;
  72258. };
  72259. }
  72260. declare module BABYLON {
  72261. /** @hidden */
  72262. export var ssaoCombinePixelShader: {
  72263. name: string;
  72264. shader: string;
  72265. };
  72266. }
  72267. declare module BABYLON {
  72268. /**
  72269. * Render pipeline to produce ssao effect
  72270. */
  72271. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72272. /**
  72273. * @ignore
  72274. * The PassPostProcess id in the pipeline that contains the original scene color
  72275. */
  72276. SSAOOriginalSceneColorEffect: string;
  72277. /**
  72278. * @ignore
  72279. * The SSAO PostProcess id in the pipeline
  72280. */
  72281. SSAORenderEffect: string;
  72282. /**
  72283. * @ignore
  72284. * The horizontal blur PostProcess id in the pipeline
  72285. */
  72286. SSAOBlurHRenderEffect: string;
  72287. /**
  72288. * @ignore
  72289. * The vertical blur PostProcess id in the pipeline
  72290. */
  72291. SSAOBlurVRenderEffect: string;
  72292. /**
  72293. * @ignore
  72294. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72295. */
  72296. SSAOCombineRenderEffect: string;
  72297. /**
  72298. * The output strength of the SSAO post-process. Default value is 1.0.
  72299. */
  72300. totalStrength: number;
  72301. /**
  72302. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72303. */
  72304. maxZ: number;
  72305. /**
  72306. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72307. */
  72308. minZAspect: number;
  72309. private _samples;
  72310. /**
  72311. * Number of samples used for the SSAO calculations. Default value is 8
  72312. */
  72313. set samples(n: number);
  72314. get samples(): number;
  72315. private _textureSamples;
  72316. /**
  72317. * Number of samples to use for antialiasing
  72318. */
  72319. set textureSamples(n: number);
  72320. get textureSamples(): number;
  72321. /**
  72322. * Force rendering the geometry through geometry buffer
  72323. */
  72324. private _forceGeometryBuffer;
  72325. /**
  72326. * Ratio object used for SSAO ratio and blur ratio
  72327. */
  72328. private _ratio;
  72329. /**
  72330. * Dynamically generated sphere sampler.
  72331. */
  72332. private _sampleSphere;
  72333. /**
  72334. * Blur filter offsets
  72335. */
  72336. private _samplerOffsets;
  72337. private _expensiveBlur;
  72338. /**
  72339. * If bilateral blur should be used
  72340. */
  72341. set expensiveBlur(b: boolean);
  72342. get expensiveBlur(): boolean;
  72343. /**
  72344. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72345. */
  72346. radius: number;
  72347. /**
  72348. * The base color of the SSAO post-process
  72349. * The final result is "base + ssao" between [0, 1]
  72350. */
  72351. base: number;
  72352. /**
  72353. * Support test.
  72354. */
  72355. static get IsSupported(): boolean;
  72356. private _scene;
  72357. private _randomTexture;
  72358. private _originalColorPostProcess;
  72359. private _ssaoPostProcess;
  72360. private _blurHPostProcess;
  72361. private _blurVPostProcess;
  72362. private _ssaoCombinePostProcess;
  72363. private _prePassRenderer;
  72364. /**
  72365. * Gets active scene
  72366. */
  72367. get scene(): Scene;
  72368. /**
  72369. * @constructor
  72370. * @param name The rendering pipeline name
  72371. * @param scene The scene linked to this pipeline
  72372. * @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 }
  72373. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72374. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  72375. */
  72376. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  72377. /**
  72378. * Get the class name
  72379. * @returns "SSAO2RenderingPipeline"
  72380. */
  72381. getClassName(): string;
  72382. /**
  72383. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72384. */
  72385. dispose(disableGeometryBufferRenderer?: boolean): void;
  72386. private _createBlurPostProcess;
  72387. /** @hidden */
  72388. _rebuild(): void;
  72389. private _bits;
  72390. private _radicalInverse_VdC;
  72391. private _hammersley;
  72392. private _hemisphereSample_uniform;
  72393. private _generateHemisphere;
  72394. private _getDefinesForSSAO;
  72395. private _createSSAOPostProcess;
  72396. private _createSSAOCombinePostProcess;
  72397. private _createRandomTexture;
  72398. /**
  72399. * Serialize the rendering pipeline (Used when exporting)
  72400. * @returns the serialized object
  72401. */
  72402. serialize(): any;
  72403. /**
  72404. * Parse the serialized pipeline
  72405. * @param source Source pipeline.
  72406. * @param scene The scene to load the pipeline to.
  72407. * @param rootUrl The URL of the serialized pipeline.
  72408. * @returns An instantiated pipeline from the serialized object.
  72409. */
  72410. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72411. }
  72412. }
  72413. declare module BABYLON {
  72414. /** @hidden */
  72415. export var ssaoPixelShader: {
  72416. name: string;
  72417. shader: string;
  72418. };
  72419. }
  72420. declare module BABYLON {
  72421. /**
  72422. * Render pipeline to produce ssao effect
  72423. */
  72424. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72425. /**
  72426. * @ignore
  72427. * The PassPostProcess id in the pipeline that contains the original scene color
  72428. */
  72429. SSAOOriginalSceneColorEffect: string;
  72430. /**
  72431. * @ignore
  72432. * The SSAO PostProcess id in the pipeline
  72433. */
  72434. SSAORenderEffect: string;
  72435. /**
  72436. * @ignore
  72437. * The horizontal blur PostProcess id in the pipeline
  72438. */
  72439. SSAOBlurHRenderEffect: string;
  72440. /**
  72441. * @ignore
  72442. * The vertical blur PostProcess id in the pipeline
  72443. */
  72444. SSAOBlurVRenderEffect: string;
  72445. /**
  72446. * @ignore
  72447. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72448. */
  72449. SSAOCombineRenderEffect: string;
  72450. /**
  72451. * The output strength of the SSAO post-process. Default value is 1.0.
  72452. */
  72453. totalStrength: number;
  72454. /**
  72455. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72456. */
  72457. radius: number;
  72458. /**
  72459. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72460. * Must not be equal to fallOff and superior to fallOff.
  72461. * Default value is 0.0075
  72462. */
  72463. area: number;
  72464. /**
  72465. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72466. * Must not be equal to area and inferior to area.
  72467. * Default value is 0.000001
  72468. */
  72469. fallOff: number;
  72470. /**
  72471. * The base color of the SSAO post-process
  72472. * The final result is "base + ssao" between [0, 1]
  72473. */
  72474. base: number;
  72475. private _scene;
  72476. private _depthTexture;
  72477. private _randomTexture;
  72478. private _originalColorPostProcess;
  72479. private _ssaoPostProcess;
  72480. private _blurHPostProcess;
  72481. private _blurVPostProcess;
  72482. private _ssaoCombinePostProcess;
  72483. private _firstUpdate;
  72484. /**
  72485. * Gets active scene
  72486. */
  72487. get scene(): Scene;
  72488. /**
  72489. * @constructor
  72490. * @param name - The rendering pipeline name
  72491. * @param scene - The scene linked to this pipeline
  72492. * @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 }
  72493. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72494. */
  72495. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72496. /**
  72497. * Get the class name
  72498. * @returns "SSAORenderingPipeline"
  72499. */
  72500. getClassName(): string;
  72501. /**
  72502. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72503. */
  72504. dispose(disableDepthRender?: boolean): void;
  72505. private _createBlurPostProcess;
  72506. /** @hidden */
  72507. _rebuild(): void;
  72508. private _createSSAOPostProcess;
  72509. private _createSSAOCombinePostProcess;
  72510. private _createRandomTexture;
  72511. }
  72512. }
  72513. declare module BABYLON {
  72514. /**
  72515. * Contains all parameters needed for the prepass to perform
  72516. * screen space reflections
  72517. */
  72518. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72519. /**
  72520. * Is ssr enabled
  72521. */
  72522. enabled: boolean;
  72523. /**
  72524. * Name of the configuration
  72525. */
  72526. name: string;
  72527. /**
  72528. * Textures that should be present in the MRT for this effect to work
  72529. */
  72530. readonly texturesRequired: number[];
  72531. }
  72532. }
  72533. declare module BABYLON {
  72534. /** @hidden */
  72535. export var screenSpaceReflectionPixelShader: {
  72536. name: string;
  72537. shader: string;
  72538. };
  72539. }
  72540. declare module BABYLON {
  72541. /**
  72542. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72543. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72544. */
  72545. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72546. /**
  72547. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72548. */
  72549. threshold: number;
  72550. /**
  72551. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72552. */
  72553. strength: number;
  72554. /**
  72555. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72556. */
  72557. reflectionSpecularFalloffExponent: number;
  72558. /**
  72559. * 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]
  72560. */
  72561. step: number;
  72562. /**
  72563. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72564. */
  72565. roughnessFactor: number;
  72566. private _forceGeometryBuffer;
  72567. private _geometryBufferRenderer;
  72568. private _prePassRenderer;
  72569. private _enableSmoothReflections;
  72570. private _reflectionSamples;
  72571. private _smoothSteps;
  72572. /**
  72573. * Gets a string identifying the name of the class
  72574. * @returns "ScreenSpaceReflectionPostProcess" string
  72575. */
  72576. getClassName(): string;
  72577. /**
  72578. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72579. * @param name The name of the effect.
  72580. * @param scene The scene containing the objects to calculate reflections.
  72581. * @param options The required width/height ratio to downsize to before computing the render pass.
  72582. * @param camera The camera to apply the render pass to.
  72583. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72584. * @param engine The engine which the post process will be applied. (default: current engine)
  72585. * @param reusable If the post process can be reused on the same frame. (default: false)
  72586. * @param textureType Type of textures used when performing the post process. (default: 0)
  72587. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)
  72588. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72589. */
  72590. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72591. /**
  72592. * Gets wether or not smoothing reflections is enabled.
  72593. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72594. */
  72595. get enableSmoothReflections(): boolean;
  72596. /**
  72597. * Sets wether or not smoothing reflections is enabled.
  72598. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72599. */
  72600. set enableSmoothReflections(enabled: boolean);
  72601. /**
  72602. * Gets the number of samples taken while computing reflections. More samples count is high,
  72603. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72604. */
  72605. get reflectionSamples(): number;
  72606. /**
  72607. * Sets the number of samples taken while computing reflections. More samples count is high,
  72608. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72609. */
  72610. set reflectionSamples(samples: number);
  72611. /**
  72612. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72613. * more the post-process will require GPU power and can generate a drop in FPS.
  72614. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72615. */
  72616. get smoothSteps(): number;
  72617. set smoothSteps(steps: number);
  72618. private _updateEffectDefines;
  72619. /** @hidden */
  72620. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72621. }
  72622. }
  72623. declare module BABYLON {
  72624. /** @hidden */
  72625. export var standardPixelShader: {
  72626. name: string;
  72627. shader: string;
  72628. };
  72629. }
  72630. declare module BABYLON {
  72631. /**
  72632. * Standard rendering pipeline
  72633. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72634. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72635. */
  72636. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72637. /**
  72638. * Public members
  72639. */
  72640. /**
  72641. * Post-process which contains the original scene color before the pipeline applies all the effects
  72642. */
  72643. originalPostProcess: Nullable<PostProcess>;
  72644. /**
  72645. * Post-process used to down scale an image x4
  72646. */
  72647. downSampleX4PostProcess: Nullable<PostProcess>;
  72648. /**
  72649. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72650. */
  72651. brightPassPostProcess: Nullable<PostProcess>;
  72652. /**
  72653. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72654. */
  72655. blurHPostProcesses: PostProcess[];
  72656. /**
  72657. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72658. */
  72659. blurVPostProcesses: PostProcess[];
  72660. /**
  72661. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72662. */
  72663. textureAdderPostProcess: Nullable<PostProcess>;
  72664. /**
  72665. * Post-process used to create volumetric lighting effect
  72666. */
  72667. volumetricLightPostProcess: Nullable<PostProcess>;
  72668. /**
  72669. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72670. */
  72671. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72672. /**
  72673. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72674. */
  72675. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72676. /**
  72677. * Post-process used to merge the volumetric light effect and the real scene color
  72678. */
  72679. volumetricLightMergePostProces: Nullable<PostProcess>;
  72680. /**
  72681. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72682. */
  72683. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72684. /**
  72685. * Base post-process used to calculate the average luminance of the final image for HDR
  72686. */
  72687. luminancePostProcess: Nullable<PostProcess>;
  72688. /**
  72689. * Post-processes used to create down sample post-processes in order to get
  72690. * the average luminance of the final image for HDR
  72691. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72692. */
  72693. luminanceDownSamplePostProcesses: PostProcess[];
  72694. /**
  72695. * Post-process used to create a HDR effect (light adaptation)
  72696. */
  72697. hdrPostProcess: Nullable<PostProcess>;
  72698. /**
  72699. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72700. */
  72701. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72702. /**
  72703. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72704. */
  72705. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72706. /**
  72707. * Post-process used to merge the final HDR post-process and the real scene color
  72708. */
  72709. hdrFinalPostProcess: Nullable<PostProcess>;
  72710. /**
  72711. * Post-process used to create a lens flare effect
  72712. */
  72713. lensFlarePostProcess: Nullable<PostProcess>;
  72714. /**
  72715. * Post-process that merges the result of the lens flare post-process and the real scene color
  72716. */
  72717. lensFlareComposePostProcess: Nullable<PostProcess>;
  72718. /**
  72719. * Post-process used to create a motion blur effect
  72720. */
  72721. motionBlurPostProcess: Nullable<PostProcess>;
  72722. /**
  72723. * Post-process used to create a depth of field effect
  72724. */
  72725. depthOfFieldPostProcess: Nullable<PostProcess>;
  72726. /**
  72727. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72728. */
  72729. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72730. /**
  72731. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72732. */
  72733. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72734. /**
  72735. * Represents the brightness threshold in order to configure the illuminated surfaces
  72736. */
  72737. brightThreshold: number;
  72738. /**
  72739. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72740. */
  72741. blurWidth: number;
  72742. /**
  72743. * Sets if the blur for highlighted surfaces must be only horizontal
  72744. */
  72745. horizontalBlur: boolean;
  72746. /**
  72747. * Gets the overall exposure used by the pipeline
  72748. */
  72749. get exposure(): number;
  72750. /**
  72751. * Sets the overall exposure used by the pipeline
  72752. */
  72753. set exposure(value: number);
  72754. /**
  72755. * Texture used typically to simulate "dirty" on camera lens
  72756. */
  72757. lensTexture: Nullable<Texture>;
  72758. /**
  72759. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72760. */
  72761. volumetricLightCoefficient: number;
  72762. /**
  72763. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72764. */
  72765. volumetricLightPower: number;
  72766. /**
  72767. * Used the set the blur intensity to smooth the volumetric lights
  72768. */
  72769. volumetricLightBlurScale: number;
  72770. /**
  72771. * Light (spot or directional) used to generate the volumetric lights rays
  72772. * The source light must have a shadow generate so the pipeline can get its
  72773. * depth map
  72774. */
  72775. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72776. /**
  72777. * For eye adaptation, represents the minimum luminance the eye can see
  72778. */
  72779. hdrMinimumLuminance: number;
  72780. /**
  72781. * For eye adaptation, represents the decrease luminance speed
  72782. */
  72783. hdrDecreaseRate: number;
  72784. /**
  72785. * For eye adaptation, represents the increase luminance speed
  72786. */
  72787. hdrIncreaseRate: number;
  72788. /**
  72789. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72790. */
  72791. get hdrAutoExposure(): boolean;
  72792. /**
  72793. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72794. */
  72795. set hdrAutoExposure(value: boolean);
  72796. /**
  72797. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72798. */
  72799. lensColorTexture: Nullable<Texture>;
  72800. /**
  72801. * The overall strengh for the lens flare effect
  72802. */
  72803. lensFlareStrength: number;
  72804. /**
  72805. * Dispersion coefficient for lens flare ghosts
  72806. */
  72807. lensFlareGhostDispersal: number;
  72808. /**
  72809. * Main lens flare halo width
  72810. */
  72811. lensFlareHaloWidth: number;
  72812. /**
  72813. * Based on the lens distortion effect, defines how much the lens flare result
  72814. * is distorted
  72815. */
  72816. lensFlareDistortionStrength: number;
  72817. /**
  72818. * Configures the blur intensity used for for lens flare (halo)
  72819. */
  72820. lensFlareBlurWidth: number;
  72821. /**
  72822. * Lens star texture must be used to simulate rays on the flares and is available
  72823. * in the documentation
  72824. */
  72825. lensStarTexture: Nullable<Texture>;
  72826. /**
  72827. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72828. * flare effect by taking account of the dirt texture
  72829. */
  72830. lensFlareDirtTexture: Nullable<Texture>;
  72831. /**
  72832. * Represents the focal length for the depth of field effect
  72833. */
  72834. depthOfFieldDistance: number;
  72835. /**
  72836. * Represents the blur intensity for the blurred part of the depth of field effect
  72837. */
  72838. depthOfFieldBlurWidth: number;
  72839. /**
  72840. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72841. */
  72842. get motionStrength(): number;
  72843. /**
  72844. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72845. */
  72846. set motionStrength(strength: number);
  72847. /**
  72848. * Gets wether or not the motion blur post-process is object based or screen based.
  72849. */
  72850. get objectBasedMotionBlur(): boolean;
  72851. /**
  72852. * Sets wether or not the motion blur post-process should be object based or screen based
  72853. */
  72854. set objectBasedMotionBlur(value: boolean);
  72855. /**
  72856. * List of animations for the pipeline (IAnimatable implementation)
  72857. */
  72858. animations: Animation[];
  72859. /**
  72860. * Private members
  72861. */
  72862. private _scene;
  72863. private _currentDepthOfFieldSource;
  72864. private _basePostProcess;
  72865. private _fixedExposure;
  72866. private _currentExposure;
  72867. private _hdrAutoExposure;
  72868. private _hdrCurrentLuminance;
  72869. private _motionStrength;
  72870. private _isObjectBasedMotionBlur;
  72871. private _floatTextureType;
  72872. private _camerasToBeAttached;
  72873. private _ratio;
  72874. private _bloomEnabled;
  72875. private _depthOfFieldEnabled;
  72876. private _vlsEnabled;
  72877. private _lensFlareEnabled;
  72878. private _hdrEnabled;
  72879. private _motionBlurEnabled;
  72880. private _fxaaEnabled;
  72881. private _screenSpaceReflectionsEnabled;
  72882. private _motionBlurSamples;
  72883. private _volumetricLightStepsCount;
  72884. private _samples;
  72885. /**
  72886. * @ignore
  72887. * Specifies if the bloom pipeline is enabled
  72888. */
  72889. get BloomEnabled(): boolean;
  72890. set BloomEnabled(enabled: boolean);
  72891. /**
  72892. * @ignore
  72893. * Specifies if the depth of field pipeline is enabed
  72894. */
  72895. get DepthOfFieldEnabled(): boolean;
  72896. set DepthOfFieldEnabled(enabled: boolean);
  72897. /**
  72898. * @ignore
  72899. * Specifies if the lens flare pipeline is enabed
  72900. */
  72901. get LensFlareEnabled(): boolean;
  72902. set LensFlareEnabled(enabled: boolean);
  72903. /**
  72904. * @ignore
  72905. * Specifies if the HDR pipeline is enabled
  72906. */
  72907. get HDREnabled(): boolean;
  72908. set HDREnabled(enabled: boolean);
  72909. /**
  72910. * @ignore
  72911. * Specifies if the volumetric lights scattering effect is enabled
  72912. */
  72913. get VLSEnabled(): boolean;
  72914. set VLSEnabled(enabled: boolean);
  72915. /**
  72916. * @ignore
  72917. * Specifies if the motion blur effect is enabled
  72918. */
  72919. get MotionBlurEnabled(): boolean;
  72920. set MotionBlurEnabled(enabled: boolean);
  72921. /**
  72922. * Specifies if anti-aliasing is enabled
  72923. */
  72924. get fxaaEnabled(): boolean;
  72925. set fxaaEnabled(enabled: boolean);
  72926. /**
  72927. * Specifies if screen space reflections are enabled.
  72928. */
  72929. get screenSpaceReflectionsEnabled(): boolean;
  72930. set screenSpaceReflectionsEnabled(enabled: boolean);
  72931. /**
  72932. * Specifies the number of steps used to calculate the volumetric lights
  72933. * Typically in interval [50, 200]
  72934. */
  72935. get volumetricLightStepsCount(): number;
  72936. set volumetricLightStepsCount(count: number);
  72937. /**
  72938. * Specifies the number of samples used for the motion blur effect
  72939. * Typically in interval [16, 64]
  72940. */
  72941. get motionBlurSamples(): number;
  72942. set motionBlurSamples(samples: number);
  72943. /**
  72944. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72945. */
  72946. get samples(): number;
  72947. set samples(sampleCount: number);
  72948. /**
  72949. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72950. * @constructor
  72951. * @param name The rendering pipeline name
  72952. * @param scene The scene linked to this pipeline
  72953. * @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)
  72954. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72955. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72956. */
  72957. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72958. private _buildPipeline;
  72959. private _createDownSampleX4PostProcess;
  72960. private _createBrightPassPostProcess;
  72961. private _createBlurPostProcesses;
  72962. private _createTextureAdderPostProcess;
  72963. private _createVolumetricLightPostProcess;
  72964. private _createLuminancePostProcesses;
  72965. private _createHdrPostProcess;
  72966. private _createLensFlarePostProcess;
  72967. private _createDepthOfFieldPostProcess;
  72968. private _createMotionBlurPostProcess;
  72969. private _getDepthTexture;
  72970. private _disposePostProcesses;
  72971. /**
  72972. * Dispose of the pipeline and stop all post processes
  72973. */
  72974. dispose(): void;
  72975. /**
  72976. * Serialize the rendering pipeline (Used when exporting)
  72977. * @returns the serialized object
  72978. */
  72979. serialize(): any;
  72980. /**
  72981. * Parse the serialized pipeline
  72982. * @param source Source pipeline.
  72983. * @param scene The scene to load the pipeline to.
  72984. * @param rootUrl The URL of the serialized pipeline.
  72985. * @returns An instantiated pipeline from the serialized object.
  72986. */
  72987. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72988. /**
  72989. * Luminance steps
  72990. */
  72991. static LuminanceSteps: number;
  72992. }
  72993. }
  72994. declare module BABYLON {
  72995. /** @hidden */
  72996. export var stereoscopicInterlacePixelShader: {
  72997. name: string;
  72998. shader: string;
  72999. };
  73000. }
  73001. declare module BABYLON {
  73002. /**
  73003. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  73004. */
  73005. export class StereoscopicInterlacePostProcessI extends PostProcess {
  73006. private _stepSize;
  73007. private _passedProcess;
  73008. /**
  73009. * Gets a string identifying the name of the class
  73010. * @returns "StereoscopicInterlacePostProcessI" string
  73011. */
  73012. getClassName(): string;
  73013. /**
  73014. * Initializes a StereoscopicInterlacePostProcessI
  73015. * @param name The name of the effect.
  73016. * @param rigCameras The rig cameras to be appled to the post process
  73017. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73018. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73020. * @param engine The engine which the post process will be applied. (default: current engine)
  73021. * @param reusable If the post process can be reused on the same frame. (default: false)
  73022. */
  73023. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73024. }
  73025. /**
  73026. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73027. */
  73028. export class StereoscopicInterlacePostProcess extends PostProcess {
  73029. private _stepSize;
  73030. private _passedProcess;
  73031. /**
  73032. * Gets a string identifying the name of the class
  73033. * @returns "StereoscopicInterlacePostProcess" string
  73034. */
  73035. getClassName(): string;
  73036. /**
  73037. * Initializes a StereoscopicInterlacePostProcess
  73038. * @param name The name of the effect.
  73039. * @param rigCameras The rig cameras to be appled to the post process
  73040. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73042. * @param engine The engine which the post process will be applied. (default: current engine)
  73043. * @param reusable If the post process can be reused on the same frame. (default: false)
  73044. */
  73045. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73046. }
  73047. }
  73048. declare module BABYLON {
  73049. /** @hidden */
  73050. export var tonemapPixelShader: {
  73051. name: string;
  73052. shader: string;
  73053. };
  73054. }
  73055. declare module BABYLON {
  73056. /** Defines operator used for tonemapping */
  73057. export enum TonemappingOperator {
  73058. /** Hable */
  73059. Hable = 0,
  73060. /** Reinhard */
  73061. Reinhard = 1,
  73062. /** HejiDawson */
  73063. HejiDawson = 2,
  73064. /** Photographic */
  73065. Photographic = 3
  73066. }
  73067. /**
  73068. * Defines a post process to apply tone mapping
  73069. */
  73070. export class TonemapPostProcess extends PostProcess {
  73071. private _operator;
  73072. /** Defines the required exposure adjustement */
  73073. exposureAdjustment: number;
  73074. /**
  73075. * Gets a string identifying the name of the class
  73076. * @returns "TonemapPostProcess" string
  73077. */
  73078. getClassName(): string;
  73079. /**
  73080. * Creates a new TonemapPostProcess
  73081. * @param name defines the name of the postprocess
  73082. * @param _operator defines the operator to use
  73083. * @param exposureAdjustment defines the required exposure adjustement
  73084. * @param camera defines the camera to use (can be null)
  73085. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  73086. * @param engine defines the hosting engine (can be ignore if camera is set)
  73087. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  73088. */
  73089. constructor(name: string, _operator: TonemappingOperator,
  73090. /** Defines the required exposure adjustement */
  73091. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  73092. }
  73093. }
  73094. declare module BABYLON {
  73095. /** @hidden */
  73096. export var volumetricLightScatteringPixelShader: {
  73097. name: string;
  73098. shader: string;
  73099. };
  73100. }
  73101. declare module BABYLON {
  73102. /** @hidden */
  73103. export var volumetricLightScatteringPassVertexShader: {
  73104. name: string;
  73105. shader: string;
  73106. };
  73107. }
  73108. declare module BABYLON {
  73109. /** @hidden */
  73110. export var volumetricLightScatteringPassPixelShader: {
  73111. name: string;
  73112. shader: string;
  73113. };
  73114. }
  73115. declare module BABYLON {
  73116. /**
  73117. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  73118. */
  73119. export class VolumetricLightScatteringPostProcess extends PostProcess {
  73120. private _volumetricLightScatteringPass;
  73121. private _volumetricLightScatteringRTT;
  73122. private _viewPort;
  73123. private _screenCoordinates;
  73124. private _cachedDefines;
  73125. /**
  73126. * If not undefined, the mesh position is computed from the attached node position
  73127. */
  73128. attachedNode: {
  73129. position: Vector3;
  73130. };
  73131. /**
  73132. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  73133. */
  73134. customMeshPosition: Vector3;
  73135. /**
  73136. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  73137. */
  73138. useCustomMeshPosition: boolean;
  73139. /**
  73140. * If the post-process should inverse the light scattering direction
  73141. */
  73142. invert: boolean;
  73143. /**
  73144. * The internal mesh used by the post-process
  73145. */
  73146. mesh: Mesh;
  73147. /**
  73148. * @hidden
  73149. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73150. */
  73151. get useDiffuseColor(): boolean;
  73152. set useDiffuseColor(useDiffuseColor: boolean);
  73153. /**
  73154. * Array containing the excluded meshes not rendered in the internal pass
  73155. */
  73156. excludedMeshes: AbstractMesh[];
  73157. /**
  73158. * Controls the overall intensity of the post-process
  73159. */
  73160. exposure: number;
  73161. /**
  73162. * Dissipates each sample's contribution in range [0, 1]
  73163. */
  73164. decay: number;
  73165. /**
  73166. * Controls the overall intensity of each sample
  73167. */
  73168. weight: number;
  73169. /**
  73170. * Controls the density of each sample
  73171. */
  73172. density: number;
  73173. /**
  73174. * @constructor
  73175. * @param name The post-process name
  73176. * @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)
  73177. * @param camera The camera that the post-process will be attached to
  73178. * @param mesh The mesh used to create the light scattering
  73179. * @param samples The post-process quality, default 100
  73180. * @param samplingModeThe post-process filtering mode
  73181. * @param engine The babylon engine
  73182. * @param reusable If the post-process is reusable
  73183. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73184. */
  73185. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73186. /**
  73187. * Returns the string "VolumetricLightScatteringPostProcess"
  73188. * @returns "VolumetricLightScatteringPostProcess"
  73189. */
  73190. getClassName(): string;
  73191. private _isReady;
  73192. /**
  73193. * Sets the new light position for light scattering effect
  73194. * @param position The new custom light position
  73195. */
  73196. setCustomMeshPosition(position: Vector3): void;
  73197. /**
  73198. * Returns the light position for light scattering effect
  73199. * @return Vector3 The custom light position
  73200. */
  73201. getCustomMeshPosition(): Vector3;
  73202. /**
  73203. * Disposes the internal assets and detaches the post-process from the camera
  73204. */
  73205. dispose(camera: Camera): void;
  73206. /**
  73207. * Returns the render target texture used by the post-process
  73208. * @return the render target texture used by the post-process
  73209. */
  73210. getPass(): RenderTargetTexture;
  73211. private _meshExcluded;
  73212. private _createPass;
  73213. private _updateMeshScreenCoordinates;
  73214. /**
  73215. * Creates a default mesh for the Volumeric Light Scattering post-process
  73216. * @param name The mesh name
  73217. * @param scene The scene where to create the mesh
  73218. * @return the default mesh
  73219. */
  73220. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73221. }
  73222. }
  73223. declare module BABYLON {
  73224. /** @hidden */
  73225. export var screenSpaceCurvaturePixelShader: {
  73226. name: string;
  73227. shader: string;
  73228. };
  73229. }
  73230. declare module BABYLON {
  73231. /**
  73232. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  73233. */
  73234. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  73235. /**
  73236. * Defines how much ridge the curvature effect displays.
  73237. */
  73238. ridge: number;
  73239. /**
  73240. * Defines how much valley the curvature effect displays.
  73241. */
  73242. valley: number;
  73243. private _geometryBufferRenderer;
  73244. /**
  73245. * Gets a string identifying the name of the class
  73246. * @returns "ScreenSpaceCurvaturePostProcess" string
  73247. */
  73248. getClassName(): string;
  73249. /**
  73250. * Creates a new instance ScreenSpaceCurvaturePostProcess
  73251. * @param name The name of the effect.
  73252. * @param scene The scene containing the objects to blur according to their velocity.
  73253. * @param options The required width/height ratio to downsize to before computing the render pass.
  73254. * @param camera The camera to apply the render pass to.
  73255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73256. * @param engine The engine which the post process will be applied. (default: current engine)
  73257. * @param reusable If the post process can be reused on the same frame. (default: false)
  73258. * @param textureType Type of textures used when performing the post process. (default: 0)
  73259. * @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)
  73260. */
  73261. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73262. /**
  73263. * Support test.
  73264. */
  73265. static get IsSupported(): boolean;
  73266. /** @hidden */
  73267. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  73268. }
  73269. }
  73270. declare module BABYLON {
  73271. interface Scene {
  73272. /** @hidden (Backing field) */
  73273. _boundingBoxRenderer: BoundingBoxRenderer;
  73274. /** @hidden (Backing field) */
  73275. _forceShowBoundingBoxes: boolean;
  73276. /**
  73277. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73278. */
  73279. forceShowBoundingBoxes: boolean;
  73280. /**
  73281. * Gets the bounding box renderer associated with the scene
  73282. * @returns a BoundingBoxRenderer
  73283. */
  73284. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73285. }
  73286. interface AbstractMesh {
  73287. /** @hidden (Backing field) */
  73288. _showBoundingBox: boolean;
  73289. /**
  73290. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73291. */
  73292. showBoundingBox: boolean;
  73293. }
  73294. /**
  73295. * Component responsible of rendering the bounding box of the meshes in a scene.
  73296. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73297. */
  73298. export class BoundingBoxRenderer implements ISceneComponent {
  73299. /**
  73300. * The component name helpfull to identify the component in the list of scene components.
  73301. */
  73302. readonly name: string;
  73303. /**
  73304. * The scene the component belongs to.
  73305. */
  73306. scene: Scene;
  73307. /**
  73308. * Color of the bounding box lines placed in front of an object
  73309. */
  73310. frontColor: Color3;
  73311. /**
  73312. * Color of the bounding box lines placed behind an object
  73313. */
  73314. backColor: Color3;
  73315. /**
  73316. * Defines if the renderer should show the back lines or not
  73317. */
  73318. showBackLines: boolean;
  73319. /**
  73320. * Observable raised before rendering a bounding box
  73321. */
  73322. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73323. /**
  73324. * Observable raised after rendering a bounding box
  73325. */
  73326. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73327. /**
  73328. * Observable raised after resources are created
  73329. */
  73330. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  73331. /**
  73332. * When false, no bounding boxes will be rendered
  73333. */
  73334. enabled: boolean;
  73335. /**
  73336. * @hidden
  73337. */
  73338. renderList: SmartArray<BoundingBox>;
  73339. private _colorShader;
  73340. private _vertexBuffers;
  73341. private _indexBuffer;
  73342. private _fillIndexBuffer;
  73343. private _fillIndexData;
  73344. /**
  73345. * Instantiates a new bounding box renderer in a scene.
  73346. * @param scene the scene the renderer renders in
  73347. */
  73348. constructor(scene: Scene);
  73349. /**
  73350. * Registers the component in a given scene
  73351. */
  73352. register(): void;
  73353. private _evaluateSubMesh;
  73354. private _preActiveMesh;
  73355. private _prepareResources;
  73356. private _createIndexBuffer;
  73357. /**
  73358. * Rebuilds the elements related to this component in case of
  73359. * context lost for instance.
  73360. */
  73361. rebuild(): void;
  73362. /**
  73363. * @hidden
  73364. */
  73365. reset(): void;
  73366. /**
  73367. * Render the bounding boxes of a specific rendering group
  73368. * @param renderingGroupId defines the rendering group to render
  73369. */
  73370. render(renderingGroupId: number): void;
  73371. /**
  73372. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73373. * @param mesh Define the mesh to render the occlusion bounding box for
  73374. */
  73375. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73376. /**
  73377. * Dispose and release the resources attached to this renderer.
  73378. */
  73379. dispose(): void;
  73380. }
  73381. }
  73382. declare module BABYLON {
  73383. interface Scene {
  73384. /** @hidden (Backing field) */
  73385. _depthRenderer: {
  73386. [id: string]: DepthRenderer;
  73387. };
  73388. /**
  73389. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73390. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73391. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73392. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  73393. * @returns the created depth renderer
  73394. */
  73395. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  73396. /**
  73397. * Disables a depth renderer for a given camera
  73398. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73399. */
  73400. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73401. }
  73402. /**
  73403. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73404. * in several rendering techniques.
  73405. */
  73406. export class DepthRendererSceneComponent implements ISceneComponent {
  73407. /**
  73408. * The component name helpfull to identify the component in the list of scene components.
  73409. */
  73410. readonly name: string;
  73411. /**
  73412. * The scene the component belongs to.
  73413. */
  73414. scene: Scene;
  73415. /**
  73416. * Creates a new instance of the component for the given scene
  73417. * @param scene Defines the scene to register the component in
  73418. */
  73419. constructor(scene: Scene);
  73420. /**
  73421. * Registers the component in a given scene
  73422. */
  73423. register(): void;
  73424. /**
  73425. * Rebuilds the elements related to this component in case of
  73426. * context lost for instance.
  73427. */
  73428. rebuild(): void;
  73429. /**
  73430. * Disposes the component and the associated ressources
  73431. */
  73432. dispose(): void;
  73433. private _gatherRenderTargets;
  73434. private _gatherActiveCameraRenderTargets;
  73435. }
  73436. }
  73437. declare module BABYLON {
  73438. interface AbstractScene {
  73439. /** @hidden (Backing field) */
  73440. _prePassRenderer: Nullable<PrePassRenderer>;
  73441. /**
  73442. * Gets or Sets the current prepass renderer associated to the scene.
  73443. */
  73444. prePassRenderer: Nullable<PrePassRenderer>;
  73445. /**
  73446. * Enables the prepass and associates it with the scene
  73447. * @returns the PrePassRenderer
  73448. */
  73449. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73450. /**
  73451. * Disables the prepass associated with the scene
  73452. */
  73453. disablePrePassRenderer(): void;
  73454. }
  73455. /**
  73456. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73457. * in several rendering techniques.
  73458. */
  73459. export class PrePassRendererSceneComponent implements ISceneComponent {
  73460. /**
  73461. * The component name helpful to identify the component in the list of scene components.
  73462. */
  73463. readonly name: string;
  73464. /**
  73465. * The scene the component belongs to.
  73466. */
  73467. scene: Scene;
  73468. /**
  73469. * Creates a new instance of the component for the given scene
  73470. * @param scene Defines the scene to register the component in
  73471. */
  73472. constructor(scene: Scene);
  73473. /**
  73474. * Registers the component in a given scene
  73475. */
  73476. register(): void;
  73477. private _beforeCameraDraw;
  73478. private _afterCameraDraw;
  73479. private _beforeClearStage;
  73480. private _beforeRenderingMeshStage;
  73481. private _afterRenderingMeshStage;
  73482. /**
  73483. * Rebuilds the elements related to this component in case of
  73484. * context lost for instance.
  73485. */
  73486. rebuild(): void;
  73487. /**
  73488. * Disposes the component and the associated ressources
  73489. */
  73490. dispose(): void;
  73491. }
  73492. }
  73493. declare module BABYLON {
  73494. /** @hidden */
  73495. export var fibonacci: {
  73496. name: string;
  73497. shader: string;
  73498. };
  73499. }
  73500. declare module BABYLON {
  73501. /** @hidden */
  73502. export var diffusionProfile: {
  73503. name: string;
  73504. shader: string;
  73505. };
  73506. }
  73507. declare module BABYLON {
  73508. /** @hidden */
  73509. export var subSurfaceScatteringPixelShader: {
  73510. name: string;
  73511. shader: string;
  73512. };
  73513. }
  73514. declare module BABYLON {
  73515. /**
  73516. * Sub surface scattering post process
  73517. */
  73518. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73519. /**
  73520. * Gets a string identifying the name of the class
  73521. * @returns "SubSurfaceScatteringPostProcess" string
  73522. */
  73523. getClassName(): string;
  73524. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73525. }
  73526. }
  73527. declare module BABYLON {
  73528. /**
  73529. * Contains all parameters needed for the prepass to perform
  73530. * screen space subsurface scattering
  73531. */
  73532. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73533. /** @hidden */
  73534. static _SceneComponentInitialization: (scene: Scene) => void;
  73535. private _ssDiffusionS;
  73536. private _ssFilterRadii;
  73537. private _ssDiffusionD;
  73538. /**
  73539. * Post process to attach for screen space subsurface scattering
  73540. */
  73541. postProcess: SubSurfaceScatteringPostProcess;
  73542. /**
  73543. * Diffusion profile color for subsurface scattering
  73544. */
  73545. get ssDiffusionS(): number[];
  73546. /**
  73547. * Diffusion profile max color channel value for subsurface scattering
  73548. */
  73549. get ssDiffusionD(): number[];
  73550. /**
  73551. * Diffusion profile filter radius for subsurface scattering
  73552. */
  73553. get ssFilterRadii(): number[];
  73554. /**
  73555. * Is subsurface enabled
  73556. */
  73557. enabled: boolean;
  73558. /**
  73559. * Name of the configuration
  73560. */
  73561. name: string;
  73562. /**
  73563. * Diffusion profile colors for subsurface scattering
  73564. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73565. * See ...
  73566. * Note that you can only store up to 5 of them
  73567. */
  73568. ssDiffusionProfileColors: Color3[];
  73569. /**
  73570. * Defines the ratio real world => scene units.
  73571. * Used for subsurface scattering
  73572. */
  73573. metersPerUnit: number;
  73574. /**
  73575. * Textures that should be present in the MRT for this effect to work
  73576. */
  73577. readonly texturesRequired: number[];
  73578. private _scene;
  73579. /**
  73580. * Builds a subsurface configuration object
  73581. * @param scene The scene
  73582. */
  73583. constructor(scene: Scene);
  73584. /**
  73585. * Adds a new diffusion profile.
  73586. * Useful for more realistic subsurface scattering on diverse materials.
  73587. * @param color The color of the diffusion profile. Should be the average color of the material.
  73588. * @return The index of the diffusion profile for the material subsurface configuration
  73589. */
  73590. addDiffusionProfile(color: Color3): number;
  73591. /**
  73592. * Creates the sss post process
  73593. * @return The created post process
  73594. */
  73595. createPostProcess(): SubSurfaceScatteringPostProcess;
  73596. /**
  73597. * Deletes all diffusion profiles.
  73598. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73599. */
  73600. clearAllDiffusionProfiles(): void;
  73601. /**
  73602. * Disposes this object
  73603. */
  73604. dispose(): void;
  73605. /**
  73606. * @hidden
  73607. * https://zero-radiance.github.io/post/sampling-diffusion/
  73608. *
  73609. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73610. * ------------------------------------------------------------------------------------
  73611. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73612. * PDF[r, phi, s] = r * R[r, phi, s]
  73613. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73614. * ------------------------------------------------------------------------------------
  73615. * We importance sample the color channel with the widest scattering distance.
  73616. */
  73617. getDiffusionProfileParameters(color: Color3): number;
  73618. /**
  73619. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73620. * 'u' is the random number (the value of the CDF): [0, 1).
  73621. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73622. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73623. */
  73624. private _sampleBurleyDiffusionProfile;
  73625. }
  73626. }
  73627. declare module BABYLON {
  73628. interface AbstractScene {
  73629. /** @hidden (Backing field) */
  73630. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73631. /**
  73632. * Gets or Sets the current prepass renderer associated to the scene.
  73633. */
  73634. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73635. /**
  73636. * Enables the subsurface effect for prepass
  73637. * @returns the SubSurfaceConfiguration
  73638. */
  73639. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73640. /**
  73641. * Disables the subsurface effect for prepass
  73642. */
  73643. disableSubSurfaceForPrePass(): void;
  73644. }
  73645. /**
  73646. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73647. * in several rendering techniques.
  73648. */
  73649. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73650. /**
  73651. * The component name helpful to identify the component in the list of scene components.
  73652. */
  73653. readonly name: string;
  73654. /**
  73655. * The scene the component belongs to.
  73656. */
  73657. scene: Scene;
  73658. /**
  73659. * Creates a new instance of the component for the given scene
  73660. * @param scene Defines the scene to register the component in
  73661. */
  73662. constructor(scene: Scene);
  73663. /**
  73664. * Registers the component in a given scene
  73665. */
  73666. register(): void;
  73667. /**
  73668. * Serializes the component data to the specified json object
  73669. * @param serializationObject The object to serialize to
  73670. */
  73671. serialize(serializationObject: any): void;
  73672. /**
  73673. * Adds all the elements from the container to the scene
  73674. * @param container the container holding the elements
  73675. */
  73676. addFromContainer(container: AbstractScene): void;
  73677. /**
  73678. * Removes all the elements in the container from the scene
  73679. * @param container contains the elements to remove
  73680. * @param dispose if the removed element should be disposed (default: false)
  73681. */
  73682. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73683. /**
  73684. * Rebuilds the elements related to this component in case of
  73685. * context lost for instance.
  73686. */
  73687. rebuild(): void;
  73688. /**
  73689. * Disposes the component and the associated ressources
  73690. */
  73691. dispose(): void;
  73692. }
  73693. }
  73694. declare module BABYLON {
  73695. /** @hidden */
  73696. export var outlinePixelShader: {
  73697. name: string;
  73698. shader: string;
  73699. };
  73700. }
  73701. declare module BABYLON {
  73702. /** @hidden */
  73703. export var outlineVertexShader: {
  73704. name: string;
  73705. shader: string;
  73706. };
  73707. }
  73708. declare module BABYLON {
  73709. interface Scene {
  73710. /** @hidden */
  73711. _outlineRenderer: OutlineRenderer;
  73712. /**
  73713. * Gets the outline renderer associated with the scene
  73714. * @returns a OutlineRenderer
  73715. */
  73716. getOutlineRenderer(): OutlineRenderer;
  73717. }
  73718. interface AbstractMesh {
  73719. /** @hidden (Backing field) */
  73720. _renderOutline: boolean;
  73721. /**
  73722. * Gets or sets a boolean indicating if the outline must be rendered as well
  73723. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73724. */
  73725. renderOutline: boolean;
  73726. /** @hidden (Backing field) */
  73727. _renderOverlay: boolean;
  73728. /**
  73729. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73730. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73731. */
  73732. renderOverlay: boolean;
  73733. }
  73734. /**
  73735. * This class is responsible to draw bothe outline/overlay of meshes.
  73736. * It should not be used directly but through the available method on mesh.
  73737. */
  73738. export class OutlineRenderer implements ISceneComponent {
  73739. /**
  73740. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73741. */
  73742. private static _StencilReference;
  73743. /**
  73744. * The name of the component. Each component must have a unique name.
  73745. */
  73746. name: string;
  73747. /**
  73748. * The scene the component belongs to.
  73749. */
  73750. scene: Scene;
  73751. /**
  73752. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73753. */
  73754. zOffset: number;
  73755. private _engine;
  73756. private _effect;
  73757. private _cachedDefines;
  73758. private _savedDepthWrite;
  73759. /**
  73760. * Instantiates a new outline renderer. (There could be only one per scene).
  73761. * @param scene Defines the scene it belongs to
  73762. */
  73763. constructor(scene: Scene);
  73764. /**
  73765. * Register the component to one instance of a scene.
  73766. */
  73767. register(): void;
  73768. /**
  73769. * Rebuilds the elements related to this component in case of
  73770. * context lost for instance.
  73771. */
  73772. rebuild(): void;
  73773. /**
  73774. * Disposes the component and the associated ressources.
  73775. */
  73776. dispose(): void;
  73777. /**
  73778. * Renders the outline in the canvas.
  73779. * @param subMesh Defines the sumesh to render
  73780. * @param batch Defines the batch of meshes in case of instances
  73781. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73782. */
  73783. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73784. /**
  73785. * Returns whether or not the outline renderer is ready for a given submesh.
  73786. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73787. * @param subMesh Defines the submesh to check readyness for
  73788. * @param useInstances Defines wheter wee are trying to render instances or not
  73789. * @returns true if ready otherwise false
  73790. */
  73791. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73792. private _beforeRenderingMesh;
  73793. private _afterRenderingMesh;
  73794. }
  73795. }
  73796. declare module BABYLON {
  73797. /**
  73798. * Defines the basic options interface of a Sprite Frame Source Size.
  73799. */
  73800. export interface ISpriteJSONSpriteSourceSize {
  73801. /**
  73802. * number of the original width of the Frame
  73803. */
  73804. w: number;
  73805. /**
  73806. * number of the original height of the Frame
  73807. */
  73808. h: number;
  73809. }
  73810. /**
  73811. * Defines the basic options interface of a Sprite Frame Data.
  73812. */
  73813. export interface ISpriteJSONSpriteFrameData {
  73814. /**
  73815. * number of the x offset of the Frame
  73816. */
  73817. x: number;
  73818. /**
  73819. * number of the y offset of the Frame
  73820. */
  73821. y: number;
  73822. /**
  73823. * number of the width of the Frame
  73824. */
  73825. w: number;
  73826. /**
  73827. * number of the height of the Frame
  73828. */
  73829. h: number;
  73830. }
  73831. /**
  73832. * Defines the basic options interface of a JSON Sprite.
  73833. */
  73834. export interface ISpriteJSONSprite {
  73835. /**
  73836. * string name of the Frame
  73837. */
  73838. filename: string;
  73839. /**
  73840. * ISpriteJSONSpriteFrame basic object of the frame data
  73841. */
  73842. frame: ISpriteJSONSpriteFrameData;
  73843. /**
  73844. * boolean to flag is the frame was rotated.
  73845. */
  73846. rotated: boolean;
  73847. /**
  73848. * boolean to flag is the frame was trimmed.
  73849. */
  73850. trimmed: boolean;
  73851. /**
  73852. * ISpriteJSONSpriteFrame basic object of the source data
  73853. */
  73854. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73855. /**
  73856. * ISpriteJSONSpriteFrame basic object of the source data
  73857. */
  73858. sourceSize: ISpriteJSONSpriteSourceSize;
  73859. }
  73860. /**
  73861. * Defines the basic options interface of a JSON atlas.
  73862. */
  73863. export interface ISpriteJSONAtlas {
  73864. /**
  73865. * Array of objects that contain the frame data.
  73866. */
  73867. frames: Array<ISpriteJSONSprite>;
  73868. /**
  73869. * object basic object containing the sprite meta data.
  73870. */
  73871. meta?: object;
  73872. }
  73873. }
  73874. declare module BABYLON {
  73875. /** @hidden */
  73876. export var spriteMapPixelShader: {
  73877. name: string;
  73878. shader: string;
  73879. };
  73880. }
  73881. declare module BABYLON {
  73882. /** @hidden */
  73883. export var spriteMapVertexShader: {
  73884. name: string;
  73885. shader: string;
  73886. };
  73887. }
  73888. declare module BABYLON {
  73889. /**
  73890. * Defines the basic options interface of a SpriteMap
  73891. */
  73892. export interface ISpriteMapOptions {
  73893. /**
  73894. * Vector2 of the number of cells in the grid.
  73895. */
  73896. stageSize?: Vector2;
  73897. /**
  73898. * Vector2 of the size of the output plane in World Units.
  73899. */
  73900. outputSize?: Vector2;
  73901. /**
  73902. * Vector3 of the position of the output plane in World Units.
  73903. */
  73904. outputPosition?: Vector3;
  73905. /**
  73906. * Vector3 of the rotation of the output plane.
  73907. */
  73908. outputRotation?: Vector3;
  73909. /**
  73910. * number of layers that the system will reserve in resources.
  73911. */
  73912. layerCount?: number;
  73913. /**
  73914. * number of max animation frames a single cell will reserve in resources.
  73915. */
  73916. maxAnimationFrames?: number;
  73917. /**
  73918. * number cell index of the base tile when the system compiles.
  73919. */
  73920. baseTile?: number;
  73921. /**
  73922. * boolean flip the sprite after its been repositioned by the framing data.
  73923. */
  73924. flipU?: boolean;
  73925. /**
  73926. * Vector3 scalar of the global RGB values of the SpriteMap.
  73927. */
  73928. colorMultiply?: Vector3;
  73929. }
  73930. /**
  73931. * Defines the IDisposable interface in order to be cleanable from resources.
  73932. */
  73933. export interface ISpriteMap extends IDisposable {
  73934. /**
  73935. * String name of the SpriteMap.
  73936. */
  73937. name: string;
  73938. /**
  73939. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73940. */
  73941. atlasJSON: ISpriteJSONAtlas;
  73942. /**
  73943. * Texture of the SpriteMap.
  73944. */
  73945. spriteSheet: Texture;
  73946. /**
  73947. * The parameters to initialize the SpriteMap with.
  73948. */
  73949. options: ISpriteMapOptions;
  73950. }
  73951. /**
  73952. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73953. */
  73954. export class SpriteMap implements ISpriteMap {
  73955. /** The Name of the spriteMap */
  73956. name: string;
  73957. /** The JSON file with the frame and meta data */
  73958. atlasJSON: ISpriteJSONAtlas;
  73959. /** The systems Sprite Sheet Texture */
  73960. spriteSheet: Texture;
  73961. /** Arguments passed with the Constructor */
  73962. options: ISpriteMapOptions;
  73963. /** Public Sprite Storage array, parsed from atlasJSON */
  73964. sprites: Array<ISpriteJSONSprite>;
  73965. /** Returns the Number of Sprites in the System */
  73966. get spriteCount(): number;
  73967. /** Returns the Position of Output Plane*/
  73968. get position(): Vector3;
  73969. /** Returns the Position of Output Plane*/
  73970. set position(v: Vector3);
  73971. /** Returns the Rotation of Output Plane*/
  73972. get rotation(): Vector3;
  73973. /** Returns the Rotation of Output Plane*/
  73974. set rotation(v: Vector3);
  73975. /** Sets the AnimationMap*/
  73976. get animationMap(): RawTexture;
  73977. /** Sets the AnimationMap*/
  73978. set animationMap(v: RawTexture);
  73979. /** Scene that the SpriteMap was created in */
  73980. private _scene;
  73981. /** Texture Buffer of Float32 that holds tile frame data*/
  73982. private _frameMap;
  73983. /** Texture Buffers of Float32 that holds tileMap data*/
  73984. private _tileMaps;
  73985. /** Texture Buffer of Float32 that holds Animation Data*/
  73986. private _animationMap;
  73987. /** Custom ShaderMaterial Central to the System*/
  73988. private _material;
  73989. /** Custom ShaderMaterial Central to the System*/
  73990. private _output;
  73991. /** Systems Time Ticker*/
  73992. private _time;
  73993. /**
  73994. * Creates a new SpriteMap
  73995. * @param name defines the SpriteMaps Name
  73996. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73997. * @param spriteSheet is the Texture that the Sprites are on.
  73998. * @param options a basic deployment configuration
  73999. * @param scene The Scene that the map is deployed on
  74000. */
  74001. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  74002. /**
  74003. * Returns tileID location
  74004. * @returns Vector2 the cell position ID
  74005. */
  74006. getTileID(): Vector2;
  74007. /**
  74008. * Gets the UV location of the mouse over the SpriteMap.
  74009. * @returns Vector2 the UV position of the mouse interaction
  74010. */
  74011. getMousePosition(): Vector2;
  74012. /**
  74013. * Creates the "frame" texture Buffer
  74014. * -------------------------------------
  74015. * Structure of frames
  74016. * "filename": "Falling-Water-2.png",
  74017. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74018. * "rotated": true,
  74019. * "trimmed": true,
  74020. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74021. * "sourceSize": {"w":32,"h":32}
  74022. * @returns RawTexture of the frameMap
  74023. */
  74024. private _createFrameBuffer;
  74025. /**
  74026. * Creates the tileMap texture Buffer
  74027. * @param buffer normally and array of numbers, or a false to generate from scratch
  74028. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74029. * @returns RawTexture of the tileMap
  74030. */
  74031. private _createTileBuffer;
  74032. /**
  74033. * Modifies the data of the tileMaps
  74034. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74035. * @param pos is the iVector2 Coordinates of the Tile
  74036. * @param tile The SpriteIndex of the new Tile
  74037. */
  74038. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74039. /**
  74040. * Creates the animationMap texture Buffer
  74041. * @param buffer normally and array of numbers, or a false to generate from scratch
  74042. * @returns RawTexture of the animationMap
  74043. */
  74044. private _createTileAnimationBuffer;
  74045. /**
  74046. * Modifies the data of the animationMap
  74047. * @param cellID is the Index of the Sprite
  74048. * @param _frame is the target Animation frame
  74049. * @param toCell is the Target Index of the next frame of the animation
  74050. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74051. * @param speed is a global scalar of the time variable on the map.
  74052. */
  74053. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74054. /**
  74055. * Exports the .tilemaps file
  74056. */
  74057. saveTileMaps(): void;
  74058. /**
  74059. * Imports the .tilemaps file
  74060. * @param url of the .tilemaps file
  74061. */
  74062. loadTileMaps(url: string): void;
  74063. /**
  74064. * Release associated resources
  74065. */
  74066. dispose(): void;
  74067. }
  74068. }
  74069. declare module BABYLON {
  74070. /**
  74071. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74072. * @see https://doc.babylonjs.com/babylon101/sprites
  74073. */
  74074. export class SpritePackedManager extends SpriteManager {
  74075. /** defines the packed manager's name */
  74076. name: string;
  74077. /**
  74078. * Creates a new sprite manager from a packed sprite sheet
  74079. * @param name defines the manager's name
  74080. * @param imgUrl defines the sprite sheet url
  74081. * @param capacity defines the maximum allowed number of sprites
  74082. * @param scene defines the hosting scene
  74083. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74084. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74085. * @param samplingMode defines the smapling mode to use with spritesheet
  74086. * @param fromPacked set to true; do not alter
  74087. */
  74088. constructor(
  74089. /** defines the packed manager's name */
  74090. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74091. }
  74092. }
  74093. declare module BABYLON {
  74094. /**
  74095. * Defines the list of states available for a task inside a AssetsManager
  74096. */
  74097. export enum AssetTaskState {
  74098. /**
  74099. * Initialization
  74100. */
  74101. INIT = 0,
  74102. /**
  74103. * Running
  74104. */
  74105. RUNNING = 1,
  74106. /**
  74107. * Done
  74108. */
  74109. DONE = 2,
  74110. /**
  74111. * Error
  74112. */
  74113. ERROR = 3
  74114. }
  74115. /**
  74116. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74117. */
  74118. export abstract class AbstractAssetTask {
  74119. /**
  74120. * Task name
  74121. */ name: string;
  74122. /**
  74123. * Callback called when the task is successful
  74124. */
  74125. onSuccess: (task: any) => void;
  74126. /**
  74127. * Callback called when the task is not successful
  74128. */
  74129. onError: (task: any, message?: string, exception?: any) => void;
  74130. /**
  74131. * Creates a new AssetsManager
  74132. * @param name defines the name of the task
  74133. */
  74134. constructor(
  74135. /**
  74136. * Task name
  74137. */ name: string);
  74138. private _isCompleted;
  74139. private _taskState;
  74140. private _errorObject;
  74141. /**
  74142. * Get if the task is completed
  74143. */
  74144. get isCompleted(): boolean;
  74145. /**
  74146. * Gets the current state of the task
  74147. */
  74148. get taskState(): AssetTaskState;
  74149. /**
  74150. * Gets the current error object (if task is in error)
  74151. */
  74152. get errorObject(): {
  74153. message?: string;
  74154. exception?: any;
  74155. };
  74156. /**
  74157. * Internal only
  74158. * @hidden
  74159. */
  74160. _setErrorObject(message?: string, exception?: any): void;
  74161. /**
  74162. * Execute the current task
  74163. * @param scene defines the scene where you want your assets to be loaded
  74164. * @param onSuccess is a callback called when the task is successfully executed
  74165. * @param onError is a callback called if an error occurs
  74166. */
  74167. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74168. /**
  74169. * Execute the current task
  74170. * @param scene defines the scene where you want your assets to be loaded
  74171. * @param onSuccess is a callback called when the task is successfully executed
  74172. * @param onError is a callback called if an error occurs
  74173. */
  74174. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74175. /**
  74176. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74177. * This can be used with failed tasks that have the reason for failure fixed.
  74178. */
  74179. reset(): void;
  74180. private onErrorCallback;
  74181. private onDoneCallback;
  74182. }
  74183. /**
  74184. * Define the interface used by progress events raised during assets loading
  74185. */
  74186. export interface IAssetsProgressEvent {
  74187. /**
  74188. * Defines the number of remaining tasks to process
  74189. */
  74190. remainingCount: number;
  74191. /**
  74192. * Defines the total number of tasks
  74193. */
  74194. totalCount: number;
  74195. /**
  74196. * Defines the task that was just processed
  74197. */
  74198. task: AbstractAssetTask;
  74199. }
  74200. /**
  74201. * Class used to share progress information about assets loading
  74202. */
  74203. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74204. /**
  74205. * Defines the number of remaining tasks to process
  74206. */
  74207. remainingCount: number;
  74208. /**
  74209. * Defines the total number of tasks
  74210. */
  74211. totalCount: number;
  74212. /**
  74213. * Defines the task that was just processed
  74214. */
  74215. task: AbstractAssetTask;
  74216. /**
  74217. * Creates a AssetsProgressEvent
  74218. * @param remainingCount defines the number of remaining tasks to process
  74219. * @param totalCount defines the total number of tasks
  74220. * @param task defines the task that was just processed
  74221. */
  74222. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74223. }
  74224. /**
  74225. * Define a task used by AssetsManager to load assets into a container
  74226. */
  74227. export class ContainerAssetTask extends AbstractAssetTask {
  74228. /**
  74229. * Defines the name of the task
  74230. */
  74231. name: string;
  74232. /**
  74233. * Defines the list of mesh's names you want to load
  74234. */
  74235. meshesNames: any;
  74236. /**
  74237. * Defines the root url to use as a base to load your meshes and associated resources
  74238. */
  74239. rootUrl: string;
  74240. /**
  74241. * Defines the filename or File of the scene to load from
  74242. */
  74243. sceneFilename: string | File;
  74244. /**
  74245. * Get the loaded asset container
  74246. */
  74247. loadedContainer: AssetContainer;
  74248. /**
  74249. * Gets the list of loaded meshes
  74250. */
  74251. loadedMeshes: Array<AbstractMesh>;
  74252. /**
  74253. * Gets the list of loaded particle systems
  74254. */
  74255. loadedParticleSystems: Array<IParticleSystem>;
  74256. /**
  74257. * Gets the list of loaded skeletons
  74258. */
  74259. loadedSkeletons: Array<Skeleton>;
  74260. /**
  74261. * Gets the list of loaded animation groups
  74262. */
  74263. loadedAnimationGroups: Array<AnimationGroup>;
  74264. /**
  74265. * Callback called when the task is successful
  74266. */
  74267. onSuccess: (task: ContainerAssetTask) => void;
  74268. /**
  74269. * Callback called when the task is successful
  74270. */
  74271. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  74272. /**
  74273. * Creates a new ContainerAssetTask
  74274. * @param name defines the name of the task
  74275. * @param meshesNames defines the list of mesh's names you want to load
  74276. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74277. * @param sceneFilename defines the filename or File of the scene to load from
  74278. */
  74279. constructor(
  74280. /**
  74281. * Defines the name of the task
  74282. */
  74283. name: string,
  74284. /**
  74285. * Defines the list of mesh's names you want to load
  74286. */
  74287. meshesNames: any,
  74288. /**
  74289. * Defines the root url to use as a base to load your meshes and associated resources
  74290. */
  74291. rootUrl: string,
  74292. /**
  74293. * Defines the filename or File of the scene to load from
  74294. */
  74295. sceneFilename: string | File);
  74296. /**
  74297. * Execute the current task
  74298. * @param scene defines the scene where you want your assets to be loaded
  74299. * @param onSuccess is a callback called when the task is successfully executed
  74300. * @param onError is a callback called if an error occurs
  74301. */
  74302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74303. }
  74304. /**
  74305. * Define a task used by AssetsManager to load meshes
  74306. */
  74307. export class MeshAssetTask extends AbstractAssetTask {
  74308. /**
  74309. * Defines the name of the task
  74310. */
  74311. name: string;
  74312. /**
  74313. * Defines the list of mesh's names you want to load
  74314. */
  74315. meshesNames: any;
  74316. /**
  74317. * Defines the root url to use as a base to load your meshes and associated resources
  74318. */
  74319. rootUrl: string;
  74320. /**
  74321. * Defines the filename or File of the scene to load from
  74322. */
  74323. sceneFilename: string | File;
  74324. /**
  74325. * Gets the list of loaded meshes
  74326. */
  74327. loadedMeshes: Array<AbstractMesh>;
  74328. /**
  74329. * Gets the list of loaded particle systems
  74330. */
  74331. loadedParticleSystems: Array<IParticleSystem>;
  74332. /**
  74333. * Gets the list of loaded skeletons
  74334. */
  74335. loadedSkeletons: Array<Skeleton>;
  74336. /**
  74337. * Gets the list of loaded animation groups
  74338. */
  74339. loadedAnimationGroups: Array<AnimationGroup>;
  74340. /**
  74341. * Callback called when the task is successful
  74342. */
  74343. onSuccess: (task: MeshAssetTask) => void;
  74344. /**
  74345. * Callback called when the task is successful
  74346. */
  74347. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74348. /**
  74349. * Creates a new MeshAssetTask
  74350. * @param name defines the name of the task
  74351. * @param meshesNames defines the list of mesh's names you want to load
  74352. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74353. * @param sceneFilename defines the filename or File of the scene to load from
  74354. */
  74355. constructor(
  74356. /**
  74357. * Defines the name of the task
  74358. */
  74359. name: string,
  74360. /**
  74361. * Defines the list of mesh's names you want to load
  74362. */
  74363. meshesNames: any,
  74364. /**
  74365. * Defines the root url to use as a base to load your meshes and associated resources
  74366. */
  74367. rootUrl: string,
  74368. /**
  74369. * Defines the filename or File of the scene to load from
  74370. */
  74371. sceneFilename: string | File);
  74372. /**
  74373. * Execute the current task
  74374. * @param scene defines the scene where you want your assets to be loaded
  74375. * @param onSuccess is a callback called when the task is successfully executed
  74376. * @param onError is a callback called if an error occurs
  74377. */
  74378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74379. }
  74380. /**
  74381. * Define a task used by AssetsManager to load text content
  74382. */
  74383. export class TextFileAssetTask extends AbstractAssetTask {
  74384. /**
  74385. * Defines the name of the task
  74386. */
  74387. name: string;
  74388. /**
  74389. * Defines the location of the file to load
  74390. */
  74391. url: string;
  74392. /**
  74393. * Gets the loaded text string
  74394. */
  74395. text: string;
  74396. /**
  74397. * Callback called when the task is successful
  74398. */
  74399. onSuccess: (task: TextFileAssetTask) => void;
  74400. /**
  74401. * Callback called when the task is successful
  74402. */
  74403. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74404. /**
  74405. * Creates a new TextFileAssetTask object
  74406. * @param name defines the name of the task
  74407. * @param url defines the location of the file to load
  74408. */
  74409. constructor(
  74410. /**
  74411. * Defines the name of the task
  74412. */
  74413. name: string,
  74414. /**
  74415. * Defines the location of the file to load
  74416. */
  74417. url: string);
  74418. /**
  74419. * Execute the current task
  74420. * @param scene defines the scene where you want your assets to be loaded
  74421. * @param onSuccess is a callback called when the task is successfully executed
  74422. * @param onError is a callback called if an error occurs
  74423. */
  74424. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74425. }
  74426. /**
  74427. * Define a task used by AssetsManager to load binary data
  74428. */
  74429. export class BinaryFileAssetTask extends AbstractAssetTask {
  74430. /**
  74431. * Defines the name of the task
  74432. */
  74433. name: string;
  74434. /**
  74435. * Defines the location of the file to load
  74436. */
  74437. url: string;
  74438. /**
  74439. * Gets the lodaded data (as an array buffer)
  74440. */
  74441. data: ArrayBuffer;
  74442. /**
  74443. * Callback called when the task is successful
  74444. */
  74445. onSuccess: (task: BinaryFileAssetTask) => void;
  74446. /**
  74447. * Callback called when the task is successful
  74448. */
  74449. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74450. /**
  74451. * Creates a new BinaryFileAssetTask object
  74452. * @param name defines the name of the new task
  74453. * @param url defines the location of the file to load
  74454. */
  74455. constructor(
  74456. /**
  74457. * Defines the name of the task
  74458. */
  74459. name: string,
  74460. /**
  74461. * Defines the location of the file to load
  74462. */
  74463. url: string);
  74464. /**
  74465. * Execute the current task
  74466. * @param scene defines the scene where you want your assets to be loaded
  74467. * @param onSuccess is a callback called when the task is successfully executed
  74468. * @param onError is a callback called if an error occurs
  74469. */
  74470. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74471. }
  74472. /**
  74473. * Define a task used by AssetsManager to load images
  74474. */
  74475. export class ImageAssetTask extends AbstractAssetTask {
  74476. /**
  74477. * Defines the name of the task
  74478. */
  74479. name: string;
  74480. /**
  74481. * Defines the location of the image to load
  74482. */
  74483. url: string;
  74484. /**
  74485. * Gets the loaded images
  74486. */
  74487. image: HTMLImageElement;
  74488. /**
  74489. * Callback called when the task is successful
  74490. */
  74491. onSuccess: (task: ImageAssetTask) => void;
  74492. /**
  74493. * Callback called when the task is successful
  74494. */
  74495. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74496. /**
  74497. * Creates a new ImageAssetTask
  74498. * @param name defines the name of the task
  74499. * @param url defines the location of the image to load
  74500. */
  74501. constructor(
  74502. /**
  74503. * Defines the name of the task
  74504. */
  74505. name: string,
  74506. /**
  74507. * Defines the location of the image to load
  74508. */
  74509. url: string);
  74510. /**
  74511. * Execute the current task
  74512. * @param scene defines the scene where you want your assets to be loaded
  74513. * @param onSuccess is a callback called when the task is successfully executed
  74514. * @param onError is a callback called if an error occurs
  74515. */
  74516. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74517. }
  74518. /**
  74519. * Defines the interface used by texture loading tasks
  74520. */
  74521. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74522. /**
  74523. * Gets the loaded texture
  74524. */
  74525. texture: TEX;
  74526. }
  74527. /**
  74528. * Define a task used by AssetsManager to load 2D textures
  74529. */
  74530. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74531. /**
  74532. * Defines the name of the task
  74533. */
  74534. name: string;
  74535. /**
  74536. * Defines the location of the file to load
  74537. */
  74538. url: string;
  74539. /**
  74540. * Defines if mipmap should not be generated (default is false)
  74541. */
  74542. noMipmap?: boolean | undefined;
  74543. /**
  74544. * Defines if texture must be inverted on Y axis (default is true)
  74545. */
  74546. invertY: boolean;
  74547. /**
  74548. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74549. */
  74550. samplingMode: number;
  74551. /**
  74552. * Gets the loaded texture
  74553. */
  74554. texture: Texture;
  74555. /**
  74556. * Callback called when the task is successful
  74557. */
  74558. onSuccess: (task: TextureAssetTask) => void;
  74559. /**
  74560. * Callback called when the task is successful
  74561. */
  74562. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74563. /**
  74564. * Creates a new TextureAssetTask object
  74565. * @param name defines the name of the task
  74566. * @param url defines the location of the file to load
  74567. * @param noMipmap defines if mipmap should not be generated (default is false)
  74568. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74569. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74570. */
  74571. constructor(
  74572. /**
  74573. * Defines the name of the task
  74574. */
  74575. name: string,
  74576. /**
  74577. * Defines the location of the file to load
  74578. */
  74579. url: string,
  74580. /**
  74581. * Defines if mipmap should not be generated (default is false)
  74582. */
  74583. noMipmap?: boolean | undefined,
  74584. /**
  74585. * Defines if texture must be inverted on Y axis (default is true)
  74586. */
  74587. invertY?: boolean,
  74588. /**
  74589. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74590. */
  74591. samplingMode?: number);
  74592. /**
  74593. * Execute the current task
  74594. * @param scene defines the scene where you want your assets to be loaded
  74595. * @param onSuccess is a callback called when the task is successfully executed
  74596. * @param onError is a callback called if an error occurs
  74597. */
  74598. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74599. }
  74600. /**
  74601. * Define a task used by AssetsManager to load cube textures
  74602. */
  74603. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74604. /**
  74605. * Defines the name of the task
  74606. */
  74607. name: string;
  74608. /**
  74609. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74610. */
  74611. url: string;
  74612. /**
  74613. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74614. */
  74615. extensions?: string[] | undefined;
  74616. /**
  74617. * Defines if mipmaps should not be generated (default is false)
  74618. */
  74619. noMipmap?: boolean | undefined;
  74620. /**
  74621. * Defines the explicit list of files (undefined by default)
  74622. */
  74623. files?: string[] | undefined;
  74624. /**
  74625. * Gets the loaded texture
  74626. */
  74627. texture: CubeTexture;
  74628. /**
  74629. * Callback called when the task is successful
  74630. */
  74631. onSuccess: (task: CubeTextureAssetTask) => void;
  74632. /**
  74633. * Callback called when the task is successful
  74634. */
  74635. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74636. /**
  74637. * Creates a new CubeTextureAssetTask
  74638. * @param name defines the name of the task
  74639. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74640. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74641. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74642. * @param files defines the explicit list of files (undefined by default)
  74643. */
  74644. constructor(
  74645. /**
  74646. * Defines the name of the task
  74647. */
  74648. name: string,
  74649. /**
  74650. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74651. */
  74652. url: string,
  74653. /**
  74654. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74655. */
  74656. extensions?: string[] | undefined,
  74657. /**
  74658. * Defines if mipmaps should not be generated (default is false)
  74659. */
  74660. noMipmap?: boolean | undefined,
  74661. /**
  74662. * Defines the explicit list of files (undefined by default)
  74663. */
  74664. files?: string[] | undefined);
  74665. /**
  74666. * Execute the current task
  74667. * @param scene defines the scene where you want your assets to be loaded
  74668. * @param onSuccess is a callback called when the task is successfully executed
  74669. * @param onError is a callback called if an error occurs
  74670. */
  74671. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74672. }
  74673. /**
  74674. * Define a task used by AssetsManager to load HDR cube textures
  74675. */
  74676. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74677. /**
  74678. * Defines the name of the task
  74679. */
  74680. name: string;
  74681. /**
  74682. * Defines the location of the file to load
  74683. */
  74684. url: string;
  74685. /**
  74686. * Defines the desired size (the more it increases the longer the generation will be)
  74687. */
  74688. size: number;
  74689. /**
  74690. * Defines if mipmaps should not be generated (default is false)
  74691. */
  74692. noMipmap: boolean;
  74693. /**
  74694. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74695. */
  74696. generateHarmonics: boolean;
  74697. /**
  74698. * 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)
  74699. */
  74700. gammaSpace: boolean;
  74701. /**
  74702. * Internal Use Only
  74703. */
  74704. reserved: boolean;
  74705. /**
  74706. * Gets the loaded texture
  74707. */
  74708. texture: HDRCubeTexture;
  74709. /**
  74710. * Callback called when the task is successful
  74711. */
  74712. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74713. /**
  74714. * Callback called when the task is successful
  74715. */
  74716. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74717. /**
  74718. * Creates a new HDRCubeTextureAssetTask object
  74719. * @param name defines the name of the task
  74720. * @param url defines the location of the file to load
  74721. * @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.
  74722. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74723. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74724. * @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)
  74725. * @param reserved Internal use only
  74726. */
  74727. constructor(
  74728. /**
  74729. * Defines the name of the task
  74730. */
  74731. name: string,
  74732. /**
  74733. * Defines the location of the file to load
  74734. */
  74735. url: string,
  74736. /**
  74737. * Defines the desired size (the more it increases the longer the generation will be)
  74738. */
  74739. size: number,
  74740. /**
  74741. * Defines if mipmaps should not be generated (default is false)
  74742. */
  74743. noMipmap?: boolean,
  74744. /**
  74745. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74746. */
  74747. generateHarmonics?: boolean,
  74748. /**
  74749. * 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)
  74750. */
  74751. gammaSpace?: boolean,
  74752. /**
  74753. * Internal Use Only
  74754. */
  74755. reserved?: boolean);
  74756. /**
  74757. * Execute the current task
  74758. * @param scene defines the scene where you want your assets to be loaded
  74759. * @param onSuccess is a callback called when the task is successfully executed
  74760. * @param onError is a callback called if an error occurs
  74761. */
  74762. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74763. }
  74764. /**
  74765. * Define a task used by AssetsManager to load Equirectangular cube textures
  74766. */
  74767. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74768. /**
  74769. * Defines the name of the task
  74770. */
  74771. name: string;
  74772. /**
  74773. * Defines the location of the file to load
  74774. */
  74775. url: string;
  74776. /**
  74777. * Defines the desired size (the more it increases the longer the generation will be)
  74778. */
  74779. size: number;
  74780. /**
  74781. * Defines if mipmaps should not be generated (default is false)
  74782. */
  74783. noMipmap: boolean;
  74784. /**
  74785. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74786. * but the standard material would require them in Gamma space) (default is true)
  74787. */
  74788. gammaSpace: boolean;
  74789. /**
  74790. * Gets the loaded texture
  74791. */
  74792. texture: EquiRectangularCubeTexture;
  74793. /**
  74794. * Callback called when the task is successful
  74795. */
  74796. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74797. /**
  74798. * Callback called when the task is successful
  74799. */
  74800. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74801. /**
  74802. * Creates a new EquiRectangularCubeTextureAssetTask object
  74803. * @param name defines the name of the task
  74804. * @param url defines the location of the file to load
  74805. * @param size defines the desired size (the more it increases the longer the generation will be)
  74806. * If the size is omitted this implies you are using a preprocessed cubemap.
  74807. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74808. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74809. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74810. * (default is true)
  74811. */
  74812. constructor(
  74813. /**
  74814. * Defines the name of the task
  74815. */
  74816. name: string,
  74817. /**
  74818. * Defines the location of the file to load
  74819. */
  74820. url: string,
  74821. /**
  74822. * Defines the desired size (the more it increases the longer the generation will be)
  74823. */
  74824. size: number,
  74825. /**
  74826. * Defines if mipmaps should not be generated (default is false)
  74827. */
  74828. noMipmap?: boolean,
  74829. /**
  74830. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74831. * but the standard material would require them in Gamma space) (default is true)
  74832. */
  74833. gammaSpace?: boolean);
  74834. /**
  74835. * Execute the current task
  74836. * @param scene defines the scene where you want your assets to be loaded
  74837. * @param onSuccess is a callback called when the task is successfully executed
  74838. * @param onError is a callback called if an error occurs
  74839. */
  74840. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74841. }
  74842. /**
  74843. * This class can be used to easily import assets into a scene
  74844. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74845. */
  74846. export class AssetsManager {
  74847. private _scene;
  74848. private _isLoading;
  74849. protected _tasks: AbstractAssetTask[];
  74850. protected _waitingTasksCount: number;
  74851. protected _totalTasksCount: number;
  74852. /**
  74853. * Callback called when all tasks are processed
  74854. */
  74855. onFinish: (tasks: AbstractAssetTask[]) => void;
  74856. /**
  74857. * Callback called when a task is successful
  74858. */
  74859. onTaskSuccess: (task: AbstractAssetTask) => void;
  74860. /**
  74861. * Callback called when a task had an error
  74862. */
  74863. onTaskError: (task: AbstractAssetTask) => void;
  74864. /**
  74865. * Callback called when a task is done (whatever the result is)
  74866. */
  74867. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74868. /**
  74869. * Observable called when all tasks are processed
  74870. */
  74871. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74872. /**
  74873. * Observable called when a task had an error
  74874. */
  74875. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74876. /**
  74877. * Observable called when all tasks were executed
  74878. */
  74879. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74880. /**
  74881. * Observable called when a task is done (whatever the result is)
  74882. */
  74883. onProgressObservable: Observable<IAssetsProgressEvent>;
  74884. /**
  74885. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74886. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74887. */
  74888. useDefaultLoadingScreen: boolean;
  74889. /**
  74890. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74891. * when all assets have been downloaded.
  74892. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74893. */
  74894. autoHideLoadingUI: boolean;
  74895. /**
  74896. * Creates a new AssetsManager
  74897. * @param scene defines the scene to work on
  74898. */
  74899. constructor(scene: Scene);
  74900. /**
  74901. * Add a ContainerAssetTask to the list of active tasks
  74902. * @param taskName defines the name of the new task
  74903. * @param meshesNames defines the name of meshes to load
  74904. * @param rootUrl defines the root url to use to locate files
  74905. * @param sceneFilename defines the filename of the scene file
  74906. * @returns a new ContainerAssetTask object
  74907. */
  74908. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74909. /**
  74910. * Add a MeshAssetTask to the list of active tasks
  74911. * @param taskName defines the name of the new task
  74912. * @param meshesNames defines the name of meshes to load
  74913. * @param rootUrl defines the root url to use to locate files
  74914. * @param sceneFilename defines the filename of the scene file
  74915. * @returns a new MeshAssetTask object
  74916. */
  74917. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74918. /**
  74919. * Add a TextFileAssetTask to the list of active tasks
  74920. * @param taskName defines the name of the new task
  74921. * @param url defines the url of the file to load
  74922. * @returns a new TextFileAssetTask object
  74923. */
  74924. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74925. /**
  74926. * Add a BinaryFileAssetTask to the list of active tasks
  74927. * @param taskName defines the name of the new task
  74928. * @param url defines the url of the file to load
  74929. * @returns a new BinaryFileAssetTask object
  74930. */
  74931. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74932. /**
  74933. * Add a ImageAssetTask to the list of active tasks
  74934. * @param taskName defines the name of the new task
  74935. * @param url defines the url of the file to load
  74936. * @returns a new ImageAssetTask object
  74937. */
  74938. addImageTask(taskName: string, url: string): ImageAssetTask;
  74939. /**
  74940. * Add a TextureAssetTask to the list of active tasks
  74941. * @param taskName defines the name of the new task
  74942. * @param url defines the url of the file to load
  74943. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74944. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74945. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74946. * @returns a new TextureAssetTask object
  74947. */
  74948. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74949. /**
  74950. * Add a CubeTextureAssetTask to the list of active tasks
  74951. * @param taskName defines the name of the new task
  74952. * @param url defines the url of the file to load
  74953. * @param extensions defines the extension to use to load the cube map (can be null)
  74954. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74955. * @param files defines the list of files to load (can be null)
  74956. * @returns a new CubeTextureAssetTask object
  74957. */
  74958. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74959. /**
  74960. *
  74961. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74962. * @param taskName defines the name of the new task
  74963. * @param url defines the url of the file to load
  74964. * @param size defines the size you want for the cubemap (can be null)
  74965. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74966. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74967. * @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)
  74968. * @param reserved Internal use only
  74969. * @returns a new HDRCubeTextureAssetTask object
  74970. */
  74971. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74972. /**
  74973. *
  74974. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74975. * @param taskName defines the name of the new task
  74976. * @param url defines the url of the file to load
  74977. * @param size defines the size you want for the cubemap (can be null)
  74978. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74979. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74980. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74981. * @returns a new EquiRectangularCubeTextureAssetTask object
  74982. */
  74983. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74984. /**
  74985. * Remove a task from the assets manager.
  74986. * @param task the task to remove
  74987. */
  74988. removeTask(task: AbstractAssetTask): void;
  74989. private _decreaseWaitingTasksCount;
  74990. private _runTask;
  74991. /**
  74992. * Reset the AssetsManager and remove all tasks
  74993. * @return the current instance of the AssetsManager
  74994. */
  74995. reset(): AssetsManager;
  74996. /**
  74997. * Start the loading process
  74998. * @return the current instance of the AssetsManager
  74999. */
  75000. load(): AssetsManager;
  75001. /**
  75002. * Start the loading process as an async operation
  75003. * @return a promise returning the list of failed tasks
  75004. */
  75005. loadAsync(): Promise<void>;
  75006. }
  75007. }
  75008. declare module BABYLON {
  75009. /**
  75010. * Wrapper class for promise with external resolve and reject.
  75011. */
  75012. export class Deferred<T> {
  75013. /**
  75014. * The promise associated with this deferred object.
  75015. */
  75016. readonly promise: Promise<T>;
  75017. private _resolve;
  75018. private _reject;
  75019. /**
  75020. * The resolve method of the promise associated with this deferred object.
  75021. */
  75022. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  75023. /**
  75024. * The reject method of the promise associated with this deferred object.
  75025. */
  75026. get reject(): (reason?: any) => void;
  75027. /**
  75028. * Constructor for this deferred object.
  75029. */
  75030. constructor();
  75031. }
  75032. }
  75033. declare module BABYLON {
  75034. /**
  75035. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75036. */
  75037. export class MeshExploder {
  75038. private _centerMesh;
  75039. private _meshes;
  75040. private _meshesOrigins;
  75041. private _toCenterVectors;
  75042. private _scaledDirection;
  75043. private _newPosition;
  75044. private _centerPosition;
  75045. /**
  75046. * Explodes meshes from a center mesh.
  75047. * @param meshes The meshes to explode.
  75048. * @param centerMesh The mesh to be center of explosion.
  75049. */
  75050. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75051. private _setCenterMesh;
  75052. /**
  75053. * Get class name
  75054. * @returns "MeshExploder"
  75055. */
  75056. getClassName(): string;
  75057. /**
  75058. * "Exploded meshes"
  75059. * @returns Array of meshes with the centerMesh at index 0.
  75060. */
  75061. getMeshes(): Array<Mesh>;
  75062. /**
  75063. * Explodes meshes giving a specific direction
  75064. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75065. */
  75066. explode(direction?: number): void;
  75067. }
  75068. }
  75069. declare module BABYLON {
  75070. /**
  75071. * Class used to help managing file picking and drag'n'drop
  75072. */
  75073. export class FilesInput {
  75074. /**
  75075. * List of files ready to be loaded
  75076. */
  75077. static get FilesToLoad(): {
  75078. [key: string]: File;
  75079. };
  75080. /**
  75081. * Callback called when a file is processed
  75082. */
  75083. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  75084. private _engine;
  75085. private _currentScene;
  75086. private _sceneLoadedCallback;
  75087. private _progressCallback;
  75088. private _additionalRenderLoopLogicCallback;
  75089. private _textureLoadingCallback;
  75090. private _startingProcessingFilesCallback;
  75091. private _onReloadCallback;
  75092. private _errorCallback;
  75093. private _elementToMonitor;
  75094. private _sceneFileToLoad;
  75095. private _filesToLoad;
  75096. /**
  75097. * Creates a new FilesInput
  75098. * @param engine defines the rendering engine
  75099. * @param scene defines the hosting scene
  75100. * @param sceneLoadedCallback callback called when scene is loaded
  75101. * @param progressCallback callback called to track progress
  75102. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75103. * @param textureLoadingCallback callback called when a texture is loading
  75104. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75105. * @param onReloadCallback callback called when a reload is requested
  75106. * @param errorCallback callback call if an error occurs
  75107. */
  75108. 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>);
  75109. private _dragEnterHandler;
  75110. private _dragOverHandler;
  75111. private _dropHandler;
  75112. /**
  75113. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75114. * @param elementToMonitor defines the DOM element to track
  75115. */
  75116. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75117. /** Gets the current list of files to load */
  75118. get filesToLoad(): File[];
  75119. /**
  75120. * Release all associated resources
  75121. */
  75122. dispose(): void;
  75123. private renderFunction;
  75124. private drag;
  75125. private drop;
  75126. private _traverseFolder;
  75127. private _processFiles;
  75128. /**
  75129. * Load files from a drop event
  75130. * @param event defines the drop event to use as source
  75131. */
  75132. loadFiles(event: any): void;
  75133. private _processReload;
  75134. /**
  75135. * Reload the current scene from the loaded files
  75136. */
  75137. reload(): void;
  75138. }
  75139. }
  75140. declare module BABYLON {
  75141. /**
  75142. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75143. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75144. */
  75145. export class SceneOptimization {
  75146. /**
  75147. * Defines the priority of this optimization (0 by default which means first in the list)
  75148. */
  75149. priority: number;
  75150. /**
  75151. * Gets a string describing the action executed by the current optimization
  75152. * @returns description string
  75153. */
  75154. getDescription(): string;
  75155. /**
  75156. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75157. * @param scene defines the current scene where to apply this optimization
  75158. * @param optimizer defines the current optimizer
  75159. * @returns true if everything that can be done was applied
  75160. */
  75161. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75162. /**
  75163. * Creates the SceneOptimization object
  75164. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75165. * @param desc defines the description associated with the optimization
  75166. */
  75167. constructor(
  75168. /**
  75169. * Defines the priority of this optimization (0 by default which means first in the list)
  75170. */
  75171. priority?: number);
  75172. }
  75173. /**
  75174. * Defines an optimization used to reduce the size of render target textures
  75175. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75176. */
  75177. export class TextureOptimization extends SceneOptimization {
  75178. /**
  75179. * Defines the priority of this optimization (0 by default which means first in the list)
  75180. */
  75181. priority: number;
  75182. /**
  75183. * 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
  75184. */
  75185. maximumSize: number;
  75186. /**
  75187. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75188. */
  75189. step: number;
  75190. /**
  75191. * Gets a string describing the action executed by the current optimization
  75192. * @returns description string
  75193. */
  75194. getDescription(): string;
  75195. /**
  75196. * Creates the TextureOptimization object
  75197. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75198. * @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
  75199. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75200. */
  75201. constructor(
  75202. /**
  75203. * Defines the priority of this optimization (0 by default which means first in the list)
  75204. */
  75205. priority?: number,
  75206. /**
  75207. * 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
  75208. */
  75209. maximumSize?: number,
  75210. /**
  75211. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75212. */
  75213. step?: number);
  75214. /**
  75215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75216. * @param scene defines the current scene where to apply this optimization
  75217. * @param optimizer defines the current optimizer
  75218. * @returns true if everything that can be done was applied
  75219. */
  75220. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75221. }
  75222. /**
  75223. * Defines an optimization used to increase or decrease the rendering resolution
  75224. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75225. */
  75226. export class HardwareScalingOptimization extends SceneOptimization {
  75227. /**
  75228. * Defines the priority of this optimization (0 by default which means first in the list)
  75229. */
  75230. priority: number;
  75231. /**
  75232. * Defines the maximum scale to use (2 by default)
  75233. */
  75234. maximumScale: number;
  75235. /**
  75236. * Defines the step to use between two passes (0.5 by default)
  75237. */
  75238. step: number;
  75239. private _currentScale;
  75240. private _directionOffset;
  75241. /**
  75242. * Gets a string describing the action executed by the current optimization
  75243. * @return description string
  75244. */
  75245. getDescription(): string;
  75246. /**
  75247. * Creates the HardwareScalingOptimization object
  75248. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75249. * @param maximumScale defines the maximum scale to use (2 by default)
  75250. * @param step defines the step to use between two passes (0.5 by default)
  75251. */
  75252. constructor(
  75253. /**
  75254. * Defines the priority of this optimization (0 by default which means first in the list)
  75255. */
  75256. priority?: number,
  75257. /**
  75258. * Defines the maximum scale to use (2 by default)
  75259. */
  75260. maximumScale?: number,
  75261. /**
  75262. * Defines the step to use between two passes (0.5 by default)
  75263. */
  75264. step?: number);
  75265. /**
  75266. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75267. * @param scene defines the current scene where to apply this optimization
  75268. * @param optimizer defines the current optimizer
  75269. * @returns true if everything that can be done was applied
  75270. */
  75271. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75272. }
  75273. /**
  75274. * Defines an optimization used to remove shadows
  75275. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75276. */
  75277. export class ShadowsOptimization extends SceneOptimization {
  75278. /**
  75279. * Gets a string describing the action executed by the current optimization
  75280. * @return description string
  75281. */
  75282. getDescription(): string;
  75283. /**
  75284. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75285. * @param scene defines the current scene where to apply this optimization
  75286. * @param optimizer defines the current optimizer
  75287. * @returns true if everything that can be done was applied
  75288. */
  75289. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75290. }
  75291. /**
  75292. * Defines an optimization used to turn post-processes off
  75293. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75294. */
  75295. export class PostProcessesOptimization extends SceneOptimization {
  75296. /**
  75297. * Gets a string describing the action executed by the current optimization
  75298. * @return description string
  75299. */
  75300. getDescription(): string;
  75301. /**
  75302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75303. * @param scene defines the current scene where to apply this optimization
  75304. * @param optimizer defines the current optimizer
  75305. * @returns true if everything that can be done was applied
  75306. */
  75307. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75308. }
  75309. /**
  75310. * Defines an optimization used to turn lens flares off
  75311. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75312. */
  75313. export class LensFlaresOptimization extends SceneOptimization {
  75314. /**
  75315. * Gets a string describing the action executed by the current optimization
  75316. * @return description string
  75317. */
  75318. getDescription(): string;
  75319. /**
  75320. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75321. * @param scene defines the current scene where to apply this optimization
  75322. * @param optimizer defines the current optimizer
  75323. * @returns true if everything that can be done was applied
  75324. */
  75325. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75326. }
  75327. /**
  75328. * Defines an optimization based on user defined callback.
  75329. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75330. */
  75331. export class CustomOptimization extends SceneOptimization {
  75332. /**
  75333. * Callback called to apply the custom optimization.
  75334. */
  75335. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75336. /**
  75337. * Callback called to get custom description
  75338. */
  75339. onGetDescription: () => string;
  75340. /**
  75341. * Gets a string describing the action executed by the current optimization
  75342. * @returns description string
  75343. */
  75344. getDescription(): string;
  75345. /**
  75346. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75347. * @param scene defines the current scene where to apply this optimization
  75348. * @param optimizer defines the current optimizer
  75349. * @returns true if everything that can be done was applied
  75350. */
  75351. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75352. }
  75353. /**
  75354. * Defines an optimization used to turn particles off
  75355. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75356. */
  75357. export class ParticlesOptimization extends SceneOptimization {
  75358. /**
  75359. * Gets a string describing the action executed by the current optimization
  75360. * @return description string
  75361. */
  75362. getDescription(): string;
  75363. /**
  75364. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75365. * @param scene defines the current scene where to apply this optimization
  75366. * @param optimizer defines the current optimizer
  75367. * @returns true if everything that can be done was applied
  75368. */
  75369. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75370. }
  75371. /**
  75372. * Defines an optimization used to turn render targets off
  75373. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75374. */
  75375. export class RenderTargetsOptimization extends SceneOptimization {
  75376. /**
  75377. * Gets a string describing the action executed by the current optimization
  75378. * @return description string
  75379. */
  75380. getDescription(): string;
  75381. /**
  75382. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75383. * @param scene defines the current scene where to apply this optimization
  75384. * @param optimizer defines the current optimizer
  75385. * @returns true if everything that can be done was applied
  75386. */
  75387. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75388. }
  75389. /**
  75390. * Defines an optimization used to merge meshes with compatible materials
  75391. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75392. */
  75393. export class MergeMeshesOptimization extends SceneOptimization {
  75394. private static _UpdateSelectionTree;
  75395. /**
  75396. * Gets or sets a boolean which defines if optimization octree has to be updated
  75397. */
  75398. static get UpdateSelectionTree(): boolean;
  75399. /**
  75400. * Gets or sets a boolean which defines if optimization octree has to be updated
  75401. */
  75402. static set UpdateSelectionTree(value: boolean);
  75403. /**
  75404. * Gets a string describing the action executed by the current optimization
  75405. * @return description string
  75406. */
  75407. getDescription(): string;
  75408. private _canBeMerged;
  75409. /**
  75410. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75411. * @param scene defines the current scene where to apply this optimization
  75412. * @param optimizer defines the current optimizer
  75413. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75414. * @returns true if everything that can be done was applied
  75415. */
  75416. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75417. }
  75418. /**
  75419. * Defines a list of options used by SceneOptimizer
  75420. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75421. */
  75422. export class SceneOptimizerOptions {
  75423. /**
  75424. * Defines the target frame rate to reach (60 by default)
  75425. */
  75426. targetFrameRate: number;
  75427. /**
  75428. * Defines the interval between two checkes (2000ms by default)
  75429. */
  75430. trackerDuration: number;
  75431. /**
  75432. * Gets the list of optimizations to apply
  75433. */
  75434. optimizations: SceneOptimization[];
  75435. /**
  75436. * Creates a new list of options used by SceneOptimizer
  75437. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75438. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75439. */
  75440. constructor(
  75441. /**
  75442. * Defines the target frame rate to reach (60 by default)
  75443. */
  75444. targetFrameRate?: number,
  75445. /**
  75446. * Defines the interval between two checkes (2000ms by default)
  75447. */
  75448. trackerDuration?: number);
  75449. /**
  75450. * Add a new optimization
  75451. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75452. * @returns the current SceneOptimizerOptions
  75453. */
  75454. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75455. /**
  75456. * Add a new custom optimization
  75457. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75458. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75459. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75460. * @returns the current SceneOptimizerOptions
  75461. */
  75462. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75463. /**
  75464. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75465. * @param targetFrameRate defines the target frame rate (60 by default)
  75466. * @returns a SceneOptimizerOptions object
  75467. */
  75468. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75469. /**
  75470. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75471. * @param targetFrameRate defines the target frame rate (60 by default)
  75472. * @returns a SceneOptimizerOptions object
  75473. */
  75474. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75475. /**
  75476. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75477. * @param targetFrameRate defines the target frame rate (60 by default)
  75478. * @returns a SceneOptimizerOptions object
  75479. */
  75480. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75481. }
  75482. /**
  75483. * Class used to run optimizations in order to reach a target frame rate
  75484. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75485. */
  75486. export class SceneOptimizer implements IDisposable {
  75487. private _isRunning;
  75488. private _options;
  75489. private _scene;
  75490. private _currentPriorityLevel;
  75491. private _targetFrameRate;
  75492. private _trackerDuration;
  75493. private _currentFrameRate;
  75494. private _sceneDisposeObserver;
  75495. private _improvementMode;
  75496. /**
  75497. * Defines an observable called when the optimizer reaches the target frame rate
  75498. */
  75499. onSuccessObservable: Observable<SceneOptimizer>;
  75500. /**
  75501. * Defines an observable called when the optimizer enables an optimization
  75502. */
  75503. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75504. /**
  75505. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75506. */
  75507. onFailureObservable: Observable<SceneOptimizer>;
  75508. /**
  75509. * Gets a boolean indicating if the optimizer is in improvement mode
  75510. */
  75511. get isInImprovementMode(): boolean;
  75512. /**
  75513. * Gets the current priority level (0 at start)
  75514. */
  75515. get currentPriorityLevel(): number;
  75516. /**
  75517. * Gets the current frame rate checked by the SceneOptimizer
  75518. */
  75519. get currentFrameRate(): number;
  75520. /**
  75521. * Gets or sets the current target frame rate (60 by default)
  75522. */
  75523. get targetFrameRate(): number;
  75524. /**
  75525. * Gets or sets the current target frame rate (60 by default)
  75526. */
  75527. set targetFrameRate(value: number);
  75528. /**
  75529. * Gets or sets the current interval between two checks (every 2000ms by default)
  75530. */
  75531. get trackerDuration(): number;
  75532. /**
  75533. * Gets or sets the current interval between two checks (every 2000ms by default)
  75534. */
  75535. set trackerDuration(value: number);
  75536. /**
  75537. * Gets the list of active optimizations
  75538. */
  75539. get optimizations(): SceneOptimization[];
  75540. /**
  75541. * Creates a new SceneOptimizer
  75542. * @param scene defines the scene to work on
  75543. * @param options defines the options to use with the SceneOptimizer
  75544. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75545. * @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)
  75546. */
  75547. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75548. /**
  75549. * Stops the current optimizer
  75550. */
  75551. stop(): void;
  75552. /**
  75553. * Reset the optimizer to initial step (current priority level = 0)
  75554. */
  75555. reset(): void;
  75556. /**
  75557. * Start the optimizer. By default it will try to reach a specific framerate
  75558. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75559. */
  75560. start(): void;
  75561. private _checkCurrentState;
  75562. /**
  75563. * Release all resources
  75564. */
  75565. dispose(): void;
  75566. /**
  75567. * Helper function to create a SceneOptimizer with one single line of code
  75568. * @param scene defines the scene to work on
  75569. * @param options defines the options to use with the SceneOptimizer
  75570. * @param onSuccess defines a callback to call on success
  75571. * @param onFailure defines a callback to call on failure
  75572. * @returns the new SceneOptimizer object
  75573. */
  75574. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75575. }
  75576. }
  75577. declare module BABYLON {
  75578. /**
  75579. * Class used to serialize a scene into a string
  75580. */
  75581. export class SceneSerializer {
  75582. /**
  75583. * Clear cache used by a previous serialization
  75584. */
  75585. static ClearCache(): void;
  75586. /**
  75587. * Serialize a scene into a JSON compatible object
  75588. * @param scene defines the scene to serialize
  75589. * @returns a JSON compatible object
  75590. */
  75591. static Serialize(scene: Scene): any;
  75592. /**
  75593. * Serialize a mesh into a JSON compatible object
  75594. * @param toSerialize defines the mesh to serialize
  75595. * @param withParents defines if parents must be serialized as well
  75596. * @param withChildren defines if children must be serialized as well
  75597. * @returns a JSON compatible object
  75598. */
  75599. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75600. }
  75601. }
  75602. declare module BABYLON {
  75603. /**
  75604. * Class used to host texture specific utilities
  75605. */
  75606. export class TextureTools {
  75607. /**
  75608. * Uses the GPU to create a copy texture rescaled at a given size
  75609. * @param texture Texture to copy from
  75610. * @param width defines the desired width
  75611. * @param height defines the desired height
  75612. * @param useBilinearMode defines if bilinear mode has to be used
  75613. * @return the generated texture
  75614. */
  75615. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75616. }
  75617. }
  75618. declare module BABYLON {
  75619. /**
  75620. * This represents the different options available for the video capture.
  75621. */
  75622. export interface VideoRecorderOptions {
  75623. /** Defines the mime type of the video. */
  75624. mimeType: string;
  75625. /** Defines the FPS the video should be recorded at. */
  75626. fps: number;
  75627. /** Defines the chunk size for the recording data. */
  75628. recordChunckSize: number;
  75629. /** The audio tracks to attach to the recording. */
  75630. audioTracks?: MediaStreamTrack[];
  75631. }
  75632. /**
  75633. * This can help with recording videos from BabylonJS.
  75634. * This is based on the available WebRTC functionalities of the browser.
  75635. *
  75636. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75637. */
  75638. export class VideoRecorder {
  75639. private static readonly _defaultOptions;
  75640. /**
  75641. * Returns whether or not the VideoRecorder is available in your browser.
  75642. * @param engine Defines the Babylon Engine.
  75643. * @returns true if supported otherwise false.
  75644. */
  75645. static IsSupported(engine: Engine): boolean;
  75646. private readonly _options;
  75647. private _canvas;
  75648. private _mediaRecorder;
  75649. private _recordedChunks;
  75650. private _fileName;
  75651. private _resolve;
  75652. private _reject;
  75653. /**
  75654. * True when a recording is already in progress.
  75655. */
  75656. get isRecording(): boolean;
  75657. /**
  75658. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75659. * @param engine Defines the BabylonJS Engine you wish to record.
  75660. * @param options Defines options that can be used to customize the capture.
  75661. */
  75662. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75663. /**
  75664. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75665. */
  75666. stopRecording(): void;
  75667. /**
  75668. * Starts recording the canvas for a max duration specified in parameters.
  75669. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75670. * If null no automatic download will start and you can rely on the promise to get the data back.
  75671. * @param maxDuration Defines the maximum recording time in seconds.
  75672. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75673. * @return A promise callback at the end of the recording with the video data in Blob.
  75674. */
  75675. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75676. /**
  75677. * Releases internal resources used during the recording.
  75678. */
  75679. dispose(): void;
  75680. private _handleDataAvailable;
  75681. private _handleError;
  75682. private _handleStop;
  75683. }
  75684. }
  75685. declare module BABYLON {
  75686. /**
  75687. * Class containing a set of static utilities functions for screenshots
  75688. */
  75689. export class ScreenshotTools {
  75690. /**
  75691. * Captures a screenshot of the current rendering
  75692. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75693. * @param engine defines the rendering engine
  75694. * @param camera defines the source camera
  75695. * @param size This parameter can be set to a single number or to an object with the
  75696. * following (optional) properties: precision, width, height. If a single number is passed,
  75697. * it will be used for both width and height. If an object is passed, the screenshot size
  75698. * will be derived from the parameters. The precision property is a multiplier allowing
  75699. * rendering at a higher or lower resolution
  75700. * @param successCallback defines the callback receives a single parameter which contains the
  75701. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75702. * src parameter of an <img> to display it
  75703. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75704. * Check your browser for supported MIME types
  75705. */
  75706. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75707. /**
  75708. * Captures a screenshot of the current rendering
  75709. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75710. * @param engine defines the rendering engine
  75711. * @param camera defines the source camera
  75712. * @param size This parameter can be set to a single number or to an object with the
  75713. * following (optional) properties: precision, width, height. If a single number is passed,
  75714. * it will be used for both width and height. If an object is passed, the screenshot size
  75715. * will be derived from the parameters. The precision property is a multiplier allowing
  75716. * rendering at a higher or lower resolution
  75717. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75718. * Check your browser for supported MIME types
  75719. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75720. * to the src parameter of an <img> to display it
  75721. */
  75722. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75723. /**
  75724. * Generates an image screenshot from the specified camera.
  75725. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75726. * @param engine The engine to use for rendering
  75727. * @param camera The camera to use for rendering
  75728. * @param size This parameter can be set to a single number or to an object with the
  75729. * following (optional) properties: precision, width, height. If a single number is passed,
  75730. * it will be used for both width and height. If an object is passed, the screenshot size
  75731. * will be derived from the parameters. The precision property is a multiplier allowing
  75732. * rendering at a higher or lower resolution
  75733. * @param successCallback The callback receives a single parameter which contains the
  75734. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75735. * src parameter of an <img> to display it
  75736. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75737. * Check your browser for supported MIME types
  75738. * @param samples Texture samples (default: 1)
  75739. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75740. * @param fileName A name for for the downloaded file.
  75741. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75742. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75743. */
  75744. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  75745. /**
  75746. * Generates an image screenshot from the specified camera.
  75747. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75748. * @param engine The engine to use for rendering
  75749. * @param camera The camera to use for rendering
  75750. * @param size This parameter can be set to a single number or to an object with the
  75751. * following (optional) properties: precision, width, height. If a single number is passed,
  75752. * it will be used for both width and height. If an object is passed, the screenshot size
  75753. * will be derived from the parameters. The precision property is a multiplier allowing
  75754. * rendering at a higher or lower resolution
  75755. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75756. * Check your browser for supported MIME types
  75757. * @param samples Texture samples (default: 1)
  75758. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75759. * @param fileName A name for for the downloaded file.
  75760. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75761. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75762. * to the src parameter of an <img> to display it
  75763. */
  75764. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75765. /**
  75766. * Gets height and width for screenshot size
  75767. * @private
  75768. */
  75769. private static _getScreenshotSize;
  75770. }
  75771. }
  75772. declare module BABYLON {
  75773. /**
  75774. * Interface for a data buffer
  75775. */
  75776. export interface IDataBuffer {
  75777. /**
  75778. * Reads bytes from the data buffer.
  75779. * @param byteOffset The byte offset to read
  75780. * @param byteLength The byte length to read
  75781. * @returns A promise that resolves when the bytes are read
  75782. */
  75783. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75784. /**
  75785. * The byte length of the buffer.
  75786. */
  75787. readonly byteLength: number;
  75788. }
  75789. /**
  75790. * Utility class for reading from a data buffer
  75791. */
  75792. export class DataReader {
  75793. /**
  75794. * The data buffer associated with this data reader.
  75795. */
  75796. readonly buffer: IDataBuffer;
  75797. /**
  75798. * The current byte offset from the beginning of the data buffer.
  75799. */
  75800. byteOffset: number;
  75801. private _dataView;
  75802. private _dataByteOffset;
  75803. /**
  75804. * Constructor
  75805. * @param buffer The buffer to read
  75806. */
  75807. constructor(buffer: IDataBuffer);
  75808. /**
  75809. * Loads the given byte length.
  75810. * @param byteLength The byte length to load
  75811. * @returns A promise that resolves when the load is complete
  75812. */
  75813. loadAsync(byteLength: number): Promise<void>;
  75814. /**
  75815. * Read a unsigned 32-bit integer from the currently loaded data range.
  75816. * @returns The 32-bit integer read
  75817. */
  75818. readUint32(): number;
  75819. /**
  75820. * Read a byte array from the currently loaded data range.
  75821. * @param byteLength The byte length to read
  75822. * @returns The byte array read
  75823. */
  75824. readUint8Array(byteLength: number): Uint8Array;
  75825. /**
  75826. * Read a string from the currently loaded data range.
  75827. * @param byteLength The byte length to read
  75828. * @returns The string read
  75829. */
  75830. readString(byteLength: number): string;
  75831. /**
  75832. * Skips the given byte length the currently loaded data range.
  75833. * @param byteLength The byte length to skip
  75834. */
  75835. skipBytes(byteLength: number): void;
  75836. }
  75837. }
  75838. declare module BABYLON {
  75839. /**
  75840. * Class for storing data to local storage if available or in-memory storage otherwise
  75841. */
  75842. export class DataStorage {
  75843. private static _Storage;
  75844. private static _GetStorage;
  75845. /**
  75846. * Reads a string from the data storage
  75847. * @param key The key to read
  75848. * @param defaultValue The value if the key doesn't exist
  75849. * @returns The string value
  75850. */
  75851. static ReadString(key: string, defaultValue: string): string;
  75852. /**
  75853. * Writes a string to the data storage
  75854. * @param key The key to write
  75855. * @param value The value to write
  75856. */
  75857. static WriteString(key: string, value: string): void;
  75858. /**
  75859. * Reads a boolean from the data storage
  75860. * @param key The key to read
  75861. * @param defaultValue The value if the key doesn't exist
  75862. * @returns The boolean value
  75863. */
  75864. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75865. /**
  75866. * Writes a boolean to the data storage
  75867. * @param key The key to write
  75868. * @param value The value to write
  75869. */
  75870. static WriteBoolean(key: string, value: boolean): void;
  75871. /**
  75872. * Reads a number from the data storage
  75873. * @param key The key to read
  75874. * @param defaultValue The value if the key doesn't exist
  75875. * @returns The number value
  75876. */
  75877. static ReadNumber(key: string, defaultValue: number): number;
  75878. /**
  75879. * Writes a number to the data storage
  75880. * @param key The key to write
  75881. * @param value The value to write
  75882. */
  75883. static WriteNumber(key: string, value: number): void;
  75884. }
  75885. }
  75886. declare module BABYLON {
  75887. /**
  75888. * Class used to record delta files between 2 scene states
  75889. */
  75890. export class SceneRecorder {
  75891. private _trackedScene;
  75892. private _savedJSON;
  75893. /**
  75894. * Track a given scene. This means the current scene state will be considered the original state
  75895. * @param scene defines the scene to track
  75896. */
  75897. track(scene: Scene): void;
  75898. /**
  75899. * Get the delta between current state and original state
  75900. * @returns a string containing the delta
  75901. */
  75902. getDelta(): any;
  75903. private _compareArray;
  75904. private _compareObjects;
  75905. private _compareCollections;
  75906. private static GetShadowGeneratorById;
  75907. /**
  75908. * Apply a given delta to a given scene
  75909. * @param deltaJSON defines the JSON containing the delta
  75910. * @param scene defines the scene to apply the delta to
  75911. */
  75912. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75913. private static _ApplyPropertiesToEntity;
  75914. private static _ApplyDeltaForEntity;
  75915. }
  75916. }
  75917. declare module BABYLON {
  75918. /**
  75919. * A 3D trajectory consisting of an order list of vectors describing a
  75920. * path of motion through 3D space.
  75921. */
  75922. export class Trajectory {
  75923. private _points;
  75924. private readonly _segmentLength;
  75925. /**
  75926. * Serialize to JSON.
  75927. * @returns serialized JSON string
  75928. */
  75929. serialize(): string;
  75930. /**
  75931. * Deserialize from JSON.
  75932. * @param json serialized JSON string
  75933. * @returns deserialized Trajectory
  75934. */
  75935. static Deserialize(json: string): Trajectory;
  75936. /**
  75937. * Create a new empty Trajectory.
  75938. * @param segmentLength radius of discretization for Trajectory points
  75939. */
  75940. constructor(segmentLength?: number);
  75941. /**
  75942. * Get the length of the Trajectory.
  75943. * @returns length of the Trajectory
  75944. */
  75945. getLength(): number;
  75946. /**
  75947. * Append a new point to the Trajectory.
  75948. * NOTE: This implementation has many allocations.
  75949. * @param point point to append to the Trajectory
  75950. */
  75951. add(point: DeepImmutable<Vector3>): void;
  75952. /**
  75953. * Create a new Trajectory with a segment length chosen to make it
  75954. * probable that the new Trajectory will have a specified number of
  75955. * segments. This operation is imprecise.
  75956. * @param targetResolution number of segments desired
  75957. * @returns new Trajectory with approximately the requested number of segments
  75958. */
  75959. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75960. /**
  75961. * Convert Trajectory segments into tokenized representation. This
  75962. * representation is an array of numbers where each nth number is the
  75963. * index of the token which is most similar to the nth segment of the
  75964. * Trajectory.
  75965. * @param tokens list of vectors which serve as discrete tokens
  75966. * @returns list of indices of most similar token per segment
  75967. */
  75968. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75969. private static _forwardDir;
  75970. private static _inverseFromVec;
  75971. private static _upDir;
  75972. private static _fromToVec;
  75973. private static _lookMatrix;
  75974. /**
  75975. * Transform the rotation (i.e., direction) of a segment to isolate
  75976. * the relative transformation represented by the segment. This operation
  75977. * may or may not succeed due to singularities in the equations that define
  75978. * motion relativity in this context.
  75979. * @param priorVec the origin of the prior segment
  75980. * @param fromVec the origin of the current segment
  75981. * @param toVec the destination of the current segment
  75982. * @param result reference to output variable
  75983. * @returns whether or not transformation was successful
  75984. */
  75985. private static _transformSegmentDirToRef;
  75986. private static _bestMatch;
  75987. private static _score;
  75988. private static _bestScore;
  75989. /**
  75990. * Determine which token vector is most similar to the
  75991. * segment vector.
  75992. * @param segment segment vector
  75993. * @param tokens token vector list
  75994. * @returns index of the most similar token to the segment
  75995. */
  75996. private static _tokenizeSegment;
  75997. }
  75998. /**
  75999. * Class representing a set of known, named trajectories to which Trajectories can be
  76000. * added and using which Trajectories can be recognized.
  76001. */
  76002. export class TrajectoryClassifier {
  76003. private _maximumAllowableMatchCost;
  76004. private _vector3Alphabet;
  76005. private _levenshteinAlphabet;
  76006. private _nameToDescribedTrajectory;
  76007. /**
  76008. * Serialize to JSON.
  76009. * @returns JSON serialization
  76010. */
  76011. serialize(): string;
  76012. /**
  76013. * Deserialize from JSON.
  76014. * @param json JSON serialization
  76015. * @returns deserialized TrajectorySet
  76016. */
  76017. static Deserialize(json: string): TrajectoryClassifier;
  76018. /**
  76019. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  76020. * VERY naive, need to be generating these things from known
  76021. * sets. Better version later, probably eliminating this one.
  76022. * @returns auto-generated TrajectorySet
  76023. */
  76024. static Generate(): TrajectoryClassifier;
  76025. private constructor();
  76026. /**
  76027. * Add a new Trajectory to the set with a given name.
  76028. * @param trajectory new Trajectory to be added
  76029. * @param classification name to which to add the Trajectory
  76030. */
  76031. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  76032. /**
  76033. * Remove a known named trajectory and all Trajectories associated with it.
  76034. * @param classification name to remove
  76035. * @returns whether anything was removed
  76036. */
  76037. deleteClassification(classification: string): boolean;
  76038. /**
  76039. * Attempt to recognize a Trajectory from among all the classifications
  76040. * already known to the classifier.
  76041. * @param trajectory Trajectory to be recognized
  76042. * @returns classification of Trajectory if recognized, null otherwise
  76043. */
  76044. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  76045. }
  76046. }
  76047. declare module BABYLON {
  76048. /**
  76049. * An interface for all Hit test features
  76050. */
  76051. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76052. /**
  76053. * Triggered when new babylon (transformed) hit test results are available
  76054. */
  76055. onHitTestResultObservable: Observable<T[]>;
  76056. }
  76057. /**
  76058. * Options used for hit testing
  76059. */
  76060. export interface IWebXRLegacyHitTestOptions {
  76061. /**
  76062. * Only test when user interacted with the scene. Default - hit test every frame
  76063. */
  76064. testOnPointerDownOnly?: boolean;
  76065. /**
  76066. * The node to use to transform the local results to world coordinates
  76067. */
  76068. worldParentNode?: TransformNode;
  76069. }
  76070. /**
  76071. * Interface defining the babylon result of raycasting/hit-test
  76072. */
  76073. export interface IWebXRLegacyHitResult {
  76074. /**
  76075. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76076. */
  76077. transformationMatrix: Matrix;
  76078. /**
  76079. * The native hit test result
  76080. */
  76081. xrHitResult: XRHitResult | XRHitTestResult;
  76082. }
  76083. /**
  76084. * The currently-working hit-test module.
  76085. * Hit test (or Ray-casting) is used to interact with the real world.
  76086. * For further information read here - https://github.com/immersive-web/hit-test
  76087. */
  76088. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76089. /**
  76090. * options to use when constructing this feature
  76091. */
  76092. readonly options: IWebXRLegacyHitTestOptions;
  76093. private _direction;
  76094. private _mat;
  76095. private _onSelectEnabled;
  76096. private _origin;
  76097. /**
  76098. * The module's name
  76099. */
  76100. static readonly Name: string;
  76101. /**
  76102. * The (Babylon) version of this module.
  76103. * This is an integer representing the implementation version.
  76104. * This number does not correspond to the WebXR specs version
  76105. */
  76106. static readonly Version: number;
  76107. /**
  76108. * Populated with the last native XR Hit Results
  76109. */
  76110. lastNativeXRHitResults: XRHitResult[];
  76111. /**
  76112. * Triggered when new babylon (transformed) hit test results are available
  76113. */
  76114. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76115. /**
  76116. * Creates a new instance of the (legacy version) hit test feature
  76117. * @param _xrSessionManager an instance of WebXRSessionManager
  76118. * @param options options to use when constructing this feature
  76119. */
  76120. constructor(_xrSessionManager: WebXRSessionManager,
  76121. /**
  76122. * options to use when constructing this feature
  76123. */
  76124. options?: IWebXRLegacyHitTestOptions);
  76125. /**
  76126. * execute a hit test with an XR Ray
  76127. *
  76128. * @param xrSession a native xrSession that will execute this hit test
  76129. * @param xrRay the ray (position and direction) to use for ray-casting
  76130. * @param referenceSpace native XR reference space to use for the hit-test
  76131. * @param filter filter function that will filter the results
  76132. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76133. */
  76134. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76135. /**
  76136. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76137. * @param event the (select) event to use to select with
  76138. * @param referenceSpace the reference space to use for this hit test
  76139. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76140. */
  76141. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76142. /**
  76143. * attach this feature
  76144. * Will usually be called by the features manager
  76145. *
  76146. * @returns true if successful.
  76147. */
  76148. attach(): boolean;
  76149. /**
  76150. * detach this feature.
  76151. * Will usually be called by the features manager
  76152. *
  76153. * @returns true if successful.
  76154. */
  76155. detach(): boolean;
  76156. /**
  76157. * Dispose this feature and all of the resources attached
  76158. */
  76159. dispose(): void;
  76160. protected _onXRFrame(frame: XRFrame): void;
  76161. private _onHitTestResults;
  76162. private _onSelect;
  76163. }
  76164. }
  76165. declare module BABYLON {
  76166. /**
  76167. * Options used for hit testing (version 2)
  76168. */
  76169. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76170. /**
  76171. * Do not create a permanent hit test. Will usually be used when only
  76172. * transient inputs are needed.
  76173. */
  76174. disablePermanentHitTest?: boolean;
  76175. /**
  76176. * Enable transient (for example touch-based) hit test inspections
  76177. */
  76178. enableTransientHitTest?: boolean;
  76179. /**
  76180. * Offset ray for the permanent hit test
  76181. */
  76182. offsetRay?: Vector3;
  76183. /**
  76184. * Offset ray for the transient hit test
  76185. */
  76186. transientOffsetRay?: Vector3;
  76187. /**
  76188. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76189. */
  76190. useReferenceSpace?: boolean;
  76191. /**
  76192. * Override the default entity type(s) of the hit-test result
  76193. */
  76194. entityTypes?: XRHitTestTrackableType[];
  76195. }
  76196. /**
  76197. * Interface defining the babylon result of hit-test
  76198. */
  76199. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76200. /**
  76201. * The input source that generated this hit test (if transient)
  76202. */
  76203. inputSource?: XRInputSource;
  76204. /**
  76205. * Is this a transient hit test
  76206. */
  76207. isTransient?: boolean;
  76208. /**
  76209. * Position of the hit test result
  76210. */
  76211. position: Vector3;
  76212. /**
  76213. * Rotation of the hit test result
  76214. */
  76215. rotationQuaternion: Quaternion;
  76216. /**
  76217. * The native hit test result
  76218. */
  76219. xrHitResult: XRHitTestResult;
  76220. }
  76221. /**
  76222. * The currently-working hit-test module.
  76223. * Hit test (or Ray-casting) is used to interact with the real world.
  76224. * For further information read here - https://github.com/immersive-web/hit-test
  76225. *
  76226. * Tested on chrome (mobile) 80.
  76227. */
  76228. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76229. /**
  76230. * options to use when constructing this feature
  76231. */
  76232. readonly options: IWebXRHitTestOptions;
  76233. private _tmpMat;
  76234. private _tmpPos;
  76235. private _tmpQuat;
  76236. private _transientXrHitTestSource;
  76237. private _xrHitTestSource;
  76238. private initHitTestSource;
  76239. /**
  76240. * The module's name
  76241. */
  76242. static readonly Name: string;
  76243. /**
  76244. * The (Babylon) version of this module.
  76245. * This is an integer representing the implementation version.
  76246. * This number does not correspond to the WebXR specs version
  76247. */
  76248. static readonly Version: number;
  76249. /**
  76250. * When set to true, each hit test will have its own position/rotation objects
  76251. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76252. * the developers will clone them or copy them as they see fit.
  76253. */
  76254. autoCloneTransformation: boolean;
  76255. /**
  76256. * Triggered when new babylon (transformed) hit test results are available
  76257. * Note - this will be called when results come back from the device. It can be an empty array!!
  76258. */
  76259. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76260. /**
  76261. * Use this to temporarily pause hit test checks.
  76262. */
  76263. paused: boolean;
  76264. /**
  76265. * Creates a new instance of the hit test feature
  76266. * @param _xrSessionManager an instance of WebXRSessionManager
  76267. * @param options options to use when constructing this feature
  76268. */
  76269. constructor(_xrSessionManager: WebXRSessionManager,
  76270. /**
  76271. * options to use when constructing this feature
  76272. */
  76273. options?: IWebXRHitTestOptions);
  76274. /**
  76275. * attach this feature
  76276. * Will usually be called by the features manager
  76277. *
  76278. * @returns true if successful.
  76279. */
  76280. attach(): boolean;
  76281. /**
  76282. * detach this feature.
  76283. * Will usually be called by the features manager
  76284. *
  76285. * @returns true if successful.
  76286. */
  76287. detach(): boolean;
  76288. /**
  76289. * Dispose this feature and all of the resources attached
  76290. */
  76291. dispose(): void;
  76292. protected _onXRFrame(frame: XRFrame): void;
  76293. private _processWebXRHitTestResult;
  76294. }
  76295. }
  76296. declare module BABYLON {
  76297. /**
  76298. * Configuration options of the anchor system
  76299. */
  76300. export interface IWebXRAnchorSystemOptions {
  76301. /**
  76302. * a node that will be used to convert local to world coordinates
  76303. */
  76304. worldParentNode?: TransformNode;
  76305. /**
  76306. * If set to true a reference of the created anchors will be kept until the next session starts
  76307. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76308. */
  76309. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76310. }
  76311. /**
  76312. * A babylon container for an XR Anchor
  76313. */
  76314. export interface IWebXRAnchor {
  76315. /**
  76316. * A babylon-assigned ID for this anchor
  76317. */
  76318. id: number;
  76319. /**
  76320. * Transformation matrix to apply to an object attached to this anchor
  76321. */
  76322. transformationMatrix: Matrix;
  76323. /**
  76324. * The native anchor object
  76325. */
  76326. xrAnchor: XRAnchor;
  76327. /**
  76328. * if defined, this object will be constantly updated by the anchor's position and rotation
  76329. */
  76330. attachedNode?: TransformNode;
  76331. /**
  76332. * Remove this anchor from the scene
  76333. */
  76334. remove(): void;
  76335. }
  76336. /**
  76337. * An implementation of the anchor system for WebXR.
  76338. * For further information see https://github.com/immersive-web/anchors/
  76339. */
  76340. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76341. private _options;
  76342. private _lastFrameDetected;
  76343. private _trackedAnchors;
  76344. private _referenceSpaceForFrameAnchors;
  76345. private _futureAnchors;
  76346. /**
  76347. * The module's name
  76348. */
  76349. static readonly Name: string;
  76350. /**
  76351. * The (Babylon) version of this module.
  76352. * This is an integer representing the implementation version.
  76353. * This number does not correspond to the WebXR specs version
  76354. */
  76355. static readonly Version: number;
  76356. /**
  76357. * Observers registered here will be executed when a new anchor was added to the session
  76358. */
  76359. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76360. /**
  76361. * Observers registered here will be executed when an anchor was removed from the session
  76362. */
  76363. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76364. /**
  76365. * Observers registered here will be executed when an existing anchor updates
  76366. * This can execute N times every frame
  76367. */
  76368. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76369. /**
  76370. * Set the reference space to use for anchor creation, when not using a hit test.
  76371. * Will default to the session's reference space if not defined
  76372. */
  76373. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76374. /**
  76375. * constructs a new anchor system
  76376. * @param _xrSessionManager an instance of WebXRSessionManager
  76377. * @param _options configuration object for this feature
  76378. */
  76379. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76380. private _tmpVector;
  76381. private _tmpQuaternion;
  76382. private _populateTmpTransformation;
  76383. /**
  76384. * Create a new anchor point using a hit test result at a specific point in the scene
  76385. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76386. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76387. *
  76388. * @param hitTestResult The hit test result to use for this anchor creation
  76389. * @param position an optional position offset for this anchor
  76390. * @param rotationQuaternion an optional rotation offset for this anchor
  76391. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76392. */
  76393. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  76394. /**
  76395. * Add a new anchor at a specific position and rotation
  76396. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76397. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76398. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76399. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76400. *
  76401. * @param position the position in which to add an anchor
  76402. * @param rotationQuaternion an optional rotation for the anchor transformation
  76403. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76404. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76405. */
  76406. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  76407. /**
  76408. * Get the list of anchors currently being tracked by the system
  76409. */
  76410. get anchors(): IWebXRAnchor[];
  76411. /**
  76412. * detach this feature.
  76413. * Will usually be called by the features manager
  76414. *
  76415. * @returns true if successful.
  76416. */
  76417. detach(): boolean;
  76418. /**
  76419. * Dispose this feature and all of the resources attached
  76420. */
  76421. dispose(): void;
  76422. protected _onXRFrame(frame: XRFrame): void;
  76423. /**
  76424. * avoiding using Array.find for global support.
  76425. * @param xrAnchor the plane to find in the array
  76426. */
  76427. private _findIndexInAnchorArray;
  76428. private _updateAnchorWithXRFrame;
  76429. private _createAnchorAtTransformation;
  76430. }
  76431. }
  76432. declare module BABYLON {
  76433. /**
  76434. * Options used in the plane detector module
  76435. */
  76436. export interface IWebXRPlaneDetectorOptions {
  76437. /**
  76438. * The node to use to transform the local results to world coordinates
  76439. */
  76440. worldParentNode?: TransformNode;
  76441. /**
  76442. * If set to true a reference of the created planes will be kept until the next session starts
  76443. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76444. */
  76445. doNotRemovePlanesOnSessionEnded?: boolean;
  76446. }
  76447. /**
  76448. * A babylon interface for a WebXR plane.
  76449. * A Plane is actually a polygon, built from N points in space
  76450. *
  76451. * Supported in chrome 79, not supported in canary 81 ATM
  76452. */
  76453. export interface IWebXRPlane {
  76454. /**
  76455. * a babylon-assigned ID for this polygon
  76456. */
  76457. id: number;
  76458. /**
  76459. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76460. */
  76461. polygonDefinition: Array<Vector3>;
  76462. /**
  76463. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76464. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76465. */
  76466. transformationMatrix: Matrix;
  76467. /**
  76468. * the native xr-plane object
  76469. */
  76470. xrPlane: XRPlane;
  76471. }
  76472. /**
  76473. * The plane detector is used to detect planes in the real world when in AR
  76474. * For more information see https://github.com/immersive-web/real-world-geometry/
  76475. */
  76476. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76477. private _options;
  76478. private _detectedPlanes;
  76479. private _enabled;
  76480. private _lastFrameDetected;
  76481. /**
  76482. * The module's name
  76483. */
  76484. static readonly Name: string;
  76485. /**
  76486. * The (Babylon) version of this module.
  76487. * This is an integer representing the implementation version.
  76488. * This number does not correspond to the WebXR specs version
  76489. */
  76490. static readonly Version: number;
  76491. /**
  76492. * Observers registered here will be executed when a new plane was added to the session
  76493. */
  76494. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76495. /**
  76496. * Observers registered here will be executed when a plane is no longer detected in the session
  76497. */
  76498. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76499. /**
  76500. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76501. * This can execute N times every frame
  76502. */
  76503. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76504. /**
  76505. * construct a new Plane Detector
  76506. * @param _xrSessionManager an instance of xr Session manager
  76507. * @param _options configuration to use when constructing this feature
  76508. */
  76509. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76510. /**
  76511. * detach this feature.
  76512. * Will usually be called by the features manager
  76513. *
  76514. * @returns true if successful.
  76515. */
  76516. detach(): boolean;
  76517. /**
  76518. * Dispose this feature and all of the resources attached
  76519. */
  76520. dispose(): void;
  76521. /**
  76522. * Check if the needed objects are defined.
  76523. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76524. */
  76525. isCompatible(): boolean;
  76526. protected _onXRFrame(frame: XRFrame): void;
  76527. private _init;
  76528. private _updatePlaneWithXRPlane;
  76529. /**
  76530. * avoiding using Array.find for global support.
  76531. * @param xrPlane the plane to find in the array
  76532. */
  76533. private findIndexInPlaneArray;
  76534. }
  76535. }
  76536. declare module BABYLON {
  76537. /**
  76538. * Options interface for the background remover plugin
  76539. */
  76540. export interface IWebXRBackgroundRemoverOptions {
  76541. /**
  76542. * Further background meshes to disable when entering AR
  76543. */
  76544. backgroundMeshes?: AbstractMesh[];
  76545. /**
  76546. * flags to configure the removal of the environment helper.
  76547. * If not set, the entire background will be removed. If set, flags should be set as well.
  76548. */
  76549. environmentHelperRemovalFlags?: {
  76550. /**
  76551. * Should the skybox be removed (default false)
  76552. */
  76553. skyBox?: boolean;
  76554. /**
  76555. * Should the ground be removed (default false)
  76556. */
  76557. ground?: boolean;
  76558. };
  76559. /**
  76560. * don't disable the environment helper
  76561. */
  76562. ignoreEnvironmentHelper?: boolean;
  76563. }
  76564. /**
  76565. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76566. */
  76567. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76568. /**
  76569. * read-only options to be used in this module
  76570. */
  76571. readonly options: IWebXRBackgroundRemoverOptions;
  76572. /**
  76573. * The module's name
  76574. */
  76575. static readonly Name: string;
  76576. /**
  76577. * The (Babylon) version of this module.
  76578. * This is an integer representing the implementation version.
  76579. * This number does not correspond to the WebXR specs version
  76580. */
  76581. static readonly Version: number;
  76582. /**
  76583. * registered observers will be triggered when the background state changes
  76584. */
  76585. onBackgroundStateChangedObservable: Observable<boolean>;
  76586. /**
  76587. * constructs a new background remover module
  76588. * @param _xrSessionManager the session manager for this module
  76589. * @param options read-only options to be used in this module
  76590. */
  76591. constructor(_xrSessionManager: WebXRSessionManager,
  76592. /**
  76593. * read-only options to be used in this module
  76594. */
  76595. options?: IWebXRBackgroundRemoverOptions);
  76596. /**
  76597. * attach this feature
  76598. * Will usually be called by the features manager
  76599. *
  76600. * @returns true if successful.
  76601. */
  76602. attach(): boolean;
  76603. /**
  76604. * detach this feature.
  76605. * Will usually be called by the features manager
  76606. *
  76607. * @returns true if successful.
  76608. */
  76609. detach(): boolean;
  76610. /**
  76611. * Dispose this feature and all of the resources attached
  76612. */
  76613. dispose(): void;
  76614. protected _onXRFrame(_xrFrame: XRFrame): void;
  76615. private _setBackgroundState;
  76616. }
  76617. }
  76618. declare module BABYLON {
  76619. /**
  76620. * Options for the controller physics feature
  76621. */
  76622. export class IWebXRControllerPhysicsOptions {
  76623. /**
  76624. * Should the headset get its own impostor
  76625. */
  76626. enableHeadsetImpostor?: boolean;
  76627. /**
  76628. * Optional parameters for the headset impostor
  76629. */
  76630. headsetImpostorParams?: {
  76631. /**
  76632. * The type of impostor to create. Default is sphere
  76633. */
  76634. impostorType: number;
  76635. /**
  76636. * the size of the impostor. Defaults to 10cm
  76637. */
  76638. impostorSize?: number | {
  76639. width: number;
  76640. height: number;
  76641. depth: number;
  76642. };
  76643. /**
  76644. * Friction definitions
  76645. */
  76646. friction?: number;
  76647. /**
  76648. * Restitution
  76649. */
  76650. restitution?: number;
  76651. };
  76652. /**
  76653. * The physics properties of the future impostors
  76654. */
  76655. physicsProperties?: {
  76656. /**
  76657. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76658. * Note that this requires a physics engine that supports mesh impostors!
  76659. */
  76660. useControllerMesh?: boolean;
  76661. /**
  76662. * The type of impostor to create. Default is sphere
  76663. */
  76664. impostorType?: number;
  76665. /**
  76666. * the size of the impostor. Defaults to 10cm
  76667. */
  76668. impostorSize?: number | {
  76669. width: number;
  76670. height: number;
  76671. depth: number;
  76672. };
  76673. /**
  76674. * Friction definitions
  76675. */
  76676. friction?: number;
  76677. /**
  76678. * Restitution
  76679. */
  76680. restitution?: number;
  76681. };
  76682. /**
  76683. * the xr input to use with this pointer selection
  76684. */
  76685. xrInput: WebXRInput;
  76686. }
  76687. /**
  76688. * Add physics impostor to your webxr controllers,
  76689. * including naive calculation of their linear and angular velocity
  76690. */
  76691. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76692. private readonly _options;
  76693. private _attachController;
  76694. private _controllers;
  76695. private _debugMode;
  76696. private _delta;
  76697. private _headsetImpostor?;
  76698. private _headsetMesh?;
  76699. private _lastTimestamp;
  76700. private _tmpQuaternion;
  76701. private _tmpVector;
  76702. /**
  76703. * The module's name
  76704. */
  76705. static readonly Name: string;
  76706. /**
  76707. * The (Babylon) version of this module.
  76708. * This is an integer representing the implementation version.
  76709. * This number does not correspond to the webxr specs version
  76710. */
  76711. static readonly Version: number;
  76712. /**
  76713. * Construct a new Controller Physics Feature
  76714. * @param _xrSessionManager the corresponding xr session manager
  76715. * @param _options options to create this feature with
  76716. */
  76717. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76718. /**
  76719. * @hidden
  76720. * enable debugging - will show console outputs and the impostor mesh
  76721. */
  76722. _enablePhysicsDebug(): void;
  76723. /**
  76724. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76725. * @param xrController the controller to add
  76726. */
  76727. addController(xrController: WebXRInputSource): void;
  76728. /**
  76729. * attach this feature
  76730. * Will usually be called by the features manager
  76731. *
  76732. * @returns true if successful.
  76733. */
  76734. attach(): boolean;
  76735. /**
  76736. * detach this feature.
  76737. * Will usually be called by the features manager
  76738. *
  76739. * @returns true if successful.
  76740. */
  76741. detach(): boolean;
  76742. /**
  76743. * Get the headset impostor, if enabled
  76744. * @returns the impostor
  76745. */
  76746. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76747. /**
  76748. * Get the physics impostor of a specific controller.
  76749. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76750. * @param controller the controller or the controller id of which to get the impostor
  76751. * @returns the impostor or null
  76752. */
  76753. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76754. /**
  76755. * Update the physics properties provided in the constructor
  76756. * @param newProperties the new properties object
  76757. */
  76758. setPhysicsProperties(newProperties: {
  76759. impostorType?: number;
  76760. impostorSize?: number | {
  76761. width: number;
  76762. height: number;
  76763. depth: number;
  76764. };
  76765. friction?: number;
  76766. restitution?: number;
  76767. }): void;
  76768. protected _onXRFrame(_xrFrame: any): void;
  76769. private _detachController;
  76770. }
  76771. }
  76772. declare module BABYLON {
  76773. /**
  76774. * A babylon interface for a "WebXR" feature point.
  76775. * Represents the position and confidence value of a given feature point.
  76776. */
  76777. export interface IWebXRFeaturePoint {
  76778. /**
  76779. * Represents the position of the feature point in world space.
  76780. */
  76781. position: Vector3;
  76782. /**
  76783. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76784. */
  76785. confidenceValue: number;
  76786. }
  76787. /**
  76788. * The feature point system is used to detect feature points from real world geometry.
  76789. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76790. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76791. */
  76792. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76793. private _enabled;
  76794. private _featurePointCloud;
  76795. /**
  76796. * The module's name
  76797. */
  76798. static readonly Name: string;
  76799. /**
  76800. * The (Babylon) version of this module.
  76801. * This is an integer representing the implementation version.
  76802. * This number does not correspond to the WebXR specs version
  76803. */
  76804. static readonly Version: number;
  76805. /**
  76806. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76807. * Will notify the observers about which feature points have been added.
  76808. */
  76809. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76810. /**
  76811. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76812. * Will notify the observers about which feature points have been updated.
  76813. */
  76814. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76815. /**
  76816. * The current feature point cloud maintained across frames.
  76817. */
  76818. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76819. /**
  76820. * construct the feature point system
  76821. * @param _xrSessionManager an instance of xr Session manager
  76822. */
  76823. constructor(_xrSessionManager: WebXRSessionManager);
  76824. /**
  76825. * Detach this feature.
  76826. * Will usually be called by the features manager
  76827. *
  76828. * @returns true if successful.
  76829. */
  76830. detach(): boolean;
  76831. /**
  76832. * Dispose this feature and all of the resources attached
  76833. */
  76834. dispose(): void;
  76835. /**
  76836. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76837. */
  76838. protected _onXRFrame(frame: XRFrame): void;
  76839. /**
  76840. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76841. */
  76842. private _init;
  76843. }
  76844. }
  76845. declare module BABYLON {
  76846. /**
  76847. * Configuration interface for the hand tracking feature
  76848. */
  76849. export interface IWebXRHandTrackingOptions {
  76850. /**
  76851. * The xrInput that will be used as source for new hands
  76852. */
  76853. xrInput: WebXRInput;
  76854. /**
  76855. * Configuration object for the joint meshes
  76856. */
  76857. jointMeshes?: {
  76858. /**
  76859. * Should the meshes created be invisible (defaults to false)
  76860. */
  76861. invisible?: boolean;
  76862. /**
  76863. * A source mesh to be used to create instances. Defaults to a sphere.
  76864. * This mesh will be the source for all other (25) meshes.
  76865. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76866. */
  76867. sourceMesh?: Mesh;
  76868. /**
  76869. * This function will be called after a mesh was created for a specific joint.
  76870. * Using this function you can either manipulate the instance or return a new mesh.
  76871. * When returning a new mesh the instance created before will be disposed
  76872. */
  76873. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76874. /**
  76875. * Should the source mesh stay visible. Defaults to false
  76876. */
  76877. keepOriginalVisible?: boolean;
  76878. /**
  76879. * Scale factor for all instances (defaults to 2)
  76880. */
  76881. scaleFactor?: number;
  76882. /**
  76883. * Should each instance have its own physics impostor
  76884. */
  76885. enablePhysics?: boolean;
  76886. /**
  76887. * If enabled, override default physics properties
  76888. */
  76889. physicsProps?: {
  76890. friction?: number;
  76891. restitution?: number;
  76892. impostorType?: number;
  76893. };
  76894. /**
  76895. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  76896. */
  76897. disableDefaultHandMesh?: boolean;
  76898. /**
  76899. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  76900. */
  76901. handMeshes?: {
  76902. right: AbstractMesh;
  76903. left: AbstractMesh;
  76904. };
  76905. /**
  76906. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  76907. */
  76908. rigMapping?: {
  76909. right: string[];
  76910. left: string[];
  76911. };
  76912. };
  76913. }
  76914. /**
  76915. * Parts of the hands divided to writs and finger names
  76916. */
  76917. export const enum HandPart {
  76918. /**
  76919. * HandPart - Wrist
  76920. */
  76921. WRIST = "wrist",
  76922. /**
  76923. * HandPart - The THumb
  76924. */
  76925. THUMB = "thumb",
  76926. /**
  76927. * HandPart - Index finger
  76928. */
  76929. INDEX = "index",
  76930. /**
  76931. * HandPart - Middle finger
  76932. */
  76933. MIDDLE = "middle",
  76934. /**
  76935. * HandPart - Ring finger
  76936. */
  76937. RING = "ring",
  76938. /**
  76939. * HandPart - Little finger
  76940. */
  76941. LITTLE = "little"
  76942. }
  76943. /**
  76944. * Representing a single hand (with its corresponding native XRHand object)
  76945. */
  76946. export class WebXRHand implements IDisposable {
  76947. /** the controller to which the hand correlates */
  76948. readonly xrController: WebXRInputSource;
  76949. /** the meshes to be used to track the hand joints */
  76950. readonly trackedMeshes: AbstractMesh[];
  76951. private _handMesh?;
  76952. private _rigMapping?;
  76953. private _scene;
  76954. private _defaultHandMesh;
  76955. private _transformNodeMapping;
  76956. /**
  76957. * Hand-parts definition (key is HandPart)
  76958. */
  76959. handPartsDefinition: {
  76960. [key: string]: number[];
  76961. };
  76962. /**
  76963. * Observers will be triggered when the mesh for this hand was initialized.
  76964. */
  76965. onHandMeshReadyObservable: Observable<WebXRHand>;
  76966. /**
  76967. * Populate the HandPartsDefinition object.
  76968. * This is called as a side effect since certain browsers don't have XRHand defined.
  76969. */
  76970. private generateHandPartsDefinition;
  76971. /**
  76972. * Construct a new hand object
  76973. * @param xrController the controller to which the hand correlates
  76974. * @param trackedMeshes the meshes to be used to track the hand joints
  76975. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  76976. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  76977. * @param disableDefaultHandMesh should the default mesh creation be disabled
  76978. */
  76979. constructor(
  76980. /** the controller to which the hand correlates */
  76981. xrController: WebXRInputSource,
  76982. /** the meshes to be used to track the hand joints */
  76983. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  76984. /**
  76985. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  76986. */
  76987. get handMesh(): AbstractMesh | undefined;
  76988. /**
  76989. * Update this hand from the latest xr frame
  76990. * @param xrFrame xrFrame to update from
  76991. * @param referenceSpace The current viewer reference space
  76992. * @param scaleFactor optional scale factor for the meshes
  76993. */
  76994. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76995. /**
  76996. * Get meshes of part of the hand
  76997. * @param part the part of hand to get
  76998. * @returns An array of meshes that correlate to the hand part requested
  76999. */
  77000. getHandPartMeshes(part: HandPart): AbstractMesh[];
  77001. /**
  77002. * Dispose this Hand object
  77003. */
  77004. dispose(): void;
  77005. private _generateDefaultHandMesh;
  77006. }
  77007. /**
  77008. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  77009. */
  77010. export class WebXRHandTracking extends WebXRAbstractFeature {
  77011. /**
  77012. * options to use when constructing this feature
  77013. */
  77014. readonly options: IWebXRHandTrackingOptions;
  77015. private static _idCounter;
  77016. /**
  77017. * The module's name
  77018. */
  77019. static readonly Name: string;
  77020. /**
  77021. * The (Babylon) version of this module.
  77022. * This is an integer representing the implementation version.
  77023. * This number does not correspond to the WebXR specs version
  77024. */
  77025. static readonly Version: number;
  77026. /**
  77027. * This observable will notify registered observers when a new hand object was added and initialized
  77028. */
  77029. onHandAddedObservable: Observable<WebXRHand>;
  77030. /**
  77031. * This observable will notify its observers right before the hand object is disposed
  77032. */
  77033. onHandRemovedObservable: Observable<WebXRHand>;
  77034. private _hands;
  77035. /**
  77036. * Creates a new instance of the hit test feature
  77037. * @param _xrSessionManager an instance of WebXRSessionManager
  77038. * @param options options to use when constructing this feature
  77039. */
  77040. constructor(_xrSessionManager: WebXRSessionManager,
  77041. /**
  77042. * options to use when constructing this feature
  77043. */
  77044. options: IWebXRHandTrackingOptions);
  77045. /**
  77046. * Check if the needed objects are defined.
  77047. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  77048. */
  77049. isCompatible(): boolean;
  77050. /**
  77051. * attach this feature
  77052. * Will usually be called by the features manager
  77053. *
  77054. * @returns true if successful.
  77055. */
  77056. attach(): boolean;
  77057. /**
  77058. * detach this feature.
  77059. * Will usually be called by the features manager
  77060. *
  77061. * @returns true if successful.
  77062. */
  77063. detach(): boolean;
  77064. /**
  77065. * Dispose this feature and all of the resources attached
  77066. */
  77067. dispose(): void;
  77068. /**
  77069. * Get the hand object according to the controller id
  77070. * @param controllerId the controller id to which we want to get the hand
  77071. * @returns null if not found or the WebXRHand object if found
  77072. */
  77073. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  77074. /**
  77075. * Get a hand object according to the requested handedness
  77076. * @param handedness the handedness to request
  77077. * @returns null if not found or the WebXRHand object if found
  77078. */
  77079. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  77080. protected _onXRFrame(_xrFrame: XRFrame): void;
  77081. private _attachHand;
  77082. private _detachHand;
  77083. }
  77084. }
  77085. declare module BABYLON {
  77086. /**
  77087. * The motion controller class for all microsoft mixed reality controllers
  77088. */
  77089. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77090. protected readonly _mapping: {
  77091. defaultButton: {
  77092. valueNodeName: string;
  77093. unpressedNodeName: string;
  77094. pressedNodeName: string;
  77095. };
  77096. defaultAxis: {
  77097. valueNodeName: string;
  77098. minNodeName: string;
  77099. maxNodeName: string;
  77100. };
  77101. buttons: {
  77102. "xr-standard-trigger": {
  77103. rootNodeName: string;
  77104. componentProperty: string;
  77105. states: string[];
  77106. };
  77107. "xr-standard-squeeze": {
  77108. rootNodeName: string;
  77109. componentProperty: string;
  77110. states: string[];
  77111. };
  77112. "xr-standard-touchpad": {
  77113. rootNodeName: string;
  77114. labelAnchorNodeName: string;
  77115. touchPointNodeName: string;
  77116. };
  77117. "xr-standard-thumbstick": {
  77118. rootNodeName: string;
  77119. componentProperty: string;
  77120. states: string[];
  77121. };
  77122. };
  77123. axes: {
  77124. "xr-standard-touchpad": {
  77125. "x-axis": {
  77126. rootNodeName: string;
  77127. };
  77128. "y-axis": {
  77129. rootNodeName: string;
  77130. };
  77131. };
  77132. "xr-standard-thumbstick": {
  77133. "x-axis": {
  77134. rootNodeName: string;
  77135. };
  77136. "y-axis": {
  77137. rootNodeName: string;
  77138. };
  77139. };
  77140. };
  77141. };
  77142. /**
  77143. * The base url used to load the left and right controller models
  77144. */
  77145. static MODEL_BASE_URL: string;
  77146. /**
  77147. * The name of the left controller model file
  77148. */
  77149. static MODEL_LEFT_FILENAME: string;
  77150. /**
  77151. * The name of the right controller model file
  77152. */
  77153. static MODEL_RIGHT_FILENAME: string;
  77154. profileId: string;
  77155. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77156. protected _getFilenameAndPath(): {
  77157. filename: string;
  77158. path: string;
  77159. };
  77160. protected _getModelLoadingConstraints(): boolean;
  77161. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77162. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77163. protected _updateModel(): void;
  77164. }
  77165. }
  77166. declare module BABYLON {
  77167. /**
  77168. * The motion controller class for oculus touch (quest, rift).
  77169. * This class supports legacy mapping as well the standard xr mapping
  77170. */
  77171. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77172. private _forceLegacyControllers;
  77173. private _modelRootNode;
  77174. /**
  77175. * The base url used to load the left and right controller models
  77176. */
  77177. static MODEL_BASE_URL: string;
  77178. /**
  77179. * The name of the left controller model file
  77180. */
  77181. static MODEL_LEFT_FILENAME: string;
  77182. /**
  77183. * The name of the right controller model file
  77184. */
  77185. static MODEL_RIGHT_FILENAME: string;
  77186. /**
  77187. * Base Url for the Quest controller model.
  77188. */
  77189. static QUEST_MODEL_BASE_URL: string;
  77190. profileId: string;
  77191. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77192. protected _getFilenameAndPath(): {
  77193. filename: string;
  77194. path: string;
  77195. };
  77196. protected _getModelLoadingConstraints(): boolean;
  77197. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77198. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77199. protected _updateModel(): void;
  77200. /**
  77201. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77202. * between the touch and touch 2.
  77203. */
  77204. private _isQuest;
  77205. }
  77206. }
  77207. declare module BABYLON {
  77208. /**
  77209. * The motion controller class for the standard HTC-Vive controllers
  77210. */
  77211. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77212. private _modelRootNode;
  77213. /**
  77214. * The base url used to load the left and right controller models
  77215. */
  77216. static MODEL_BASE_URL: string;
  77217. /**
  77218. * File name for the controller model.
  77219. */
  77220. static MODEL_FILENAME: string;
  77221. profileId: string;
  77222. /**
  77223. * Create a new Vive motion controller object
  77224. * @param scene the scene to use to create this controller
  77225. * @param gamepadObject the corresponding gamepad object
  77226. * @param handedness the handedness of the controller
  77227. */
  77228. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77229. protected _getFilenameAndPath(): {
  77230. filename: string;
  77231. path: string;
  77232. };
  77233. protected _getModelLoadingConstraints(): boolean;
  77234. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77235. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77236. protected _updateModel(): void;
  77237. }
  77238. }
  77239. declare module BABYLON {
  77240. /**
  77241. * A cursor which tracks a point on a path
  77242. */
  77243. export class PathCursor {
  77244. private path;
  77245. /**
  77246. * Stores path cursor callbacks for when an onchange event is triggered
  77247. */
  77248. private _onchange;
  77249. /**
  77250. * The value of the path cursor
  77251. */
  77252. value: number;
  77253. /**
  77254. * The animation array of the path cursor
  77255. */
  77256. animations: Animation[];
  77257. /**
  77258. * Initializes the path cursor
  77259. * @param path The path to track
  77260. */
  77261. constructor(path: Path2);
  77262. /**
  77263. * Gets the cursor point on the path
  77264. * @returns A point on the path cursor at the cursor location
  77265. */
  77266. getPoint(): Vector3;
  77267. /**
  77268. * Moves the cursor ahead by the step amount
  77269. * @param step The amount to move the cursor forward
  77270. * @returns This path cursor
  77271. */
  77272. moveAhead(step?: number): PathCursor;
  77273. /**
  77274. * Moves the cursor behind by the step amount
  77275. * @param step The amount to move the cursor back
  77276. * @returns This path cursor
  77277. */
  77278. moveBack(step?: number): PathCursor;
  77279. /**
  77280. * Moves the cursor by the step amount
  77281. * If the step amount is greater than one, an exception is thrown
  77282. * @param step The amount to move the cursor
  77283. * @returns This path cursor
  77284. */
  77285. move(step: number): PathCursor;
  77286. /**
  77287. * Ensures that the value is limited between zero and one
  77288. * @returns This path cursor
  77289. */
  77290. private ensureLimits;
  77291. /**
  77292. * Runs onchange callbacks on change (used by the animation engine)
  77293. * @returns This path cursor
  77294. */
  77295. private raiseOnChange;
  77296. /**
  77297. * Executes a function on change
  77298. * @param f A path cursor onchange callback
  77299. * @returns This path cursor
  77300. */
  77301. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77302. }
  77303. }
  77304. declare module BABYLON {
  77305. /** @hidden */
  77306. export var blurPixelShader: {
  77307. name: string;
  77308. shader: string;
  77309. };
  77310. }
  77311. declare module BABYLON {
  77312. /** @hidden */
  77313. export var pointCloudVertexDeclaration: {
  77314. name: string;
  77315. shader: string;
  77316. };
  77317. }
  77318. // Mixins
  77319. interface Window {
  77320. mozIndexedDB: IDBFactory;
  77321. webkitIndexedDB: IDBFactory;
  77322. msIndexedDB: IDBFactory;
  77323. webkitURL: typeof URL;
  77324. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  77325. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  77326. WebGLRenderingContext: WebGLRenderingContext;
  77327. MSGesture: MSGesture;
  77328. CANNON: any;
  77329. AudioContext: AudioContext;
  77330. webkitAudioContext: AudioContext;
  77331. PointerEvent: any;
  77332. Math: Math;
  77333. Uint8Array: Uint8ArrayConstructor;
  77334. Float32Array: Float32ArrayConstructor;
  77335. mozURL: typeof URL;
  77336. msURL: typeof URL;
  77337. VRFrameData: any; // WebVR, from specs 1.1
  77338. DracoDecoderModule: any;
  77339. setImmediate(handler: (...args: any[]) => void): number;
  77340. }
  77341. interface HTMLCanvasElement {
  77342. requestPointerLock(): void;
  77343. msRequestPointerLock?(): void;
  77344. mozRequestPointerLock?(): void;
  77345. webkitRequestPointerLock?(): void;
  77346. /** Track wether a record is in progress */
  77347. isRecording: boolean;
  77348. /** Capture Stream method defined by some browsers */
  77349. captureStream(fps?: number): MediaStream;
  77350. }
  77351. interface CanvasRenderingContext2D {
  77352. msImageSmoothingEnabled: boolean;
  77353. }
  77354. interface MouseEvent {
  77355. mozMovementX: number;
  77356. mozMovementY: number;
  77357. webkitMovementX: number;
  77358. webkitMovementY: number;
  77359. msMovementX: number;
  77360. msMovementY: number;
  77361. }
  77362. interface Navigator {
  77363. mozGetVRDevices: (any: any) => any;
  77364. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77365. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77366. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77367. webkitGetGamepads(): Gamepad[];
  77368. msGetGamepads(): Gamepad[];
  77369. webkitGamepads(): Gamepad[];
  77370. }
  77371. interface HTMLVideoElement {
  77372. mozSrcObject: any;
  77373. }
  77374. interface Math {
  77375. fround(x: number): number;
  77376. imul(a: number, b: number): number;
  77377. }
  77378. interface WebGLRenderingContext {
  77379. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  77380. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  77381. vertexAttribDivisor(index: number, divisor: number): void;
  77382. createVertexArray(): any;
  77383. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  77384. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  77385. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  77386. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  77387. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  77388. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  77389. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  77390. // Queries
  77391. createQuery(): WebGLQuery;
  77392. deleteQuery(query: WebGLQuery): void;
  77393. beginQuery(target: number, query: WebGLQuery): void;
  77394. endQuery(target: number): void;
  77395. getQueryParameter(query: WebGLQuery, pname: number): any;
  77396. getQuery(target: number, pname: number): any;
  77397. MAX_SAMPLES: number;
  77398. RGBA8: number;
  77399. READ_FRAMEBUFFER: number;
  77400. DRAW_FRAMEBUFFER: number;
  77401. UNIFORM_BUFFER: number;
  77402. HALF_FLOAT_OES: number;
  77403. RGBA16F: number;
  77404. RGBA32F: number;
  77405. R32F: number;
  77406. RG32F: number;
  77407. RGB32F: number;
  77408. R16F: number;
  77409. RG16F: number;
  77410. RGB16F: number;
  77411. RED: number;
  77412. RG: number;
  77413. R8: number;
  77414. RG8: number;
  77415. UNSIGNED_INT_24_8: number;
  77416. DEPTH24_STENCIL8: number;
  77417. MIN: number;
  77418. MAX: number;
  77419. /* Multiple Render Targets */
  77420. drawBuffers(buffers: number[]): void;
  77421. readBuffer(src: number): void;
  77422. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  77423. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  77424. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  77425. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  77426. // Occlusion Query
  77427. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  77428. ANY_SAMPLES_PASSED: number;
  77429. QUERY_RESULT_AVAILABLE: number;
  77430. QUERY_RESULT: number;
  77431. }
  77432. interface WebGLProgram {
  77433. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  77434. }
  77435. interface EXT_disjoint_timer_query {
  77436. QUERY_COUNTER_BITS_EXT: number;
  77437. TIME_ELAPSED_EXT: number;
  77438. TIMESTAMP_EXT: number;
  77439. GPU_DISJOINT_EXT: number;
  77440. QUERY_RESULT_EXT: number;
  77441. QUERY_RESULT_AVAILABLE_EXT: number;
  77442. queryCounterEXT(query: WebGLQuery, target: number): void;
  77443. createQueryEXT(): WebGLQuery;
  77444. beginQueryEXT(target: number, query: WebGLQuery): void;
  77445. endQueryEXT(target: number): void;
  77446. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  77447. deleteQueryEXT(query: WebGLQuery): void;
  77448. }
  77449. interface WebGLUniformLocation {
  77450. _currentState: any;
  77451. }
  77452. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  77453. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  77454. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  77455. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77456. interface WebGLRenderingContext {
  77457. readonly RASTERIZER_DISCARD: number;
  77458. readonly DEPTH_COMPONENT24: number;
  77459. readonly TEXTURE_3D: number;
  77460. readonly TEXTURE_2D_ARRAY: number;
  77461. readonly TEXTURE_COMPARE_FUNC: number;
  77462. readonly TEXTURE_COMPARE_MODE: number;
  77463. readonly COMPARE_REF_TO_TEXTURE: number;
  77464. readonly TEXTURE_WRAP_R: number;
  77465. readonly HALF_FLOAT: number;
  77466. readonly RGB8: number;
  77467. readonly RED_INTEGER: number;
  77468. readonly RG_INTEGER: number;
  77469. readonly RGB_INTEGER: number;
  77470. readonly RGBA_INTEGER: number;
  77471. readonly R8_SNORM: number;
  77472. readonly RG8_SNORM: number;
  77473. readonly RGB8_SNORM: number;
  77474. readonly RGBA8_SNORM: number;
  77475. readonly R8I: number;
  77476. readonly RG8I: number;
  77477. readonly RGB8I: number;
  77478. readonly RGBA8I: number;
  77479. readonly R8UI: number;
  77480. readonly RG8UI: number;
  77481. readonly RGB8UI: number;
  77482. readonly RGBA8UI: number;
  77483. readonly R16I: number;
  77484. readonly RG16I: number;
  77485. readonly RGB16I: number;
  77486. readonly RGBA16I: number;
  77487. readonly R16UI: number;
  77488. readonly RG16UI: number;
  77489. readonly RGB16UI: number;
  77490. readonly RGBA16UI: number;
  77491. readonly R32I: number;
  77492. readonly RG32I: number;
  77493. readonly RGB32I: number;
  77494. readonly RGBA32I: number;
  77495. readonly R32UI: number;
  77496. readonly RG32UI: number;
  77497. readonly RGB32UI: number;
  77498. readonly RGBA32UI: number;
  77499. readonly RGB10_A2UI: number;
  77500. readonly R11F_G11F_B10F: number;
  77501. readonly RGB9_E5: number;
  77502. readonly RGB10_A2: number;
  77503. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77504. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77505. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77506. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77507. readonly DEPTH_COMPONENT32F: number;
  77508. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77509. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77510. 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;
  77511. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77512. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77513. readonly TRANSFORM_FEEDBACK: number;
  77514. readonly INTERLEAVED_ATTRIBS: number;
  77515. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77516. createTransformFeedback(): WebGLTransformFeedback;
  77517. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77518. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77519. beginTransformFeedback(primitiveMode: number): void;
  77520. endTransformFeedback(): void;
  77521. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77522. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77523. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77524. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77525. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77526. }
  77527. interface ImageBitmap {
  77528. readonly width: number;
  77529. readonly height: number;
  77530. close(): void;
  77531. }
  77532. interface WebGLQuery extends WebGLObject {
  77533. }
  77534. declare var WebGLQuery: {
  77535. prototype: WebGLQuery;
  77536. new(): WebGLQuery;
  77537. };
  77538. interface WebGLSampler extends WebGLObject {
  77539. }
  77540. declare var WebGLSampler: {
  77541. prototype: WebGLSampler;
  77542. new(): WebGLSampler;
  77543. };
  77544. interface WebGLSync extends WebGLObject {
  77545. }
  77546. declare var WebGLSync: {
  77547. prototype: WebGLSync;
  77548. new(): WebGLSync;
  77549. };
  77550. interface WebGLTransformFeedback extends WebGLObject {
  77551. }
  77552. declare var WebGLTransformFeedback: {
  77553. prototype: WebGLTransformFeedback;
  77554. new(): WebGLTransformFeedback;
  77555. };
  77556. interface WebGLVertexArrayObject extends WebGLObject {
  77557. }
  77558. declare var WebGLVertexArrayObject: {
  77559. prototype: WebGLVertexArrayObject;
  77560. new(): WebGLVertexArrayObject;
  77561. };
  77562. // Type definitions for WebVR API
  77563. // Project: https://w3c.github.io/webvr/
  77564. // Definitions by: six a <https://github.com/lostfictions>
  77565. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77566. interface VRDisplay extends EventTarget {
  77567. /**
  77568. * Dictionary of capabilities describing the VRDisplay.
  77569. */
  77570. readonly capabilities: VRDisplayCapabilities;
  77571. /**
  77572. * z-depth defining the far plane of the eye view frustum
  77573. * enables mapping of values in the render target depth
  77574. * attachment to scene coordinates. Initially set to 10000.0.
  77575. */
  77576. depthFar: number;
  77577. /**
  77578. * z-depth defining the near plane of the eye view frustum
  77579. * enables mapping of values in the render target depth
  77580. * attachment to scene coordinates. Initially set to 0.01.
  77581. */
  77582. depthNear: number;
  77583. /**
  77584. * An identifier for this distinct VRDisplay. Used as an
  77585. * association point in the Gamepad API.
  77586. */
  77587. readonly displayId: number;
  77588. /**
  77589. * A display name, a user-readable name identifying it.
  77590. */
  77591. readonly displayName: string;
  77592. readonly isConnected: boolean;
  77593. readonly isPresenting: boolean;
  77594. /**
  77595. * If this VRDisplay supports room-scale experiences, the optional
  77596. * stage attribute contains details on the room-scale parameters.
  77597. */
  77598. readonly stageParameters: VRStageParameters | null;
  77599. /**
  77600. * Passing the value returned by `requestAnimationFrame` to
  77601. * `cancelAnimationFrame` will unregister the callback.
  77602. * @param handle Define the hanle of the request to cancel
  77603. */
  77604. cancelAnimationFrame(handle: number): void;
  77605. /**
  77606. * Stops presenting to the VRDisplay.
  77607. * @returns a promise to know when it stopped
  77608. */
  77609. exitPresent(): Promise<void>;
  77610. /**
  77611. * Return the current VREyeParameters for the given eye.
  77612. * @param whichEye Define the eye we want the parameter for
  77613. * @returns the eye parameters
  77614. */
  77615. getEyeParameters(whichEye: string): VREyeParameters;
  77616. /**
  77617. * Populates the passed VRFrameData with the information required to render
  77618. * the current frame.
  77619. * @param frameData Define the data structure to populate
  77620. * @returns true if ok otherwise false
  77621. */
  77622. getFrameData(frameData: VRFrameData): boolean;
  77623. /**
  77624. * Get the layers currently being presented.
  77625. * @returns the list of VR layers
  77626. */
  77627. getLayers(): VRLayer[];
  77628. /**
  77629. * Return a VRPose containing the future predicted pose of the VRDisplay
  77630. * when the current frame will be presented. The value returned will not
  77631. * change until JavaScript has returned control to the browser.
  77632. *
  77633. * The VRPose will contain the position, orientation, velocity,
  77634. * and acceleration of each of these properties.
  77635. * @returns the pose object
  77636. */
  77637. getPose(): VRPose;
  77638. /**
  77639. * Return the current instantaneous pose of the VRDisplay, with no
  77640. * prediction applied.
  77641. * @returns the current instantaneous pose
  77642. */
  77643. getImmediatePose(): VRPose;
  77644. /**
  77645. * The callback passed to `requestAnimationFrame` will be called
  77646. * any time a new frame should be rendered. When the VRDisplay is
  77647. * presenting the callback will be called at the native refresh
  77648. * rate of the HMD. When not presenting this function acts
  77649. * identically to how window.requestAnimationFrame acts. Content should
  77650. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77651. * asynchronously from other displays and at differing refresh rates.
  77652. * @param callback Define the eaction to run next frame
  77653. * @returns the request handle it
  77654. */
  77655. requestAnimationFrame(callback: FrameRequestCallback): number;
  77656. /**
  77657. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77658. * Repeat calls while already presenting will update the VRLayers being displayed.
  77659. * @param layers Define the list of layer to present
  77660. * @returns a promise to know when the request has been fulfilled
  77661. */
  77662. requestPresent(layers: VRLayer[]): Promise<void>;
  77663. /**
  77664. * Reset the pose for this display, treating its current position and
  77665. * orientation as the "origin/zero" values. VRPose.position,
  77666. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77667. * updated when calling resetPose(). This should be called in only
  77668. * sitting-space experiences.
  77669. */
  77670. resetPose(): void;
  77671. /**
  77672. * The VRLayer provided to the VRDisplay will be captured and presented
  77673. * in the HMD. Calling this function has the same effect on the source
  77674. * canvas as any other operation that uses its source image, and canvases
  77675. * created without preserveDrawingBuffer set to true will be cleared.
  77676. * @param pose Define the pose to submit
  77677. */
  77678. submitFrame(pose?: VRPose): void;
  77679. }
  77680. declare var VRDisplay: {
  77681. prototype: VRDisplay;
  77682. new(): VRDisplay;
  77683. };
  77684. interface VRLayer {
  77685. leftBounds?: number[] | Float32Array | null;
  77686. rightBounds?: number[] | Float32Array | null;
  77687. source?: HTMLCanvasElement | null;
  77688. }
  77689. interface VRDisplayCapabilities {
  77690. readonly canPresent: boolean;
  77691. readonly hasExternalDisplay: boolean;
  77692. readonly hasOrientation: boolean;
  77693. readonly hasPosition: boolean;
  77694. readonly maxLayers: number;
  77695. }
  77696. interface VREyeParameters {
  77697. /** @deprecated */
  77698. readonly fieldOfView: VRFieldOfView;
  77699. readonly offset: Float32Array;
  77700. readonly renderHeight: number;
  77701. readonly renderWidth: number;
  77702. }
  77703. interface VRFieldOfView {
  77704. readonly downDegrees: number;
  77705. readonly leftDegrees: number;
  77706. readonly rightDegrees: number;
  77707. readonly upDegrees: number;
  77708. }
  77709. interface VRFrameData {
  77710. readonly leftProjectionMatrix: Float32Array;
  77711. readonly leftViewMatrix: Float32Array;
  77712. readonly pose: VRPose;
  77713. readonly rightProjectionMatrix: Float32Array;
  77714. readonly rightViewMatrix: Float32Array;
  77715. readonly timestamp: number;
  77716. }
  77717. interface VRPose {
  77718. readonly angularAcceleration: Float32Array | null;
  77719. readonly angularVelocity: Float32Array | null;
  77720. readonly linearAcceleration: Float32Array | null;
  77721. readonly linearVelocity: Float32Array | null;
  77722. readonly orientation: Float32Array | null;
  77723. readonly position: Float32Array | null;
  77724. readonly timestamp: number;
  77725. }
  77726. interface VRStageParameters {
  77727. sittingToStandingTransform?: Float32Array;
  77728. sizeX?: number;
  77729. sizeY?: number;
  77730. }
  77731. interface Navigator {
  77732. getVRDisplays(): Promise<VRDisplay[]>;
  77733. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77734. }
  77735. interface Window {
  77736. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77737. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77738. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77739. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77740. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77741. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77742. }
  77743. interface Gamepad {
  77744. readonly displayId: number;
  77745. }
  77746. /**
  77747. * Available session modes
  77748. */
  77749. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77750. /**
  77751. * Reference space types
  77752. */
  77753. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77754. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77755. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77756. /**
  77757. * Handedness types
  77758. */
  77759. type XRHandedness = "none" | "left" | "right";
  77760. /**
  77761. * InputSource target ray modes
  77762. */
  77763. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77764. /**
  77765. * Eye types
  77766. */
  77767. type XREye = "none" | "left" | "right";
  77768. /**
  77769. * Type of XR events available
  77770. */
  77771. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77772. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77773. type XRPlaneSet = Set<XRPlane>;
  77774. type XRAnchorSet = Set<XRAnchor>;
  77775. type XREventHandler = (callback: any) => void;
  77776. interface XRLayer extends EventTarget {}
  77777. interface XRSessionInit {
  77778. optionalFeatures?: string[];
  77779. requiredFeatures?: string[];
  77780. }
  77781. interface XRSessionEvent extends Event {
  77782. readonly session: XRSession;
  77783. }
  77784. interface XRSystem {
  77785. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77786. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77787. }
  77788. interface XRViewport {
  77789. readonly x: number;
  77790. readonly y: number;
  77791. readonly width: number;
  77792. readonly height: number;
  77793. }
  77794. interface XRWebGLLayerInit {
  77795. antialias?: boolean;
  77796. depth?: boolean;
  77797. stencil?: boolean;
  77798. alpha?: boolean;
  77799. multiview?: boolean;
  77800. framebufferScaleFactor?: number;
  77801. }
  77802. declare class XRWebGLLayer {
  77803. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77804. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77805. readonly antialias: boolean;
  77806. readonly framebuffer: WebGLFramebuffer;
  77807. readonly framebufferWidth: number;
  77808. readonly framebufferHeight: number;
  77809. readonly ignoreDepthValues: boolean;
  77810. getViewport: (view: XRView) => XRViewport;
  77811. }
  77812. // tslint:disable-next-line no-empty-interface
  77813. interface XRSpace extends EventTarget {}
  77814. interface XRRenderState {
  77815. readonly baseLayer?: XRWebGLLayer;
  77816. readonly depthFar: number;
  77817. readonly depthNear: number;
  77818. readonly inlineVerticalFieldOfView?: number;
  77819. }
  77820. interface XRRenderStateInit extends XRRenderState {
  77821. baseLayer: XRWebGLLayer;
  77822. depthFar: number;
  77823. depthNear: number;
  77824. inlineVerticalFieldOfView?: number;
  77825. layers?: XRLayer[];
  77826. }
  77827. interface XRReferenceSpace extends XRSpace {
  77828. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77829. onreset: XREventHandler;
  77830. }
  77831. interface XRBoundedReferenceSpace extends XRSpace {
  77832. readonly boundsGeometry: DOMPointReadOnly[];
  77833. }
  77834. interface XRInputSource {
  77835. readonly handedness: XRHandedness;
  77836. readonly targetRayMode: XRTargetRayMode;
  77837. readonly targetRaySpace: XRSpace;
  77838. readonly gripSpace?: XRSpace;
  77839. readonly gamepad?: Gamepad;
  77840. readonly profiles: Array<string>;
  77841. readonly hand?: XRHand;
  77842. }
  77843. interface XRPose {
  77844. readonly transform: XRRigidTransform;
  77845. readonly emulatedPosition: boolean;
  77846. }
  77847. interface XRFrame {
  77848. readonly session: XRSession;
  77849. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77850. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77851. // AR
  77852. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77853. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77854. // Anchors
  77855. trackedAnchors?: XRAnchorSet;
  77856. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77857. // Planes
  77858. worldInformation?: {
  77859. detectedPlanes?: XRPlaneSet;
  77860. };
  77861. // Hand tracking
  77862. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77863. }
  77864. interface XRInputSourceEvent extends Event {
  77865. readonly frame: XRFrame;
  77866. readonly inputSource: XRInputSource;
  77867. }
  77868. type XRInputSourceArray = XRInputSource[];
  77869. interface XRSession {
  77870. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77871. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77872. /**
  77873. * Returns a list of this session's XRInputSources, each representing an input device
  77874. * used to control the camera and/or scene.
  77875. */
  77876. readonly inputSources: Array<XRInputSource>;
  77877. /**
  77878. * object which contains options affecting how the imagery is rendered.
  77879. * This includes things such as the near and far clipping planes
  77880. */
  77881. readonly renderState: XRRenderState;
  77882. readonly visibilityState: XRVisibilityState;
  77883. /**
  77884. * Removes a callback from the animation frame painting callback from
  77885. * XRSession's set of animation frame rendering callbacks, given the
  77886. * identifying handle returned by a previous call to requestAnimationFrame().
  77887. */
  77888. cancelAnimationFrame: (handle: number) => void;
  77889. /**
  77890. * Ends the WebXR session. Returns a promise which resolves when the
  77891. * session has been shut down.
  77892. */
  77893. end(): Promise<void>;
  77894. /**
  77895. * Schedules the specified method to be called the next time the user agent
  77896. * is working on rendering an animation frame for the WebXR device. Returns an
  77897. * integer value which can be used to identify the request for the purposes of
  77898. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77899. * to the Window.requestAnimationFrame() method.
  77900. */
  77901. requestAnimationFrame: XRFrameRequestCallback;
  77902. /**
  77903. * Requests that a new XRReferenceSpace of the specified type be created.
  77904. * Returns a promise which resolves with the XRReferenceSpace or
  77905. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77906. * the requested space type isn't supported by the device.
  77907. */
  77908. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77909. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77910. onend: XREventHandler;
  77911. oninputsourceschange: XREventHandler;
  77912. onselect: XREventHandler;
  77913. onselectstart: XREventHandler;
  77914. onselectend: XREventHandler;
  77915. onsqueeze: XREventHandler;
  77916. onsqueezestart: XREventHandler;
  77917. onsqueezeend: XREventHandler;
  77918. onvisibilitychange: XREventHandler;
  77919. // hit test
  77920. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77921. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77922. // legacy AR hit test
  77923. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77924. // legacy plane detection
  77925. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77926. }
  77927. interface XRViewerPose extends XRPose {
  77928. readonly views: Array<XRView>;
  77929. }
  77930. declare class XRRigidTransform {
  77931. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77932. position: DOMPointReadOnly;
  77933. orientation: DOMPointReadOnly;
  77934. matrix: Float32Array;
  77935. inverse: XRRigidTransform;
  77936. }
  77937. interface XRView {
  77938. readonly eye: XREye;
  77939. readonly projectionMatrix: Float32Array;
  77940. readonly transform: XRRigidTransform;
  77941. readonly recommendedViewportScale?: number;
  77942. requestViewportScale(scale: number): void;
  77943. }
  77944. interface XRInputSourceChangeEvent extends Event {
  77945. session: XRSession;
  77946. removed: Array<XRInputSource>;
  77947. added: Array<XRInputSource>;
  77948. }
  77949. // Experimental/Draft features
  77950. declare class XRRay {
  77951. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77952. origin: DOMPointReadOnly;
  77953. direction: DOMPointReadOnly;
  77954. matrix: Float32Array;
  77955. }
  77956. declare enum XRHitTestTrackableType {
  77957. "point",
  77958. "plane",
  77959. "mesh",
  77960. }
  77961. interface XRHitResult {
  77962. hitMatrix: Float32Array;
  77963. }
  77964. interface XRTransientInputHitTestResult {
  77965. readonly inputSource: XRInputSource;
  77966. readonly results: Array<XRHitTestResult>;
  77967. }
  77968. interface XRHitTestResult {
  77969. getPose(baseSpace: XRSpace): XRPose | undefined;
  77970. // When anchor system is enabled
  77971. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77972. }
  77973. interface XRHitTestSource {
  77974. cancel(): void;
  77975. }
  77976. interface XRTransientInputHitTestSource {
  77977. cancel(): void;
  77978. }
  77979. interface XRHitTestOptionsInit {
  77980. space: XRSpace;
  77981. entityTypes?: Array<XRHitTestTrackableType>;
  77982. offsetRay?: XRRay;
  77983. }
  77984. interface XRTransientInputHitTestOptionsInit {
  77985. profile: string;
  77986. entityTypes?: Array<XRHitTestTrackableType>;
  77987. offsetRay?: XRRay;
  77988. }
  77989. interface XRAnchor {
  77990. anchorSpace: XRSpace;
  77991. delete(): void;
  77992. }
  77993. interface XRPlane {
  77994. orientation: "Horizontal" | "Vertical";
  77995. planeSpace: XRSpace;
  77996. polygon: Array<DOMPointReadOnly>;
  77997. lastChangedTime: number;
  77998. }
  77999. interface XRJointSpace extends XRSpace {}
  78000. interface XRJointPose extends XRPose {
  78001. radius: number | undefined;
  78002. }
  78003. interface XRHand extends Iterable<XRJointSpace> {
  78004. readonly length: number;
  78005. [index: number]: XRJointSpace;
  78006. readonly WRIST: number;
  78007. readonly THUMB_METACARPAL: number;
  78008. readonly THUMB_PHALANX_PROXIMAL: number;
  78009. readonly THUMB_PHALANX_DISTAL: number;
  78010. readonly THUMB_PHALANX_TIP: number;
  78011. readonly INDEX_METACARPAL: number;
  78012. readonly INDEX_PHALANX_PROXIMAL: number;
  78013. readonly INDEX_PHALANX_INTERMEDIATE: number;
  78014. readonly INDEX_PHALANX_DISTAL: number;
  78015. readonly INDEX_PHALANX_TIP: number;
  78016. readonly MIDDLE_METACARPAL: number;
  78017. readonly MIDDLE_PHALANX_PROXIMAL: number;
  78018. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  78019. readonly MIDDLE_PHALANX_DISTAL: number;
  78020. readonly MIDDLE_PHALANX_TIP: number;
  78021. readonly RING_METACARPAL: number;
  78022. readonly RING_PHALANX_PROXIMAL: number;
  78023. readonly RING_PHALANX_INTERMEDIATE: number;
  78024. readonly RING_PHALANX_DISTAL: number;
  78025. readonly RING_PHALANX_TIP: number;
  78026. readonly LITTLE_METACARPAL: number;
  78027. readonly LITTLE_PHALANX_PROXIMAL: number;
  78028. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  78029. readonly LITTLE_PHALANX_DISTAL: number;
  78030. readonly LITTLE_PHALANX_TIP: number;
  78031. }
  78032. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  78033. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  78034. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  78035. interface XRSession {
  78036. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  78037. }
  78038. interface XRFrame {
  78039. featurePointCloud? : Array<number>;
  78040. }
  78041. /**
  78042. * @ignore
  78043. */
  78044. declare module BABYLON.GLTF2.Exporter {
  78045. }
  78046. /**
  78047. * @ignore
  78048. */
  78049. declare module BABYLON.GLTF1 {
  78050. }
  78051. declare module BABYLON.GUI {
  78052. /**
  78053. * Interface used to define a control that can receive focus
  78054. */
  78055. export interface IFocusableControl {
  78056. /**
  78057. * Function called when the control receives the focus
  78058. */
  78059. onFocus(): void;
  78060. /**
  78061. * Function called when the control loses the focus
  78062. */
  78063. onBlur(): void;
  78064. /**
  78065. * Function called to let the control handle keyboard events
  78066. * @param evt defines the current keyboard event
  78067. */
  78068. processKeyboard(evt: KeyboardEvent): void;
  78069. /**
  78070. * Function called to get the list of controls that should not steal the focus from this control
  78071. * @returns an array of controls
  78072. */
  78073. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78074. /**
  78075. * Function to focus the control programmatically
  78076. */
  78077. focus(): void;
  78078. /**
  78079. * Function to unfocus the control programmatically
  78080. */
  78081. blur(): void;
  78082. }
  78083. }
  78084. declare module BABYLON.GUI {
  78085. /**
  78086. * Class used to specific a value and its associated unit
  78087. */
  78088. export class ValueAndUnit {
  78089. /** defines the unit to store */
  78090. unit: number;
  78091. /** defines a boolean indicating if the value can be negative */
  78092. negativeValueAllowed: boolean;
  78093. private _value;
  78094. private _originalUnit;
  78095. /**
  78096. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  78097. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78098. */
  78099. ignoreAdaptiveScaling: boolean;
  78100. /**
  78101. * Creates a new ValueAndUnit
  78102. * @param value defines the value to store
  78103. * @param unit defines the unit to store
  78104. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  78105. */
  78106. constructor(value: number,
  78107. /** defines the unit to store */
  78108. unit?: number,
  78109. /** defines a boolean indicating if the value can be negative */
  78110. negativeValueAllowed?: boolean);
  78111. /** Gets a boolean indicating if the value is a percentage */
  78112. get isPercentage(): boolean;
  78113. /** Gets a boolean indicating if the value is store as pixel */
  78114. get isPixel(): boolean;
  78115. /** Gets direct internal value */
  78116. get internalValue(): number;
  78117. /**
  78118. * Gets value as pixel
  78119. * @param host defines the root host
  78120. * @param refValue defines the reference value for percentages
  78121. * @returns the value as pixel
  78122. */
  78123. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  78124. /**
  78125. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  78126. * @param value defines the value to store
  78127. * @param unit defines the unit to store
  78128. * @returns the current ValueAndUnit
  78129. */
  78130. updateInPlace(value: number, unit?: number): ValueAndUnit;
  78131. /**
  78132. * Gets the value accordingly to its unit
  78133. * @param host defines the root host
  78134. * @returns the value
  78135. */
  78136. getValue(host: AdvancedDynamicTexture): number;
  78137. /**
  78138. * Gets a string representation of the value
  78139. * @param host defines the root host
  78140. * @param decimals defines an optional number of decimals to display
  78141. * @returns a string
  78142. */
  78143. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  78144. /**
  78145. * Store a value parsed from a string
  78146. * @param source defines the source string
  78147. * @returns true if the value was successfully parsed
  78148. */
  78149. fromString(source: string | number): boolean;
  78150. private static _Regex;
  78151. private static _UNITMODE_PERCENTAGE;
  78152. private static _UNITMODE_PIXEL;
  78153. /** UNITMODE_PERCENTAGE */
  78154. static get UNITMODE_PERCENTAGE(): number;
  78155. /** UNITMODE_PIXEL */
  78156. static get UNITMODE_PIXEL(): number;
  78157. }
  78158. }
  78159. declare module BABYLON.GUI {
  78160. /**
  78161. * Define a style used by control to automatically setup properties based on a template.
  78162. * Only support font related properties so far
  78163. */
  78164. export class Style implements BABYLON.IDisposable {
  78165. private _fontFamily;
  78166. private _fontStyle;
  78167. private _fontWeight;
  78168. /** @hidden */
  78169. _host: AdvancedDynamicTexture;
  78170. /** @hidden */
  78171. _fontSize: ValueAndUnit;
  78172. /**
  78173. * BABYLON.Observable raised when the style values are changed
  78174. */
  78175. onChangedObservable: BABYLON.Observable<Style>;
  78176. /**
  78177. * Creates a new style object
  78178. * @param host defines the AdvancedDynamicTexture which hosts this style
  78179. */
  78180. constructor(host: AdvancedDynamicTexture);
  78181. /**
  78182. * Gets or sets the font size
  78183. */
  78184. get fontSize(): string | number;
  78185. set fontSize(value: string | number);
  78186. /**
  78187. * Gets or sets the font family
  78188. */
  78189. get fontFamily(): string;
  78190. set fontFamily(value: string);
  78191. /**
  78192. * Gets or sets the font style
  78193. */
  78194. get fontStyle(): string;
  78195. set fontStyle(value: string);
  78196. /** Gets or sets font weight */
  78197. get fontWeight(): string;
  78198. set fontWeight(value: string);
  78199. /** Dispose all associated resources */
  78200. dispose(): void;
  78201. }
  78202. }
  78203. declare module BABYLON.GUI {
  78204. /**
  78205. * Class used to transport BABYLON.Vector2 information for pointer events
  78206. */
  78207. export class Vector2WithInfo extends BABYLON.Vector2 {
  78208. /** defines the current mouse button index */
  78209. buttonIndex: number;
  78210. /**
  78211. * Creates a new Vector2WithInfo
  78212. * @param source defines the vector2 data to transport
  78213. * @param buttonIndex defines the current mouse button index
  78214. */
  78215. constructor(source: BABYLON.Vector2,
  78216. /** defines the current mouse button index */
  78217. buttonIndex?: number);
  78218. }
  78219. /** Class used to provide 2D matrix features */
  78220. export class Matrix2D {
  78221. /** Gets the internal array of 6 floats used to store matrix data */
  78222. m: Float32Array;
  78223. /**
  78224. * Creates a new matrix
  78225. * @param m00 defines value for (0, 0)
  78226. * @param m01 defines value for (0, 1)
  78227. * @param m10 defines value for (1, 0)
  78228. * @param m11 defines value for (1, 1)
  78229. * @param m20 defines value for (2, 0)
  78230. * @param m21 defines value for (2, 1)
  78231. */
  78232. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  78233. /**
  78234. * Fills the matrix from direct values
  78235. * @param m00 defines value for (0, 0)
  78236. * @param m01 defines value for (0, 1)
  78237. * @param m10 defines value for (1, 0)
  78238. * @param m11 defines value for (1, 1)
  78239. * @param m20 defines value for (2, 0)
  78240. * @param m21 defines value for (2, 1)
  78241. * @returns the current modified matrix
  78242. */
  78243. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  78244. /**
  78245. * Gets matrix determinant
  78246. * @returns the determinant
  78247. */
  78248. determinant(): number;
  78249. /**
  78250. * Inverses the matrix and stores it in a target matrix
  78251. * @param result defines the target matrix
  78252. * @returns the current matrix
  78253. */
  78254. invertToRef(result: Matrix2D): Matrix2D;
  78255. /**
  78256. * Multiplies the current matrix with another one
  78257. * @param other defines the second operand
  78258. * @param result defines the target matrix
  78259. * @returns the current matrix
  78260. */
  78261. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  78262. /**
  78263. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  78264. * @param x defines the x coordinate to transform
  78265. * @param y defines the x coordinate to transform
  78266. * @param result defines the target vector2
  78267. * @returns the current matrix
  78268. */
  78269. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  78270. /**
  78271. * Creates an identity matrix
  78272. * @returns a new matrix
  78273. */
  78274. static Identity(): Matrix2D;
  78275. /**
  78276. * Creates a translation matrix and stores it in a target matrix
  78277. * @param x defines the x coordinate of the translation
  78278. * @param y defines the y coordinate of the translation
  78279. * @param result defines the target matrix
  78280. */
  78281. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  78282. /**
  78283. * Creates a scaling matrix and stores it in a target matrix
  78284. * @param x defines the x coordinate of the scaling
  78285. * @param y defines the y coordinate of the scaling
  78286. * @param result defines the target matrix
  78287. */
  78288. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  78289. /**
  78290. * Creates a rotation matrix and stores it in a target matrix
  78291. * @param angle defines the rotation angle
  78292. * @param result defines the target matrix
  78293. */
  78294. static RotationToRef(angle: number, result: Matrix2D): void;
  78295. private static _TempPreTranslationMatrix;
  78296. private static _TempPostTranslationMatrix;
  78297. private static _TempRotationMatrix;
  78298. private static _TempScalingMatrix;
  78299. private static _TempCompose0;
  78300. private static _TempCompose1;
  78301. private static _TempCompose2;
  78302. /**
  78303. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  78304. * @param tx defines the x coordinate of the translation
  78305. * @param ty defines the y coordinate of the translation
  78306. * @param angle defines the rotation angle
  78307. * @param scaleX defines the x coordinate of the scaling
  78308. * @param scaleY defines the y coordinate of the scaling
  78309. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  78310. * @param result defines the target matrix
  78311. */
  78312. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  78313. }
  78314. }
  78315. declare module BABYLON.GUI {
  78316. /**
  78317. * Class used to store 2D control sizes
  78318. */
  78319. export class Measure {
  78320. /** defines left coordinate */
  78321. left: number;
  78322. /** defines top coordinate */
  78323. top: number;
  78324. /** defines width dimension */
  78325. width: number;
  78326. /** defines height dimension */
  78327. height: number;
  78328. /**
  78329. * Creates a new measure
  78330. * @param left defines left coordinate
  78331. * @param top defines top coordinate
  78332. * @param width defines width dimension
  78333. * @param height defines height dimension
  78334. */
  78335. constructor(
  78336. /** defines left coordinate */
  78337. left: number,
  78338. /** defines top coordinate */
  78339. top: number,
  78340. /** defines width dimension */
  78341. width: number,
  78342. /** defines height dimension */
  78343. height: number);
  78344. /**
  78345. * Copy from another measure
  78346. * @param other defines the other measure to copy from
  78347. */
  78348. copyFrom(other: Measure): void;
  78349. /**
  78350. * Copy from a group of 4 floats
  78351. * @param left defines left coordinate
  78352. * @param top defines top coordinate
  78353. * @param width defines width dimension
  78354. * @param height defines height dimension
  78355. */
  78356. copyFromFloats(left: number, top: number, width: number, height: number): void;
  78357. /**
  78358. * Computes the axis aligned bounding box measure for two given measures
  78359. * @param a Input measure
  78360. * @param b Input measure
  78361. * @param result the resulting bounding measure
  78362. */
  78363. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  78364. /**
  78365. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78366. * @param transform the matrix to transform the measure before computing the AABB
  78367. * @param addX number to add to left
  78368. * @param addY number to add to top
  78369. * @param addWidth number to add to width
  78370. * @param addHeight number to add to height
  78371. * @param result the resulting AABB
  78372. */
  78373. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  78374. /**
  78375. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78376. * @param transform the matrix to transform the measure before computing the AABB
  78377. * @param result the resulting AABB
  78378. */
  78379. transformToRef(transform: Matrix2D, result: Measure): void;
  78380. /**
  78381. * Check equality between this measure and another one
  78382. * @param other defines the other measures
  78383. * @returns true if both measures are equals
  78384. */
  78385. isEqualsTo(other: Measure): boolean;
  78386. /**
  78387. * Creates an empty measure
  78388. * @returns a new measure
  78389. */
  78390. static Empty(): Measure;
  78391. }
  78392. }
  78393. declare module BABYLON.GUI {
  78394. /**
  78395. * Class used to create texture to support 2D GUI elements
  78396. * @see https://doc.babylonjs.com/how_to/gui
  78397. */
  78398. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  78399. private _isDirty;
  78400. private _renderObserver;
  78401. private _resizeObserver;
  78402. private _preKeyboardObserver;
  78403. private _pointerMoveObserver;
  78404. private _pointerObserver;
  78405. private _canvasPointerOutObserver;
  78406. private _canvasBlurObserver;
  78407. private _background;
  78408. /** @hidden */
  78409. _rootContainer: Container;
  78410. /** @hidden */
  78411. _lastPickedControl: Control;
  78412. /** @hidden */
  78413. _lastControlOver: {
  78414. [pointerId: number]: Control;
  78415. };
  78416. /** @hidden */
  78417. _lastControlDown: {
  78418. [pointerId: number]: Control;
  78419. };
  78420. /** @hidden */
  78421. _capturingControl: {
  78422. [pointerId: number]: Control;
  78423. };
  78424. /** @hidden */
  78425. _shouldBlockPointer: boolean;
  78426. /** @hidden */
  78427. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  78428. /** @hidden */
  78429. _linkedControls: Control[];
  78430. private _isFullscreen;
  78431. private _fullscreenViewport;
  78432. private _idealWidth;
  78433. private _idealHeight;
  78434. private _useSmallestIdeal;
  78435. private _renderAtIdealSize;
  78436. private _focusedControl;
  78437. private _blockNextFocusCheck;
  78438. private _renderScale;
  78439. private _rootElement;
  78440. private _cursorChanged;
  78441. private _defaultMousePointerId;
  78442. /** @hidden */
  78443. _numLayoutCalls: number;
  78444. /** Gets the number of layout calls made the last time the ADT has been rendered */
  78445. get numLayoutCalls(): number;
  78446. /** @hidden */
  78447. _numRenderCalls: number;
  78448. /** Gets the number of render calls made the last time the ADT has been rendered */
  78449. get numRenderCalls(): number;
  78450. /**
  78451. * Define type to string to ensure compatibility across browsers
  78452. * Safari doesn't support DataTransfer constructor
  78453. */
  78454. private _clipboardData;
  78455. /**
  78456. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  78457. */
  78458. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  78459. /**
  78460. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  78461. */
  78462. onControlPickedObservable: BABYLON.Observable<Control>;
  78463. /**
  78464. * BABYLON.Observable event triggered before layout is evaluated
  78465. */
  78466. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78467. /**
  78468. * BABYLON.Observable event triggered after the layout was evaluated
  78469. */
  78470. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78471. /**
  78472. * BABYLON.Observable event triggered before the texture is rendered
  78473. */
  78474. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78475. /**
  78476. * BABYLON.Observable event triggered after the texture was rendered
  78477. */
  78478. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78479. /**
  78480. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78481. */
  78482. premulAlpha: boolean;
  78483. /**
  78484. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  78485. */
  78486. applyYInversionOnUpdate: boolean;
  78487. /**
  78488. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78489. * Useful when you want more antialiasing
  78490. */
  78491. get renderScale(): number;
  78492. set renderScale(value: number);
  78493. /** Gets or sets the background color */
  78494. get background(): string;
  78495. set background(value: string);
  78496. /**
  78497. * Gets or sets the ideal width used to design controls.
  78498. * The GUI will then rescale everything accordingly
  78499. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78500. */
  78501. get idealWidth(): number;
  78502. set idealWidth(value: number);
  78503. /**
  78504. * Gets or sets the ideal height used to design controls.
  78505. * The GUI will then rescale everything accordingly
  78506. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78507. */
  78508. get idealHeight(): number;
  78509. set idealHeight(value: number);
  78510. /**
  78511. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78512. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78513. */
  78514. get useSmallestIdeal(): boolean;
  78515. set useSmallestIdeal(value: boolean);
  78516. /**
  78517. * Gets or sets a boolean indicating if adaptive scaling must be used
  78518. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78519. */
  78520. get renderAtIdealSize(): boolean;
  78521. set renderAtIdealSize(value: boolean);
  78522. /**
  78523. * Gets the ratio used when in "ideal mode"
  78524. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78525. * */
  78526. get idealRatio(): number;
  78527. /**
  78528. * Gets the underlying layer used to render the texture when in fullscreen mode
  78529. */
  78530. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78531. /**
  78532. * Gets the root container control
  78533. */
  78534. get rootContainer(): Container;
  78535. /**
  78536. * Returns an array containing the root container.
  78537. * This is mostly used to let the Inspector introspects the ADT
  78538. * @returns an array containing the rootContainer
  78539. */
  78540. getChildren(): Array<Container>;
  78541. /**
  78542. * Will return all controls that are inside this texture
  78543. * @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
  78544. * @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
  78545. * @return all child controls
  78546. */
  78547. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78548. /**
  78549. * Gets or sets the current focused control
  78550. */
  78551. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78552. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78553. /**
  78554. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78555. */
  78556. get isForeground(): boolean;
  78557. set isForeground(value: boolean);
  78558. /**
  78559. * Gets or set information about clipboardData
  78560. */
  78561. get clipboardData(): string;
  78562. set clipboardData(value: string);
  78563. /**
  78564. * Creates a new AdvancedDynamicTexture
  78565. * @param name defines the name of the texture
  78566. * @param width defines the width of the texture
  78567. * @param height defines the height of the texture
  78568. * @param scene defines the hosting scene
  78569. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78570. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78571. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78572. */
  78573. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78574. /**
  78575. * Get the current class name of the texture useful for serialization or dynamic coding.
  78576. * @returns "AdvancedDynamicTexture"
  78577. */
  78578. getClassName(): string;
  78579. /**
  78580. * Function used to execute a function on all controls
  78581. * @param func defines the function to execute
  78582. * @param container defines the container where controls belong. If null the root container will be used
  78583. */
  78584. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78585. private _useInvalidateRectOptimization;
  78586. /**
  78587. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78588. */
  78589. get useInvalidateRectOptimization(): boolean;
  78590. set useInvalidateRectOptimization(value: boolean);
  78591. private _invalidatedRectangle;
  78592. /**
  78593. * Invalidates a rectangle area on the gui texture
  78594. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78595. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78596. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78597. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78598. */
  78599. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78600. /**
  78601. * Marks the texture as dirty forcing a complete update
  78602. */
  78603. markAsDirty(): void;
  78604. /**
  78605. * Helper function used to create a new style
  78606. * @returns a new style
  78607. * @see https://doc.babylonjs.com/how_to/gui#styles
  78608. */
  78609. createStyle(): Style;
  78610. /**
  78611. * Adds a new control to the root container
  78612. * @param control defines the control to add
  78613. * @returns the current texture
  78614. */
  78615. addControl(control: Control): AdvancedDynamicTexture;
  78616. /**
  78617. * Removes a control from the root container
  78618. * @param control defines the control to remove
  78619. * @returns the current texture
  78620. */
  78621. removeControl(control: Control): AdvancedDynamicTexture;
  78622. /**
  78623. * Release all resources
  78624. */
  78625. dispose(): void;
  78626. private _onResize;
  78627. /** @hidden */
  78628. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78629. /**
  78630. * Get screen coordinates for a vector3
  78631. * @param position defines the position to project
  78632. * @param worldMatrix defines the world matrix to use
  78633. * @returns the projected position
  78634. */
  78635. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78636. /**
  78637. * Get screen coordinates for a vector3
  78638. * @param position defines the position to project
  78639. * @param worldMatrix defines the world matrix to use
  78640. * @returns the projected position with Z
  78641. */
  78642. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  78643. private _checkUpdate;
  78644. private _clearMeasure;
  78645. private _render;
  78646. /** @hidden */
  78647. _changeCursor(cursor: string): void;
  78648. /** @hidden */
  78649. _registerLastControlDown(control: Control, pointerId: number): void;
  78650. private _doPicking;
  78651. /** @hidden */
  78652. _cleanControlAfterRemovalFromList(list: {
  78653. [pointerId: number]: Control;
  78654. }, control: Control): void;
  78655. /** @hidden */
  78656. _cleanControlAfterRemoval(control: Control): void;
  78657. /** Attach to all scene events required to support pointer events */
  78658. attach(): void;
  78659. /** @hidden */
  78660. private onClipboardCopy;
  78661. /** @hidden */
  78662. private onClipboardCut;
  78663. /** @hidden */
  78664. private onClipboardPaste;
  78665. /**
  78666. * Register the clipboard Events onto the canvas
  78667. */
  78668. registerClipboardEvents(): void;
  78669. /**
  78670. * Unregister the clipboard Events from the canvas
  78671. */
  78672. unRegisterClipboardEvents(): void;
  78673. /**
  78674. * Connect the texture to a hosting mesh to enable interactions
  78675. * @param mesh defines the mesh to attach to
  78676. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78677. */
  78678. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78679. /**
  78680. * Move the focus to a specific control
  78681. * @param control defines the control which will receive the focus
  78682. */
  78683. moveFocusToControl(control: IFocusableControl): void;
  78684. private _manageFocus;
  78685. private _attachToOnPointerOut;
  78686. private _attachToOnBlur;
  78687. /**
  78688. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78689. * @param mesh defines the mesh which will receive the texture
  78690. * @param width defines the texture width (1024 by default)
  78691. * @param height defines the texture height (1024 by default)
  78692. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78693. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78694. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78695. * @returns a new AdvancedDynamicTexture
  78696. */
  78697. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78698. /**
  78699. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh) BUT do not create a new material for the mesh. You will be responsible for connecting the texture
  78700. * @param mesh defines the mesh which will receive the texture
  78701. * @param width defines the texture width (1024 by default)
  78702. * @param height defines the texture height (1024 by default)
  78703. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78704. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78705. * @returns a new AdvancedDynamicTexture
  78706. */
  78707. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78708. /**
  78709. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78710. * In this mode the texture will rely on a layer for its rendering.
  78711. * This allows it to be treated like any other layer.
  78712. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78713. * LayerMask is set through advancedTexture.layer.layerMask
  78714. * @param name defines name for the texture
  78715. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78716. * @param scene defines the hsoting scene
  78717. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78718. * @returns a new AdvancedDynamicTexture
  78719. */
  78720. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78721. }
  78722. }
  78723. declare module BABYLON.GUI {
  78724. /**
  78725. * Root class used for all 2D controls
  78726. * @see https://doc.babylonjs.com/how_to/gui#controls
  78727. */
  78728. export class Control {
  78729. /** defines the name of the control */
  78730. name?: string | undefined;
  78731. /**
  78732. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78733. */
  78734. static AllowAlphaInheritance: boolean;
  78735. private _alpha;
  78736. private _alphaSet;
  78737. private _zIndex;
  78738. /** @hidden */
  78739. _host: AdvancedDynamicTexture;
  78740. /** Gets or sets the control parent */
  78741. parent: BABYLON.Nullable<Container>;
  78742. /** @hidden */
  78743. _currentMeasure: Measure;
  78744. private _fontFamily;
  78745. private _fontStyle;
  78746. private _fontWeight;
  78747. private _fontSize;
  78748. private _font;
  78749. /** @hidden */
  78750. _width: ValueAndUnit;
  78751. /** @hidden */
  78752. _height: ValueAndUnit;
  78753. /** @hidden */
  78754. protected _fontOffset: {
  78755. ascent: number;
  78756. height: number;
  78757. descent: number;
  78758. };
  78759. private _color;
  78760. private _style;
  78761. private _styleObserver;
  78762. /** @hidden */
  78763. protected _horizontalAlignment: number;
  78764. /** @hidden */
  78765. protected _verticalAlignment: number;
  78766. /** @hidden */
  78767. protected _isDirty: boolean;
  78768. /** @hidden */
  78769. protected _wasDirty: boolean;
  78770. /** @hidden */
  78771. _tempParentMeasure: Measure;
  78772. /** @hidden */
  78773. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78774. /** @hidden */
  78775. protected _cachedParentMeasure: Measure;
  78776. private _paddingLeft;
  78777. private _paddingRight;
  78778. private _paddingTop;
  78779. private _paddingBottom;
  78780. /** @hidden */
  78781. _left: ValueAndUnit;
  78782. /** @hidden */
  78783. _top: ValueAndUnit;
  78784. private _scaleX;
  78785. private _scaleY;
  78786. private _rotation;
  78787. private _transformCenterX;
  78788. private _transformCenterY;
  78789. /** @hidden */
  78790. _transformMatrix: Matrix2D;
  78791. /** @hidden */
  78792. protected _invertTransformMatrix: Matrix2D;
  78793. /** @hidden */
  78794. protected _transformedPosition: BABYLON.Vector2;
  78795. private _isMatrixDirty;
  78796. private _cachedOffsetX;
  78797. private _cachedOffsetY;
  78798. private _isVisible;
  78799. private _isHighlighted;
  78800. /** @hidden */
  78801. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78802. private _fontSet;
  78803. private _dummyVector2;
  78804. private _downCount;
  78805. private _enterCount;
  78806. private _doNotRender;
  78807. private _downPointerIds;
  78808. protected _isEnabled: boolean;
  78809. protected _disabledColor: string;
  78810. protected _disabledColorItem: string;
  78811. /** @hidden */
  78812. protected _rebuildLayout: boolean;
  78813. /** @hidden */
  78814. _customData: any;
  78815. /** @hidden */
  78816. _isClipped: boolean;
  78817. /** @hidden */
  78818. _automaticSize: boolean;
  78819. /** @hidden */
  78820. _tag: any;
  78821. /**
  78822. * 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
  78823. */
  78824. uniqueId: number;
  78825. /**
  78826. * Gets or sets an object used to store user defined information for the node
  78827. */
  78828. metadata: any;
  78829. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78830. isHitTestVisible: boolean;
  78831. /** Gets or sets a boolean indicating if the control can block pointer events */
  78832. isPointerBlocker: boolean;
  78833. /** Gets or sets a boolean indicating if the control can be focusable */
  78834. isFocusInvisible: boolean;
  78835. /**
  78836. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78837. * 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
  78838. */
  78839. clipChildren: boolean;
  78840. /**
  78841. * Gets or sets a boolean indicating that control content must be clipped
  78842. * 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
  78843. */
  78844. clipContent: boolean;
  78845. /**
  78846. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78847. */
  78848. useBitmapCache: boolean;
  78849. private _cacheData;
  78850. private _shadowOffsetX;
  78851. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78852. get shadowOffsetX(): number;
  78853. set shadowOffsetX(value: number);
  78854. private _shadowOffsetY;
  78855. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78856. get shadowOffsetY(): number;
  78857. set shadowOffsetY(value: number);
  78858. private _shadowBlur;
  78859. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78860. get shadowBlur(): number;
  78861. set shadowBlur(value: number);
  78862. private _shadowColor;
  78863. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78864. get shadowColor(): string;
  78865. set shadowColor(value: string);
  78866. /** Gets or sets the cursor to use when the control is hovered */
  78867. hoverCursor: string;
  78868. /** @hidden */
  78869. protected _linkOffsetX: ValueAndUnit;
  78870. /** @hidden */
  78871. protected _linkOffsetY: ValueAndUnit;
  78872. /** Gets the control type name */
  78873. get typeName(): string;
  78874. /**
  78875. * Get the current class name of the control.
  78876. * @returns current class name
  78877. */
  78878. getClassName(): string;
  78879. /**
  78880. * An event triggered when pointer wheel is scrolled
  78881. */
  78882. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78883. /**
  78884. * An event triggered when the pointer move over the control.
  78885. */
  78886. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78887. /**
  78888. * An event triggered when the pointer move out of the control.
  78889. */
  78890. onPointerOutObservable: BABYLON.Observable<Control>;
  78891. /**
  78892. * An event triggered when the pointer taps the control
  78893. */
  78894. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78895. /**
  78896. * An event triggered when pointer up
  78897. */
  78898. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78899. /**
  78900. * An event triggered when a control is clicked on
  78901. */
  78902. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78903. /**
  78904. * An event triggered when pointer enters the control
  78905. */
  78906. onPointerEnterObservable: BABYLON.Observable<Control>;
  78907. /**
  78908. * An event triggered when the control is marked as dirty
  78909. */
  78910. onDirtyObservable: BABYLON.Observable<Control>;
  78911. /**
  78912. * An event triggered before drawing the control
  78913. */
  78914. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78915. /**
  78916. * An event triggered after the control was drawn
  78917. */
  78918. onAfterDrawObservable: BABYLON.Observable<Control>;
  78919. /**
  78920. * An event triggered when the control has been disposed
  78921. */
  78922. onDisposeObservable: BABYLON.Observable<Control>;
  78923. /**
  78924. * Get the hosting AdvancedDynamicTexture
  78925. */
  78926. get host(): AdvancedDynamicTexture;
  78927. /** Gets or set information about font offsets (used to render and align text) */
  78928. get fontOffset(): {
  78929. ascent: number;
  78930. height: number;
  78931. descent: number;
  78932. };
  78933. set fontOffset(offset: {
  78934. ascent: number;
  78935. height: number;
  78936. descent: number;
  78937. });
  78938. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78939. get alpha(): number;
  78940. set alpha(value: number);
  78941. /**
  78942. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78943. */
  78944. get isHighlighted(): boolean;
  78945. set isHighlighted(value: boolean);
  78946. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78947. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78948. */
  78949. get scaleX(): number;
  78950. set scaleX(value: number);
  78951. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78952. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78953. */
  78954. get scaleY(): number;
  78955. set scaleY(value: number);
  78956. /** Gets or sets the rotation angle (0 by default)
  78957. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78958. */
  78959. get rotation(): number;
  78960. set rotation(value: number);
  78961. /** Gets or sets the transformation center on Y axis (0 by default)
  78962. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78963. */
  78964. get transformCenterY(): number;
  78965. set transformCenterY(value: number);
  78966. /** Gets or sets the transformation center on X axis (0 by default)
  78967. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78968. */
  78969. get transformCenterX(): number;
  78970. set transformCenterX(value: number);
  78971. /**
  78972. * Gets or sets the horizontal alignment
  78973. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78974. */
  78975. get horizontalAlignment(): number;
  78976. set horizontalAlignment(value: number);
  78977. /**
  78978. * Gets or sets the vertical alignment
  78979. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78980. */
  78981. get verticalAlignment(): number;
  78982. set verticalAlignment(value: number);
  78983. /**
  78984. * Gets or sets a fixed ratio for this control.
  78985. * When different from 0, the ratio is used to compute the "second" dimension.
  78986. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78987. * second dimension is computed as first dimension * fixedRatio
  78988. */
  78989. fixedRatio: number;
  78990. private _fixedRatioMasterIsWidth;
  78991. /**
  78992. * Gets or sets control width
  78993. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78994. */
  78995. get width(): string | number;
  78996. set width(value: string | number);
  78997. /**
  78998. * Gets or sets the control width in pixel
  78999. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79000. */
  79001. get widthInPixels(): number;
  79002. set widthInPixels(value: number);
  79003. /**
  79004. * Gets or sets control height
  79005. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79006. */
  79007. get height(): string | number;
  79008. set height(value: string | number);
  79009. /**
  79010. * Gets or sets control height in pixel
  79011. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79012. */
  79013. get heightInPixels(): number;
  79014. set heightInPixels(value: number);
  79015. /** Gets or set font family */
  79016. get fontFamily(): string;
  79017. set fontFamily(value: string);
  79018. /** Gets or sets font style */
  79019. get fontStyle(): string;
  79020. set fontStyle(value: string);
  79021. /** Gets or sets font weight */
  79022. get fontWeight(): string;
  79023. set fontWeight(value: string);
  79024. /**
  79025. * Gets or sets style
  79026. * @see https://doc.babylonjs.com/how_to/gui#styles
  79027. */
  79028. get style(): BABYLON.Nullable<Style>;
  79029. set style(value: BABYLON.Nullable<Style>);
  79030. /** @hidden */
  79031. get _isFontSizeInPercentage(): boolean;
  79032. /** Gets or sets font size in pixels */
  79033. get fontSizeInPixels(): number;
  79034. set fontSizeInPixels(value: number);
  79035. /** Gets or sets font size */
  79036. get fontSize(): string | number;
  79037. set fontSize(value: string | number);
  79038. /** Gets or sets foreground color */
  79039. get color(): string;
  79040. set color(value: string);
  79041. /** Gets or sets z index which is used to reorder controls on the z axis */
  79042. get zIndex(): number;
  79043. set zIndex(value: number);
  79044. /** Gets or sets a boolean indicating if the control can be rendered */
  79045. get notRenderable(): boolean;
  79046. set notRenderable(value: boolean);
  79047. /** Gets or sets a boolean indicating if the control is visible */
  79048. get isVisible(): boolean;
  79049. set isVisible(value: boolean);
  79050. /** Gets a boolean indicating that the control needs to update its rendering */
  79051. get isDirty(): boolean;
  79052. /**
  79053. * Gets the current linked mesh (or null if none)
  79054. */
  79055. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  79056. /**
  79057. * Gets or sets a value indicating the padding to use on the left of the control
  79058. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79059. */
  79060. get paddingLeft(): string | number;
  79061. set paddingLeft(value: string | number);
  79062. /**
  79063. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  79064. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79065. */
  79066. get paddingLeftInPixels(): number;
  79067. set paddingLeftInPixels(value: number);
  79068. /**
  79069. * Gets or sets a value indicating the padding to use on the right of the control
  79070. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79071. */
  79072. get paddingRight(): string | number;
  79073. set paddingRight(value: string | number);
  79074. /**
  79075. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  79076. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79077. */
  79078. get paddingRightInPixels(): number;
  79079. set paddingRightInPixels(value: number);
  79080. /**
  79081. * Gets or sets a value indicating the padding to use on the top of the control
  79082. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79083. */
  79084. get paddingTop(): string | number;
  79085. set paddingTop(value: string | number);
  79086. /**
  79087. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  79088. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79089. */
  79090. get paddingTopInPixels(): number;
  79091. set paddingTopInPixels(value: number);
  79092. /**
  79093. * Gets or sets a value indicating the padding to use on the bottom of the control
  79094. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79095. */
  79096. get paddingBottom(): string | number;
  79097. set paddingBottom(value: string | number);
  79098. /**
  79099. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  79100. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79101. */
  79102. get paddingBottomInPixels(): number;
  79103. set paddingBottomInPixels(value: number);
  79104. /**
  79105. * Gets or sets a value indicating the left coordinate of the control
  79106. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79107. */
  79108. get left(): string | number;
  79109. set left(value: string | number);
  79110. /**
  79111. * Gets or sets a value indicating the left coordinate in pixels of the control
  79112. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79113. */
  79114. get leftInPixels(): number;
  79115. set leftInPixels(value: number);
  79116. /**
  79117. * Gets or sets a value indicating the top coordinate of the control
  79118. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79119. */
  79120. get top(): string | number;
  79121. set top(value: string | number);
  79122. /**
  79123. * Gets or sets a value indicating the top coordinate in pixels of the control
  79124. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79125. */
  79126. get topInPixels(): number;
  79127. set topInPixels(value: number);
  79128. /**
  79129. * Gets or sets a value indicating the offset on X axis to the linked mesh
  79130. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79131. */
  79132. get linkOffsetX(): string | number;
  79133. set linkOffsetX(value: string | number);
  79134. /**
  79135. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  79136. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79137. */
  79138. get linkOffsetXInPixels(): number;
  79139. set linkOffsetXInPixels(value: number);
  79140. /**
  79141. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  79142. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79143. */
  79144. get linkOffsetY(): string | number;
  79145. set linkOffsetY(value: string | number);
  79146. /**
  79147. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  79148. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79149. */
  79150. get linkOffsetYInPixels(): number;
  79151. set linkOffsetYInPixels(value: number);
  79152. /** Gets the center coordinate on X axis */
  79153. get centerX(): number;
  79154. /** Gets the center coordinate on Y axis */
  79155. get centerY(): number;
  79156. /** Gets or sets if control is Enabled*/
  79157. get isEnabled(): boolean;
  79158. set isEnabled(value: boolean);
  79159. /** Gets or sets background color of control if it's disabled*/
  79160. get disabledColor(): string;
  79161. set disabledColor(value: string);
  79162. /** Gets or sets front color of control if it's disabled*/
  79163. get disabledColorItem(): string;
  79164. set disabledColorItem(value: string);
  79165. /**
  79166. * Creates a new control
  79167. * @param name defines the name of the control
  79168. */
  79169. constructor(
  79170. /** defines the name of the control */
  79171. name?: string | undefined);
  79172. /** @hidden */
  79173. protected _getTypeName(): string;
  79174. /**
  79175. * Gets the first ascendant in the hierarchy of the given type
  79176. * @param className defines the required type
  79177. * @returns the ascendant or null if not found
  79178. */
  79179. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  79180. /** @hidden */
  79181. _resetFontCache(): void;
  79182. /**
  79183. * Determines if a container is an ascendant of the current control
  79184. * @param container defines the container to look for
  79185. * @returns true if the container is one of the ascendant of the control
  79186. */
  79187. isAscendant(container: Control): boolean;
  79188. /**
  79189. * Gets coordinates in local control space
  79190. * @param globalCoordinates defines the coordinates to transform
  79191. * @returns the new coordinates in local space
  79192. */
  79193. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79194. /**
  79195. * Gets coordinates in local control space
  79196. * @param globalCoordinates defines the coordinates to transform
  79197. * @param result defines the target vector2 where to store the result
  79198. * @returns the current control
  79199. */
  79200. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  79201. /**
  79202. * Gets coordinates in parent local control space
  79203. * @param globalCoordinates defines the coordinates to transform
  79204. * @returns the new coordinates in parent local space
  79205. */
  79206. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79207. /**
  79208. * Move the current control to a vector3 position projected onto the screen.
  79209. * @param position defines the target position
  79210. * @param scene defines the hosting scene
  79211. */
  79212. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  79213. /**
  79214. * Will store all controls that have this control as ascendant in a given array
  79215. * @param results defines the array where to store the descendants
  79216. * @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
  79217. * @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
  79218. */
  79219. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79220. /**
  79221. * Will return all controls that have this control as ascendant
  79222. * @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
  79223. * @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
  79224. * @return all child controls
  79225. */
  79226. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  79227. /**
  79228. * Link current control with a target mesh
  79229. * @param mesh defines the mesh to link with
  79230. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79231. */
  79232. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  79233. /** @hidden */
  79234. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  79235. /** @hidden */
  79236. _offsetLeft(offset: number): void;
  79237. /** @hidden */
  79238. _offsetTop(offset: number): void;
  79239. /** @hidden */
  79240. _markMatrixAsDirty(): void;
  79241. /** @hidden */
  79242. _flagDescendantsAsMatrixDirty(): void;
  79243. /** @hidden */
  79244. _intersectsRect(rect: Measure): boolean;
  79245. /** @hidden */
  79246. protected invalidateRect(): void;
  79247. /** @hidden */
  79248. _markAsDirty(force?: boolean): void;
  79249. /** @hidden */
  79250. _markAllAsDirty(): void;
  79251. /** @hidden */
  79252. _link(host: AdvancedDynamicTexture): void;
  79253. /** @hidden */
  79254. protected _transform(context?: CanvasRenderingContext2D): void;
  79255. /** @hidden */
  79256. _renderHighlight(context: CanvasRenderingContext2D): void;
  79257. /** @hidden */
  79258. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79259. /** @hidden */
  79260. protected _applyStates(context: CanvasRenderingContext2D): void;
  79261. /** @hidden */
  79262. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79263. /** @hidden */
  79264. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79265. protected _evaluateClippingState(parentMeasure: Measure): void;
  79266. /** @hidden */
  79267. _measure(): void;
  79268. /** @hidden */
  79269. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79270. /** @hidden */
  79271. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79272. /** @hidden */
  79273. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79274. /** @hidden */
  79275. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79276. private static _ClipMeasure;
  79277. private _tmpMeasureA;
  79278. private _clip;
  79279. /** @hidden */
  79280. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  79281. /** @hidden */
  79282. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79283. /**
  79284. * Tests if a given coordinates belong to the current control
  79285. * @param x defines x coordinate to test
  79286. * @param y defines y coordinate to test
  79287. * @returns true if the coordinates are inside the control
  79288. */
  79289. contains(x: number, y: number): boolean;
  79290. /** @hidden */
  79291. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79292. /** @hidden */
  79293. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79294. /** @hidden */
  79295. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79296. /** @hidden */
  79297. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  79298. /** @hidden */
  79299. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79300. /** @hidden */
  79301. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  79302. /** @hidden */
  79303. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79304. /** @hidden */
  79305. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  79306. /** @hidden */
  79307. _onCanvasBlur(): void;
  79308. /** @hidden */
  79309. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79310. private _prepareFont;
  79311. /** Releases associated resources */
  79312. dispose(): void;
  79313. private static _HORIZONTAL_ALIGNMENT_LEFT;
  79314. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  79315. private static _HORIZONTAL_ALIGNMENT_CENTER;
  79316. private static _VERTICAL_ALIGNMENT_TOP;
  79317. private static _VERTICAL_ALIGNMENT_BOTTOM;
  79318. private static _VERTICAL_ALIGNMENT_CENTER;
  79319. /** HORIZONTAL_ALIGNMENT_LEFT */
  79320. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  79321. /** HORIZONTAL_ALIGNMENT_RIGHT */
  79322. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  79323. /** HORIZONTAL_ALIGNMENT_CENTER */
  79324. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  79325. /** VERTICAL_ALIGNMENT_TOP */
  79326. static get VERTICAL_ALIGNMENT_TOP(): number;
  79327. /** VERTICAL_ALIGNMENT_BOTTOM */
  79328. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  79329. /** VERTICAL_ALIGNMENT_CENTER */
  79330. static get VERTICAL_ALIGNMENT_CENTER(): number;
  79331. private static _FontHeightSizes;
  79332. /** @hidden */
  79333. static _GetFontOffset(font: string): {
  79334. ascent: number;
  79335. height: number;
  79336. descent: number;
  79337. };
  79338. /**
  79339. * Creates a stack panel that can be used to render headers
  79340. * @param control defines the control to associate with the header
  79341. * @param text defines the text of the header
  79342. * @param size defines the size of the header
  79343. * @param options defines options used to configure the header
  79344. * @returns a new StackPanel
  79345. * @ignore
  79346. * @hidden
  79347. */
  79348. static AddHeader: (control: Control, text: string, size: string | number, options: {
  79349. isHorizontal: boolean;
  79350. controlFirst: boolean;
  79351. }) => any;
  79352. /** @hidden */
  79353. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  79354. }
  79355. }
  79356. declare module BABYLON.GUI {
  79357. /**
  79358. * Root class for 2D containers
  79359. * @see https://doc.babylonjs.com/how_to/gui#containers
  79360. */
  79361. export class Container extends Control {
  79362. name?: string | undefined;
  79363. /** @hidden */
  79364. _children: Control[];
  79365. /** @hidden */
  79366. protected _measureForChildren: Measure;
  79367. /** @hidden */
  79368. protected _background: string;
  79369. /** @hidden */
  79370. protected _adaptWidthToChildren: boolean;
  79371. /** @hidden */
  79372. protected _adaptHeightToChildren: boolean;
  79373. /**
  79374. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  79375. */
  79376. logLayoutCycleErrors: boolean;
  79377. /**
  79378. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  79379. */
  79380. maxLayoutCycle: number;
  79381. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  79382. get adaptHeightToChildren(): boolean;
  79383. set adaptHeightToChildren(value: boolean);
  79384. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  79385. get adaptWidthToChildren(): boolean;
  79386. set adaptWidthToChildren(value: boolean);
  79387. /** Gets or sets background color */
  79388. get background(): string;
  79389. set background(value: string);
  79390. /** Gets the list of children */
  79391. get children(): Control[];
  79392. /**
  79393. * Creates a new Container
  79394. * @param name defines the name of the container
  79395. */
  79396. constructor(name?: string | undefined);
  79397. protected _getTypeName(): string;
  79398. _flagDescendantsAsMatrixDirty(): void;
  79399. /**
  79400. * Gets a child using its name
  79401. * @param name defines the child name to look for
  79402. * @returns the child control if found
  79403. */
  79404. getChildByName(name: string): BABYLON.Nullable<Control>;
  79405. /**
  79406. * Gets a child using its type and its name
  79407. * @param name defines the child name to look for
  79408. * @param type defines the child type to look for
  79409. * @returns the child control if found
  79410. */
  79411. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  79412. /**
  79413. * Search for a specific control in children
  79414. * @param control defines the control to look for
  79415. * @returns true if the control is in child list
  79416. */
  79417. containsControl(control: Control): boolean;
  79418. /**
  79419. * Adds a new control to the current container
  79420. * @param control defines the control to add
  79421. * @returns the current container
  79422. */
  79423. addControl(control: BABYLON.Nullable<Control>): Container;
  79424. /**
  79425. * Removes all controls from the current container
  79426. * @returns the current container
  79427. */
  79428. clearControls(): Container;
  79429. /**
  79430. * Removes a control from the current container
  79431. * @param control defines the control to remove
  79432. * @returns the current container
  79433. */
  79434. removeControl(control: Control): Container;
  79435. /** @hidden */
  79436. _reOrderControl(control: Control): void;
  79437. /** @hidden */
  79438. _offsetLeft(offset: number): void;
  79439. /** @hidden */
  79440. _offsetTop(offset: number): void;
  79441. /** @hidden */
  79442. _markAllAsDirty(): void;
  79443. /** @hidden */
  79444. protected _localDraw(context: CanvasRenderingContext2D): void;
  79445. /** @hidden */
  79446. _link(host: AdvancedDynamicTexture): void;
  79447. /** @hidden */
  79448. protected _beforeLayout(): void;
  79449. /** @hidden */
  79450. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79451. /** @hidden */
  79452. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79453. protected _postMeasure(): void;
  79454. /** @hidden */
  79455. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79456. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79457. /** @hidden */
  79458. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79459. /** @hidden */
  79460. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79461. /** Releases associated resources */
  79462. dispose(): void;
  79463. }
  79464. }
  79465. declare module BABYLON.GUI {
  79466. /** Class used to create rectangle container */
  79467. export class Rectangle extends Container {
  79468. name?: string | undefined;
  79469. private _thickness;
  79470. private _cornerRadius;
  79471. /** Gets or sets border thickness */
  79472. get thickness(): number;
  79473. set thickness(value: number);
  79474. /** Gets or sets the corner radius angle */
  79475. get cornerRadius(): number;
  79476. set cornerRadius(value: number);
  79477. /**
  79478. * Creates a new Rectangle
  79479. * @param name defines the control name
  79480. */
  79481. constructor(name?: string | undefined);
  79482. protected _getTypeName(): string;
  79483. protected _localDraw(context: CanvasRenderingContext2D): void;
  79484. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79485. private _drawRoundedRect;
  79486. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79487. }
  79488. }
  79489. declare module BABYLON.GUI {
  79490. /**
  79491. * Enum that determines the text-wrapping mode to use.
  79492. */
  79493. export enum TextWrapping {
  79494. /**
  79495. * Clip the text when it's larger than Control.width; this is the default mode.
  79496. */
  79497. Clip = 0,
  79498. /**
  79499. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79500. */
  79501. WordWrap = 1,
  79502. /**
  79503. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79504. */
  79505. Ellipsis = 2
  79506. }
  79507. /**
  79508. * Class used to create text block control
  79509. */
  79510. export class TextBlock extends Control {
  79511. /**
  79512. * Defines the name of the control
  79513. */
  79514. name?: string | undefined;
  79515. private _text;
  79516. private _textWrapping;
  79517. private _textHorizontalAlignment;
  79518. private _textVerticalAlignment;
  79519. private _lines;
  79520. private _resizeToFit;
  79521. private _lineSpacing;
  79522. private _outlineWidth;
  79523. private _outlineColor;
  79524. private _underline;
  79525. private _lineThrough;
  79526. /**
  79527. * An event triggered after the text is changed
  79528. */
  79529. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79530. /**
  79531. * An event triggered after the text was broken up into lines
  79532. */
  79533. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79534. /**
  79535. * Function used to split a string into words. By default, a string is split at each space character found
  79536. */
  79537. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79538. /**
  79539. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79540. */
  79541. get lines(): any[];
  79542. /**
  79543. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79544. */
  79545. get resizeToFit(): boolean;
  79546. /**
  79547. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79548. */
  79549. set resizeToFit(value: boolean);
  79550. /**
  79551. * Gets or sets a boolean indicating if text must be wrapped
  79552. */
  79553. get textWrapping(): TextWrapping | boolean;
  79554. /**
  79555. * Gets or sets a boolean indicating if text must be wrapped
  79556. */
  79557. set textWrapping(value: TextWrapping | boolean);
  79558. /**
  79559. * Gets or sets text to display
  79560. */
  79561. get text(): string;
  79562. /**
  79563. * Gets or sets text to display
  79564. */
  79565. set text(value: string);
  79566. /**
  79567. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79568. */
  79569. get textHorizontalAlignment(): number;
  79570. /**
  79571. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79572. */
  79573. set textHorizontalAlignment(value: number);
  79574. /**
  79575. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79576. */
  79577. get textVerticalAlignment(): number;
  79578. /**
  79579. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79580. */
  79581. set textVerticalAlignment(value: number);
  79582. /**
  79583. * Gets or sets line spacing value
  79584. */
  79585. set lineSpacing(value: string | number);
  79586. /**
  79587. * Gets or sets line spacing value
  79588. */
  79589. get lineSpacing(): string | number;
  79590. /**
  79591. * Gets or sets outlineWidth of the text to display
  79592. */
  79593. get outlineWidth(): number;
  79594. /**
  79595. * Gets or sets outlineWidth of the text to display
  79596. */
  79597. set outlineWidth(value: number);
  79598. /**
  79599. * Gets or sets a boolean indicating that text must have underline
  79600. */
  79601. get underline(): boolean;
  79602. /**
  79603. * Gets or sets a boolean indicating that text must have underline
  79604. */
  79605. set underline(value: boolean);
  79606. /**
  79607. * Gets or sets an boolean indicating that text must be crossed out
  79608. */
  79609. get lineThrough(): boolean;
  79610. /**
  79611. * Gets or sets an boolean indicating that text must be crossed out
  79612. */
  79613. set lineThrough(value: boolean);
  79614. /**
  79615. * Gets or sets outlineColor of the text to display
  79616. */
  79617. get outlineColor(): string;
  79618. /**
  79619. * Gets or sets outlineColor of the text to display
  79620. */
  79621. set outlineColor(value: string);
  79622. /**
  79623. * Creates a new TextBlock object
  79624. * @param name defines the name of the control
  79625. * @param text defines the text to display (emptry string by default)
  79626. */
  79627. constructor(
  79628. /**
  79629. * Defines the name of the control
  79630. */
  79631. name?: string | undefined, text?: string);
  79632. protected _getTypeName(): string;
  79633. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79634. private _drawText;
  79635. /** @hidden */
  79636. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79637. protected _applyStates(context: CanvasRenderingContext2D): void;
  79638. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79639. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79640. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79641. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79642. protected _renderLines(context: CanvasRenderingContext2D): void;
  79643. /**
  79644. * Given a width constraint applied on the text block, find the expected height
  79645. * @returns expected height
  79646. */
  79647. computeExpectedHeight(): number;
  79648. dispose(): void;
  79649. }
  79650. }
  79651. declare module BABYLON.GUI {
  79652. /**
  79653. * Class used to create 2D images
  79654. */
  79655. export class Image extends Control {
  79656. name?: string | undefined;
  79657. private _workingCanvas;
  79658. private _domImage;
  79659. private _imageWidth;
  79660. private _imageHeight;
  79661. private _loaded;
  79662. private _stretch;
  79663. private _source;
  79664. private _autoScale;
  79665. private _sourceLeft;
  79666. private _sourceTop;
  79667. private _sourceWidth;
  79668. private _sourceHeight;
  79669. private _svgAttributesComputationCompleted;
  79670. private _isSVG;
  79671. private _cellWidth;
  79672. private _cellHeight;
  79673. private _cellId;
  79674. private _populateNinePatchSlicesFromImage;
  79675. private _sliceLeft;
  79676. private _sliceRight;
  79677. private _sliceTop;
  79678. private _sliceBottom;
  79679. private _detectPointerOnOpaqueOnly;
  79680. private _imageDataCache;
  79681. /**
  79682. * BABYLON.Observable notified when the content is loaded
  79683. */
  79684. onImageLoadedObservable: BABYLON.Observable<Image>;
  79685. /**
  79686. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79687. */
  79688. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79689. /**
  79690. * Gets a boolean indicating that the content is loaded
  79691. */
  79692. get isLoaded(): boolean;
  79693. /**
  79694. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79695. */
  79696. get populateNinePatchSlicesFromImage(): boolean;
  79697. set populateNinePatchSlicesFromImage(value: boolean);
  79698. /**
  79699. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79700. * Beware using this as this will comsume more memory as the image has to be stored twice
  79701. */
  79702. get detectPointerOnOpaqueOnly(): boolean;
  79703. set detectPointerOnOpaqueOnly(value: boolean);
  79704. /**
  79705. * Gets or sets the left value for slicing (9-patch)
  79706. */
  79707. get sliceLeft(): number;
  79708. set sliceLeft(value: number);
  79709. /**
  79710. * Gets or sets the right value for slicing (9-patch)
  79711. */
  79712. get sliceRight(): number;
  79713. set sliceRight(value: number);
  79714. /**
  79715. * Gets or sets the top value for slicing (9-patch)
  79716. */
  79717. get sliceTop(): number;
  79718. set sliceTop(value: number);
  79719. /**
  79720. * Gets or sets the bottom value for slicing (9-patch)
  79721. */
  79722. get sliceBottom(): number;
  79723. set sliceBottom(value: number);
  79724. /**
  79725. * Gets or sets the left coordinate in the source image
  79726. */
  79727. get sourceLeft(): number;
  79728. set sourceLeft(value: number);
  79729. /**
  79730. * Gets or sets the top coordinate in the source image
  79731. */
  79732. get sourceTop(): number;
  79733. set sourceTop(value: number);
  79734. /**
  79735. * Gets or sets the width to capture in the source image
  79736. */
  79737. get sourceWidth(): number;
  79738. set sourceWidth(value: number);
  79739. /**
  79740. * Gets or sets the height to capture in the source image
  79741. */
  79742. get sourceHeight(): number;
  79743. set sourceHeight(value: number);
  79744. /** Indicates if the format of the image is SVG */
  79745. get isSVG(): boolean;
  79746. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79747. get svgAttributesComputationCompleted(): boolean;
  79748. /**
  79749. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79750. * @see https://doc.babylonjs.com/how_to/gui#image
  79751. */
  79752. get autoScale(): boolean;
  79753. set autoScale(value: boolean);
  79754. /** Gets or sets the streching mode used by the image */
  79755. get stretch(): number;
  79756. set stretch(value: number);
  79757. /** @hidden */
  79758. _rotate90(n: number, preserveProperties?: boolean): Image;
  79759. private _handleRotationForSVGImage;
  79760. private _rotate90SourceProperties;
  79761. /**
  79762. * Gets or sets the internal DOM image used to render the control
  79763. */
  79764. set domImage(value: HTMLImageElement);
  79765. get domImage(): HTMLImageElement;
  79766. private _onImageLoaded;
  79767. private _extractNinePatchSliceDataFromImage;
  79768. /**
  79769. * Gets or sets image source url
  79770. */
  79771. set source(value: BABYLON.Nullable<string>);
  79772. /**
  79773. * Checks for svg document with icon id present
  79774. */
  79775. private _svgCheck;
  79776. /**
  79777. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79778. * given external svg file and icon id
  79779. */
  79780. private _getSVGAttribs;
  79781. /**
  79782. * Gets or sets the cell width to use when animation sheet is enabled
  79783. * @see https://doc.babylonjs.com/how_to/gui#image
  79784. */
  79785. get cellWidth(): number;
  79786. set cellWidth(value: number);
  79787. /**
  79788. * Gets or sets the cell height to use when animation sheet is enabled
  79789. * @see https://doc.babylonjs.com/how_to/gui#image
  79790. */
  79791. get cellHeight(): number;
  79792. set cellHeight(value: number);
  79793. /**
  79794. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79795. * @see https://doc.babylonjs.com/how_to/gui#image
  79796. */
  79797. get cellId(): number;
  79798. set cellId(value: number);
  79799. /**
  79800. * Creates a new Image
  79801. * @param name defines the control name
  79802. * @param url defines the image url
  79803. */
  79804. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79805. /**
  79806. * Tests if a given coordinates belong to the current control
  79807. * @param x defines x coordinate to test
  79808. * @param y defines y coordinate to test
  79809. * @returns true if the coordinates are inside the control
  79810. */
  79811. contains(x: number, y: number): boolean;
  79812. protected _getTypeName(): string;
  79813. /** Force the control to synchronize with its content */
  79814. synchronizeSizeWithContent(): void;
  79815. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79816. private _prepareWorkingCanvasForOpaqueDetection;
  79817. private _drawImage;
  79818. _draw(context: CanvasRenderingContext2D): void;
  79819. private _renderCornerPatch;
  79820. private _renderNinePatch;
  79821. dispose(): void;
  79822. /** STRETCH_NONE */
  79823. static readonly STRETCH_NONE: number;
  79824. /** STRETCH_FILL */
  79825. static readonly STRETCH_FILL: number;
  79826. /** STRETCH_UNIFORM */
  79827. static readonly STRETCH_UNIFORM: number;
  79828. /** STRETCH_EXTEND */
  79829. static readonly STRETCH_EXTEND: number;
  79830. /** NINE_PATCH */
  79831. static readonly STRETCH_NINE_PATCH: number;
  79832. }
  79833. }
  79834. declare module BABYLON.GUI {
  79835. /**
  79836. * Class used to create 2D buttons
  79837. */
  79838. export class Button extends Rectangle {
  79839. name?: string | undefined;
  79840. /**
  79841. * Function called to generate a pointer enter animation
  79842. */
  79843. pointerEnterAnimation: () => void;
  79844. /**
  79845. * Function called to generate a pointer out animation
  79846. */
  79847. pointerOutAnimation: () => void;
  79848. /**
  79849. * Function called to generate a pointer down animation
  79850. */
  79851. pointerDownAnimation: () => void;
  79852. /**
  79853. * Function called to generate a pointer up animation
  79854. */
  79855. pointerUpAnimation: () => void;
  79856. /**
  79857. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79858. */
  79859. delegatePickingToChildren: boolean;
  79860. private _image;
  79861. /**
  79862. * Returns the image part of the button (if any)
  79863. */
  79864. get image(): BABYLON.Nullable<Image>;
  79865. private _textBlock;
  79866. /**
  79867. * Returns the image part of the button (if any)
  79868. */
  79869. get textBlock(): BABYLON.Nullable<TextBlock>;
  79870. /**
  79871. * Creates a new Button
  79872. * @param name defines the name of the button
  79873. */
  79874. constructor(name?: string | undefined);
  79875. protected _getTypeName(): string;
  79876. /** @hidden */
  79877. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79878. /** @hidden */
  79879. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79880. /** @hidden */
  79881. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79882. /** @hidden */
  79883. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79884. /** @hidden */
  79885. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79886. /**
  79887. * Creates a new button made with an image and a text
  79888. * @param name defines the name of the button
  79889. * @param text defines the text of the button
  79890. * @param imageUrl defines the url of the image
  79891. * @returns a new Button
  79892. */
  79893. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79894. /**
  79895. * Creates a new button made with an image
  79896. * @param name defines the name of the button
  79897. * @param imageUrl defines the url of the image
  79898. * @returns a new Button
  79899. */
  79900. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79901. /**
  79902. * Creates a new button made with a text
  79903. * @param name defines the name of the button
  79904. * @param text defines the text of the button
  79905. * @returns a new Button
  79906. */
  79907. static CreateSimpleButton(name: string, text: string): Button;
  79908. /**
  79909. * Creates a new button made with an image and a centered text
  79910. * @param name defines the name of the button
  79911. * @param text defines the text of the button
  79912. * @param imageUrl defines the url of the image
  79913. * @returns a new Button
  79914. */
  79915. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79916. }
  79917. }
  79918. declare module BABYLON.GUI {
  79919. /**
  79920. * Class used to create a 2D stack panel container
  79921. */
  79922. export class StackPanel extends Container {
  79923. name?: string | undefined;
  79924. private _isVertical;
  79925. private _manualWidth;
  79926. private _manualHeight;
  79927. private _doNotTrackManualChanges;
  79928. /**
  79929. * Gets or sets a boolean indicating that layou warnings should be ignored
  79930. */
  79931. ignoreLayoutWarnings: boolean;
  79932. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79933. get isVertical(): boolean;
  79934. set isVertical(value: boolean);
  79935. /**
  79936. * Gets or sets panel width.
  79937. * This value should not be set when in horizontal mode as it will be computed automatically
  79938. */
  79939. set width(value: string | number);
  79940. get width(): string | number;
  79941. /**
  79942. * Gets or sets panel height.
  79943. * This value should not be set when in vertical mode as it will be computed automatically
  79944. */
  79945. set height(value: string | number);
  79946. get height(): string | number;
  79947. /**
  79948. * Creates a new StackPanel
  79949. * @param name defines control name
  79950. */
  79951. constructor(name?: string | undefined);
  79952. protected _getTypeName(): string;
  79953. /** @hidden */
  79954. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79955. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79956. protected _postMeasure(): void;
  79957. }
  79958. }
  79959. declare module BABYLON.GUI {
  79960. /**
  79961. * Class used to represent a 2D checkbox
  79962. */
  79963. export class Checkbox extends Control {
  79964. name?: string | undefined;
  79965. private _isChecked;
  79966. private _background;
  79967. private _checkSizeRatio;
  79968. private _thickness;
  79969. /** Gets or sets border thickness */
  79970. get thickness(): number;
  79971. set thickness(value: number);
  79972. /**
  79973. * BABYLON.Observable raised when isChecked property changes
  79974. */
  79975. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79976. /** Gets or sets a value indicating the ratio between overall size and check size */
  79977. get checkSizeRatio(): number;
  79978. set checkSizeRatio(value: number);
  79979. /** Gets or sets background color */
  79980. get background(): string;
  79981. set background(value: string);
  79982. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79983. get isChecked(): boolean;
  79984. set isChecked(value: boolean);
  79985. /**
  79986. * Creates a new CheckBox
  79987. * @param name defines the control name
  79988. */
  79989. constructor(name?: string | undefined);
  79990. protected _getTypeName(): string;
  79991. /** @hidden */
  79992. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79993. /** @hidden */
  79994. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79995. /**
  79996. * Utility function to easily create a checkbox with a header
  79997. * @param title defines the label to use for the header
  79998. * @param onValueChanged defines the callback to call when value changes
  79999. * @returns a StackPanel containing the checkbox and a textBlock
  80000. */
  80001. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  80002. }
  80003. }
  80004. declare module BABYLON.GUI {
  80005. /**
  80006. * Class used to store key control properties
  80007. */
  80008. export class KeyPropertySet {
  80009. /** Width */
  80010. width?: string;
  80011. /** Height */
  80012. height?: string;
  80013. /** Left padding */
  80014. paddingLeft?: string;
  80015. /** Right padding */
  80016. paddingRight?: string;
  80017. /** Top padding */
  80018. paddingTop?: string;
  80019. /** Bottom padding */
  80020. paddingBottom?: string;
  80021. /** Foreground color */
  80022. color?: string;
  80023. /** Background color */
  80024. background?: string;
  80025. }
  80026. /**
  80027. * Class used to create virtual keyboard
  80028. */
  80029. export class VirtualKeyboard extends StackPanel {
  80030. /** BABYLON.Observable raised when a key is pressed */
  80031. onKeyPressObservable: BABYLON.Observable<string>;
  80032. /** Gets or sets default key button width */
  80033. defaultButtonWidth: string;
  80034. /** Gets or sets default key button height */
  80035. defaultButtonHeight: string;
  80036. /** Gets or sets default key button left padding */
  80037. defaultButtonPaddingLeft: string;
  80038. /** Gets or sets default key button right padding */
  80039. defaultButtonPaddingRight: string;
  80040. /** Gets or sets default key button top padding */
  80041. defaultButtonPaddingTop: string;
  80042. /** Gets or sets default key button bottom padding */
  80043. defaultButtonPaddingBottom: string;
  80044. /** Gets or sets default key button foreground color */
  80045. defaultButtonColor: string;
  80046. /** Gets or sets default key button background color */
  80047. defaultButtonBackground: string;
  80048. /** Gets or sets shift button foreground color */
  80049. shiftButtonColor: string;
  80050. /** Gets or sets shift button thickness*/
  80051. selectedShiftThickness: number;
  80052. /** Gets shift key state */
  80053. shiftState: number;
  80054. protected _getTypeName(): string;
  80055. private _createKey;
  80056. /**
  80057. * Adds a new row of keys
  80058. * @param keys defines the list of keys to add
  80059. * @param propertySets defines the associated property sets
  80060. */
  80061. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  80062. /**
  80063. * Set the shift key to a specific state
  80064. * @param shiftState defines the new shift state
  80065. */
  80066. applyShiftState(shiftState: number): void;
  80067. private _currentlyConnectedInputText;
  80068. private _connectedInputTexts;
  80069. private _onKeyPressObserver;
  80070. /** Gets the input text control currently attached to the keyboard */
  80071. get connectedInputText(): BABYLON.Nullable<InputText>;
  80072. /**
  80073. * Connects the keyboard with an input text control
  80074. *
  80075. * @param input defines the target control
  80076. */
  80077. connect(input: InputText): void;
  80078. /**
  80079. * Disconnects the keyboard from connected InputText controls
  80080. *
  80081. * @param input optionally defines a target control, otherwise all are disconnected
  80082. */
  80083. disconnect(input?: InputText): void;
  80084. private _removeConnectedInputObservables;
  80085. /**
  80086. * Release all resources
  80087. */
  80088. dispose(): void;
  80089. /**
  80090. * Creates a new keyboard using a default layout
  80091. *
  80092. * @param name defines control name
  80093. * @returns a new VirtualKeyboard
  80094. */
  80095. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  80096. }
  80097. }
  80098. declare module BABYLON.GUI {
  80099. /** @hidden */
  80100. export class TextWrapper {
  80101. private _text;
  80102. private _characters;
  80103. get text(): string;
  80104. set text(txt: string);
  80105. get length(): number;
  80106. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  80107. charAt(idx: number): string;
  80108. substr(from: number, length?: number): string;
  80109. substring(from: number, to?: number): string;
  80110. isWord(index: number): boolean;
  80111. }
  80112. }
  80113. declare module BABYLON.GUI {
  80114. /**
  80115. * Class used to create input text control
  80116. */
  80117. export class InputText extends Control implements IFocusableControl {
  80118. name?: string | undefined;
  80119. private _textWrapper;
  80120. private _placeholderText;
  80121. private _background;
  80122. private _focusedBackground;
  80123. private _focusedColor;
  80124. private _placeholderColor;
  80125. private _thickness;
  80126. private _margin;
  80127. private _autoStretchWidth;
  80128. private _maxWidth;
  80129. private _isFocused;
  80130. private _blinkTimeout;
  80131. private _blinkIsEven;
  80132. private _cursorOffset;
  80133. private _scrollLeft;
  80134. private _textWidth;
  80135. private _clickedCoordinate;
  80136. private _deadKey;
  80137. private _addKey;
  80138. private _currentKey;
  80139. private _isTextHighlightOn;
  80140. private _textHighlightColor;
  80141. private _highligherOpacity;
  80142. private _highlightedText;
  80143. private _startHighlightIndex;
  80144. private _endHighlightIndex;
  80145. private _cursorIndex;
  80146. private _onFocusSelectAll;
  80147. private _isPointerDown;
  80148. private _onClipboardObserver;
  80149. private _onPointerDblTapObserver;
  80150. /** @hidden */
  80151. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  80152. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  80153. promptMessage: string;
  80154. /** Force disable prompt on mobile device */
  80155. disableMobilePrompt: boolean;
  80156. /** BABYLON.Observable raised when the text changes */
  80157. onTextChangedObservable: BABYLON.Observable<InputText>;
  80158. /** BABYLON.Observable raised just before an entered character is to be added */
  80159. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  80160. /** BABYLON.Observable raised when the control gets the focus */
  80161. onFocusObservable: BABYLON.Observable<InputText>;
  80162. /** BABYLON.Observable raised when the control loses the focus */
  80163. onBlurObservable: BABYLON.Observable<InputText>;
  80164. /**Observable raised when the text is highlighted */
  80165. onTextHighlightObservable: BABYLON.Observable<InputText>;
  80166. /**Observable raised when copy event is triggered */
  80167. onTextCopyObservable: BABYLON.Observable<InputText>;
  80168. /** BABYLON.Observable raised when cut event is triggered */
  80169. onTextCutObservable: BABYLON.Observable<InputText>;
  80170. /** BABYLON.Observable raised when paste event is triggered */
  80171. onTextPasteObservable: BABYLON.Observable<InputText>;
  80172. /** BABYLON.Observable raised when a key event was processed */
  80173. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  80174. /** Gets or sets the maximum width allowed by the control */
  80175. get maxWidth(): string | number;
  80176. /** Gets the maximum width allowed by the control in pixels */
  80177. get maxWidthInPixels(): number;
  80178. set maxWidth(value: string | number);
  80179. /** Gets or sets the text highlighter transparency; default: 0.4 */
  80180. get highligherOpacity(): number;
  80181. set highligherOpacity(value: number);
  80182. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  80183. get onFocusSelectAll(): boolean;
  80184. set onFocusSelectAll(value: boolean);
  80185. /** Gets or sets the text hightlight color */
  80186. get textHighlightColor(): string;
  80187. set textHighlightColor(value: string);
  80188. /** Gets or sets control margin */
  80189. get margin(): string;
  80190. /** Gets control margin in pixels */
  80191. get marginInPixels(): number;
  80192. set margin(value: string);
  80193. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  80194. get autoStretchWidth(): boolean;
  80195. set autoStretchWidth(value: boolean);
  80196. /** Gets or sets border thickness */
  80197. get thickness(): number;
  80198. set thickness(value: number);
  80199. /** Gets or sets the background color when focused */
  80200. get focusedBackground(): string;
  80201. set focusedBackground(value: string);
  80202. /** Gets or sets the background color when focused */
  80203. get focusedColor(): string;
  80204. set focusedColor(value: string);
  80205. /** Gets or sets the background color */
  80206. get background(): string;
  80207. set background(value: string);
  80208. /** Gets or sets the placeholder color */
  80209. get placeholderColor(): string;
  80210. set placeholderColor(value: string);
  80211. /** Gets or sets the text displayed when the control is empty */
  80212. get placeholderText(): string;
  80213. set placeholderText(value: string);
  80214. /** Gets or sets the dead key flag */
  80215. get deadKey(): boolean;
  80216. set deadKey(flag: boolean);
  80217. /** Gets or sets the highlight text */
  80218. get highlightedText(): string;
  80219. set highlightedText(text: string);
  80220. /** Gets or sets if the current key should be added */
  80221. get addKey(): boolean;
  80222. set addKey(flag: boolean);
  80223. /** Gets or sets the value of the current key being entered */
  80224. get currentKey(): string;
  80225. set currentKey(key: string);
  80226. /** Gets or sets the text displayed in the control */
  80227. get text(): string;
  80228. set text(value: string);
  80229. private _textHasChanged;
  80230. /** Gets or sets control width */
  80231. get width(): string | number;
  80232. set width(value: string | number);
  80233. /**
  80234. * Creates a new InputText
  80235. * @param name defines the control name
  80236. * @param text defines the text of the control
  80237. */
  80238. constructor(name?: string | undefined, text?: string);
  80239. /** @hidden */
  80240. onBlur(): void;
  80241. /** @hidden */
  80242. onFocus(): void;
  80243. /**
  80244. * Function to focus an inputText programmatically
  80245. */
  80246. focus(): void;
  80247. /**
  80248. * Function to unfocus an inputText programmatically
  80249. */
  80250. blur(): void;
  80251. protected _getTypeName(): string;
  80252. /**
  80253. * Function called to get the list of controls that should not steal the focus from this control
  80254. * @returns an array of controls
  80255. */
  80256. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  80257. /** @hidden */
  80258. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  80259. /** @hidden */
  80260. private _updateValueFromCursorIndex;
  80261. /** @hidden */
  80262. private _processDblClick;
  80263. /** @hidden */
  80264. private _selectAllText;
  80265. /**
  80266. * Handles the keyboard event
  80267. * @param evt Defines the KeyboardEvent
  80268. */
  80269. processKeyboard(evt: KeyboardEvent): void;
  80270. /** @hidden */
  80271. private _onCopyText;
  80272. /** @hidden */
  80273. private _onCutText;
  80274. /** @hidden */
  80275. private _onPasteText;
  80276. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80277. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80278. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80279. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80280. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80281. dispose(): void;
  80282. }
  80283. }
  80284. declare module BABYLON.GUI {
  80285. /**
  80286. * Class used to create a 2D grid container
  80287. */
  80288. export class Grid extends Container {
  80289. name?: string | undefined;
  80290. private _rowDefinitions;
  80291. private _columnDefinitions;
  80292. private _cells;
  80293. private _childControls;
  80294. /**
  80295. * Gets the number of columns
  80296. */
  80297. get columnCount(): number;
  80298. /**
  80299. * Gets the number of rows
  80300. */
  80301. get rowCount(): number;
  80302. /** Gets the list of children */
  80303. get children(): Control[];
  80304. /** Gets the list of cells (e.g. the containers) */
  80305. get cells(): {
  80306. [key: string]: Container;
  80307. };
  80308. /**
  80309. * Gets the definition of a specific row
  80310. * @param index defines the index of the row
  80311. * @returns the row definition
  80312. */
  80313. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80314. /**
  80315. * Gets the definition of a specific column
  80316. * @param index defines the index of the column
  80317. * @returns the column definition
  80318. */
  80319. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80320. /**
  80321. * Adds a new row to the grid
  80322. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80323. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  80324. * @returns the current grid
  80325. */
  80326. addRowDefinition(height: number, isPixel?: boolean): Grid;
  80327. /**
  80328. * Adds a new column to the grid
  80329. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80330. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80331. * @returns the current grid
  80332. */
  80333. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  80334. /**
  80335. * Update a row definition
  80336. * @param index defines the index of the row to update
  80337. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80338. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  80339. * @returns the current grid
  80340. */
  80341. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  80342. /**
  80343. * Update a column definition
  80344. * @param index defines the index of the column to update
  80345. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80346. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80347. * @returns the current grid
  80348. */
  80349. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  80350. /**
  80351. * Gets the list of children stored in a specific cell
  80352. * @param row defines the row to check
  80353. * @param column defines the column to check
  80354. * @returns the list of controls
  80355. */
  80356. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  80357. /**
  80358. * Gets a string representing the child cell info (row x column)
  80359. * @param child defines the control to get info from
  80360. * @returns a string containing the child cell info (row x column)
  80361. */
  80362. getChildCellInfo(child: Control): string;
  80363. private _removeCell;
  80364. private _offsetCell;
  80365. /**
  80366. * Remove a column definition at specified index
  80367. * @param index defines the index of the column to remove
  80368. * @returns the current grid
  80369. */
  80370. removeColumnDefinition(index: number): Grid;
  80371. /**
  80372. * Remove a row definition at specified index
  80373. * @param index defines the index of the row to remove
  80374. * @returns the current grid
  80375. */
  80376. removeRowDefinition(index: number): Grid;
  80377. /**
  80378. * Adds a new control to the current grid
  80379. * @param control defines the control to add
  80380. * @param row defines the row where to add the control (0 by default)
  80381. * @param column defines the column where to add the control (0 by default)
  80382. * @returns the current grid
  80383. */
  80384. addControl(control: Control, row?: number, column?: number): Grid;
  80385. /**
  80386. * Removes a control from the current container
  80387. * @param control defines the control to remove
  80388. * @returns the current container
  80389. */
  80390. removeControl(control: Control): Container;
  80391. /**
  80392. * Creates a new Grid
  80393. * @param name defines control name
  80394. */
  80395. constructor(name?: string | undefined);
  80396. protected _getTypeName(): string;
  80397. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  80398. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80399. _flagDescendantsAsMatrixDirty(): void;
  80400. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80401. /** Releases associated resources */
  80402. dispose(): void;
  80403. }
  80404. }
  80405. declare module BABYLON.GUI {
  80406. /** Class used to create color pickers */
  80407. export class ColorPicker extends Control {
  80408. name?: string | undefined;
  80409. private static _Epsilon;
  80410. private _colorWheelCanvas;
  80411. private _value;
  80412. private _tmpColor;
  80413. private _pointerStartedOnSquare;
  80414. private _pointerStartedOnWheel;
  80415. private _squareLeft;
  80416. private _squareTop;
  80417. private _squareSize;
  80418. private _h;
  80419. private _s;
  80420. private _v;
  80421. private _lastPointerDownID;
  80422. /**
  80423. * BABYLON.Observable raised when the value changes
  80424. */
  80425. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  80426. /** Gets or sets the color of the color picker */
  80427. get value(): BABYLON.Color3;
  80428. set value(value: BABYLON.Color3);
  80429. /**
  80430. * Gets or sets control width
  80431. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80432. */
  80433. get width(): string | number;
  80434. set width(value: string | number);
  80435. /**
  80436. * Gets or sets control height
  80437. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80438. */
  80439. get height(): string | number;
  80440. /** Gets or sets control height */
  80441. set height(value: string | number);
  80442. /** Gets or sets control size */
  80443. get size(): string | number;
  80444. set size(value: string | number);
  80445. /**
  80446. * Creates a new ColorPicker
  80447. * @param name defines the control name
  80448. */
  80449. constructor(name?: string | undefined);
  80450. protected _getTypeName(): string;
  80451. /** @hidden */
  80452. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80453. private _updateSquareProps;
  80454. private _drawGradientSquare;
  80455. private _drawCircle;
  80456. private _createColorWheelCanvas;
  80457. /** @hidden */
  80458. _draw(context: CanvasRenderingContext2D): void;
  80459. private _pointerIsDown;
  80460. private _updateValueFromPointer;
  80461. private _isPointOnSquare;
  80462. private _isPointOnWheel;
  80463. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80464. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80465. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  80466. _onCanvasBlur(): void;
  80467. /**
  80468. * This function expands the color picker by creating a color picker dialog with manual
  80469. * color value input and the ability to save colors into an array to be used later in
  80470. * subsequent launches of the dialogue.
  80471. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  80472. * @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.
  80473. * @returns picked color as a hex string and the saved colors array as hex strings.
  80474. */
  80475. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  80476. pickerWidth?: string;
  80477. pickerHeight?: string;
  80478. headerHeight?: string;
  80479. lastColor?: string;
  80480. swatchLimit?: number;
  80481. numSwatchesPerLine?: number;
  80482. savedColors?: Array<string>;
  80483. }): Promise<{
  80484. savedColors?: string[];
  80485. pickedColor: string;
  80486. }>;
  80487. }
  80488. }
  80489. declare module BABYLON.GUI {
  80490. /** Class used to create 2D ellipse containers */
  80491. export class Ellipse extends Container {
  80492. name?: string | undefined;
  80493. private _thickness;
  80494. /** Gets or sets border thickness */
  80495. get thickness(): number;
  80496. set thickness(value: number);
  80497. /**
  80498. * Creates a new Ellipse
  80499. * @param name defines the control name
  80500. */
  80501. constructor(name?: string | undefined);
  80502. protected _getTypeName(): string;
  80503. protected _localDraw(context: CanvasRenderingContext2D): void;
  80504. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80505. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  80506. }
  80507. }
  80508. declare module BABYLON.GUI {
  80509. /**
  80510. * Class used to create a focusable button that can easily handle keyboard events
  80511. */
  80512. export class FocusableButton extends Button implements IFocusableControl {
  80513. name?: string | undefined;
  80514. /** Highlight color when button is focused */
  80515. focusedColor: BABYLON.Nullable<string>;
  80516. private _isFocused;
  80517. private _unfocusedColor;
  80518. /** BABYLON.Observable raised when the control gets the focus */
  80519. onFocusObservable: BABYLON.Observable<Button>;
  80520. /** BABYLON.Observable raised when the control loses the focus */
  80521. onBlurObservable: BABYLON.Observable<Button>;
  80522. /** BABYLON.Observable raised when a key event was processed */
  80523. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  80524. constructor(name?: string | undefined);
  80525. /** @hidden */
  80526. onBlur(): void;
  80527. /** @hidden */
  80528. onFocus(): void;
  80529. /**
  80530. * Function called to get the list of controls that should not steal the focus from this control
  80531. * @returns an array of controls
  80532. */
  80533. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  80534. /**
  80535. * Function to focus a button programmatically
  80536. */
  80537. focus(): void;
  80538. /**
  80539. * Function to unfocus a button programmatically
  80540. */
  80541. blur(): void;
  80542. /**
  80543. * Handles the keyboard event
  80544. * @param evt Defines the KeyboardEvent
  80545. */
  80546. processKeyboard(evt: KeyboardEvent): void;
  80547. /** @hidden */
  80548. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80549. /** @hidden */
  80550. displose(): void;
  80551. }
  80552. }
  80553. declare module BABYLON.GUI {
  80554. /**
  80555. * Class used to create a password control
  80556. */
  80557. export class InputPassword extends InputText {
  80558. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80559. }
  80560. }
  80561. declare module BABYLON.GUI {
  80562. /** Class used to render 2D lines */
  80563. export class Line extends Control {
  80564. name?: string | undefined;
  80565. private _lineWidth;
  80566. private _x1;
  80567. private _y1;
  80568. private _x2;
  80569. private _y2;
  80570. private _dash;
  80571. private _connectedControl;
  80572. private _connectedControlDirtyObserver;
  80573. /** Gets or sets the dash pattern */
  80574. get dash(): Array<number>;
  80575. set dash(value: Array<number>);
  80576. /** Gets or sets the control connected with the line end */
  80577. get connectedControl(): Control;
  80578. set connectedControl(value: Control);
  80579. /** Gets or sets start coordinates on X axis */
  80580. get x1(): string | number;
  80581. set x1(value: string | number);
  80582. /** Gets or sets start coordinates on Y axis */
  80583. get y1(): string | number;
  80584. set y1(value: string | number);
  80585. /** Gets or sets end coordinates on X axis */
  80586. get x2(): string | number;
  80587. set x2(value: string | number);
  80588. /** Gets or sets end coordinates on Y axis */
  80589. get y2(): string | number;
  80590. set y2(value: string | number);
  80591. /** Gets or sets line width */
  80592. get lineWidth(): number;
  80593. set lineWidth(value: number);
  80594. /** Gets or sets horizontal alignment */
  80595. set horizontalAlignment(value: number);
  80596. /** Gets or sets vertical alignment */
  80597. set verticalAlignment(value: number);
  80598. private get _effectiveX2();
  80599. private get _effectiveY2();
  80600. /**
  80601. * Creates a new Line
  80602. * @param name defines the control name
  80603. */
  80604. constructor(name?: string | undefined);
  80605. protected _getTypeName(): string;
  80606. _draw(context: CanvasRenderingContext2D): void;
  80607. _measure(): void;
  80608. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80609. /**
  80610. * Move one end of the line given 3D cartesian coordinates.
  80611. * @param position Targeted world position
  80612. * @param scene BABYLON.Scene
  80613. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80614. */
  80615. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80616. /**
  80617. * Move one end of the line to a position in screen absolute space.
  80618. * @param projectedPosition Position in screen absolute space (X, Y)
  80619. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80620. */
  80621. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80622. }
  80623. }
  80624. declare module BABYLON.GUI {
  80625. /**
  80626. * Class used to store a point for a MultiLine object.
  80627. * The point can be pure 2D coordinates, a mesh or a control
  80628. */
  80629. export class MultiLinePoint {
  80630. private _multiLine;
  80631. private _x;
  80632. private _y;
  80633. private _control;
  80634. private _mesh;
  80635. private _controlObserver;
  80636. private _meshObserver;
  80637. /** @hidden */
  80638. _point: BABYLON.Vector3;
  80639. /**
  80640. * Creates a new MultiLinePoint
  80641. * @param multiLine defines the source MultiLine object
  80642. */
  80643. constructor(multiLine: MultiLine);
  80644. /** Gets or sets x coordinate */
  80645. get x(): string | number;
  80646. set x(value: string | number);
  80647. /** Gets or sets y coordinate */
  80648. get y(): string | number;
  80649. set y(value: string | number);
  80650. /** Gets or sets the control associated with this point */
  80651. get control(): BABYLON.Nullable<Control>;
  80652. set control(value: BABYLON.Nullable<Control>);
  80653. /** Gets or sets the mesh associated with this point */
  80654. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80655. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80656. /** Resets links */
  80657. resetLinks(): void;
  80658. /**
  80659. * Gets a translation vector with Z component
  80660. * @returns the translation vector
  80661. */
  80662. translate(): BABYLON.Vector3;
  80663. private _translatePoint;
  80664. /** Release associated resources */
  80665. dispose(): void;
  80666. }
  80667. }
  80668. declare module BABYLON.GUI {
  80669. /**
  80670. * Class used to create multi line control
  80671. */
  80672. export class MultiLine extends Control {
  80673. name?: string | undefined;
  80674. private _lineWidth;
  80675. private _dash;
  80676. private _points;
  80677. private _minX;
  80678. private _minY;
  80679. private _maxX;
  80680. private _maxY;
  80681. /**
  80682. * Creates a new MultiLine
  80683. * @param name defines the control name
  80684. */
  80685. constructor(name?: string | undefined);
  80686. /** Gets or sets dash pattern */
  80687. get dash(): Array<number>;
  80688. set dash(value: Array<number>);
  80689. /**
  80690. * Gets point stored at specified index
  80691. * @param index defines the index to look for
  80692. * @returns the requested point if found
  80693. */
  80694. getAt(index: number): MultiLinePoint;
  80695. /** Function called when a point is updated */
  80696. onPointUpdate: () => void;
  80697. /**
  80698. * Adds new points to the point collection
  80699. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80700. * @returns the list of created MultiLinePoint
  80701. */
  80702. add(...items: (AbstractMesh | Control | {
  80703. x: string | number;
  80704. y: string | number;
  80705. })[]): MultiLinePoint[];
  80706. /**
  80707. * Adds a new point to the point collection
  80708. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80709. * @returns the created MultiLinePoint
  80710. */
  80711. push(item?: (AbstractMesh | Control | {
  80712. x: string | number;
  80713. y: string | number;
  80714. })): MultiLinePoint;
  80715. /**
  80716. * Remove a specific value or point from the active point collection
  80717. * @param value defines the value or point to remove
  80718. */
  80719. remove(value: number | MultiLinePoint): void;
  80720. /**
  80721. * Resets this object to initial state (no point)
  80722. */
  80723. reset(): void;
  80724. /**
  80725. * Resets all links
  80726. */
  80727. resetLinks(): void;
  80728. /** Gets or sets line width */
  80729. get lineWidth(): number;
  80730. set lineWidth(value: number);
  80731. set horizontalAlignment(value: number);
  80732. set verticalAlignment(value: number);
  80733. protected _getTypeName(): string;
  80734. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80735. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80736. _measure(): void;
  80737. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80738. dispose(): void;
  80739. }
  80740. }
  80741. declare module BABYLON.GUI {
  80742. /**
  80743. * Class used to create radio button controls
  80744. */
  80745. export class RadioButton extends Control {
  80746. name?: string | undefined;
  80747. private _isChecked;
  80748. private _background;
  80749. private _checkSizeRatio;
  80750. private _thickness;
  80751. /** Gets or sets border thickness */
  80752. get thickness(): number;
  80753. set thickness(value: number);
  80754. /** Gets or sets group name */
  80755. group: string;
  80756. /** BABYLON.Observable raised when isChecked is changed */
  80757. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80758. /** Gets or sets a value indicating the ratio between overall size and check size */
  80759. get checkSizeRatio(): number;
  80760. set checkSizeRatio(value: number);
  80761. /** Gets or sets background color */
  80762. get background(): string;
  80763. set background(value: string);
  80764. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80765. get isChecked(): boolean;
  80766. set isChecked(value: boolean);
  80767. /**
  80768. * Creates a new RadioButton
  80769. * @param name defines the control name
  80770. */
  80771. constructor(name?: string | undefined);
  80772. protected _getTypeName(): string;
  80773. _draw(context: CanvasRenderingContext2D): void;
  80774. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80775. /**
  80776. * Utility function to easily create a radio button with a header
  80777. * @param title defines the label to use for the header
  80778. * @param group defines the group to use for the radio button
  80779. * @param isChecked defines the initial state of the radio button
  80780. * @param onValueChanged defines the callback to call when value changes
  80781. * @returns a StackPanel containing the radio button and a textBlock
  80782. */
  80783. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80784. }
  80785. }
  80786. declare module BABYLON.GUI {
  80787. /**
  80788. * Class used to create slider controls
  80789. */
  80790. export class BaseSlider extends Control {
  80791. name?: string | undefined;
  80792. protected _thumbWidth: ValueAndUnit;
  80793. private _minimum;
  80794. private _maximum;
  80795. private _value;
  80796. private _isVertical;
  80797. protected _barOffset: ValueAndUnit;
  80798. private _isThumbClamped;
  80799. protected _displayThumb: boolean;
  80800. private _step;
  80801. private _lastPointerDownID;
  80802. protected _effectiveBarOffset: number;
  80803. protected _renderLeft: number;
  80804. protected _renderTop: number;
  80805. protected _renderWidth: number;
  80806. protected _renderHeight: number;
  80807. protected _backgroundBoxLength: number;
  80808. protected _backgroundBoxThickness: number;
  80809. protected _effectiveThumbThickness: number;
  80810. /** BABYLON.Observable raised when the sldier value changes */
  80811. onValueChangedObservable: BABYLON.Observable<number>;
  80812. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80813. get displayThumb(): boolean;
  80814. set displayThumb(value: boolean);
  80815. /** Gets or sets a step to apply to values (0 by default) */
  80816. get step(): number;
  80817. set step(value: number);
  80818. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80819. get barOffset(): string | number;
  80820. /** Gets main bar offset in pixels*/
  80821. get barOffsetInPixels(): number;
  80822. set barOffset(value: string | number);
  80823. /** Gets or sets thumb width */
  80824. get thumbWidth(): string | number;
  80825. /** Gets thumb width in pixels */
  80826. get thumbWidthInPixels(): number;
  80827. set thumbWidth(value: string | number);
  80828. /** Gets or sets minimum value */
  80829. get minimum(): number;
  80830. set minimum(value: number);
  80831. /** Gets or sets maximum value */
  80832. get maximum(): number;
  80833. set maximum(value: number);
  80834. /** Gets or sets current value */
  80835. get value(): number;
  80836. set value(value: number);
  80837. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80838. get isVertical(): boolean;
  80839. set isVertical(value: boolean);
  80840. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80841. get isThumbClamped(): boolean;
  80842. set isThumbClamped(value: boolean);
  80843. /**
  80844. * Creates a new BaseSlider
  80845. * @param name defines the control name
  80846. */
  80847. constructor(name?: string | undefined);
  80848. protected _getTypeName(): string;
  80849. protected _getThumbPosition(): number;
  80850. protected _getThumbThickness(type: string): number;
  80851. protected _prepareRenderingData(type: string): void;
  80852. private _pointerIsDown;
  80853. /** @hidden */
  80854. protected _updateValueFromPointer(x: number, y: number): void;
  80855. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80856. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80857. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80858. _onCanvasBlur(): void;
  80859. }
  80860. }
  80861. declare module BABYLON.GUI {
  80862. /**
  80863. * Class used to create slider controls
  80864. */
  80865. export class Slider extends BaseSlider {
  80866. name?: string | undefined;
  80867. private _background;
  80868. private _borderColor;
  80869. private _thumbColor;
  80870. private _isThumbCircle;
  80871. protected _displayValueBar: boolean;
  80872. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80873. get displayValueBar(): boolean;
  80874. set displayValueBar(value: boolean);
  80875. /** Gets or sets border color */
  80876. get borderColor(): string;
  80877. set borderColor(value: string);
  80878. /** Gets or sets background color */
  80879. get background(): string;
  80880. set background(value: string);
  80881. /** Gets or sets thumb's color */
  80882. get thumbColor(): string;
  80883. set thumbColor(value: string);
  80884. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80885. get isThumbCircle(): boolean;
  80886. set isThumbCircle(value: boolean);
  80887. /**
  80888. * Creates a new Slider
  80889. * @param name defines the control name
  80890. */
  80891. constructor(name?: string | undefined);
  80892. protected _getTypeName(): string;
  80893. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80894. }
  80895. }
  80896. declare module BABYLON.GUI {
  80897. /** Class used to create a RadioGroup
  80898. * which contains groups of radio buttons
  80899. */
  80900. export class SelectorGroup {
  80901. /** name of SelectorGroup */
  80902. name: string;
  80903. private _groupPanel;
  80904. private _selectors;
  80905. private _groupHeader;
  80906. /**
  80907. * Creates a new SelectorGroup
  80908. * @param name of group, used as a group heading
  80909. */
  80910. constructor(
  80911. /** name of SelectorGroup */
  80912. name: string);
  80913. /** Gets the groupPanel of the SelectorGroup */
  80914. get groupPanel(): StackPanel;
  80915. /** Gets the selectors array */
  80916. get selectors(): StackPanel[];
  80917. /** Gets and sets the group header */
  80918. get header(): string;
  80919. set header(label: string);
  80920. /** @hidden */
  80921. private _addGroupHeader;
  80922. /** @hidden*/
  80923. _getSelector(selectorNb: number): StackPanel | undefined;
  80924. /** Removes the selector at the given position
  80925. * @param selectorNb the position of the selector within the group
  80926. */
  80927. removeSelector(selectorNb: number): void;
  80928. }
  80929. /** Class used to create a CheckboxGroup
  80930. * which contains groups of checkbox buttons
  80931. */
  80932. export class CheckboxGroup extends SelectorGroup {
  80933. /** Adds a checkbox as a control
  80934. * @param text is the label for the selector
  80935. * @param func is the function called when the Selector is checked
  80936. * @param checked is true when Selector is checked
  80937. */
  80938. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80939. /** @hidden */
  80940. _setSelectorLabel(selectorNb: number, label: string): void;
  80941. /** @hidden */
  80942. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80943. /** @hidden */
  80944. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80945. /** @hidden */
  80946. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80947. }
  80948. /** Class used to create a RadioGroup
  80949. * which contains groups of radio buttons
  80950. */
  80951. export class RadioGroup extends SelectorGroup {
  80952. private _selectNb;
  80953. /** Adds a radio button as a control
  80954. * @param label is the label for the selector
  80955. * @param func is the function called when the Selector is checked
  80956. * @param checked is true when Selector is checked
  80957. */
  80958. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80959. /** @hidden */
  80960. _setSelectorLabel(selectorNb: number, label: string): void;
  80961. /** @hidden */
  80962. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80963. /** @hidden */
  80964. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80965. /** @hidden */
  80966. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80967. }
  80968. /** Class used to create a SliderGroup
  80969. * which contains groups of slider buttons
  80970. */
  80971. export class SliderGroup extends SelectorGroup {
  80972. /**
  80973. * Adds a slider to the SelectorGroup
  80974. * @param label is the label for the SliderBar
  80975. * @param func is the function called when the Slider moves
  80976. * @param unit is a string describing the units used, eg degrees or metres
  80977. * @param min is the minimum value for the Slider
  80978. * @param max is the maximum value for the Slider
  80979. * @param value is the start value for the Slider between min and max
  80980. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80981. */
  80982. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80983. /** @hidden */
  80984. _setSelectorLabel(selectorNb: number, label: string): void;
  80985. /** @hidden */
  80986. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80987. /** @hidden */
  80988. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80989. /** @hidden */
  80990. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80991. }
  80992. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80993. * @see https://doc.babylonjs.com/how_to/selector
  80994. */
  80995. export class SelectionPanel extends Rectangle {
  80996. /** name of SelectionPanel */
  80997. name: string;
  80998. /** an array of SelectionGroups */
  80999. groups: SelectorGroup[];
  81000. private _panel;
  81001. private _buttonColor;
  81002. private _buttonBackground;
  81003. private _headerColor;
  81004. private _barColor;
  81005. private _barHeight;
  81006. private _spacerHeight;
  81007. private _labelColor;
  81008. private _groups;
  81009. private _bars;
  81010. /**
  81011. * Creates a new SelectionPanel
  81012. * @param name of SelectionPanel
  81013. * @param groups is an array of SelectionGroups
  81014. */
  81015. constructor(
  81016. /** name of SelectionPanel */
  81017. name: string,
  81018. /** an array of SelectionGroups */
  81019. groups?: SelectorGroup[]);
  81020. protected _getTypeName(): string;
  81021. /** Gets the (stack) panel of the SelectionPanel */
  81022. get panel(): StackPanel;
  81023. /** Gets or sets the headerColor */
  81024. get headerColor(): string;
  81025. set headerColor(color: string);
  81026. private _setHeaderColor;
  81027. /** Gets or sets the button color */
  81028. get buttonColor(): string;
  81029. set buttonColor(color: string);
  81030. private _setbuttonColor;
  81031. /** Gets or sets the label color */
  81032. get labelColor(): string;
  81033. set labelColor(color: string);
  81034. private _setLabelColor;
  81035. /** Gets or sets the button background */
  81036. get buttonBackground(): string;
  81037. set buttonBackground(color: string);
  81038. private _setButtonBackground;
  81039. /** Gets or sets the color of separator bar */
  81040. get barColor(): string;
  81041. set barColor(color: string);
  81042. private _setBarColor;
  81043. /** Gets or sets the height of separator bar */
  81044. get barHeight(): string;
  81045. set barHeight(value: string);
  81046. private _setBarHeight;
  81047. /** Gets or sets the height of spacers*/
  81048. get spacerHeight(): string;
  81049. set spacerHeight(value: string);
  81050. private _setSpacerHeight;
  81051. /** Adds a bar between groups */
  81052. private _addSpacer;
  81053. /** Add a group to the selection panel
  81054. * @param group is the selector group to add
  81055. */
  81056. addGroup(group: SelectorGroup): void;
  81057. /** Remove the group from the given position
  81058. * @param groupNb is the position of the group in the list
  81059. */
  81060. removeGroup(groupNb: number): void;
  81061. /** Change a group header label
  81062. * @param label is the new group header label
  81063. * @param groupNb is the number of the group to relabel
  81064. * */
  81065. setHeaderName(label: string, groupNb: number): void;
  81066. /** Change selector label to the one given
  81067. * @param label is the new selector label
  81068. * @param groupNb is the number of the groupcontaining the selector
  81069. * @param selectorNb is the number of the selector within a group to relabel
  81070. * */
  81071. relabel(label: string, groupNb: number, selectorNb: number): void;
  81072. /** For a given group position remove the selector at the given position
  81073. * @param groupNb is the number of the group to remove the selector from
  81074. * @param selectorNb is the number of the selector within the group
  81075. */
  81076. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  81077. /** For a given group position of correct type add a checkbox button
  81078. * @param groupNb is the number of the group to remove the selector from
  81079. * @param label is the label for the selector
  81080. * @param func is the function called when the Selector is checked
  81081. * @param checked is true when Selector is checked
  81082. */
  81083. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  81084. /** For a given group position of correct type add a radio button
  81085. * @param groupNb is the number of the group to remove the selector from
  81086. * @param label is the label for the selector
  81087. * @param func is the function called when the Selector is checked
  81088. * @param checked is true when Selector is checked
  81089. */
  81090. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  81091. /**
  81092. * For a given slider group add a slider
  81093. * @param groupNb is the number of the group to add the slider to
  81094. * @param label is the label for the Slider
  81095. * @param func is the function called when the Slider moves
  81096. * @param unit is a string describing the units used, eg degrees or metres
  81097. * @param min is the minimum value for the Slider
  81098. * @param max is the maximum value for the Slider
  81099. * @param value is the start value for the Slider between min and max
  81100. * @param onVal is the function used to format the value displayed, eg radians to degrees
  81101. */
  81102. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  81103. }
  81104. }
  81105. declare module BABYLON.GUI {
  81106. /**
  81107. * Class used to hold a the container for ScrollViewer
  81108. * @hidden
  81109. */
  81110. export class _ScrollViewerWindow extends Container {
  81111. parentClientWidth: number;
  81112. parentClientHeight: number;
  81113. private _freezeControls;
  81114. private _parentMeasure;
  81115. private _oldLeft;
  81116. private _oldTop;
  81117. get freezeControls(): boolean;
  81118. set freezeControls(value: boolean);
  81119. private _bucketWidth;
  81120. private _bucketHeight;
  81121. private _buckets;
  81122. private _bucketLen;
  81123. get bucketWidth(): number;
  81124. get bucketHeight(): number;
  81125. setBucketSizes(width: number, height: number): void;
  81126. private _useBuckets;
  81127. private _makeBuckets;
  81128. private _dispatchInBuckets;
  81129. private _updateMeasures;
  81130. private _updateChildrenMeasures;
  81131. private _restoreMeasures;
  81132. /**
  81133. * Creates a new ScrollViewerWindow
  81134. * @param name of ScrollViewerWindow
  81135. */
  81136. constructor(name?: string);
  81137. protected _getTypeName(): string;
  81138. /** @hidden */
  81139. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81140. /** @hidden */
  81141. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  81142. private _scrollChildren;
  81143. private _scrollChildrenWithBuckets;
  81144. /** @hidden */
  81145. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  81146. protected _postMeasure(): void;
  81147. }
  81148. }
  81149. declare module BABYLON.GUI {
  81150. /**
  81151. * Class used to create slider controls
  81152. */
  81153. export class ScrollBar extends BaseSlider {
  81154. name?: string | undefined;
  81155. private _background;
  81156. private _borderColor;
  81157. private _tempMeasure;
  81158. /** Gets or sets border color */
  81159. get borderColor(): string;
  81160. set borderColor(value: string);
  81161. /** Gets or sets background color */
  81162. get background(): string;
  81163. set background(value: string);
  81164. /**
  81165. * Creates a new Slider
  81166. * @param name defines the control name
  81167. */
  81168. constructor(name?: string | undefined);
  81169. protected _getTypeName(): string;
  81170. protected _getThumbThickness(): number;
  81171. _draw(context: CanvasRenderingContext2D): void;
  81172. private _first;
  81173. private _originX;
  81174. private _originY;
  81175. /** @hidden */
  81176. protected _updateValueFromPointer(x: number, y: number): void;
  81177. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  81178. }
  81179. }
  81180. declare module BABYLON.GUI {
  81181. /**
  81182. * Class used to create slider controls
  81183. */
  81184. export class ImageScrollBar extends BaseSlider {
  81185. name?: string | undefined;
  81186. private _backgroundBaseImage;
  81187. private _backgroundImage;
  81188. private _thumbImage;
  81189. private _thumbBaseImage;
  81190. private _thumbLength;
  81191. private _thumbHeight;
  81192. private _barImageHeight;
  81193. private _tempMeasure;
  81194. /** Number of 90° rotation to apply on the images when in vertical mode */
  81195. num90RotationInVerticalMode: number;
  81196. /**
  81197. * Gets or sets the image used to render the background for horizontal bar
  81198. */
  81199. get backgroundImage(): Image;
  81200. set backgroundImage(value: Image);
  81201. /**
  81202. * Gets or sets the image used to render the thumb
  81203. */
  81204. get thumbImage(): Image;
  81205. set thumbImage(value: Image);
  81206. /**
  81207. * Gets or sets the length of the thumb
  81208. */
  81209. get thumbLength(): number;
  81210. set thumbLength(value: number);
  81211. /**
  81212. * Gets or sets the height of the thumb
  81213. */
  81214. get thumbHeight(): number;
  81215. set thumbHeight(value: number);
  81216. /**
  81217. * Gets or sets the height of the bar image
  81218. */
  81219. get barImageHeight(): number;
  81220. set barImageHeight(value: number);
  81221. /**
  81222. * Creates a new ImageScrollBar
  81223. * @param name defines the control name
  81224. */
  81225. constructor(name?: string | undefined);
  81226. protected _getTypeName(): string;
  81227. protected _getThumbThickness(): number;
  81228. _draw(context: CanvasRenderingContext2D): void;
  81229. private _first;
  81230. private _originX;
  81231. private _originY;
  81232. /** @hidden */
  81233. protected _updateValueFromPointer(x: number, y: number): void;
  81234. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  81235. }
  81236. }
  81237. declare module BABYLON.GUI {
  81238. /**
  81239. * Class used to hold a viewer window and sliders in a grid
  81240. */
  81241. export class ScrollViewer extends Rectangle {
  81242. private _grid;
  81243. private _horizontalBarSpace;
  81244. private _verticalBarSpace;
  81245. private _dragSpace;
  81246. private _horizontalBar;
  81247. private _verticalBar;
  81248. private _barColor;
  81249. private _barBackground;
  81250. private _barImage;
  81251. private _horizontalBarImage;
  81252. private _verticalBarImage;
  81253. private _barBackgroundImage;
  81254. private _horizontalBarBackgroundImage;
  81255. private _verticalBarBackgroundImage;
  81256. private _barSize;
  81257. private _window;
  81258. private _pointerIsOver;
  81259. private _wheelPrecision;
  81260. private _onWheelObserver;
  81261. private _clientWidth;
  81262. private _clientHeight;
  81263. private _useImageBar;
  81264. private _thumbLength;
  81265. private _thumbHeight;
  81266. private _barImageHeight;
  81267. private _horizontalBarImageHeight;
  81268. private _verticalBarImageHeight;
  81269. private _oldWindowContentsWidth;
  81270. private _oldWindowContentsHeight;
  81271. /**
  81272. * Gets the horizontal scrollbar
  81273. */
  81274. get horizontalBar(): ScrollBar | ImageScrollBar;
  81275. /**
  81276. * Gets the vertical scrollbar
  81277. */
  81278. get verticalBar(): ScrollBar | ImageScrollBar;
  81279. /**
  81280. * Adds a new control to the current container
  81281. * @param control defines the control to add
  81282. * @returns the current container
  81283. */
  81284. addControl(control: BABYLON.Nullable<Control>): Container;
  81285. /**
  81286. * Removes a control from the current container
  81287. * @param control defines the control to remove
  81288. * @returns the current container
  81289. */
  81290. removeControl(control: Control): Container;
  81291. /** Gets the list of children */
  81292. get children(): Control[];
  81293. _flagDescendantsAsMatrixDirty(): void;
  81294. /**
  81295. * Freezes or unfreezes the controls in the window.
  81296. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  81297. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  81298. */
  81299. get freezeControls(): boolean;
  81300. set freezeControls(value: boolean);
  81301. /** Gets the bucket width */
  81302. get bucketWidth(): number;
  81303. /** Gets the bucket height */
  81304. get bucketHeight(): number;
  81305. /**
  81306. * Sets the bucket sizes.
  81307. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  81308. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  81309. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  81310. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  81311. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  81312. * used), that's why it is not enabled by default.
  81313. * @param width width of the bucket
  81314. * @param height height of the bucket
  81315. */
  81316. setBucketSizes(width: number, height: number): void;
  81317. private _forceHorizontalBar;
  81318. private _forceVerticalBar;
  81319. /**
  81320. * Forces the horizontal scroll bar to be displayed
  81321. */
  81322. get forceHorizontalBar(): boolean;
  81323. set forceHorizontalBar(value: boolean);
  81324. /**
  81325. * Forces the vertical scroll bar to be displayed
  81326. */
  81327. get forceVerticalBar(): boolean;
  81328. set forceVerticalBar(value: boolean);
  81329. /**
  81330. * Creates a new ScrollViewer
  81331. * @param name of ScrollViewer
  81332. */
  81333. constructor(name?: string, isImageBased?: boolean);
  81334. /** Reset the scroll viewer window to initial size */
  81335. resetWindow(): void;
  81336. protected _getTypeName(): string;
  81337. private _buildClientSizes;
  81338. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81339. protected _postMeasure(): void;
  81340. /**
  81341. * Gets or sets the mouse wheel precision
  81342. * from 0 to 1 with a default value of 0.05
  81343. * */
  81344. get wheelPrecision(): number;
  81345. set wheelPrecision(value: number);
  81346. /** Gets or sets the scroll bar container background color */
  81347. get scrollBackground(): string;
  81348. set scrollBackground(color: string);
  81349. /** Gets or sets the bar color */
  81350. get barColor(): string;
  81351. set barColor(color: string);
  81352. /** Gets or sets the bar image */
  81353. get thumbImage(): Image;
  81354. set thumbImage(value: Image);
  81355. /** Gets or sets the horizontal bar image */
  81356. get horizontalThumbImage(): Image;
  81357. set horizontalThumbImage(value: Image);
  81358. /** Gets or sets the vertical bar image */
  81359. get verticalThumbImage(): Image;
  81360. set verticalThumbImage(value: Image);
  81361. /** Gets or sets the size of the bar */
  81362. get barSize(): number;
  81363. set barSize(value: number);
  81364. /** Gets or sets the length of the thumb */
  81365. get thumbLength(): number;
  81366. set thumbLength(value: number);
  81367. /** Gets or sets the height of the thumb */
  81368. get thumbHeight(): number;
  81369. set thumbHeight(value: number);
  81370. /** Gets or sets the height of the bar image */
  81371. get barImageHeight(): number;
  81372. set barImageHeight(value: number);
  81373. /** Gets or sets the height of the horizontal bar image */
  81374. get horizontalBarImageHeight(): number;
  81375. set horizontalBarImageHeight(value: number);
  81376. /** Gets or sets the height of the vertical bar image */
  81377. get verticalBarImageHeight(): number;
  81378. set verticalBarImageHeight(value: number);
  81379. /** Gets or sets the bar background */
  81380. get barBackground(): string;
  81381. set barBackground(color: string);
  81382. /** Gets or sets the bar background image */
  81383. get barImage(): Image;
  81384. set barImage(value: Image);
  81385. /** Gets or sets the horizontal bar background image */
  81386. get horizontalBarImage(): Image;
  81387. set horizontalBarImage(value: Image);
  81388. /** Gets or sets the vertical bar background image */
  81389. get verticalBarImage(): Image;
  81390. set verticalBarImage(value: Image);
  81391. private _setWindowPosition;
  81392. /** @hidden */
  81393. private _updateScroller;
  81394. _link(host: AdvancedDynamicTexture): void;
  81395. /** @hidden */
  81396. private _addBar;
  81397. /** @hidden */
  81398. private _attachWheel;
  81399. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  81400. /** Releases associated resources */
  81401. dispose(): void;
  81402. }
  81403. }
  81404. declare module BABYLON.GUI {
  81405. /** Class used to render a grid */
  81406. export class DisplayGrid extends Control {
  81407. name?: string | undefined;
  81408. private _cellWidth;
  81409. private _cellHeight;
  81410. private _minorLineTickness;
  81411. private _minorLineColor;
  81412. private _majorLineTickness;
  81413. private _majorLineColor;
  81414. private _majorLineFrequency;
  81415. private _background;
  81416. private _displayMajorLines;
  81417. private _displayMinorLines;
  81418. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  81419. get displayMinorLines(): boolean;
  81420. set displayMinorLines(value: boolean);
  81421. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  81422. get displayMajorLines(): boolean;
  81423. set displayMajorLines(value: boolean);
  81424. /** Gets or sets background color (Black by default) */
  81425. get background(): string;
  81426. set background(value: string);
  81427. /** Gets or sets the width of each cell (20 by default) */
  81428. get cellWidth(): number;
  81429. set cellWidth(value: number);
  81430. /** Gets or sets the height of each cell (20 by default) */
  81431. get cellHeight(): number;
  81432. set cellHeight(value: number);
  81433. /** Gets or sets the tickness of minor lines (1 by default) */
  81434. get minorLineTickness(): number;
  81435. set minorLineTickness(value: number);
  81436. /** Gets or sets the color of minor lines (DarkGray by default) */
  81437. get minorLineColor(): string;
  81438. set minorLineColor(value: string);
  81439. /** Gets or sets the tickness of major lines (2 by default) */
  81440. get majorLineTickness(): number;
  81441. set majorLineTickness(value: number);
  81442. /** Gets or sets the color of major lines (White by default) */
  81443. get majorLineColor(): string;
  81444. set majorLineColor(value: string);
  81445. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  81446. get majorLineFrequency(): number;
  81447. set majorLineFrequency(value: number);
  81448. /**
  81449. * Creates a new GridDisplayRectangle
  81450. * @param name defines the control name
  81451. */
  81452. constructor(name?: string | undefined);
  81453. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81454. protected _getTypeName(): string;
  81455. }
  81456. }
  81457. declare module BABYLON.GUI {
  81458. /**
  81459. * Class used to create slider controls based on images
  81460. */
  81461. export class ImageBasedSlider extends BaseSlider {
  81462. name?: string | undefined;
  81463. private _backgroundImage;
  81464. private _thumbImage;
  81465. private _valueBarImage;
  81466. private _tempMeasure;
  81467. get displayThumb(): boolean;
  81468. set displayThumb(value: boolean);
  81469. /**
  81470. * Gets or sets the image used to render the background
  81471. */
  81472. get backgroundImage(): Image;
  81473. set backgroundImage(value: Image);
  81474. /**
  81475. * Gets or sets the image used to render the value bar
  81476. */
  81477. get valueBarImage(): Image;
  81478. set valueBarImage(value: Image);
  81479. /**
  81480. * Gets or sets the image used to render the thumb
  81481. */
  81482. get thumbImage(): Image;
  81483. set thumbImage(value: Image);
  81484. /**
  81485. * Creates a new ImageBasedSlider
  81486. * @param name defines the control name
  81487. */
  81488. constructor(name?: string | undefined);
  81489. protected _getTypeName(): string;
  81490. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81491. }
  81492. }
  81493. declare module BABYLON.GUI {
  81494. /**
  81495. * Forcing an export so that this code will execute
  81496. * @hidden
  81497. */
  81498. const name = "Statics";
  81499. }
  81500. declare module BABYLON.GUI {
  81501. /**
  81502. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  81503. */
  81504. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  81505. /**
  81506. * Define the instrumented AdvancedDynamicTexture.
  81507. */
  81508. texture: AdvancedDynamicTexture;
  81509. private _captureRenderTime;
  81510. private _renderTime;
  81511. private _captureLayoutTime;
  81512. private _layoutTime;
  81513. private _onBeginRenderObserver;
  81514. private _onEndRenderObserver;
  81515. private _onBeginLayoutObserver;
  81516. private _onEndLayoutObserver;
  81517. /**
  81518. * Gets the perf counter used to capture render time
  81519. */
  81520. get renderTimeCounter(): BABYLON.PerfCounter;
  81521. /**
  81522. * Gets the perf counter used to capture layout time
  81523. */
  81524. get layoutTimeCounter(): BABYLON.PerfCounter;
  81525. /**
  81526. * Enable or disable the render time capture
  81527. */
  81528. get captureRenderTime(): boolean;
  81529. set captureRenderTime(value: boolean);
  81530. /**
  81531. * Enable or disable the layout time capture
  81532. */
  81533. get captureLayoutTime(): boolean;
  81534. set captureLayoutTime(value: boolean);
  81535. /**
  81536. * Instantiates a new advanced dynamic texture instrumentation.
  81537. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  81538. * @param texture Defines the AdvancedDynamicTexture to instrument
  81539. */
  81540. constructor(
  81541. /**
  81542. * Define the instrumented AdvancedDynamicTexture.
  81543. */
  81544. texture: AdvancedDynamicTexture);
  81545. /**
  81546. * Dispose and release associated resources.
  81547. */
  81548. dispose(): void;
  81549. }
  81550. }
  81551. declare module BABYLON.GUI {
  81552. /**
  81553. * Class used to load GUI via XML.
  81554. */
  81555. export class XmlLoader {
  81556. private _nodes;
  81557. private _nodeTypes;
  81558. private _isLoaded;
  81559. private _objectAttributes;
  81560. private _parentClass;
  81561. /**
  81562. * Create a new xml loader
  81563. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  81564. */
  81565. constructor(parentClass?: null);
  81566. private _getChainElement;
  81567. private _getClassAttribute;
  81568. private _createGuiElement;
  81569. private _parseGrid;
  81570. private _parseElement;
  81571. private _prepareSourceElement;
  81572. private _parseElementsFromSource;
  81573. private _parseXml;
  81574. /**
  81575. * Gets if the loading has finished.
  81576. * @returns whether the loading has finished or not
  81577. */
  81578. isLoaded(): boolean;
  81579. /**
  81580. * Gets a loaded node / control by id.
  81581. * @param id the Controls id set in the xml
  81582. * @returns element of type Control
  81583. */
  81584. getNodeById(id: string): any;
  81585. /**
  81586. * Gets all loaded nodes / controls
  81587. * @returns Array of controls
  81588. */
  81589. getNodes(): any;
  81590. /**
  81591. * Initiates the xml layout loading
  81592. * @param xmlFile defines the xml layout to load
  81593. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81594. * @param callback defines the callback called on layout load.
  81595. */
  81596. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81597. }
  81598. }
  81599. declare module BABYLON.GUI {
  81600. /**
  81601. * Class used to create containers for controls
  81602. */
  81603. export class Container3D extends Control3D {
  81604. private _blockLayout;
  81605. /**
  81606. * Gets the list of child controls
  81607. */
  81608. protected _children: Control3D[];
  81609. /**
  81610. * Gets the list of child controls
  81611. */
  81612. get children(): Array<Control3D>;
  81613. /**
  81614. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81615. * This is helpful to optimize layout operation when adding multiple children in a row
  81616. */
  81617. get blockLayout(): boolean;
  81618. set blockLayout(value: boolean);
  81619. /**
  81620. * Creates a new container
  81621. * @param name defines the container name
  81622. */
  81623. constructor(name?: string);
  81624. /**
  81625. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81626. * @returns the current container
  81627. */
  81628. updateLayout(): Container3D;
  81629. /**
  81630. * Gets a boolean indicating if the given control is in the children of this control
  81631. * @param control defines the control to check
  81632. * @returns true if the control is in the child list
  81633. */
  81634. containsControl(control: Control3D): boolean;
  81635. /**
  81636. * Adds a control to the children of this control
  81637. * @param control defines the control to add
  81638. * @returns the current container
  81639. */
  81640. addControl(control: Control3D): Container3D;
  81641. /**
  81642. * This function will be called everytime a new control is added
  81643. */
  81644. protected _arrangeChildren(): void;
  81645. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81646. /**
  81647. * Removes a control from the children of this control
  81648. * @param control defines the control to remove
  81649. * @returns the current container
  81650. */
  81651. removeControl(control: Control3D): Container3D;
  81652. protected _getTypeName(): string;
  81653. /**
  81654. * Releases all associated resources
  81655. */
  81656. dispose(): void;
  81657. /** Control rotation will remain unchanged */
  81658. static readonly UNSET_ORIENTATION: number;
  81659. /** Control will rotate to make it look at sphere central axis */
  81660. static readonly FACEORIGIN_ORIENTATION: number;
  81661. /** Control will rotate to make it look back at sphere central axis */
  81662. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81663. /** Control will rotate to look at z axis (0, 0, 1) */
  81664. static readonly FACEFORWARD_ORIENTATION: number;
  81665. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81666. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81667. }
  81668. }
  81669. declare module BABYLON.GUI {
  81670. /**
  81671. * Class used to manage 3D user interface
  81672. * @see https://doc.babylonjs.com/how_to/gui3d
  81673. */
  81674. export class GUI3DManager implements BABYLON.IDisposable {
  81675. private _scene;
  81676. private _sceneDisposeObserver;
  81677. private _utilityLayer;
  81678. private _rootContainer;
  81679. private _pointerObserver;
  81680. private _pointerOutObserver;
  81681. /** @hidden */
  81682. _lastPickedControl: Control3D;
  81683. /** @hidden */
  81684. _lastControlOver: {
  81685. [pointerId: number]: Control3D;
  81686. };
  81687. /** @hidden */
  81688. _lastControlDown: {
  81689. [pointerId: number]: Control3D;
  81690. };
  81691. /**
  81692. * BABYLON.Observable raised when the point picked by the pointer events changed
  81693. */
  81694. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81695. /** @hidden */
  81696. _sharedMaterials: {
  81697. [key: string]: BABYLON.Material;
  81698. };
  81699. /** Gets the hosting scene */
  81700. get scene(): BABYLON.Scene;
  81701. /** Gets associated utility layer */
  81702. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81703. /**
  81704. * Creates a new GUI3DManager
  81705. * @param scene
  81706. */
  81707. constructor(scene?: BABYLON.Scene);
  81708. private _handlePointerOut;
  81709. private _doPicking;
  81710. /**
  81711. * Gets the root container
  81712. */
  81713. get rootContainer(): Container3D;
  81714. /**
  81715. * Gets a boolean indicating if the given control is in the root child list
  81716. * @param control defines the control to check
  81717. * @returns true if the control is in the root child list
  81718. */
  81719. containsControl(control: Control3D): boolean;
  81720. /**
  81721. * Adds a control to the root child list
  81722. * @param control defines the control to add
  81723. * @returns the current manager
  81724. */
  81725. addControl(control: Control3D): GUI3DManager;
  81726. /**
  81727. * Removes a control from the root child list
  81728. * @param control defines the control to remove
  81729. * @returns the current container
  81730. */
  81731. removeControl(control: Control3D): GUI3DManager;
  81732. /**
  81733. * Releases all associated resources
  81734. */
  81735. dispose(): void;
  81736. }
  81737. }
  81738. declare module BABYLON.GUI {
  81739. /**
  81740. * Class used to transport BABYLON.Vector3 information for pointer events
  81741. */
  81742. export class Vector3WithInfo extends BABYLON.Vector3 {
  81743. /** defines the current mouse button index */
  81744. buttonIndex: number;
  81745. /**
  81746. * Creates a new Vector3WithInfo
  81747. * @param source defines the vector3 data to transport
  81748. * @param buttonIndex defines the current mouse button index
  81749. */
  81750. constructor(source: BABYLON.Vector3,
  81751. /** defines the current mouse button index */
  81752. buttonIndex?: number);
  81753. }
  81754. }
  81755. declare module BABYLON.GUI {
  81756. /**
  81757. * Class used as base class for controls
  81758. */
  81759. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81760. /** Defines the control name */
  81761. name?: string | undefined;
  81762. /** @hidden */
  81763. _host: GUI3DManager;
  81764. private _node;
  81765. private _downCount;
  81766. private _enterCount;
  81767. private _downPointerIds;
  81768. private _isVisible;
  81769. /** Gets or sets the control position in world space */
  81770. get position(): BABYLON.Vector3;
  81771. set position(value: BABYLON.Vector3);
  81772. /** Gets or sets the control scaling in world space */
  81773. get scaling(): BABYLON.Vector3;
  81774. set scaling(value: BABYLON.Vector3);
  81775. /** Callback used to start pointer enter animation */
  81776. pointerEnterAnimation: () => void;
  81777. /** Callback used to start pointer out animation */
  81778. pointerOutAnimation: () => void;
  81779. /** Callback used to start pointer down animation */
  81780. pointerDownAnimation: () => void;
  81781. /** Callback used to start pointer up animation */
  81782. pointerUpAnimation: () => void;
  81783. /**
  81784. * An event triggered when the pointer move over the control
  81785. */
  81786. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81787. /**
  81788. * An event triggered when the pointer move out of the control
  81789. */
  81790. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81791. /**
  81792. * An event triggered when the pointer taps the control
  81793. */
  81794. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81795. /**
  81796. * An event triggered when pointer is up
  81797. */
  81798. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81799. /**
  81800. * An event triggered when a control is clicked on (with a mouse)
  81801. */
  81802. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81803. /**
  81804. * An event triggered when pointer enters the control
  81805. */
  81806. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81807. /**
  81808. * Gets or sets the parent container
  81809. */
  81810. parent: BABYLON.Nullable<Container3D>;
  81811. private _behaviors;
  81812. /**
  81813. * Gets the list of attached behaviors
  81814. * @see https://doc.babylonjs.com/features/behaviour
  81815. */
  81816. get behaviors(): BABYLON.Behavior<Control3D>[];
  81817. /**
  81818. * Attach a behavior to the control
  81819. * @see https://doc.babylonjs.com/features/behaviour
  81820. * @param behavior defines the behavior to attach
  81821. * @returns the current control
  81822. */
  81823. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81824. /**
  81825. * Remove an attached behavior
  81826. * @see https://doc.babylonjs.com/features/behaviour
  81827. * @param behavior defines the behavior to attach
  81828. * @returns the current control
  81829. */
  81830. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81831. /**
  81832. * Gets an attached behavior by name
  81833. * @param name defines the name of the behavior to look for
  81834. * @see https://doc.babylonjs.com/features/behaviour
  81835. * @returns null if behavior was not found else the requested behavior
  81836. */
  81837. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81838. /** Gets or sets a boolean indicating if the control is visible */
  81839. get isVisible(): boolean;
  81840. set isVisible(value: boolean);
  81841. /**
  81842. * Creates a new control
  81843. * @param name defines the control name
  81844. */
  81845. constructor(
  81846. /** Defines the control name */
  81847. name?: string | undefined);
  81848. /**
  81849. * Gets a string representing the class name
  81850. */
  81851. get typeName(): string;
  81852. /**
  81853. * Get the current class name of the control.
  81854. * @returns current class name
  81855. */
  81856. getClassName(): string;
  81857. protected _getTypeName(): string;
  81858. /**
  81859. * Gets the transform node used by this control
  81860. */
  81861. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81862. /**
  81863. * Gets the mesh used to render this control
  81864. */
  81865. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81866. /**
  81867. * Link the control as child of the given node
  81868. * @param node defines the node to link to. Use null to unlink the control
  81869. * @returns the current control
  81870. */
  81871. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81872. /** @hidden **/
  81873. _prepareNode(scene: BABYLON.Scene): void;
  81874. /**
  81875. * Node creation.
  81876. * Can be overriden by children
  81877. * @param scene defines the scene where the node must be attached
  81878. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81879. */
  81880. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81881. /**
  81882. * Affect a material to the given mesh
  81883. * @param mesh defines the mesh which will represent the control
  81884. */
  81885. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81886. /** @hidden */
  81887. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81888. /** @hidden */
  81889. _onPointerEnter(target: Control3D): boolean;
  81890. /** @hidden */
  81891. _onPointerOut(target: Control3D): void;
  81892. /** @hidden */
  81893. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81894. /** @hidden */
  81895. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81896. /** @hidden */
  81897. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81898. /** @hidden */
  81899. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81900. /** @hidden */
  81901. _disposeNode(): void;
  81902. /**
  81903. * Releases all associated resources
  81904. */
  81905. dispose(): void;
  81906. }
  81907. }
  81908. declare module BABYLON.GUI {
  81909. /**
  81910. * Class used as a root to all buttons
  81911. */
  81912. export class AbstractButton3D extends Control3D {
  81913. /**
  81914. * Creates a new button
  81915. * @param name defines the control name
  81916. */
  81917. constructor(name?: string);
  81918. protected _getTypeName(): string;
  81919. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81920. }
  81921. }
  81922. declare module BABYLON.GUI {
  81923. /**
  81924. * Class used to create a button in 3D
  81925. */
  81926. export class Button3D extends AbstractButton3D {
  81927. /** @hidden */
  81928. protected _currentMaterial: BABYLON.Material;
  81929. private _facadeTexture;
  81930. private _content;
  81931. private _contentResolution;
  81932. private _contentScaleRatio;
  81933. /**
  81934. * Gets or sets the texture resolution used to render content (512 by default)
  81935. */
  81936. get contentResolution(): BABYLON.int;
  81937. set contentResolution(value: BABYLON.int);
  81938. /**
  81939. * Gets or sets the texture scale ratio used to render content (2 by default)
  81940. */
  81941. get contentScaleRatio(): number;
  81942. set contentScaleRatio(value: number);
  81943. protected _disposeFacadeTexture(): void;
  81944. protected _resetContent(): void;
  81945. /**
  81946. * Creates a new button
  81947. * @param name defines the control name
  81948. */
  81949. constructor(name?: string);
  81950. /**
  81951. * Gets or sets the GUI 2D content used to display the button's facade
  81952. */
  81953. get content(): Control;
  81954. set content(value: Control);
  81955. /**
  81956. * Apply the facade texture (created from the content property).
  81957. * This function can be overloaded by child classes
  81958. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81959. */
  81960. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81961. protected _getTypeName(): string;
  81962. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81963. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81964. /**
  81965. * Releases all associated resources
  81966. */
  81967. dispose(): void;
  81968. }
  81969. }
  81970. declare module BABYLON.GUI {
  81971. /**
  81972. * Abstract class used to create a container panel deployed on the surface of a volume
  81973. */
  81974. export abstract class VolumeBasedPanel extends Container3D {
  81975. private _columns;
  81976. private _rows;
  81977. private _rowThenColum;
  81978. private _orientation;
  81979. protected _cellWidth: number;
  81980. protected _cellHeight: number;
  81981. /**
  81982. * Gets or sets the distance between elements
  81983. */
  81984. margin: number;
  81985. /**
  81986. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81987. * | Value | Type | Description |
  81988. * | ----- | ----------------------------------- | ----------- |
  81989. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81990. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81991. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81992. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81993. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81994. */
  81995. get orientation(): number;
  81996. set orientation(value: number);
  81997. /**
  81998. * Gets or sets the number of columns requested (10 by default).
  81999. * The panel will automatically compute the number of rows based on number of child controls.
  82000. */
  82001. get columns(): BABYLON.int;
  82002. set columns(value: BABYLON.int);
  82003. /**
  82004. * Gets or sets a the number of rows requested.
  82005. * The panel will automatically compute the number of columns based on number of child controls.
  82006. */
  82007. get rows(): BABYLON.int;
  82008. set rows(value: BABYLON.int);
  82009. /**
  82010. * Creates new VolumeBasedPanel
  82011. */
  82012. constructor();
  82013. protected _arrangeChildren(): void;
  82014. /** Child classes must implement this function to provide correct control positioning */
  82015. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82016. /** Child classes can implement this function to provide additional processing */
  82017. protected _finalProcessing(): void;
  82018. }
  82019. }
  82020. declare module BABYLON.GUI {
  82021. /**
  82022. * Class used to create a container panel deployed on the surface of a cylinder
  82023. */
  82024. export class CylinderPanel extends VolumeBasedPanel {
  82025. private _radius;
  82026. /**
  82027. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  82028. */
  82029. get radius(): BABYLON.float;
  82030. set radius(value: BABYLON.float);
  82031. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82032. private _cylindricalMapping;
  82033. }
  82034. }
  82035. declare module BABYLON.GUI {
  82036. /** @hidden */
  82037. export var fluentVertexShader: {
  82038. name: string;
  82039. shader: string;
  82040. };
  82041. }
  82042. declare module BABYLON.GUI {
  82043. /** @hidden */
  82044. export var fluentPixelShader: {
  82045. name: string;
  82046. shader: string;
  82047. };
  82048. }
  82049. declare module BABYLON.GUI {
  82050. /** @hidden */
  82051. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  82052. INNERGLOW: boolean;
  82053. BORDER: boolean;
  82054. HOVERLIGHT: boolean;
  82055. TEXTURE: boolean;
  82056. constructor();
  82057. }
  82058. /**
  82059. * Class used to render controls with fluent desgin
  82060. */
  82061. export class FluentMaterial extends BABYLON.PushMaterial {
  82062. /**
  82063. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  82064. */
  82065. innerGlowColorIntensity: number;
  82066. /**
  82067. * Gets or sets the inner glow color (white by default)
  82068. */
  82069. innerGlowColor: BABYLON.Color3;
  82070. /**
  82071. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  82072. */
  82073. albedoColor: BABYLON.Color3;
  82074. /**
  82075. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  82076. */
  82077. renderBorders: boolean;
  82078. /**
  82079. * Gets or sets border width (default is 0.5)
  82080. */
  82081. borderWidth: number;
  82082. /**
  82083. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  82084. */
  82085. edgeSmoothingValue: number;
  82086. /**
  82087. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  82088. */
  82089. borderMinValue: number;
  82090. /**
  82091. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  82092. */
  82093. renderHoverLight: boolean;
  82094. /**
  82095. * Gets or sets the radius used to render the hover light (default is 1.0)
  82096. */
  82097. hoverRadius: number;
  82098. /**
  82099. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  82100. */
  82101. hoverColor: BABYLON.Color4;
  82102. /**
  82103. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  82104. */
  82105. hoverPosition: BABYLON.Vector3;
  82106. private _albedoTexture;
  82107. /** Gets or sets the texture to use for albedo color */
  82108. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82109. /**
  82110. * Creates a new Fluent material
  82111. * @param name defines the name of the material
  82112. * @param scene defines the hosting scene
  82113. */
  82114. constructor(name: string, scene: BABYLON.Scene);
  82115. needAlphaBlending(): boolean;
  82116. needAlphaTesting(): boolean;
  82117. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82118. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82119. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82120. getActiveTextures(): BABYLON.BaseTexture[];
  82121. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82122. dispose(forceDisposeEffect?: boolean): void;
  82123. clone(name: string): FluentMaterial;
  82124. serialize(): any;
  82125. getClassName(): string;
  82126. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  82127. }
  82128. }
  82129. declare module BABYLON.GUI {
  82130. /**
  82131. * Class used to create a holographic button in 3D
  82132. */
  82133. export class HolographicButton extends Button3D {
  82134. private _backPlate;
  82135. private _textPlate;
  82136. private _frontPlate;
  82137. private _text;
  82138. private _imageUrl;
  82139. private _shareMaterials;
  82140. private _frontMaterial;
  82141. private _backMaterial;
  82142. private _plateMaterial;
  82143. private _pickedPointObserver;
  82144. private _tooltipFade;
  82145. private _tooltipTextBlock;
  82146. private _tooltipTexture;
  82147. private _tooltipMesh;
  82148. private _tooltipHoverObserver;
  82149. private _tooltipOutObserver;
  82150. private _disposeTooltip;
  82151. /**
  82152. * Rendering ground id of all the mesh in the button
  82153. */
  82154. set renderingGroupId(id: number);
  82155. get renderingGroupId(): number;
  82156. /**
  82157. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  82158. */
  82159. set tooltipText(text: BABYLON.Nullable<string>);
  82160. get tooltipText(): BABYLON.Nullable<string>;
  82161. /**
  82162. * Gets or sets text for the button
  82163. */
  82164. get text(): string;
  82165. set text(value: string);
  82166. /**
  82167. * Gets or sets the image url for the button
  82168. */
  82169. get imageUrl(): string;
  82170. set imageUrl(value: string);
  82171. /**
  82172. * Gets the back material used by this button
  82173. */
  82174. get backMaterial(): FluentMaterial;
  82175. /**
  82176. * Gets the front material used by this button
  82177. */
  82178. get frontMaterial(): FluentMaterial;
  82179. /**
  82180. * Gets the plate material used by this button
  82181. */
  82182. get plateMaterial(): BABYLON.StandardMaterial;
  82183. /**
  82184. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  82185. */
  82186. get shareMaterials(): boolean;
  82187. /**
  82188. * Creates a new button
  82189. * @param name defines the control name
  82190. */
  82191. constructor(name?: string, shareMaterials?: boolean);
  82192. protected _getTypeName(): string;
  82193. private _rebuildContent;
  82194. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  82195. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  82196. private _createBackMaterial;
  82197. private _createFrontMaterial;
  82198. private _createPlateMaterial;
  82199. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  82200. /**
  82201. * Releases all associated resources
  82202. */
  82203. dispose(): void;
  82204. }
  82205. }
  82206. declare module BABYLON.GUI {
  82207. /**
  82208. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  82209. */
  82210. export class MeshButton3D extends Button3D {
  82211. /** @hidden */
  82212. protected _currentMesh: BABYLON.Mesh;
  82213. /**
  82214. * Creates a new 3D button based on a mesh
  82215. * @param mesh mesh to become a 3D button
  82216. * @param name defines the control name
  82217. */
  82218. constructor(mesh: BABYLON.Mesh, name?: string);
  82219. protected _getTypeName(): string;
  82220. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  82221. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  82222. }
  82223. }
  82224. declare module BABYLON.GUI {
  82225. /**
  82226. * Class used to create a container panel deployed on the surface of a plane
  82227. */
  82228. export class PlanePanel extends VolumeBasedPanel {
  82229. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82230. }
  82231. }
  82232. declare module BABYLON.GUI {
  82233. /**
  82234. * Class used to create a container panel where items get randomized planar mapping
  82235. */
  82236. export class ScatterPanel extends VolumeBasedPanel {
  82237. private _iteration;
  82238. /**
  82239. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  82240. */
  82241. get iteration(): BABYLON.float;
  82242. set iteration(value: BABYLON.float);
  82243. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82244. private _scatterMapping;
  82245. protected _finalProcessing(): void;
  82246. }
  82247. }
  82248. declare module BABYLON.GUI {
  82249. /**
  82250. * Class used to create a container panel deployed on the surface of a sphere
  82251. */
  82252. export class SpherePanel extends VolumeBasedPanel {
  82253. private _radius;
  82254. /**
  82255. * Gets or sets the radius of the sphere where to project controls (5 by default)
  82256. */
  82257. get radius(): BABYLON.float;
  82258. set radius(value: BABYLON.float);
  82259. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82260. private _sphericalMapping;
  82261. }
  82262. }
  82263. declare module BABYLON.GUI {
  82264. /**
  82265. * Class used to create a stack panel in 3D on XY plane
  82266. */
  82267. export class StackPanel3D extends Container3D {
  82268. private _isVertical;
  82269. /**
  82270. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  82271. */
  82272. get isVertical(): boolean;
  82273. set isVertical(value: boolean);
  82274. /**
  82275. * Gets or sets the distance between elements
  82276. */
  82277. margin: number;
  82278. /**
  82279. * Creates new StackPanel
  82280. * @param isVertical
  82281. */
  82282. constructor(isVertical?: boolean);
  82283. protected _arrangeChildren(): void;
  82284. }
  82285. }
  82286. declare module BABYLON {
  82287. /**
  82288. * Configuration for glTF validation
  82289. */
  82290. export interface IGLTFValidationConfiguration {
  82291. /**
  82292. * The url of the glTF validator.
  82293. */
  82294. url: string;
  82295. }
  82296. /**
  82297. * glTF validation
  82298. */
  82299. export class GLTFValidation {
  82300. /**
  82301. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  82302. */
  82303. static Configuration: IGLTFValidationConfiguration;
  82304. private static _LoadScriptPromise;
  82305. /**
  82306. * Validate a glTF asset using the glTF-Validator.
  82307. * @param data The JSON of a glTF or the array buffer of a binary glTF
  82308. * @param rootUrl The root url for the glTF
  82309. * @param fileName The file name for the glTF
  82310. * @param getExternalResource The callback to get external resources for the glTF validator
  82311. * @returns A promise that resolves with the glTF validation results once complete
  82312. */
  82313. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  82314. }
  82315. }
  82316. declare module BABYLON {
  82317. /**
  82318. * Mode that determines the coordinate system to use.
  82319. */
  82320. export enum GLTFLoaderCoordinateSystemMode {
  82321. /**
  82322. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  82323. */
  82324. AUTO = 0,
  82325. /**
  82326. * Sets the useRightHandedSystem flag on the scene.
  82327. */
  82328. FORCE_RIGHT_HANDED = 1
  82329. }
  82330. /**
  82331. * Mode that determines what animations will start.
  82332. */
  82333. export enum GLTFLoaderAnimationStartMode {
  82334. /**
  82335. * No animation will start.
  82336. */
  82337. NONE = 0,
  82338. /**
  82339. * The first animation will start.
  82340. */
  82341. FIRST = 1,
  82342. /**
  82343. * All animations will start.
  82344. */
  82345. ALL = 2
  82346. }
  82347. /**
  82348. * Interface that contains the data for the glTF asset.
  82349. */
  82350. export interface IGLTFLoaderData {
  82351. /**
  82352. * The object that represents the glTF JSON.
  82353. */
  82354. json: Object;
  82355. /**
  82356. * The BIN chunk of a binary glTF.
  82357. */
  82358. bin: Nullable<IDataBuffer>;
  82359. }
  82360. /**
  82361. * Interface for extending the loader.
  82362. */
  82363. export interface IGLTFLoaderExtension {
  82364. /**
  82365. * The name of this extension.
  82366. */
  82367. readonly name: string;
  82368. /**
  82369. * Defines whether this extension is enabled.
  82370. */
  82371. enabled: boolean;
  82372. /**
  82373. * Defines the order of this extension.
  82374. * The loader sorts the extensions using these values when loading.
  82375. */
  82376. order?: number;
  82377. }
  82378. /**
  82379. * Loader state.
  82380. */
  82381. export enum GLTFLoaderState {
  82382. /**
  82383. * The asset is loading.
  82384. */
  82385. LOADING = 0,
  82386. /**
  82387. * The asset is ready for rendering.
  82388. */
  82389. READY = 1,
  82390. /**
  82391. * The asset is completely loaded.
  82392. */
  82393. COMPLETE = 2
  82394. }
  82395. /** @hidden */
  82396. export interface IGLTFLoader extends IDisposable {
  82397. readonly state: Nullable<GLTFLoaderState>;
  82398. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  82399. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  82400. }
  82401. /**
  82402. * File loader for loading glTF files into a scene.
  82403. */
  82404. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82405. /** @hidden */
  82406. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82407. /** @hidden */
  82408. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82409. /**
  82410. * Raised when the asset has been parsed
  82411. */
  82412. onParsedObservable: Observable<IGLTFLoaderData>;
  82413. private _onParsedObserver;
  82414. /**
  82415. * Raised when the asset has been parsed
  82416. */
  82417. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  82418. /**
  82419. * 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.
  82420. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  82421. * Defaults to true.
  82422. * @hidden
  82423. */
  82424. static IncrementalLoading: boolean;
  82425. /**
  82426. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  82427. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  82428. * @hidden
  82429. */
  82430. static HomogeneousCoordinates: boolean;
  82431. /**
  82432. * The coordinate system mode. Defaults to AUTO.
  82433. */
  82434. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  82435. /**
  82436. * The animation start mode. Defaults to FIRST.
  82437. */
  82438. animationStartMode: GLTFLoaderAnimationStartMode;
  82439. /**
  82440. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  82441. */
  82442. compileMaterials: boolean;
  82443. /**
  82444. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  82445. */
  82446. useClipPlane: boolean;
  82447. /**
  82448. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  82449. */
  82450. compileShadowGenerators: boolean;
  82451. /**
  82452. * Defines if the Alpha blended materials are only applied as coverage.
  82453. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  82454. * If true, no extra effects are applied to transparent pixels.
  82455. */
  82456. transparencyAsCoverage: boolean;
  82457. /**
  82458. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  82459. * Enabling will disable offline support and glTF validator.
  82460. * Defaults to false.
  82461. */
  82462. useRangeRequests: boolean;
  82463. /**
  82464. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  82465. */
  82466. createInstances: boolean;
  82467. /**
  82468. * 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.
  82469. */
  82470. alwaysComputeBoundingBox: boolean;
  82471. /**
  82472. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  82473. */
  82474. loadAllMaterials: boolean;
  82475. /**
  82476. * Function called before loading a url referenced by the asset.
  82477. */
  82478. preprocessUrlAsync: (url: string) => Promise<string>;
  82479. /**
  82480. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82481. * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  82482. */
  82483. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  82484. private _onMeshLoadedObserver;
  82485. /**
  82486. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82487. * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  82488. */
  82489. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  82490. /**
  82491. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  82492. */
  82493. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  82494. private _onTextureLoadedObserver;
  82495. /**
  82496. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  82497. */
  82498. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  82499. /**
  82500. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  82501. */
  82502. readonly onMaterialLoadedObservable: Observable<Material>;
  82503. private _onMaterialLoadedObserver;
  82504. /**
  82505. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  82506. */
  82507. set onMaterialLoaded(callback: (material: Material) => void);
  82508. /**
  82509. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  82510. */
  82511. readonly onCameraLoadedObservable: Observable<Camera>;
  82512. private _onCameraLoadedObserver;
  82513. /**
  82514. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  82515. */
  82516. set onCameraLoaded(callback: (camera: Camera) => void);
  82517. /**
  82518. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  82519. * For assets with LODs, raised when all of the LODs are complete.
  82520. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82521. */
  82522. readonly onCompleteObservable: Observable<void>;
  82523. private _onCompleteObserver;
  82524. /**
  82525. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  82526. * For assets with LODs, raised when all of the LODs are complete.
  82527. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82528. */
  82529. set onComplete(callback: () => void);
  82530. /**
  82531. * Observable raised when an error occurs.
  82532. */
  82533. readonly onErrorObservable: Observable<any>;
  82534. private _onErrorObserver;
  82535. /**
  82536. * Callback raised when an error occurs.
  82537. */
  82538. set onError(callback: (reason: any) => void);
  82539. /**
  82540. * Observable raised after the loader is disposed.
  82541. */
  82542. readonly onDisposeObservable: Observable<void>;
  82543. private _onDisposeObserver;
  82544. /**
  82545. * Callback raised after the loader is disposed.
  82546. */
  82547. set onDispose(callback: () => void);
  82548. /**
  82549. * Observable raised after a loader extension is created.
  82550. * Set additional options for a loader extension in this event.
  82551. */
  82552. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  82553. private _onExtensionLoadedObserver;
  82554. /**
  82555. * Callback raised after a loader extension is created.
  82556. */
  82557. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82558. /**
  82559. * Defines if the loader logging is enabled.
  82560. */
  82561. get loggingEnabled(): boolean;
  82562. set loggingEnabled(value: boolean);
  82563. /**
  82564. * Defines if the loader should capture performance counters.
  82565. */
  82566. get capturePerformanceCounters(): boolean;
  82567. set capturePerformanceCounters(value: boolean);
  82568. /**
  82569. * Defines if the loader should validate the asset.
  82570. */
  82571. validate: boolean;
  82572. /**
  82573. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82574. */
  82575. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82576. private _onValidatedObserver;
  82577. /**
  82578. * Callback raised after a loader extension is created.
  82579. */
  82580. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82581. private _loader;
  82582. private _progressCallback?;
  82583. private _requests;
  82584. private static magicBase64Encoded;
  82585. /**
  82586. * Name of the loader ("gltf")
  82587. */
  82588. name: string;
  82589. /** @hidden */
  82590. extensions: ISceneLoaderPluginExtensions;
  82591. /**
  82592. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82593. */
  82594. dispose(): void;
  82595. /** @hidden */
  82596. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82597. /** @hidden */
  82598. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82599. /** @hidden */
  82600. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  82601. /** @hidden */
  82602. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82603. /** @hidden */
  82604. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82605. /** @hidden */
  82606. canDirectLoad(data: string): boolean;
  82607. /** @hidden */
  82608. directLoad(scene: Scene, data: string): Promise<any>;
  82609. /**
  82610. * The callback that allows custom handling of the root url based on the response url.
  82611. * @param rootUrl the original root url
  82612. * @param responseURL the response url if available
  82613. * @returns the new root url
  82614. */
  82615. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82616. /** @hidden */
  82617. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82618. /**
  82619. * The loader state or null if the loader is not active.
  82620. */
  82621. get loaderState(): Nullable<GLTFLoaderState>;
  82622. /**
  82623. * Returns a promise that resolves when the asset is completely loaded.
  82624. * @returns a promise that resolves when the asset is completely loaded.
  82625. */
  82626. whenCompleteAsync(): Promise<void>;
  82627. /** @hidden */
  82628. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82629. /** @hidden */
  82630. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82631. private _onProgress;
  82632. private _validate;
  82633. private _getLoader;
  82634. private _parseJson;
  82635. private _unpackBinaryAsync;
  82636. private _unpackBinaryV1Async;
  82637. private _unpackBinaryV2Async;
  82638. private static _parseVersion;
  82639. private static _compareVersion;
  82640. private static readonly _logSpaces;
  82641. private _logIndentLevel;
  82642. private _loggingEnabled;
  82643. /** @hidden */
  82644. _log: (message: string) => void;
  82645. /** @hidden */
  82646. _logOpen(message: string): void;
  82647. /** @hidden */
  82648. _logClose(): void;
  82649. private _logEnabled;
  82650. private _logDisabled;
  82651. private _capturePerformanceCounters;
  82652. /** @hidden */
  82653. _startPerformanceCounter: (counterName: string) => void;
  82654. /** @hidden */
  82655. _endPerformanceCounter: (counterName: string) => void;
  82656. private _startPerformanceCounterEnabled;
  82657. private _startPerformanceCounterDisabled;
  82658. private _endPerformanceCounterEnabled;
  82659. private _endPerformanceCounterDisabled;
  82660. }
  82661. }
  82662. declare module BABYLON.GLTF1 {
  82663. /**
  82664. * Enums
  82665. * @hidden
  82666. */
  82667. export enum EComponentType {
  82668. BYTE = 5120,
  82669. UNSIGNED_BYTE = 5121,
  82670. SHORT = 5122,
  82671. UNSIGNED_SHORT = 5123,
  82672. FLOAT = 5126
  82673. }
  82674. /** @hidden */
  82675. export enum EShaderType {
  82676. FRAGMENT = 35632,
  82677. VERTEX = 35633
  82678. }
  82679. /** @hidden */
  82680. export enum EParameterType {
  82681. BYTE = 5120,
  82682. UNSIGNED_BYTE = 5121,
  82683. SHORT = 5122,
  82684. UNSIGNED_SHORT = 5123,
  82685. INT = 5124,
  82686. UNSIGNED_INT = 5125,
  82687. FLOAT = 5126,
  82688. FLOAT_VEC2 = 35664,
  82689. FLOAT_VEC3 = 35665,
  82690. FLOAT_VEC4 = 35666,
  82691. INT_VEC2 = 35667,
  82692. INT_VEC3 = 35668,
  82693. INT_VEC4 = 35669,
  82694. BOOL = 35670,
  82695. BOOL_VEC2 = 35671,
  82696. BOOL_VEC3 = 35672,
  82697. BOOL_VEC4 = 35673,
  82698. FLOAT_MAT2 = 35674,
  82699. FLOAT_MAT3 = 35675,
  82700. FLOAT_MAT4 = 35676,
  82701. SAMPLER_2D = 35678
  82702. }
  82703. /** @hidden */
  82704. export enum ETextureWrapMode {
  82705. CLAMP_TO_EDGE = 33071,
  82706. MIRRORED_REPEAT = 33648,
  82707. REPEAT = 10497
  82708. }
  82709. /** @hidden */
  82710. export enum ETextureFilterType {
  82711. NEAREST = 9728,
  82712. LINEAR = 9728,
  82713. NEAREST_MIPMAP_NEAREST = 9984,
  82714. LINEAR_MIPMAP_NEAREST = 9985,
  82715. NEAREST_MIPMAP_LINEAR = 9986,
  82716. LINEAR_MIPMAP_LINEAR = 9987
  82717. }
  82718. /** @hidden */
  82719. export enum ETextureFormat {
  82720. ALPHA = 6406,
  82721. RGB = 6407,
  82722. RGBA = 6408,
  82723. LUMINANCE = 6409,
  82724. LUMINANCE_ALPHA = 6410
  82725. }
  82726. /** @hidden */
  82727. export enum ECullingType {
  82728. FRONT = 1028,
  82729. BACK = 1029,
  82730. FRONT_AND_BACK = 1032
  82731. }
  82732. /** @hidden */
  82733. export enum EBlendingFunction {
  82734. ZERO = 0,
  82735. ONE = 1,
  82736. SRC_COLOR = 768,
  82737. ONE_MINUS_SRC_COLOR = 769,
  82738. DST_COLOR = 774,
  82739. ONE_MINUS_DST_COLOR = 775,
  82740. SRC_ALPHA = 770,
  82741. ONE_MINUS_SRC_ALPHA = 771,
  82742. DST_ALPHA = 772,
  82743. ONE_MINUS_DST_ALPHA = 773,
  82744. CONSTANT_COLOR = 32769,
  82745. ONE_MINUS_CONSTANT_COLOR = 32770,
  82746. CONSTANT_ALPHA = 32771,
  82747. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82748. SRC_ALPHA_SATURATE = 776
  82749. }
  82750. /** @hidden */
  82751. export interface IGLTFProperty {
  82752. extensions?: {
  82753. [key: string]: any;
  82754. };
  82755. extras?: Object;
  82756. }
  82757. /** @hidden */
  82758. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82759. name?: string;
  82760. }
  82761. /** @hidden */
  82762. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82763. bufferView: string;
  82764. byteOffset: number;
  82765. byteStride: number;
  82766. count: number;
  82767. type: string;
  82768. componentType: EComponentType;
  82769. max?: number[];
  82770. min?: number[];
  82771. name?: string;
  82772. }
  82773. /** @hidden */
  82774. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82775. buffer: string;
  82776. byteOffset: number;
  82777. byteLength: number;
  82778. byteStride: number;
  82779. target?: number;
  82780. }
  82781. /** @hidden */
  82782. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82783. uri: string;
  82784. byteLength?: number;
  82785. type?: string;
  82786. }
  82787. /** @hidden */
  82788. export interface IGLTFShader extends IGLTFChildRootProperty {
  82789. uri: string;
  82790. type: EShaderType;
  82791. }
  82792. /** @hidden */
  82793. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82794. attributes: string[];
  82795. fragmentShader: string;
  82796. vertexShader: string;
  82797. }
  82798. /** @hidden */
  82799. export interface IGLTFTechniqueParameter {
  82800. type: number;
  82801. count?: number;
  82802. semantic?: string;
  82803. node?: string;
  82804. value?: number | boolean | string | Array<any>;
  82805. source?: string;
  82806. babylonValue?: any;
  82807. }
  82808. /** @hidden */
  82809. export interface IGLTFTechniqueCommonProfile {
  82810. lightingModel: string;
  82811. texcoordBindings: Object;
  82812. parameters?: Array<any>;
  82813. }
  82814. /** @hidden */
  82815. export interface IGLTFTechniqueStatesFunctions {
  82816. blendColor?: number[];
  82817. blendEquationSeparate?: number[];
  82818. blendFuncSeparate?: number[];
  82819. colorMask: boolean[];
  82820. cullFace: number[];
  82821. }
  82822. /** @hidden */
  82823. export interface IGLTFTechniqueStates {
  82824. enable: number[];
  82825. functions: IGLTFTechniqueStatesFunctions;
  82826. }
  82827. /** @hidden */
  82828. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82829. parameters: {
  82830. [key: string]: IGLTFTechniqueParameter;
  82831. };
  82832. program: string;
  82833. attributes: {
  82834. [key: string]: string;
  82835. };
  82836. uniforms: {
  82837. [key: string]: string;
  82838. };
  82839. states: IGLTFTechniqueStates;
  82840. }
  82841. /** @hidden */
  82842. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82843. technique?: string;
  82844. values: string[];
  82845. }
  82846. /** @hidden */
  82847. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82848. attributes: {
  82849. [key: string]: string;
  82850. };
  82851. indices: string;
  82852. material: string;
  82853. mode?: number;
  82854. }
  82855. /** @hidden */
  82856. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82857. primitives: IGLTFMeshPrimitive[];
  82858. }
  82859. /** @hidden */
  82860. export interface IGLTFImage extends IGLTFChildRootProperty {
  82861. uri: string;
  82862. }
  82863. /** @hidden */
  82864. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82865. magFilter?: number;
  82866. minFilter?: number;
  82867. wrapS?: number;
  82868. wrapT?: number;
  82869. }
  82870. /** @hidden */
  82871. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82872. sampler: string;
  82873. source: string;
  82874. format?: ETextureFormat;
  82875. internalFormat?: ETextureFormat;
  82876. target?: number;
  82877. type?: number;
  82878. babylonTexture?: Texture;
  82879. }
  82880. /** @hidden */
  82881. export interface IGLTFAmbienLight {
  82882. color?: number[];
  82883. }
  82884. /** @hidden */
  82885. export interface IGLTFDirectionalLight {
  82886. color?: number[];
  82887. }
  82888. /** @hidden */
  82889. export interface IGLTFPointLight {
  82890. color?: number[];
  82891. constantAttenuation?: number;
  82892. linearAttenuation?: number;
  82893. quadraticAttenuation?: number;
  82894. }
  82895. /** @hidden */
  82896. export interface IGLTFSpotLight {
  82897. color?: number[];
  82898. constantAttenuation?: number;
  82899. fallOfAngle?: number;
  82900. fallOffExponent?: number;
  82901. linearAttenuation?: number;
  82902. quadraticAttenuation?: number;
  82903. }
  82904. /** @hidden */
  82905. export interface IGLTFLight extends IGLTFChildRootProperty {
  82906. type: string;
  82907. }
  82908. /** @hidden */
  82909. export interface IGLTFCameraOrthographic {
  82910. xmag: number;
  82911. ymag: number;
  82912. zfar: number;
  82913. znear: number;
  82914. }
  82915. /** @hidden */
  82916. export interface IGLTFCameraPerspective {
  82917. aspectRatio: number;
  82918. yfov: number;
  82919. zfar: number;
  82920. znear: number;
  82921. }
  82922. /** @hidden */
  82923. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82924. type: string;
  82925. }
  82926. /** @hidden */
  82927. export interface IGLTFAnimationChannelTarget {
  82928. id: string;
  82929. path: string;
  82930. }
  82931. /** @hidden */
  82932. export interface IGLTFAnimationChannel {
  82933. sampler: string;
  82934. target: IGLTFAnimationChannelTarget;
  82935. }
  82936. /** @hidden */
  82937. export interface IGLTFAnimationSampler {
  82938. input: string;
  82939. output: string;
  82940. interpolation?: string;
  82941. }
  82942. /** @hidden */
  82943. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82944. channels?: IGLTFAnimationChannel[];
  82945. parameters?: {
  82946. [key: string]: string;
  82947. };
  82948. samplers?: {
  82949. [key: string]: IGLTFAnimationSampler;
  82950. };
  82951. }
  82952. /** @hidden */
  82953. export interface IGLTFNodeInstanceSkin {
  82954. skeletons: string[];
  82955. skin: string;
  82956. meshes: string[];
  82957. }
  82958. /** @hidden */
  82959. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82960. bindShapeMatrix: number[];
  82961. inverseBindMatrices: string;
  82962. jointNames: string[];
  82963. babylonSkeleton?: Skeleton;
  82964. }
  82965. /** @hidden */
  82966. export interface IGLTFNode extends IGLTFChildRootProperty {
  82967. camera?: string;
  82968. children: string[];
  82969. skin?: string;
  82970. jointName?: string;
  82971. light?: string;
  82972. matrix: number[];
  82973. mesh?: string;
  82974. meshes?: string[];
  82975. rotation?: number[];
  82976. scale?: number[];
  82977. translation?: number[];
  82978. babylonNode?: Node;
  82979. }
  82980. /** @hidden */
  82981. export interface IGLTFScene extends IGLTFChildRootProperty {
  82982. nodes: string[];
  82983. }
  82984. /** @hidden */
  82985. export interface IGLTFRuntime {
  82986. extensions: {
  82987. [key: string]: any;
  82988. };
  82989. accessors: {
  82990. [key: string]: IGLTFAccessor;
  82991. };
  82992. buffers: {
  82993. [key: string]: IGLTFBuffer;
  82994. };
  82995. bufferViews: {
  82996. [key: string]: IGLTFBufferView;
  82997. };
  82998. meshes: {
  82999. [key: string]: IGLTFMesh;
  83000. };
  83001. lights: {
  83002. [key: string]: IGLTFLight;
  83003. };
  83004. cameras: {
  83005. [key: string]: IGLTFCamera;
  83006. };
  83007. nodes: {
  83008. [key: string]: IGLTFNode;
  83009. };
  83010. images: {
  83011. [key: string]: IGLTFImage;
  83012. };
  83013. textures: {
  83014. [key: string]: IGLTFTexture;
  83015. };
  83016. shaders: {
  83017. [key: string]: IGLTFShader;
  83018. };
  83019. programs: {
  83020. [key: string]: IGLTFProgram;
  83021. };
  83022. samplers: {
  83023. [key: string]: IGLTFSampler;
  83024. };
  83025. techniques: {
  83026. [key: string]: IGLTFTechnique;
  83027. };
  83028. materials: {
  83029. [key: string]: IGLTFMaterial;
  83030. };
  83031. animations: {
  83032. [key: string]: IGLTFAnimation;
  83033. };
  83034. skins: {
  83035. [key: string]: IGLTFSkins;
  83036. };
  83037. currentScene?: Object;
  83038. scenes: {
  83039. [key: string]: IGLTFScene;
  83040. };
  83041. extensionsUsed: string[];
  83042. extensionsRequired?: string[];
  83043. buffersCount: number;
  83044. shaderscount: number;
  83045. scene: Scene;
  83046. rootUrl: string;
  83047. loadedBufferCount: number;
  83048. loadedBufferViews: {
  83049. [name: string]: ArrayBufferView;
  83050. };
  83051. loadedShaderCount: number;
  83052. importOnlyMeshes: boolean;
  83053. importMeshesNames?: string[];
  83054. dummyNodes: Node[];
  83055. forAssetContainer: boolean;
  83056. }
  83057. /** @hidden */
  83058. export interface INodeToRoot {
  83059. bone: Bone;
  83060. node: IGLTFNode;
  83061. id: string;
  83062. }
  83063. /** @hidden */
  83064. export interface IJointNode {
  83065. node: IGLTFNode;
  83066. id: string;
  83067. }
  83068. }
  83069. declare module BABYLON.GLTF1 {
  83070. /**
  83071. * Utils functions for GLTF
  83072. * @hidden
  83073. */
  83074. export class GLTFUtils {
  83075. /**
  83076. * Sets the given "parameter" matrix
  83077. * @param scene: the Scene object
  83078. * @param source: the source node where to pick the matrix
  83079. * @param parameter: the GLTF technique parameter
  83080. * @param uniformName: the name of the shader's uniform
  83081. * @param shaderMaterial: the shader material
  83082. */
  83083. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  83084. /**
  83085. * Sets the given "parameter" matrix
  83086. * @param shaderMaterial: the shader material
  83087. * @param uniform: the name of the shader's uniform
  83088. * @param value: the value of the uniform
  83089. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  83090. */
  83091. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  83092. /**
  83093. * Returns the wrap mode of the texture
  83094. * @param mode: the mode value
  83095. */
  83096. static GetWrapMode(mode: number): number;
  83097. /**
  83098. * Returns the byte stride giving an accessor
  83099. * @param accessor: the GLTF accessor objet
  83100. */
  83101. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  83102. /**
  83103. * Returns the texture filter mode giving a mode value
  83104. * @param mode: the filter mode value
  83105. */
  83106. static GetTextureFilterMode(mode: number): ETextureFilterType;
  83107. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  83108. /**
  83109. * Returns a buffer from its accessor
  83110. * @param gltfRuntime: the GLTF runtime
  83111. * @param accessor: the GLTF accessor
  83112. */
  83113. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  83114. /**
  83115. * Decodes a buffer view into a string
  83116. * @param view: the buffer view
  83117. */
  83118. static DecodeBufferToText(view: ArrayBufferView): string;
  83119. /**
  83120. * Returns the default material of gltf. Related to
  83121. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  83122. * @param scene: the Babylon.js scene
  83123. */
  83124. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  83125. private static _DefaultMaterial;
  83126. }
  83127. }
  83128. declare module BABYLON.GLTF1 {
  83129. /**
  83130. * Implementation of the base glTF spec
  83131. * @hidden
  83132. */
  83133. export class GLTFLoaderBase {
  83134. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  83135. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  83136. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  83137. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  83138. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  83139. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  83140. }
  83141. /**
  83142. * glTF V1 Loader
  83143. * @hidden
  83144. */
  83145. export class GLTFLoader implements IGLTFLoader {
  83146. static Extensions: {
  83147. [name: string]: GLTFLoaderExtension;
  83148. };
  83149. static RegisterExtension(extension: GLTFLoaderExtension): void;
  83150. state: Nullable<GLTFLoaderState>;
  83151. dispose(): void;
  83152. private _importMeshAsync;
  83153. /**
  83154. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  83155. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83156. * @param scene the scene the meshes should be added to
  83157. * @param forAssetContainer defines if the entities must be stored in the scene
  83158. * @param data gltf data containing information of the meshes in a loaded file
  83159. * @param rootUrl root url to load from
  83160. * @param onProgress event that fires when loading progress has occured
  83161. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83162. */
  83163. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  83164. private _loadAsync;
  83165. /**
  83166. * Imports all objects from a loaded gltf file and adds them to the scene
  83167. * @param scene the scene the objects should be added to
  83168. * @param data gltf data containing information of the meshes in a loaded file
  83169. * @param rootUrl root url to load from
  83170. * @param onProgress event that fires when loading progress has occured
  83171. * @returns a promise which completes when objects have been loaded to the scene
  83172. */
  83173. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  83174. private _loadShadersAsync;
  83175. private _loadBuffersAsync;
  83176. private _createNodes;
  83177. }
  83178. /** @hidden */
  83179. export abstract class GLTFLoaderExtension {
  83180. private _name;
  83181. constructor(name: string);
  83182. get name(): string;
  83183. /**
  83184. * Defines an override for loading the runtime
  83185. * Return true to stop further extensions from loading the runtime
  83186. */
  83187. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  83188. /**
  83189. * Defines an onverride for creating gltf runtime
  83190. * Return true to stop further extensions from creating the runtime
  83191. */
  83192. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  83193. /**
  83194. * Defines an override for loading buffers
  83195. * Return true to stop further extensions from loading this buffer
  83196. */
  83197. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  83198. /**
  83199. * Defines an override for loading texture buffers
  83200. * Return true to stop further extensions from loading this texture data
  83201. */
  83202. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83203. /**
  83204. * Defines an override for creating textures
  83205. * Return true to stop further extensions from loading this texture
  83206. */
  83207. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  83208. /**
  83209. * Defines an override for loading shader strings
  83210. * Return true to stop further extensions from loading this shader data
  83211. */
  83212. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  83213. /**
  83214. * Defines an override for loading materials
  83215. * Return true to stop further extensions from loading this material
  83216. */
  83217. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83218. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  83219. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  83220. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  83221. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  83222. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  83223. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  83224. private static LoadTextureBufferAsync;
  83225. private static CreateTextureAsync;
  83226. private static ApplyExtensions;
  83227. }
  83228. }
  83229. declare module BABYLON.GLTF1 {
  83230. /** @hidden */
  83231. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  83232. private _bin;
  83233. constructor();
  83234. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  83235. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83236. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83237. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  83238. }
  83239. }
  83240. declare module BABYLON.GLTF1 {
  83241. /** @hidden */
  83242. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  83243. constructor();
  83244. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  83245. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83246. private _loadTexture;
  83247. }
  83248. }
  83249. declare module BABYLON.GLTF2.Loader {
  83250. /**
  83251. * Loader interface with an index field.
  83252. */
  83253. export interface IArrayItem {
  83254. /**
  83255. * The index of this item in the array.
  83256. */
  83257. index: number;
  83258. }
  83259. /**
  83260. * Loader interface with additional members.
  83261. */
  83262. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  83263. /** @hidden */
  83264. _data?: Promise<ArrayBufferView>;
  83265. /** @hidden */
  83266. _babylonVertexBuffer?: Promise<VertexBuffer>;
  83267. }
  83268. /**
  83269. * Loader interface with additional members.
  83270. */
  83271. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  83272. }
  83273. /** @hidden */
  83274. export interface _IAnimationSamplerData {
  83275. input: Float32Array;
  83276. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  83277. output: Float32Array;
  83278. }
  83279. /**
  83280. * Loader interface with additional members.
  83281. */
  83282. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  83283. /** @hidden */
  83284. _data?: Promise<_IAnimationSamplerData>;
  83285. }
  83286. /**
  83287. * Loader interface with additional members.
  83288. */
  83289. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  83290. channels: IAnimationChannel[];
  83291. samplers: IAnimationSampler[];
  83292. /** @hidden */
  83293. _babylonAnimationGroup?: AnimationGroup;
  83294. }
  83295. /**
  83296. * Loader interface with additional members.
  83297. */
  83298. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  83299. /** @hidden */
  83300. _data?: Promise<ArrayBufferView>;
  83301. }
  83302. /**
  83303. * Loader interface with additional members.
  83304. */
  83305. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  83306. /** @hidden */
  83307. _data?: Promise<ArrayBufferView>;
  83308. /** @hidden */
  83309. _babylonBuffer?: Promise<Buffer>;
  83310. }
  83311. /**
  83312. * Loader interface with additional members.
  83313. */
  83314. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  83315. }
  83316. /**
  83317. * Loader interface with additional members.
  83318. */
  83319. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  83320. /** @hidden */
  83321. _data?: Promise<ArrayBufferView>;
  83322. }
  83323. /**
  83324. * Loader interface with additional members.
  83325. */
  83326. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  83327. }
  83328. /**
  83329. * Loader interface with additional members.
  83330. */
  83331. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  83332. }
  83333. /**
  83334. * Loader interface with additional members.
  83335. */
  83336. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  83337. baseColorTexture?: ITextureInfo;
  83338. metallicRoughnessTexture?: ITextureInfo;
  83339. }
  83340. /**
  83341. * Loader interface with additional members.
  83342. */
  83343. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  83344. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83345. normalTexture?: IMaterialNormalTextureInfo;
  83346. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83347. emissiveTexture?: ITextureInfo;
  83348. /** @hidden */
  83349. _data?: {
  83350. [babylonDrawMode: number]: {
  83351. babylonMaterial: Material;
  83352. babylonMeshes: AbstractMesh[];
  83353. promise: Promise<void>;
  83354. };
  83355. };
  83356. }
  83357. /**
  83358. * Loader interface with additional members.
  83359. */
  83360. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  83361. primitives: IMeshPrimitive[];
  83362. }
  83363. /**
  83364. * Loader interface with additional members.
  83365. */
  83366. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  83367. /** @hidden */
  83368. _instanceData?: {
  83369. babylonSourceMesh: Mesh;
  83370. promise: Promise<any>;
  83371. };
  83372. }
  83373. /**
  83374. * Loader interface with additional members.
  83375. */
  83376. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  83377. /**
  83378. * The parent glTF node.
  83379. */
  83380. parent?: INode;
  83381. /** @hidden */
  83382. _babylonTransformNode?: TransformNode;
  83383. /** @hidden */
  83384. _primitiveBabylonMeshes?: AbstractMesh[];
  83385. /** @hidden */
  83386. _babylonBones?: Bone[];
  83387. /** @hidden */
  83388. _numMorphTargets?: number;
  83389. }
  83390. /** @hidden */
  83391. export interface _ISamplerData {
  83392. noMipMaps: boolean;
  83393. samplingMode: number;
  83394. wrapU: number;
  83395. wrapV: number;
  83396. }
  83397. /**
  83398. * Loader interface with additional members.
  83399. */
  83400. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  83401. /** @hidden */
  83402. _data?: _ISamplerData;
  83403. }
  83404. /**
  83405. * Loader interface with additional members.
  83406. */
  83407. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  83408. }
  83409. /**
  83410. * Loader interface with additional members.
  83411. */
  83412. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  83413. /** @hidden */
  83414. _data?: {
  83415. babylonSkeleton: Skeleton;
  83416. promise: Promise<void>;
  83417. };
  83418. }
  83419. /**
  83420. * Loader interface with additional members.
  83421. */
  83422. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  83423. /** @hidden */
  83424. _textureInfo: ITextureInfo;
  83425. }
  83426. /**
  83427. * Loader interface with additional members.
  83428. */
  83429. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  83430. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  83431. nonColorData?: boolean;
  83432. }
  83433. /**
  83434. * Loader interface with additional members.
  83435. */
  83436. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  83437. accessors?: IAccessor[];
  83438. animations?: IAnimation[];
  83439. buffers?: IBuffer[];
  83440. bufferViews?: IBufferView[];
  83441. cameras?: ICamera[];
  83442. images?: IImage[];
  83443. materials?: IMaterial[];
  83444. meshes?: IMesh[];
  83445. nodes?: INode[];
  83446. samplers?: ISampler[];
  83447. scenes?: IScene[];
  83448. skins?: ISkin[];
  83449. textures?: ITexture[];
  83450. }
  83451. }
  83452. declare module BABYLON.GLTF2 {
  83453. /**
  83454. * Interface for a glTF loader extension.
  83455. */
  83456. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  83457. /**
  83458. * Called after the loader state changes to LOADING.
  83459. */
  83460. onLoading?(): void;
  83461. /**
  83462. * Called after the loader state changes to READY.
  83463. */
  83464. onReady?(): void;
  83465. /**
  83466. * Define this method to modify the default behavior when loading scenes.
  83467. * @param context The context when loading the asset
  83468. * @param scene The glTF scene property
  83469. * @returns A promise that resolves when the load is complete or null if not handled
  83470. */
  83471. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  83472. /**
  83473. * Define this method to modify the default behavior when loading nodes.
  83474. * @param context The context when loading the asset
  83475. * @param node The glTF node property
  83476. * @param assign A function called synchronously after parsing the glTF properties
  83477. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  83478. */
  83479. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83480. /**
  83481. * Define this method to modify the default behavior when loading cameras.
  83482. * @param context The context when loading the asset
  83483. * @param camera The glTF camera property
  83484. * @param assign A function called synchronously after parsing the glTF properties
  83485. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  83486. */
  83487. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83488. /**
  83489. * @hidden
  83490. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  83491. * @param context The context when loading the asset
  83492. * @param primitive The glTF mesh primitive property
  83493. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  83494. */
  83495. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83496. /**
  83497. * @hidden
  83498. * Define this method to modify the default behavior when loading data for mesh primitives.
  83499. * @param context The context when loading the asset
  83500. * @param name The mesh name when loading the asset
  83501. * @param node The glTF node when loading the asset
  83502. * @param mesh The glTF mesh when loading the asset
  83503. * @param primitive The glTF mesh primitive property
  83504. * @param assign A function called synchronously after parsing the glTF properties
  83505. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83506. */
  83507. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83508. /**
  83509. * @hidden
  83510. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  83511. * @param context The context when loading the asset
  83512. * @param material The glTF material property
  83513. * @param assign A function called synchronously after parsing the glTF properties
  83514. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  83515. */
  83516. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83517. /**
  83518. * Define this method to modify the default behavior when creating materials.
  83519. * @param context The context when loading the asset
  83520. * @param material The glTF material property
  83521. * @param babylonDrawMode The draw mode for the Babylon material
  83522. * @returns The Babylon material or null if not handled
  83523. */
  83524. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83525. /**
  83526. * Define this method to modify the default behavior when loading material properties.
  83527. * @param context The context when loading the asset
  83528. * @param material The glTF material property
  83529. * @param babylonMaterial The Babylon material
  83530. * @returns A promise that resolves when the load is complete or null if not handled
  83531. */
  83532. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83533. /**
  83534. * Define this method to modify the default behavior when loading texture infos.
  83535. * @param context The context when loading the asset
  83536. * @param textureInfo The glTF texture info property
  83537. * @param assign A function called synchronously after parsing the glTF properties
  83538. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83539. */
  83540. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83541. /**
  83542. * @hidden
  83543. * Define this method to modify the default behavior when loading textures.
  83544. * @param context The context when loading the asset
  83545. * @param texture The glTF texture property
  83546. * @param assign A function called synchronously after parsing the glTF properties
  83547. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83548. */
  83549. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83550. /**
  83551. * Define this method to modify the default behavior when loading animations.
  83552. * @param context The context when loading the asset
  83553. * @param animation The glTF animation property
  83554. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83555. */
  83556. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83557. /**
  83558. * @hidden
  83559. * Define this method to modify the default behavior when loading skins.
  83560. * @param context The context when loading the asset
  83561. * @param node The glTF node property
  83562. * @param skin The glTF skin property
  83563. * @returns A promise that resolves when the load is complete or null if not handled
  83564. */
  83565. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83566. /**
  83567. * @hidden
  83568. * Define this method to modify the default behavior when loading uris.
  83569. * @param context The context when loading the asset
  83570. * @param property The glTF property associated with the uri
  83571. * @param uri The uri to load
  83572. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83573. */
  83574. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83575. /**
  83576. * Define this method to modify the default behavior when loading buffer views.
  83577. * @param context The context when loading the asset
  83578. * @param bufferView The glTF buffer view property
  83579. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83580. */
  83581. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83582. /**
  83583. * Define this method to modify the default behavior when loading buffers.
  83584. * @param context The context when loading the asset
  83585. * @param buffer The glTF buffer property
  83586. * @param byteOffset The byte offset to load
  83587. * @param byteLength The byte length to load
  83588. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83589. */
  83590. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83591. }
  83592. }
  83593. declare module BABYLON.GLTF2 {
  83594. /**
  83595. * Helper class for working with arrays when loading the glTF asset
  83596. */
  83597. export class ArrayItem {
  83598. /**
  83599. * Gets an item from the given array.
  83600. * @param context The context when loading the asset
  83601. * @param array The array to get the item from
  83602. * @param index The index to the array
  83603. * @returns The array item
  83604. */
  83605. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83606. /**
  83607. * Assign an `index` field to each item of the given array.
  83608. * @param array The array of items
  83609. */
  83610. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83611. }
  83612. /**
  83613. * The glTF 2.0 loader
  83614. */
  83615. export class GLTFLoader implements IGLTFLoader {
  83616. /** @hidden */
  83617. _completePromises: Promise<any>[];
  83618. /** @hidden */
  83619. _forAssetContainer: boolean;
  83620. /** Storage */
  83621. _babylonLights: Light[];
  83622. /** @hidden */
  83623. _disableInstancedMesh: number;
  83624. private _disposed;
  83625. private _parent;
  83626. private _state;
  83627. private _extensions;
  83628. private _rootUrl;
  83629. private _fileName;
  83630. private _uniqueRootUrl;
  83631. private _gltf;
  83632. private _bin;
  83633. private _babylonScene;
  83634. private _rootBabylonMesh;
  83635. private _defaultBabylonMaterialData;
  83636. private static _RegisteredExtensions;
  83637. /**
  83638. * The default glTF sampler.
  83639. */
  83640. static readonly DefaultSampler: ISampler;
  83641. /**
  83642. * Registers a loader extension.
  83643. * @param name The name of the loader extension.
  83644. * @param factory The factory function that creates the loader extension.
  83645. */
  83646. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83647. /**
  83648. * Unregisters a loader extension.
  83649. * @param name The name of the loader extension.
  83650. * @returns A boolean indicating whether the extension has been unregistered
  83651. */
  83652. static UnregisterExtension(name: string): boolean;
  83653. /**
  83654. * The loader state.
  83655. */
  83656. get state(): Nullable<GLTFLoaderState>;
  83657. /**
  83658. * The object that represents the glTF JSON.
  83659. */
  83660. get gltf(): IGLTF;
  83661. /**
  83662. * The BIN chunk of a binary glTF.
  83663. */
  83664. get bin(): Nullable<IDataBuffer>;
  83665. /**
  83666. * The parent file loader.
  83667. */
  83668. get parent(): GLTFFileLoader;
  83669. /**
  83670. * The Babylon scene when loading the asset.
  83671. */
  83672. get babylonScene(): Scene;
  83673. /**
  83674. * The root Babylon mesh when loading the asset.
  83675. */
  83676. get rootBabylonMesh(): Mesh;
  83677. /** @hidden */
  83678. constructor(parent: GLTFFileLoader);
  83679. /** @hidden */
  83680. dispose(): void;
  83681. /** @hidden */
  83682. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  83683. /** @hidden */
  83684. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83685. private _loadAsync;
  83686. private _loadData;
  83687. private _setupData;
  83688. private _loadExtensions;
  83689. private _checkExtensions;
  83690. private _setState;
  83691. private _createRootNode;
  83692. /**
  83693. * Loads a glTF scene.
  83694. * @param context The context when loading the asset
  83695. * @param scene The glTF scene property
  83696. * @returns A promise that resolves when the load is complete
  83697. */
  83698. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83699. private _forEachPrimitive;
  83700. private _getGeometries;
  83701. private _getMeshes;
  83702. private _getTransformNodes;
  83703. private _getSkeletons;
  83704. private _getAnimationGroups;
  83705. private _startAnimations;
  83706. /**
  83707. * Loads a glTF node.
  83708. * @param context The context when loading the asset
  83709. * @param node The glTF node property
  83710. * @param assign A function called synchronously after parsing the glTF properties
  83711. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83712. */
  83713. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83714. private _loadMeshAsync;
  83715. /**
  83716. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83717. * @param context The context when loading the asset
  83718. * @param name The mesh name when loading the asset
  83719. * @param node The glTF node when loading the asset
  83720. * @param mesh The glTF mesh when loading the asset
  83721. * @param primitive The glTF mesh primitive property
  83722. * @param assign A function called synchronously after parsing the glTF properties
  83723. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83724. */
  83725. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83726. private _loadVertexDataAsync;
  83727. private _createMorphTargets;
  83728. private _loadMorphTargetsAsync;
  83729. private _loadMorphTargetVertexDataAsync;
  83730. private static _LoadTransform;
  83731. private _loadSkinAsync;
  83732. private _loadBones;
  83733. private _loadBone;
  83734. private _loadSkinInverseBindMatricesDataAsync;
  83735. private _updateBoneMatrices;
  83736. private _getNodeMatrix;
  83737. /**
  83738. * Loads a glTF camera.
  83739. * @param context The context when loading the asset
  83740. * @param camera The glTF camera property
  83741. * @param assign A function called synchronously after parsing the glTF properties
  83742. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83743. */
  83744. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83745. private _loadAnimationsAsync;
  83746. /**
  83747. * Loads a glTF animation.
  83748. * @param context The context when loading the asset
  83749. * @param animation The glTF animation property
  83750. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83751. */
  83752. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83753. /**
  83754. * @hidden Loads a glTF animation channel.
  83755. * @param context The context when loading the asset
  83756. * @param animationContext The context of the animation when loading the asset
  83757. * @param animation The glTF animation property
  83758. * @param channel The glTF animation channel property
  83759. * @param babylonAnimationGroup The babylon animation group property
  83760. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83761. * @returns A void promise when the channel load is complete
  83762. */
  83763. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83764. private _loadAnimationSamplerAsync;
  83765. private _loadBufferAsync;
  83766. /**
  83767. * Loads a glTF buffer view.
  83768. * @param context The context when loading the asset
  83769. * @param bufferView The glTF buffer view property
  83770. * @returns A promise that resolves with the loaded data when the load is complete
  83771. */
  83772. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83773. private _loadAccessorAsync;
  83774. /** @hidden */
  83775. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83776. private _loadIndicesAccessorAsync;
  83777. private _loadVertexBufferViewAsync;
  83778. private _loadVertexAccessorAsync;
  83779. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83780. /** @hidden */
  83781. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83782. private _createDefaultMaterial;
  83783. /**
  83784. * Creates a Babylon material from a glTF material.
  83785. * @param context The context when loading the asset
  83786. * @param material The glTF material property
  83787. * @param babylonDrawMode The draw mode for the Babylon material
  83788. * @returns The Babylon material
  83789. */
  83790. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83791. /**
  83792. * Loads properties from a glTF material into a Babylon material.
  83793. * @param context The context when loading the asset
  83794. * @param material The glTF material property
  83795. * @param babylonMaterial The Babylon material
  83796. * @returns A promise that resolves when the load is complete
  83797. */
  83798. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83799. /**
  83800. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83801. * @param context The context when loading the asset
  83802. * @param material The glTF material property
  83803. * @param babylonMaterial The Babylon material
  83804. * @returns A promise that resolves when the load is complete
  83805. */
  83806. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83807. /**
  83808. * Loads the alpha properties from a glTF material into a Babylon material.
  83809. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83810. * @param context The context when loading the asset
  83811. * @param material The glTF material property
  83812. * @param babylonMaterial The Babylon material
  83813. */
  83814. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83815. /**
  83816. * Loads a glTF texture info.
  83817. * @param context The context when loading the asset
  83818. * @param textureInfo The glTF texture info property
  83819. * @param assign A function called synchronously after parsing the glTF properties
  83820. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83821. */
  83822. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83823. /** @hidden */
  83824. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83825. /** @hidden */
  83826. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83827. private _loadSampler;
  83828. /**
  83829. * Loads a glTF image.
  83830. * @param context The context when loading the asset
  83831. * @param image The glTF image property
  83832. * @returns A promise that resolves with the loaded data when the load is complete
  83833. */
  83834. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83835. /**
  83836. * Loads a glTF uri.
  83837. * @param context The context when loading the asset
  83838. * @param property The glTF property associated with the uri
  83839. * @param uri The base64 or relative uri
  83840. * @returns A promise that resolves with the loaded data when the load is complete
  83841. */
  83842. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83843. /**
  83844. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83845. * @param babylonObject the Babylon object with metadata
  83846. * @param pointer the JSON pointer
  83847. */
  83848. static AddPointerMetadata(babylonObject: {
  83849. metadata: any;
  83850. }, pointer: string): void;
  83851. private static _GetTextureWrapMode;
  83852. private static _GetTextureSamplingMode;
  83853. private static _GetTypedArrayConstructor;
  83854. private static _GetTypedArray;
  83855. private static _GetNumComponents;
  83856. private static _ValidateUri;
  83857. /** @hidden */
  83858. static _GetDrawMode(context: string, mode: number | undefined): number;
  83859. private _compileMaterialsAsync;
  83860. private _compileShadowGeneratorsAsync;
  83861. private _forEachExtensions;
  83862. private _applyExtensions;
  83863. private _extensionsOnLoading;
  83864. private _extensionsOnReady;
  83865. private _extensionsLoadSceneAsync;
  83866. private _extensionsLoadNodeAsync;
  83867. private _extensionsLoadCameraAsync;
  83868. private _extensionsLoadVertexDataAsync;
  83869. private _extensionsLoadMeshPrimitiveAsync;
  83870. private _extensionsLoadMaterialAsync;
  83871. private _extensionsCreateMaterial;
  83872. private _extensionsLoadMaterialPropertiesAsync;
  83873. private _extensionsLoadTextureInfoAsync;
  83874. private _extensionsLoadTextureAsync;
  83875. private _extensionsLoadAnimationAsync;
  83876. private _extensionsLoadSkinAsync;
  83877. private _extensionsLoadUriAsync;
  83878. private _extensionsLoadBufferViewAsync;
  83879. private _extensionsLoadBufferAsync;
  83880. /**
  83881. * Helper method called by a loader extension to load an glTF extension.
  83882. * @param context The context when loading the asset
  83883. * @param property The glTF property to load the extension from
  83884. * @param extensionName The name of the extension to load
  83885. * @param actionAsync The action to run
  83886. * @returns The promise returned by actionAsync or null if the extension does not exist
  83887. */
  83888. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83889. /**
  83890. * Helper method called by a loader extension to load a glTF extra.
  83891. * @param context The context when loading the asset
  83892. * @param property The glTF property to load the extra from
  83893. * @param extensionName The name of the extension to load
  83894. * @param actionAsync The action to run
  83895. * @returns The promise returned by actionAsync or null if the extra does not exist
  83896. */
  83897. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83898. /**
  83899. * Checks for presence of an extension.
  83900. * @param name The name of the extension to check
  83901. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83902. */
  83903. isExtensionUsed(name: string): boolean;
  83904. /**
  83905. * Increments the indentation level and logs a message.
  83906. * @param message The message to log
  83907. */
  83908. logOpen(message: string): void;
  83909. /**
  83910. * Decrements the indentation level.
  83911. */
  83912. logClose(): void;
  83913. /**
  83914. * Logs a message
  83915. * @param message The message to log
  83916. */
  83917. log(message: string): void;
  83918. /**
  83919. * Starts a performance counter.
  83920. * @param counterName The name of the performance counter
  83921. */
  83922. startPerformanceCounter(counterName: string): void;
  83923. /**
  83924. * Ends a performance counter.
  83925. * @param counterName The name of the performance counter
  83926. */
  83927. endPerformanceCounter(counterName: string): void;
  83928. }
  83929. }
  83930. declare module BABYLON.GLTF2.Loader.Extensions {
  83931. /** @hidden */
  83932. interface IEXTLightsImageBased_LightImageBased {
  83933. _babylonTexture?: BaseTexture;
  83934. _loaded?: Promise<void>;
  83935. }
  83936. /**
  83937. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83938. */
  83939. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83940. /**
  83941. * The name of this extension.
  83942. */
  83943. readonly name: string;
  83944. /**
  83945. * Defines whether this extension is enabled.
  83946. */
  83947. enabled: boolean;
  83948. private _loader;
  83949. private _lights?;
  83950. /** @hidden */
  83951. constructor(loader: GLTFLoader);
  83952. /** @hidden */
  83953. dispose(): void;
  83954. /** @hidden */
  83955. onLoading(): void;
  83956. /** @hidden */
  83957. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83958. private _loadLightAsync;
  83959. }
  83960. }
  83961. declare module BABYLON.GLTF2.Loader.Extensions {
  83962. /**
  83963. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83964. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83965. * !!! Experimental Extension Subject to Changes !!!
  83966. */
  83967. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83968. /**
  83969. * The name of this extension.
  83970. */
  83971. readonly name: string;
  83972. /**
  83973. * Defines whether this extension is enabled.
  83974. */
  83975. enabled: boolean;
  83976. private _loader;
  83977. /** @hidden */
  83978. constructor(loader: GLTFLoader);
  83979. /** @hidden */
  83980. dispose(): void;
  83981. /** @hidden */
  83982. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83983. }
  83984. }
  83985. declare module BABYLON.GLTF2.Loader.Extensions {
  83986. /**
  83987. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  83988. *
  83989. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  83990. */
  83991. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  83992. /**
  83993. * The name of this extension.
  83994. */
  83995. readonly name: string;
  83996. /**
  83997. * Defines whether this extension is enabled.
  83998. */
  83999. enabled: boolean;
  84000. /**
  84001. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.module.js
  84002. */
  84003. static DecoderPath: string;
  84004. private _loader;
  84005. private _decoder;
  84006. /** @hidden */
  84007. constructor(loader: GLTFLoader);
  84008. /** @hidden */
  84009. dispose(): void;
  84010. /** @hidden */
  84011. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  84012. }
  84013. }
  84014. declare module BABYLON.GLTF2.Loader.Extensions {
  84015. /**
  84016. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  84017. */
  84018. export class EXT_texture_webp implements IGLTFLoaderExtension {
  84019. /** The name of this extension. */
  84020. readonly name: string;
  84021. /** Defines whether this extension is enabled. */
  84022. enabled: boolean;
  84023. private _loader;
  84024. /** @hidden */
  84025. constructor(loader: GLTFLoader);
  84026. /** @hidden */
  84027. dispose(): void;
  84028. /** @hidden */
  84029. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84030. }
  84031. }
  84032. declare module BABYLON.GLTF2.Loader.Extensions {
  84033. /**
  84034. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  84035. */
  84036. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  84037. /**
  84038. * The name of this extension.
  84039. */
  84040. readonly name: string;
  84041. /**
  84042. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  84043. */
  84044. dracoCompression?: DracoCompression;
  84045. /**
  84046. * Defines whether this extension is enabled.
  84047. */
  84048. enabled: boolean;
  84049. private _loader;
  84050. /** @hidden */
  84051. constructor(loader: GLTFLoader);
  84052. /** @hidden */
  84053. dispose(): void;
  84054. /** @hidden */
  84055. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  84056. }
  84057. }
  84058. declare module BABYLON.GLTF2.Loader.Extensions {
  84059. /**
  84060. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  84061. */
  84062. export class KHR_lights implements IGLTFLoaderExtension {
  84063. /**
  84064. * The name of this extension.
  84065. */
  84066. readonly name: string;
  84067. /**
  84068. * Defines whether this extension is enabled.
  84069. */
  84070. enabled: boolean;
  84071. private _loader;
  84072. private _lights?;
  84073. /** @hidden */
  84074. constructor(loader: GLTFLoader);
  84075. /** @hidden */
  84076. dispose(): void;
  84077. /** @hidden */
  84078. onLoading(): void;
  84079. /** @hidden */
  84080. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84081. }
  84082. }
  84083. declare module BABYLON.GLTF2.Loader.Extensions {
  84084. /**
  84085. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  84086. */
  84087. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  84088. /**
  84089. * The name of this extension.
  84090. */
  84091. readonly name: string;
  84092. /**
  84093. * Defines whether this extension is enabled.
  84094. */
  84095. enabled: boolean;
  84096. /**
  84097. * Defines a number that determines the order the extensions are applied.
  84098. */
  84099. order: number;
  84100. private _loader;
  84101. /** @hidden */
  84102. constructor(loader: GLTFLoader);
  84103. /** @hidden */
  84104. dispose(): void;
  84105. /** @hidden */
  84106. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84107. private _loadSpecularGlossinessPropertiesAsync;
  84108. }
  84109. }
  84110. declare module BABYLON.GLTF2.Loader.Extensions {
  84111. /**
  84112. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  84113. */
  84114. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  84115. /**
  84116. * The name of this extension.
  84117. */
  84118. readonly name: string;
  84119. /**
  84120. * Defines whether this extension is enabled.
  84121. */
  84122. enabled: boolean;
  84123. /**
  84124. * Defines a number that determines the order the extensions are applied.
  84125. */
  84126. order: number;
  84127. private _loader;
  84128. /** @hidden */
  84129. constructor(loader: GLTFLoader);
  84130. /** @hidden */
  84131. dispose(): void;
  84132. /** @hidden */
  84133. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84134. private _loadUnlitPropertiesAsync;
  84135. }
  84136. }
  84137. declare module BABYLON.GLTF2.Loader.Extensions {
  84138. /**
  84139. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  84140. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  84141. */
  84142. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  84143. /**
  84144. * The name of this extension.
  84145. */
  84146. readonly name: string;
  84147. /**
  84148. * Defines whether this extension is enabled.
  84149. */
  84150. enabled: boolean;
  84151. /**
  84152. * Defines a number that determines the order the extensions are applied.
  84153. */
  84154. order: number;
  84155. private _loader;
  84156. /** @hidden */
  84157. constructor(loader: GLTFLoader);
  84158. /** @hidden */
  84159. dispose(): void;
  84160. /** @hidden */
  84161. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84162. private _loadClearCoatPropertiesAsync;
  84163. }
  84164. }
  84165. declare module BABYLON.GLTF2.Loader.Extensions {
  84166. /**
  84167. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  84168. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  84169. * !!! Experimental Extension Subject to Changes !!!
  84170. */
  84171. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  84172. /**
  84173. * The name of this extension.
  84174. */
  84175. readonly name: string;
  84176. /**
  84177. * Defines whether this extension is enabled.
  84178. */
  84179. enabled: boolean;
  84180. /**
  84181. * Defines a number that determines the order the extensions are applied.
  84182. */
  84183. order: number;
  84184. private _loader;
  84185. /** @hidden */
  84186. constructor(loader: GLTFLoader);
  84187. /** @hidden */
  84188. dispose(): void;
  84189. /** @hidden */
  84190. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84191. private _loadSheenPropertiesAsync;
  84192. }
  84193. }
  84194. declare module BABYLON.GLTF2.Loader.Extensions {
  84195. /**
  84196. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  84197. * !!! Experimental Extension Subject to Changes !!!
  84198. */
  84199. export class KHR_materials_specular implements IGLTFLoaderExtension {
  84200. /**
  84201. * The name of this extension.
  84202. */
  84203. readonly name: string;
  84204. /**
  84205. * Defines whether this extension is enabled.
  84206. */
  84207. enabled: boolean;
  84208. /**
  84209. * Defines a number that determines the order the extensions are applied.
  84210. */
  84211. order: number;
  84212. private _loader;
  84213. /** @hidden */
  84214. constructor(loader: GLTFLoader);
  84215. /** @hidden */
  84216. dispose(): void;
  84217. /** @hidden */
  84218. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84219. private _loadSpecularPropertiesAsync;
  84220. }
  84221. }
  84222. declare module BABYLON.GLTF2.Loader.Extensions {
  84223. /**
  84224. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  84225. * !!! Experimental Extension Subject to Changes !!!
  84226. */
  84227. export class KHR_materials_ior implements IGLTFLoaderExtension {
  84228. /**
  84229. * Default ior Value from the spec.
  84230. */
  84231. private static readonly _DEFAULT_IOR;
  84232. /**
  84233. * The name of this extension.
  84234. */
  84235. readonly name: string;
  84236. /**
  84237. * Defines whether this extension is enabled.
  84238. */
  84239. enabled: boolean;
  84240. /**
  84241. * Defines a number that determines the order the extensions are applied.
  84242. */
  84243. order: number;
  84244. private _loader;
  84245. /** @hidden */
  84246. constructor(loader: GLTFLoader);
  84247. /** @hidden */
  84248. dispose(): void;
  84249. /** @hidden */
  84250. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84251. private _loadIorPropertiesAsync;
  84252. }
  84253. }
  84254. declare module BABYLON.GLTF2.Loader.Extensions {
  84255. /**
  84256. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  84257. */
  84258. export class KHR_materials_variants implements IGLTFLoaderExtension {
  84259. /**
  84260. * The name of this extension.
  84261. */
  84262. readonly name: string;
  84263. /**
  84264. * Defines whether this extension is enabled.
  84265. */
  84266. enabled: boolean;
  84267. private _loader;
  84268. private _variants?;
  84269. /** @hidden */
  84270. constructor(loader: GLTFLoader);
  84271. /** @hidden */
  84272. dispose(): void;
  84273. /**
  84274. * Gets the list of available variant names for this asset.
  84275. * @param rootMesh The glTF root mesh
  84276. * @returns the list of all the variant names for this model
  84277. */
  84278. static GetAvailableVariants(rootMesh: Mesh): string[];
  84279. /**
  84280. * Gets the list of available variant names for this asset.
  84281. * @param rootMesh The glTF root mesh
  84282. * @returns the list of all the variant names for this model
  84283. */
  84284. getAvailableVariants(rootMesh: Mesh): string[];
  84285. /**
  84286. * Select a variant given a variant name or a list of variant names.
  84287. * @param rootMesh The glTF root mesh
  84288. * @param variantName The variant name(s) to select.
  84289. */
  84290. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84291. /**
  84292. * Select a variant given a variant name or a list of variant names.
  84293. * @param rootMesh The glTF root mesh
  84294. * @param variantName The variant name(s) to select.
  84295. */
  84296. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84297. /**
  84298. * Reset back to the original before selecting a variant.
  84299. * @param rootMesh The glTF root mesh
  84300. */
  84301. static Reset(rootMesh: Mesh): void;
  84302. /**
  84303. * Reset back to the original before selecting a variant.
  84304. * @param rootMesh The glTF root mesh
  84305. */
  84306. reset(rootMesh: Mesh): void;
  84307. /**
  84308. * Gets the last selected variant name(s) or null if original.
  84309. * @param rootMesh The glTF root mesh
  84310. * @returns The selected variant name(s).
  84311. */
  84312. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84313. /**
  84314. * Gets the last selected variant name(s) or null if original.
  84315. * @param rootMesh The glTF root mesh
  84316. * @returns The selected variant name(s).
  84317. */
  84318. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84319. private static _GetExtensionMetadata;
  84320. /** @hidden */
  84321. onLoading(): void;
  84322. /** @hidden */
  84323. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  84324. }
  84325. }
  84326. declare module BABYLON.GLTF2.Loader.Extensions {
  84327. /**
  84328. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  84329. */
  84330. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  84331. /**
  84332. * The name of this extension.
  84333. */
  84334. readonly name: string;
  84335. /**
  84336. * Defines whether this extension is enabled.
  84337. */
  84338. enabled: boolean;
  84339. /**
  84340. * Defines a number that determines the order the extensions are applied.
  84341. */
  84342. order: number;
  84343. private _loader;
  84344. /** @hidden */
  84345. constructor(loader: GLTFLoader);
  84346. /** @hidden */
  84347. dispose(): void;
  84348. /** @hidden */
  84349. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84350. private _loadTransparentPropertiesAsync;
  84351. }
  84352. }
  84353. declare module BABYLON.GLTF2.Loader.Extensions {
  84354. /**
  84355. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  84356. * !!! Experimental Extension Subject to Changes !!!
  84357. */
  84358. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  84359. /**
  84360. * The name of this extension.
  84361. */
  84362. readonly name: string;
  84363. /**
  84364. * Defines whether this extension is enabled.
  84365. */
  84366. enabled: boolean;
  84367. /**
  84368. * Defines a number that determines the order the extensions are applied.
  84369. */
  84370. order: number;
  84371. private _loader;
  84372. /** @hidden */
  84373. constructor(loader: GLTFLoader);
  84374. /** @hidden */
  84375. dispose(): void;
  84376. /** @hidden */
  84377. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84378. private _loadTranslucentPropertiesAsync;
  84379. }
  84380. }
  84381. declare module BABYLON.GLTF2.Loader.Extensions {
  84382. /**
  84383. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  84384. */
  84385. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  84386. /**
  84387. * The name of this extension.
  84388. */
  84389. readonly name: string;
  84390. /**
  84391. * Defines whether this extension is enabled.
  84392. */
  84393. enabled: boolean;
  84394. /** @hidden */
  84395. constructor(loader: GLTFLoader);
  84396. /** @hidden */
  84397. dispose(): void;
  84398. }
  84399. }
  84400. declare module BABYLON.GLTF2.Loader.Extensions {
  84401. /**
  84402. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  84403. * !!! Experimental Extension Subject to Changes !!!
  84404. */
  84405. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  84406. /** The name of this extension. */
  84407. readonly name: string;
  84408. /** Defines whether this extension is enabled. */
  84409. enabled: boolean;
  84410. private _loader;
  84411. /** @hidden */
  84412. constructor(loader: GLTFLoader);
  84413. /** @hidden */
  84414. dispose(): void;
  84415. /** @hidden */
  84416. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84417. }
  84418. }
  84419. declare module BABYLON.GLTF2.Loader.Extensions {
  84420. /**
  84421. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  84422. */
  84423. export class KHR_texture_transform implements IGLTFLoaderExtension {
  84424. /**
  84425. * The name of this extension.
  84426. */
  84427. readonly name: string;
  84428. /**
  84429. * Defines whether this extension is enabled.
  84430. */
  84431. enabled: boolean;
  84432. private _loader;
  84433. /** @hidden */
  84434. constructor(loader: GLTFLoader);
  84435. /** @hidden */
  84436. dispose(): void;
  84437. /** @hidden */
  84438. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84439. }
  84440. }
  84441. declare module BABYLON.GLTF2.Loader.Extensions {
  84442. /**
  84443. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  84444. */
  84445. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  84446. /**
  84447. * The name of this extension.
  84448. */
  84449. readonly name: string;
  84450. /**
  84451. * Defines whether this extension is enabled.
  84452. */
  84453. enabled: boolean;
  84454. private _loader;
  84455. private _clips;
  84456. private _emitters;
  84457. /** @hidden */
  84458. constructor(loader: GLTFLoader);
  84459. /** @hidden */
  84460. dispose(): void;
  84461. /** @hidden */
  84462. onLoading(): void;
  84463. /** @hidden */
  84464. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84465. /** @hidden */
  84466. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84467. /** @hidden */
  84468. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  84469. private _loadClipAsync;
  84470. private _loadEmitterAsync;
  84471. private _getEventAction;
  84472. private _loadAnimationEventAsync;
  84473. }
  84474. }
  84475. declare module BABYLON.GLTF2.Loader.Extensions {
  84476. /**
  84477. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  84478. */
  84479. export class MSFT_lod implements IGLTFLoaderExtension {
  84480. /**
  84481. * The name of this extension.
  84482. */
  84483. readonly name: string;
  84484. /**
  84485. * Defines whether this extension is enabled.
  84486. */
  84487. enabled: boolean;
  84488. /**
  84489. * Defines a number that determines the order the extensions are applied.
  84490. */
  84491. order: number;
  84492. /**
  84493. * Maximum number of LODs to load, starting from the lowest LOD.
  84494. */
  84495. maxLODsToLoad: number;
  84496. /**
  84497. * Observable raised when all node LODs of one level are loaded.
  84498. * The event data is the index of the loaded LOD starting from zero.
  84499. * Dispose the loader to cancel the loading of the next level of LODs.
  84500. */
  84501. onNodeLODsLoadedObservable: Observable<number>;
  84502. /**
  84503. * Observable raised when all material LODs of one level are loaded.
  84504. * The event data is the index of the loaded LOD starting from zero.
  84505. * Dispose the loader to cancel the loading of the next level of LODs.
  84506. */
  84507. onMaterialLODsLoadedObservable: Observable<number>;
  84508. private _loader;
  84509. private _bufferLODs;
  84510. private _nodeIndexLOD;
  84511. private _nodeSignalLODs;
  84512. private _nodePromiseLODs;
  84513. private _nodeBufferLODs;
  84514. private _materialIndexLOD;
  84515. private _materialSignalLODs;
  84516. private _materialPromiseLODs;
  84517. private _materialBufferLODs;
  84518. /** @hidden */
  84519. constructor(loader: GLTFLoader);
  84520. /** @hidden */
  84521. dispose(): void;
  84522. /** @hidden */
  84523. onReady(): void;
  84524. /** @hidden */
  84525. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84526. /** @hidden */
  84527. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84528. /** @hidden */
  84529. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  84530. /** @hidden */
  84531. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  84532. /** @hidden */
  84533. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  84534. private _loadBufferLOD;
  84535. /**
  84536. * Gets an array of LOD properties from lowest to highest.
  84537. */
  84538. private _getLODs;
  84539. private _disposeTransformNode;
  84540. private _disposeMaterials;
  84541. }
  84542. }
  84543. declare module BABYLON.GLTF2.Loader.Extensions {
  84544. /** @hidden */
  84545. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  84546. readonly name: string;
  84547. enabled: boolean;
  84548. private _loader;
  84549. constructor(loader: GLTFLoader);
  84550. dispose(): void;
  84551. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84552. }
  84553. }
  84554. declare module BABYLON.GLTF2.Loader.Extensions {
  84555. /** @hidden */
  84556. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  84557. readonly name: string;
  84558. enabled: boolean;
  84559. private _loader;
  84560. constructor(loader: GLTFLoader);
  84561. dispose(): void;
  84562. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84563. }
  84564. }
  84565. declare module BABYLON.GLTF2.Loader.Extensions {
  84566. /**
  84567. * Store glTF extras (if present) in BJS objects' metadata
  84568. */
  84569. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  84570. /**
  84571. * The name of this extension.
  84572. */
  84573. readonly name: string;
  84574. /**
  84575. * Defines whether this extension is enabled.
  84576. */
  84577. enabled: boolean;
  84578. private _loader;
  84579. private _assignExtras;
  84580. /** @hidden */
  84581. constructor(loader: GLTFLoader);
  84582. /** @hidden */
  84583. dispose(): void;
  84584. /** @hidden */
  84585. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84586. /** @hidden */
  84587. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84588. /** @hidden */
  84589. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84590. }
  84591. }
  84592. declare module BABYLON {
  84593. /**
  84594. * Class reading and parsing the MTL file bundled with the obj file.
  84595. */
  84596. export class MTLFileLoader {
  84597. /**
  84598. * Invert Y-Axis of referenced textures on load
  84599. */
  84600. static INVERT_TEXTURE_Y: boolean;
  84601. /**
  84602. * All material loaded from the mtl will be set here
  84603. */
  84604. materials: StandardMaterial[];
  84605. /**
  84606. * This function will read the mtl file and create each material described inside
  84607. * This function could be improve by adding :
  84608. * -some component missing (Ni, Tf...)
  84609. * -including the specific options available
  84610. *
  84611. * @param scene defines the scene the material will be created in
  84612. * @param data defines the mtl data to parse
  84613. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84614. * @param forAssetContainer defines if the material should be registered in the scene
  84615. */
  84616. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84617. /**
  84618. * Gets the texture for the material.
  84619. *
  84620. * If the material is imported from input file,
  84621. * We sanitize the url to ensure it takes the textre from aside the material.
  84622. *
  84623. * @param rootUrl The root url to load from
  84624. * @param value The value stored in the mtl
  84625. * @return The Texture
  84626. */
  84627. private static _getTexture;
  84628. }
  84629. }
  84630. declare module BABYLON {
  84631. /**
  84632. * Options for loading OBJ/MTL files
  84633. */
  84634. type MeshLoadOptions = {
  84635. /**
  84636. * Defines if UVs are optimized by default during load.
  84637. */
  84638. OptimizeWithUV: boolean;
  84639. /**
  84640. * Defines custom scaling of UV coordinates of loaded meshes.
  84641. */
  84642. UVScaling: Vector2;
  84643. /**
  84644. * Invert model on y-axis (does a model scaling inversion)
  84645. */
  84646. InvertY: boolean;
  84647. /**
  84648. * Invert Y-Axis of referenced textures on load
  84649. */
  84650. InvertTextureY: boolean;
  84651. /**
  84652. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84653. */
  84654. ImportVertexColors: boolean;
  84655. /**
  84656. * Compute the normals for the model, even if normals are present in the file.
  84657. */
  84658. ComputeNormals: boolean;
  84659. /**
  84660. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84661. */
  84662. SkipMaterials: boolean;
  84663. /**
  84664. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84665. */
  84666. MaterialLoadingFailsSilently: boolean;
  84667. };
  84668. /**
  84669. * OBJ file type loader.
  84670. * This is a babylon scene loader plugin.
  84671. */
  84672. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84673. /**
  84674. * Defines if UVs are optimized by default during load.
  84675. */
  84676. static OPTIMIZE_WITH_UV: boolean;
  84677. /**
  84678. * Invert model on y-axis (does a model scaling inversion)
  84679. */
  84680. static INVERT_Y: boolean;
  84681. /**
  84682. * Invert Y-Axis of referenced textures on load
  84683. */
  84684. static get INVERT_TEXTURE_Y(): boolean;
  84685. static set INVERT_TEXTURE_Y(value: boolean);
  84686. /**
  84687. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84688. */
  84689. static IMPORT_VERTEX_COLORS: boolean;
  84690. /**
  84691. * Compute the normals for the model, even if normals are present in the file.
  84692. */
  84693. static COMPUTE_NORMALS: boolean;
  84694. /**
  84695. * Defines custom scaling of UV coordinates of loaded meshes.
  84696. */
  84697. static UV_SCALING: Vector2;
  84698. /**
  84699. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84700. */
  84701. static SKIP_MATERIALS: boolean;
  84702. /**
  84703. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84704. *
  84705. * Defaults to true for backwards compatibility.
  84706. */
  84707. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84708. /**
  84709. * Defines the name of the plugin.
  84710. */
  84711. name: string;
  84712. /**
  84713. * Defines the extension the plugin is able to load.
  84714. */
  84715. extensions: string;
  84716. /** @hidden */
  84717. obj: RegExp;
  84718. /** @hidden */
  84719. group: RegExp;
  84720. /** @hidden */
  84721. mtllib: RegExp;
  84722. /** @hidden */
  84723. usemtl: RegExp;
  84724. /** @hidden */
  84725. smooth: RegExp;
  84726. /** @hidden */
  84727. vertexPattern: RegExp;
  84728. /** @hidden */
  84729. normalPattern: RegExp;
  84730. /** @hidden */
  84731. uvPattern: RegExp;
  84732. /** @hidden */
  84733. facePattern1: RegExp;
  84734. /** @hidden */
  84735. facePattern2: RegExp;
  84736. /** @hidden */
  84737. facePattern3: RegExp;
  84738. /** @hidden */
  84739. facePattern4: RegExp;
  84740. /** @hidden */
  84741. facePattern5: RegExp;
  84742. private _forAssetContainer;
  84743. private _meshLoadOptions;
  84744. /**
  84745. * Creates loader for .OBJ files
  84746. *
  84747. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84748. */
  84749. constructor(meshLoadOptions?: MeshLoadOptions);
  84750. private static get currentMeshLoadOptions();
  84751. /**
  84752. * Calls synchronously the MTL file attached to this obj.
  84753. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84754. * Without this function materials are not displayed in the first frame (but displayed after).
  84755. * In consequence it is impossible to get material information in your HTML file
  84756. *
  84757. * @param url The URL of the MTL file
  84758. * @param rootUrl
  84759. * @param onSuccess Callback function to be called when the MTL file is loaded
  84760. * @private
  84761. */
  84762. private _loadMTL;
  84763. /**
  84764. * Instantiates a OBJ file loader plugin.
  84765. * @returns the created plugin
  84766. */
  84767. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84768. /**
  84769. * If the data string can be loaded directly.
  84770. *
  84771. * @param data string containing the file data
  84772. * @returns if the data can be loaded directly
  84773. */
  84774. canDirectLoad(data: string): boolean;
  84775. /**
  84776. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84777. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84778. * @param scene the scene the meshes should be added to
  84779. * @param data the OBJ data to load
  84780. * @param rootUrl root url to load from
  84781. * @param onProgress event that fires when loading progress has occured
  84782. * @param fileName Defines the name of the file to load
  84783. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84784. */
  84785. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  84786. /**
  84787. * Imports all objects from the loaded OBJ data and adds them to the scene
  84788. * @param scene the scene the objects should be added to
  84789. * @param data the OBJ data to load
  84790. * @param rootUrl root url to load from
  84791. * @param onProgress event that fires when loading progress has occured
  84792. * @param fileName Defines the name of the file to load
  84793. * @returns a promise which completes when objects have been loaded to the scene
  84794. */
  84795. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84796. /**
  84797. * Load into an asset container.
  84798. * @param scene The scene to load into
  84799. * @param data The data to import
  84800. * @param rootUrl The root url for scene and resources
  84801. * @param onProgress The callback when the load progresses
  84802. * @param fileName Defines the name of the file to load
  84803. * @returns The loaded asset container
  84804. */
  84805. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84806. /**
  84807. * Read the OBJ file and create an Array of meshes.
  84808. * Each mesh contains all information given by the OBJ and the MTL file.
  84809. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84810. *
  84811. * @param meshesNames
  84812. * @param scene Scene The scene where are displayed the data
  84813. * @param data String The content of the obj file
  84814. * @param rootUrl String The path to the folder
  84815. * @returns Array<AbstractMesh>
  84816. * @private
  84817. */
  84818. private _parseSolid;
  84819. }
  84820. }
  84821. declare module BABYLON {
  84822. /**
  84823. * STL file type loader.
  84824. * This is a babylon scene loader plugin.
  84825. */
  84826. export class STLFileLoader implements ISceneLoaderPlugin {
  84827. /** @hidden */
  84828. solidPattern: RegExp;
  84829. /** @hidden */
  84830. facetsPattern: RegExp;
  84831. /** @hidden */
  84832. normalPattern: RegExp;
  84833. /** @hidden */
  84834. vertexPattern: RegExp;
  84835. /**
  84836. * Defines the name of the plugin.
  84837. */
  84838. name: string;
  84839. /**
  84840. * Defines the extensions the stl loader is able to load.
  84841. * force data to come in as an ArrayBuffer
  84842. * we'll convert to string if it looks like it's an ASCII .stl
  84843. */
  84844. extensions: ISceneLoaderPluginExtensions;
  84845. /**
  84846. * Import meshes into a scene.
  84847. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84848. * @param scene The scene to import into
  84849. * @param data The data to import
  84850. * @param rootUrl The root url for scene and resources
  84851. * @param meshes The meshes array to import into
  84852. * @param particleSystems The particle systems array to import into
  84853. * @param skeletons The skeletons array to import into
  84854. * @param onError The callback when import fails
  84855. * @returns True if successful or false otherwise
  84856. */
  84857. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84858. /**
  84859. * Load into a scene.
  84860. * @param scene The scene to load into
  84861. * @param data The data to import
  84862. * @param rootUrl The root url for scene and resources
  84863. * @param onError The callback when import fails
  84864. * @returns true if successful or false otherwise
  84865. */
  84866. load(scene: Scene, data: any, rootUrl: string): boolean;
  84867. /**
  84868. * Load into an asset container.
  84869. * @param scene The scene to load into
  84870. * @param data The data to import
  84871. * @param rootUrl The root url for scene and resources
  84872. * @param onError The callback when import fails
  84873. * @returns The loaded asset container
  84874. */
  84875. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84876. private _isBinary;
  84877. private _parseBinary;
  84878. private _parseASCII;
  84879. }
  84880. }
  84881. declare module BABYLON {
  84882. /**
  84883. * Class for generating OBJ data from a Babylon scene.
  84884. */
  84885. export class OBJExport {
  84886. /**
  84887. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84888. * @param mesh defines the list of meshes to serialize
  84889. * @param materials defines if materials should be exported
  84890. * @param matlibname defines the name of the associated mtl file
  84891. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84892. * @returns the OBJ content
  84893. */
  84894. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84895. /**
  84896. * Exports the material(s) of a mesh in .MTL file format (text)
  84897. * @param mesh defines the mesh to extract the material from
  84898. * @returns the mtl content
  84899. */
  84900. static MTL(mesh: Mesh): string;
  84901. }
  84902. }
  84903. declare module BABYLON {
  84904. /** @hidden */
  84905. export var __IGLTFExporterExtension: number;
  84906. /**
  84907. * Interface for extending the exporter
  84908. * @hidden
  84909. */
  84910. export interface IGLTFExporterExtension {
  84911. /**
  84912. * The name of this extension
  84913. */
  84914. readonly name: string;
  84915. /**
  84916. * Defines whether this extension is enabled
  84917. */
  84918. enabled: boolean;
  84919. /**
  84920. * Defines whether this extension is required
  84921. */
  84922. required: boolean;
  84923. }
  84924. }
  84925. declare module BABYLON.GLTF2.Exporter {
  84926. /** @hidden */
  84927. export var __IGLTFExporterExtensionV2: number;
  84928. /**
  84929. * Interface for a glTF exporter extension
  84930. * @hidden
  84931. */
  84932. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84933. /**
  84934. * Define this method to modify the default behavior before exporting a texture
  84935. * @param context The context when loading the asset
  84936. * @param babylonTexture The Babylon.js texture
  84937. * @param mimeType The mime-type of the generated image
  84938. * @returns A promise that resolves with the exported texture
  84939. */
  84940. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84941. /**
  84942. * Define this method to get notified when a texture info is created
  84943. * @param context The context when loading the asset
  84944. * @param textureInfo The glTF texture info
  84945. * @param babylonTexture The Babylon.js texture
  84946. */
  84947. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84948. /**
  84949. * Define this method to modify the default behavior when exporting texture info
  84950. * @param context The context when loading the asset
  84951. * @param meshPrimitive glTF mesh primitive
  84952. * @param babylonSubMesh Babylon submesh
  84953. * @param binaryWriter glTF serializer binary writer instance
  84954. * @returns nullable IMeshPrimitive promise
  84955. */
  84956. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84957. /**
  84958. * Define this method to modify the default behavior when exporting a node
  84959. * @param context The context when exporting the node
  84960. * @param node glTF node
  84961. * @param babylonNode BabylonJS node
  84962. * @returns nullable INode promise
  84963. */
  84964. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84965. [key: number]: number;
  84966. }): Promise<Nullable<INode>>;
  84967. /**
  84968. * Define this method to modify the default behavior when exporting a material
  84969. * @param material glTF material
  84970. * @param babylonMaterial BabylonJS material
  84971. * @returns nullable IMaterial promise
  84972. */
  84973. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84974. /**
  84975. * Define this method to return additional textures to export from a material
  84976. * @param material glTF material
  84977. * @param babylonMaterial BabylonJS material
  84978. * @returns List of textures
  84979. */
  84980. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84981. /** Gets a boolean indicating that this extension was used */
  84982. wasUsed: boolean;
  84983. /** Gets a boolean indicating that this extension is required for the file to work */
  84984. required: boolean;
  84985. /**
  84986. * Called after the exporter state changes to EXPORTING
  84987. */
  84988. onExporting?(): void;
  84989. }
  84990. }
  84991. declare module BABYLON.GLTF2.Exporter {
  84992. /**
  84993. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84994. * @hidden
  84995. */
  84996. export class _GLTFMaterialExporter {
  84997. /**
  84998. * Represents the dielectric specular values for R, G and B
  84999. */
  85000. private static readonly _DielectricSpecular;
  85001. /**
  85002. * Allows the maximum specular power to be defined for material calculations
  85003. */
  85004. private static readonly _MaxSpecularPower;
  85005. /**
  85006. * Mapping to store textures
  85007. */
  85008. private _textureMap;
  85009. /**
  85010. * Numeric tolerance value
  85011. */
  85012. private static readonly _Epsilon;
  85013. /**
  85014. * Reference to the glTF Exporter
  85015. */
  85016. private _exporter;
  85017. constructor(exporter: _Exporter);
  85018. /**
  85019. * Specifies if two colors are approximately equal in value
  85020. * @param color1 first color to compare to
  85021. * @param color2 second color to compare to
  85022. * @param epsilon threshold value
  85023. */
  85024. private static FuzzyEquals;
  85025. /**
  85026. * Gets the materials from a Babylon scene and converts them to glTF materials
  85027. * @param scene babylonjs scene
  85028. * @param mimeType texture mime type
  85029. * @param images array of images
  85030. * @param textures array of textures
  85031. * @param materials array of materials
  85032. * @param imageData mapping of texture names to base64 textures
  85033. * @param hasTextureCoords specifies if texture coordinates are present on the material
  85034. */
  85035. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  85036. /**
  85037. * Makes a copy of the glTF material without the texture parameters
  85038. * @param originalMaterial original glTF material
  85039. * @returns glTF material without texture parameters
  85040. */
  85041. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  85042. /**
  85043. * Specifies if the material has any texture parameters present
  85044. * @param material glTF Material
  85045. * @returns boolean specifying if texture parameters are present
  85046. */
  85047. _hasTexturesPresent(material: IMaterial): boolean;
  85048. /**
  85049. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  85050. * @param babylonStandardMaterial
  85051. * @returns glTF Metallic Roughness Material representation
  85052. */
  85053. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  85054. /**
  85055. * Computes the metallic factor
  85056. * @param diffuse diffused value
  85057. * @param specular specular value
  85058. * @param oneMinusSpecularStrength one minus the specular strength
  85059. * @returns metallic value
  85060. */
  85061. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  85062. /**
  85063. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  85064. * @param glTFMaterial glTF material
  85065. * @param babylonMaterial Babylon material
  85066. */
  85067. private static _SetAlphaMode;
  85068. /**
  85069. * Converts a Babylon Standard Material to a glTF Material
  85070. * @param babylonStandardMaterial BJS Standard Material
  85071. * @param mimeType mime type to use for the textures
  85072. * @param images array of glTF image interfaces
  85073. * @param textures array of glTF texture interfaces
  85074. * @param materials array of glTF material interfaces
  85075. * @param imageData map of image file name to data
  85076. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85077. */
  85078. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  85079. private _finishMaterial;
  85080. /**
  85081. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  85082. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  85083. * @param mimeType mime type to use for the textures
  85084. * @param images array of glTF image interfaces
  85085. * @param textures array of glTF texture interfaces
  85086. * @param materials array of glTF material interfaces
  85087. * @param imageData map of image file name to data
  85088. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85089. */
  85090. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  85091. /**
  85092. * Converts an image typed array buffer to a base64 image
  85093. * @param buffer typed array buffer
  85094. * @param width width of the image
  85095. * @param height height of the image
  85096. * @param mimeType mimetype of the image
  85097. * @returns base64 image string
  85098. */
  85099. private _createBase64FromCanvasAsync;
  85100. /**
  85101. * Generates a white texture based on the specified width and height
  85102. * @param width width of the texture in pixels
  85103. * @param height height of the texture in pixels
  85104. * @param scene babylonjs scene
  85105. * @returns white texture
  85106. */
  85107. private _createWhiteTexture;
  85108. /**
  85109. * 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
  85110. * @param texture1 first texture to resize
  85111. * @param texture2 second texture to resize
  85112. * @param scene babylonjs scene
  85113. * @returns resized textures or null
  85114. */
  85115. private _resizeTexturesToSameDimensions;
  85116. /**
  85117. * Converts an array of pixels to a Float32Array
  85118. * Throws an error if the pixel format is not supported
  85119. * @param pixels - array buffer containing pixel values
  85120. * @returns Float32 of pixels
  85121. */
  85122. private _convertPixelArrayToFloat32;
  85123. /**
  85124. * Convert Specular Glossiness Textures to Metallic Roughness
  85125. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  85126. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  85127. * @param diffuseTexture texture used to store diffuse information
  85128. * @param specularGlossinessTexture texture used to store specular and glossiness information
  85129. * @param factors specular glossiness material factors
  85130. * @param mimeType the mime type to use for the texture
  85131. * @returns pbr metallic roughness interface or null
  85132. */
  85133. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  85134. /**
  85135. * Converts specular glossiness material properties to metallic roughness
  85136. * @param specularGlossiness interface with specular glossiness material properties
  85137. * @returns interface with metallic roughness material properties
  85138. */
  85139. private _convertSpecularGlossinessToMetallicRoughness;
  85140. /**
  85141. * Calculates the surface reflectance, independent of lighting conditions
  85142. * @param color Color source to calculate brightness from
  85143. * @returns number representing the perceived brightness, or zero if color is undefined
  85144. */
  85145. private _getPerceivedBrightness;
  85146. /**
  85147. * Returns the maximum color component value
  85148. * @param color
  85149. * @returns maximum color component value, or zero if color is null or undefined
  85150. */
  85151. private _getMaxComponent;
  85152. /**
  85153. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  85154. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85155. * @param mimeType mime type to use for the textures
  85156. * @param images array of glTF image interfaces
  85157. * @param textures array of glTF texture interfaces
  85158. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  85159. * @param imageData map of image file name to data
  85160. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85161. * @returns glTF PBR Metallic Roughness factors
  85162. */
  85163. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  85164. private _getGLTFTextureSampler;
  85165. private _getGLTFTextureWrapMode;
  85166. private _getGLTFTextureWrapModesSampler;
  85167. /**
  85168. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  85169. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85170. * @param mimeType mime type to use for the textures
  85171. * @param images array of glTF image interfaces
  85172. * @param textures array of glTF texture interfaces
  85173. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  85174. * @param imageData map of image file name to data
  85175. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85176. * @returns glTF PBR Metallic Roughness factors
  85177. */
  85178. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  85179. /**
  85180. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  85181. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85182. * @param mimeType mime type to use for the textures
  85183. * @param images array of glTF image interfaces
  85184. * @param textures array of glTF texture interfaces
  85185. * @param materials array of glTF material interfaces
  85186. * @param imageData map of image file name to data
  85187. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85188. */
  85189. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  85190. private setMetallicRoughnessPbrMaterial;
  85191. private getPixelsFromTexture;
  85192. /**
  85193. * Extracts a texture from a Babylon texture into file data and glTF data
  85194. * @param babylonTexture Babylon texture to extract
  85195. * @param mimeType Mime Type of the babylonTexture
  85196. * @return glTF texture info, or null if the texture format is not supported
  85197. */
  85198. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  85199. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  85200. /**
  85201. * Builds a texture from base64 string
  85202. * @param base64Texture base64 texture string
  85203. * @param baseTextureName Name to use for the texture
  85204. * @param mimeType image mime type for the texture
  85205. * @param images array of images
  85206. * @param textures array of textures
  85207. * @param imageData map of image data
  85208. * @returns glTF texture info, or null if the texture format is not supported
  85209. */
  85210. private _getTextureInfoFromBase64;
  85211. }
  85212. }
  85213. declare module BABYLON {
  85214. /**
  85215. * Class for holding and downloading glTF file data
  85216. */
  85217. export class GLTFData {
  85218. /**
  85219. * Object which contains the file name as the key and its data as the value
  85220. */
  85221. glTFFiles: {
  85222. [fileName: string]: string | Blob;
  85223. };
  85224. /**
  85225. * Initializes the glTF file object
  85226. */
  85227. constructor();
  85228. /**
  85229. * Downloads the glTF data as files based on their names and data
  85230. */
  85231. downloadFiles(): void;
  85232. }
  85233. }
  85234. declare module BABYLON {
  85235. /**
  85236. * Holds a collection of exporter options and parameters
  85237. */
  85238. export interface IExportOptions {
  85239. /**
  85240. * Function which indicates whether a babylon node should be exported or not
  85241. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  85242. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  85243. */
  85244. shouldExportNode?(node: Node): boolean;
  85245. /**
  85246. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  85247. * @param metadata source metadata to read from
  85248. * @returns the data to store to glTF node extras
  85249. */
  85250. metadataSelector?(metadata: any): any;
  85251. /**
  85252. * The sample rate to bake animation curves
  85253. */
  85254. animationSampleRate?: number;
  85255. /**
  85256. * Begin serialization without waiting for the scene to be ready
  85257. */
  85258. exportWithoutWaitingForScene?: boolean;
  85259. /**
  85260. * Indicates if coordinate system swapping root nodes should be included in export
  85261. */
  85262. includeCoordinateSystemConversionNodes?: boolean;
  85263. }
  85264. /**
  85265. * Class for generating glTF data from a Babylon scene.
  85266. */
  85267. export class GLTF2Export {
  85268. /**
  85269. * Exports the geometry of the scene to .gltf file format asynchronously
  85270. * @param scene Babylon scene with scene hierarchy information
  85271. * @param filePrefix File prefix to use when generating the glTF file
  85272. * @param options Exporter options
  85273. * @returns Returns an object with a .gltf file and associates texture names
  85274. * as keys and their data and paths as values
  85275. */
  85276. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85277. private static _PreExportAsync;
  85278. private static _PostExportAsync;
  85279. /**
  85280. * Exports the geometry of the scene to .glb file format asychronously
  85281. * @param scene Babylon scene with scene hierarchy information
  85282. * @param filePrefix File prefix to use when generating glb file
  85283. * @param options Exporter options
  85284. * @returns Returns an object with a .glb filename as key and data as value
  85285. */
  85286. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85287. }
  85288. }
  85289. declare module BABYLON.GLTF2.Exporter {
  85290. /**
  85291. * @hidden
  85292. */
  85293. export class _GLTFUtilities {
  85294. /**
  85295. * Creates a buffer view based on the supplied arguments
  85296. * @param bufferIndex index value of the specified buffer
  85297. * @param byteOffset byte offset value
  85298. * @param byteLength byte length of the bufferView
  85299. * @param byteStride byte distance between conequential elements
  85300. * @param name name of the buffer view
  85301. * @returns bufferView for glTF
  85302. */
  85303. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  85304. /**
  85305. * Creates an accessor based on the supplied arguments
  85306. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  85307. * @param name The name of the accessor
  85308. * @param type The type of the accessor
  85309. * @param componentType The datatype of components in the attribute
  85310. * @param count The number of attributes referenced by this accessor
  85311. * @param byteOffset The offset relative to the start of the bufferView in bytes
  85312. * @param min Minimum value of each component in this attribute
  85313. * @param max Maximum value of each component in this attribute
  85314. * @returns accessor for glTF
  85315. */
  85316. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  85317. /**
  85318. * Calculates the minimum and maximum values of an array of position floats
  85319. * @param positions Positions array of a mesh
  85320. * @param vertexStart Starting vertex offset to calculate min and max values
  85321. * @param vertexCount Number of vertices to check for min and max values
  85322. * @returns min number array and max number array
  85323. */
  85324. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  85325. min: number[];
  85326. max: number[];
  85327. };
  85328. /**
  85329. * Converts a new right-handed Vector3
  85330. * @param vector vector3 array
  85331. * @returns right-handed Vector3
  85332. */
  85333. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  85334. /**
  85335. * Converts a Vector3 to right-handed
  85336. * @param vector Vector3 to convert to right-handed
  85337. */
  85338. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  85339. /**
  85340. * Converts a three element number array to right-handed
  85341. * @param vector number array to convert to right-handed
  85342. */
  85343. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  85344. /**
  85345. * Converts a new right-handed Vector3
  85346. * @param vector vector3 array
  85347. * @returns right-handed Vector3
  85348. */
  85349. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  85350. /**
  85351. * Converts a Vector3 to right-handed
  85352. * @param vector Vector3 to convert to right-handed
  85353. */
  85354. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  85355. /**
  85356. * Converts a three element number array to right-handed
  85357. * @param vector number array to convert to right-handed
  85358. */
  85359. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  85360. /**
  85361. * Converts a Vector4 to right-handed
  85362. * @param vector Vector4 to convert to right-handed
  85363. */
  85364. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  85365. /**
  85366. * Converts a Vector4 to right-handed
  85367. * @param vector Vector4 to convert to right-handed
  85368. */
  85369. static _GetRightHandedArray4FromRef(vector: number[]): void;
  85370. /**
  85371. * Converts a Quaternion to right-handed
  85372. * @param quaternion Source quaternion to convert to right-handed
  85373. */
  85374. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  85375. /**
  85376. * Converts a Quaternion to right-handed
  85377. * @param quaternion Source quaternion to convert to right-handed
  85378. */
  85379. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  85380. static _NormalizeTangentFromRef(tangent: Vector4): void;
  85381. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  85382. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  85383. }
  85384. }
  85385. declare module BABYLON.GLTF2.Exporter {
  85386. /**
  85387. * Converts Babylon Scene into glTF 2.0.
  85388. * @hidden
  85389. */
  85390. export class _Exporter {
  85391. /**
  85392. * Stores the glTF to export
  85393. */
  85394. _glTF: IGLTF;
  85395. /**
  85396. * Stores all generated buffer views, which represents views into the main glTF buffer data
  85397. */
  85398. _bufferViews: IBufferView[];
  85399. /**
  85400. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  85401. */
  85402. _accessors: IAccessor[];
  85403. /**
  85404. * Stores all the generated nodes, which contains transform and/or mesh information per node
  85405. */
  85406. _nodes: INode[];
  85407. /**
  85408. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  85409. */
  85410. private _scenes;
  85411. /**
  85412. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  85413. */
  85414. private _meshes;
  85415. /**
  85416. * Stores all the generated material information, which represents the appearance of each primitive
  85417. */
  85418. _materials: IMaterial[];
  85419. _materialMap: {
  85420. [materialID: number]: number;
  85421. };
  85422. /**
  85423. * Stores all the generated texture information, which is referenced by glTF materials
  85424. */
  85425. _textures: ITexture[];
  85426. /**
  85427. * Stores all the generated image information, which is referenced by glTF textures
  85428. */
  85429. _images: IImage[];
  85430. /**
  85431. * Stores all the texture samplers
  85432. */
  85433. _samplers: ISampler[];
  85434. /**
  85435. * Stores all the generated glTF skins
  85436. */
  85437. _skins: ISkin[];
  85438. /**
  85439. * Stores all the generated animation samplers, which is referenced by glTF animations
  85440. */
  85441. /**
  85442. * Stores the animations for glTF models
  85443. */
  85444. private _animations;
  85445. /**
  85446. * Stores the total amount of bytes stored in the glTF buffer
  85447. */
  85448. private _totalByteLength;
  85449. /**
  85450. * Stores a reference to the Babylon scene containing the source geometry and material information
  85451. */
  85452. _babylonScene: Scene;
  85453. /**
  85454. * Stores a map of the image data, where the key is the file name and the value
  85455. * is the image data
  85456. */
  85457. _imageData: {
  85458. [fileName: string]: {
  85459. data: Uint8Array;
  85460. mimeType: ImageMimeType;
  85461. };
  85462. };
  85463. protected _orderedImageData: Array<{
  85464. data: Uint8Array;
  85465. mimeType: ImageMimeType;
  85466. }>;
  85467. /**
  85468. * Stores a map of the unique id of a node to its index in the node array
  85469. */
  85470. _nodeMap: {
  85471. [key: number]: number;
  85472. };
  85473. /**
  85474. * Specifies if the source Babylon scene was left handed, and needed conversion.
  85475. */
  85476. _convertToRightHandedSystem: boolean;
  85477. /**
  85478. * Specifies if a Babylon node should be converted to right-handed on export
  85479. */
  85480. _convertToRightHandedSystemMap: {
  85481. [nodeId: number]: boolean;
  85482. };
  85483. _includeCoordinateSystemConversionNodes: boolean;
  85484. /**
  85485. * Baked animation sample rate
  85486. */
  85487. private _animationSampleRate;
  85488. private _options;
  85489. private _localEngine;
  85490. _glTFMaterialExporter: _GLTFMaterialExporter;
  85491. private _extensions;
  85492. private static _ExtensionNames;
  85493. private static _ExtensionFactories;
  85494. private _applyExtension;
  85495. private _applyExtensions;
  85496. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  85497. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  85498. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85499. [key: number]: number;
  85500. }): Promise<Nullable<INode>>;
  85501. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  85502. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  85503. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  85504. private _forEachExtensions;
  85505. private _extensionsOnExporting;
  85506. /**
  85507. * Load glTF serializer extensions
  85508. */
  85509. private _loadExtensions;
  85510. /**
  85511. * Creates a glTF Exporter instance, which can accept optional exporter options
  85512. * @param babylonScene Babylon scene object
  85513. * @param options Options to modify the behavior of the exporter
  85514. */
  85515. constructor(babylonScene: Scene, options?: IExportOptions);
  85516. dispose(): void;
  85517. /**
  85518. * Registers a glTF exporter extension
  85519. * @param name Name of the extension to export
  85520. * @param factory The factory function that creates the exporter extension
  85521. */
  85522. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  85523. /**
  85524. * Un-registers an exporter extension
  85525. * @param name The name fo the exporter extension
  85526. * @returns A boolean indicating whether the extension has been un-registered
  85527. */
  85528. static UnregisterExtension(name: string): boolean;
  85529. /**
  85530. * Lazy load a local engine
  85531. */
  85532. _getLocalEngine(): Engine;
  85533. private reorderIndicesBasedOnPrimitiveMode;
  85534. /**
  85535. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  85536. * clock-wise during export to glTF
  85537. * @param submesh BabylonJS submesh
  85538. * @param primitiveMode Primitive mode of the mesh
  85539. * @param sideOrientation the winding order of the submesh
  85540. * @param vertexBufferKind The type of vertex attribute
  85541. * @param meshAttributeArray The vertex attribute data
  85542. * @param byteOffset The offset to the binary data
  85543. * @param binaryWriter The binary data for the glTF file
  85544. * @param convertToRightHandedSystem Converts the values to right-handed
  85545. */
  85546. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  85547. /**
  85548. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  85549. * clock-wise during export to glTF
  85550. * @param submesh BabylonJS submesh
  85551. * @param primitiveMode Primitive mode of the mesh
  85552. * @param sideOrientation the winding order of the submesh
  85553. * @param vertexBufferKind The type of vertex attribute
  85554. * @param meshAttributeArray The vertex attribute data
  85555. * @param byteOffset The offset to the binary data
  85556. * @param binaryWriter The binary data for the glTF file
  85557. * @param convertToRightHandedSystem Converts the values to right-handed
  85558. */
  85559. private reorderTriangleFillMode;
  85560. /**
  85561. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  85562. * clock-wise during export to glTF
  85563. * @param submesh BabylonJS submesh
  85564. * @param primitiveMode Primitive mode of the mesh
  85565. * @param sideOrientation the winding order of the submesh
  85566. * @param vertexBufferKind The type of vertex attribute
  85567. * @param meshAttributeArray The vertex attribute data
  85568. * @param byteOffset The offset to the binary data
  85569. * @param binaryWriter The binary data for the glTF file
  85570. * @param convertToRightHandedSystem Converts the values to right-handed
  85571. */
  85572. private reorderTriangleStripDrawMode;
  85573. /**
  85574. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85575. * clock-wise during export to glTF
  85576. * @param submesh BabylonJS submesh
  85577. * @param primitiveMode Primitive mode of the mesh
  85578. * @param sideOrientation the winding order of the submesh
  85579. * @param vertexBufferKind The type of vertex attribute
  85580. * @param meshAttributeArray The vertex attribute data
  85581. * @param byteOffset The offset to the binary data
  85582. * @param binaryWriter The binary data for the glTF file
  85583. * @param convertToRightHandedSystem Converts the values to right-handed
  85584. */
  85585. private reorderTriangleFanMode;
  85586. /**
  85587. * Writes the vertex attribute data to binary
  85588. * @param vertices The vertices to write to the binary writer
  85589. * @param byteOffset The offset into the binary writer to overwrite binary data
  85590. * @param vertexAttributeKind The vertex attribute type
  85591. * @param meshAttributeArray The vertex attribute data
  85592. * @param binaryWriter The writer containing the binary data
  85593. * @param convertToRightHandedSystem Converts the values to right-handed
  85594. */
  85595. private writeVertexAttributeData;
  85596. /**
  85597. * Writes mesh attribute data to a data buffer
  85598. * Returns the bytelength of the data
  85599. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85600. * @param meshAttributeArray Array containing the attribute data
  85601. * @param byteStride Specifies the space between data
  85602. * @param binaryWriter The buffer to write the binary data to
  85603. * @param convertToRightHandedSystem Converts the values to right-handed
  85604. */
  85605. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85606. /**
  85607. * Writes mesh attribute data to a data buffer
  85608. * Returns the bytelength of the data
  85609. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85610. * @param meshAttributeArray Array containing the attribute data
  85611. * @param byteStride Specifies the space between data
  85612. * @param binaryWriter The buffer to write the binary data to
  85613. * @param convertToRightHandedSystem Converts the values to right-handed
  85614. */
  85615. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85616. /**
  85617. * Generates glTF json data
  85618. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85619. * @param glTFPrefix Text to use when prefixing a glTF file
  85620. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85621. * @returns json data as string
  85622. */
  85623. private generateJSON;
  85624. /**
  85625. * Generates data for .gltf and .bin files based on the glTF prefix string
  85626. * @param glTFPrefix Text to use when prefixing a glTF file
  85627. * @param dispose Dispose the exporter
  85628. * @returns GLTFData with glTF file data
  85629. */
  85630. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85631. /**
  85632. * Creates a binary buffer for glTF
  85633. * @returns array buffer for binary data
  85634. */
  85635. private _generateBinaryAsync;
  85636. /**
  85637. * Pads the number to a multiple of 4
  85638. * @param num number to pad
  85639. * @returns padded number
  85640. */
  85641. private _getPadding;
  85642. /**
  85643. * @hidden
  85644. */
  85645. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85646. /**
  85647. * Sets the TRS for each node
  85648. * @param node glTF Node for storing the transformation data
  85649. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85650. * @param convertToRightHandedSystem Converts the values to right-handed
  85651. */
  85652. private setNodeTransformation;
  85653. private getVertexBufferFromMesh;
  85654. /**
  85655. * Creates a bufferview based on the vertices type for the Babylon mesh
  85656. * @param kind Indicates the type of vertices data
  85657. * @param componentType Indicates the numerical type used to store the data
  85658. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85659. * @param binaryWriter The buffer to write the bufferview data to
  85660. * @param convertToRightHandedSystem Converts the values to right-handed
  85661. */
  85662. private createBufferViewKind;
  85663. /**
  85664. * Creates a bufferview based on the vertices type for the Babylon mesh
  85665. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85666. * @param babylonMorphTarget the morph target to be exported
  85667. * @param binaryWriter The buffer to write the bufferview data to
  85668. * @param convertToRightHandedSystem Converts the values to right-handed
  85669. */
  85670. private setMorphTargetAttributes;
  85671. /**
  85672. * The primitive mode of the Babylon mesh
  85673. * @param babylonMesh The BabylonJS mesh
  85674. */
  85675. private getMeshPrimitiveMode;
  85676. /**
  85677. * Sets the primitive mode of the glTF mesh primitive
  85678. * @param meshPrimitive glTF mesh primitive
  85679. * @param primitiveMode The primitive mode
  85680. */
  85681. private setPrimitiveMode;
  85682. /**
  85683. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85684. * @param meshPrimitive glTF mesh primitive
  85685. * @param attributeKind vertex attribute
  85686. * @returns boolean specifying if uv coordinates are present
  85687. */
  85688. private setAttributeKind;
  85689. /**
  85690. * Sets data for the primitive attributes of each submesh
  85691. * @param mesh glTF Mesh object to store the primitive attribute information
  85692. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85693. * @param binaryWriter Buffer to write the attribute data to
  85694. * @param convertToRightHandedSystem Converts the values to right-handed
  85695. */
  85696. private setPrimitiveAttributesAsync;
  85697. /**
  85698. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85699. * @param node The node to check
  85700. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85701. */
  85702. private isBabylonCoordinateSystemConvertingNode;
  85703. /**
  85704. * Creates a glTF scene based on the array of meshes
  85705. * Returns the the total byte offset
  85706. * @param babylonScene Babylon scene to get the mesh data from
  85707. * @param binaryWriter Buffer to write binary data to
  85708. */
  85709. private createSceneAsync;
  85710. /**
  85711. * Creates a mapping of Node unique id to node index and handles animations
  85712. * @param babylonScene Babylon Scene
  85713. * @param nodes Babylon transform nodes
  85714. * @param binaryWriter Buffer to write binary data to
  85715. * @returns Node mapping of unique id to index
  85716. */
  85717. private createNodeMapAndAnimationsAsync;
  85718. /**
  85719. * Creates a glTF node from a Babylon mesh
  85720. * @param babylonMesh Source Babylon mesh
  85721. * @param binaryWriter Buffer for storing geometry data
  85722. * @param convertToRightHandedSystem Converts the values to right-handed
  85723. * @param nodeMap Node mapping of unique id to glTF node index
  85724. * @returns glTF node
  85725. */
  85726. private createNodeAsync;
  85727. /**
  85728. * Creates a glTF skin from a Babylon skeleton
  85729. * @param babylonScene Babylon Scene
  85730. * @param nodes Babylon transform nodes
  85731. * @param binaryWriter Buffer to write binary data to
  85732. * @returns Node mapping of unique id to index
  85733. */
  85734. private createSkinsAsync;
  85735. }
  85736. /**
  85737. * @hidden
  85738. *
  85739. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85740. */
  85741. export class _BinaryWriter {
  85742. /**
  85743. * Array buffer which stores all binary data
  85744. */
  85745. private _arrayBuffer;
  85746. /**
  85747. * View of the array buffer
  85748. */
  85749. private _dataView;
  85750. /**
  85751. * byte offset of data in array buffer
  85752. */
  85753. private _byteOffset;
  85754. /**
  85755. * Initialize binary writer with an initial byte length
  85756. * @param byteLength Initial byte length of the array buffer
  85757. */
  85758. constructor(byteLength: number);
  85759. /**
  85760. * Resize the array buffer to the specified byte length
  85761. * @param byteLength
  85762. */
  85763. private resizeBuffer;
  85764. /**
  85765. * Get an array buffer with the length of the byte offset
  85766. * @returns ArrayBuffer resized to the byte offset
  85767. */
  85768. getArrayBuffer(): ArrayBuffer;
  85769. /**
  85770. * Get the byte offset of the array buffer
  85771. * @returns byte offset
  85772. */
  85773. getByteOffset(): number;
  85774. /**
  85775. * Stores an UInt8 in the array buffer
  85776. * @param entry
  85777. * @param byteOffset If defined, specifies where to set the value as an offset.
  85778. */
  85779. setUInt8(entry: number, byteOffset?: number): void;
  85780. /**
  85781. * Stores an UInt16 in the array buffer
  85782. * @param entry
  85783. * @param byteOffset If defined, specifies where to set the value as an offset.
  85784. */
  85785. setUInt16(entry: number, byteOffset?: number): void;
  85786. /**
  85787. * Gets an UInt32 in the array buffer
  85788. * @param entry
  85789. * @param byteOffset If defined, specifies where to set the value as an offset.
  85790. */
  85791. getUInt32(byteOffset: number): number;
  85792. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85793. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85794. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85795. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85796. /**
  85797. * Stores a Float32 in the array buffer
  85798. * @param entry
  85799. */
  85800. setFloat32(entry: number, byteOffset?: number): void;
  85801. /**
  85802. * Stores an UInt32 in the array buffer
  85803. * @param entry
  85804. * @param byteOffset If defined, specifies where to set the value as an offset.
  85805. */
  85806. setUInt32(entry: number, byteOffset?: number): void;
  85807. }
  85808. }
  85809. declare module BABYLON.GLTF2.Exporter {
  85810. /**
  85811. * @hidden
  85812. * Interface to store animation data.
  85813. */
  85814. export interface _IAnimationData {
  85815. /**
  85816. * Keyframe data.
  85817. */
  85818. inputs: number[];
  85819. /**
  85820. * Value data.
  85821. */
  85822. outputs: number[][];
  85823. /**
  85824. * Animation interpolation data.
  85825. */
  85826. samplerInterpolation: AnimationSamplerInterpolation;
  85827. /**
  85828. * Minimum keyframe value.
  85829. */
  85830. inputsMin: number;
  85831. /**
  85832. * Maximum keyframe value.
  85833. */
  85834. inputsMax: number;
  85835. }
  85836. /**
  85837. * @hidden
  85838. */
  85839. export interface _IAnimationInfo {
  85840. /**
  85841. * The target channel for the animation
  85842. */
  85843. animationChannelTargetPath: AnimationChannelTargetPath;
  85844. /**
  85845. * The glTF accessor type for the data.
  85846. */
  85847. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85848. /**
  85849. * Specifies if quaternions should be used.
  85850. */
  85851. useQuaternion: boolean;
  85852. }
  85853. /**
  85854. * @hidden
  85855. * Utility class for generating glTF animation data from BabylonJS.
  85856. */
  85857. export class _GLTFAnimation {
  85858. /**
  85859. * @ignore
  85860. *
  85861. * Creates glTF channel animation from BabylonJS animation.
  85862. * @param babylonTransformNode - BabylonJS mesh.
  85863. * @param animation - animation.
  85864. * @param animationChannelTargetPath - The target animation channel.
  85865. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85866. * @param useQuaternion - Specifies if quaternions are used.
  85867. * @returns nullable IAnimationData
  85868. */
  85869. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85870. private static _DeduceAnimationInfo;
  85871. /**
  85872. * @ignore
  85873. * Create node animations from the transform node animations
  85874. * @param babylonNode
  85875. * @param runtimeGLTFAnimation
  85876. * @param idleGLTFAnimations
  85877. * @param nodeMap
  85878. * @param nodes
  85879. * @param binaryWriter
  85880. * @param bufferViews
  85881. * @param accessors
  85882. * @param convertToRightHandedSystem
  85883. * @param animationSampleRate
  85884. */
  85885. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85886. [key: number]: number;
  85887. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85888. /**
  85889. * @ignore
  85890. * Create individual morph animations from the mesh's morph target animation tracks
  85891. * @param babylonNode
  85892. * @param runtimeGLTFAnimation
  85893. * @param idleGLTFAnimations
  85894. * @param nodeMap
  85895. * @param nodes
  85896. * @param binaryWriter
  85897. * @param bufferViews
  85898. * @param accessors
  85899. * @param convertToRightHandedSystem
  85900. * @param animationSampleRate
  85901. */
  85902. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85903. [key: number]: number;
  85904. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85905. /**
  85906. * @ignore
  85907. * Create node and morph animations from the animation groups
  85908. * @param babylonScene
  85909. * @param glTFAnimations
  85910. * @param nodeMap
  85911. * @param nodes
  85912. * @param binaryWriter
  85913. * @param bufferViews
  85914. * @param accessors
  85915. * @param convertToRightHandedSystemMap
  85916. * @param animationSampleRate
  85917. */
  85918. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85919. [key: number]: number;
  85920. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85921. [nodeId: number]: boolean;
  85922. }, animationSampleRate: number): void;
  85923. private static AddAnimation;
  85924. /**
  85925. * Create a baked animation
  85926. * @param babylonTransformNode BabylonJS mesh
  85927. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85928. * @param animationChannelTargetPath animation target channel
  85929. * @param minFrame minimum animation frame
  85930. * @param maxFrame maximum animation frame
  85931. * @param fps frames per second of the animation
  85932. * @param inputs input key frames of the animation
  85933. * @param outputs output key frame data of the animation
  85934. * @param convertToRightHandedSystem converts the values to right-handed
  85935. * @param useQuaternion specifies if quaternions should be used
  85936. */
  85937. private static _CreateBakedAnimation;
  85938. private static _ConvertFactorToVector3OrQuaternion;
  85939. private static _SetInterpolatedValue;
  85940. /**
  85941. * Creates linear animation from the animation key frames
  85942. * @param babylonTransformNode BabylonJS mesh
  85943. * @param animation BabylonJS animation
  85944. * @param animationChannelTargetPath The target animation channel
  85945. * @param frameDelta The difference between the last and first frame of the animation
  85946. * @param inputs Array to store the key frame times
  85947. * @param outputs Array to store the key frame data
  85948. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85949. * @param useQuaternion Specifies if quaternions are used in the animation
  85950. */
  85951. private static _CreateLinearOrStepAnimation;
  85952. /**
  85953. * Creates cubic spline animation from the animation key frames
  85954. * @param babylonTransformNode BabylonJS mesh
  85955. * @param animation BabylonJS animation
  85956. * @param animationChannelTargetPath The target animation channel
  85957. * @param frameDelta The difference between the last and first frame of the animation
  85958. * @param inputs Array to store the key frame times
  85959. * @param outputs Array to store the key frame data
  85960. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85961. * @param useQuaternion Specifies if quaternions are used in the animation
  85962. */
  85963. private static _CreateCubicSplineAnimation;
  85964. private static _GetBasePositionRotationOrScale;
  85965. /**
  85966. * Adds a key frame value
  85967. * @param keyFrame
  85968. * @param animation
  85969. * @param outputs
  85970. * @param animationChannelTargetPath
  85971. * @param basePositionRotationOrScale
  85972. * @param convertToRightHandedSystem
  85973. * @param useQuaternion
  85974. */
  85975. private static _AddKeyframeValue;
  85976. /**
  85977. * Determine the interpolation based on the key frames
  85978. * @param keyFrames
  85979. * @param animationChannelTargetPath
  85980. * @param useQuaternion
  85981. */
  85982. private static _DeduceInterpolation;
  85983. /**
  85984. * Adds an input tangent or output tangent to the output data
  85985. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85986. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85987. * @param outputs The animation data by keyframe
  85988. * @param animationChannelTargetPath The target animation channel
  85989. * @param interpolation The interpolation type
  85990. * @param keyFrame The key frame with the animation data
  85991. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85992. * @param useQuaternion Specifies if quaternions are used
  85993. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85994. */
  85995. private static AddSplineTangent;
  85996. /**
  85997. * Get the minimum and maximum key frames' frame values
  85998. * @param keyFrames animation key frames
  85999. * @returns the minimum and maximum key frame value
  86000. */
  86001. private static calculateMinMaxKeyFrames;
  86002. }
  86003. }
  86004. declare module BABYLON.GLTF2.Exporter {
  86005. /** @hidden */
  86006. export var textureTransformPixelShader: {
  86007. name: string;
  86008. shader: string;
  86009. };
  86010. }
  86011. declare module BABYLON.GLTF2.Exporter.Extensions {
  86012. /**
  86013. * @hidden
  86014. */
  86015. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  86016. private _recordedTextures;
  86017. /** Name of this extension */
  86018. readonly name: string;
  86019. /** Defines whether this extension is enabled */
  86020. enabled: boolean;
  86021. /** Defines whether this extension is required */
  86022. required: boolean;
  86023. /** Reference to the glTF exporter */
  86024. private _wasUsed;
  86025. constructor(exporter: _Exporter);
  86026. dispose(): void;
  86027. /** @hidden */
  86028. get wasUsed(): boolean;
  86029. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  86030. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  86031. /**
  86032. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  86033. * @param babylonTexture
  86034. * @param offset
  86035. * @param rotation
  86036. * @param scale
  86037. * @param scene
  86038. */
  86039. private _textureTransformTextureAsync;
  86040. }
  86041. }
  86042. declare module BABYLON.GLTF2.Exporter.Extensions {
  86043. /**
  86044. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  86045. */
  86046. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  86047. /** The name of this extension. */
  86048. readonly name: string;
  86049. /** Defines whether this extension is enabled. */
  86050. enabled: boolean;
  86051. /** Defines whether this extension is required */
  86052. required: boolean;
  86053. /** Reference to the glTF exporter */
  86054. private _exporter;
  86055. private _lights;
  86056. /** @hidden */
  86057. constructor(exporter: _Exporter);
  86058. /** @hidden */
  86059. dispose(): void;
  86060. /** @hidden */
  86061. get wasUsed(): boolean;
  86062. /** @hidden */
  86063. onExporting(): void;
  86064. /**
  86065. * Define this method to modify the default behavior when exporting a node
  86066. * @param context The context when exporting the node
  86067. * @param node glTF node
  86068. * @param babylonNode BabylonJS node
  86069. * @param nodeMap Node mapping of unique id to glTF node index
  86070. * @returns nullable INode promise
  86071. */
  86072. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  86073. [key: number]: number;
  86074. }): Promise<Nullable<INode>>;
  86075. }
  86076. }
  86077. declare module BABYLON.GLTF2.Exporter.Extensions {
  86078. /**
  86079. * @hidden
  86080. */
  86081. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  86082. /** Name of this extension */
  86083. readonly name: string;
  86084. /** Defines whether this extension is enabled */
  86085. enabled: boolean;
  86086. /** Defines whether this extension is required */
  86087. required: boolean;
  86088. /** Reference to the glTF exporter */
  86089. private _textureInfos;
  86090. private _exportedTextures;
  86091. private _wasUsed;
  86092. constructor(exporter: _Exporter);
  86093. dispose(): void;
  86094. /** @hidden */
  86095. get wasUsed(): boolean;
  86096. private _getTextureIndex;
  86097. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  86098. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  86099. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  86100. }
  86101. }
  86102. declare module BABYLON.GLTF2.Exporter.Extensions {
  86103. /**
  86104. * @hidden
  86105. */
  86106. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  86107. /** Name of this extension */
  86108. readonly name: string;
  86109. /** Defines whether this extension is enabled */
  86110. enabled: boolean;
  86111. /** Defines whether this extension is required */
  86112. required: boolean;
  86113. private _wasUsed;
  86114. constructor(exporter: _Exporter);
  86115. /** @hidden */
  86116. get wasUsed(): boolean;
  86117. dispose(): void;
  86118. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  86119. }
  86120. }
  86121. declare module BABYLON {
  86122. /**
  86123. * Class for generating STL data from a Babylon scene.
  86124. */
  86125. export class STLExport {
  86126. /**
  86127. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  86128. * @param meshes list defines the mesh to serialize
  86129. * @param download triggers the automatic download of the file.
  86130. * @param fileName changes the downloads fileName.
  86131. * @param binary changes the STL to a binary type.
  86132. * @param isLittleEndian toggle for binary type exporter.
  86133. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  86134. * @returns the STL as UTF8 string
  86135. */
  86136. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  86137. }
  86138. }
  86139. declare module "babylonjs-gltf2interface" {
  86140. export = BABYLON.GLTF2;
  86141. }
  86142. /**
  86143. * Module for glTF 2.0 Interface
  86144. */
  86145. declare module BABYLON.GLTF2 {
  86146. /**
  86147. * The datatype of the components in the attribute
  86148. */
  86149. const enum AccessorComponentType {
  86150. /**
  86151. * Byte
  86152. */
  86153. BYTE = 5120,
  86154. /**
  86155. * Unsigned Byte
  86156. */
  86157. UNSIGNED_BYTE = 5121,
  86158. /**
  86159. * Short
  86160. */
  86161. SHORT = 5122,
  86162. /**
  86163. * Unsigned Short
  86164. */
  86165. UNSIGNED_SHORT = 5123,
  86166. /**
  86167. * Unsigned Int
  86168. */
  86169. UNSIGNED_INT = 5125,
  86170. /**
  86171. * Float
  86172. */
  86173. FLOAT = 5126,
  86174. }
  86175. /**
  86176. * Specifies if the attirbute is a scalar, vector, or matrix
  86177. */
  86178. const enum AccessorType {
  86179. /**
  86180. * Scalar
  86181. */
  86182. SCALAR = "SCALAR",
  86183. /**
  86184. * Vector2
  86185. */
  86186. VEC2 = "VEC2",
  86187. /**
  86188. * Vector3
  86189. */
  86190. VEC3 = "VEC3",
  86191. /**
  86192. * Vector4
  86193. */
  86194. VEC4 = "VEC4",
  86195. /**
  86196. * Matrix2x2
  86197. */
  86198. MAT2 = "MAT2",
  86199. /**
  86200. * Matrix3x3
  86201. */
  86202. MAT3 = "MAT3",
  86203. /**
  86204. * Matrix4x4
  86205. */
  86206. MAT4 = "MAT4",
  86207. }
  86208. /**
  86209. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86210. */
  86211. const enum AnimationChannelTargetPath {
  86212. /**
  86213. * Translation
  86214. */
  86215. TRANSLATION = "translation",
  86216. /**
  86217. * Rotation
  86218. */
  86219. ROTATION = "rotation",
  86220. /**
  86221. * Scale
  86222. */
  86223. SCALE = "scale",
  86224. /**
  86225. * Weights
  86226. */
  86227. WEIGHTS = "weights",
  86228. }
  86229. /**
  86230. * Interpolation algorithm
  86231. */
  86232. const enum AnimationSamplerInterpolation {
  86233. /**
  86234. * The animated values are linearly interpolated between keyframes
  86235. */
  86236. LINEAR = "LINEAR",
  86237. /**
  86238. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  86239. */
  86240. STEP = "STEP",
  86241. /**
  86242. * The animation's interpolation is computed using a cubic spline with specified tangents
  86243. */
  86244. CUBICSPLINE = "CUBICSPLINE",
  86245. }
  86246. /**
  86247. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86248. */
  86249. const enum CameraType {
  86250. /**
  86251. * A perspective camera containing properties to create a perspective projection matrix
  86252. */
  86253. PERSPECTIVE = "perspective",
  86254. /**
  86255. * An orthographic camera containing properties to create an orthographic projection matrix
  86256. */
  86257. ORTHOGRAPHIC = "orthographic",
  86258. }
  86259. /**
  86260. * The mime-type of the image
  86261. */
  86262. const enum ImageMimeType {
  86263. /**
  86264. * JPEG Mime-type
  86265. */
  86266. JPEG = "image/jpeg",
  86267. /**
  86268. * PNG Mime-type
  86269. */
  86270. PNG = "image/png",
  86271. }
  86272. /**
  86273. * The alpha rendering mode of the material
  86274. */
  86275. const enum MaterialAlphaMode {
  86276. /**
  86277. * The alpha value is ignored and the rendered output is fully opaque
  86278. */
  86279. OPAQUE = "OPAQUE",
  86280. /**
  86281. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  86282. */
  86283. MASK = "MASK",
  86284. /**
  86285. * 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)
  86286. */
  86287. BLEND = "BLEND",
  86288. }
  86289. /**
  86290. * The type of the primitives to render
  86291. */
  86292. const enum MeshPrimitiveMode {
  86293. /**
  86294. * Points
  86295. */
  86296. POINTS = 0,
  86297. /**
  86298. * Lines
  86299. */
  86300. LINES = 1,
  86301. /**
  86302. * Line Loop
  86303. */
  86304. LINE_LOOP = 2,
  86305. /**
  86306. * Line Strip
  86307. */
  86308. LINE_STRIP = 3,
  86309. /**
  86310. * Triangles
  86311. */
  86312. TRIANGLES = 4,
  86313. /**
  86314. * Triangle Strip
  86315. */
  86316. TRIANGLE_STRIP = 5,
  86317. /**
  86318. * Triangle Fan
  86319. */
  86320. TRIANGLE_FAN = 6,
  86321. }
  86322. /**
  86323. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86324. */
  86325. const enum TextureMagFilter {
  86326. /**
  86327. * Nearest
  86328. */
  86329. NEAREST = 9728,
  86330. /**
  86331. * Linear
  86332. */
  86333. LINEAR = 9729,
  86334. }
  86335. /**
  86336. * Minification filter. All valid values correspond to WebGL enums
  86337. */
  86338. const enum TextureMinFilter {
  86339. /**
  86340. * Nearest
  86341. */
  86342. NEAREST = 9728,
  86343. /**
  86344. * Linear
  86345. */
  86346. LINEAR = 9729,
  86347. /**
  86348. * Nearest Mip-Map Nearest
  86349. */
  86350. NEAREST_MIPMAP_NEAREST = 9984,
  86351. /**
  86352. * Linear Mipmap Nearest
  86353. */
  86354. LINEAR_MIPMAP_NEAREST = 9985,
  86355. /**
  86356. * Nearest Mipmap Linear
  86357. */
  86358. NEAREST_MIPMAP_LINEAR = 9986,
  86359. /**
  86360. * Linear Mipmap Linear
  86361. */
  86362. LINEAR_MIPMAP_LINEAR = 9987,
  86363. }
  86364. /**
  86365. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86366. */
  86367. const enum TextureWrapMode {
  86368. /**
  86369. * Clamp to Edge
  86370. */
  86371. CLAMP_TO_EDGE = 33071,
  86372. /**
  86373. * Mirrored Repeat
  86374. */
  86375. MIRRORED_REPEAT = 33648,
  86376. /**
  86377. * Repeat
  86378. */
  86379. REPEAT = 10497,
  86380. }
  86381. /**
  86382. * glTF Property
  86383. */
  86384. interface IProperty {
  86385. /**
  86386. * Dictionary object with extension-specific objects
  86387. */
  86388. extensions?: {
  86389. [key: string]: any;
  86390. };
  86391. /**
  86392. * Application-Specific data
  86393. */
  86394. extras?: any;
  86395. }
  86396. /**
  86397. * glTF Child of Root Property
  86398. */
  86399. interface IChildRootProperty extends IProperty {
  86400. /**
  86401. * The user-defined name of this object
  86402. */
  86403. name?: string;
  86404. }
  86405. /**
  86406. * Indices of those attributes that deviate from their initialization value
  86407. */
  86408. interface IAccessorSparseIndices extends IProperty {
  86409. /**
  86410. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86411. */
  86412. bufferView: number;
  86413. /**
  86414. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86415. */
  86416. byteOffset?: number;
  86417. /**
  86418. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  86419. */
  86420. componentType: AccessorComponentType;
  86421. }
  86422. /**
  86423. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  86424. */
  86425. interface IAccessorSparseValues extends IProperty {
  86426. /**
  86427. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86428. */
  86429. bufferView: number;
  86430. /**
  86431. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86432. */
  86433. byteOffset?: number;
  86434. }
  86435. /**
  86436. * Sparse storage of attributes that deviate from their initialization value
  86437. */
  86438. interface IAccessorSparse extends IProperty {
  86439. /**
  86440. * The number of attributes encoded in this sparse accessor
  86441. */
  86442. count: number;
  86443. /**
  86444. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  86445. */
  86446. indices: IAccessorSparseIndices;
  86447. /**
  86448. * 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
  86449. */
  86450. values: IAccessorSparseValues;
  86451. }
  86452. /**
  86453. * 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
  86454. */
  86455. interface IAccessor extends IChildRootProperty {
  86456. /**
  86457. * The index of the bufferview
  86458. */
  86459. bufferView?: number;
  86460. /**
  86461. * The offset relative to the start of the bufferView in bytes
  86462. */
  86463. byteOffset?: number;
  86464. /**
  86465. * The datatype of components in the attribute
  86466. */
  86467. componentType: AccessorComponentType;
  86468. /**
  86469. * Specifies whether integer data values should be normalized
  86470. */
  86471. normalized?: boolean;
  86472. /**
  86473. * The number of attributes referenced by this accessor
  86474. */
  86475. count: number;
  86476. /**
  86477. * Specifies if the attribute is a scalar, vector, or matrix
  86478. */
  86479. type: AccessorType;
  86480. /**
  86481. * Maximum value of each component in this attribute
  86482. */
  86483. max?: number[];
  86484. /**
  86485. * Minimum value of each component in this attribute
  86486. */
  86487. min?: number[];
  86488. /**
  86489. * Sparse storage of attributes that deviate from their initialization value
  86490. */
  86491. sparse?: IAccessorSparse;
  86492. }
  86493. /**
  86494. * Targets an animation's sampler at a node's property
  86495. */
  86496. interface IAnimationChannel extends IProperty {
  86497. /**
  86498. * The index of a sampler in this animation used to compute the value for the target
  86499. */
  86500. sampler: number;
  86501. /**
  86502. * The index of the node and TRS property to target
  86503. */
  86504. target: IAnimationChannelTarget;
  86505. }
  86506. /**
  86507. * The index of the node and TRS property that an animation channel targets
  86508. */
  86509. interface IAnimationChannelTarget extends IProperty {
  86510. /**
  86511. * The index of the node to target
  86512. */
  86513. node: number;
  86514. /**
  86515. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86516. */
  86517. path: AnimationChannelTargetPath;
  86518. }
  86519. /**
  86520. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86521. */
  86522. interface IAnimationSampler extends IProperty {
  86523. /**
  86524. * The index of an accessor containing keyframe input values, e.g., time
  86525. */
  86526. input: number;
  86527. /**
  86528. * Interpolation algorithm
  86529. */
  86530. interpolation?: AnimationSamplerInterpolation;
  86531. /**
  86532. * The index of an accessor, containing keyframe output values
  86533. */
  86534. output: number;
  86535. }
  86536. /**
  86537. * A keyframe animation
  86538. */
  86539. interface IAnimation extends IChildRootProperty {
  86540. /**
  86541. * An array of channels, each of which targets an animation's sampler at a node's property
  86542. */
  86543. channels: IAnimationChannel[];
  86544. /**
  86545. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86546. */
  86547. samplers: IAnimationSampler[];
  86548. }
  86549. /**
  86550. * Metadata about the glTF asset
  86551. */
  86552. interface IAsset extends IChildRootProperty {
  86553. /**
  86554. * A copyright message suitable for display to credit the content creator
  86555. */
  86556. copyright?: string;
  86557. /**
  86558. * Tool that generated this glTF model. Useful for debugging
  86559. */
  86560. generator?: string;
  86561. /**
  86562. * The glTF version that this asset targets
  86563. */
  86564. version: string;
  86565. /**
  86566. * The minimum glTF version that this asset targets
  86567. */
  86568. minVersion?: string;
  86569. }
  86570. /**
  86571. * A buffer points to binary geometry, animation, or skins
  86572. */
  86573. interface IBuffer extends IChildRootProperty {
  86574. /**
  86575. * 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
  86576. */
  86577. uri?: string;
  86578. /**
  86579. * The length of the buffer in bytes
  86580. */
  86581. byteLength: number;
  86582. }
  86583. /**
  86584. * A view into a buffer generally representing a subset of the buffer
  86585. */
  86586. interface IBufferView extends IChildRootProperty {
  86587. /**
  86588. * The index of the buffer
  86589. */
  86590. buffer: number;
  86591. /**
  86592. * The offset into the buffer in bytes
  86593. */
  86594. byteOffset?: number;
  86595. /**
  86596. * The lenth of the bufferView in bytes
  86597. */
  86598. byteLength: number;
  86599. /**
  86600. * The stride, in bytes
  86601. */
  86602. byteStride?: number;
  86603. }
  86604. /**
  86605. * An orthographic camera containing properties to create an orthographic projection matrix
  86606. */
  86607. interface ICameraOrthographic extends IProperty {
  86608. /**
  86609. * The floating-point horizontal magnification of the view. Must not be zero
  86610. */
  86611. xmag: number;
  86612. /**
  86613. * The floating-point vertical magnification of the view. Must not be zero
  86614. */
  86615. ymag: number;
  86616. /**
  86617. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86618. */
  86619. zfar: number;
  86620. /**
  86621. * The floating-point distance to the near clipping plane
  86622. */
  86623. znear: number;
  86624. }
  86625. /**
  86626. * A perspective camera containing properties to create a perspective projection matrix
  86627. */
  86628. interface ICameraPerspective extends IProperty {
  86629. /**
  86630. * The floating-point aspect ratio of the field of view
  86631. */
  86632. aspectRatio?: number;
  86633. /**
  86634. * The floating-point vertical field of view in radians
  86635. */
  86636. yfov: number;
  86637. /**
  86638. * The floating-point distance to the far clipping plane
  86639. */
  86640. zfar?: number;
  86641. /**
  86642. * The floating-point distance to the near clipping plane
  86643. */
  86644. znear: number;
  86645. }
  86646. /**
  86647. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86648. */
  86649. interface ICamera extends IChildRootProperty {
  86650. /**
  86651. * An orthographic camera containing properties to create an orthographic projection matrix
  86652. */
  86653. orthographic?: ICameraOrthographic;
  86654. /**
  86655. * A perspective camera containing properties to create a perspective projection matrix
  86656. */
  86657. perspective?: ICameraPerspective;
  86658. /**
  86659. * Specifies if the camera uses a perspective or orthographic projection
  86660. */
  86661. type: CameraType;
  86662. }
  86663. /**
  86664. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86665. */
  86666. interface IImage extends IChildRootProperty {
  86667. /**
  86668. * 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
  86669. */
  86670. uri?: string;
  86671. /**
  86672. * The image's MIME type
  86673. */
  86674. mimeType?: ImageMimeType;
  86675. /**
  86676. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86677. */
  86678. bufferView?: number;
  86679. }
  86680. /**
  86681. * Material Normal Texture Info
  86682. */
  86683. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86684. /**
  86685. * The scalar multiplier applied to each normal vector of the normal texture
  86686. */
  86687. scale?: number;
  86688. }
  86689. /**
  86690. * Material Occlusion Texture Info
  86691. */
  86692. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86693. /**
  86694. * A scalar multiplier controlling the amount of occlusion applied
  86695. */
  86696. strength?: number;
  86697. }
  86698. /**
  86699. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86700. */
  86701. interface IMaterialPbrMetallicRoughness {
  86702. /**
  86703. * The material's base color factor
  86704. */
  86705. baseColorFactor?: number[];
  86706. /**
  86707. * The base color texture
  86708. */
  86709. baseColorTexture?: ITextureInfo;
  86710. /**
  86711. * The metalness of the material
  86712. */
  86713. metallicFactor?: number;
  86714. /**
  86715. * The roughness of the material
  86716. */
  86717. roughnessFactor?: number;
  86718. /**
  86719. * The metallic-roughness texture
  86720. */
  86721. metallicRoughnessTexture?: ITextureInfo;
  86722. }
  86723. /**
  86724. * The material appearance of a primitive
  86725. */
  86726. interface IMaterial extends IChildRootProperty {
  86727. /**
  86728. * 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
  86729. */
  86730. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86731. /**
  86732. * The normal map texture
  86733. */
  86734. normalTexture?: IMaterialNormalTextureInfo;
  86735. /**
  86736. * The occlusion map texture
  86737. */
  86738. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86739. /**
  86740. * The emissive map texture
  86741. */
  86742. emissiveTexture?: ITextureInfo;
  86743. /**
  86744. * 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
  86745. */
  86746. emissiveFactor?: number[];
  86747. /**
  86748. * The alpha rendering mode of the material
  86749. */
  86750. alphaMode?: MaterialAlphaMode;
  86751. /**
  86752. * The alpha cutoff value of the material
  86753. */
  86754. alphaCutoff?: number;
  86755. /**
  86756. * Specifies whether the material is double sided
  86757. */
  86758. doubleSided?: boolean;
  86759. }
  86760. /**
  86761. * Geometry to be rendered with the given material
  86762. */
  86763. interface IMeshPrimitive extends IProperty {
  86764. /**
  86765. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86766. */
  86767. attributes: {
  86768. [name: string]: number;
  86769. };
  86770. /**
  86771. * The index of the accessor that contains the indices
  86772. */
  86773. indices?: number;
  86774. /**
  86775. * The index of the material to apply to this primitive when rendering
  86776. */
  86777. material?: number;
  86778. /**
  86779. * The type of primitives to render. All valid values correspond to WebGL enums
  86780. */
  86781. mode?: MeshPrimitiveMode;
  86782. /**
  86783. * 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
  86784. */
  86785. targets?: {
  86786. [name: string]: number;
  86787. }[];
  86788. }
  86789. /**
  86790. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86791. */
  86792. interface IMesh extends IChildRootProperty {
  86793. /**
  86794. * An array of primitives, each defining geometry to be rendered with a material
  86795. */
  86796. primitives: IMeshPrimitive[];
  86797. /**
  86798. * Array of weights to be applied to the Morph Targets
  86799. */
  86800. weights?: number[];
  86801. }
  86802. /**
  86803. * A node in the node hierarchy
  86804. */
  86805. interface INode extends IChildRootProperty {
  86806. /**
  86807. * The index of the camera referenced by this node
  86808. */
  86809. camera?: number;
  86810. /**
  86811. * The indices of this node's children
  86812. */
  86813. children?: number[];
  86814. /**
  86815. * The index of the skin referenced by this node
  86816. */
  86817. skin?: number;
  86818. /**
  86819. * A floating-point 4x4 transformation matrix stored in column-major order
  86820. */
  86821. matrix?: number[];
  86822. /**
  86823. * The index of the mesh in this node
  86824. */
  86825. mesh?: number;
  86826. /**
  86827. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86828. */
  86829. rotation?: number[];
  86830. /**
  86831. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86832. */
  86833. scale?: number[];
  86834. /**
  86835. * The node's translation along the x, y, and z axes
  86836. */
  86837. translation?: number[];
  86838. /**
  86839. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86840. */
  86841. weights?: number[];
  86842. }
  86843. /**
  86844. * Texture sampler properties for filtering and wrapping modes
  86845. */
  86846. interface ISampler extends IChildRootProperty {
  86847. /**
  86848. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86849. */
  86850. magFilter?: TextureMagFilter;
  86851. /**
  86852. * Minification filter. All valid values correspond to WebGL enums
  86853. */
  86854. minFilter?: TextureMinFilter;
  86855. /**
  86856. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86857. */
  86858. wrapS?: TextureWrapMode;
  86859. /**
  86860. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86861. */
  86862. wrapT?: TextureWrapMode;
  86863. }
  86864. /**
  86865. * The root nodes of a scene
  86866. */
  86867. interface IScene extends IChildRootProperty {
  86868. /**
  86869. * The indices of each root node
  86870. */
  86871. nodes: number[];
  86872. }
  86873. /**
  86874. * Joints and matrices defining a skin
  86875. */
  86876. interface ISkin extends IChildRootProperty {
  86877. /**
  86878. * 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
  86879. */
  86880. inverseBindMatrices?: number;
  86881. /**
  86882. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86883. */
  86884. skeleton?: number;
  86885. /**
  86886. * 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)
  86887. */
  86888. joints: number[];
  86889. }
  86890. /**
  86891. * A texture and its sampler
  86892. */
  86893. interface ITexture extends IChildRootProperty {
  86894. /**
  86895. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86896. */
  86897. sampler?: number;
  86898. /**
  86899. * The index of the image used by this texture
  86900. */
  86901. source: number;
  86902. }
  86903. /**
  86904. * Reference to a texture
  86905. */
  86906. interface ITextureInfo extends IProperty {
  86907. /**
  86908. * The index of the texture
  86909. */
  86910. index: number;
  86911. /**
  86912. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86913. */
  86914. texCoord?: number;
  86915. }
  86916. /**
  86917. * The root object for a glTF asset
  86918. */
  86919. interface IGLTF extends IProperty {
  86920. /**
  86921. * An array of accessors. An accessor is a typed view into a bufferView
  86922. */
  86923. accessors?: IAccessor[];
  86924. /**
  86925. * An array of keyframe animations
  86926. */
  86927. animations?: IAnimation[];
  86928. /**
  86929. * Metadata about the glTF asset
  86930. */
  86931. asset: IAsset;
  86932. /**
  86933. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86934. */
  86935. buffers?: IBuffer[];
  86936. /**
  86937. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86938. */
  86939. bufferViews?: IBufferView[];
  86940. /**
  86941. * An array of cameras
  86942. */
  86943. cameras?: ICamera[];
  86944. /**
  86945. * Names of glTF extensions used somewhere in this asset
  86946. */
  86947. extensionsUsed?: string[];
  86948. /**
  86949. * Names of glTF extensions required to properly load this asset
  86950. */
  86951. extensionsRequired?: string[];
  86952. /**
  86953. * An array of images. An image defines data used to create a texture
  86954. */
  86955. images?: IImage[];
  86956. /**
  86957. * An array of materials. A material defines the appearance of a primitive
  86958. */
  86959. materials?: IMaterial[];
  86960. /**
  86961. * An array of meshes. A mesh is a set of primitives to be rendered
  86962. */
  86963. meshes?: IMesh[];
  86964. /**
  86965. * An array of nodes
  86966. */
  86967. nodes?: INode[];
  86968. /**
  86969. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86970. */
  86971. samplers?: ISampler[];
  86972. /**
  86973. * The index of the default scene
  86974. */
  86975. scene?: number;
  86976. /**
  86977. * An array of scenes
  86978. */
  86979. scenes?: IScene[];
  86980. /**
  86981. * An array of skins. A skin is defined by joints and matrices
  86982. */
  86983. skins?: ISkin[];
  86984. /**
  86985. * An array of textures
  86986. */
  86987. textures?: ITexture[];
  86988. }
  86989. /**
  86990. * The glTF validation results
  86991. * @ignore
  86992. */
  86993. interface IGLTFValidationResults {
  86994. info: {
  86995. generator: string;
  86996. hasAnimations: boolean;
  86997. hasDefaultScene: boolean;
  86998. hasMaterials: boolean;
  86999. hasMorphTargets: boolean;
  87000. hasSkins: boolean;
  87001. hasTextures: boolean;
  87002. maxAttributesUsed: number;
  87003. primitivesCount: number
  87004. };
  87005. issues: {
  87006. messages: Array<string>;
  87007. numErrors: number;
  87008. numHints: number;
  87009. numInfos: number;
  87010. numWarnings: number;
  87011. truncated: boolean
  87012. };
  87013. mimeType: string;
  87014. uri: string;
  87015. validatedAt: string;
  87016. validatorVersion: string;
  87017. }
  87018. /**
  87019. * The glTF validation options
  87020. */
  87021. interface IGLTFValidationOptions {
  87022. /** Uri to use */
  87023. uri?: string;
  87024. /** Function used to load external resources */
  87025. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  87026. /** Boolean indicating that we need to validate accessor data */
  87027. validateAccessorData?: boolean;
  87028. /** max number of issues allowed */
  87029. maxIssues?: number;
  87030. /** Ignored issues */
  87031. ignoredIssues?: Array<string>;
  87032. /** Value to override severy settings */
  87033. severityOverrides?: Object;
  87034. }
  87035. /**
  87036. * The glTF validator object
  87037. * @ignore
  87038. */
  87039. interface IGLTFValidator {
  87040. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  87041. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  87042. }
  87043. /**
  87044. * Interfaces from the EXT_lights_image_based extension
  87045. */
  87046. /** @hidden */
  87047. interface IEXTLightsImageBased_LightReferenceImageBased {
  87048. light: number;
  87049. }
  87050. /** @hidden */
  87051. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  87052. intensity: number;
  87053. rotation: number[];
  87054. specularImageSize: number;
  87055. specularImages: number[][];
  87056. irradianceCoefficients: number[][];
  87057. }
  87058. /** @hidden */
  87059. interface IEXTLightsImageBased {
  87060. lights: IEXTLightsImageBased_LightImageBased[];
  87061. }
  87062. /**
  87063. * Interfaces from the EXT_mesh_gpu_instancing extension
  87064. * !!! Experimental Extension Subject to Changes !!!
  87065. */
  87066. /** @hidden */
  87067. interface IEXTMeshGpuInstancing {
  87068. mesh?: number;
  87069. attributes: { [name: string]: number };
  87070. }
  87071. /**
  87072. * Interfaces from the KHR_draco_mesh_compression extension
  87073. */
  87074. /** @hidden */
  87075. interface IKHRDracoMeshCompression {
  87076. bufferView: number;
  87077. attributes: { [name: string]: number };
  87078. }
  87079. /**
  87080. * Interfaces from the KHR_lights_punctual extension
  87081. */
  87082. /** @hidden */
  87083. const enum IKHRLightsPunctual_LightType {
  87084. DIRECTIONAL = "directional",
  87085. POINT = "point",
  87086. SPOT = "spot"
  87087. }
  87088. /** @hidden */
  87089. interface IKHRLightsPunctual_LightReference {
  87090. light: number;
  87091. }
  87092. /** @hidden */
  87093. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  87094. type: IKHRLightsPunctual_LightType;
  87095. color?: number[];
  87096. intensity?: number;
  87097. range?: number;
  87098. spot?: {
  87099. innerConeAngle?: number;
  87100. outerConeAngle?: number;
  87101. };
  87102. }
  87103. /** @hidden */
  87104. interface IKHRLightsPunctual {
  87105. lights: IKHRLightsPunctual_Light[];
  87106. }
  87107. /**
  87108. * Interfaces from the KHR_materials_clearcoat extension
  87109. * !!! Experimental Extension Subject to Changes !!!
  87110. */
  87111. /** @hidden */
  87112. interface IKHRMaterialsClearcoat {
  87113. clearcoatFactor: number;
  87114. clearcoatTexture: ITextureInfo;
  87115. clearcoatRoughnessFactor: number;
  87116. clearcoatRoughnessTexture: ITextureInfo;
  87117. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  87118. }
  87119. /**
  87120. * Interfaces from the KHR_materials_ior extension
  87121. * !!! Experimental Extension Subject to Changes !!!
  87122. */
  87123. /** @hidden */
  87124. interface IKHRMaterialsIor {
  87125. ior: number;
  87126. }
  87127. /**
  87128. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  87129. */
  87130. /** @hidden */
  87131. interface IKHRMaterialsPbrSpecularGlossiness {
  87132. diffuseFactor: number[];
  87133. diffuseTexture: ITextureInfo;
  87134. specularFactor: number[];
  87135. glossinessFactor: number;
  87136. specularGlossinessTexture: ITextureInfo;
  87137. }
  87138. /**
  87139. * Interfaces from the KHR_materials_sheen extension
  87140. * !!! Experimental Extension Subject to Changes !!!
  87141. */
  87142. /** @hidden */
  87143. interface IKHRMaterialsSheen {
  87144. sheenColorFactor?: number[];
  87145. sheenColorTexture?: ITextureInfo;
  87146. sheenRoughnessFactor?: number;
  87147. sheenRoughnessTexture?: ITextureInfo;
  87148. }
  87149. /**
  87150. * Interfaces from the KHR_materials_specular extension
  87151. * !!! Experimental Extension Subject to Changes !!!
  87152. */
  87153. /** @hidden */
  87154. interface IKHRMaterialsSpecular {
  87155. specularFactor: number;
  87156. specularColorFactor: number[];
  87157. specularTexture: ITextureInfo;
  87158. }
  87159. /**
  87160. * Interfaces from the KHR_materials_transmission extension
  87161. * !!! Experimental Extension Subject to Changes !!!
  87162. */
  87163. /** @hidden */
  87164. interface IKHRMaterialsTransmission {
  87165. transmissionFactor?: number;
  87166. transmissionTexture?: ITextureInfo;
  87167. }
  87168. /**
  87169. * Interfaces from the KHR_materials_translucency extension
  87170. * !!! Experimental Extension Subject to Changes !!!
  87171. */
  87172. /** @hidden */
  87173. interface IKHRMaterialsTranslucency {
  87174. translucencyFactor?: number;
  87175. translucencyTexture?: ITextureInfo;
  87176. }
  87177. /**
  87178. * Interfaces from the KHR_materials_variants extension
  87179. * !!! Experimental Extension Subject to Changes !!!
  87180. */
  87181. /** @hidden */
  87182. interface IKHRMaterialVariants_Mapping extends IProperty {
  87183. mappings: Array<{
  87184. variants: number[];
  87185. material: number;
  87186. }>;
  87187. }
  87188. /** @hidden */
  87189. interface IKHRMaterialVariants_Variant extends IProperty {
  87190. name: string;
  87191. }
  87192. /** @hidden */
  87193. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  87194. variants: Array<IKHRMaterialVariants_Variant>;
  87195. }
  87196. /**
  87197. * Interfaces from the KHR_texture_basisu extension
  87198. * !!! Experimental Extension Subject to Changes !!!
  87199. */
  87200. /** @hidden */
  87201. interface IKHRTextureBasisU {
  87202. source: number;
  87203. }
  87204. /**
  87205. * Interfaces from the EXT_texture_webp extension
  87206. */
  87207. /** @hidden */
  87208. interface IEXTTextureWebP {
  87209. source: number;
  87210. }
  87211. /**
  87212. * Interfaces from the KHR_texture_transform extension
  87213. */
  87214. /** @hidden */
  87215. interface IKHRTextureTransform {
  87216. offset?: number[];
  87217. rotation?: number;
  87218. scale?: number[];
  87219. texCoord?: number;
  87220. }
  87221. /**
  87222. * Interfaces from the KHR_xmp extension
  87223. * !!! Experimental Extension Subject to Changes !!!
  87224. */
  87225. /** @hidden */
  87226. interface IKHRXmp_Data {
  87227. [key: string]: unknown;
  87228. }
  87229. /** @hidden */
  87230. interface IKHRXmp_Gltf {
  87231. packets: IKHRXmp_Data[];
  87232. }
  87233. /** @hidden */
  87234. interface IKHRXmp_Node {
  87235. packet: number;
  87236. }
  87237. /**
  87238. * Interfaces from the MSFT_audio_emitter extension
  87239. */
  87240. /** @hidden */
  87241. interface IMSFTAudioEmitter_ClipReference {
  87242. clip: number;
  87243. weight?: number;
  87244. }
  87245. /** @hidden */
  87246. interface IMSFTAudioEmitter_EmittersReference {
  87247. emitters: number[];
  87248. }
  87249. /** @hidden */
  87250. const enum IMSFTAudioEmitter_DistanceModel {
  87251. linear = "linear",
  87252. inverse = "inverse",
  87253. exponential = "exponential",
  87254. }
  87255. /** @hidden */
  87256. interface IMSFTAudioEmitter_Emitter {
  87257. name?: string;
  87258. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  87259. refDistance?: number;
  87260. maxDistance?: number;
  87261. rolloffFactor?: number;
  87262. innerAngle?: number;
  87263. outerAngle?: number;
  87264. loop?: boolean;
  87265. volume?: number;
  87266. clips: IMSFTAudioEmitter_ClipReference[];
  87267. }
  87268. /** @hidden */
  87269. const enum IMSFTAudioEmitter_AudioMimeType {
  87270. WAV = "audio/wav",
  87271. }
  87272. /** @hidden */
  87273. interface IMSFTAudioEmitter_Clip extends IProperty {
  87274. uri?: string;
  87275. bufferView?: number;
  87276. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  87277. }
  87278. /** @hidden */
  87279. const enum IMSFTAudioEmitter_AnimationEventAction {
  87280. play = "play",
  87281. pause = "pause",
  87282. stop = "stop",
  87283. }
  87284. /** @hidden */
  87285. interface IMSFTAudioEmitter_AnimationEvent {
  87286. action: IMSFTAudioEmitter_AnimationEventAction;
  87287. emitter: number;
  87288. time: number;
  87289. startOffset?: number;
  87290. }
  87291. /**
  87292. * Interfaces from the MSFT_lod extension
  87293. */
  87294. /** @hidden */
  87295. interface IMSFTLOD {
  87296. ids: number[];
  87297. }
  87298. }
  87299. declare module BABYLON {
  87300. /** @hidden */
  87301. export var cellPixelShader: {
  87302. name: string;
  87303. shader: string;
  87304. };
  87305. }
  87306. declare module BABYLON {
  87307. /** @hidden */
  87308. export var cellVertexShader: {
  87309. name: string;
  87310. shader: string;
  87311. };
  87312. }
  87313. declare module BABYLON {
  87314. export class CellMaterial extends BABYLON.PushMaterial {
  87315. private _diffuseTexture;
  87316. diffuseTexture: BABYLON.BaseTexture;
  87317. diffuseColor: BABYLON.Color3;
  87318. _computeHighLevel: boolean;
  87319. computeHighLevel: boolean;
  87320. private _disableLighting;
  87321. disableLighting: boolean;
  87322. private _maxSimultaneousLights;
  87323. maxSimultaneousLights: number;
  87324. constructor(name: string, scene: BABYLON.Scene);
  87325. needAlphaBlending(): boolean;
  87326. needAlphaTesting(): boolean;
  87327. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87328. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87329. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87330. getAnimatables(): BABYLON.IAnimatable[];
  87331. getActiveTextures(): BABYLON.BaseTexture[];
  87332. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87333. dispose(forceDisposeEffect?: boolean): void;
  87334. getClassName(): string;
  87335. clone(name: string): CellMaterial;
  87336. serialize(): any;
  87337. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  87338. }
  87339. }
  87340. declare module BABYLON {
  87341. export class CustomShaderStructure {
  87342. FragmentStore: string;
  87343. VertexStore: string;
  87344. constructor();
  87345. }
  87346. export class ShaderSpecialParts {
  87347. constructor();
  87348. Fragment_Begin: string;
  87349. Fragment_Definitions: string;
  87350. Fragment_MainBegin: string;
  87351. Fragment_Custom_Diffuse: string;
  87352. Fragment_Before_Lights: string;
  87353. Fragment_Before_Fog: string;
  87354. Fragment_Custom_Alpha: string;
  87355. Fragment_Before_FragColor: string;
  87356. Vertex_Begin: string;
  87357. Vertex_Definitions: string;
  87358. Vertex_MainBegin: string;
  87359. Vertex_Before_PositionUpdated: string;
  87360. Vertex_Before_NormalUpdated: string;
  87361. Vertex_After_WorldPosComputed: string;
  87362. Vertex_MainEnd: string;
  87363. }
  87364. export class CustomMaterial extends BABYLON.StandardMaterial {
  87365. static ShaderIndexer: number;
  87366. CustomParts: ShaderSpecialParts;
  87367. _isCreatedShader: boolean;
  87368. _createdShaderName: string;
  87369. _customUniform: string[];
  87370. _newUniforms: string[];
  87371. _newUniformInstances: {
  87372. [name: string]: any;
  87373. };
  87374. _newSamplerInstances: {
  87375. [name: string]: BABYLON.Texture;
  87376. };
  87377. _customAttributes: string[];
  87378. FragmentShader: string;
  87379. VertexShader: string;
  87380. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87381. ReviewUniform(name: string, arr: string[]): string[];
  87382. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87383. constructor(name: string, scene: BABYLON.Scene);
  87384. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  87385. AddAttribute(name: string): CustomMaterial;
  87386. Fragment_Begin(shaderPart: string): CustomMaterial;
  87387. Fragment_Definitions(shaderPart: string): CustomMaterial;
  87388. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  87389. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  87390. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  87391. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  87392. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  87393. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  87394. Vertex_Begin(shaderPart: string): CustomMaterial;
  87395. Vertex_Definitions(shaderPart: string): CustomMaterial;
  87396. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  87397. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  87398. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  87399. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  87400. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  87401. }
  87402. }
  87403. declare module BABYLON {
  87404. export class ShaderAlebdoParts {
  87405. constructor();
  87406. Fragment_Begin: string;
  87407. Fragment_Definitions: string;
  87408. Fragment_MainBegin: string;
  87409. Fragment_Custom_Albedo: string;
  87410. Fragment_Before_Lights: string;
  87411. Fragment_Custom_MetallicRoughness: string;
  87412. Fragment_Custom_MicroSurface: string;
  87413. Fragment_Before_Fog: string;
  87414. Fragment_Custom_Alpha: string;
  87415. Fragment_Before_FragColor: string;
  87416. Vertex_Begin: string;
  87417. Vertex_Definitions: string;
  87418. Vertex_MainBegin: string;
  87419. Vertex_Before_PositionUpdated: string;
  87420. Vertex_Before_NormalUpdated: string;
  87421. Vertex_After_WorldPosComputed: string;
  87422. Vertex_MainEnd: string;
  87423. }
  87424. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  87425. static ShaderIndexer: number;
  87426. CustomParts: ShaderAlebdoParts;
  87427. _isCreatedShader: boolean;
  87428. _createdShaderName: string;
  87429. _customUniform: string[];
  87430. _newUniforms: string[];
  87431. _newUniformInstances: {
  87432. [name: string]: any;
  87433. };
  87434. _newSamplerInstances: {
  87435. [name: string]: BABYLON.Texture;
  87436. };
  87437. _customAttributes: string[];
  87438. FragmentShader: string;
  87439. VertexShader: string;
  87440. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87441. ReviewUniform(name: string, arr: string[]): string[];
  87442. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87443. constructor(name: string, scene: BABYLON.Scene);
  87444. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  87445. AddAttribute(name: string): PBRCustomMaterial;
  87446. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  87447. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  87448. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  87449. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  87450. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  87451. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  87452. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  87453. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  87454. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  87455. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  87456. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  87457. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  87458. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  87459. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  87460. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  87461. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  87462. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  87463. }
  87464. }
  87465. declare module BABYLON {
  87466. /** @hidden */
  87467. export var firePixelShader: {
  87468. name: string;
  87469. shader: string;
  87470. };
  87471. }
  87472. declare module BABYLON {
  87473. /** @hidden */
  87474. export var fireVertexShader: {
  87475. name: string;
  87476. shader: string;
  87477. };
  87478. }
  87479. declare module BABYLON {
  87480. export class FireMaterial extends BABYLON.PushMaterial {
  87481. private _diffuseTexture;
  87482. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87483. private _distortionTexture;
  87484. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87485. private _opacityTexture;
  87486. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87487. diffuseColor: BABYLON.Color3;
  87488. speed: number;
  87489. private _scaledDiffuse;
  87490. private _lastTime;
  87491. constructor(name: string, scene: BABYLON.Scene);
  87492. needAlphaBlending(): boolean;
  87493. needAlphaTesting(): boolean;
  87494. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87495. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87496. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87497. getAnimatables(): BABYLON.IAnimatable[];
  87498. getActiveTextures(): BABYLON.BaseTexture[];
  87499. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87500. getClassName(): string;
  87501. dispose(forceDisposeEffect?: boolean): void;
  87502. clone(name: string): FireMaterial;
  87503. serialize(): any;
  87504. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  87505. }
  87506. }
  87507. declare module BABYLON {
  87508. /** @hidden */
  87509. export var furPixelShader: {
  87510. name: string;
  87511. shader: string;
  87512. };
  87513. }
  87514. declare module BABYLON {
  87515. /** @hidden */
  87516. export var furVertexShader: {
  87517. name: string;
  87518. shader: string;
  87519. };
  87520. }
  87521. declare module BABYLON {
  87522. export class FurMaterial extends BABYLON.PushMaterial {
  87523. private _diffuseTexture;
  87524. diffuseTexture: BABYLON.BaseTexture;
  87525. private _heightTexture;
  87526. heightTexture: BABYLON.BaseTexture;
  87527. diffuseColor: BABYLON.Color3;
  87528. furLength: number;
  87529. furAngle: number;
  87530. furColor: BABYLON.Color3;
  87531. furOffset: number;
  87532. furSpacing: number;
  87533. furGravity: BABYLON.Vector3;
  87534. furSpeed: number;
  87535. furDensity: number;
  87536. furOcclusion: number;
  87537. furTexture: BABYLON.DynamicTexture;
  87538. private _disableLighting;
  87539. disableLighting: boolean;
  87540. private _maxSimultaneousLights;
  87541. maxSimultaneousLights: number;
  87542. highLevelFur: boolean;
  87543. _meshes: BABYLON.AbstractMesh[];
  87544. private _furTime;
  87545. constructor(name: string, scene: BABYLON.Scene);
  87546. get furTime(): number;
  87547. set furTime(furTime: number);
  87548. needAlphaBlending(): boolean;
  87549. needAlphaTesting(): boolean;
  87550. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87551. updateFur(): void;
  87552. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87553. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87554. getAnimatables(): BABYLON.IAnimatable[];
  87555. getActiveTextures(): BABYLON.BaseTexture[];
  87556. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87557. dispose(forceDisposeEffect?: boolean): void;
  87558. clone(name: string): FurMaterial;
  87559. serialize(): any;
  87560. getClassName(): string;
  87561. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  87562. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  87563. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  87564. }
  87565. }
  87566. declare module BABYLON {
  87567. /** @hidden */
  87568. export var gradientPixelShader: {
  87569. name: string;
  87570. shader: string;
  87571. };
  87572. }
  87573. declare module BABYLON {
  87574. /** @hidden */
  87575. export var gradientVertexShader: {
  87576. name: string;
  87577. shader: string;
  87578. };
  87579. }
  87580. declare module BABYLON {
  87581. export class GradientMaterial extends BABYLON.PushMaterial {
  87582. private _maxSimultaneousLights;
  87583. maxSimultaneousLights: number;
  87584. topColor: BABYLON.Color3;
  87585. topColorAlpha: number;
  87586. bottomColor: BABYLON.Color3;
  87587. bottomColorAlpha: number;
  87588. offset: number;
  87589. scale: number;
  87590. smoothness: number;
  87591. private _disableLighting;
  87592. disableLighting: boolean;
  87593. constructor(name: string, scene: BABYLON.Scene);
  87594. needAlphaBlending(): boolean;
  87595. needAlphaTesting(): boolean;
  87596. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87597. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87598. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87599. getAnimatables(): BABYLON.IAnimatable[];
  87600. dispose(forceDisposeEffect?: boolean): void;
  87601. clone(name: string): GradientMaterial;
  87602. serialize(): any;
  87603. getClassName(): string;
  87604. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87605. }
  87606. }
  87607. declare module BABYLON {
  87608. /** @hidden */
  87609. export var gridPixelShader: {
  87610. name: string;
  87611. shader: string;
  87612. };
  87613. }
  87614. declare module BABYLON {
  87615. /** @hidden */
  87616. export var gridVertexShader: {
  87617. name: string;
  87618. shader: string;
  87619. };
  87620. }
  87621. declare module BABYLON {
  87622. /**
  87623. * The grid materials allows you to wrap any shape with a grid.
  87624. * Colors are customizable.
  87625. */
  87626. export class GridMaterial extends BABYLON.PushMaterial {
  87627. /**
  87628. * Main color of the grid (e.g. between lines)
  87629. */
  87630. mainColor: BABYLON.Color3;
  87631. /**
  87632. * Color of the grid lines.
  87633. */
  87634. lineColor: BABYLON.Color3;
  87635. /**
  87636. * The scale of the grid compared to unit.
  87637. */
  87638. gridRatio: number;
  87639. /**
  87640. * Allows setting an offset for the grid lines.
  87641. */
  87642. gridOffset: BABYLON.Vector3;
  87643. /**
  87644. * The frequency of thicker lines.
  87645. */
  87646. majorUnitFrequency: number;
  87647. /**
  87648. * The visibility of minor units in the grid.
  87649. */
  87650. minorUnitVisibility: number;
  87651. /**
  87652. * The grid opacity outside of the lines.
  87653. */
  87654. opacity: number;
  87655. /**
  87656. * Determine RBG output is premultiplied by alpha value.
  87657. */
  87658. preMultiplyAlpha: boolean;
  87659. private _opacityTexture;
  87660. opacityTexture: BABYLON.BaseTexture;
  87661. private _gridControl;
  87662. /**
  87663. * constructor
  87664. * @param name The name given to the material in order to identify it afterwards.
  87665. * @param scene The scene the material is used in.
  87666. */
  87667. constructor(name: string, scene: BABYLON.Scene);
  87668. /**
  87669. * Returns wehter or not the grid requires alpha blending.
  87670. */
  87671. needAlphaBlending(): boolean;
  87672. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87673. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87674. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87675. /**
  87676. * Dispose the material and its associated resources.
  87677. * @param forceDisposeEffect will also dispose the used effect when true
  87678. */
  87679. dispose(forceDisposeEffect?: boolean): void;
  87680. clone(name: string): GridMaterial;
  87681. serialize(): any;
  87682. getClassName(): string;
  87683. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87684. }
  87685. }
  87686. declare module BABYLON {
  87687. /** @hidden */
  87688. export var lavaPixelShader: {
  87689. name: string;
  87690. shader: string;
  87691. };
  87692. }
  87693. declare module BABYLON {
  87694. /** @hidden */
  87695. export var lavaVertexShader: {
  87696. name: string;
  87697. shader: string;
  87698. };
  87699. }
  87700. declare module BABYLON {
  87701. export class LavaMaterial extends BABYLON.PushMaterial {
  87702. private _diffuseTexture;
  87703. diffuseTexture: BABYLON.BaseTexture;
  87704. noiseTexture: BABYLON.BaseTexture;
  87705. fogColor: BABYLON.Color3;
  87706. speed: number;
  87707. movingSpeed: number;
  87708. lowFrequencySpeed: number;
  87709. fogDensity: number;
  87710. private _lastTime;
  87711. diffuseColor: BABYLON.Color3;
  87712. private _disableLighting;
  87713. disableLighting: boolean;
  87714. private _unlit;
  87715. unlit: boolean;
  87716. private _maxSimultaneousLights;
  87717. maxSimultaneousLights: number;
  87718. private _scaledDiffuse;
  87719. constructor(name: string, scene: BABYLON.Scene);
  87720. needAlphaBlending(): boolean;
  87721. needAlphaTesting(): boolean;
  87722. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87723. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87724. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87725. getAnimatables(): BABYLON.IAnimatable[];
  87726. getActiveTextures(): BABYLON.BaseTexture[];
  87727. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87728. dispose(forceDisposeEffect?: boolean): void;
  87729. clone(name: string): LavaMaterial;
  87730. serialize(): any;
  87731. getClassName(): string;
  87732. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87733. }
  87734. }
  87735. declare module BABYLON {
  87736. /** @hidden */
  87737. export var mixPixelShader: {
  87738. name: string;
  87739. shader: string;
  87740. };
  87741. }
  87742. declare module BABYLON {
  87743. /** @hidden */
  87744. export var mixVertexShader: {
  87745. name: string;
  87746. shader: string;
  87747. };
  87748. }
  87749. declare module BABYLON {
  87750. export class MixMaterial extends BABYLON.PushMaterial {
  87751. /**
  87752. * Mix textures
  87753. */
  87754. private _mixTexture1;
  87755. mixTexture1: BABYLON.BaseTexture;
  87756. private _mixTexture2;
  87757. mixTexture2: BABYLON.BaseTexture;
  87758. /**
  87759. * Diffuse textures
  87760. */
  87761. private _diffuseTexture1;
  87762. diffuseTexture1: BABYLON.Texture;
  87763. private _diffuseTexture2;
  87764. diffuseTexture2: BABYLON.Texture;
  87765. private _diffuseTexture3;
  87766. diffuseTexture3: BABYLON.Texture;
  87767. private _diffuseTexture4;
  87768. diffuseTexture4: BABYLON.Texture;
  87769. private _diffuseTexture5;
  87770. diffuseTexture5: BABYLON.Texture;
  87771. private _diffuseTexture6;
  87772. diffuseTexture6: BABYLON.Texture;
  87773. private _diffuseTexture7;
  87774. diffuseTexture7: BABYLON.Texture;
  87775. private _diffuseTexture8;
  87776. diffuseTexture8: BABYLON.Texture;
  87777. /**
  87778. * Uniforms
  87779. */
  87780. diffuseColor: BABYLON.Color3;
  87781. specularColor: BABYLON.Color3;
  87782. specularPower: number;
  87783. private _disableLighting;
  87784. disableLighting: boolean;
  87785. private _maxSimultaneousLights;
  87786. maxSimultaneousLights: number;
  87787. constructor(name: string, scene: BABYLON.Scene);
  87788. needAlphaBlending(): boolean;
  87789. needAlphaTesting(): boolean;
  87790. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87791. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87792. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87793. getAnimatables(): BABYLON.IAnimatable[];
  87794. getActiveTextures(): BABYLON.BaseTexture[];
  87795. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87796. dispose(forceDisposeEffect?: boolean): void;
  87797. clone(name: string): MixMaterial;
  87798. serialize(): any;
  87799. getClassName(): string;
  87800. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87801. }
  87802. }
  87803. declare module BABYLON {
  87804. /** @hidden */
  87805. export var normalPixelShader: {
  87806. name: string;
  87807. shader: string;
  87808. };
  87809. }
  87810. declare module BABYLON {
  87811. /** @hidden */
  87812. export var normalVertexShader: {
  87813. name: string;
  87814. shader: string;
  87815. };
  87816. }
  87817. declare module BABYLON {
  87818. export class NormalMaterial extends BABYLON.PushMaterial {
  87819. private _diffuseTexture;
  87820. diffuseTexture: BABYLON.BaseTexture;
  87821. diffuseColor: BABYLON.Color3;
  87822. private _disableLighting;
  87823. disableLighting: boolean;
  87824. private _maxSimultaneousLights;
  87825. maxSimultaneousLights: number;
  87826. constructor(name: string, scene: BABYLON.Scene);
  87827. needAlphaBlending(): boolean;
  87828. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87829. needAlphaTesting(): boolean;
  87830. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87831. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87832. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87833. getAnimatables(): BABYLON.IAnimatable[];
  87834. getActiveTextures(): BABYLON.BaseTexture[];
  87835. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87836. dispose(forceDisposeEffect?: boolean): void;
  87837. clone(name: string): NormalMaterial;
  87838. serialize(): any;
  87839. getClassName(): string;
  87840. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87841. }
  87842. }
  87843. declare module BABYLON {
  87844. /** @hidden */
  87845. export var shadowOnlyPixelShader: {
  87846. name: string;
  87847. shader: string;
  87848. };
  87849. }
  87850. declare module BABYLON {
  87851. /** @hidden */
  87852. export var shadowOnlyVertexShader: {
  87853. name: string;
  87854. shader: string;
  87855. };
  87856. }
  87857. declare module BABYLON {
  87858. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87859. private _activeLight;
  87860. private _needAlphaBlending;
  87861. constructor(name: string, scene: BABYLON.Scene);
  87862. shadowColor: BABYLON.Color3;
  87863. needAlphaBlending(): boolean;
  87864. needAlphaTesting(): boolean;
  87865. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87866. get activeLight(): BABYLON.IShadowLight;
  87867. set activeLight(light: BABYLON.IShadowLight);
  87868. private _getFirstShadowLightForMesh;
  87869. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87870. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87871. clone(name: string): ShadowOnlyMaterial;
  87872. serialize(): any;
  87873. getClassName(): string;
  87874. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87875. }
  87876. }
  87877. declare module BABYLON {
  87878. /** @hidden */
  87879. export var simplePixelShader: {
  87880. name: string;
  87881. shader: string;
  87882. };
  87883. }
  87884. declare module BABYLON {
  87885. /** @hidden */
  87886. export var simpleVertexShader: {
  87887. name: string;
  87888. shader: string;
  87889. };
  87890. }
  87891. declare module BABYLON {
  87892. export class SimpleMaterial extends BABYLON.PushMaterial {
  87893. private _diffuseTexture;
  87894. diffuseTexture: BABYLON.BaseTexture;
  87895. diffuseColor: BABYLON.Color3;
  87896. private _disableLighting;
  87897. disableLighting: boolean;
  87898. private _maxSimultaneousLights;
  87899. maxSimultaneousLights: number;
  87900. constructor(name: string, scene: BABYLON.Scene);
  87901. needAlphaBlending(): boolean;
  87902. needAlphaTesting(): boolean;
  87903. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87904. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87905. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87906. getAnimatables(): BABYLON.IAnimatable[];
  87907. getActiveTextures(): BABYLON.BaseTexture[];
  87908. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87909. dispose(forceDisposeEffect?: boolean): void;
  87910. clone(name: string): SimpleMaterial;
  87911. serialize(): any;
  87912. getClassName(): string;
  87913. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87914. }
  87915. }
  87916. declare module BABYLON {
  87917. /** @hidden */
  87918. export var skyPixelShader: {
  87919. name: string;
  87920. shader: string;
  87921. };
  87922. }
  87923. declare module BABYLON {
  87924. /** @hidden */
  87925. export var skyVertexShader: {
  87926. name: string;
  87927. shader: string;
  87928. };
  87929. }
  87930. declare module BABYLON {
  87931. /**
  87932. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87933. * @see https://doc.babylonjs.com/extensions/sky
  87934. */
  87935. export class SkyMaterial extends BABYLON.PushMaterial {
  87936. /**
  87937. * Defines the overall luminance of sky in interval ]0, 1[.
  87938. */
  87939. luminance: number;
  87940. /**
  87941. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87942. */
  87943. turbidity: number;
  87944. /**
  87945. * Defines the sky appearance (light intensity).
  87946. */
  87947. rayleigh: number;
  87948. /**
  87949. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87950. */
  87951. mieCoefficient: number;
  87952. /**
  87953. * Defines the amount of haze particles following the Mie scattering theory.
  87954. */
  87955. mieDirectionalG: number;
  87956. /**
  87957. * Defines the distance of the sun according to the active scene camera.
  87958. */
  87959. distance: number;
  87960. /**
  87961. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87962. * "inclined".
  87963. */
  87964. inclination: number;
  87965. /**
  87966. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87967. * an object direction and a reference direction.
  87968. */
  87969. azimuth: number;
  87970. /**
  87971. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87972. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87973. */
  87974. sunPosition: BABYLON.Vector3;
  87975. /**
  87976. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87977. * .sunPosition property.
  87978. */
  87979. useSunPosition: boolean;
  87980. /**
  87981. * Defines an offset vector used to get a horizon offset.
  87982. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87983. */
  87984. cameraOffset: BABYLON.Vector3;
  87985. private _cameraPosition;
  87986. /**
  87987. * Instantiates a new sky material.
  87988. * This material allows to create dynamic and texture free
  87989. * effects for skyboxes by taking care of the atmosphere state.
  87990. * @see https://doc.babylonjs.com/extensions/sky
  87991. * @param name Define the name of the material in the scene
  87992. * @param scene Define the scene the material belong to
  87993. */
  87994. constructor(name: string, scene: BABYLON.Scene);
  87995. /**
  87996. * Specifies if the material will require alpha blending
  87997. * @returns a boolean specifying if alpha blending is needed
  87998. */
  87999. needAlphaBlending(): boolean;
  88000. /**
  88001. * Specifies if this material should be rendered in alpha test mode
  88002. * @returns false as the sky material doesn't need alpha testing.
  88003. */
  88004. needAlphaTesting(): boolean;
  88005. /**
  88006. * Get the texture used for alpha test purpose.
  88007. * @returns null as the sky material has no texture.
  88008. */
  88009. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88010. /**
  88011. * Get if the submesh is ready to be used and all its information available.
  88012. * Child classes can use it to update shaders
  88013. * @param mesh defines the mesh to check
  88014. * @param subMesh defines which submesh to check
  88015. * @param useInstances specifies that instances should be used
  88016. * @returns a boolean indicating that the submesh is ready or not
  88017. */
  88018. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88019. /**
  88020. * Binds the submesh to this material by preparing the effect and shader to draw
  88021. * @param world defines the world transformation matrix
  88022. * @param mesh defines the mesh containing the submesh
  88023. * @param subMesh defines the submesh to bind the material to
  88024. */
  88025. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88026. /**
  88027. * Get the list of animatables in the material.
  88028. * @returns the list of animatables object used in the material
  88029. */
  88030. getAnimatables(): BABYLON.IAnimatable[];
  88031. /**
  88032. * Disposes the material
  88033. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88034. */
  88035. dispose(forceDisposeEffect?: boolean): void;
  88036. /**
  88037. * Makes a duplicate of the material, and gives it a new name
  88038. * @param name defines the new name for the duplicated material
  88039. * @returns the cloned material
  88040. */
  88041. clone(name: string): SkyMaterial;
  88042. /**
  88043. * Serializes this material in a JSON representation
  88044. * @returns the serialized material object
  88045. */
  88046. serialize(): any;
  88047. /**
  88048. * Gets the current class name of the material e.g. "SkyMaterial"
  88049. * Mainly use in serialization.
  88050. * @returns the class name
  88051. */
  88052. getClassName(): string;
  88053. /**
  88054. * Creates a sky material from parsed material data
  88055. * @param source defines the JSON representation of the material
  88056. * @param scene defines the hosting scene
  88057. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88058. * @returns a new sky material
  88059. */
  88060. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  88061. }
  88062. }
  88063. declare module BABYLON {
  88064. /** @hidden */
  88065. export var terrainPixelShader: {
  88066. name: string;
  88067. shader: string;
  88068. };
  88069. }
  88070. declare module BABYLON {
  88071. /** @hidden */
  88072. export var terrainVertexShader: {
  88073. name: string;
  88074. shader: string;
  88075. };
  88076. }
  88077. declare module BABYLON {
  88078. export class TerrainMaterial extends BABYLON.PushMaterial {
  88079. private _mixTexture;
  88080. mixTexture: BABYLON.BaseTexture;
  88081. private _diffuseTexture1;
  88082. diffuseTexture1: BABYLON.Texture;
  88083. private _diffuseTexture2;
  88084. diffuseTexture2: BABYLON.Texture;
  88085. private _diffuseTexture3;
  88086. diffuseTexture3: BABYLON.Texture;
  88087. private _bumpTexture1;
  88088. bumpTexture1: BABYLON.Texture;
  88089. private _bumpTexture2;
  88090. bumpTexture2: BABYLON.Texture;
  88091. private _bumpTexture3;
  88092. bumpTexture3: BABYLON.Texture;
  88093. diffuseColor: BABYLON.Color3;
  88094. specularColor: BABYLON.Color3;
  88095. specularPower: number;
  88096. private _disableLighting;
  88097. disableLighting: boolean;
  88098. private _maxSimultaneousLights;
  88099. maxSimultaneousLights: number;
  88100. constructor(name: string, scene: BABYLON.Scene);
  88101. needAlphaBlending(): boolean;
  88102. needAlphaTesting(): boolean;
  88103. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88104. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88105. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88106. getAnimatables(): BABYLON.IAnimatable[];
  88107. getActiveTextures(): BABYLON.BaseTexture[];
  88108. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88109. dispose(forceDisposeEffect?: boolean): void;
  88110. clone(name: string): TerrainMaterial;
  88111. serialize(): any;
  88112. getClassName(): string;
  88113. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  88114. }
  88115. }
  88116. declare module BABYLON {
  88117. /** @hidden */
  88118. export var triplanarPixelShader: {
  88119. name: string;
  88120. shader: string;
  88121. };
  88122. }
  88123. declare module BABYLON {
  88124. /** @hidden */
  88125. export var triplanarVertexShader: {
  88126. name: string;
  88127. shader: string;
  88128. };
  88129. }
  88130. declare module BABYLON {
  88131. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  88132. mixTexture: BABYLON.BaseTexture;
  88133. private _diffuseTextureX;
  88134. diffuseTextureX: BABYLON.BaseTexture;
  88135. private _diffuseTextureY;
  88136. diffuseTextureY: BABYLON.BaseTexture;
  88137. private _diffuseTextureZ;
  88138. diffuseTextureZ: BABYLON.BaseTexture;
  88139. private _normalTextureX;
  88140. normalTextureX: BABYLON.BaseTexture;
  88141. private _normalTextureY;
  88142. normalTextureY: BABYLON.BaseTexture;
  88143. private _normalTextureZ;
  88144. normalTextureZ: BABYLON.BaseTexture;
  88145. tileSize: number;
  88146. diffuseColor: BABYLON.Color3;
  88147. specularColor: BABYLON.Color3;
  88148. specularPower: number;
  88149. private _disableLighting;
  88150. disableLighting: boolean;
  88151. private _maxSimultaneousLights;
  88152. maxSimultaneousLights: number;
  88153. constructor(name: string, scene: BABYLON.Scene);
  88154. needAlphaBlending(): boolean;
  88155. needAlphaTesting(): boolean;
  88156. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88157. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88158. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88159. getAnimatables(): BABYLON.IAnimatable[];
  88160. getActiveTextures(): BABYLON.BaseTexture[];
  88161. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88162. dispose(forceDisposeEffect?: boolean): void;
  88163. clone(name: string): TriPlanarMaterial;
  88164. serialize(): any;
  88165. getClassName(): string;
  88166. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  88167. }
  88168. }
  88169. declare module BABYLON {
  88170. /** @hidden */
  88171. export var waterPixelShader: {
  88172. name: string;
  88173. shader: string;
  88174. };
  88175. }
  88176. declare module BABYLON {
  88177. /** @hidden */
  88178. export var waterVertexShader: {
  88179. name: string;
  88180. shader: string;
  88181. };
  88182. }
  88183. declare module BABYLON {
  88184. export class WaterMaterial extends BABYLON.PushMaterial {
  88185. renderTargetSize: BABYLON.Vector2;
  88186. private _bumpTexture;
  88187. bumpTexture: BABYLON.BaseTexture;
  88188. diffuseColor: BABYLON.Color3;
  88189. specularColor: BABYLON.Color3;
  88190. specularPower: number;
  88191. private _disableLighting;
  88192. disableLighting: boolean;
  88193. private _maxSimultaneousLights;
  88194. maxSimultaneousLights: number;
  88195. /**
  88196. * Defines the wind force.
  88197. */
  88198. windForce: number;
  88199. /**
  88200. * Defines the direction of the wind in the plane (X, Z).
  88201. */
  88202. windDirection: BABYLON.Vector2;
  88203. /**
  88204. * Defines the height of the waves.
  88205. */
  88206. waveHeight: number;
  88207. /**
  88208. * Defines the bump height related to the bump map.
  88209. */
  88210. bumpHeight: number;
  88211. /**
  88212. * Defines wether or not: to add a smaller moving bump to less steady waves.
  88213. */
  88214. private _bumpSuperimpose;
  88215. bumpSuperimpose: boolean;
  88216. /**
  88217. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  88218. */
  88219. private _fresnelSeparate;
  88220. fresnelSeparate: boolean;
  88221. /**
  88222. * Defines wether or not bump Wwves modify the reflection.
  88223. */
  88224. private _bumpAffectsReflection;
  88225. bumpAffectsReflection: boolean;
  88226. /**
  88227. * Defines the water color blended with the refraction (near).
  88228. */
  88229. waterColor: BABYLON.Color3;
  88230. /**
  88231. * Defines the blend factor related to the water color.
  88232. */
  88233. colorBlendFactor: number;
  88234. /**
  88235. * Defines the water color blended with the reflection (far).
  88236. */
  88237. waterColor2: BABYLON.Color3;
  88238. /**
  88239. * Defines the blend factor related to the water color (reflection, far).
  88240. */
  88241. colorBlendFactor2: number;
  88242. /**
  88243. * Defines the maximum length of a wave.
  88244. */
  88245. waveLength: number;
  88246. /**
  88247. * Defines the waves speed.
  88248. */
  88249. waveSpeed: number;
  88250. /**
  88251. * Defines the number of times waves are repeated. This is typically used to adjust waves count according to the ground's size where the material is applied on.
  88252. */
  88253. waveCount: number;
  88254. /**
  88255. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  88256. * will avoid calculating useless pixels in the pixel shader of the water material.
  88257. */
  88258. disableClipPlane: boolean;
  88259. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  88260. private _mesh;
  88261. private _refractionRTT;
  88262. private _reflectionRTT;
  88263. private _reflectionTransform;
  88264. private _lastTime;
  88265. private _lastDeltaTime;
  88266. private _useLogarithmicDepth;
  88267. private _waitingRenderList;
  88268. private _imageProcessingConfiguration;
  88269. private _imageProcessingObserver;
  88270. /**
  88271. * Gets a boolean indicating that current material needs to register RTT
  88272. */
  88273. get hasRenderTargetTextures(): boolean;
  88274. /**
  88275. * Constructor
  88276. */
  88277. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  88278. get useLogarithmicDepth(): boolean;
  88279. set useLogarithmicDepth(value: boolean);
  88280. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88281. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88282. addToRenderList(node: any): void;
  88283. enableRenderTargets(enable: boolean): void;
  88284. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  88285. get renderTargetsEnabled(): boolean;
  88286. needAlphaBlending(): boolean;
  88287. needAlphaTesting(): boolean;
  88288. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88289. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88290. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88291. private _createRenderTargets;
  88292. getAnimatables(): BABYLON.IAnimatable[];
  88293. getActiveTextures(): BABYLON.BaseTexture[];
  88294. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88295. dispose(forceDisposeEffect?: boolean): void;
  88296. clone(name: string): WaterMaterial;
  88297. serialize(): any;
  88298. getClassName(): string;
  88299. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  88300. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  88301. }
  88302. }
  88303. declare module BABYLON {
  88304. /** @hidden */
  88305. export var asciiartPixelShader: {
  88306. name: string;
  88307. shader: string;
  88308. };
  88309. }
  88310. declare module BABYLON {
  88311. /**
  88312. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  88313. *
  88314. * It basically takes care rendering the font front the given font size to a texture.
  88315. * This is used later on in the postprocess.
  88316. */
  88317. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  88318. private _font;
  88319. private _text;
  88320. private _charSize;
  88321. /**
  88322. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88323. */
  88324. get charSize(): number;
  88325. /**
  88326. * Create a new instance of the Ascii Art FontTexture class
  88327. * @param name the name of the texture
  88328. * @param font the font to use, use the W3C CSS notation
  88329. * @param text the caracter set to use in the rendering.
  88330. * @param scene the scene that owns the texture
  88331. */
  88332. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88333. /**
  88334. * Gets the max char width of a font.
  88335. * @param font the font to use, use the W3C CSS notation
  88336. * @return the max char width
  88337. */
  88338. private getFontWidth;
  88339. /**
  88340. * Gets the max char height of a font.
  88341. * @param font the font to use, use the W3C CSS notation
  88342. * @return the max char height
  88343. */
  88344. private getFontHeight;
  88345. /**
  88346. * Clones the current AsciiArtTexture.
  88347. * @return the clone of the texture.
  88348. */
  88349. clone(): AsciiArtFontTexture;
  88350. /**
  88351. * Parses a json object representing the texture and returns an instance of it.
  88352. * @param source the source JSON representation
  88353. * @param scene the scene to create the texture for
  88354. * @return the parsed texture
  88355. */
  88356. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  88357. }
  88358. /**
  88359. * Option available in the Ascii Art Post Process.
  88360. */
  88361. export interface IAsciiArtPostProcessOptions {
  88362. /**
  88363. * The font to use following the w3c font definition.
  88364. */
  88365. font?: string;
  88366. /**
  88367. * The character set to use in the postprocess.
  88368. */
  88369. characterSet?: string;
  88370. /**
  88371. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88372. * This number is defined between 0 and 1;
  88373. */
  88374. mixToTile?: number;
  88375. /**
  88376. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88377. * This number is defined between 0 and 1;
  88378. */
  88379. mixToNormal?: number;
  88380. }
  88381. /**
  88382. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  88383. *
  88384. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88385. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  88386. */
  88387. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  88388. /**
  88389. * The font texture used to render the char in the post process.
  88390. */
  88391. private _asciiArtFontTexture;
  88392. /**
  88393. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88394. * This number is defined between 0 and 1;
  88395. */
  88396. mixToTile: number;
  88397. /**
  88398. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88399. * This number is defined between 0 and 1;
  88400. */
  88401. mixToNormal: number;
  88402. /**
  88403. * Instantiates a new Ascii Art Post Process.
  88404. * @param name the name to give to the postprocess
  88405. * @camera the camera to apply the post process to.
  88406. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  88407. */
  88408. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  88409. }
  88410. }
  88411. declare module BABYLON {
  88412. /** @hidden */
  88413. export var digitalrainPixelShader: {
  88414. name: string;
  88415. shader: string;
  88416. };
  88417. }
  88418. declare module BABYLON {
  88419. /**
  88420. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  88421. *
  88422. * It basically takes care rendering the font front the given font size to a texture.
  88423. * This is used later on in the postprocess.
  88424. */
  88425. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  88426. private _font;
  88427. private _text;
  88428. private _charSize;
  88429. /**
  88430. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88431. */
  88432. get charSize(): number;
  88433. /**
  88434. * Create a new instance of the Digital Rain FontTexture class
  88435. * @param name the name of the texture
  88436. * @param font the font to use, use the W3C CSS notation
  88437. * @param text the caracter set to use in the rendering.
  88438. * @param scene the scene that owns the texture
  88439. */
  88440. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88441. /**
  88442. * Gets the max char width of a font.
  88443. * @param font the font to use, use the W3C CSS notation
  88444. * @return the max char width
  88445. */
  88446. private getFontWidth;
  88447. /**
  88448. * Gets the max char height of a font.
  88449. * @param font the font to use, use the W3C CSS notation
  88450. * @return the max char height
  88451. */
  88452. private getFontHeight;
  88453. /**
  88454. * Clones the current DigitalRainFontTexture.
  88455. * @return the clone of the texture.
  88456. */
  88457. clone(): DigitalRainFontTexture;
  88458. /**
  88459. * Parses a json object representing the texture and returns an instance of it.
  88460. * @param source the source JSON representation
  88461. * @param scene the scene to create the texture for
  88462. * @return the parsed texture
  88463. */
  88464. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  88465. }
  88466. /**
  88467. * Option available in the Digital Rain Post Process.
  88468. */
  88469. export interface IDigitalRainPostProcessOptions {
  88470. /**
  88471. * The font to use following the w3c font definition.
  88472. */
  88473. font?: string;
  88474. /**
  88475. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88476. * This number is defined between 0 and 1;
  88477. */
  88478. mixToTile?: number;
  88479. /**
  88480. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88481. * This number is defined between 0 and 1;
  88482. */
  88483. mixToNormal?: number;
  88484. }
  88485. /**
  88486. * DigitalRainPostProcess helps rendering everithing in digital rain.
  88487. *
  88488. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88489. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  88490. */
  88491. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  88492. /**
  88493. * The font texture used to render the char in the post process.
  88494. */
  88495. private _digitalRainFontTexture;
  88496. /**
  88497. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88498. * This number is defined between 0 and 1;
  88499. */
  88500. mixToTile: number;
  88501. /**
  88502. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88503. * This number is defined between 0 and 1;
  88504. */
  88505. mixToNormal: number;
  88506. /**
  88507. * Instantiates a new Digital Rain Post Process.
  88508. * @param name the name to give to the postprocess
  88509. * @camera the camera to apply the post process to.
  88510. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  88511. */
  88512. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  88513. }
  88514. }
  88515. declare module BABYLON {
  88516. /** @hidden */
  88517. export var brickProceduralTexturePixelShader: {
  88518. name: string;
  88519. shader: string;
  88520. };
  88521. }
  88522. declare module BABYLON {
  88523. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  88524. private _numberOfBricksHeight;
  88525. private _numberOfBricksWidth;
  88526. private _jointColor;
  88527. private _brickColor;
  88528. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88529. updateShaderUniforms(): void;
  88530. get numberOfBricksHeight(): number;
  88531. set numberOfBricksHeight(value: number);
  88532. get numberOfBricksWidth(): number;
  88533. set numberOfBricksWidth(value: number);
  88534. get jointColor(): BABYLON.Color3;
  88535. set jointColor(value: BABYLON.Color3);
  88536. get brickColor(): BABYLON.Color3;
  88537. set brickColor(value: BABYLON.Color3);
  88538. /**
  88539. * Serializes this brick procedural texture
  88540. * @returns a serialized brick procedural texture object
  88541. */
  88542. serialize(): any;
  88543. /**
  88544. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  88545. * @param parsedTexture defines parsed texture data
  88546. * @param scene defines the current scene
  88547. * @param rootUrl defines the root URL containing brick procedural texture information
  88548. * @returns a parsed Brick Procedural BABYLON.Texture
  88549. */
  88550. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  88551. }
  88552. }
  88553. declare module BABYLON {
  88554. /** @hidden */
  88555. export var cloudProceduralTexturePixelShader: {
  88556. name: string;
  88557. shader: string;
  88558. };
  88559. }
  88560. declare module BABYLON {
  88561. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  88562. private _skyColor;
  88563. private _cloudColor;
  88564. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88565. updateShaderUniforms(): void;
  88566. get skyColor(): BABYLON.Color4;
  88567. set skyColor(value: BABYLON.Color4);
  88568. get cloudColor(): BABYLON.Color4;
  88569. set cloudColor(value: BABYLON.Color4);
  88570. /**
  88571. * Serializes this cloud procedural texture
  88572. * @returns a serialized cloud procedural texture object
  88573. */
  88574. serialize(): any;
  88575. /**
  88576. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  88577. * @param parsedTexture defines parsed texture data
  88578. * @param scene defines the current scene
  88579. * @param rootUrl defines the root URL containing cloud procedural texture information
  88580. * @returns a parsed Cloud Procedural BABYLON.Texture
  88581. */
  88582. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88583. }
  88584. }
  88585. declare module BABYLON {
  88586. /** @hidden */
  88587. export var fireProceduralTexturePixelShader: {
  88588. name: string;
  88589. shader: string;
  88590. };
  88591. }
  88592. declare module BABYLON {
  88593. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88594. private _time;
  88595. private _speed;
  88596. private _autoGenerateTime;
  88597. private _fireColors;
  88598. private _alphaThreshold;
  88599. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88600. updateShaderUniforms(): void;
  88601. render(useCameraPostProcess?: boolean): void;
  88602. static get PurpleFireColors(): BABYLON.Color3[];
  88603. static get GreenFireColors(): BABYLON.Color3[];
  88604. static get RedFireColors(): BABYLON.Color3[];
  88605. static get BlueFireColors(): BABYLON.Color3[];
  88606. get autoGenerateTime(): boolean;
  88607. set autoGenerateTime(value: boolean);
  88608. get fireColors(): BABYLON.Color3[];
  88609. set fireColors(value: BABYLON.Color3[]);
  88610. get time(): number;
  88611. set time(value: number);
  88612. get speed(): BABYLON.Vector2;
  88613. set speed(value: BABYLON.Vector2);
  88614. get alphaThreshold(): number;
  88615. set alphaThreshold(value: number);
  88616. /**
  88617. * Serializes this fire procedural texture
  88618. * @returns a serialized fire procedural texture object
  88619. */
  88620. serialize(): any;
  88621. /**
  88622. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88623. * @param parsedTexture defines parsed texture data
  88624. * @param scene defines the current scene
  88625. * @param rootUrl defines the root URL containing fire procedural texture information
  88626. * @returns a parsed Fire Procedural BABYLON.Texture
  88627. */
  88628. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88629. }
  88630. }
  88631. declare module BABYLON {
  88632. /** @hidden */
  88633. export var grassProceduralTexturePixelShader: {
  88634. name: string;
  88635. shader: string;
  88636. };
  88637. }
  88638. declare module BABYLON {
  88639. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88640. private _grassColors;
  88641. private _groundColor;
  88642. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88643. updateShaderUniforms(): void;
  88644. get grassColors(): BABYLON.Color3[];
  88645. set grassColors(value: BABYLON.Color3[]);
  88646. get groundColor(): BABYLON.Color3;
  88647. set groundColor(value: BABYLON.Color3);
  88648. /**
  88649. * Serializes this grass procedural texture
  88650. * @returns a serialized grass procedural texture object
  88651. */
  88652. serialize(): any;
  88653. /**
  88654. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88655. * @param parsedTexture defines parsed texture data
  88656. * @param scene defines the current scene
  88657. * @param rootUrl defines the root URL containing grass procedural texture information
  88658. * @returns a parsed Grass Procedural BABYLON.Texture
  88659. */
  88660. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88661. }
  88662. }
  88663. declare module BABYLON {
  88664. /** @hidden */
  88665. export var marbleProceduralTexturePixelShader: {
  88666. name: string;
  88667. shader: string;
  88668. };
  88669. }
  88670. declare module BABYLON {
  88671. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88672. private _numberOfTilesHeight;
  88673. private _numberOfTilesWidth;
  88674. private _amplitude;
  88675. private _jointColor;
  88676. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88677. updateShaderUniforms(): void;
  88678. get numberOfTilesHeight(): number;
  88679. set numberOfTilesHeight(value: number);
  88680. get amplitude(): number;
  88681. set amplitude(value: number);
  88682. get numberOfTilesWidth(): number;
  88683. set numberOfTilesWidth(value: number);
  88684. get jointColor(): BABYLON.Color3;
  88685. set jointColor(value: BABYLON.Color3);
  88686. /**
  88687. * Serializes this marble procedural texture
  88688. * @returns a serialized marble procedural texture object
  88689. */
  88690. serialize(): any;
  88691. /**
  88692. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88693. * @param parsedTexture defines parsed texture data
  88694. * @param scene defines the current scene
  88695. * @param rootUrl defines the root URL containing marble procedural texture information
  88696. * @returns a parsed Marble Procedural BABYLON.Texture
  88697. */
  88698. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88699. }
  88700. }
  88701. declare module BABYLON {
  88702. /** @hidden */
  88703. export var normalMapProceduralTexturePixelShader: {
  88704. name: string;
  88705. shader: string;
  88706. };
  88707. }
  88708. declare module BABYLON {
  88709. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88710. private _baseTexture;
  88711. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88712. updateShaderUniforms(): void;
  88713. render(useCameraPostProcess?: boolean): void;
  88714. resize(size: any, generateMipMaps: any): void;
  88715. get baseTexture(): BABYLON.Texture;
  88716. set baseTexture(texture: BABYLON.Texture);
  88717. /**
  88718. * Serializes this normal map procedural texture
  88719. * @returns a serialized normal map procedural texture object
  88720. */
  88721. serialize(): any;
  88722. /**
  88723. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88724. * @param parsedTexture defines parsed texture data
  88725. * @param scene defines the current scene
  88726. * @param rootUrl defines the root URL containing normal map procedural texture information
  88727. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88728. */
  88729. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88730. }
  88731. }
  88732. declare module BABYLON {
  88733. /** @hidden */
  88734. export var perlinNoiseProceduralTexturePixelShader: {
  88735. name: string;
  88736. shader: string;
  88737. };
  88738. }
  88739. declare module BABYLON {
  88740. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88741. time: number;
  88742. timeScale: number;
  88743. translationSpeed: number;
  88744. private _currentTranslation;
  88745. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88746. updateShaderUniforms(): void;
  88747. render(useCameraPostProcess?: boolean): void;
  88748. resize(size: any, generateMipMaps: any): void;
  88749. /**
  88750. * Serializes this perlin noise procedural texture
  88751. * @returns a serialized perlin noise procedural texture object
  88752. */
  88753. serialize(): any;
  88754. /**
  88755. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88756. * @param parsedTexture defines parsed texture data
  88757. * @param scene defines the current scene
  88758. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88759. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88760. */
  88761. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88762. }
  88763. }
  88764. declare module BABYLON {
  88765. /** @hidden */
  88766. export var roadProceduralTexturePixelShader: {
  88767. name: string;
  88768. shader: string;
  88769. };
  88770. }
  88771. declare module BABYLON {
  88772. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88773. private _roadColor;
  88774. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88775. updateShaderUniforms(): void;
  88776. get roadColor(): BABYLON.Color3;
  88777. set roadColor(value: BABYLON.Color3);
  88778. /**
  88779. * Serializes this road procedural texture
  88780. * @returns a serialized road procedural texture object
  88781. */
  88782. serialize(): any;
  88783. /**
  88784. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88785. * @param parsedTexture defines parsed texture data
  88786. * @param scene defines the current scene
  88787. * @param rootUrl defines the root URL containing road procedural texture information
  88788. * @returns a parsed Road Procedural BABYLON.Texture
  88789. */
  88790. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88791. }
  88792. }
  88793. declare module BABYLON {
  88794. /** @hidden */
  88795. export var starfieldProceduralTexturePixelShader: {
  88796. name: string;
  88797. shader: string;
  88798. };
  88799. }
  88800. declare module BABYLON {
  88801. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88802. private _time;
  88803. private _alpha;
  88804. private _beta;
  88805. private _zoom;
  88806. private _formuparam;
  88807. private _stepsize;
  88808. private _tile;
  88809. private _brightness;
  88810. private _darkmatter;
  88811. private _distfading;
  88812. private _saturation;
  88813. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88814. updateShaderUniforms(): void;
  88815. get time(): number;
  88816. set time(value: number);
  88817. get alpha(): number;
  88818. set alpha(value: number);
  88819. get beta(): number;
  88820. set beta(value: number);
  88821. get formuparam(): number;
  88822. set formuparam(value: number);
  88823. get stepsize(): number;
  88824. set stepsize(value: number);
  88825. get zoom(): number;
  88826. set zoom(value: number);
  88827. get tile(): number;
  88828. set tile(value: number);
  88829. get brightness(): number;
  88830. set brightness(value: number);
  88831. get darkmatter(): number;
  88832. set darkmatter(value: number);
  88833. get distfading(): number;
  88834. set distfading(value: number);
  88835. get saturation(): number;
  88836. set saturation(value: number);
  88837. /**
  88838. * Serializes this starfield procedural texture
  88839. * @returns a serialized starfield procedural texture object
  88840. */
  88841. serialize(): any;
  88842. /**
  88843. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88844. * @param parsedTexture defines parsed texture data
  88845. * @param scene defines the current scene
  88846. * @param rootUrl defines the root URL containing startfield procedural texture information
  88847. * @returns a parsed Starfield Procedural BABYLON.Texture
  88848. */
  88849. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88850. }
  88851. }
  88852. declare module BABYLON {
  88853. /** @hidden */
  88854. export var woodProceduralTexturePixelShader: {
  88855. name: string;
  88856. shader: string;
  88857. };
  88858. }
  88859. declare module BABYLON {
  88860. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88861. private _ampScale;
  88862. private _woodColor;
  88863. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88864. updateShaderUniforms(): void;
  88865. get ampScale(): number;
  88866. set ampScale(value: number);
  88867. get woodColor(): BABYLON.Color3;
  88868. set woodColor(value: BABYLON.Color3);
  88869. /**
  88870. * Serializes this wood procedural texture
  88871. * @returns a serialized wood procedural texture object
  88872. */
  88873. serialize(): any;
  88874. /**
  88875. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88876. * @param parsedTexture defines parsed texture data
  88877. * @param scene defines the current scene
  88878. * @param rootUrl defines the root URL containing wood procedural texture information
  88879. * @returns a parsed Wood Procedural BABYLON.Texture
  88880. */
  88881. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88882. }
  88883. }