documentation.d.ts 3.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812
  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
  2389. * @param direction the direction to check if the plane is facing
  2390. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2391. * @returns True is the vector "direction" is the same side than the plane normal.
  2392. */
  2393. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2394. /**
  2395. * Calculates the distance to a point
  2396. * @param point point to calculate distance to
  2397. * @returns the signed distance (float) from the given point to the Plane.
  2398. */
  2399. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2400. /**
  2401. * Creates a plane from an array
  2402. * @param array the array to create a plane from
  2403. * @returns a new Plane from the given array.
  2404. */
  2405. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2406. /**
  2407. * Creates a plane from three points
  2408. * @param point1 point used to create the plane
  2409. * @param point2 point used to create the plane
  2410. * @param point3 point used to create the plane
  2411. * @returns a new Plane defined by the three given points.
  2412. */
  2413. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2414. /**
  2415. * Creates a plane from an origin point and a normal
  2416. * @param origin origin of the plane to be constructed
  2417. * @param normal normal of the plane to be constructed
  2418. * @returns a new Plane the normal vector to this plane at the given origin point.
  2419. * Note : the vector "normal" is updated because normalized.
  2420. */
  2421. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2422. /**
  2423. * Calculates the distance from a plane and a point
  2424. * @param origin origin of the plane to be constructed
  2425. * @param normal normal of the plane to be constructed
  2426. * @param point point to calculate distance to
  2427. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2428. */
  2429. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2430. }
  2431. }
  2432. declare module BABYLON {
  2433. /** @hidden */
  2434. export class PerformanceConfigurator {
  2435. /** @hidden */
  2436. static MatrixUse64Bits: boolean;
  2437. /** @hidden */
  2438. static MatrixTrackPrecisionChange: boolean;
  2439. /** @hidden */
  2440. static MatrixCurrentType: any;
  2441. /** @hidden */
  2442. static MatrixTrackedMatrices: Array<any> | null;
  2443. /** @hidden */
  2444. static SetMatrixPrecision(use64bits: boolean): void;
  2445. }
  2446. }
  2447. declare module BABYLON {
  2448. /**
  2449. * Class representing a vector containing 2 coordinates
  2450. */
  2451. export class Vector2 {
  2452. /** defines the first coordinate */
  2453. x: number;
  2454. /** defines the second coordinate */
  2455. y: number;
  2456. /**
  2457. * Creates a new Vector2 from the given x and y coordinates
  2458. * @param x defines the first coordinate
  2459. * @param y defines the second coordinate
  2460. */
  2461. constructor(
  2462. /** defines the first coordinate */
  2463. x?: number,
  2464. /** defines the second coordinate */
  2465. y?: number);
  2466. /**
  2467. * Gets a string with the Vector2 coordinates
  2468. * @returns a string with the Vector2 coordinates
  2469. */
  2470. toString(): string;
  2471. /**
  2472. * Gets class name
  2473. * @returns the string "Vector2"
  2474. */
  2475. getClassName(): string;
  2476. /**
  2477. * Gets current vector hash code
  2478. * @returns the Vector2 hash code as a number
  2479. */
  2480. getHashCode(): number;
  2481. /**
  2482. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2483. * @param array defines the source array
  2484. * @param index defines the offset in source array
  2485. * @returns the current Vector2
  2486. */
  2487. toArray(array: FloatArray, index?: number): Vector2;
  2488. /**
  2489. * Update the current vector from an array
  2490. * @param array defines the destination array
  2491. * @param index defines the offset in the destination array
  2492. * @returns the current Vector3
  2493. */
  2494. fromArray(array: FloatArray, index?: number): Vector2;
  2495. /**
  2496. * Copy the current vector to an array
  2497. * @returns a new array with 2 elements: the Vector2 coordinates.
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2502. * @param source defines the source Vector2
  2503. * @returns the current updated Vector2
  2504. */
  2505. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2506. /**
  2507. * Sets the Vector2 coordinates with the given floats
  2508. * @param x defines the first coordinate
  2509. * @param y defines the second coordinate
  2510. * @returns the current updated Vector2
  2511. */
  2512. copyFromFloats(x: number, y: number): Vector2;
  2513. /**
  2514. * Sets the Vector2 coordinates with the given floats
  2515. * @param x defines the first coordinate
  2516. * @param y defines the second coordinate
  2517. * @returns the current updated Vector2
  2518. */
  2519. set(x: number, y: number): Vector2;
  2520. /**
  2521. * Add another vector with the current one
  2522. * @param otherVector defines the other vector
  2523. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2524. */
  2525. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2526. /**
  2527. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2528. * @param otherVector defines the other vector
  2529. * @param result defines the target vector
  2530. * @returns the unmodified current Vector2
  2531. */
  2532. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2533. /**
  2534. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2535. * @param otherVector defines the other vector
  2536. * @returns the current updated Vector2
  2537. */
  2538. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2539. /**
  2540. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2541. * @param otherVector defines the other vector
  2542. * @returns a new Vector2
  2543. */
  2544. addVector3(otherVector: Vector3): Vector2;
  2545. /**
  2546. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2547. * @param otherVector defines the other vector
  2548. * @returns a new Vector2
  2549. */
  2550. subtract(otherVector: Vector2): Vector2;
  2551. /**
  2552. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2553. * @param otherVector defines the other vector
  2554. * @param result defines the target vector
  2555. * @returns the unmodified current Vector2
  2556. */
  2557. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2558. /**
  2559. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2560. * @param otherVector defines the other vector
  2561. * @returns the current updated Vector2
  2562. */
  2563. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2564. /**
  2565. * Multiplies in place the current Vector2 coordinates by the given ones
  2566. * @param otherVector defines the other vector
  2567. * @returns the current updated Vector2
  2568. */
  2569. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2570. /**
  2571. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2572. * @param otherVector defines the other vector
  2573. * @returns a new Vector2
  2574. */
  2575. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2576. /**
  2577. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2578. * @param otherVector defines the other vector
  2579. * @param result defines the target vector
  2580. * @returns the unmodified current Vector2
  2581. */
  2582. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2583. /**
  2584. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2585. * @param x defines the first coordinate
  2586. * @param y defines the second coordinate
  2587. * @returns a new Vector2
  2588. */
  2589. multiplyByFloats(x: number, y: number): Vector2;
  2590. /**
  2591. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2592. * @param otherVector defines the other vector
  2593. * @returns a new Vector2
  2594. */
  2595. divide(otherVector: Vector2): Vector2;
  2596. /**
  2597. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2598. * @param otherVector defines the other vector
  2599. * @param result defines the target vector
  2600. * @returns the unmodified current Vector2
  2601. */
  2602. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2603. /**
  2604. * Divides the current Vector2 coordinates by the given ones
  2605. * @param otherVector defines the other vector
  2606. * @returns the current updated Vector2
  2607. */
  2608. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2609. /**
  2610. * Gets a new Vector2 with current Vector2 negated coordinates
  2611. * @returns a new Vector2
  2612. */
  2613. negate(): Vector2;
  2614. /**
  2615. * Negate this vector in place
  2616. * @returns this
  2617. */
  2618. negateInPlace(): Vector2;
  2619. /**
  2620. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2621. * @param result defines the Vector3 object where to store the result
  2622. * @returns the current Vector2
  2623. */
  2624. negateToRef(result: Vector2): Vector2;
  2625. /**
  2626. * Multiply the Vector2 coordinates by scale
  2627. * @param scale defines the scaling factor
  2628. * @returns the current updated Vector2
  2629. */
  2630. scaleInPlace(scale: number): Vector2;
  2631. /**
  2632. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2633. * @param scale defines the scaling factor
  2634. * @returns a new Vector2
  2635. */
  2636. scale(scale: number): Vector2;
  2637. /**
  2638. * Scale the current Vector2 values by a factor to a given Vector2
  2639. * @param scale defines the scale factor
  2640. * @param result defines the Vector2 object where to store the result
  2641. * @returns the unmodified current Vector2
  2642. */
  2643. scaleToRef(scale: number, result: Vector2): Vector2;
  2644. /**
  2645. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2646. * @param scale defines the scale factor
  2647. * @param result defines the Vector2 object where to store the result
  2648. * @returns the unmodified current Vector2
  2649. */
  2650. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2651. /**
  2652. * Gets a boolean if two vectors are equals
  2653. * @param otherVector defines the other vector
  2654. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2655. */
  2656. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2657. /**
  2658. * Gets a boolean if two vectors are equals (using an epsilon value)
  2659. * @param otherVector defines the other vector
  2660. * @param epsilon defines the minimal distance to consider equality
  2661. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2662. */
  2663. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2664. /**
  2665. * Gets a new Vector2 from current Vector2 floored values
  2666. * @returns a new Vector2
  2667. */
  2668. floor(): Vector2;
  2669. /**
  2670. * Gets a new Vector2 from current Vector2 floored values
  2671. * @returns a new Vector2
  2672. */
  2673. fract(): Vector2;
  2674. /**
  2675. * Gets the length of the vector
  2676. * @returns the vector length (float)
  2677. */
  2678. length(): number;
  2679. /**
  2680. * Gets the vector squared length
  2681. * @returns the vector squared length (float)
  2682. */
  2683. lengthSquared(): number;
  2684. /**
  2685. * Normalize the vector
  2686. * @returns the current updated Vector2
  2687. */
  2688. normalize(): Vector2;
  2689. /**
  2690. * Gets a new Vector2 copied from the Vector2
  2691. * @returns a new Vector2
  2692. */
  2693. clone(): Vector2;
  2694. /**
  2695. * Gets a new Vector2(0, 0)
  2696. * @returns a new Vector2
  2697. */
  2698. static Zero(): Vector2;
  2699. /**
  2700. * Gets a new Vector2(1, 1)
  2701. * @returns a new Vector2
  2702. */
  2703. static One(): Vector2;
  2704. /**
  2705. * Gets a new Vector2 set from the given index element of the given array
  2706. * @param array defines the data source
  2707. * @param offset defines the offset in the data source
  2708. * @returns a new Vector2
  2709. */
  2710. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2711. /**
  2712. * Sets "result" from the given index element of the given array
  2713. * @param array defines the data source
  2714. * @param offset defines the offset in the data source
  2715. * @param result defines the target vector
  2716. */
  2717. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2718. /**
  2719. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2720. * @param value1 defines 1st point of control
  2721. * @param value2 defines 2nd point of control
  2722. * @param value3 defines 3rd point of control
  2723. * @param value4 defines 4th point of control
  2724. * @param amount defines the interpolation factor
  2725. * @returns a new Vector2
  2726. */
  2727. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2728. /**
  2729. * 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".
  2730. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2731. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2732. * @param value defines the value to clamp
  2733. * @param min defines the lower limit
  2734. * @param max defines the upper limit
  2735. * @returns a new Vector2
  2736. */
  2737. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2738. /**
  2739. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2740. * @param value1 defines the 1st control point
  2741. * @param tangent1 defines the outgoing tangent
  2742. * @param value2 defines the 2nd control point
  2743. * @param tangent2 defines the incoming tangent
  2744. * @param amount defines the interpolation factor
  2745. * @returns a new Vector2
  2746. */
  2747. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2748. /**
  2749. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2750. * @param start defines the start vector
  2751. * @param end defines the end vector
  2752. * @param amount defines the interpolation factor
  2753. * @returns a new Vector2
  2754. */
  2755. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2756. /**
  2757. * Gets the dot product of the vector "left" and the vector "right"
  2758. * @param left defines first vector
  2759. * @param right defines second vector
  2760. * @returns the dot product (float)
  2761. */
  2762. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2763. /**
  2764. * Returns a new Vector2 equal to the normalized given vector
  2765. * @param vector defines the vector to normalize
  2766. * @returns a new Vector2
  2767. */
  2768. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2769. /**
  2770. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2771. * @param left defines 1st vector
  2772. * @param right defines 2nd vector
  2773. * @returns a new Vector2
  2774. */
  2775. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2776. /**
  2777. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2778. * @param left defines 1st vector
  2779. * @param right defines 2nd vector
  2780. * @returns a new Vector2
  2781. */
  2782. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2783. /**
  2784. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2785. * @param vector defines the vector to transform
  2786. * @param transformation defines the matrix to apply
  2787. * @returns a new Vector2
  2788. */
  2789. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2790. /**
  2791. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2792. * @param vector defines the vector to transform
  2793. * @param transformation defines the matrix to apply
  2794. * @param result defines the target vector
  2795. */
  2796. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2797. /**
  2798. * Determines if a given vector is included in a triangle
  2799. * @param p defines the vector to test
  2800. * @param p0 defines 1st triangle point
  2801. * @param p1 defines 2nd triangle point
  2802. * @param p2 defines 3rd triangle point
  2803. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2804. */
  2805. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2806. /**
  2807. * Gets the distance between the vectors "value1" and "value2"
  2808. * @param value1 defines first vector
  2809. * @param value2 defines second vector
  2810. * @returns the distance between vectors
  2811. */
  2812. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2813. /**
  2814. * Returns the squared distance between the vectors "value1" and "value2"
  2815. * @param value1 defines first vector
  2816. * @param value2 defines second vector
  2817. * @returns the squared distance between vectors
  2818. */
  2819. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2820. /**
  2821. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2822. * @param value1 defines first vector
  2823. * @param value2 defines second vector
  2824. * @returns a new Vector2
  2825. */
  2826. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2827. /**
  2828. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2829. * @param p defines the middle point
  2830. * @param segA defines one point of the segment
  2831. * @param segB defines the other point of the segment
  2832. * @returns the shortest distance
  2833. */
  2834. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2835. }
  2836. /**
  2837. * Class used to store (x,y,z) vector representation
  2838. * A Vector3 is the main object used in 3D geometry
  2839. * It can represent etiher the coordinates of a point the space, either a direction
  2840. * Reminder: js uses a left handed forward facing system
  2841. */
  2842. export class Vector3 {
  2843. private static _UpReadOnly;
  2844. private static _ZeroReadOnly;
  2845. /** @hidden */
  2846. _x: number;
  2847. /** @hidden */
  2848. _y: number;
  2849. /** @hidden */
  2850. _z: number;
  2851. /** @hidden */
  2852. _isDirty: boolean;
  2853. /** Gets or sets the x coordinate */
  2854. get x(): number;
  2855. set x(value: number);
  2856. /** Gets or sets the y coordinate */
  2857. get y(): number;
  2858. set y(value: number);
  2859. /** Gets or sets the z coordinate */
  2860. get z(): number;
  2861. set z(value: number);
  2862. /**
  2863. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2864. * @param x defines the first coordinates (on X axis)
  2865. * @param y defines the second coordinates (on Y axis)
  2866. * @param z defines the third coordinates (on Z axis)
  2867. */
  2868. constructor(x?: number, y?: number, z?: number);
  2869. /**
  2870. * Creates a string representation of the Vector3
  2871. * @returns a string with the Vector3 coordinates.
  2872. */
  2873. toString(): string;
  2874. /**
  2875. * Gets the class name
  2876. * @returns the string "Vector3"
  2877. */
  2878. getClassName(): string;
  2879. /**
  2880. * Creates the Vector3 hash code
  2881. * @returns a number which tends to be unique between Vector3 instances
  2882. */
  2883. getHashCode(): number;
  2884. /**
  2885. * Creates an array containing three elements : the coordinates of the Vector3
  2886. * @returns a new array of numbers
  2887. */
  2888. asArray(): number[];
  2889. /**
  2890. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2891. * @param array defines the destination array
  2892. * @param index defines the offset in the destination array
  2893. * @returns the current Vector3
  2894. */
  2895. toArray(array: FloatArray, index?: number): Vector3;
  2896. /**
  2897. * Update the current vector from an array
  2898. * @param array defines the destination array
  2899. * @param index defines the offset in the destination array
  2900. * @returns the current Vector3
  2901. */
  2902. fromArray(array: FloatArray, index?: number): Vector3;
  2903. /**
  2904. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2905. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2906. */
  2907. toQuaternion(): Quaternion;
  2908. /**
  2909. * Adds the given vector to the current Vector3
  2910. * @param otherVector defines the second operand
  2911. * @returns the current updated Vector3
  2912. */
  2913. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Adds the given coordinates to the current Vector3
  2916. * @param x defines the x coordinate of the operand
  2917. * @param y defines the y coordinate of the operand
  2918. * @param z defines the z coordinate of the operand
  2919. * @returns the current updated Vector3
  2920. */
  2921. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2922. /**
  2923. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2924. * @param otherVector defines the second operand
  2925. * @returns the resulting Vector3
  2926. */
  2927. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2928. /**
  2929. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2930. * @param otherVector defines the second operand
  2931. * @param result defines the Vector3 object where to store the result
  2932. * @returns the current Vector3
  2933. */
  2934. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2935. /**
  2936. * Subtract the given vector from the current Vector3
  2937. * @param otherVector defines the second operand
  2938. * @returns the current updated Vector3
  2939. */
  2940. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2941. /**
  2942. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2943. * @param otherVector defines the second operand
  2944. * @returns the resulting Vector3
  2945. */
  2946. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2947. /**
  2948. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2949. * @param otherVector defines the second operand
  2950. * @param result defines the Vector3 object where to store the result
  2951. * @returns the current Vector3
  2952. */
  2953. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2954. /**
  2955. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2956. * @param x defines the x coordinate of the operand
  2957. * @param y defines the y coordinate of the operand
  2958. * @param z defines the z coordinate of the operand
  2959. * @returns the resulting Vector3
  2960. */
  2961. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2962. /**
  2963. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2964. * @param x defines the x coordinate of the operand
  2965. * @param y defines the y coordinate of the operand
  2966. * @param z defines the z coordinate of the operand
  2967. * @param result defines the Vector3 object where to store the result
  2968. * @returns the current Vector3
  2969. */
  2970. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2971. /**
  2972. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2973. * @returns a new Vector3
  2974. */
  2975. negate(): Vector3;
  2976. /**
  2977. * Negate this vector in place
  2978. * @returns this
  2979. */
  2980. negateInPlace(): Vector3;
  2981. /**
  2982. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2983. * @param result defines the Vector3 object where to store the result
  2984. * @returns the current Vector3
  2985. */
  2986. negateToRef(result: Vector3): Vector3;
  2987. /**
  2988. * Multiplies the Vector3 coordinates by the float "scale"
  2989. * @param scale defines the multiplier factor
  2990. * @returns the current updated Vector3
  2991. */
  2992. scaleInPlace(scale: number): Vector3;
  2993. /**
  2994. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2995. * @param scale defines the multiplier factor
  2996. * @returns a new Vector3
  2997. */
  2998. scale(scale: number): Vector3;
  2999. /**
  3000. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3001. * @param scale defines the multiplier factor
  3002. * @param result defines the Vector3 object where to store the result
  3003. * @returns the current Vector3
  3004. */
  3005. scaleToRef(scale: number, result: Vector3): Vector3;
  3006. /**
  3007. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3008. * @param scale defines the scale factor
  3009. * @param result defines the Vector3 object where to store the result
  3010. * @returns the unmodified current Vector3
  3011. */
  3012. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3013. /**
  3014. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3015. * @param origin defines the origin of the projection ray
  3016. * @param plane defines the plane to project to
  3017. * @returns the projected vector3
  3018. */
  3019. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3020. /**
  3021. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3022. * @param origin defines the origin of the projection ray
  3023. * @param plane defines the plane to project to
  3024. * @param result defines the Vector3 where to store the result
  3025. */
  3026. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3027. /**
  3028. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3029. * @param otherVector defines the second operand
  3030. * @returns true if both vectors are equals
  3031. */
  3032. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3033. /**
  3034. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3035. * @param otherVector defines the second operand
  3036. * @param epsilon defines the minimal distance to define values as equals
  3037. * @returns true if both vectors are distant less than epsilon
  3038. */
  3039. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3040. /**
  3041. * Returns true if the current Vector3 coordinates equals the given floats
  3042. * @param x defines the x coordinate of the operand
  3043. * @param y defines the y coordinate of the operand
  3044. * @param z defines the z coordinate of the operand
  3045. * @returns true if both vectors are equals
  3046. */
  3047. equalsToFloats(x: number, y: number, z: number): boolean;
  3048. /**
  3049. * Multiplies the current Vector3 coordinates by the given ones
  3050. * @param otherVector defines the second operand
  3051. * @returns the current updated Vector3
  3052. */
  3053. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3054. /**
  3055. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3056. * @param otherVector defines the second operand
  3057. * @returns the new Vector3
  3058. */
  3059. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3060. /**
  3061. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3062. * @param otherVector defines the second operand
  3063. * @param result defines the Vector3 object where to store the result
  3064. * @returns the current Vector3
  3065. */
  3066. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3067. /**
  3068. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3069. * @param x defines the x coordinate of the operand
  3070. * @param y defines the y coordinate of the operand
  3071. * @param z defines the z coordinate of the operand
  3072. * @returns the new Vector3
  3073. */
  3074. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3075. /**
  3076. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3077. * @param otherVector defines the second operand
  3078. * @returns the new Vector3
  3079. */
  3080. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3081. /**
  3082. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3083. * @param otherVector defines the second operand
  3084. * @param result defines the Vector3 object where to store the result
  3085. * @returns the current Vector3
  3086. */
  3087. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3088. /**
  3089. * Divides the current Vector3 coordinates by the given ones.
  3090. * @param otherVector defines the second operand
  3091. * @returns the current updated Vector3
  3092. */
  3093. divideInPlace(otherVector: Vector3): Vector3;
  3094. /**
  3095. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3096. * @param other defines the second operand
  3097. * @returns the current updated Vector3
  3098. */
  3099. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3100. /**
  3101. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3102. * @param other defines the second operand
  3103. * @returns the current updated Vector3
  3104. */
  3105. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3106. /**
  3107. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3108. * @param x defines the x coordinate of the operand
  3109. * @param y defines the y coordinate of the operand
  3110. * @param z defines the z coordinate of the operand
  3111. * @returns the current updated Vector3
  3112. */
  3113. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3114. /**
  3115. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3116. * @param x defines the x coordinate of the operand
  3117. * @param y defines the y coordinate of the operand
  3118. * @param z defines the z coordinate of the operand
  3119. * @returns the current updated Vector3
  3120. */
  3121. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3122. /**
  3123. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3124. * Check if is non uniform within a certain amount of decimal places to account for this
  3125. * @param epsilon the amount the values can differ
  3126. * @returns if the the vector is non uniform to a certain number of decimal places
  3127. */
  3128. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3129. /**
  3130. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3131. */
  3132. get isNonUniform(): boolean;
  3133. /**
  3134. * Gets a new Vector3 from current Vector3 floored values
  3135. * @returns a new Vector3
  3136. */
  3137. floor(): Vector3;
  3138. /**
  3139. * Gets a new Vector3 from current Vector3 floored values
  3140. * @returns a new Vector3
  3141. */
  3142. fract(): Vector3;
  3143. /**
  3144. * Gets the length of the Vector3
  3145. * @returns the length of the Vector3
  3146. */
  3147. length(): number;
  3148. /**
  3149. * Gets the squared length of the Vector3
  3150. * @returns squared length of the Vector3
  3151. */
  3152. lengthSquared(): number;
  3153. /**
  3154. * Normalize the current Vector3.
  3155. * Please note that this is an in place operation.
  3156. * @returns the current updated Vector3
  3157. */
  3158. normalize(): Vector3;
  3159. /**
  3160. * Reorders the x y z properties of the vector in place
  3161. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3162. * @returns the current updated vector
  3163. */
  3164. reorderInPlace(order: string): this;
  3165. /**
  3166. * Rotates the vector around 0,0,0 by a quaternion
  3167. * @param quaternion the rotation quaternion
  3168. * @param result vector to store the result
  3169. * @returns the resulting vector
  3170. */
  3171. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3172. /**
  3173. * Rotates a vector around a given point
  3174. * @param quaternion the rotation quaternion
  3175. * @param point the point to rotate around
  3176. * @param result vector to store the result
  3177. * @returns the resulting vector
  3178. */
  3179. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3180. /**
  3181. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3182. * The cross product is then orthogonal to both current and "other"
  3183. * @param other defines the right operand
  3184. * @returns the cross product
  3185. */
  3186. cross(other: Vector3): Vector3;
  3187. /**
  3188. * Normalize the current Vector3 with the given input length.
  3189. * Please note that this is an in place operation.
  3190. * @param len the length of the vector
  3191. * @returns the current updated Vector3
  3192. */
  3193. normalizeFromLength(len: number): Vector3;
  3194. /**
  3195. * Normalize the current Vector3 to a new vector
  3196. * @returns the new Vector3
  3197. */
  3198. normalizeToNew(): Vector3;
  3199. /**
  3200. * Normalize the current Vector3 to the reference
  3201. * @param reference define the Vector3 to update
  3202. * @returns the updated Vector3
  3203. */
  3204. normalizeToRef(reference: Vector3): Vector3;
  3205. /**
  3206. * Creates a new Vector3 copied from the current Vector3
  3207. * @returns the new Vector3
  3208. */
  3209. clone(): Vector3;
  3210. /**
  3211. * Copies the given vector coordinates to the current Vector3 ones
  3212. * @param source defines the source Vector3
  3213. * @returns the current updated Vector3
  3214. */
  3215. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3216. /**
  3217. * Copies the given floats to the current Vector3 coordinates
  3218. * @param x defines the x coordinate of the operand
  3219. * @param y defines the y coordinate of the operand
  3220. * @param z defines the z coordinate of the operand
  3221. * @returns the current updated Vector3
  3222. */
  3223. copyFromFloats(x: number, y: number, z: number): Vector3;
  3224. /**
  3225. * Copies the given floats to the current Vector3 coordinates
  3226. * @param x defines the x coordinate of the operand
  3227. * @param y defines the y coordinate of the operand
  3228. * @param z defines the z coordinate of the operand
  3229. * @returns the current updated Vector3
  3230. */
  3231. set(x: number, y: number, z: number): Vector3;
  3232. /**
  3233. * Copies the given float to the current Vector3 coordinates
  3234. * @param v defines the x, y and z coordinates of the operand
  3235. * @returns the current updated Vector3
  3236. */
  3237. setAll(v: number): Vector3;
  3238. /**
  3239. * Get the clip factor between two vectors
  3240. * @param vector0 defines the first operand
  3241. * @param vector1 defines the second operand
  3242. * @param axis defines the axis to use
  3243. * @param size defines the size along the axis
  3244. * @returns the clip factor
  3245. */
  3246. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3247. /**
  3248. * Get angle between two vectors
  3249. * @param vector0 angle between vector0 and vector1
  3250. * @param vector1 angle between vector0 and vector1
  3251. * @param normal direction of the normal
  3252. * @return the angle between vector0 and vector1
  3253. */
  3254. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3255. /**
  3256. * Returns a new Vector3 set from the index "offset" of the given array
  3257. * @param array defines the source array
  3258. * @param offset defines the offset in the source array
  3259. * @returns the new Vector3
  3260. */
  3261. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3262. /**
  3263. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3264. * @param array defines the source array
  3265. * @param offset defines the offset in the source array
  3266. * @returns the new Vector3
  3267. * @deprecated Please use FromArray instead.
  3268. */
  3269. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3270. /**
  3271. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3272. * @param array defines the source array
  3273. * @param offset defines the offset in the source array
  3274. * @param result defines the Vector3 where to store the result
  3275. */
  3276. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3277. /**
  3278. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3279. * @param array defines the source array
  3280. * @param offset defines the offset in the source array
  3281. * @param result defines the Vector3 where to store the result
  3282. * @deprecated Please use FromArrayToRef instead.
  3283. */
  3284. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3285. /**
  3286. * Sets the given vector "result" with the given floats.
  3287. * @param x defines the x coordinate of the source
  3288. * @param y defines the y coordinate of the source
  3289. * @param z defines the z coordinate of the source
  3290. * @param result defines the Vector3 where to store the result
  3291. */
  3292. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3293. /**
  3294. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3295. * @returns a new empty Vector3
  3296. */
  3297. static Zero(): Vector3;
  3298. /**
  3299. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3300. * @returns a new unit Vector3
  3301. */
  3302. static One(): Vector3;
  3303. /**
  3304. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3305. * @returns a new up Vector3
  3306. */
  3307. static Up(): Vector3;
  3308. /**
  3309. * Gets a up Vector3 that must not be updated
  3310. */
  3311. static get UpReadOnly(): DeepImmutable<Vector3>;
  3312. /**
  3313. * Gets a zero Vector3 that must not be updated
  3314. */
  3315. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3316. /**
  3317. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3318. * @returns a new down Vector3
  3319. */
  3320. static Down(): Vector3;
  3321. /**
  3322. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3323. * @param rightHandedSystem is the scene right-handed (negative z)
  3324. * @returns a new forward Vector3
  3325. */
  3326. static Forward(rightHandedSystem?: boolean): Vector3;
  3327. /**
  3328. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3329. * @param rightHandedSystem is the scene right-handed (negative-z)
  3330. * @returns a new forward Vector3
  3331. */
  3332. static Backward(rightHandedSystem?: boolean): Vector3;
  3333. /**
  3334. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3335. * @returns a new right Vector3
  3336. */
  3337. static Right(): Vector3;
  3338. /**
  3339. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3340. * @returns a new left Vector3
  3341. */
  3342. static Left(): Vector3;
  3343. /**
  3344. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3345. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3346. * @param vector defines the Vector3 to transform
  3347. * @param transformation defines the transformation matrix
  3348. * @returns the transformed Vector3
  3349. */
  3350. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3351. /**
  3352. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3353. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3354. * @param vector defines the Vector3 to transform
  3355. * @param transformation defines the transformation matrix
  3356. * @param result defines the Vector3 where to store the result
  3357. */
  3358. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3359. /**
  3360. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3361. * This method computes tranformed coordinates only, not transformed direction vectors
  3362. * @param x define the x coordinate of the source vector
  3363. * @param y define the y coordinate of the source vector
  3364. * @param z define the z coordinate of the source vector
  3365. * @param transformation defines the transformation matrix
  3366. * @param result defines the Vector3 where to store the result
  3367. */
  3368. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3369. /**
  3370. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3371. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3372. * @param vector defines the Vector3 to transform
  3373. * @param transformation defines the transformation matrix
  3374. * @returns the new Vector3
  3375. */
  3376. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3377. /**
  3378. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3379. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3380. * @param vector defines the Vector3 to transform
  3381. * @param transformation defines the transformation matrix
  3382. * @param result defines the Vector3 where to store the result
  3383. */
  3384. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3385. /**
  3386. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3387. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3388. * @param x define the x coordinate of the source vector
  3389. * @param y define the y coordinate of the source vector
  3390. * @param z define the z coordinate of the source vector
  3391. * @param transformation defines the transformation matrix
  3392. * @param result defines the Vector3 where to store the result
  3393. */
  3394. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3395. /**
  3396. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3397. * @param value1 defines the first control point
  3398. * @param value2 defines the second control point
  3399. * @param value3 defines the third control point
  3400. * @param value4 defines the fourth control point
  3401. * @param amount defines the amount on the spline to use
  3402. * @returns the new Vector3
  3403. */
  3404. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3405. /**
  3406. * 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"
  3407. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3408. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3409. * @param value defines the current value
  3410. * @param min defines the lower range value
  3411. * @param max defines the upper range value
  3412. * @returns the new Vector3
  3413. */
  3414. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3415. /**
  3416. * 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"
  3417. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3418. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3419. * @param value defines the current value
  3420. * @param min defines the lower range value
  3421. * @param max defines the upper range value
  3422. * @param result defines the Vector3 where to store the result
  3423. */
  3424. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3425. /**
  3426. * Checks if a given vector is inside a specific range
  3427. * @param v defines the vector to test
  3428. * @param min defines the minimum range
  3429. * @param max defines the maximum range
  3430. */
  3431. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3432. /**
  3433. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3434. * @param value1 defines the first control point
  3435. * @param tangent1 defines the first tangent vector
  3436. * @param value2 defines the second control point
  3437. * @param tangent2 defines the second tangent vector
  3438. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3439. * @returns the new Vector3
  3440. */
  3441. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3442. /**
  3443. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3444. * @param start defines the start value
  3445. * @param end defines the end value
  3446. * @param amount max defines amount between both (between 0 and 1)
  3447. * @returns the new Vector3
  3448. */
  3449. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3450. /**
  3451. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3452. * @param start defines the start value
  3453. * @param end defines the end value
  3454. * @param amount max defines amount between both (between 0 and 1)
  3455. * @param result defines the Vector3 where to store the result
  3456. */
  3457. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3458. /**
  3459. * Returns the dot product (float) between the vectors "left" and "right"
  3460. * @param left defines the left operand
  3461. * @param right defines the right operand
  3462. * @returns the dot product
  3463. */
  3464. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3465. /**
  3466. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3467. * The cross product is then orthogonal to both "left" and "right"
  3468. * @param left defines the left operand
  3469. * @param right defines the right operand
  3470. * @returns the cross product
  3471. */
  3472. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3473. /**
  3474. * Sets the given vector "result" with the cross product of "left" and "right"
  3475. * The cross product is then orthogonal to both "left" and "right"
  3476. * @param left defines the left operand
  3477. * @param right defines the right operand
  3478. * @param result defines the Vector3 where to store the result
  3479. */
  3480. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3481. /**
  3482. * Returns a new Vector3 as the normalization of the given vector
  3483. * @param vector defines the Vector3 to normalize
  3484. * @returns the new Vector3
  3485. */
  3486. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3487. /**
  3488. * Sets the given vector "result" with the normalization of the given first vector
  3489. * @param vector defines the Vector3 to normalize
  3490. * @param result defines the Vector3 where to store the result
  3491. */
  3492. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3493. /**
  3494. * Project a Vector3 onto screen space
  3495. * @param vector defines the Vector3 to project
  3496. * @param world defines the world matrix to use
  3497. * @param transform defines the transform (view x projection) matrix to use
  3498. * @param viewport defines the screen viewport to use
  3499. * @returns the new Vector3
  3500. */
  3501. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3502. /**
  3503. * Project a Vector3 onto screen space to reference
  3504. * @param vector defines the Vector3 to project
  3505. * @param world defines the world matrix to use
  3506. * @param transform defines the transform (view x projection) matrix to use
  3507. * @param viewport defines the screen viewport to use
  3508. * @param result the vector in which the screen space will be stored
  3509. * @returns the new Vector3
  3510. */
  3511. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3512. /** @hidden */
  3513. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3514. /**
  3515. * Unproject from screen space to object space
  3516. * @param source defines the screen space Vector3 to use
  3517. * @param viewportWidth defines the current width of the viewport
  3518. * @param viewportHeight defines the current height of the viewport
  3519. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3520. * @param transform defines the transform (view x projection) matrix to use
  3521. * @returns the new Vector3
  3522. */
  3523. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3524. /**
  3525. * Unproject from screen space to object space
  3526. * @param source defines the screen space Vector3 to use
  3527. * @param viewportWidth defines the current width of the viewport
  3528. * @param viewportHeight defines the current height of the viewport
  3529. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3530. * @param view defines the view matrix to use
  3531. * @param projection defines the projection matrix to use
  3532. * @returns the new Vector3
  3533. */
  3534. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: 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. * @param result defines the Vector3 where to store the result
  3544. */
  3545. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3546. /**
  3547. * Unproject from screen space to object space
  3548. * @param sourceX defines the screen space x coordinate to use
  3549. * @param sourceY defines the screen space y coordinate to use
  3550. * @param sourceZ defines the screen space z coordinate to use
  3551. * @param viewportWidth defines the current width of the viewport
  3552. * @param viewportHeight defines the current height of the viewport
  3553. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3554. * @param view defines the view matrix to use
  3555. * @param projection defines the projection matrix to use
  3556. * @param result defines the Vector3 where to store the result
  3557. */
  3558. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3559. /**
  3560. * Gets the minimal coordinate values between two Vector3
  3561. * @param left defines the first operand
  3562. * @param right defines the second operand
  3563. * @returns the new Vector3
  3564. */
  3565. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3566. /**
  3567. * Gets the maximal coordinate values between two Vector3
  3568. * @param left defines the first operand
  3569. * @param right defines the second operand
  3570. * @returns the new Vector3
  3571. */
  3572. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3573. /**
  3574. * Returns the distance between the vectors "value1" and "value2"
  3575. * @param value1 defines the first operand
  3576. * @param value2 defines the second operand
  3577. * @returns the distance
  3578. */
  3579. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3580. /**
  3581. * Returns the squared distance between the vectors "value1" and "value2"
  3582. * @param value1 defines the first operand
  3583. * @param value2 defines the second operand
  3584. * @returns the squared distance
  3585. */
  3586. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3587. /**
  3588. * Returns a new Vector3 located at the center between "value1" and "value2"
  3589. * @param value1 defines the first operand
  3590. * @param value2 defines the second operand
  3591. * @returns the new Vector3
  3592. */
  3593. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3594. /**
  3595. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3596. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3597. * to something in order to rotate it from its local system to the given target system
  3598. * Note: axis1, axis2 and axis3 are normalized during this operation
  3599. * @param axis1 defines the first axis
  3600. * @param axis2 defines the second axis
  3601. * @param axis3 defines the third axis
  3602. * @returns a new Vector3
  3603. */
  3604. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3605. /**
  3606. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3607. * @param axis1 defines the first axis
  3608. * @param axis2 defines the second axis
  3609. * @param axis3 defines the third axis
  3610. * @param ref defines the Vector3 where to store the result
  3611. */
  3612. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3613. }
  3614. /**
  3615. * Vector4 class created for EulerAngle class conversion to Quaternion
  3616. */
  3617. export class Vector4 {
  3618. /** x value of the vector */
  3619. x: number;
  3620. /** y value of the vector */
  3621. y: number;
  3622. /** z value of the vector */
  3623. z: number;
  3624. /** w value of the vector */
  3625. w: number;
  3626. /**
  3627. * Creates a Vector4 object from the given floats.
  3628. * @param x x value of the vector
  3629. * @param y y value of the vector
  3630. * @param z z value of the vector
  3631. * @param w w value of the vector
  3632. */
  3633. constructor(
  3634. /** x value of the vector */
  3635. x: number,
  3636. /** y value of the vector */
  3637. y: number,
  3638. /** z value of the vector */
  3639. z: number,
  3640. /** w value of the vector */
  3641. w: number);
  3642. /**
  3643. * Returns the string with the Vector4 coordinates.
  3644. * @returns a string containing all the vector values
  3645. */
  3646. toString(): string;
  3647. /**
  3648. * Returns the string "Vector4".
  3649. * @returns "Vector4"
  3650. */
  3651. getClassName(): string;
  3652. /**
  3653. * Returns the Vector4 hash code.
  3654. * @returns a unique hash code
  3655. */
  3656. getHashCode(): number;
  3657. /**
  3658. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3659. * @returns the resulting array
  3660. */
  3661. asArray(): number[];
  3662. /**
  3663. * Populates the given array from the given index with the Vector4 coordinates.
  3664. * @param array array to populate
  3665. * @param index index of the array to start at (default: 0)
  3666. * @returns the Vector4.
  3667. */
  3668. toArray(array: FloatArray, index?: number): Vector4;
  3669. /**
  3670. * Update the current vector from an array
  3671. * @param array defines the destination array
  3672. * @param index defines the offset in the destination array
  3673. * @returns the current Vector3
  3674. */
  3675. fromArray(array: FloatArray, index?: number): Vector4;
  3676. /**
  3677. * Adds the given vector to the current Vector4.
  3678. * @param otherVector the vector to add
  3679. * @returns the updated Vector4.
  3680. */
  3681. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3682. /**
  3683. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3684. * @param otherVector the vector to add
  3685. * @returns the resulting vector
  3686. */
  3687. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3688. /**
  3689. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3690. * @param otherVector the vector to add
  3691. * @param result the vector to store the result
  3692. * @returns the current Vector4.
  3693. */
  3694. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3695. /**
  3696. * Subtract in place the given vector from the current Vector4.
  3697. * @param otherVector the vector to subtract
  3698. * @returns the updated Vector4.
  3699. */
  3700. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3701. /**
  3702. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3703. * @param otherVector the vector to add
  3704. * @returns the new vector with the result
  3705. */
  3706. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3707. /**
  3708. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3709. * @param otherVector the vector to subtract
  3710. * @param result the vector to store the result
  3711. * @returns the current Vector4.
  3712. */
  3713. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3714. /**
  3715. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3716. */
  3717. /**
  3718. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3719. * @param x value to subtract
  3720. * @param y value to subtract
  3721. * @param z value to subtract
  3722. * @param w value to subtract
  3723. * @returns new vector containing the result
  3724. */
  3725. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3726. /**
  3727. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3728. * @param x value to subtract
  3729. * @param y value to subtract
  3730. * @param z value to subtract
  3731. * @param w value to subtract
  3732. * @param result the vector to store the result in
  3733. * @returns the current Vector4.
  3734. */
  3735. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3736. /**
  3737. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3738. * @returns a new vector with the negated values
  3739. */
  3740. negate(): Vector4;
  3741. /**
  3742. * Negate this vector in place
  3743. * @returns this
  3744. */
  3745. negateInPlace(): Vector4;
  3746. /**
  3747. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3748. * @param result defines the Vector3 object where to store the result
  3749. * @returns the current Vector4
  3750. */
  3751. negateToRef(result: Vector4): Vector4;
  3752. /**
  3753. * Multiplies the current Vector4 coordinates by scale (float).
  3754. * @param scale the number to scale with
  3755. * @returns the updated Vector4.
  3756. */
  3757. scaleInPlace(scale: number): Vector4;
  3758. /**
  3759. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3760. * @param scale the number to scale with
  3761. * @returns a new vector with the result
  3762. */
  3763. scale(scale: number): Vector4;
  3764. /**
  3765. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3766. * @param scale the number to scale with
  3767. * @param result a vector to store the result in
  3768. * @returns the current Vector4.
  3769. */
  3770. scaleToRef(scale: number, result: Vector4): Vector4;
  3771. /**
  3772. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3773. * @param scale defines the scale factor
  3774. * @param result defines the Vector4 object where to store the result
  3775. * @returns the unmodified current Vector4
  3776. */
  3777. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3778. /**
  3779. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3780. * @param otherVector the vector to compare against
  3781. * @returns true if they are equal
  3782. */
  3783. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3784. /**
  3785. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3786. * @param otherVector vector to compare against
  3787. * @param epsilon (Default: very small number)
  3788. * @returns true if they are equal
  3789. */
  3790. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3791. /**
  3792. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3793. * @param x x value to compare against
  3794. * @param y y value to compare against
  3795. * @param z z value to compare against
  3796. * @param w w value to compare against
  3797. * @returns true if equal
  3798. */
  3799. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3800. /**
  3801. * Multiplies in place the current Vector4 by the given one.
  3802. * @param otherVector vector to multiple with
  3803. * @returns the updated Vector4.
  3804. */
  3805. multiplyInPlace(otherVector: Vector4): Vector4;
  3806. /**
  3807. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3808. * @param otherVector vector to multiple with
  3809. * @returns resulting new vector
  3810. */
  3811. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3812. /**
  3813. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3814. * @param otherVector vector to multiple with
  3815. * @param result vector to store the result
  3816. * @returns the current Vector4.
  3817. */
  3818. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3819. /**
  3820. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3821. * @param x x value multiply with
  3822. * @param y y value multiply with
  3823. * @param z z value multiply with
  3824. * @param w w value multiply with
  3825. * @returns resulting new vector
  3826. */
  3827. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3828. /**
  3829. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3830. * @param otherVector vector to devide with
  3831. * @returns resulting new vector
  3832. */
  3833. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3834. /**
  3835. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3836. * @param otherVector vector to devide with
  3837. * @param result vector to store the result
  3838. * @returns the current Vector4.
  3839. */
  3840. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3841. /**
  3842. * Divides the current Vector3 coordinates by the given ones.
  3843. * @param otherVector vector to devide with
  3844. * @returns the updated Vector3.
  3845. */
  3846. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3847. /**
  3848. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3849. * @param other defines the second operand
  3850. * @returns the current updated Vector4
  3851. */
  3852. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3853. /**
  3854. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3855. * @param other defines the second operand
  3856. * @returns the current updated Vector4
  3857. */
  3858. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3859. /**
  3860. * Gets a new Vector4 from current Vector4 floored values
  3861. * @returns a new Vector4
  3862. */
  3863. floor(): Vector4;
  3864. /**
  3865. * Gets a new Vector4 from current Vector3 floored values
  3866. * @returns a new Vector4
  3867. */
  3868. fract(): Vector4;
  3869. /**
  3870. * Returns the Vector4 length (float).
  3871. * @returns the length
  3872. */
  3873. length(): number;
  3874. /**
  3875. * Returns the Vector4 squared length (float).
  3876. * @returns the length squared
  3877. */
  3878. lengthSquared(): number;
  3879. /**
  3880. * Normalizes in place the Vector4.
  3881. * @returns the updated Vector4.
  3882. */
  3883. normalize(): Vector4;
  3884. /**
  3885. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3886. * @returns this converted to a new vector3
  3887. */
  3888. toVector3(): Vector3;
  3889. /**
  3890. * Returns a new Vector4 copied from the current one.
  3891. * @returns the new cloned vector
  3892. */
  3893. clone(): Vector4;
  3894. /**
  3895. * Updates the current Vector4 with the given one coordinates.
  3896. * @param source the source vector to copy from
  3897. * @returns the updated Vector4.
  3898. */
  3899. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3900. /**
  3901. * Updates the current Vector4 coordinates with the given floats.
  3902. * @param x float to copy from
  3903. * @param y float to copy from
  3904. * @param z float to copy from
  3905. * @param w float to copy from
  3906. * @returns the updated Vector4.
  3907. */
  3908. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3909. /**
  3910. * Updates the current Vector4 coordinates with the given floats.
  3911. * @param x float to set from
  3912. * @param y float to set from
  3913. * @param z float to set from
  3914. * @param w float to set from
  3915. * @returns the updated Vector4.
  3916. */
  3917. set(x: number, y: number, z: number, w: number): Vector4;
  3918. /**
  3919. * Copies the given float to the current Vector3 coordinates
  3920. * @param v defines the x, y, z and w coordinates of the operand
  3921. * @returns the current updated Vector3
  3922. */
  3923. setAll(v: number): Vector4;
  3924. /**
  3925. * Returns a new Vector4 set from the starting index of the given array.
  3926. * @param array the array to pull values from
  3927. * @param offset the offset into the array to start at
  3928. * @returns the new vector
  3929. */
  3930. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3931. /**
  3932. * Updates the given vector "result" from the starting index of the given array.
  3933. * @param array the array to pull values from
  3934. * @param offset the offset into the array to start at
  3935. * @param result the vector to store the result in
  3936. */
  3937. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3938. /**
  3939. * Updates the given vector "result" from the starting index of the given Float32Array.
  3940. * @param array the array to pull values from
  3941. * @param offset the offset into the array to start at
  3942. * @param result the vector to store the result in
  3943. */
  3944. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3945. /**
  3946. * Updates the given vector "result" coordinates from the given floats.
  3947. * @param x float to set from
  3948. * @param y float to set from
  3949. * @param z float to set from
  3950. * @param w float to set from
  3951. * @param result the vector to the floats in
  3952. */
  3953. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3954. /**
  3955. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3956. * @returns the new vector
  3957. */
  3958. static Zero(): Vector4;
  3959. /**
  3960. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3961. * @returns the new vector
  3962. */
  3963. static One(): Vector4;
  3964. /**
  3965. * Returns a new normalized Vector4 from the given one.
  3966. * @param vector the vector to normalize
  3967. * @returns the vector
  3968. */
  3969. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3970. /**
  3971. * Updates the given vector "result" from the normalization of the given one.
  3972. * @param vector the vector to normalize
  3973. * @param result the vector to store the result in
  3974. */
  3975. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3976. /**
  3977. * Returns a vector with the minimum values from the left and right vectors
  3978. * @param left left vector to minimize
  3979. * @param right right vector to minimize
  3980. * @returns a new vector with the minimum of the left and right vector values
  3981. */
  3982. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3983. /**
  3984. * Returns a vector with the maximum values from the left and right vectors
  3985. * @param left left vector to maximize
  3986. * @param right right vector to maximize
  3987. * @returns a new vector with the maximum of the left and right vector values
  3988. */
  3989. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3990. /**
  3991. * Returns the distance (float) between the vectors "value1" and "value2".
  3992. * @param value1 value to calulate the distance between
  3993. * @param value2 value to calulate the distance between
  3994. * @return the distance between the two vectors
  3995. */
  3996. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3997. /**
  3998. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3999. * @param value1 value to calulate the distance between
  4000. * @param value2 value to calulate the distance between
  4001. * @return the distance between the two vectors squared
  4002. */
  4003. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4004. /**
  4005. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4006. * @param value1 value to calulate the center between
  4007. * @param value2 value to calulate the center between
  4008. * @return the center between the two vectors
  4009. */
  4010. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4011. /**
  4012. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4013. * This methods computes transformed normalized direction vectors only.
  4014. * @param vector the vector to transform
  4015. * @param transformation the transformation matrix to apply
  4016. * @returns the new vector
  4017. */
  4018. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4019. /**
  4020. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4021. * This methods computes transformed normalized direction vectors only.
  4022. * @param vector the vector to transform
  4023. * @param transformation the transformation matrix to apply
  4024. * @param result the vector to store the result in
  4025. */
  4026. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4027. /**
  4028. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4029. * This methods computes transformed normalized direction vectors only.
  4030. * @param x value to transform
  4031. * @param y value to transform
  4032. * @param z value to transform
  4033. * @param w value to transform
  4034. * @param transformation the transformation matrix to apply
  4035. * @param result the vector to store the results in
  4036. */
  4037. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4038. /**
  4039. * Creates a new Vector4 from a Vector3
  4040. * @param source defines the source data
  4041. * @param w defines the 4th component (default is 0)
  4042. * @returns a new Vector4
  4043. */
  4044. static FromVector3(source: Vector3, w?: number): Vector4;
  4045. }
  4046. /**
  4047. * Class used to store quaternion data
  4048. * @see https://en.wikipedia.org/wiki/Quaternion
  4049. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4050. */
  4051. export class Quaternion {
  4052. /** @hidden */
  4053. _x: number;
  4054. /** @hidden */
  4055. _y: number;
  4056. /** @hidden */
  4057. _z: number;
  4058. /** @hidden */
  4059. _w: number;
  4060. /** @hidden */
  4061. _isDirty: boolean;
  4062. /** Gets or sets the x coordinate */
  4063. get x(): number;
  4064. set x(value: number);
  4065. /** Gets or sets the y coordinate */
  4066. get y(): number;
  4067. set y(value: number);
  4068. /** Gets or sets the z coordinate */
  4069. get z(): number;
  4070. set z(value: number);
  4071. /** Gets or sets the w coordinate */
  4072. get w(): number;
  4073. set w(value: number);
  4074. /**
  4075. * Creates a new Quaternion from the given floats
  4076. * @param x defines the first component (0 by default)
  4077. * @param y defines the second component (0 by default)
  4078. * @param z defines the third component (0 by default)
  4079. * @param w defines the fourth component (1.0 by default)
  4080. */
  4081. constructor(x?: number, y?: number, z?: number, w?: number);
  4082. /**
  4083. * Gets a string representation for the current quaternion
  4084. * @returns a string with the Quaternion coordinates
  4085. */
  4086. toString(): string;
  4087. /**
  4088. * Gets the class name of the quaternion
  4089. * @returns the string "Quaternion"
  4090. */
  4091. getClassName(): string;
  4092. /**
  4093. * Gets a hash code for this quaternion
  4094. * @returns the quaternion hash code
  4095. */
  4096. getHashCode(): number;
  4097. /**
  4098. * Copy the quaternion to an array
  4099. * @returns a new array populated with 4 elements from the quaternion coordinates
  4100. */
  4101. asArray(): number[];
  4102. /**
  4103. * Check if two quaternions are equals
  4104. * @param otherQuaternion defines the second operand
  4105. * @return true if the current quaternion and the given one coordinates are strictly equals
  4106. */
  4107. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4108. /**
  4109. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4110. * @param otherQuaternion defines the other quaternion
  4111. * @param epsilon defines the minimal distance to consider equality
  4112. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4113. */
  4114. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4115. /**
  4116. * Clone the current quaternion
  4117. * @returns a new quaternion copied from the current one
  4118. */
  4119. clone(): Quaternion;
  4120. /**
  4121. * Copy a quaternion to the current one
  4122. * @param other defines the other quaternion
  4123. * @returns the updated current quaternion
  4124. */
  4125. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4126. /**
  4127. * Updates the current quaternion with the given float coordinates
  4128. * @param x defines the x coordinate
  4129. * @param y defines the y coordinate
  4130. * @param z defines the z coordinate
  4131. * @param w defines the w coordinate
  4132. * @returns the updated current quaternion
  4133. */
  4134. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4135. /**
  4136. * Updates the current quaternion from the given float coordinates
  4137. * @param x defines the x coordinate
  4138. * @param y defines the y coordinate
  4139. * @param z defines the z coordinate
  4140. * @param w defines the w coordinate
  4141. * @returns the updated current quaternion
  4142. */
  4143. set(x: number, y: number, z: number, w: number): Quaternion;
  4144. /**
  4145. * Adds two quaternions
  4146. * @param other defines the second operand
  4147. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4148. */
  4149. add(other: DeepImmutable<Quaternion>): Quaternion;
  4150. /**
  4151. * Add a quaternion to the current one
  4152. * @param other defines the quaternion to add
  4153. * @returns the current quaternion
  4154. */
  4155. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4156. /**
  4157. * Subtract two quaternions
  4158. * @param other defines the second operand
  4159. * @returns a new quaternion as the subtraction result of the given one from the current one
  4160. */
  4161. subtract(other: Quaternion): Quaternion;
  4162. /**
  4163. * Multiplies the current quaternion by a scale factor
  4164. * @param value defines the scale factor
  4165. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4166. */
  4167. scale(value: number): Quaternion;
  4168. /**
  4169. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4170. * @param scale defines the scale factor
  4171. * @param result defines the Quaternion object where to store the result
  4172. * @returns the unmodified current quaternion
  4173. */
  4174. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4175. /**
  4176. * Multiplies in place the current quaternion by a scale factor
  4177. * @param value defines the scale factor
  4178. * @returns the current modified quaternion
  4179. */
  4180. scaleInPlace(value: number): Quaternion;
  4181. /**
  4182. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4183. * @param scale defines the scale factor
  4184. * @param result defines the Quaternion object where to store the result
  4185. * @returns the unmodified current quaternion
  4186. */
  4187. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4188. /**
  4189. * Multiplies two quaternions
  4190. * @param q1 defines the second operand
  4191. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4192. */
  4193. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4194. /**
  4195. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4196. * @param q1 defines the second operand
  4197. * @param result defines the target quaternion
  4198. * @returns the current quaternion
  4199. */
  4200. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4201. /**
  4202. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4203. * @param q1 defines the second operand
  4204. * @returns the currentupdated quaternion
  4205. */
  4206. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4207. /**
  4208. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4209. * @param ref defines the target quaternion
  4210. * @returns the current quaternion
  4211. */
  4212. conjugateToRef(ref: Quaternion): Quaternion;
  4213. /**
  4214. * Conjugates in place (1-q) the current quaternion
  4215. * @returns the current updated quaternion
  4216. */
  4217. conjugateInPlace(): Quaternion;
  4218. /**
  4219. * Conjugates in place (1-q) the current quaternion
  4220. * @returns a new quaternion
  4221. */
  4222. conjugate(): Quaternion;
  4223. /**
  4224. * Gets length of current quaternion
  4225. * @returns the quaternion length (float)
  4226. */
  4227. length(): number;
  4228. /**
  4229. * Normalize in place the current quaternion
  4230. * @returns the current updated quaternion
  4231. */
  4232. normalize(): Quaternion;
  4233. /**
  4234. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4235. * @param order is a reserved parameter and is ignored for now
  4236. * @returns a new Vector3 containing the Euler angles
  4237. */
  4238. toEulerAngles(order?: string): Vector3;
  4239. /**
  4240. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4241. * @param result defines the vector which will be filled with the Euler angles
  4242. * @returns the current unchanged quaternion
  4243. */
  4244. toEulerAnglesToRef(result: Vector3): Quaternion;
  4245. /**
  4246. * Updates the given rotation matrix with the current quaternion values
  4247. * @param result defines the target matrix
  4248. * @returns the current unchanged quaternion
  4249. */
  4250. toRotationMatrix(result: Matrix): Quaternion;
  4251. /**
  4252. * Updates the current quaternion from the given rotation matrix values
  4253. * @param matrix defines the source matrix
  4254. * @returns the current updated quaternion
  4255. */
  4256. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4257. /**
  4258. * Creates a new quaternion from a rotation matrix
  4259. * @param matrix defines the source matrix
  4260. * @returns a new quaternion created from the given rotation matrix values
  4261. */
  4262. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4263. /**
  4264. * Updates the given quaternion with the given rotation matrix values
  4265. * @param matrix defines the source matrix
  4266. * @param result defines the target quaternion
  4267. */
  4268. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4269. /**
  4270. * Returns the dot product (float) between the quaternions "left" and "right"
  4271. * @param left defines the left operand
  4272. * @param right defines the right operand
  4273. * @returns the dot product
  4274. */
  4275. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4276. /**
  4277. * Checks if the two quaternions are close to each other
  4278. * @param quat0 defines the first quaternion to check
  4279. * @param quat1 defines the second quaternion to check
  4280. * @returns true if the two quaternions are close to each other
  4281. */
  4282. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4283. /**
  4284. * Creates an empty quaternion
  4285. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4286. */
  4287. static Zero(): Quaternion;
  4288. /**
  4289. * Inverse a given quaternion
  4290. * @param q defines the source quaternion
  4291. * @returns a new quaternion as the inverted current quaternion
  4292. */
  4293. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4294. /**
  4295. * Inverse a given quaternion
  4296. * @param q defines the source quaternion
  4297. * @param result the quaternion the result will be stored in
  4298. * @returns the result quaternion
  4299. */
  4300. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4301. /**
  4302. * Creates an identity quaternion
  4303. * @returns the identity quaternion
  4304. */
  4305. static Identity(): Quaternion;
  4306. /**
  4307. * Gets a boolean indicating if the given quaternion is identity
  4308. * @param quaternion defines the quaternion to check
  4309. * @returns true if the quaternion is identity
  4310. */
  4311. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4312. /**
  4313. * Creates a quaternion from a rotation around an axis
  4314. * @param axis defines the axis to use
  4315. * @param angle defines the angle to use
  4316. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4317. */
  4318. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4319. /**
  4320. * Creates a rotation around an axis and stores it into the given quaternion
  4321. * @param axis defines the axis to use
  4322. * @param angle defines the angle to use
  4323. * @param result defines the target quaternion
  4324. * @returns the target quaternion
  4325. */
  4326. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4327. /**
  4328. * Creates a new quaternion from data stored into an array
  4329. * @param array defines the data source
  4330. * @param offset defines the offset in the source array where the data starts
  4331. * @returns a new quaternion
  4332. */
  4333. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4334. /**
  4335. * Updates the given quaternion "result" from the starting index of the given array.
  4336. * @param array the array to pull values from
  4337. * @param offset the offset into the array to start at
  4338. * @param result the quaternion to store the result in
  4339. */
  4340. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4341. /**
  4342. * Create a quaternion from Euler rotation angles
  4343. * @param x Pitch
  4344. * @param y Yaw
  4345. * @param z Roll
  4346. * @returns the new Quaternion
  4347. */
  4348. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4349. /**
  4350. * Updates a quaternion from Euler rotation angles
  4351. * @param x Pitch
  4352. * @param y Yaw
  4353. * @param z Roll
  4354. * @param result the quaternion to store the result
  4355. * @returns the updated quaternion
  4356. */
  4357. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4358. /**
  4359. * Create a quaternion from Euler rotation vector
  4360. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4361. * @returns the new Quaternion
  4362. */
  4363. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4364. /**
  4365. * Updates a quaternion from Euler rotation vector
  4366. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4367. * @param result the quaternion to store the result
  4368. * @returns the updated quaternion
  4369. */
  4370. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4371. /**
  4372. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4373. * @param yaw defines the rotation around Y axis
  4374. * @param pitch defines the rotation around X axis
  4375. * @param roll defines the rotation around Z axis
  4376. * @returns the new quaternion
  4377. */
  4378. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4379. /**
  4380. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4381. * @param yaw defines the rotation around Y axis
  4382. * @param pitch defines the rotation around X axis
  4383. * @param roll defines the rotation around Z axis
  4384. * @param result defines the target quaternion
  4385. */
  4386. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4387. /**
  4388. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4389. * @param alpha defines the rotation around first axis
  4390. * @param beta defines the rotation around second axis
  4391. * @param gamma defines the rotation around third axis
  4392. * @returns the new quaternion
  4393. */
  4394. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4395. /**
  4396. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4397. * @param alpha defines the rotation around first axis
  4398. * @param beta defines the rotation around second axis
  4399. * @param gamma defines the rotation around third axis
  4400. * @param result defines the target quaternion
  4401. */
  4402. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4403. /**
  4404. * 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)
  4405. * @param axis1 defines the first axis
  4406. * @param axis2 defines the second axis
  4407. * @param axis3 defines the third axis
  4408. * @returns the new quaternion
  4409. */
  4410. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4411. /**
  4412. * 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
  4413. * @param axis1 defines the first axis
  4414. * @param axis2 defines the second axis
  4415. * @param axis3 defines the third axis
  4416. * @param ref defines the target quaternion
  4417. */
  4418. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4419. /**
  4420. * Interpolates between two quaternions
  4421. * @param left defines first quaternion
  4422. * @param right defines second quaternion
  4423. * @param amount defines the gradient to use
  4424. * @returns the new interpolated quaternion
  4425. */
  4426. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4427. /**
  4428. * Interpolates between two quaternions and stores it into a target quaternion
  4429. * @param left defines first quaternion
  4430. * @param right defines second quaternion
  4431. * @param amount defines the gradient to use
  4432. * @param result defines the target quaternion
  4433. */
  4434. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4435. /**
  4436. * Interpolate between two quaternions using Hermite interpolation
  4437. * @param value1 defines first quaternion
  4438. * @param tangent1 defines the incoming tangent
  4439. * @param value2 defines second quaternion
  4440. * @param tangent2 defines the outgoing tangent
  4441. * @param amount defines the target quaternion
  4442. * @returns the new interpolated quaternion
  4443. */
  4444. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4445. }
  4446. /**
  4447. * Class used to store matrix data (4x4)
  4448. */
  4449. export class Matrix {
  4450. /**
  4451. * Gets the precision of matrix computations
  4452. */
  4453. static get Use64Bits(): boolean;
  4454. private static _updateFlagSeed;
  4455. private static _identityReadOnly;
  4456. private _isIdentity;
  4457. private _isIdentityDirty;
  4458. private _isIdentity3x2;
  4459. private _isIdentity3x2Dirty;
  4460. /**
  4461. * Gets the update flag of the matrix which is an unique number for the matrix.
  4462. * It will be incremented every time the matrix data change.
  4463. * You can use it to speed the comparison between two versions of the same matrix.
  4464. */
  4465. updateFlag: number;
  4466. private readonly _m;
  4467. /**
  4468. * Gets the internal data of the matrix
  4469. */
  4470. get m(): DeepImmutable<Float32Array | Array<number>>;
  4471. /** @hidden */
  4472. _markAsUpdated(): void;
  4473. /** @hidden */
  4474. private _updateIdentityStatus;
  4475. /**
  4476. * Creates an empty matrix (filled with zeros)
  4477. */
  4478. constructor();
  4479. /**
  4480. * Check if the current matrix is identity
  4481. * @returns true is the matrix is the identity matrix
  4482. */
  4483. isIdentity(): boolean;
  4484. /**
  4485. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4486. * @returns true is the matrix is the identity matrix
  4487. */
  4488. isIdentityAs3x2(): boolean;
  4489. /**
  4490. * Gets the determinant of the matrix
  4491. * @returns the matrix determinant
  4492. */
  4493. determinant(): number;
  4494. /**
  4495. * Returns the matrix as a Float32Array or Array<number>
  4496. * @returns the matrix underlying array
  4497. */
  4498. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4499. /**
  4500. * Returns the matrix as a Float32Array or Array<number>
  4501. * @returns the matrix underlying array.
  4502. */
  4503. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4504. /**
  4505. * Inverts the current matrix in place
  4506. * @returns the current inverted matrix
  4507. */
  4508. invert(): Matrix;
  4509. /**
  4510. * Sets all the matrix elements to zero
  4511. * @returns the current matrix
  4512. */
  4513. reset(): Matrix;
  4514. /**
  4515. * Adds the current matrix with a second one
  4516. * @param other defines the matrix to add
  4517. * @returns a new matrix as the addition of the current matrix and the given one
  4518. */
  4519. add(other: DeepImmutable<Matrix>): Matrix;
  4520. /**
  4521. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4522. * @param other defines the matrix to add
  4523. * @param result defines the target matrix
  4524. * @returns the current matrix
  4525. */
  4526. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4527. /**
  4528. * Adds in place the given matrix to the current matrix
  4529. * @param other defines the second operand
  4530. * @returns the current updated matrix
  4531. */
  4532. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4533. /**
  4534. * Sets the given matrix to the current inverted Matrix
  4535. * @param other defines the target matrix
  4536. * @returns the unmodified current matrix
  4537. */
  4538. invertToRef(other: Matrix): Matrix;
  4539. /**
  4540. * add a value at the specified position in the current Matrix
  4541. * @param index the index of the value within the matrix. between 0 and 15.
  4542. * @param value the value to be added
  4543. * @returns the current updated matrix
  4544. */
  4545. addAtIndex(index: number, value: number): Matrix;
  4546. /**
  4547. * mutiply the specified position in the current Matrix by a value
  4548. * @param index the index of the value within the matrix. between 0 and 15.
  4549. * @param value the value to be added
  4550. * @returns the current updated matrix
  4551. */
  4552. multiplyAtIndex(index: number, value: number): Matrix;
  4553. /**
  4554. * Inserts the translation vector (using 3 floats) in the current matrix
  4555. * @param x defines the 1st component of the translation
  4556. * @param y defines the 2nd component of the translation
  4557. * @param z defines the 3rd component of the translation
  4558. * @returns the current updated matrix
  4559. */
  4560. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4561. /**
  4562. * Adds the translation vector (using 3 floats) in the current matrix
  4563. * @param x defines the 1st component of the translation
  4564. * @param y defines the 2nd component of the translation
  4565. * @param z defines the 3rd component of the translation
  4566. * @returns the current updated matrix
  4567. */
  4568. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4569. /**
  4570. * Inserts the translation vector in the current matrix
  4571. * @param vector3 defines the translation to insert
  4572. * @returns the current updated matrix
  4573. */
  4574. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4575. /**
  4576. * Gets the translation value of the current matrix
  4577. * @returns a new Vector3 as the extracted translation from the matrix
  4578. */
  4579. getTranslation(): Vector3;
  4580. /**
  4581. * Fill a Vector3 with the extracted translation from the matrix
  4582. * @param result defines the Vector3 where to store the translation
  4583. * @returns the current matrix
  4584. */
  4585. getTranslationToRef(result: Vector3): Matrix;
  4586. /**
  4587. * Remove rotation and scaling part from the matrix
  4588. * @returns the updated matrix
  4589. */
  4590. removeRotationAndScaling(): Matrix;
  4591. /**
  4592. * Multiply two matrices
  4593. * @param other defines the second operand
  4594. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4595. */
  4596. multiply(other: DeepImmutable<Matrix>): Matrix;
  4597. /**
  4598. * Copy the current matrix from the given one
  4599. * @param other defines the source matrix
  4600. * @returns the current updated matrix
  4601. */
  4602. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4603. /**
  4604. * Populates the given array from the starting index with the current matrix values
  4605. * @param array defines the target array
  4606. * @param offset defines the offset in the target array where to start storing values
  4607. * @returns the current matrix
  4608. */
  4609. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4610. /**
  4611. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4612. * @param other defines the second operand
  4613. * @param result defines the matrix where to store the multiplication
  4614. * @returns the current matrix
  4615. */
  4616. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4617. /**
  4618. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4619. * @param other defines the second operand
  4620. * @param result defines the array where to store the multiplication
  4621. * @param offset defines the offset in the target array where to start storing values
  4622. * @returns the current matrix
  4623. */
  4624. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4625. /**
  4626. * Check equality between this matrix and a second one
  4627. * @param value defines the second matrix to compare
  4628. * @returns true is the current matrix and the given one values are strictly equal
  4629. */
  4630. equals(value: DeepImmutable<Matrix>): boolean;
  4631. /**
  4632. * Clone the current matrix
  4633. * @returns a new matrix from the current matrix
  4634. */
  4635. clone(): Matrix;
  4636. /**
  4637. * Returns the name of the current matrix class
  4638. * @returns the string "Matrix"
  4639. */
  4640. getClassName(): string;
  4641. /**
  4642. * Gets the hash code of the current matrix
  4643. * @returns the hash code
  4644. */
  4645. getHashCode(): number;
  4646. /**
  4647. * Decomposes the current Matrix into a translation, rotation and scaling components
  4648. * @param scale defines the scale vector3 given as a reference to update
  4649. * @param rotation defines the rotation quaternion given as a reference to update
  4650. * @param translation defines the translation vector3 given as a reference to update
  4651. * @returns true if operation was successful
  4652. */
  4653. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4654. /**
  4655. * Gets specific row of the matrix
  4656. * @param index defines the number of the row to get
  4657. * @returns the index-th row of the current matrix as a new Vector4
  4658. */
  4659. getRow(index: number): Nullable<Vector4>;
  4660. /**
  4661. * Sets the index-th row of the current matrix to the vector4 values
  4662. * @param index defines the number of the row to set
  4663. * @param row defines the target vector4
  4664. * @returns the updated current matrix
  4665. */
  4666. setRow(index: number, row: Vector4): Matrix;
  4667. /**
  4668. * Compute the transpose of the matrix
  4669. * @returns the new transposed matrix
  4670. */
  4671. transpose(): Matrix;
  4672. /**
  4673. * Compute the transpose of the matrix and store it in a given matrix
  4674. * @param result defines the target matrix
  4675. * @returns the current matrix
  4676. */
  4677. transposeToRef(result: Matrix): Matrix;
  4678. /**
  4679. * Sets the index-th row of the current matrix with the given 4 x float values
  4680. * @param index defines the row index
  4681. * @param x defines the x component to set
  4682. * @param y defines the y component to set
  4683. * @param z defines the z component to set
  4684. * @param w defines the w component to set
  4685. * @returns the updated current matrix
  4686. */
  4687. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4688. /**
  4689. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4690. * @param scale defines the scale factor
  4691. * @returns a new matrix
  4692. */
  4693. scale(scale: number): Matrix;
  4694. /**
  4695. * Scale the current matrix values by a factor to a given result matrix
  4696. * @param scale defines the scale factor
  4697. * @param result defines the matrix to store the result
  4698. * @returns the current matrix
  4699. */
  4700. scaleToRef(scale: number, result: Matrix): Matrix;
  4701. /**
  4702. * Scale the current matrix values by a factor and add the result to a given matrix
  4703. * @param scale defines the scale factor
  4704. * @param result defines the Matrix to store the result
  4705. * @returns the current matrix
  4706. */
  4707. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4708. /**
  4709. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4710. * @param ref matrix to store the result
  4711. */
  4712. toNormalMatrix(ref: Matrix): void;
  4713. /**
  4714. * Gets only rotation part of the current matrix
  4715. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4716. */
  4717. getRotationMatrix(): Matrix;
  4718. /**
  4719. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4720. * @param result defines the target matrix to store data to
  4721. * @returns the current matrix
  4722. */
  4723. getRotationMatrixToRef(result: Matrix): Matrix;
  4724. /**
  4725. * Toggles model matrix from being right handed to left handed in place and vice versa
  4726. */
  4727. toggleModelMatrixHandInPlace(): void;
  4728. /**
  4729. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4730. */
  4731. toggleProjectionMatrixHandInPlace(): void;
  4732. /**
  4733. * Creates a matrix from an array
  4734. * @param array defines the source array
  4735. * @param offset defines an offset in the source array
  4736. * @returns a new Matrix set from the starting index of the given array
  4737. */
  4738. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4739. /**
  4740. * Copy the content of an array into a given matrix
  4741. * @param array defines the source array
  4742. * @param offset defines an offset in the source array
  4743. * @param result defines the target matrix
  4744. */
  4745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4746. /**
  4747. * Stores an array into a matrix after having multiplied each component by a given factor
  4748. * @param array defines the source array
  4749. * @param offset defines the offset in the source array
  4750. * @param scale defines the scaling factor
  4751. * @param result defines the target matrix
  4752. */
  4753. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4754. /**
  4755. * Gets an identity matrix that must not be updated
  4756. */
  4757. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4758. /**
  4759. * Stores a list of values (16) inside a given matrix
  4760. * @param initialM11 defines 1st value of 1st row
  4761. * @param initialM12 defines 2nd value of 1st row
  4762. * @param initialM13 defines 3rd value of 1st row
  4763. * @param initialM14 defines 4th value of 1st row
  4764. * @param initialM21 defines 1st value of 2nd row
  4765. * @param initialM22 defines 2nd value of 2nd row
  4766. * @param initialM23 defines 3rd value of 2nd row
  4767. * @param initialM24 defines 4th value of 2nd row
  4768. * @param initialM31 defines 1st value of 3rd row
  4769. * @param initialM32 defines 2nd value of 3rd row
  4770. * @param initialM33 defines 3rd value of 3rd row
  4771. * @param initialM34 defines 4th value of 3rd row
  4772. * @param initialM41 defines 1st value of 4th row
  4773. * @param initialM42 defines 2nd value of 4th row
  4774. * @param initialM43 defines 3rd value of 4th row
  4775. * @param initialM44 defines 4th value of 4th row
  4776. * @param result defines the target matrix
  4777. */
  4778. 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;
  4779. /**
  4780. * Creates new matrix from a list of values (16)
  4781. * @param initialM11 defines 1st value of 1st row
  4782. * @param initialM12 defines 2nd value of 1st row
  4783. * @param initialM13 defines 3rd value of 1st row
  4784. * @param initialM14 defines 4th value of 1st row
  4785. * @param initialM21 defines 1st value of 2nd row
  4786. * @param initialM22 defines 2nd value of 2nd row
  4787. * @param initialM23 defines 3rd value of 2nd row
  4788. * @param initialM24 defines 4th value of 2nd row
  4789. * @param initialM31 defines 1st value of 3rd row
  4790. * @param initialM32 defines 2nd value of 3rd row
  4791. * @param initialM33 defines 3rd value of 3rd row
  4792. * @param initialM34 defines 4th value of 3rd row
  4793. * @param initialM41 defines 1st value of 4th row
  4794. * @param initialM42 defines 2nd value of 4th row
  4795. * @param initialM43 defines 3rd value of 4th row
  4796. * @param initialM44 defines 4th value of 4th row
  4797. * @returns the new matrix
  4798. */
  4799. 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;
  4800. /**
  4801. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4802. * @param scale defines the scale vector3
  4803. * @param rotation defines the rotation quaternion
  4804. * @param translation defines the translation vector3
  4805. * @returns a new matrix
  4806. */
  4807. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4808. /**
  4809. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4810. * @param scale defines the scale vector3
  4811. * @param rotation defines the rotation quaternion
  4812. * @param translation defines the translation vector3
  4813. * @param result defines the target matrix
  4814. */
  4815. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4816. /**
  4817. * Creates a new identity matrix
  4818. * @returns a new identity matrix
  4819. */
  4820. static Identity(): Matrix;
  4821. /**
  4822. * Creates a new identity matrix and stores the result in a given matrix
  4823. * @param result defines the target matrix
  4824. */
  4825. static IdentityToRef(result: Matrix): void;
  4826. /**
  4827. * Creates a new zero matrix
  4828. * @returns a new zero matrix
  4829. */
  4830. static Zero(): Matrix;
  4831. /**
  4832. * Creates a new rotation matrix for "angle" radians around the X axis
  4833. * @param angle defines the angle (in radians) to use
  4834. * @return the new matrix
  4835. */
  4836. static RotationX(angle: number): Matrix;
  4837. /**
  4838. * Creates a new matrix as the invert of a given matrix
  4839. * @param source defines the source matrix
  4840. * @returns the new matrix
  4841. */
  4842. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4843. /**
  4844. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4845. * @param angle defines the angle (in radians) to use
  4846. * @param result defines the target matrix
  4847. */
  4848. static RotationXToRef(angle: number, result: Matrix): void;
  4849. /**
  4850. * Creates a new rotation matrix for "angle" radians around the Y axis
  4851. * @param angle defines the angle (in radians) to use
  4852. * @return the new matrix
  4853. */
  4854. static RotationY(angle: number): Matrix;
  4855. /**
  4856. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4857. * @param angle defines the angle (in radians) to use
  4858. * @param result defines the target matrix
  4859. */
  4860. static RotationYToRef(angle: number, result: Matrix): void;
  4861. /**
  4862. * Creates a new rotation matrix for "angle" radians around the Z axis
  4863. * @param angle defines the angle (in radians) to use
  4864. * @return the new matrix
  4865. */
  4866. static RotationZ(angle: number): Matrix;
  4867. /**
  4868. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4869. * @param angle defines the angle (in radians) to use
  4870. * @param result defines the target matrix
  4871. */
  4872. static RotationZToRef(angle: number, result: Matrix): void;
  4873. /**
  4874. * Creates a new rotation matrix for "angle" radians around the given axis
  4875. * @param axis defines the axis to use
  4876. * @param angle defines the angle (in radians) to use
  4877. * @return the new matrix
  4878. */
  4879. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4880. /**
  4881. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4882. * @param axis defines the axis to use
  4883. * @param angle defines the angle (in radians) to use
  4884. * @param result defines the target matrix
  4885. */
  4886. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4887. /**
  4888. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4889. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4890. * @param from defines the vector to align
  4891. * @param to defines the vector to align to
  4892. * @param result defines the target matrix
  4893. */
  4894. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4895. /**
  4896. * Creates a rotation matrix
  4897. * @param yaw defines the yaw angle in radians (Y axis)
  4898. * @param pitch defines the pitch angle in radians (X axis)
  4899. * @param roll defines the roll angle in radians (Z axis)
  4900. * @returns the new rotation matrix
  4901. */
  4902. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4903. /**
  4904. * Creates a rotation matrix and stores it in a given matrix
  4905. * @param yaw defines the yaw angle in radians (Y axis)
  4906. * @param pitch defines the pitch angle in radians (X axis)
  4907. * @param roll defines the roll angle in radians (Z axis)
  4908. * @param result defines the target matrix
  4909. */
  4910. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4911. /**
  4912. * Creates a scaling matrix
  4913. * @param x defines the scale factor on X axis
  4914. * @param y defines the scale factor on Y axis
  4915. * @param z defines the scale factor on Z axis
  4916. * @returns the new matrix
  4917. */
  4918. static Scaling(x: number, y: number, z: number): Matrix;
  4919. /**
  4920. * Creates a scaling matrix and stores it in a given matrix
  4921. * @param x defines the scale factor on X axis
  4922. * @param y defines the scale factor on Y axis
  4923. * @param z defines the scale factor on Z axis
  4924. * @param result defines the target matrix
  4925. */
  4926. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4927. /**
  4928. * Creates a translation matrix
  4929. * @param x defines the translation on X axis
  4930. * @param y defines the translation on Y axis
  4931. * @param z defines the translationon Z axis
  4932. * @returns the new matrix
  4933. */
  4934. static Translation(x: number, y: number, z: number): Matrix;
  4935. /**
  4936. * Creates a translation matrix and stores it in a given matrix
  4937. * @param x defines the translation on X axis
  4938. * @param y defines the translation on Y axis
  4939. * @param z defines the translationon Z axis
  4940. * @param result defines the target matrix
  4941. */
  4942. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4943. /**
  4944. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4945. * @param startValue defines the start value
  4946. * @param endValue defines the end value
  4947. * @param gradient defines the gradient factor
  4948. * @returns the new matrix
  4949. */
  4950. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4951. /**
  4952. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4953. * @param startValue defines the start value
  4954. * @param endValue defines the end value
  4955. * @param gradient defines the gradient factor
  4956. * @param result defines the Matrix object where to store data
  4957. */
  4958. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4959. /**
  4960. * Builds a new matrix whose values are computed by:
  4961. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4962. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4963. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4964. * @param startValue defines the first matrix
  4965. * @param endValue defines the second matrix
  4966. * @param gradient defines the gradient between the two matrices
  4967. * @returns the new matrix
  4968. */
  4969. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4970. /**
  4971. * Update a matrix to values which are computed by:
  4972. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4973. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4974. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4975. * @param startValue defines the first matrix
  4976. * @param endValue defines the second matrix
  4977. * @param gradient defines the gradient between the two matrices
  4978. * @param result defines the target matrix
  4979. */
  4980. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4981. /**
  4982. * 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"
  4983. * This function works in left handed mode
  4984. * @param eye defines the final position of the entity
  4985. * @param target defines where the entity should look at
  4986. * @param up defines the up vector for the entity
  4987. * @returns the new matrix
  4988. */
  4989. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4990. /**
  4991. * 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".
  4992. * This function works in left handed mode
  4993. * @param eye defines the final position of the entity
  4994. * @param target defines where the entity should look at
  4995. * @param up defines the up vector for the entity
  4996. * @param result defines the target matrix
  4997. */
  4998. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4999. /**
  5000. * 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"
  5001. * This function works in right handed mode
  5002. * @param eye defines the final position of the entity
  5003. * @param target defines where the entity should look at
  5004. * @param up defines the up vector for the entity
  5005. * @returns the new matrix
  5006. */
  5007. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5008. /**
  5009. * 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".
  5010. * This function works in right 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. * @param result defines the target matrix
  5015. */
  5016. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5017. /**
  5018. * Create a left-handed orthographic projection matrix
  5019. * @param width defines the viewport width
  5020. * @param height defines the viewport height
  5021. * @param znear defines the near clip plane
  5022. * @param zfar defines the far clip plane
  5023. * @returns a new matrix as a left-handed orthographic projection matrix
  5024. */
  5025. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5026. /**
  5027. * Store a left-handed orthographic projection to a given matrix
  5028. * @param width defines the viewport width
  5029. * @param height defines the viewport height
  5030. * @param znear defines the near clip plane
  5031. * @param zfar defines the far clip plane
  5032. * @param result defines the target matrix
  5033. */
  5034. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5035. /**
  5036. * Create a left-handed orthographic projection matrix
  5037. * @param left defines the viewport left coordinate
  5038. * @param right defines the viewport right coordinate
  5039. * @param bottom defines the viewport bottom coordinate
  5040. * @param top defines the viewport top coordinate
  5041. * @param znear defines the near clip plane
  5042. * @param zfar defines the far clip plane
  5043. * @returns a new matrix as a left-handed orthographic projection matrix
  5044. */
  5045. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5046. /**
  5047. * Stores a left-handed orthographic projection into a given matrix
  5048. * @param left defines the viewport left coordinate
  5049. * @param right defines the viewport right coordinate
  5050. * @param bottom defines the viewport bottom coordinate
  5051. * @param top defines the viewport top coordinate
  5052. * @param znear defines the near clip plane
  5053. * @param zfar defines the far clip plane
  5054. * @param result defines the target matrix
  5055. */
  5056. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5057. /**
  5058. * Creates a right-handed orthographic projection matrix
  5059. * @param left defines the viewport left coordinate
  5060. * @param right defines the viewport right coordinate
  5061. * @param bottom defines the viewport bottom coordinate
  5062. * @param top defines the viewport top coordinate
  5063. * @param znear defines the near clip plane
  5064. * @param zfar defines the far clip plane
  5065. * @returns a new matrix as a right-handed orthographic projection matrix
  5066. */
  5067. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5068. /**
  5069. * Stores a right-handed orthographic projection into a given matrix
  5070. * @param left defines the viewport left coordinate
  5071. * @param right defines the viewport right coordinate
  5072. * @param bottom defines the viewport bottom coordinate
  5073. * @param top defines the viewport top coordinate
  5074. * @param znear defines the near clip plane
  5075. * @param zfar defines the far clip plane
  5076. * @param result defines the target matrix
  5077. */
  5078. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5079. /**
  5080. * Creates a left-handed perspective projection matrix
  5081. * @param width defines the viewport width
  5082. * @param height defines the viewport height
  5083. * @param znear defines the near clip plane
  5084. * @param zfar defines the far clip plane
  5085. * @returns a new matrix as a left-handed perspective projection matrix
  5086. */
  5087. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5088. /**
  5089. * Creates a left-handed perspective projection matrix
  5090. * @param fov defines the horizontal field of view
  5091. * @param aspect defines the aspect ratio
  5092. * @param znear defines the near clip plane
  5093. * @param zfar defines the far clip plane
  5094. * @returns a new matrix as a left-handed perspective projection matrix
  5095. */
  5096. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5097. /**
  5098. * Stores a left-handed perspective projection into a given matrix
  5099. * @param fov defines the horizontal field of view
  5100. * @param aspect defines the aspect ratio
  5101. * @param znear defines the near clip plane
  5102. * @param zfar defines the far clip plane
  5103. * @param result defines the target matrix
  5104. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5105. */
  5106. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5107. /**
  5108. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5109. * @param fov defines the horizontal field of view
  5110. * @param aspect defines the aspect ratio
  5111. * @param znear defines the near clip plane
  5112. * @param zfar not used as infinity is used as far clip
  5113. * @param result defines the target matrix
  5114. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5115. */
  5116. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5117. /**
  5118. * Creates a right-handed perspective projection matrix
  5119. * @param fov defines the horizontal field of view
  5120. * @param aspect defines the aspect ratio
  5121. * @param znear defines the near clip plane
  5122. * @param zfar defines the far clip plane
  5123. * @returns a new matrix as a right-handed perspective projection matrix
  5124. */
  5125. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5126. /**
  5127. * Stores a right-handed perspective projection into a given matrix
  5128. * @param fov defines the horizontal field of view
  5129. * @param aspect defines the aspect ratio
  5130. * @param znear defines the near clip plane
  5131. * @param zfar defines the far clip plane
  5132. * @param result defines the target matrix
  5133. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5134. */
  5135. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5136. /**
  5137. * Stores a right-handed perspective projection into a given matrix
  5138. * @param fov defines the horizontal field of view
  5139. * @param aspect defines the aspect ratio
  5140. * @param znear defines the near clip plane
  5141. * @param zfar not used as infinity is used as far clip
  5142. * @param result defines the target matrix
  5143. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5144. */
  5145. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5146. /**
  5147. * Stores a perspective projection for WebVR info a given matrix
  5148. * @param fov defines the field of view
  5149. * @param znear defines the near clip plane
  5150. * @param zfar defines the far clip plane
  5151. * @param result defines the target matrix
  5152. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5153. */
  5154. static PerspectiveFovWebVRToRef(fov: {
  5155. upDegrees: number;
  5156. downDegrees: number;
  5157. leftDegrees: number;
  5158. rightDegrees: number;
  5159. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5160. /**
  5161. * Computes a complete transformation matrix
  5162. * @param viewport defines the viewport to use
  5163. * @param world defines the world matrix
  5164. * @param view defines the view matrix
  5165. * @param projection defines the projection matrix
  5166. * @param zmin defines the near clip plane
  5167. * @param zmax defines the far clip plane
  5168. * @returns the transformation matrix
  5169. */
  5170. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5171. /**
  5172. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5173. * @param matrix defines the matrix to use
  5174. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5175. */
  5176. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5177. /**
  5178. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5179. * @param matrix defines the matrix to use
  5180. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5181. */
  5182. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5183. /**
  5184. * Compute the transpose of a given matrix
  5185. * @param matrix defines the matrix to transpose
  5186. * @returns the new matrix
  5187. */
  5188. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5189. /**
  5190. * Compute the transpose of a matrix and store it in a target matrix
  5191. * @param matrix defines the matrix to transpose
  5192. * @param result defines the target matrix
  5193. */
  5194. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5195. /**
  5196. * Computes a reflection matrix from a plane
  5197. * @param plane defines the reflection plane
  5198. * @returns a new matrix
  5199. */
  5200. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5201. /**
  5202. * Computes a reflection matrix from a plane
  5203. * @param plane defines the reflection plane
  5204. * @param result defines the target matrix
  5205. */
  5206. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5207. /**
  5208. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5209. * @param xaxis defines the value of the 1st axis
  5210. * @param yaxis defines the value of the 2nd axis
  5211. * @param zaxis defines the value of the 3rd axis
  5212. * @param result defines the target matrix
  5213. */
  5214. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5215. /**
  5216. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5217. * @param quat defines the quaternion to use
  5218. * @param result defines the target matrix
  5219. */
  5220. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5221. }
  5222. /**
  5223. * @hidden
  5224. */
  5225. export class TmpVectors {
  5226. static Vector2: Vector2[];
  5227. static Vector3: Vector3[];
  5228. static Vector4: Vector4[];
  5229. static Quaternion: Quaternion[];
  5230. static Matrix: Matrix[];
  5231. }
  5232. }
  5233. declare module BABYLON {
  5234. /**
  5235. * Defines potential orientation for back face culling
  5236. */
  5237. export enum Orientation {
  5238. /**
  5239. * Clockwise
  5240. */
  5241. CW = 0,
  5242. /** Counter clockwise */
  5243. CCW = 1
  5244. }
  5245. /** Class used to represent a Bezier curve */
  5246. export class BezierCurve {
  5247. /**
  5248. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5249. * @param t defines the time
  5250. * @param x1 defines the left coordinate on X axis
  5251. * @param y1 defines the left coordinate on Y axis
  5252. * @param x2 defines the right coordinate on X axis
  5253. * @param y2 defines the right coordinate on Y axis
  5254. * @returns the interpolated value
  5255. */
  5256. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5257. }
  5258. /**
  5259. * Defines angle representation
  5260. */
  5261. export class Angle {
  5262. private _radians;
  5263. /**
  5264. * Creates an Angle object of "radians" radians (float).
  5265. * @param radians the angle in radians
  5266. */
  5267. constructor(radians: number);
  5268. /**
  5269. * Get value in degrees
  5270. * @returns the Angle value in degrees (float)
  5271. */
  5272. degrees(): number;
  5273. /**
  5274. * Get value in radians
  5275. * @returns the Angle value in radians (float)
  5276. */
  5277. radians(): number;
  5278. /**
  5279. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5280. * @param a defines first point as the origin
  5281. * @param b defines point
  5282. * @returns a new Angle
  5283. */
  5284. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5285. /**
  5286. * Gets a new Angle object from the given float in radians
  5287. * @param radians defines the angle value in radians
  5288. * @returns a new Angle
  5289. */
  5290. static FromRadians(radians: number): Angle;
  5291. /**
  5292. * Gets a new Angle object from the given float in degrees
  5293. * @param degrees defines the angle value in degrees
  5294. * @returns a new Angle
  5295. */
  5296. static FromDegrees(degrees: number): Angle;
  5297. }
  5298. /**
  5299. * This represents an arc in a 2d space.
  5300. */
  5301. export class Arc2 {
  5302. /** Defines the start point of the arc */
  5303. startPoint: Vector2;
  5304. /** Defines the mid point of the arc */
  5305. midPoint: Vector2;
  5306. /** Defines the end point of the arc */
  5307. endPoint: Vector2;
  5308. /**
  5309. * Defines the center point of the arc.
  5310. */
  5311. centerPoint: Vector2;
  5312. /**
  5313. * Defines the radius of the arc.
  5314. */
  5315. radius: number;
  5316. /**
  5317. * Defines the angle of the arc (from mid point to end point).
  5318. */
  5319. angle: Angle;
  5320. /**
  5321. * Defines the start angle of the arc (from start point to middle point).
  5322. */
  5323. startAngle: Angle;
  5324. /**
  5325. * Defines the orientation of the arc (clock wise/counter clock wise).
  5326. */
  5327. orientation: Orientation;
  5328. /**
  5329. * Creates an Arc object from the three given points : start, middle and end.
  5330. * @param startPoint Defines the start point of the arc
  5331. * @param midPoint Defines the midlle point of the arc
  5332. * @param endPoint Defines the end point of the arc
  5333. */
  5334. constructor(
  5335. /** Defines the start point of the arc */
  5336. startPoint: Vector2,
  5337. /** Defines the mid point of the arc */
  5338. midPoint: Vector2,
  5339. /** Defines the end point of the arc */
  5340. endPoint: Vector2);
  5341. }
  5342. /**
  5343. * Represents a 2D path made up of multiple 2D points
  5344. */
  5345. export class Path2 {
  5346. private _points;
  5347. private _length;
  5348. /**
  5349. * If the path start and end point are the same
  5350. */
  5351. closed: boolean;
  5352. /**
  5353. * Creates a Path2 object from the starting 2D coordinates x and y.
  5354. * @param x the starting points x value
  5355. * @param y the starting points y value
  5356. */
  5357. constructor(x: number, y: number);
  5358. /**
  5359. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5360. * @param x the added points x value
  5361. * @param y the added points y value
  5362. * @returns the updated Path2.
  5363. */
  5364. addLineTo(x: number, y: number): Path2;
  5365. /**
  5366. * 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.
  5367. * @param midX middle point x value
  5368. * @param midY middle point y value
  5369. * @param endX end point x value
  5370. * @param endY end point y value
  5371. * @param numberOfSegments (default: 36)
  5372. * @returns the updated Path2.
  5373. */
  5374. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5375. /**
  5376. * Closes the Path2.
  5377. * @returns the Path2.
  5378. */
  5379. close(): Path2;
  5380. /**
  5381. * Gets the sum of the distance between each sequential point in the path
  5382. * @returns the Path2 total length (float).
  5383. */
  5384. length(): number;
  5385. /**
  5386. * Gets the points which construct the path
  5387. * @returns the Path2 internal array of points.
  5388. */
  5389. getPoints(): Vector2[];
  5390. /**
  5391. * Retreives the point at the distance aways from the starting point
  5392. * @param normalizedLengthPosition the length along the path to retreive the point from
  5393. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5394. */
  5395. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5396. /**
  5397. * Creates a new path starting from an x and y position
  5398. * @param x starting x value
  5399. * @param y starting y value
  5400. * @returns a new Path2 starting at the coordinates (x, y).
  5401. */
  5402. static StartingAt(x: number, y: number): Path2;
  5403. }
  5404. /**
  5405. * Represents a 3D path made up of multiple 3D points
  5406. */
  5407. export class Path3D {
  5408. /**
  5409. * an array of Vector3, the curve axis of the Path3D
  5410. */
  5411. path: Vector3[];
  5412. private _curve;
  5413. private _distances;
  5414. private _tangents;
  5415. private _normals;
  5416. private _binormals;
  5417. private _raw;
  5418. private _alignTangentsWithPath;
  5419. private readonly _pointAtData;
  5420. /**
  5421. * new Path3D(path, normal, raw)
  5422. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5423. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5424. * @param path an array of Vector3, the curve axis of the Path3D
  5425. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5426. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5427. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5428. */
  5429. constructor(
  5430. /**
  5431. * an array of Vector3, the curve axis of the Path3D
  5432. */
  5433. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5434. /**
  5435. * Returns the Path3D array of successive Vector3 designing its curve.
  5436. * @returns the Path3D array of successive Vector3 designing its curve.
  5437. */
  5438. getCurve(): Vector3[];
  5439. /**
  5440. * Returns the Path3D array of successive Vector3 designing its curve.
  5441. * @returns the Path3D array of successive Vector3 designing its curve.
  5442. */
  5443. getPoints(): Vector3[];
  5444. /**
  5445. * @returns the computed length (float) of the path.
  5446. */
  5447. length(): number;
  5448. /**
  5449. * Returns an array populated with tangent vectors on each Path3D curve point.
  5450. * @returns an array populated with tangent vectors on each Path3D curve point.
  5451. */
  5452. getTangents(): Vector3[];
  5453. /**
  5454. * Returns an array populated with normal vectors on each Path3D curve point.
  5455. * @returns an array populated with normal vectors on each Path3D curve point.
  5456. */
  5457. getNormals(): Vector3[];
  5458. /**
  5459. * Returns an array populated with binormal vectors on each Path3D curve point.
  5460. * @returns an array populated with binormal vectors on each Path3D curve point.
  5461. */
  5462. getBinormals(): Vector3[];
  5463. /**
  5464. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5465. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5466. */
  5467. getDistances(): number[];
  5468. /**
  5469. * Returns an interpolated point along this path
  5470. * @param position the position of the point along this path, from 0.0 to 1.0
  5471. * @returns a new Vector3 as the point
  5472. */
  5473. getPointAt(position: number): Vector3;
  5474. /**
  5475. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5476. * @param position the position of the point along this path, from 0.0 to 1.0
  5477. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5478. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5479. */
  5480. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5481. /**
  5482. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5483. * @param position the position of the point along this path, from 0.0 to 1.0
  5484. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5485. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5486. */
  5487. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5488. /**
  5489. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5490. * @param position the position of the point along this path, from 0.0 to 1.0
  5491. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5492. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5493. */
  5494. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5495. /**
  5496. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5497. * @param position the position of the point along this path, from 0.0 to 1.0
  5498. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5499. */
  5500. getDistanceAt(position: number): number;
  5501. /**
  5502. * Returns the array index of the previous point of an interpolated point along this path
  5503. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5504. * @returns the array index
  5505. */
  5506. getPreviousPointIndexAt(position: number): number;
  5507. /**
  5508. * 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)
  5509. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5510. * @returns the sub position
  5511. */
  5512. getSubPositionAt(position: number): number;
  5513. /**
  5514. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5515. * @param target the vector of which to get the closest position to
  5516. * @returns the position of the closest virtual point on this path to the target vector
  5517. */
  5518. getClosestPositionTo(target: Vector3): number;
  5519. /**
  5520. * Returns a sub path (slice) of this path
  5521. * @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
  5522. * @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
  5523. * @returns a sub path (slice) of this path
  5524. */
  5525. slice(start?: number, end?: number): Path3D;
  5526. /**
  5527. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5528. * @param path path which all values are copied into the curves points
  5529. * @param firstNormal which should be projected onto the curve
  5530. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5531. * @returns the same object updated.
  5532. */
  5533. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5534. private _compute;
  5535. private _getFirstNonNullVector;
  5536. private _getLastNonNullVector;
  5537. private _normalVector;
  5538. /**
  5539. * Updates the point at data for an interpolated point along this curve
  5540. * @param position the position of the point along this curve, from 0.0 to 1.0
  5541. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5542. * @returns the (updated) point at data
  5543. */
  5544. private _updatePointAtData;
  5545. /**
  5546. * Updates the point at data from the specified parameters
  5547. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5548. * @param point the interpolated point
  5549. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5550. */
  5551. private _setPointAtData;
  5552. /**
  5553. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5554. */
  5555. private _updateInterpolationMatrix;
  5556. }
  5557. /**
  5558. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5559. * A Curve3 is designed from a series of successive Vector3.
  5560. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5561. */
  5562. export class Curve3 {
  5563. private _points;
  5564. private _length;
  5565. /**
  5566. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5567. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5568. * @param v1 (Vector3) the control point
  5569. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5570. * @param nbPoints (integer) the wanted number of points in the curve
  5571. * @returns the created Curve3
  5572. */
  5573. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5574. /**
  5575. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5576. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5577. * @param v1 (Vector3) the first control point
  5578. * @param v2 (Vector3) the second control point
  5579. * @param v3 (Vector3) the end point of the Cubic Bezier
  5580. * @param nbPoints (integer) the wanted number of points in the curve
  5581. * @returns the created Curve3
  5582. */
  5583. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5584. /**
  5585. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5586. * @param p1 (Vector3) the origin point of the Hermite Spline
  5587. * @param t1 (Vector3) the tangent vector at the origin point
  5588. * @param p2 (Vector3) the end point of the Hermite Spline
  5589. * @param t2 (Vector3) the tangent vector at the end point
  5590. * @param nbPoints (integer) the wanted number of points in the curve
  5591. * @returns the created Curve3
  5592. */
  5593. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5594. /**
  5595. * Returns a Curve3 object along a CatmullRom Spline curve :
  5596. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5597. * @param nbPoints (integer) the wanted number of points between each curve control points
  5598. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5599. * @returns the created Curve3
  5600. */
  5601. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5602. /**
  5603. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5604. * A Curve3 is designed from a series of successive Vector3.
  5605. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5606. * @param points points which make up the curve
  5607. */
  5608. constructor(points: Vector3[]);
  5609. /**
  5610. * @returns the Curve3 stored array of successive Vector3
  5611. */
  5612. getPoints(): Vector3[];
  5613. /**
  5614. * @returns the computed length (float) of the curve.
  5615. */
  5616. length(): number;
  5617. /**
  5618. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5619. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5620. * curveA and curveB keep unchanged.
  5621. * @param curve the curve to continue from this curve
  5622. * @returns the newly constructed curve
  5623. */
  5624. continue(curve: DeepImmutable<Curve3>): Curve3;
  5625. private _computeLength;
  5626. }
  5627. }
  5628. declare module BABYLON {
  5629. /**
  5630. * This represents the main contract an easing function should follow.
  5631. * Easing functions are used throughout the animation system.
  5632. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5633. */
  5634. export interface IEasingFunction {
  5635. /**
  5636. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5637. * of the easing function.
  5638. * The link below provides some of the most common examples of easing functions.
  5639. * @see https://easings.net/
  5640. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5641. * @returns the corresponding value on the curve defined by the easing function
  5642. */
  5643. ease(gradient: number): number;
  5644. }
  5645. /**
  5646. * Base class used for every default easing function.
  5647. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5648. */
  5649. export class EasingFunction implements IEasingFunction {
  5650. /**
  5651. * Interpolation follows the mathematical formula associated with the easing function.
  5652. */
  5653. static readonly EASINGMODE_EASEIN: number;
  5654. /**
  5655. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5656. */
  5657. static readonly EASINGMODE_EASEOUT: number;
  5658. /**
  5659. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5660. */
  5661. static readonly EASINGMODE_EASEINOUT: number;
  5662. private _easingMode;
  5663. /**
  5664. * Sets the easing mode of the current function.
  5665. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5666. */
  5667. setEasingMode(easingMode: number): void;
  5668. /**
  5669. * Gets the current easing mode.
  5670. * @returns the easing mode
  5671. */
  5672. getEasingMode(): number;
  5673. /**
  5674. * @hidden
  5675. */
  5676. easeInCore(gradient: number): number;
  5677. /**
  5678. * Given an input gradient between 0 and 1, this returns the corresponding value
  5679. * of the easing function.
  5680. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5681. * @returns the corresponding value on the curve defined by the easing function
  5682. */
  5683. ease(gradient: number): number;
  5684. }
  5685. /**
  5686. * Easing function with a circle shape (see link below).
  5687. * @see https://easings.net/#easeInCirc
  5688. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5689. */
  5690. export class CircleEase extends EasingFunction implements IEasingFunction {
  5691. /** @hidden */
  5692. easeInCore(gradient: number): number;
  5693. }
  5694. /**
  5695. * Easing function with a ease back shape (see link below).
  5696. * @see https://easings.net/#easeInBack
  5697. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5698. */
  5699. export class BackEase extends EasingFunction implements IEasingFunction {
  5700. /** Defines the amplitude of the function */
  5701. amplitude: number;
  5702. /**
  5703. * Instantiates a back ease easing
  5704. * @see https://easings.net/#easeInBack
  5705. * @param amplitude Defines the amplitude of the function
  5706. */
  5707. constructor(
  5708. /** Defines the amplitude of the function */
  5709. amplitude?: number);
  5710. /** @hidden */
  5711. easeInCore(gradient: number): number;
  5712. }
  5713. /**
  5714. * Easing function with a bouncing shape (see link below).
  5715. * @see https://easings.net/#easeInBounce
  5716. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5717. */
  5718. export class BounceEase extends EasingFunction implements IEasingFunction {
  5719. /** Defines the number of bounces */
  5720. bounces: number;
  5721. /** Defines the amplitude of the bounce */
  5722. bounciness: number;
  5723. /**
  5724. * Instantiates a bounce easing
  5725. * @see https://easings.net/#easeInBounce
  5726. * @param bounces Defines the number of bounces
  5727. * @param bounciness Defines the amplitude of the bounce
  5728. */
  5729. constructor(
  5730. /** Defines the number of bounces */
  5731. bounces?: number,
  5732. /** Defines the amplitude of the bounce */
  5733. bounciness?: number);
  5734. /** @hidden */
  5735. easeInCore(gradient: number): number;
  5736. }
  5737. /**
  5738. * Easing function with a power of 3 shape (see link below).
  5739. * @see https://easings.net/#easeInCubic
  5740. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5741. */
  5742. export class CubicEase extends EasingFunction implements IEasingFunction {
  5743. /** @hidden */
  5744. easeInCore(gradient: number): number;
  5745. }
  5746. /**
  5747. * Easing function with an elastic shape (see link below).
  5748. * @see https://easings.net/#easeInElastic
  5749. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5750. */
  5751. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5752. /** Defines the number of oscillations*/
  5753. oscillations: number;
  5754. /** Defines the amplitude of the oscillations*/
  5755. springiness: number;
  5756. /**
  5757. * Instantiates an elastic easing function
  5758. * @see https://easings.net/#easeInElastic
  5759. * @param oscillations Defines the number of oscillations
  5760. * @param springiness Defines the amplitude of the oscillations
  5761. */
  5762. constructor(
  5763. /** Defines the number of oscillations*/
  5764. oscillations?: number,
  5765. /** Defines the amplitude of the oscillations*/
  5766. springiness?: number);
  5767. /** @hidden */
  5768. easeInCore(gradient: number): number;
  5769. }
  5770. /**
  5771. * Easing function with an exponential shape (see link below).
  5772. * @see https://easings.net/#easeInExpo
  5773. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5774. */
  5775. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5776. /** Defines the exponent of the function */
  5777. exponent: number;
  5778. /**
  5779. * Instantiates an exponential easing function
  5780. * @see https://easings.net/#easeInExpo
  5781. * @param exponent Defines the exponent of the function
  5782. */
  5783. constructor(
  5784. /** Defines the exponent of the function */
  5785. exponent?: number);
  5786. /** @hidden */
  5787. easeInCore(gradient: number): number;
  5788. }
  5789. /**
  5790. * Easing function with a power shape (see link below).
  5791. * @see https://easings.net/#easeInQuad
  5792. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5793. */
  5794. export class PowerEase extends EasingFunction implements IEasingFunction {
  5795. /** Defines the power of the function */
  5796. power: number;
  5797. /**
  5798. * Instantiates an power base easing function
  5799. * @see https://easings.net/#easeInQuad
  5800. * @param power Defines the power of the function
  5801. */
  5802. constructor(
  5803. /** Defines the power of the function */
  5804. power?: number);
  5805. /** @hidden */
  5806. easeInCore(gradient: number): number;
  5807. }
  5808. /**
  5809. * Easing function with a power of 2 shape (see link below).
  5810. * @see https://easings.net/#easeInQuad
  5811. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5812. */
  5813. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5814. /** @hidden */
  5815. easeInCore(gradient: number): number;
  5816. }
  5817. /**
  5818. * Easing function with a power of 4 shape (see link below).
  5819. * @see https://easings.net/#easeInQuart
  5820. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5821. */
  5822. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5823. /** @hidden */
  5824. easeInCore(gradient: number): number;
  5825. }
  5826. /**
  5827. * Easing function with a power of 5 shape (see link below).
  5828. * @see https://easings.net/#easeInQuint
  5829. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5830. */
  5831. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5832. /** @hidden */
  5833. easeInCore(gradient: number): number;
  5834. }
  5835. /**
  5836. * Easing function with a sin shape (see link below).
  5837. * @see https://easings.net/#easeInSine
  5838. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5839. */
  5840. export class SineEase extends EasingFunction implements IEasingFunction {
  5841. /** @hidden */
  5842. easeInCore(gradient: number): number;
  5843. }
  5844. /**
  5845. * Easing function with a bezier shape (see link below).
  5846. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5847. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5848. */
  5849. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5850. /** Defines the x component of the start tangent in the bezier curve */
  5851. x1: number;
  5852. /** Defines the y component of the start tangent in the bezier curve */
  5853. y1: number;
  5854. /** Defines the x component of the end tangent in the bezier curve */
  5855. x2: number;
  5856. /** Defines the y component of the end tangent in the bezier curve */
  5857. y2: number;
  5858. /**
  5859. * Instantiates a bezier function
  5860. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5861. * @param x1 Defines the x component of the start tangent in the bezier curve
  5862. * @param y1 Defines the y component of the start tangent in the bezier curve
  5863. * @param x2 Defines the x component of the end tangent in the bezier curve
  5864. * @param y2 Defines the y component of the end tangent in the bezier curve
  5865. */
  5866. constructor(
  5867. /** Defines the x component of the start tangent in the bezier curve */
  5868. x1?: number,
  5869. /** Defines the y component of the start tangent in the bezier curve */
  5870. y1?: number,
  5871. /** Defines the x component of the end tangent in the bezier curve */
  5872. x2?: number,
  5873. /** Defines the y component of the end tangent in the bezier curve */
  5874. y2?: number);
  5875. /** @hidden */
  5876. easeInCore(gradient: number): number;
  5877. }
  5878. }
  5879. declare module BABYLON {
  5880. /**
  5881. * Class used to hold a RBG color
  5882. */
  5883. export class Color3 {
  5884. /**
  5885. * Defines the red component (between 0 and 1, default is 0)
  5886. */
  5887. r: number;
  5888. /**
  5889. * Defines the green component (between 0 and 1, default is 0)
  5890. */
  5891. g: number;
  5892. /**
  5893. * Defines the blue component (between 0 and 1, default is 0)
  5894. */
  5895. b: number;
  5896. /**
  5897. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5898. * @param r defines the red component (between 0 and 1, default is 0)
  5899. * @param g defines the green component (between 0 and 1, default is 0)
  5900. * @param b defines the blue component (between 0 and 1, default is 0)
  5901. */
  5902. constructor(
  5903. /**
  5904. * Defines the red component (between 0 and 1, default is 0)
  5905. */
  5906. r?: number,
  5907. /**
  5908. * Defines the green component (between 0 and 1, default is 0)
  5909. */
  5910. g?: number,
  5911. /**
  5912. * Defines the blue component (between 0 and 1, default is 0)
  5913. */
  5914. b?: number);
  5915. /**
  5916. * Creates a string with the Color3 current values
  5917. * @returns the string representation of the Color3 object
  5918. */
  5919. toString(): string;
  5920. /**
  5921. * Returns the string "Color3"
  5922. * @returns "Color3"
  5923. */
  5924. getClassName(): string;
  5925. /**
  5926. * Compute the Color3 hash code
  5927. * @returns an unique number that can be used to hash Color3 objects
  5928. */
  5929. getHashCode(): number;
  5930. /**
  5931. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5932. * @param array defines the array where to store the r,g,b components
  5933. * @param index defines an optional index in the target array to define where to start storing values
  5934. * @returns the current Color3 object
  5935. */
  5936. toArray(array: FloatArray, index?: number): Color3;
  5937. /**
  5938. * Update the current color with values stored in an array from the starting index of the given array
  5939. * @param array defines the source array
  5940. * @param offset defines an offset in the source array
  5941. * @returns the current Color3 object
  5942. */
  5943. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5944. /**
  5945. * Returns a new Color4 object from the current Color3 and the given alpha
  5946. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5947. * @returns a new Color4 object
  5948. */
  5949. toColor4(alpha?: number): Color4;
  5950. /**
  5951. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5952. * @returns the new array
  5953. */
  5954. asArray(): number[];
  5955. /**
  5956. * Returns the luminance value
  5957. * @returns a float value
  5958. */
  5959. toLuminance(): number;
  5960. /**
  5961. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5962. * @param otherColor defines the second operand
  5963. * @returns the new Color3 object
  5964. */
  5965. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5966. /**
  5967. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5968. * @param otherColor defines the second operand
  5969. * @param result defines the Color3 object where to store the result
  5970. * @returns the current Color3
  5971. */
  5972. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5973. /**
  5974. * Determines equality between Color3 objects
  5975. * @param otherColor defines the second operand
  5976. * @returns true if the rgb values are equal to the given ones
  5977. */
  5978. equals(otherColor: DeepImmutable<Color3>): boolean;
  5979. /**
  5980. * Determines equality between the current Color3 object and a set of r,b,g values
  5981. * @param r defines the red component to check
  5982. * @param g defines the green component to check
  5983. * @param b defines the blue component to check
  5984. * @returns true if the rgb values are equal to the given ones
  5985. */
  5986. equalsFloats(r: number, g: number, b: number): boolean;
  5987. /**
  5988. * Multiplies in place each rgb value by scale
  5989. * @param scale defines the scaling factor
  5990. * @returns the updated Color3
  5991. */
  5992. scale(scale: number): Color3;
  5993. /**
  5994. * Multiplies the rgb values by scale and stores the result into "result"
  5995. * @param scale defines the scaling factor
  5996. * @param result defines the Color3 object where to store the result
  5997. * @returns the unmodified current Color3
  5998. */
  5999. scaleToRef(scale: number, result: Color3): Color3;
  6000. /**
  6001. * Scale the current Color3 values by a factor and add the result to a given Color3
  6002. * @param scale defines the scale factor
  6003. * @param result defines color to store the result into
  6004. * @returns the unmodified current Color3
  6005. */
  6006. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6007. /**
  6008. * Clamps the rgb values by the min and max values and stores the result into "result"
  6009. * @param min defines minimum clamping value (default is 0)
  6010. * @param max defines maximum clamping value (default is 1)
  6011. * @param result defines color to store the result into
  6012. * @returns the original Color3
  6013. */
  6014. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6015. /**
  6016. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6017. * @param otherColor defines the second operand
  6018. * @returns the new Color3
  6019. */
  6020. add(otherColor: DeepImmutable<Color3>): Color3;
  6021. /**
  6022. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6023. * @param otherColor defines the second operand
  6024. * @param result defines Color3 object to store the result into
  6025. * @returns the unmodified current Color3
  6026. */
  6027. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6028. /**
  6029. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6030. * @param otherColor defines the second operand
  6031. * @returns the new Color3
  6032. */
  6033. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6034. /**
  6035. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6036. * @param otherColor defines the second operand
  6037. * @param result defines Color3 object to store the result into
  6038. * @returns the unmodified current Color3
  6039. */
  6040. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6041. /**
  6042. * Copy the current object
  6043. * @returns a new Color3 copied the current one
  6044. */
  6045. clone(): Color3;
  6046. /**
  6047. * Copies the rgb values from the source in the current Color3
  6048. * @param source defines the source Color3 object
  6049. * @returns the updated Color3 object
  6050. */
  6051. copyFrom(source: DeepImmutable<Color3>): Color3;
  6052. /**
  6053. * Updates the Color3 rgb values from the given floats
  6054. * @param r defines the red component to read from
  6055. * @param g defines the green component to read from
  6056. * @param b defines the blue component to read from
  6057. * @returns the current Color3 object
  6058. */
  6059. copyFromFloats(r: number, g: number, b: number): Color3;
  6060. /**
  6061. * Updates the Color3 rgb values from the given floats
  6062. * @param r defines the red component to read from
  6063. * @param g defines the green component to read from
  6064. * @param b defines the blue component to read from
  6065. * @returns the current Color3 object
  6066. */
  6067. set(r: number, g: number, b: number): Color3;
  6068. /**
  6069. * Compute the Color3 hexadecimal code as a string
  6070. * @returns a string containing the hexadecimal representation of the Color3 object
  6071. */
  6072. toHexString(): string;
  6073. /**
  6074. * Computes a new Color3 converted from the current one to linear space
  6075. * @returns a new Color3 object
  6076. */
  6077. toLinearSpace(): Color3;
  6078. /**
  6079. * Converts current color in rgb space to HSV values
  6080. * @returns a new color3 representing the HSV values
  6081. */
  6082. toHSV(): Color3;
  6083. /**
  6084. * Converts current color in rgb space to HSV values
  6085. * @param result defines the Color3 where to store the HSV values
  6086. */
  6087. toHSVToRef(result: Color3): void;
  6088. /**
  6089. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6090. * @param convertedColor defines the Color3 object where to store the linear space version
  6091. * @returns the unmodified Color3
  6092. */
  6093. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6094. /**
  6095. * Computes a new Color3 converted from the current one to gamma space
  6096. * @returns a new Color3 object
  6097. */
  6098. toGammaSpace(): Color3;
  6099. /**
  6100. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6101. * @param convertedColor defines the Color3 object where to store the gamma space version
  6102. * @returns the unmodified Color3
  6103. */
  6104. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6105. private static _BlackReadOnly;
  6106. /**
  6107. * Convert Hue, saturation and value to a Color3 (RGB)
  6108. * @param hue defines the hue
  6109. * @param saturation defines the saturation
  6110. * @param value defines the value
  6111. * @param result defines the Color3 where to store the RGB values
  6112. */
  6113. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6114. /**
  6115. * Creates a new Color3 from the string containing valid hexadecimal values
  6116. * @param hex defines a string containing valid hexadecimal values
  6117. * @returns a new Color3 object
  6118. */
  6119. static FromHexString(hex: string): Color3;
  6120. /**
  6121. * Creates a new Color3 from the starting index of the given array
  6122. * @param array defines the source array
  6123. * @param offset defines an offset in the source array
  6124. * @returns a new Color3 object
  6125. */
  6126. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6127. /**
  6128. * Creates a new Color3 from the starting index element of the given array
  6129. * @param array defines the source array to read from
  6130. * @param offset defines the offset in the source array
  6131. * @param result defines the target Color3 object
  6132. */
  6133. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6134. /**
  6135. * Creates a new Color3 from integer values (< 256)
  6136. * @param r defines the red component to read from (value between 0 and 255)
  6137. * @param g defines the green component to read from (value between 0 and 255)
  6138. * @param b defines the blue component to read from (value between 0 and 255)
  6139. * @returns a new Color3 object
  6140. */
  6141. static FromInts(r: number, g: number, b: number): Color3;
  6142. /**
  6143. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6144. * @param start defines the start Color3 value
  6145. * @param end defines the end Color3 value
  6146. * @param amount defines the gradient value between start and end
  6147. * @returns a new Color3 object
  6148. */
  6149. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6150. /**
  6151. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6152. * @param left defines the start value
  6153. * @param right defines the end value
  6154. * @param amount defines the gradient factor
  6155. * @param result defines the Color3 object where to store the result
  6156. */
  6157. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6158. /**
  6159. * Returns a Color3 value containing a red color
  6160. * @returns a new Color3 object
  6161. */
  6162. static Red(): Color3;
  6163. /**
  6164. * Returns a Color3 value containing a green color
  6165. * @returns a new Color3 object
  6166. */
  6167. static Green(): Color3;
  6168. /**
  6169. * Returns a Color3 value containing a blue color
  6170. * @returns a new Color3 object
  6171. */
  6172. static Blue(): Color3;
  6173. /**
  6174. * Returns a Color3 value containing a black color
  6175. * @returns a new Color3 object
  6176. */
  6177. static Black(): Color3;
  6178. /**
  6179. * Gets a Color3 value containing a black color that must not be updated
  6180. */
  6181. static get BlackReadOnly(): DeepImmutable<Color3>;
  6182. /**
  6183. * Returns a Color3 value containing a white color
  6184. * @returns a new Color3 object
  6185. */
  6186. static White(): Color3;
  6187. /**
  6188. * Returns a Color3 value containing a purple color
  6189. * @returns a new Color3 object
  6190. */
  6191. static Purple(): Color3;
  6192. /**
  6193. * Returns a Color3 value containing a magenta color
  6194. * @returns a new Color3 object
  6195. */
  6196. static Magenta(): Color3;
  6197. /**
  6198. * Returns a Color3 value containing a yellow color
  6199. * @returns a new Color3 object
  6200. */
  6201. static Yellow(): Color3;
  6202. /**
  6203. * Returns a Color3 value containing a gray color
  6204. * @returns a new Color3 object
  6205. */
  6206. static Gray(): Color3;
  6207. /**
  6208. * Returns a Color3 value containing a teal color
  6209. * @returns a new Color3 object
  6210. */
  6211. static Teal(): Color3;
  6212. /**
  6213. * Returns a Color3 value containing a random color
  6214. * @returns a new Color3 object
  6215. */
  6216. static Random(): Color3;
  6217. }
  6218. /**
  6219. * Class used to hold a RBGA color
  6220. */
  6221. export class Color4 {
  6222. /**
  6223. * Defines the red component (between 0 and 1, default is 0)
  6224. */
  6225. r: number;
  6226. /**
  6227. * Defines the green component (between 0 and 1, default is 0)
  6228. */
  6229. g: number;
  6230. /**
  6231. * Defines the blue component (between 0 and 1, default is 0)
  6232. */
  6233. b: number;
  6234. /**
  6235. * Defines the alpha component (between 0 and 1, default is 1)
  6236. */
  6237. a: number;
  6238. /**
  6239. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6240. * @param r defines the red component (between 0 and 1, default is 0)
  6241. * @param g defines the green component (between 0 and 1, default is 0)
  6242. * @param b defines the blue component (between 0 and 1, default is 0)
  6243. * @param a defines the alpha component (between 0 and 1, default is 1)
  6244. */
  6245. constructor(
  6246. /**
  6247. * Defines the red component (between 0 and 1, default is 0)
  6248. */
  6249. r?: number,
  6250. /**
  6251. * Defines the green component (between 0 and 1, default is 0)
  6252. */
  6253. g?: number,
  6254. /**
  6255. * Defines the blue component (between 0 and 1, default is 0)
  6256. */
  6257. b?: number,
  6258. /**
  6259. * Defines the alpha component (between 0 and 1, default is 1)
  6260. */
  6261. a?: number);
  6262. /**
  6263. * Adds in place the given Color4 values to the current Color4 object
  6264. * @param right defines the second operand
  6265. * @returns the current updated Color4 object
  6266. */
  6267. addInPlace(right: DeepImmutable<Color4>): Color4;
  6268. /**
  6269. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6270. * @returns the new array
  6271. */
  6272. asArray(): number[];
  6273. /**
  6274. * Stores from the starting index in the given array the Color4 successive values
  6275. * @param array defines the array where to store the r,g,b components
  6276. * @param index defines an optional index in the target array to define where to start storing values
  6277. * @returns the current Color4 object
  6278. */
  6279. toArray(array: number[], index?: number): Color4;
  6280. /**
  6281. * Update the current color with values stored in an array from the starting index of the given array
  6282. * @param array defines the source array
  6283. * @param offset defines an offset in the source array
  6284. * @returns the current Color4 object
  6285. */
  6286. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6287. /**
  6288. * Determines equality between Color4 objects
  6289. * @param otherColor defines the second operand
  6290. * @returns true if the rgba values are equal to the given ones
  6291. */
  6292. equals(otherColor: DeepImmutable<Color4>): boolean;
  6293. /**
  6294. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6295. * @param right defines the second operand
  6296. * @returns a new Color4 object
  6297. */
  6298. add(right: DeepImmutable<Color4>): Color4;
  6299. /**
  6300. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6301. * @param right defines the second operand
  6302. * @returns a new Color4 object
  6303. */
  6304. subtract(right: DeepImmutable<Color4>): Color4;
  6305. /**
  6306. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6307. * @param right defines the second operand
  6308. * @param result defines the Color4 object where to store the result
  6309. * @returns the current Color4 object
  6310. */
  6311. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6312. /**
  6313. * Creates a new Color4 with the current Color4 values multiplied by scale
  6314. * @param scale defines the scaling factor to apply
  6315. * @returns a new Color4 object
  6316. */
  6317. scale(scale: number): Color4;
  6318. /**
  6319. * Multiplies the current Color4 values by scale and stores the result in "result"
  6320. * @param scale defines the scaling factor to apply
  6321. * @param result defines the Color4 object where to store the result
  6322. * @returns the current unmodified Color4
  6323. */
  6324. scaleToRef(scale: number, result: Color4): Color4;
  6325. /**
  6326. * Scale the current Color4 values by a factor and add the result to a given Color4
  6327. * @param scale defines the scale factor
  6328. * @param result defines the Color4 object where to store the result
  6329. * @returns the unmodified current Color4
  6330. */
  6331. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6332. /**
  6333. * Clamps the rgb values by the min and max values and stores the result into "result"
  6334. * @param min defines minimum clamping value (default is 0)
  6335. * @param max defines maximum clamping value (default is 1)
  6336. * @param result defines color to store the result into.
  6337. * @returns the cuurent Color4
  6338. */
  6339. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6340. /**
  6341. * Multipy an Color4 value by another and return a new Color4 object
  6342. * @param color defines the Color4 value to multiply by
  6343. * @returns a new Color4 object
  6344. */
  6345. multiply(color: Color4): Color4;
  6346. /**
  6347. * Multipy a Color4 value by another and push the result in a reference value
  6348. * @param color defines the Color4 value to multiply by
  6349. * @param result defines the Color4 to fill the result in
  6350. * @returns the result Color4
  6351. */
  6352. multiplyToRef(color: Color4, result: Color4): Color4;
  6353. /**
  6354. * Creates a string with the Color4 current values
  6355. * @returns the string representation of the Color4 object
  6356. */
  6357. toString(): string;
  6358. /**
  6359. * Returns the string "Color4"
  6360. * @returns "Color4"
  6361. */
  6362. getClassName(): string;
  6363. /**
  6364. * Compute the Color4 hash code
  6365. * @returns an unique number that can be used to hash Color4 objects
  6366. */
  6367. getHashCode(): number;
  6368. /**
  6369. * Creates a new Color4 copied from the current one
  6370. * @returns a new Color4 object
  6371. */
  6372. clone(): Color4;
  6373. /**
  6374. * Copies the given Color4 values into the current one
  6375. * @param source defines the source Color4 object
  6376. * @returns the current updated Color4 object
  6377. */
  6378. copyFrom(source: Color4): Color4;
  6379. /**
  6380. * Copies the given float values into the current one
  6381. * @param r defines the red component to read from
  6382. * @param g defines the green component to read from
  6383. * @param b defines the blue component to read from
  6384. * @param a defines the alpha component to read from
  6385. * @returns the current updated Color4 object
  6386. */
  6387. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6388. /**
  6389. * Copies the given float values into the current one
  6390. * @param r defines the red component to read from
  6391. * @param g defines the green component to read from
  6392. * @param b defines the blue component to read from
  6393. * @param a defines the alpha component to read from
  6394. * @returns the current updated Color4 object
  6395. */
  6396. set(r: number, g: number, b: number, a: number): Color4;
  6397. /**
  6398. * Compute the Color4 hexadecimal code as a string
  6399. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6400. * @returns a string containing the hexadecimal representation of the Color4 object
  6401. */
  6402. toHexString(returnAsColor3?: boolean): string;
  6403. /**
  6404. * Computes a new Color4 converted from the current one to linear space
  6405. * @returns a new Color4 object
  6406. */
  6407. toLinearSpace(): Color4;
  6408. /**
  6409. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6410. * @param convertedColor defines the Color4 object where to store the linear space version
  6411. * @returns the unmodified Color4
  6412. */
  6413. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6414. /**
  6415. * Computes a new Color4 converted from the current one to gamma space
  6416. * @returns a new Color4 object
  6417. */
  6418. toGammaSpace(): Color4;
  6419. /**
  6420. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6421. * @param convertedColor defines the Color4 object where to store the gamma space version
  6422. * @returns the unmodified Color4
  6423. */
  6424. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6425. /**
  6426. * Creates a new Color4 from the string containing valid hexadecimal values
  6427. * @param hex defines a string containing valid hexadecimal values
  6428. * @returns a new Color4 object
  6429. */
  6430. static FromHexString(hex: string): Color4;
  6431. /**
  6432. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6433. * @param left defines the start value
  6434. * @param right defines the end value
  6435. * @param amount defines the gradient factor
  6436. * @returns a new Color4 object
  6437. */
  6438. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6439. /**
  6440. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6441. * @param left defines the start value
  6442. * @param right defines the end value
  6443. * @param amount defines the gradient factor
  6444. * @param result defines the Color4 object where to store data
  6445. */
  6446. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6447. /**
  6448. * Creates a new Color4 from a Color3 and an alpha value
  6449. * @param color3 defines the source Color3 to read from
  6450. * @param alpha defines the alpha component (1.0 by default)
  6451. * @returns a new Color4 object
  6452. */
  6453. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6454. /**
  6455. * Creates a new Color4 from the starting index element of the given array
  6456. * @param array defines the source array to read from
  6457. * @param offset defines the offset in the source array
  6458. * @returns a new Color4 object
  6459. */
  6460. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6461. /**
  6462. * Creates a new Color4 from the starting index element of the given array
  6463. * @param array defines the source array to read from
  6464. * @param offset defines the offset in the source array
  6465. * @param result defines the target Color4 object
  6466. */
  6467. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6468. /**
  6469. * Creates a new Color3 from integer values (< 256)
  6470. * @param r defines the red component to read from (value between 0 and 255)
  6471. * @param g defines the green component to read from (value between 0 and 255)
  6472. * @param b defines the blue component to read from (value between 0 and 255)
  6473. * @param a defines the alpha component to read from (value between 0 and 255)
  6474. * @returns a new Color3 object
  6475. */
  6476. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6477. /**
  6478. * Check the content of a given array and convert it to an array containing RGBA data
  6479. * If the original array was already containing count * 4 values then it is returned directly
  6480. * @param colors defines the array to check
  6481. * @param count defines the number of RGBA data to expect
  6482. * @returns an array containing count * 4 values (RGBA)
  6483. */
  6484. static CheckColors4(colors: number[], count: number): number[];
  6485. }
  6486. /**
  6487. * @hidden
  6488. */
  6489. export class TmpColors {
  6490. static Color3: Color3[];
  6491. static Color4: Color4[];
  6492. }
  6493. }
  6494. declare module BABYLON {
  6495. /**
  6496. * Defines an interface which represents an animation key frame
  6497. */
  6498. export interface IAnimationKey {
  6499. /**
  6500. * Frame of the key frame
  6501. */
  6502. frame: number;
  6503. /**
  6504. * Value at the specifies key frame
  6505. */
  6506. value: any;
  6507. /**
  6508. * The input tangent for the cubic hermite spline
  6509. */
  6510. inTangent?: any;
  6511. /**
  6512. * The output tangent for the cubic hermite spline
  6513. */
  6514. outTangent?: any;
  6515. /**
  6516. * The animation interpolation type
  6517. */
  6518. interpolation?: AnimationKeyInterpolation;
  6519. }
  6520. /**
  6521. * Enum for the animation key frame interpolation type
  6522. */
  6523. export enum AnimationKeyInterpolation {
  6524. /**
  6525. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6526. */
  6527. STEP = 1
  6528. }
  6529. }
  6530. declare module BABYLON {
  6531. /**
  6532. * Represents the range of an animation
  6533. */
  6534. export class AnimationRange {
  6535. /**The name of the animation range**/
  6536. name: string;
  6537. /**The starting frame of the animation */
  6538. from: number;
  6539. /**The ending frame of the animation*/
  6540. to: number;
  6541. /**
  6542. * Initializes the range of an animation
  6543. * @param name The name of the animation range
  6544. * @param from The starting frame of the animation
  6545. * @param to The ending frame of the animation
  6546. */
  6547. constructor(
  6548. /**The name of the animation range**/
  6549. name: string,
  6550. /**The starting frame of the animation */
  6551. from: number,
  6552. /**The ending frame of the animation*/
  6553. to: number);
  6554. /**
  6555. * Makes a copy of the animation range
  6556. * @returns A copy of the animation range
  6557. */
  6558. clone(): AnimationRange;
  6559. }
  6560. }
  6561. declare module BABYLON {
  6562. /**
  6563. * Composed of a frame, and an action function
  6564. */
  6565. export class AnimationEvent {
  6566. /** The frame for which the event is triggered **/
  6567. frame: number;
  6568. /** The event to perform when triggered **/
  6569. action: (currentFrame: number) => void;
  6570. /** Specifies if the event should be triggered only once**/
  6571. onlyOnce?: boolean | undefined;
  6572. /**
  6573. * Specifies if the animation event is done
  6574. */
  6575. isDone: boolean;
  6576. /**
  6577. * Initializes the animation event
  6578. * @param frame The frame for which the event is triggered
  6579. * @param action The event to perform when triggered
  6580. * @param onlyOnce Specifies if the event should be triggered only once
  6581. */
  6582. constructor(
  6583. /** The frame for which the event is triggered **/
  6584. frame: number,
  6585. /** The event to perform when triggered **/
  6586. action: (currentFrame: number) => void,
  6587. /** Specifies if the event should be triggered only once**/
  6588. onlyOnce?: boolean | undefined);
  6589. /** @hidden */
  6590. _clone(): AnimationEvent;
  6591. }
  6592. }
  6593. declare module BABYLON {
  6594. /**
  6595. * Interface used to define a behavior
  6596. */
  6597. export interface Behavior<T> {
  6598. /** gets or sets behavior's name */
  6599. name: string;
  6600. /**
  6601. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6602. */
  6603. init(): void;
  6604. /**
  6605. * Called when the behavior is attached to a target
  6606. * @param target defines the target where the behavior is attached to
  6607. */
  6608. attach(target: T): void;
  6609. /**
  6610. * Called when the behavior is detached from its target
  6611. */
  6612. detach(): void;
  6613. }
  6614. /**
  6615. * Interface implemented by classes supporting behaviors
  6616. */
  6617. export interface IBehaviorAware<T> {
  6618. /**
  6619. * Attach a behavior
  6620. * @param behavior defines the behavior to attach
  6621. * @returns the current host
  6622. */
  6623. addBehavior(behavior: Behavior<T>): T;
  6624. /**
  6625. * Remove a behavior from the current object
  6626. * @param behavior defines the behavior to detach
  6627. * @returns the current host
  6628. */
  6629. removeBehavior(behavior: Behavior<T>): T;
  6630. /**
  6631. * Gets a behavior using its name to search
  6632. * @param name defines the name to search
  6633. * @returns the behavior or null if not found
  6634. */
  6635. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6636. }
  6637. }
  6638. declare module BABYLON {
  6639. /**
  6640. * Class used to store data that will be store in GPU memory
  6641. */
  6642. export class Buffer {
  6643. private _engine;
  6644. private _buffer;
  6645. /** @hidden */
  6646. _data: Nullable<DataArray>;
  6647. private _updatable;
  6648. private _instanced;
  6649. private _divisor;
  6650. /**
  6651. * Gets the byte stride.
  6652. */
  6653. readonly byteStride: number;
  6654. /**
  6655. * Constructor
  6656. * @param engine the engine
  6657. * @param data the data to use for this buffer
  6658. * @param updatable whether the data is updatable
  6659. * @param stride the stride (optional)
  6660. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6661. * @param instanced whether the buffer is instanced (optional)
  6662. * @param useBytes set to true if the stride in in bytes (optional)
  6663. * @param divisor sets an optional divisor for instances (1 by default)
  6664. */
  6665. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6666. /**
  6667. * Create a new VertexBuffer based on the current buffer
  6668. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6669. * @param offset defines offset in the buffer (0 by default)
  6670. * @param size defines the size in floats of attributes (position is 3 for instance)
  6671. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6672. * @param instanced defines if the vertex buffer contains indexed data
  6673. * @param useBytes defines if the offset and stride are in bytes *
  6674. * @param divisor sets an optional divisor for instances (1 by default)
  6675. * @returns the new vertex buffer
  6676. */
  6677. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6678. /**
  6679. * Gets a boolean indicating if the Buffer is updatable?
  6680. * @returns true if the buffer is updatable
  6681. */
  6682. isUpdatable(): boolean;
  6683. /**
  6684. * Gets current buffer's data
  6685. * @returns a DataArray or null
  6686. */
  6687. getData(): Nullable<DataArray>;
  6688. /**
  6689. * Gets underlying native buffer
  6690. * @returns underlying native buffer
  6691. */
  6692. getBuffer(): Nullable<DataBuffer>;
  6693. /**
  6694. * Gets the stride in float32 units (i.e. byte stride / 4).
  6695. * May not be an integer if the byte stride is not divisible by 4.
  6696. * @returns the stride in float32 units
  6697. * @deprecated Please use byteStride instead.
  6698. */
  6699. getStrideSize(): number;
  6700. /**
  6701. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6702. * @param data defines the data to store
  6703. */
  6704. create(data?: Nullable<DataArray>): void;
  6705. /** @hidden */
  6706. _rebuild(): void;
  6707. /**
  6708. * Update current buffer data
  6709. * @param data defines the data to store
  6710. */
  6711. update(data: DataArray): void;
  6712. /**
  6713. * Updates the data directly.
  6714. * @param data the new data
  6715. * @param offset the new offset
  6716. * @param vertexCount the vertex count (optional)
  6717. * @param useBytes set to true if the offset is in bytes
  6718. */
  6719. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6720. /**
  6721. * Release all resources
  6722. */
  6723. dispose(): void;
  6724. }
  6725. /**
  6726. * Specialized buffer used to store vertex data
  6727. */
  6728. export class VertexBuffer {
  6729. /** @hidden */
  6730. _buffer: Buffer;
  6731. private _kind;
  6732. private _size;
  6733. private _ownsBuffer;
  6734. private _instanced;
  6735. private _instanceDivisor;
  6736. /**
  6737. * The byte type.
  6738. */
  6739. static readonly BYTE: number;
  6740. /**
  6741. * The unsigned byte type.
  6742. */
  6743. static readonly UNSIGNED_BYTE: number;
  6744. /**
  6745. * The short type.
  6746. */
  6747. static readonly SHORT: number;
  6748. /**
  6749. * The unsigned short type.
  6750. */
  6751. static readonly UNSIGNED_SHORT: number;
  6752. /**
  6753. * The integer type.
  6754. */
  6755. static readonly INT: number;
  6756. /**
  6757. * The unsigned integer type.
  6758. */
  6759. static readonly UNSIGNED_INT: number;
  6760. /**
  6761. * The float type.
  6762. */
  6763. static readonly FLOAT: number;
  6764. /**
  6765. * Gets or sets the instance divisor when in instanced mode
  6766. */
  6767. get instanceDivisor(): number;
  6768. set instanceDivisor(value: number);
  6769. /**
  6770. * Gets the byte stride.
  6771. */
  6772. readonly byteStride: number;
  6773. /**
  6774. * Gets the byte offset.
  6775. */
  6776. readonly byteOffset: number;
  6777. /**
  6778. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6779. */
  6780. readonly normalized: boolean;
  6781. /**
  6782. * Gets the data type of each component in the array.
  6783. */
  6784. readonly type: number;
  6785. /**
  6786. * Constructor
  6787. * @param engine the engine
  6788. * @param data the data to use for this vertex buffer
  6789. * @param kind the vertex buffer kind
  6790. * @param updatable whether the data is updatable
  6791. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6792. * @param stride the stride (optional)
  6793. * @param instanced whether the buffer is instanced (optional)
  6794. * @param offset the offset of the data (optional)
  6795. * @param size the number of components (optional)
  6796. * @param type the type of the component (optional)
  6797. * @param normalized whether the data contains normalized data (optional)
  6798. * @param useBytes set to true if stride and offset are in bytes (optional)
  6799. * @param divisor defines the instance divisor to use (1 by default)
  6800. */
  6801. 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);
  6802. /** @hidden */
  6803. _rebuild(): void;
  6804. /**
  6805. * Returns the kind of the VertexBuffer (string)
  6806. * @returns a string
  6807. */
  6808. getKind(): string;
  6809. /**
  6810. * Gets a boolean indicating if the VertexBuffer is updatable?
  6811. * @returns true if the buffer is updatable
  6812. */
  6813. isUpdatable(): boolean;
  6814. /**
  6815. * Gets current buffer's data
  6816. * @returns a DataArray or null
  6817. */
  6818. getData(): Nullable<DataArray>;
  6819. /**
  6820. * Gets underlying native buffer
  6821. * @returns underlying native buffer
  6822. */
  6823. getBuffer(): Nullable<DataBuffer>;
  6824. /**
  6825. * Gets the stride in float32 units (i.e. byte stride / 4).
  6826. * May not be an integer if the byte stride is not divisible by 4.
  6827. * @returns the stride in float32 units
  6828. * @deprecated Please use byteStride instead.
  6829. */
  6830. getStrideSize(): number;
  6831. /**
  6832. * Returns the offset as a multiple of the type byte length.
  6833. * @returns the offset in bytes
  6834. * @deprecated Please use byteOffset instead.
  6835. */
  6836. getOffset(): number;
  6837. /**
  6838. * Returns the number of components per vertex attribute (integer)
  6839. * @returns the size in float
  6840. */
  6841. getSize(): number;
  6842. /**
  6843. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6844. * @returns true if this buffer is instanced
  6845. */
  6846. getIsInstanced(): boolean;
  6847. /**
  6848. * Returns the instancing divisor, zero for non-instanced (integer).
  6849. * @returns a number
  6850. */
  6851. getInstanceDivisor(): number;
  6852. /**
  6853. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6854. * @param data defines the data to store
  6855. */
  6856. create(data?: DataArray): void;
  6857. /**
  6858. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6859. * This function will create a new buffer if the current one is not updatable
  6860. * @param data defines the data to store
  6861. */
  6862. update(data: DataArray): void;
  6863. /**
  6864. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6865. * Returns the directly updated WebGLBuffer.
  6866. * @param data the new data
  6867. * @param offset the new offset
  6868. * @param useBytes set to true if the offset is in bytes
  6869. */
  6870. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6871. /**
  6872. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6873. */
  6874. dispose(): void;
  6875. /**
  6876. * Enumerates each value of this vertex buffer as numbers.
  6877. * @param count the number of values to enumerate
  6878. * @param callback the callback function called for each value
  6879. */
  6880. forEach(count: number, callback: (value: number, index: number) => void): void;
  6881. /**
  6882. * Positions
  6883. */
  6884. static readonly PositionKind: string;
  6885. /**
  6886. * Normals
  6887. */
  6888. static readonly NormalKind: string;
  6889. /**
  6890. * Tangents
  6891. */
  6892. static readonly TangentKind: string;
  6893. /**
  6894. * Texture coordinates
  6895. */
  6896. static readonly UVKind: string;
  6897. /**
  6898. * Texture coordinates 2
  6899. */
  6900. static readonly UV2Kind: string;
  6901. /**
  6902. * Texture coordinates 3
  6903. */
  6904. static readonly UV3Kind: string;
  6905. /**
  6906. * Texture coordinates 4
  6907. */
  6908. static readonly UV4Kind: string;
  6909. /**
  6910. * Texture coordinates 5
  6911. */
  6912. static readonly UV5Kind: string;
  6913. /**
  6914. * Texture coordinates 6
  6915. */
  6916. static readonly UV6Kind: string;
  6917. /**
  6918. * Colors
  6919. */
  6920. static readonly ColorKind: string;
  6921. /**
  6922. * Matrix indices (for bones)
  6923. */
  6924. static readonly MatricesIndicesKind: string;
  6925. /**
  6926. * Matrix weights (for bones)
  6927. */
  6928. static readonly MatricesWeightsKind: string;
  6929. /**
  6930. * Additional matrix indices (for bones)
  6931. */
  6932. static readonly MatricesIndicesExtraKind: string;
  6933. /**
  6934. * Additional matrix weights (for bones)
  6935. */
  6936. static readonly MatricesWeightsExtraKind: string;
  6937. /**
  6938. * Deduces the stride given a kind.
  6939. * @param kind The kind string to deduce
  6940. * @returns The deduced stride
  6941. */
  6942. static DeduceStride(kind: string): number;
  6943. /**
  6944. * Gets the byte length of the given type.
  6945. * @param type the type
  6946. * @returns the number of bytes
  6947. */
  6948. static GetTypeByteLength(type: number): number;
  6949. /**
  6950. * Enumerates each value of the given parameters as numbers.
  6951. * @param data the data to enumerate
  6952. * @param byteOffset the byte offset of the data
  6953. * @param byteStride the byte stride of the data
  6954. * @param componentCount the number of components per element
  6955. * @param componentType the type of the component
  6956. * @param count the number of values to enumerate
  6957. * @param normalized whether the data is normalized
  6958. * @param callback the callback function called for each value
  6959. */
  6960. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6961. private static _GetFloatValue;
  6962. }
  6963. }
  6964. declare module BABYLON {
  6965. /**
  6966. * @hidden
  6967. */
  6968. export class IntersectionInfo {
  6969. bu: Nullable<number>;
  6970. bv: Nullable<number>;
  6971. distance: number;
  6972. faceId: number;
  6973. subMeshId: number;
  6974. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6975. }
  6976. }
  6977. declare module BABYLON {
  6978. /**
  6979. * Class used to store bounding sphere information
  6980. */
  6981. export class BoundingSphere {
  6982. /**
  6983. * Gets the center of the bounding sphere in local space
  6984. */
  6985. readonly center: Vector3;
  6986. /**
  6987. * Radius of the bounding sphere in local space
  6988. */
  6989. radius: number;
  6990. /**
  6991. * Gets the center of the bounding sphere in world space
  6992. */
  6993. readonly centerWorld: Vector3;
  6994. /**
  6995. * Radius of the bounding sphere in world space
  6996. */
  6997. radiusWorld: number;
  6998. /**
  6999. * Gets the minimum vector in local space
  7000. */
  7001. readonly minimum: Vector3;
  7002. /**
  7003. * Gets the maximum vector in local space
  7004. */
  7005. readonly maximum: Vector3;
  7006. private _worldMatrix;
  7007. private static readonly TmpVector3;
  7008. /**
  7009. * Creates a new bounding sphere
  7010. * @param min defines the minimum vector (in local space)
  7011. * @param max defines the maximum vector (in local space)
  7012. * @param worldMatrix defines the new world matrix
  7013. */
  7014. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7015. /**
  7016. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7017. * @param min defines the new minimum vector (in local space)
  7018. * @param max defines the new maximum vector (in local space)
  7019. * @param worldMatrix defines the new world matrix
  7020. */
  7021. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7022. /**
  7023. * Scale the current bounding sphere by applying a scale factor
  7024. * @param factor defines the scale factor to apply
  7025. * @returns the current bounding box
  7026. */
  7027. scale(factor: number): BoundingSphere;
  7028. /**
  7029. * Gets the world matrix of the bounding box
  7030. * @returns a matrix
  7031. */
  7032. getWorldMatrix(): DeepImmutable<Matrix>;
  7033. /** @hidden */
  7034. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7035. /**
  7036. * Tests if the bounding sphere is intersecting the frustum planes
  7037. * @param frustumPlanes defines the frustum planes to test
  7038. * @returns true if there is an intersection
  7039. */
  7040. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7041. /**
  7042. * Tests if the bounding sphere center is in between the frustum planes.
  7043. * Used for optimistic fast inclusion.
  7044. * @param frustumPlanes defines the frustum planes to test
  7045. * @returns true if the sphere center is in between the frustum planes
  7046. */
  7047. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7048. /**
  7049. * Tests if a point is inside the bounding sphere
  7050. * @param point defines the point to test
  7051. * @returns true if the point is inside the bounding sphere
  7052. */
  7053. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7054. /**
  7055. * Checks if two sphere intersct
  7056. * @param sphere0 sphere 0
  7057. * @param sphere1 sphere 1
  7058. * @returns true if the speres intersect
  7059. */
  7060. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7061. }
  7062. }
  7063. declare module BABYLON {
  7064. /**
  7065. * Class used to store bounding box information
  7066. */
  7067. export class BoundingBox implements ICullable {
  7068. /**
  7069. * Gets the 8 vectors representing the bounding box in local space
  7070. */
  7071. readonly vectors: Vector3[];
  7072. /**
  7073. * Gets the center of the bounding box in local space
  7074. */
  7075. readonly center: Vector3;
  7076. /**
  7077. * Gets the center of the bounding box in world space
  7078. */
  7079. readonly centerWorld: Vector3;
  7080. /**
  7081. * Gets the extend size in local space
  7082. */
  7083. readonly extendSize: Vector3;
  7084. /**
  7085. * Gets the extend size in world space
  7086. */
  7087. readonly extendSizeWorld: Vector3;
  7088. /**
  7089. * Gets the OBB (object bounding box) directions
  7090. */
  7091. readonly directions: Vector3[];
  7092. /**
  7093. * Gets the 8 vectors representing the bounding box in world space
  7094. */
  7095. readonly vectorsWorld: Vector3[];
  7096. /**
  7097. * Gets the minimum vector in world space
  7098. */
  7099. readonly minimumWorld: Vector3;
  7100. /**
  7101. * Gets the maximum vector in world space
  7102. */
  7103. readonly maximumWorld: Vector3;
  7104. /**
  7105. * Gets the minimum vector in local space
  7106. */
  7107. readonly minimum: Vector3;
  7108. /**
  7109. * Gets the maximum vector in local space
  7110. */
  7111. readonly maximum: Vector3;
  7112. private _worldMatrix;
  7113. private static readonly TmpVector3;
  7114. /**
  7115. * @hidden
  7116. */
  7117. _tag: number;
  7118. /**
  7119. * Creates a new bounding box
  7120. * @param min defines the minimum vector (in local space)
  7121. * @param max defines the maximum vector (in local space)
  7122. * @param worldMatrix defines the new world matrix
  7123. */
  7124. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7125. /**
  7126. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7127. * @param min defines the new minimum vector (in local space)
  7128. * @param max defines the new maximum vector (in local space)
  7129. * @param worldMatrix defines the new world matrix
  7130. */
  7131. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7132. /**
  7133. * Scale the current bounding box by applying a scale factor
  7134. * @param factor defines the scale factor to apply
  7135. * @returns the current bounding box
  7136. */
  7137. scale(factor: number): BoundingBox;
  7138. /**
  7139. * Gets the world matrix of the bounding box
  7140. * @returns a matrix
  7141. */
  7142. getWorldMatrix(): DeepImmutable<Matrix>;
  7143. /** @hidden */
  7144. _update(world: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * Tests if the bounding box is intersecting the frustum planes
  7147. * @param frustumPlanes defines the frustum planes to test
  7148. * @returns true if there is an intersection
  7149. */
  7150. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7151. /**
  7152. * Tests if the bounding box is entirely inside the frustum planes
  7153. * @param frustumPlanes defines the frustum planes to test
  7154. * @returns true if there is an inclusion
  7155. */
  7156. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7157. /**
  7158. * Tests if a point is inside the bounding box
  7159. * @param point defines the point to test
  7160. * @returns true if the point is inside the bounding box
  7161. */
  7162. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7163. /**
  7164. * Tests if the bounding box intersects with a bounding sphere
  7165. * @param sphere defines the sphere to test
  7166. * @returns true if there is an intersection
  7167. */
  7168. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7169. /**
  7170. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7171. * @param min defines the min vector to use
  7172. * @param max defines the max vector to use
  7173. * @returns true if there is an intersection
  7174. */
  7175. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7176. /**
  7177. * Tests if two bounding boxes are intersections
  7178. * @param box0 defines the first box to test
  7179. * @param box1 defines the second box to test
  7180. * @returns true if there is an intersection
  7181. */
  7182. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7183. /**
  7184. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7185. * @param minPoint defines the minimum vector of the bounding box
  7186. * @param maxPoint defines the maximum vector of the bounding box
  7187. * @param sphereCenter defines the sphere center
  7188. * @param sphereRadius defines the sphere radius
  7189. * @returns true if there is an intersection
  7190. */
  7191. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7192. /**
  7193. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7194. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7195. * @param frustumPlanes defines the frustum planes to test
  7196. * @return true if there is an inclusion
  7197. */
  7198. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7199. /**
  7200. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7201. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7202. * @param frustumPlanes defines the frustum planes to test
  7203. * @return true if there is an intersection
  7204. */
  7205. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7206. }
  7207. }
  7208. declare module BABYLON {
  7209. /** @hidden */
  7210. export class Collider {
  7211. /** Define if a collision was found */
  7212. collisionFound: boolean;
  7213. /**
  7214. * Define last intersection point in local space
  7215. */
  7216. intersectionPoint: Vector3;
  7217. /**
  7218. * Define last collided mesh
  7219. */
  7220. collidedMesh: Nullable<AbstractMesh>;
  7221. private _collisionPoint;
  7222. private _planeIntersectionPoint;
  7223. private _tempVector;
  7224. private _tempVector2;
  7225. private _tempVector3;
  7226. private _tempVector4;
  7227. private _edge;
  7228. private _baseToVertex;
  7229. private _destinationPoint;
  7230. private _slidePlaneNormal;
  7231. private _displacementVector;
  7232. /** @hidden */
  7233. _radius: Vector3;
  7234. /** @hidden */
  7235. _retry: number;
  7236. private _velocity;
  7237. private _basePoint;
  7238. private _epsilon;
  7239. /** @hidden */
  7240. _velocityWorldLength: number;
  7241. /** @hidden */
  7242. _basePointWorld: Vector3;
  7243. private _velocityWorld;
  7244. private _normalizedVelocity;
  7245. /** @hidden */
  7246. _initialVelocity: Vector3;
  7247. /** @hidden */
  7248. _initialPosition: Vector3;
  7249. private _nearestDistance;
  7250. private _collisionMask;
  7251. get collisionMask(): number;
  7252. set collisionMask(mask: number);
  7253. /**
  7254. * Gets the plane normal used to compute the sliding response (in local space)
  7255. */
  7256. get slidePlaneNormal(): Vector3;
  7257. /** @hidden */
  7258. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7259. /** @hidden */
  7260. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7261. /** @hidden */
  7262. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7263. /** @hidden */
  7264. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7265. /** @hidden */
  7266. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7267. /** @hidden */
  7268. _getResponse(pos: Vector3, vel: Vector3): void;
  7269. }
  7270. }
  7271. declare module BABYLON {
  7272. /**
  7273. * Interface for cullable objects
  7274. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7275. */
  7276. export interface ICullable {
  7277. /**
  7278. * Checks if the object or part of the object is in the frustum
  7279. * @param frustumPlanes Camera near/planes
  7280. * @returns true if the object is in frustum otherwise false
  7281. */
  7282. isInFrustum(frustumPlanes: Plane[]): boolean;
  7283. /**
  7284. * Checks if a cullable object (mesh...) is in the camera frustum
  7285. * Unlike isInFrustum this cheks the full bounding box
  7286. * @param frustumPlanes Camera near/planes
  7287. * @returns true if the object is in frustum otherwise false
  7288. */
  7289. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7290. }
  7291. /**
  7292. * Info for a bounding data of a mesh
  7293. */
  7294. export class BoundingInfo implements ICullable {
  7295. /**
  7296. * Bounding box for the mesh
  7297. */
  7298. readonly boundingBox: BoundingBox;
  7299. /**
  7300. * Bounding sphere for the mesh
  7301. */
  7302. readonly boundingSphere: BoundingSphere;
  7303. private _isLocked;
  7304. private static readonly TmpVector3;
  7305. /**
  7306. * Constructs bounding info
  7307. * @param minimum min vector of the bounding box/sphere
  7308. * @param maximum max vector of the bounding box/sphere
  7309. * @param worldMatrix defines the new world matrix
  7310. */
  7311. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7312. /**
  7313. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7314. * @param min defines the new minimum vector (in local space)
  7315. * @param max defines the new maximum vector (in local space)
  7316. * @param worldMatrix defines the new world matrix
  7317. */
  7318. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7319. /**
  7320. * min vector of the bounding box/sphere
  7321. */
  7322. get minimum(): Vector3;
  7323. /**
  7324. * max vector of the bounding box/sphere
  7325. */
  7326. get maximum(): Vector3;
  7327. /**
  7328. * If the info is locked and won't be updated to avoid perf overhead
  7329. */
  7330. get isLocked(): boolean;
  7331. set isLocked(value: boolean);
  7332. /**
  7333. * Updates the bounding sphere and box
  7334. * @param world world matrix to be used to update
  7335. */
  7336. update(world: DeepImmutable<Matrix>): void;
  7337. /**
  7338. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7339. * @param center New center of the bounding info
  7340. * @param extend New extend of the bounding info
  7341. * @returns the current bounding info
  7342. */
  7343. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7344. /**
  7345. * Scale the current bounding info by applying a scale factor
  7346. * @param factor defines the scale factor to apply
  7347. * @returns the current bounding info
  7348. */
  7349. scale(factor: number): BoundingInfo;
  7350. /**
  7351. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7352. * @param frustumPlanes defines the frustum to test
  7353. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7354. * @returns true if the bounding info is in the frustum planes
  7355. */
  7356. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7357. /**
  7358. * Gets the world distance between the min and max points of the bounding box
  7359. */
  7360. get diagonalLength(): number;
  7361. /**
  7362. * Checks if a cullable object (mesh...) is in the camera frustum
  7363. * Unlike isInFrustum this cheks the full bounding box
  7364. * @param frustumPlanes Camera near/planes
  7365. * @returns true if the object is in frustum otherwise false
  7366. */
  7367. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7368. /** @hidden */
  7369. _checkCollision(collider: Collider): boolean;
  7370. /**
  7371. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7372. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7373. * @param point the point to check intersection with
  7374. * @returns if the point intersects
  7375. */
  7376. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7377. /**
  7378. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7379. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7380. * @param boundingInfo the bounding info to check intersection with
  7381. * @param precise if the intersection should be done using OBB
  7382. * @returns if the bounding info intersects
  7383. */
  7384. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7385. }
  7386. }
  7387. declare module BABYLON {
  7388. /**
  7389. * Extracts minimum and maximum values from a list of indexed positions
  7390. * @param positions defines the positions to use
  7391. * @param indices defines the indices to the positions
  7392. * @param indexStart defines the start index
  7393. * @param indexCount defines the end index
  7394. * @param bias defines bias value to add to the result
  7395. * @return minimum and maximum values
  7396. */
  7397. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7398. minimum: Vector3;
  7399. maximum: Vector3;
  7400. };
  7401. /**
  7402. * Extracts minimum and maximum values from a list of positions
  7403. * @param positions defines the positions to use
  7404. * @param start defines the start index in the positions array
  7405. * @param count defines the number of positions to handle
  7406. * @param bias defines bias value to add to the result
  7407. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7408. * @return minimum and maximum values
  7409. */
  7410. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7411. minimum: Vector3;
  7412. maximum: Vector3;
  7413. };
  7414. }
  7415. declare module BABYLON {
  7416. /**
  7417. * Class used to manipulate GUIDs
  7418. */
  7419. export class GUID {
  7420. /**
  7421. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7422. * Be aware Math.random() could cause collisions, but:
  7423. * "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"
  7424. * @returns a pseudo random id
  7425. */
  7426. static RandomId(): string;
  7427. }
  7428. }
  7429. declare module BABYLON {
  7430. /**
  7431. * Base class of all the textures in babylon.
  7432. * It groups all the common properties the materials, post process, lights... might need
  7433. * in order to make a correct use of the texture.
  7434. */
  7435. export class BaseTexture extends ThinTexture implements IAnimatable {
  7436. /**
  7437. * Default anisotropic filtering level for the application.
  7438. * It is set to 4 as a good tradeoff between perf and quality.
  7439. */
  7440. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7441. /**
  7442. * Gets or sets the unique id of the texture
  7443. */
  7444. uniqueId: number;
  7445. /**
  7446. * Define the name of the texture.
  7447. */
  7448. name: string;
  7449. /**
  7450. * Gets or sets an object used to store user defined information.
  7451. */
  7452. metadata: any;
  7453. /**
  7454. * For internal use only. Please do not use.
  7455. */
  7456. reservedDataStore: any;
  7457. private _hasAlpha;
  7458. /**
  7459. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7460. */
  7461. set hasAlpha(value: boolean);
  7462. get hasAlpha(): boolean;
  7463. /**
  7464. * Defines if the alpha value should be determined via the rgb values.
  7465. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7466. */
  7467. getAlphaFromRGB: boolean;
  7468. /**
  7469. * Intensity or strength of the texture.
  7470. * It is commonly used by materials to fine tune the intensity of the texture
  7471. */
  7472. level: number;
  7473. /**
  7474. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7475. * This is part of the texture as textures usually maps to one uv set.
  7476. */
  7477. coordinatesIndex: number;
  7478. protected _coordinatesMode: number;
  7479. /**
  7480. * How a texture is mapped.
  7481. *
  7482. * | Value | Type | Description |
  7483. * | ----- | ----------------------------------- | ----------- |
  7484. * | 0 | EXPLICIT_MODE | |
  7485. * | 1 | SPHERICAL_MODE | |
  7486. * | 2 | PLANAR_MODE | |
  7487. * | 3 | CUBIC_MODE | |
  7488. * | 4 | PROJECTION_MODE | |
  7489. * | 5 | SKYBOX_MODE | |
  7490. * | 6 | INVCUBIC_MODE | |
  7491. * | 7 | EQUIRECTANGULAR_MODE | |
  7492. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7493. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7494. */
  7495. set coordinatesMode(value: number);
  7496. get coordinatesMode(): number;
  7497. /**
  7498. * | Value | Type | Description |
  7499. * | ----- | ------------------ | ----------- |
  7500. * | 0 | CLAMP_ADDRESSMODE | |
  7501. * | 1 | WRAP_ADDRESSMODE | |
  7502. * | 2 | MIRROR_ADDRESSMODE | |
  7503. */
  7504. get wrapU(): number;
  7505. set wrapU(value: number);
  7506. /**
  7507. * | Value | Type | Description |
  7508. * | ----- | ------------------ | ----------- |
  7509. * | 0 | CLAMP_ADDRESSMODE | |
  7510. * | 1 | WRAP_ADDRESSMODE | |
  7511. * | 2 | MIRROR_ADDRESSMODE | |
  7512. */
  7513. get wrapV(): number;
  7514. set wrapV(value: number);
  7515. /**
  7516. * | Value | Type | Description |
  7517. * | ----- | ------------------ | ----------- |
  7518. * | 0 | CLAMP_ADDRESSMODE | |
  7519. * | 1 | WRAP_ADDRESSMODE | |
  7520. * | 2 | MIRROR_ADDRESSMODE | |
  7521. */
  7522. wrapR: number;
  7523. /**
  7524. * With compliant hardware and browser (supporting anisotropic filtering)
  7525. * this defines the level of anisotropic filtering in the texture.
  7526. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7527. */
  7528. anisotropicFilteringLevel: number;
  7529. private _isCube;
  7530. /**
  7531. * Define if the texture is a cube texture or if false a 2d texture.
  7532. */
  7533. get isCube(): boolean;
  7534. set isCube(value: boolean);
  7535. /**
  7536. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7537. */
  7538. get is3D(): boolean;
  7539. set is3D(value: boolean);
  7540. /**
  7541. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7542. */
  7543. get is2DArray(): boolean;
  7544. set is2DArray(value: boolean);
  7545. private _gammaSpace;
  7546. /**
  7547. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7548. * HDR texture are usually stored in linear space.
  7549. * This only impacts the PBR and Background materials
  7550. */
  7551. get gammaSpace(): boolean;
  7552. set gammaSpace(gamma: boolean);
  7553. /**
  7554. * Gets or sets whether or not the texture contains RGBD data.
  7555. */
  7556. get isRGBD(): boolean;
  7557. set isRGBD(value: boolean);
  7558. /**
  7559. * Is Z inverted in the texture (useful in a cube texture).
  7560. */
  7561. invertZ: boolean;
  7562. /**
  7563. * Are mip maps generated for this texture or not.
  7564. */
  7565. get noMipmap(): boolean;
  7566. /**
  7567. * @hidden
  7568. */
  7569. lodLevelInAlpha: boolean;
  7570. /**
  7571. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7572. */
  7573. get lodGenerationOffset(): number;
  7574. set lodGenerationOffset(value: number);
  7575. /**
  7576. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7577. */
  7578. get lodGenerationScale(): number;
  7579. set lodGenerationScale(value: number);
  7580. /**
  7581. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7582. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7583. * average roughness values.
  7584. */
  7585. get linearSpecularLOD(): boolean;
  7586. set linearSpecularLOD(value: boolean);
  7587. /**
  7588. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7589. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7590. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7591. */
  7592. get irradianceTexture(): Nullable<BaseTexture>;
  7593. set irradianceTexture(value: Nullable<BaseTexture>);
  7594. /**
  7595. * Define if the texture is a render target.
  7596. */
  7597. isRenderTarget: boolean;
  7598. /**
  7599. * Define the unique id of the texture in the scene.
  7600. */
  7601. get uid(): string;
  7602. /** @hidden */
  7603. _prefiltered: boolean;
  7604. /**
  7605. * Return a string representation of the texture.
  7606. * @returns the texture as a string
  7607. */
  7608. toString(): string;
  7609. /**
  7610. * Get the class name of the texture.
  7611. * @returns "BaseTexture"
  7612. */
  7613. getClassName(): string;
  7614. /**
  7615. * Define the list of animation attached to the texture.
  7616. */
  7617. animations: Animation[];
  7618. /**
  7619. * An event triggered when the texture is disposed.
  7620. */
  7621. onDisposeObservable: Observable<BaseTexture>;
  7622. private _onDisposeObserver;
  7623. /**
  7624. * Callback triggered when the texture has been disposed.
  7625. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7626. */
  7627. set onDispose(callback: () => void);
  7628. protected _scene: Nullable<Scene>;
  7629. /** @hidden */
  7630. _texture: Nullable<InternalTexture>;
  7631. private _uid;
  7632. /**
  7633. * Define if the texture is preventinga material to render or not.
  7634. * If not and the texture is not ready, the engine will use a default black texture instead.
  7635. */
  7636. get isBlocking(): boolean;
  7637. /**
  7638. * Instantiates a new BaseTexture.
  7639. * Base class of all the textures in babylon.
  7640. * It groups all the common properties the materials, post process, lights... might need
  7641. * in order to make a correct use of the texture.
  7642. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7643. */
  7644. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7645. /**
  7646. * Get the scene the texture belongs to.
  7647. * @returns the scene or null if undefined
  7648. */
  7649. getScene(): Nullable<Scene>;
  7650. /** @hidden */
  7651. protected _getEngine(): Nullable<ThinEngine>;
  7652. /**
  7653. * Checks if the texture has the same transform matrix than another texture
  7654. * @param texture texture to check against
  7655. * @returns true if the transforms are the same, else false
  7656. */
  7657. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7658. /**
  7659. * Get the texture transform matrix used to offset tile the texture for istance.
  7660. * @returns the transformation matrix
  7661. */
  7662. getTextureMatrix(): Matrix;
  7663. /**
  7664. * Get the texture reflection matrix used to rotate/transform the reflection.
  7665. * @returns the reflection matrix
  7666. */
  7667. getReflectionTextureMatrix(): Matrix;
  7668. /**
  7669. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7670. * @returns true if ready or not blocking
  7671. */
  7672. isReadyOrNotBlocking(): boolean;
  7673. /**
  7674. * Scales the texture if is `canRescale()`
  7675. * @param ratio the resize factor we want to use to rescale
  7676. */
  7677. scale(ratio: number): void;
  7678. /**
  7679. * Get if the texture can rescale.
  7680. */
  7681. get canRescale(): boolean;
  7682. /** @hidden */
  7683. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7684. /** @hidden */
  7685. _rebuild(): void;
  7686. /**
  7687. * Clones the texture.
  7688. * @returns the cloned texture
  7689. */
  7690. clone(): Nullable<BaseTexture>;
  7691. /**
  7692. * Get the texture underlying type (INT, FLOAT...)
  7693. */
  7694. get textureType(): number;
  7695. /**
  7696. * Get the texture underlying format (RGB, RGBA...)
  7697. */
  7698. get textureFormat(): number;
  7699. /**
  7700. * Indicates that textures need to be re-calculated for all materials
  7701. */
  7702. protected _markAllSubMeshesAsTexturesDirty(): void;
  7703. /**
  7704. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7705. * This will returns an RGBA array buffer containing either in values (0-255) or
  7706. * float values (0-1) depending of the underlying buffer type.
  7707. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7708. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7709. * @param buffer defines a user defined buffer to fill with data (can be null)
  7710. * @returns The Array buffer containing the pixels data.
  7711. */
  7712. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  7713. /** @hidden */
  7714. get _lodTextureHigh(): Nullable<BaseTexture>;
  7715. /** @hidden */
  7716. get _lodTextureMid(): Nullable<BaseTexture>;
  7717. /** @hidden */
  7718. get _lodTextureLow(): Nullable<BaseTexture>;
  7719. /**
  7720. * Dispose the texture and release its associated resources.
  7721. */
  7722. dispose(): void;
  7723. /**
  7724. * Serialize the texture into a JSON representation that can be parsed later on.
  7725. * @returns the JSON representation of the texture
  7726. */
  7727. serialize(): any;
  7728. /**
  7729. * Helper function to be called back once a list of texture contains only ready textures.
  7730. * @param textures Define the list of textures to wait for
  7731. * @param callback Define the callback triggered once the entire list will be ready
  7732. */
  7733. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  7734. private static _isScene;
  7735. }
  7736. }
  7737. declare module BABYLON {
  7738. /** @hidden */
  7739. export class WebGLDataBuffer extends DataBuffer {
  7740. private _buffer;
  7741. constructor(resource: WebGLBuffer);
  7742. get underlyingResource(): any;
  7743. }
  7744. }
  7745. declare module BABYLON {
  7746. /** @hidden */
  7747. export class WebGLPipelineContext implements IPipelineContext {
  7748. engine: ThinEngine;
  7749. program: Nullable<WebGLProgram>;
  7750. context?: WebGLRenderingContext;
  7751. vertexShader?: WebGLShader;
  7752. fragmentShader?: WebGLShader;
  7753. isParallelCompiled: boolean;
  7754. onCompiled?: () => void;
  7755. transformFeedback?: WebGLTransformFeedback | null;
  7756. vertexCompilationError: Nullable<string>;
  7757. fragmentCompilationError: Nullable<string>;
  7758. programLinkError: Nullable<string>;
  7759. programValidationError: Nullable<string>;
  7760. get isAsync(): boolean;
  7761. get isReady(): boolean;
  7762. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7763. _getVertexShaderCode(): string | null;
  7764. _getFragmentShaderCode(): string | null;
  7765. }
  7766. }
  7767. declare module BABYLON {
  7768. interface ThinEngine {
  7769. /**
  7770. * Create an uniform buffer
  7771. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7772. * @param elements defines the content of the uniform buffer
  7773. * @returns the webGL uniform buffer
  7774. */
  7775. createUniformBuffer(elements: FloatArray): DataBuffer;
  7776. /**
  7777. * Create a dynamic uniform buffer
  7778. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7779. * @param elements defines the content of the uniform buffer
  7780. * @returns the webGL uniform buffer
  7781. */
  7782. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7783. /**
  7784. * Update an existing uniform buffer
  7785. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7786. * @param uniformBuffer defines the target uniform buffer
  7787. * @param elements defines the content to update
  7788. * @param offset defines the offset in the uniform buffer where update should start
  7789. * @param count defines the size of the data to update
  7790. */
  7791. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7792. /**
  7793. * Bind an uniform buffer to the current webGL context
  7794. * @param buffer defines the buffer to bind
  7795. */
  7796. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7797. /**
  7798. * Bind a buffer to the current webGL context at a given location
  7799. * @param buffer defines the buffer to bind
  7800. * @param location defines the index where to bind the buffer
  7801. */
  7802. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7803. /**
  7804. * Bind a specific block at a given index in a specific shader program
  7805. * @param pipelineContext defines the pipeline context to use
  7806. * @param blockName defines the block name
  7807. * @param index defines the index where to bind the block
  7808. */
  7809. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7810. }
  7811. }
  7812. declare module BABYLON {
  7813. /**
  7814. * Uniform buffer objects.
  7815. *
  7816. * Handles blocks of uniform on the GPU.
  7817. *
  7818. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7819. *
  7820. * For more information, please refer to :
  7821. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7822. */
  7823. export class UniformBuffer {
  7824. private _engine;
  7825. private _buffer;
  7826. private _data;
  7827. private _bufferData;
  7828. private _dynamic?;
  7829. private _uniformLocations;
  7830. private _uniformSizes;
  7831. private _uniformLocationPointer;
  7832. private _needSync;
  7833. private _noUBO;
  7834. private _currentEffect;
  7835. /** @hidden */
  7836. _alreadyBound: boolean;
  7837. private static _MAX_UNIFORM_SIZE;
  7838. private static _tempBuffer;
  7839. /**
  7840. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7841. * This is dynamic to allow compat with webgl 1 and 2.
  7842. * You will need to pass the name of the uniform as well as the value.
  7843. */
  7844. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7845. /**
  7846. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7847. * This is dynamic to allow compat with webgl 1 and 2.
  7848. * You will need to pass the name of the uniform as well as the value.
  7849. */
  7850. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7851. /**
  7852. * Lambda to Update a single float in a uniform buffer.
  7853. * This is dynamic to allow compat with webgl 1 and 2.
  7854. * You will need to pass the name of the uniform as well as the value.
  7855. */
  7856. updateFloat: (name: string, x: number) => void;
  7857. /**
  7858. * Lambda to Update a vec2 of float in a uniform buffer.
  7859. * This is dynamic to allow compat with webgl 1 and 2.
  7860. * You will need to pass the name of the uniform as well as the value.
  7861. */
  7862. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7863. /**
  7864. * Lambda to Update a vec3 of float in a uniform buffer.
  7865. * This is dynamic to allow compat with webgl 1 and 2.
  7866. * You will need to pass the name of the uniform as well as the value.
  7867. */
  7868. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7869. /**
  7870. * Lambda to Update a vec4 of float in a uniform buffer.
  7871. * This is dynamic to allow compat with webgl 1 and 2.
  7872. * You will need to pass the name of the uniform as well as the value.
  7873. */
  7874. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7875. /**
  7876. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7877. * This is dynamic to allow compat with webgl 1 and 2.
  7878. * You will need to pass the name of the uniform as well as the value.
  7879. */
  7880. updateMatrix: (name: string, mat: Matrix) => void;
  7881. /**
  7882. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7883. * This is dynamic to allow compat with webgl 1 and 2.
  7884. * You will need to pass the name of the uniform as well as the value.
  7885. */
  7886. updateVector3: (name: string, vector: Vector3) => void;
  7887. /**
  7888. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7889. * This is dynamic to allow compat with webgl 1 and 2.
  7890. * You will need to pass the name of the uniform as well as the value.
  7891. */
  7892. updateVector4: (name: string, vector: Vector4) => void;
  7893. /**
  7894. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7895. * This is dynamic to allow compat with webgl 1 and 2.
  7896. * You will need to pass the name of the uniform as well as the value.
  7897. */
  7898. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7899. /**
  7900. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7901. * This is dynamic to allow compat with webgl 1 and 2.
  7902. * You will need to pass the name of the uniform as well as the value.
  7903. */
  7904. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7905. /**
  7906. * Instantiates a new Uniform buffer objects.
  7907. *
  7908. * Handles blocks of uniform on the GPU.
  7909. *
  7910. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7911. *
  7912. * For more information, please refer to :
  7913. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7914. * @param engine Define the engine the buffer is associated with
  7915. * @param data Define the data contained in the buffer
  7916. * @param dynamic Define if the buffer is updatable
  7917. */
  7918. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7919. /**
  7920. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7921. * or just falling back on setUniformXXX calls.
  7922. */
  7923. get useUbo(): boolean;
  7924. /**
  7925. * Indicates if the WebGL underlying uniform buffer is in sync
  7926. * with the javascript cache data.
  7927. */
  7928. get isSync(): boolean;
  7929. /**
  7930. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7931. * Also, a dynamic UniformBuffer will disable cache verification and always
  7932. * update the underlying WebGL uniform buffer to the GPU.
  7933. * @returns if Dynamic, otherwise false
  7934. */
  7935. isDynamic(): boolean;
  7936. /**
  7937. * The data cache on JS side.
  7938. * @returns the underlying data as a float array
  7939. */
  7940. getData(): Float32Array;
  7941. /**
  7942. * The underlying WebGL Uniform buffer.
  7943. * @returns the webgl buffer
  7944. */
  7945. getBuffer(): Nullable<DataBuffer>;
  7946. /**
  7947. * std140 layout specifies how to align data within an UBO structure.
  7948. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7949. * for specs.
  7950. */
  7951. private _fillAlignment;
  7952. /**
  7953. * Adds an uniform in the buffer.
  7954. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7955. * for the layout to be correct !
  7956. * @param name Name of the uniform, as used in the uniform block in the shader.
  7957. * @param size Data size, or data directly.
  7958. */
  7959. addUniform(name: string, size: number | number[]): void;
  7960. /**
  7961. * Adds a Matrix 4x4 to the uniform buffer.
  7962. * @param name Name of the uniform, as used in the uniform block in the shader.
  7963. * @param mat A 4x4 matrix.
  7964. */
  7965. addMatrix(name: string, mat: Matrix): void;
  7966. /**
  7967. * Adds a vec2 to the uniform buffer.
  7968. * @param name Name of the uniform, as used in the uniform block in the shader.
  7969. * @param x Define the x component value of the vec2
  7970. * @param y Define the y component value of the vec2
  7971. */
  7972. addFloat2(name: string, x: number, y: number): void;
  7973. /**
  7974. * Adds a vec3 to the uniform buffer.
  7975. * @param name Name of the uniform, as used in the uniform block in the shader.
  7976. * @param x Define the x component value of the vec3
  7977. * @param y Define the y component value of the vec3
  7978. * @param z Define the z component value of the vec3
  7979. */
  7980. addFloat3(name: string, x: number, y: number, z: number): void;
  7981. /**
  7982. * Adds a vec3 to the uniform buffer.
  7983. * @param name Name of the uniform, as used in the uniform block in the shader.
  7984. * @param color Define the vec3 from a Color
  7985. */
  7986. addColor3(name: string, color: Color3): void;
  7987. /**
  7988. * Adds a vec4 to the uniform buffer.
  7989. * @param name Name of the uniform, as used in the uniform block in the shader.
  7990. * @param color Define the rgb components from a Color
  7991. * @param alpha Define the a component of the vec4
  7992. */
  7993. addColor4(name: string, color: Color3, alpha: number): void;
  7994. /**
  7995. * Adds a vec3 to the uniform buffer.
  7996. * @param name Name of the uniform, as used in the uniform block in the shader.
  7997. * @param vector Define the vec3 components from a Vector
  7998. */
  7999. addVector3(name: string, vector: Vector3): void;
  8000. /**
  8001. * Adds a Matrix 3x3 to the uniform buffer.
  8002. * @param name Name of the uniform, as used in the uniform block in the shader.
  8003. */
  8004. addMatrix3x3(name: string): void;
  8005. /**
  8006. * Adds a Matrix 2x2 to the uniform buffer.
  8007. * @param name Name of the uniform, as used in the uniform block in the shader.
  8008. */
  8009. addMatrix2x2(name: string): void;
  8010. /**
  8011. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8012. */
  8013. create(): void;
  8014. /** @hidden */
  8015. _rebuild(): void;
  8016. /**
  8017. * Updates the WebGL Uniform Buffer on the GPU.
  8018. * If the `dynamic` flag is set to true, no cache comparison is done.
  8019. * Otherwise, the buffer will be updated only if the cache differs.
  8020. */
  8021. update(): void;
  8022. /**
  8023. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8024. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8025. * @param data Define the flattened data
  8026. * @param size Define the size of the data.
  8027. */
  8028. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8029. private _valueCache;
  8030. private _cacheMatrix;
  8031. private _updateMatrix3x3ForUniform;
  8032. private _updateMatrix3x3ForEffect;
  8033. private _updateMatrix2x2ForEffect;
  8034. private _updateMatrix2x2ForUniform;
  8035. private _updateFloatForEffect;
  8036. private _updateFloatForUniform;
  8037. private _updateFloat2ForEffect;
  8038. private _updateFloat2ForUniform;
  8039. private _updateFloat3ForEffect;
  8040. private _updateFloat3ForUniform;
  8041. private _updateFloat4ForEffect;
  8042. private _updateFloat4ForUniform;
  8043. private _updateMatrixForEffect;
  8044. private _updateMatrixForUniform;
  8045. private _updateVector3ForEffect;
  8046. private _updateVector3ForUniform;
  8047. private _updateVector4ForEffect;
  8048. private _updateVector4ForUniform;
  8049. private _updateColor3ForEffect;
  8050. private _updateColor3ForUniform;
  8051. private _updateColor4ForEffect;
  8052. private _updateColor4ForUniform;
  8053. /**
  8054. * Sets a sampler uniform on the effect.
  8055. * @param name Define the name of the sampler.
  8056. * @param texture Define the texture to set in the sampler
  8057. */
  8058. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8059. /**
  8060. * Directly updates the value of the uniform in the cache AND on the GPU.
  8061. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8062. * @param data Define the flattened data
  8063. */
  8064. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8065. /**
  8066. * Binds this uniform buffer to an effect.
  8067. * @param effect Define the effect to bind the buffer to
  8068. * @param name Name of the uniform block in the shader.
  8069. */
  8070. bindToEffect(effect: Effect, name: string): void;
  8071. /**
  8072. * Disposes the uniform buffer.
  8073. */
  8074. dispose(): void;
  8075. }
  8076. }
  8077. declare module BABYLON {
  8078. /**
  8079. * Manages the defines for the Material
  8080. */
  8081. export class MaterialDefines {
  8082. /** @hidden */
  8083. protected _keys: string[];
  8084. private _isDirty;
  8085. /** @hidden */
  8086. _renderId: number;
  8087. /** @hidden */
  8088. _areLightsDirty: boolean;
  8089. /** @hidden */
  8090. _areLightsDisposed: boolean;
  8091. /** @hidden */
  8092. _areAttributesDirty: boolean;
  8093. /** @hidden */
  8094. _areTexturesDirty: boolean;
  8095. /** @hidden */
  8096. _areFresnelDirty: boolean;
  8097. /** @hidden */
  8098. _areMiscDirty: boolean;
  8099. /** @hidden */
  8100. _arePrePassDirty: boolean;
  8101. /** @hidden */
  8102. _areImageProcessingDirty: boolean;
  8103. /** @hidden */
  8104. _normals: boolean;
  8105. /** @hidden */
  8106. _uvs: boolean;
  8107. /** @hidden */
  8108. _needNormals: boolean;
  8109. /** @hidden */
  8110. _needUVs: boolean;
  8111. [id: string]: any;
  8112. /**
  8113. * Specifies if the material needs to be re-calculated
  8114. */
  8115. get isDirty(): boolean;
  8116. /**
  8117. * Marks the material to indicate that it has been re-calculated
  8118. */
  8119. markAsProcessed(): void;
  8120. /**
  8121. * Marks the material to indicate that it needs to be re-calculated
  8122. */
  8123. markAsUnprocessed(): void;
  8124. /**
  8125. * Marks the material to indicate all of its defines need to be re-calculated
  8126. */
  8127. markAllAsDirty(): void;
  8128. /**
  8129. * Marks the material to indicate that image processing needs to be re-calculated
  8130. */
  8131. markAsImageProcessingDirty(): void;
  8132. /**
  8133. * Marks the material to indicate the lights need to be re-calculated
  8134. * @param disposed Defines whether the light is dirty due to dispose or not
  8135. */
  8136. markAsLightDirty(disposed?: boolean): void;
  8137. /**
  8138. * Marks the attribute state as changed
  8139. */
  8140. markAsAttributesDirty(): void;
  8141. /**
  8142. * Marks the texture state as changed
  8143. */
  8144. markAsTexturesDirty(): void;
  8145. /**
  8146. * Marks the fresnel state as changed
  8147. */
  8148. markAsFresnelDirty(): void;
  8149. /**
  8150. * Marks the misc state as changed
  8151. */
  8152. markAsMiscDirty(): void;
  8153. /**
  8154. * Marks the prepass state as changed
  8155. */
  8156. markAsPrePassDirty(): void;
  8157. /**
  8158. * Rebuilds the material defines
  8159. */
  8160. rebuild(): void;
  8161. /**
  8162. * Specifies if two material defines are equal
  8163. * @param other - A material define instance to compare to
  8164. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8165. */
  8166. isEqual(other: MaterialDefines): boolean;
  8167. /**
  8168. * Clones this instance's defines to another instance
  8169. * @param other - material defines to clone values to
  8170. */
  8171. cloneTo(other: MaterialDefines): void;
  8172. /**
  8173. * Resets the material define values
  8174. */
  8175. reset(): void;
  8176. /**
  8177. * Converts the material define values to a string
  8178. * @returns - String of material define information
  8179. */
  8180. toString(): string;
  8181. }
  8182. }
  8183. declare module BABYLON {
  8184. /**
  8185. * Enum that determines the text-wrapping mode to use.
  8186. */
  8187. export enum InspectableType {
  8188. /**
  8189. * Checkbox for booleans
  8190. */
  8191. Checkbox = 0,
  8192. /**
  8193. * Sliders for numbers
  8194. */
  8195. Slider = 1,
  8196. /**
  8197. * Vector3
  8198. */
  8199. Vector3 = 2,
  8200. /**
  8201. * Quaternions
  8202. */
  8203. Quaternion = 3,
  8204. /**
  8205. * Color3
  8206. */
  8207. Color3 = 4,
  8208. /**
  8209. * String
  8210. */
  8211. String = 5
  8212. }
  8213. /**
  8214. * Interface used to define custom inspectable properties.
  8215. * This interface is used by the inspector to display custom property grids
  8216. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8217. */
  8218. export interface IInspectable {
  8219. /**
  8220. * Gets the label to display
  8221. */
  8222. label: string;
  8223. /**
  8224. * Gets the name of the property to edit
  8225. */
  8226. propertyName: string;
  8227. /**
  8228. * Gets the type of the editor to use
  8229. */
  8230. type: InspectableType;
  8231. /**
  8232. * Gets the minimum value of the property when using in "slider" mode
  8233. */
  8234. min?: number;
  8235. /**
  8236. * Gets the maximum value of the property when using in "slider" mode
  8237. */
  8238. max?: number;
  8239. /**
  8240. * Gets the setp to use when using in "slider" mode
  8241. */
  8242. step?: number;
  8243. }
  8244. }
  8245. declare module BABYLON {
  8246. /**
  8247. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8248. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8249. * 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.
  8250. */
  8251. export abstract class Light extends Node {
  8252. /**
  8253. * Falloff Default: light is falling off following the material specification:
  8254. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8255. */
  8256. static readonly FALLOFF_DEFAULT: number;
  8257. /**
  8258. * Falloff Physical: light is falling off following the inverse squared distance law.
  8259. */
  8260. static readonly FALLOFF_PHYSICAL: number;
  8261. /**
  8262. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8263. * to enhance interoperability with other engines.
  8264. */
  8265. static readonly FALLOFF_GLTF: number;
  8266. /**
  8267. * Falloff Standard: light is falling off like in the standard material
  8268. * to enhance interoperability with other materials.
  8269. */
  8270. static readonly FALLOFF_STANDARD: number;
  8271. /**
  8272. * If every light affecting the material is in this lightmapMode,
  8273. * material.lightmapTexture adds or multiplies
  8274. * (depends on material.useLightmapAsShadowmap)
  8275. * after every other light calculations.
  8276. */
  8277. static readonly LIGHTMAP_DEFAULT: number;
  8278. /**
  8279. * material.lightmapTexture as only diffuse lighting from this light
  8280. * adds only specular lighting from this light
  8281. * adds dynamic shadows
  8282. */
  8283. static readonly LIGHTMAP_SPECULAR: number;
  8284. /**
  8285. * material.lightmapTexture as only lighting
  8286. * no light calculation from this light
  8287. * only adds dynamic shadows from this light
  8288. */
  8289. static readonly LIGHTMAP_SHADOWSONLY: number;
  8290. /**
  8291. * Each light type uses the default quantity according to its type:
  8292. * point/spot lights use luminous intensity
  8293. * directional lights use illuminance
  8294. */
  8295. static readonly INTENSITYMODE_AUTOMATIC: number;
  8296. /**
  8297. * lumen (lm)
  8298. */
  8299. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8300. /**
  8301. * candela (lm/sr)
  8302. */
  8303. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8304. /**
  8305. * lux (lm/m^2)
  8306. */
  8307. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8308. /**
  8309. * nit (cd/m^2)
  8310. */
  8311. static readonly INTENSITYMODE_LUMINANCE: number;
  8312. /**
  8313. * Light type const id of the point light.
  8314. */
  8315. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8316. /**
  8317. * Light type const id of the directional light.
  8318. */
  8319. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8320. /**
  8321. * Light type const id of the spot light.
  8322. */
  8323. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8324. /**
  8325. * Light type const id of the hemispheric light.
  8326. */
  8327. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8328. /**
  8329. * Diffuse gives the basic color to an object.
  8330. */
  8331. diffuse: Color3;
  8332. /**
  8333. * Specular produces a highlight color on an object.
  8334. * Note: This is note affecting PBR materials.
  8335. */
  8336. specular: Color3;
  8337. /**
  8338. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8339. * falling off base on range or angle.
  8340. * This can be set to any values in Light.FALLOFF_x.
  8341. *
  8342. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8343. * other types of materials.
  8344. */
  8345. falloffType: number;
  8346. /**
  8347. * Strength of the light.
  8348. * Note: By default it is define in the framework own unit.
  8349. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8350. */
  8351. intensity: number;
  8352. private _range;
  8353. protected _inverseSquaredRange: number;
  8354. /**
  8355. * Defines how far from the source the light is impacting in scene units.
  8356. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8357. */
  8358. get range(): number;
  8359. /**
  8360. * Defines how far from the source the light is impacting in scene units.
  8361. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8362. */
  8363. set range(value: number);
  8364. /**
  8365. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8366. * of light.
  8367. */
  8368. private _photometricScale;
  8369. private _intensityMode;
  8370. /**
  8371. * Gets the photometric scale used to interpret the intensity.
  8372. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8373. */
  8374. get intensityMode(): number;
  8375. /**
  8376. * Sets the photometric scale used to interpret the intensity.
  8377. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8378. */
  8379. set intensityMode(value: number);
  8380. private _radius;
  8381. /**
  8382. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8383. */
  8384. get radius(): number;
  8385. /**
  8386. * sets the light radius used by PBR Materials to simulate soft area lights.
  8387. */
  8388. set radius(value: number);
  8389. private _renderPriority;
  8390. /**
  8391. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8392. * exceeding the number allowed of the materials.
  8393. */
  8394. renderPriority: number;
  8395. private _shadowEnabled;
  8396. /**
  8397. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8398. * the current shadow generator.
  8399. */
  8400. get shadowEnabled(): boolean;
  8401. /**
  8402. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8403. * the current shadow generator.
  8404. */
  8405. set shadowEnabled(value: boolean);
  8406. private _includedOnlyMeshes;
  8407. /**
  8408. * Gets the only meshes impacted by this light.
  8409. */
  8410. get includedOnlyMeshes(): AbstractMesh[];
  8411. /**
  8412. * Sets the only meshes impacted by this light.
  8413. */
  8414. set includedOnlyMeshes(value: AbstractMesh[]);
  8415. private _excludedMeshes;
  8416. /**
  8417. * Gets the meshes not impacted by this light.
  8418. */
  8419. get excludedMeshes(): AbstractMesh[];
  8420. /**
  8421. * Sets the meshes not impacted by this light.
  8422. */
  8423. set excludedMeshes(value: AbstractMesh[]);
  8424. private _excludeWithLayerMask;
  8425. /**
  8426. * Gets the layer id use to find what meshes are not impacted by the light.
  8427. * Inactive if 0
  8428. */
  8429. get excludeWithLayerMask(): number;
  8430. /**
  8431. * Sets the layer id use to find what meshes are not impacted by the light.
  8432. * Inactive if 0
  8433. */
  8434. set excludeWithLayerMask(value: number);
  8435. private _includeOnlyWithLayerMask;
  8436. /**
  8437. * Gets the layer id use to find what meshes are impacted by the light.
  8438. * Inactive if 0
  8439. */
  8440. get includeOnlyWithLayerMask(): number;
  8441. /**
  8442. * Sets the layer id use to find what meshes are impacted by the light.
  8443. * Inactive if 0
  8444. */
  8445. set includeOnlyWithLayerMask(value: number);
  8446. private _lightmapMode;
  8447. /**
  8448. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8449. */
  8450. get lightmapMode(): number;
  8451. /**
  8452. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8453. */
  8454. set lightmapMode(value: number);
  8455. /**
  8456. * Shadow generator associted to the light.
  8457. * @hidden Internal use only.
  8458. */
  8459. _shadowGenerator: Nullable<IShadowGenerator>;
  8460. /**
  8461. * @hidden Internal use only.
  8462. */
  8463. _excludedMeshesIds: string[];
  8464. /**
  8465. * @hidden Internal use only.
  8466. */
  8467. _includedOnlyMeshesIds: string[];
  8468. /**
  8469. * The current light unifom buffer.
  8470. * @hidden Internal use only.
  8471. */
  8472. _uniformBuffer: UniformBuffer;
  8473. /** @hidden */
  8474. _renderId: number;
  8475. /**
  8476. * Creates a Light object in the scene.
  8477. * Documentation : https://doc.babylonjs.com/babylon101/lights
  8478. * @param name The firendly name of the light
  8479. * @param scene The scene the light belongs too
  8480. */
  8481. constructor(name: string, scene: Scene);
  8482. protected abstract _buildUniformLayout(): void;
  8483. /**
  8484. * Sets the passed Effect "effect" with the Light information.
  8485. * @param effect The effect to update
  8486. * @param lightIndex The index of the light in the effect to update
  8487. * @returns The light
  8488. */
  8489. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8490. /**
  8491. * Sets the passed Effect "effect" with the Light textures.
  8492. * @param effect The effect to update
  8493. * @param lightIndex The index of the light in the effect to update
  8494. * @returns The light
  8495. */
  8496. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  8497. /**
  8498. * Binds the lights information from the scene to the effect for the given mesh.
  8499. * @param lightIndex Light index
  8500. * @param scene The scene where the light belongs to
  8501. * @param effect The effect we are binding the data to
  8502. * @param useSpecular Defines if specular is supported
  8503. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8504. */
  8505. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  8506. /**
  8507. * Sets the passed Effect "effect" with the Light information.
  8508. * @param effect The effect to update
  8509. * @param lightDataUniformName The uniform used to store light data (position or direction)
  8510. * @returns The light
  8511. */
  8512. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  8513. /**
  8514. * Returns the string "Light".
  8515. * @returns the class name
  8516. */
  8517. getClassName(): string;
  8518. /** @hidden */
  8519. readonly _isLight: boolean;
  8520. /**
  8521. * Converts the light information to a readable string for debug purpose.
  8522. * @param fullDetails Supports for multiple levels of logging within scene loading
  8523. * @returns the human readable light info
  8524. */
  8525. toString(fullDetails?: boolean): string;
  8526. /** @hidden */
  8527. protected _syncParentEnabledState(): void;
  8528. /**
  8529. * Set the enabled state of this node.
  8530. * @param value - the new enabled state
  8531. */
  8532. setEnabled(value: boolean): void;
  8533. /**
  8534. * Returns the Light associated shadow generator if any.
  8535. * @return the associated shadow generator.
  8536. */
  8537. getShadowGenerator(): Nullable<IShadowGenerator>;
  8538. /**
  8539. * Returns a Vector3, the absolute light position in the World.
  8540. * @returns the world space position of the light
  8541. */
  8542. getAbsolutePosition(): Vector3;
  8543. /**
  8544. * Specifies if the light will affect the passed mesh.
  8545. * @param mesh The mesh to test against the light
  8546. * @return true the mesh is affected otherwise, false.
  8547. */
  8548. canAffectMesh(mesh: AbstractMesh): boolean;
  8549. /**
  8550. * Sort function to order lights for rendering.
  8551. * @param a First Light object to compare to second.
  8552. * @param b Second Light object to compare first.
  8553. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8554. */
  8555. static CompareLightsPriority(a: Light, b: Light): number;
  8556. /**
  8557. * Releases resources associated with this node.
  8558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8560. */
  8561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8562. /**
  8563. * Returns the light type ID (integer).
  8564. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8565. */
  8566. getTypeID(): number;
  8567. /**
  8568. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8569. * @returns the scaled intensity in intensity mode unit
  8570. */
  8571. getScaledIntensity(): number;
  8572. /**
  8573. * Returns a new Light object, named "name", from the current one.
  8574. * @param name The name of the cloned light
  8575. * @param newParent The parent of this light, if it has one
  8576. * @returns the new created light
  8577. */
  8578. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  8579. /**
  8580. * Serializes the current light into a Serialization object.
  8581. * @returns the serialized object.
  8582. */
  8583. serialize(): any;
  8584. /**
  8585. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8586. * This new light is named "name" and added to the passed scene.
  8587. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8588. * @param name The friendly name of the light
  8589. * @param scene The scene the new light will belong to
  8590. * @returns the constructor function
  8591. */
  8592. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8593. /**
  8594. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8595. * @param parsedLight The JSON representation of the light
  8596. * @param scene The scene to create the parsed light in
  8597. * @returns the created light after parsing
  8598. */
  8599. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8600. private _hookArrayForExcluded;
  8601. private _hookArrayForIncludedOnly;
  8602. private _resyncMeshes;
  8603. /**
  8604. * Forces the meshes to update their light related information in their rendering used effects
  8605. * @hidden Internal Use Only
  8606. */
  8607. _markMeshesAsLightDirty(): void;
  8608. /**
  8609. * Recomputes the cached photometric scale if needed.
  8610. */
  8611. private _computePhotometricScale;
  8612. /**
  8613. * Returns the Photometric Scale according to the light type and intensity mode.
  8614. */
  8615. private _getPhotometricScale;
  8616. /**
  8617. * Reorder the light in the scene according to their defined priority.
  8618. * @hidden Internal Use Only
  8619. */
  8620. _reorderLightsInScene(): void;
  8621. /**
  8622. * Prepares the list of defines specific to the light type.
  8623. * @param defines the list of defines
  8624. * @param lightIndex defines the index of the light for the effect
  8625. */
  8626. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  8627. }
  8628. }
  8629. declare module BABYLON {
  8630. /** Defines supported spaces */
  8631. export enum Space {
  8632. /** Local (object) space */
  8633. LOCAL = 0,
  8634. /** World space */
  8635. WORLD = 1,
  8636. /** Bone space */
  8637. BONE = 2
  8638. }
  8639. /** Defines the 3 main axes */
  8640. export class Axis {
  8641. /** X axis */
  8642. static X: Vector3;
  8643. /** Y axis */
  8644. static Y: Vector3;
  8645. /** Z axis */
  8646. static Z: Vector3;
  8647. }
  8648. /**
  8649. * Defines cartesian components.
  8650. */
  8651. export enum Coordinate {
  8652. /** X axis */
  8653. X = 0,
  8654. /** Y axis */
  8655. Y = 1,
  8656. /** Z axis */
  8657. Z = 2
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /**
  8662. * Interface describing all the common properties and methods a shadow light needs to implement.
  8663. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8664. * as well as binding the different shadow properties to the effects.
  8665. */
  8666. export interface IShadowLight extends Light {
  8667. /**
  8668. * The light id in the scene (used in scene.findLighById for instance)
  8669. */
  8670. id: string;
  8671. /**
  8672. * The position the shdow will be casted from.
  8673. */
  8674. position: Vector3;
  8675. /**
  8676. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8677. */
  8678. direction: Vector3;
  8679. /**
  8680. * The transformed position. Position of the light in world space taking parenting in account.
  8681. */
  8682. transformedPosition: Vector3;
  8683. /**
  8684. * The transformed direction. Direction of the light in world space taking parenting in account.
  8685. */
  8686. transformedDirection: Vector3;
  8687. /**
  8688. * The friendly name of the light in the scene.
  8689. */
  8690. name: string;
  8691. /**
  8692. * Defines the shadow projection clipping minimum z value.
  8693. */
  8694. shadowMinZ: number;
  8695. /**
  8696. * Defines the shadow projection clipping maximum z value.
  8697. */
  8698. shadowMaxZ: number;
  8699. /**
  8700. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8701. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8702. */
  8703. computeTransformedInformation(): boolean;
  8704. /**
  8705. * Gets the scene the light belongs to.
  8706. * @returns The scene
  8707. */
  8708. getScene(): Scene;
  8709. /**
  8710. * Callback defining a custom Projection Matrix Builder.
  8711. * This can be used to override the default projection matrix computation.
  8712. */
  8713. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8714. /**
  8715. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8716. * @param matrix The materix to updated with the projection information
  8717. * @param viewMatrix The transform matrix of the light
  8718. * @param renderList The list of mesh to render in the map
  8719. * @returns The current light
  8720. */
  8721. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8722. /**
  8723. * Gets the current depth scale used in ESM.
  8724. * @returns The scale
  8725. */
  8726. getDepthScale(): number;
  8727. /**
  8728. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8729. * @returns true if a cube texture needs to be use
  8730. */
  8731. needCube(): boolean;
  8732. /**
  8733. * Detects if the projection matrix requires to be recomputed this frame.
  8734. * @returns true if it requires to be recomputed otherwise, false.
  8735. */
  8736. needProjectionMatrixCompute(): boolean;
  8737. /**
  8738. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8739. */
  8740. forceProjectionMatrixCompute(): void;
  8741. /**
  8742. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8743. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8744. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8745. */
  8746. getShadowDirection(faceIndex?: number): Vector3;
  8747. /**
  8748. * Gets the minZ used for shadow according to both the scene and the light.
  8749. * @param activeCamera The camera we are returning the min for
  8750. * @returns the depth min z
  8751. */
  8752. getDepthMinZ(activeCamera: Camera): number;
  8753. /**
  8754. * Gets the maxZ used for shadow according to both the scene and the light.
  8755. * @param activeCamera The camera we are returning the max for
  8756. * @returns the depth max z
  8757. */
  8758. getDepthMaxZ(activeCamera: Camera): number;
  8759. }
  8760. /**
  8761. * Base implementation IShadowLight
  8762. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8763. */
  8764. export abstract class ShadowLight extends Light implements IShadowLight {
  8765. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8766. protected _position: Vector3;
  8767. protected _setPosition(value: Vector3): void;
  8768. /**
  8769. * Sets the position the shadow will be casted from. Also use as the light position for both
  8770. * point and spot lights.
  8771. */
  8772. get position(): Vector3;
  8773. /**
  8774. * Sets the position the shadow will be casted from. Also use as the light position for both
  8775. * point and spot lights.
  8776. */
  8777. set position(value: Vector3);
  8778. protected _direction: Vector3;
  8779. protected _setDirection(value: Vector3): void;
  8780. /**
  8781. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8782. * Also use as the light direction on spot and directional lights.
  8783. */
  8784. get direction(): Vector3;
  8785. /**
  8786. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8787. * Also use as the light direction on spot and directional lights.
  8788. */
  8789. set direction(value: Vector3);
  8790. protected _shadowMinZ: number;
  8791. /**
  8792. * Gets the shadow projection clipping minimum z value.
  8793. */
  8794. get shadowMinZ(): number;
  8795. /**
  8796. * Sets the shadow projection clipping minimum z value.
  8797. */
  8798. set shadowMinZ(value: number);
  8799. protected _shadowMaxZ: number;
  8800. /**
  8801. * Sets the shadow projection clipping maximum z value.
  8802. */
  8803. get shadowMaxZ(): number;
  8804. /**
  8805. * Gets the shadow projection clipping maximum z value.
  8806. */
  8807. set shadowMaxZ(value: number);
  8808. /**
  8809. * Callback defining a custom Projection Matrix Builder.
  8810. * This can be used to override the default projection matrix computation.
  8811. */
  8812. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8813. /**
  8814. * The transformed position. Position of the light in world space taking parenting in account.
  8815. */
  8816. transformedPosition: Vector3;
  8817. /**
  8818. * The transformed direction. Direction of the light in world space taking parenting in account.
  8819. */
  8820. transformedDirection: Vector3;
  8821. private _needProjectionMatrixCompute;
  8822. /**
  8823. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8824. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8825. */
  8826. computeTransformedInformation(): boolean;
  8827. /**
  8828. * Return the depth scale used for the shadow map.
  8829. * @returns the depth scale.
  8830. */
  8831. getDepthScale(): number;
  8832. /**
  8833. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8834. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8835. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8836. */
  8837. getShadowDirection(faceIndex?: number): Vector3;
  8838. /**
  8839. * Returns the ShadowLight absolute position in the World.
  8840. * @returns the position vector in world space
  8841. */
  8842. getAbsolutePosition(): Vector3;
  8843. /**
  8844. * Sets the ShadowLight direction toward the passed target.
  8845. * @param target The point to target in local space
  8846. * @returns the updated ShadowLight direction
  8847. */
  8848. setDirectionToTarget(target: Vector3): Vector3;
  8849. /**
  8850. * Returns the light rotation in euler definition.
  8851. * @returns the x y z rotation in local space.
  8852. */
  8853. getRotation(): Vector3;
  8854. /**
  8855. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8856. * @returns true if a cube texture needs to be use
  8857. */
  8858. needCube(): boolean;
  8859. /**
  8860. * Detects if the projection matrix requires to be recomputed this frame.
  8861. * @returns true if it requires to be recomputed otherwise, false.
  8862. */
  8863. needProjectionMatrixCompute(): boolean;
  8864. /**
  8865. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8866. */
  8867. forceProjectionMatrixCompute(): void;
  8868. /** @hidden */
  8869. _initCache(): void;
  8870. /** @hidden */
  8871. _isSynchronized(): boolean;
  8872. /**
  8873. * Computes the world matrix of the node
  8874. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8875. * @returns the world matrix
  8876. */
  8877. computeWorldMatrix(force?: boolean): Matrix;
  8878. /**
  8879. * Gets the minZ used for shadow according to both the scene and the light.
  8880. * @param activeCamera The camera we are returning the min for
  8881. * @returns the depth min z
  8882. */
  8883. getDepthMinZ(activeCamera: Camera): number;
  8884. /**
  8885. * Gets the maxZ used for shadow according to both the scene and the light.
  8886. * @param activeCamera The camera we are returning the max for
  8887. * @returns the depth max z
  8888. */
  8889. getDepthMaxZ(activeCamera: Camera): number;
  8890. /**
  8891. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8892. * @param matrix The materix to updated with the projection information
  8893. * @param viewMatrix The transform matrix of the light
  8894. * @param renderList The list of mesh to render in the map
  8895. * @returns The current light
  8896. */
  8897. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8898. }
  8899. }
  8900. declare module BABYLON {
  8901. /**
  8902. * Configuration needed for prepass-capable materials
  8903. */
  8904. export class PrePassConfiguration {
  8905. /**
  8906. * Previous world matrices of meshes carrying this material
  8907. * Used for computing velocity
  8908. */
  8909. previousWorldMatrices: {
  8910. [index: number]: Matrix;
  8911. };
  8912. /**
  8913. * Previous view project matrix
  8914. * Used for computing velocity
  8915. */
  8916. previousViewProjection: Matrix;
  8917. /**
  8918. * Previous bones of meshes carrying this material
  8919. * Used for computing velocity
  8920. */
  8921. previousBones: {
  8922. [index: number]: Float32Array;
  8923. };
  8924. /**
  8925. * Add the required uniforms to the current list.
  8926. * @param uniforms defines the current uniform list.
  8927. */
  8928. static AddUniforms(uniforms: string[]): void;
  8929. /**
  8930. * Add the required samplers to the current list.
  8931. * @param samplers defines the current sampler list.
  8932. */
  8933. static AddSamplers(samplers: string[]): void;
  8934. /**
  8935. * Binds the material data.
  8936. * @param effect defines the effect to update
  8937. * @param scene defines the scene the material belongs to.
  8938. * @param mesh The mesh
  8939. * @param world World matrix of this mesh
  8940. * @param isFrozen Is the material frozen
  8941. */
  8942. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  8943. }
  8944. }
  8945. declare module BABYLON {
  8946. /**
  8947. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8948. * This is the base of the follow, arc rotate cameras and Free camera
  8949. * @see https://doc.babylonjs.com/features/cameras
  8950. */
  8951. export class TargetCamera extends Camera {
  8952. private static _RigCamTransformMatrix;
  8953. private static _TargetTransformMatrix;
  8954. private static _TargetFocalPoint;
  8955. private _tmpUpVector;
  8956. private _tmpTargetVector;
  8957. /**
  8958. * Define the current direction the camera is moving to
  8959. */
  8960. cameraDirection: Vector3;
  8961. /**
  8962. * Define the current rotation the camera is rotating to
  8963. */
  8964. cameraRotation: Vector2;
  8965. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  8966. ignoreParentScaling: boolean;
  8967. /**
  8968. * When set, the up vector of the camera will be updated by the rotation of the camera
  8969. */
  8970. updateUpVectorFromRotation: boolean;
  8971. private _tmpQuaternion;
  8972. /**
  8973. * Define the current rotation of the camera
  8974. */
  8975. rotation: Vector3;
  8976. /**
  8977. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8978. */
  8979. rotationQuaternion: Quaternion;
  8980. /**
  8981. * Define the current speed of the camera
  8982. */
  8983. speed: number;
  8984. /**
  8985. * Add constraint to the camera to prevent it to move freely in all directions and
  8986. * around all axis.
  8987. */
  8988. noRotationConstraint: boolean;
  8989. /**
  8990. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8991. * panning
  8992. */
  8993. invertRotation: boolean;
  8994. /**
  8995. * Speed multiplier for inverse camera panning
  8996. */
  8997. inverseRotationSpeed: number;
  8998. /**
  8999. * Define the current target of the camera as an object or a position.
  9000. */
  9001. lockedTarget: any;
  9002. /** @hidden */
  9003. _currentTarget: Vector3;
  9004. /** @hidden */
  9005. _initialFocalDistance: number;
  9006. /** @hidden */
  9007. _viewMatrix: Matrix;
  9008. /** @hidden */
  9009. _camMatrix: Matrix;
  9010. /** @hidden */
  9011. _cameraTransformMatrix: Matrix;
  9012. /** @hidden */
  9013. _cameraRotationMatrix: Matrix;
  9014. /** @hidden */
  9015. _referencePoint: Vector3;
  9016. /** @hidden */
  9017. _transformedReferencePoint: Vector3;
  9018. /** @hidden */
  9019. _reset: () => void;
  9020. private _defaultUp;
  9021. /**
  9022. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9023. * This is the base of the follow, arc rotate cameras and Free camera
  9024. * @see https://doc.babylonjs.com/features/cameras
  9025. * @param name Defines the name of the camera in the scene
  9026. * @param position Defines the start position of the camera in the scene
  9027. * @param scene Defines the scene the camera belongs to
  9028. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9029. */
  9030. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9031. /**
  9032. * Gets the position in front of the camera at a given distance.
  9033. * @param distance The distance from the camera we want the position to be
  9034. * @returns the position
  9035. */
  9036. getFrontPosition(distance: number): Vector3;
  9037. /** @hidden */
  9038. _getLockedTargetPosition(): Nullable<Vector3>;
  9039. private _storedPosition;
  9040. private _storedRotation;
  9041. private _storedRotationQuaternion;
  9042. /**
  9043. * Store current camera state of the camera (fov, position, rotation, etc..)
  9044. * @returns the camera
  9045. */
  9046. storeState(): Camera;
  9047. /**
  9048. * Restored camera state. You must call storeState() first
  9049. * @returns whether it was successful or not
  9050. * @hidden
  9051. */
  9052. _restoreStateValues(): boolean;
  9053. /** @hidden */
  9054. _initCache(): void;
  9055. /** @hidden */
  9056. _updateCache(ignoreParentClass?: boolean): void;
  9057. /** @hidden */
  9058. _isSynchronizedViewMatrix(): boolean;
  9059. /** @hidden */
  9060. _computeLocalCameraSpeed(): number;
  9061. /**
  9062. * Defines the target the camera should look at.
  9063. * @param target Defines the new target as a Vector or a mesh
  9064. */
  9065. setTarget(target: Vector3): void;
  9066. /**
  9067. * Defines the target point of the camera.
  9068. * The camera looks towards it form the radius distance.
  9069. */
  9070. get target(): Vector3;
  9071. set target(value: Vector3);
  9072. /**
  9073. * Return the current target position of the camera. This value is expressed in local space.
  9074. * @returns the target position
  9075. */
  9076. getTarget(): Vector3;
  9077. /** @hidden */
  9078. _decideIfNeedsToMove(): boolean;
  9079. /** @hidden */
  9080. _updatePosition(): void;
  9081. /** @hidden */
  9082. _checkInputs(): void;
  9083. protected _updateCameraRotationMatrix(): void;
  9084. /**
  9085. * 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)
  9086. * @returns the current camera
  9087. */
  9088. private _rotateUpVectorWithCameraRotationMatrix;
  9089. private _cachedRotationZ;
  9090. private _cachedQuaternionRotationZ;
  9091. /** @hidden */
  9092. _getViewMatrix(): Matrix;
  9093. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9094. /**
  9095. * @hidden
  9096. */
  9097. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9098. /**
  9099. * @hidden
  9100. */
  9101. _updateRigCameras(): void;
  9102. private _getRigCamPositionAndTarget;
  9103. /**
  9104. * Gets the current object class name.
  9105. * @return the class name
  9106. */
  9107. getClassName(): string;
  9108. }
  9109. }
  9110. declare module BABYLON {
  9111. /**
  9112. * @ignore
  9113. * This is a list of all the different input types that are available in the application.
  9114. * Fo instance: ArcRotateCameraGamepadInput...
  9115. */
  9116. export var CameraInputTypes: {};
  9117. /**
  9118. * This is the contract to implement in order to create a new input class.
  9119. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9120. */
  9121. export interface ICameraInput<TCamera extends Camera> {
  9122. /**
  9123. * Defines the camera the input is attached to.
  9124. */
  9125. camera: Nullable<TCamera>;
  9126. /**
  9127. * Gets the class name of the current intput.
  9128. * @returns the class name
  9129. */
  9130. getClassName(): string;
  9131. /**
  9132. * Get the friendly name associated with the input class.
  9133. * @returns the input friendly name
  9134. */
  9135. getSimpleName(): string;
  9136. /**
  9137. * Attach the input controls to a specific dom element to get the input from.
  9138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9139. */
  9140. attachControl(noPreventDefault?: boolean): void;
  9141. /**
  9142. * Detach the current controls from the specified dom element.
  9143. */
  9144. detachControl(): void;
  9145. /**
  9146. * Update the current camera state depending on the inputs that have been used this frame.
  9147. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9148. */
  9149. checkInputs?: () => void;
  9150. }
  9151. /**
  9152. * Represents a map of input types to input instance or input index to input instance.
  9153. */
  9154. export interface CameraInputsMap<TCamera extends Camera> {
  9155. /**
  9156. * Accessor to the input by input type.
  9157. */
  9158. [name: string]: ICameraInput<TCamera>;
  9159. /**
  9160. * Accessor to the input by input index.
  9161. */
  9162. [idx: number]: ICameraInput<TCamera>;
  9163. }
  9164. /**
  9165. * This represents the input manager used within a camera.
  9166. * It helps dealing with all the different kind of input attached to a camera.
  9167. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9168. */
  9169. export class CameraInputsManager<TCamera extends Camera> {
  9170. /**
  9171. * Defines the list of inputs attahed to the camera.
  9172. */
  9173. attached: CameraInputsMap<TCamera>;
  9174. /**
  9175. * Defines the dom element the camera is collecting inputs from.
  9176. * This is null if the controls have not been attached.
  9177. */
  9178. attachedToElement: boolean;
  9179. /**
  9180. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9181. */
  9182. noPreventDefault: boolean;
  9183. /**
  9184. * Defined the camera the input manager belongs to.
  9185. */
  9186. camera: TCamera;
  9187. /**
  9188. * Update the current camera state depending on the inputs that have been used this frame.
  9189. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9190. */
  9191. checkInputs: () => void;
  9192. /**
  9193. * Instantiate a new Camera Input Manager.
  9194. * @param camera Defines the camera the input manager blongs to
  9195. */
  9196. constructor(camera: TCamera);
  9197. /**
  9198. * Add an input method to a camera
  9199. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9200. * @param input camera input method
  9201. */
  9202. add(input: ICameraInput<TCamera>): void;
  9203. /**
  9204. * Remove a specific input method from a camera
  9205. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9206. * @param inputToRemove camera input method
  9207. */
  9208. remove(inputToRemove: ICameraInput<TCamera>): void;
  9209. /**
  9210. * Remove a specific input type from a camera
  9211. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9212. * @param inputType the type of the input to remove
  9213. */
  9214. removeByType(inputType: string): void;
  9215. private _addCheckInputs;
  9216. /**
  9217. * Attach the input controls to the currently attached dom element to listen the events from.
  9218. * @param input Defines the input to attach
  9219. */
  9220. attachInput(input: ICameraInput<TCamera>): void;
  9221. /**
  9222. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9223. * @param element Defines the dom element to collect the events from
  9224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9225. */
  9226. attachElement(noPreventDefault?: boolean): void;
  9227. /**
  9228. * Detach the current manager inputs controls from a specific dom element.
  9229. * @param element Defines the dom element to collect the events from
  9230. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9231. */
  9232. detachElement(disconnect?: boolean): void;
  9233. /**
  9234. * Rebuild the dynamic inputCheck function from the current list of
  9235. * defined inputs in the manager.
  9236. */
  9237. rebuildInputCheck(): void;
  9238. /**
  9239. * Remove all attached input methods from a camera
  9240. */
  9241. clear(): void;
  9242. /**
  9243. * Serialize the current input manager attached to a camera.
  9244. * This ensures than once parsed,
  9245. * the input associated to the camera will be identical to the current ones
  9246. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9247. */
  9248. serialize(serializedCamera: any): void;
  9249. /**
  9250. * Parses an input manager serialized JSON to restore the previous list of inputs
  9251. * and states associated to a camera.
  9252. * @param parsedCamera Defines the JSON to parse
  9253. */
  9254. parse(parsedCamera: any): void;
  9255. }
  9256. }
  9257. declare module BABYLON {
  9258. /**
  9259. * Gather the list of keyboard event types as constants.
  9260. */
  9261. export class KeyboardEventTypes {
  9262. /**
  9263. * The keydown event is fired when a key becomes active (pressed).
  9264. */
  9265. static readonly KEYDOWN: number;
  9266. /**
  9267. * The keyup event is fired when a key has been released.
  9268. */
  9269. static readonly KEYUP: number;
  9270. }
  9271. /**
  9272. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9273. */
  9274. export class KeyboardInfo {
  9275. /**
  9276. * Defines the type of event (KeyboardEventTypes)
  9277. */
  9278. type: number;
  9279. /**
  9280. * Defines the related dom event
  9281. */
  9282. event: KeyboardEvent;
  9283. /**
  9284. * Instantiates a new keyboard info.
  9285. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9286. * @param type Defines the type of event (KeyboardEventTypes)
  9287. * @param event Defines the related dom event
  9288. */
  9289. constructor(
  9290. /**
  9291. * Defines the type of event (KeyboardEventTypes)
  9292. */
  9293. type: number,
  9294. /**
  9295. * Defines the related dom event
  9296. */
  9297. event: KeyboardEvent);
  9298. }
  9299. /**
  9300. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9301. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9302. */
  9303. export class KeyboardInfoPre extends KeyboardInfo {
  9304. /**
  9305. * Defines the type of event (KeyboardEventTypes)
  9306. */
  9307. type: number;
  9308. /**
  9309. * Defines the related dom event
  9310. */
  9311. event: KeyboardEvent;
  9312. /**
  9313. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9314. */
  9315. skipOnPointerObservable: boolean;
  9316. /**
  9317. * Instantiates a new keyboard pre info.
  9318. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9319. * @param type Defines the type of event (KeyboardEventTypes)
  9320. * @param event Defines the related dom event
  9321. */
  9322. constructor(
  9323. /**
  9324. * Defines the type of event (KeyboardEventTypes)
  9325. */
  9326. type: number,
  9327. /**
  9328. * Defines the related dom event
  9329. */
  9330. event: KeyboardEvent);
  9331. }
  9332. }
  9333. declare module BABYLON {
  9334. /**
  9335. * Manage the keyboard inputs to control the movement of a free camera.
  9336. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9337. */
  9338. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9339. /**
  9340. * Defines the camera the input is attached to.
  9341. */
  9342. camera: FreeCamera;
  9343. /**
  9344. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9345. */
  9346. keysUp: number[];
  9347. /**
  9348. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9349. */
  9350. keysUpward: number[];
  9351. /**
  9352. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9353. */
  9354. keysDown: number[];
  9355. /**
  9356. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9357. */
  9358. keysDownward: number[];
  9359. /**
  9360. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9361. */
  9362. keysLeft: number[];
  9363. /**
  9364. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9365. */
  9366. keysRight: number[];
  9367. private _keys;
  9368. private _onCanvasBlurObserver;
  9369. private _onKeyboardObserver;
  9370. private _engine;
  9371. private _scene;
  9372. /**
  9373. * Attach the input controls to a specific dom element to get the input from.
  9374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9375. */
  9376. attachControl(noPreventDefault?: boolean): void;
  9377. /**
  9378. * Detach the current controls from the specified dom element.
  9379. */
  9380. detachControl(): void;
  9381. /**
  9382. * Update the current camera state depending on the inputs that have been used this frame.
  9383. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9384. */
  9385. checkInputs(): void;
  9386. /**
  9387. * Gets the class name of the current intput.
  9388. * @returns the class name
  9389. */
  9390. getClassName(): string;
  9391. /** @hidden */
  9392. _onLostFocus(): void;
  9393. /**
  9394. * Get the friendly name associated with the input class.
  9395. * @returns the input friendly name
  9396. */
  9397. getSimpleName(): string;
  9398. }
  9399. }
  9400. declare module BABYLON {
  9401. /**
  9402. * Interface used to define Action
  9403. */
  9404. export interface IAction {
  9405. /**
  9406. * Trigger for the action
  9407. */
  9408. trigger: number;
  9409. /** Options of the trigger */
  9410. triggerOptions: any;
  9411. /**
  9412. * Gets the trigger parameters
  9413. * @returns the trigger parameters
  9414. */
  9415. getTriggerParameter(): any;
  9416. /**
  9417. * Internal only - executes current action event
  9418. * @hidden
  9419. */
  9420. _executeCurrent(evt?: ActionEvent): void;
  9421. /**
  9422. * Serialize placeholder for child classes
  9423. * @param parent of child
  9424. * @returns the serialized object
  9425. */
  9426. serialize(parent: any): any;
  9427. /**
  9428. * Internal only
  9429. * @hidden
  9430. */
  9431. _prepare(): void;
  9432. /**
  9433. * Internal only - manager for action
  9434. * @hidden
  9435. */
  9436. _actionManager: Nullable<AbstractActionManager>;
  9437. /**
  9438. * Adds action to chain of actions, may be a DoNothingAction
  9439. * @param action defines the next action to execute
  9440. * @returns The action passed in
  9441. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9442. */
  9443. then(action: IAction): IAction;
  9444. }
  9445. /**
  9446. * The action to be carried out following a trigger
  9447. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9448. */
  9449. export class Action implements IAction {
  9450. /** the trigger, with or without parameters, for the action */
  9451. triggerOptions: any;
  9452. /**
  9453. * Trigger for the action
  9454. */
  9455. trigger: number;
  9456. /**
  9457. * Internal only - manager for action
  9458. * @hidden
  9459. */
  9460. _actionManager: ActionManager;
  9461. private _nextActiveAction;
  9462. private _child;
  9463. private _condition?;
  9464. private _triggerParameter;
  9465. /**
  9466. * An event triggered prior to action being executed.
  9467. */
  9468. onBeforeExecuteObservable: Observable<Action>;
  9469. /**
  9470. * Creates a new Action
  9471. * @param triggerOptions the trigger, with or without parameters, for the action
  9472. * @param condition an optional determinant of action
  9473. */
  9474. constructor(
  9475. /** the trigger, with or without parameters, for the action */
  9476. triggerOptions: any, condition?: Condition);
  9477. /**
  9478. * Internal only
  9479. * @hidden
  9480. */
  9481. _prepare(): void;
  9482. /**
  9483. * Gets the trigger parameters
  9484. * @returns the trigger parameters
  9485. */
  9486. getTriggerParameter(): any;
  9487. /**
  9488. * Internal only - executes current action event
  9489. * @hidden
  9490. */
  9491. _executeCurrent(evt?: ActionEvent): void;
  9492. /**
  9493. * Execute placeholder for child classes
  9494. * @param evt optional action event
  9495. */
  9496. execute(evt?: ActionEvent): void;
  9497. /**
  9498. * Skips to next active action
  9499. */
  9500. skipToNextActiveAction(): void;
  9501. /**
  9502. * Adds action to chain of actions, may be a DoNothingAction
  9503. * @param action defines the next action to execute
  9504. * @returns The action passed in
  9505. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9506. */
  9507. then(action: Action): Action;
  9508. /**
  9509. * Internal only
  9510. * @hidden
  9511. */
  9512. _getProperty(propertyPath: string): string;
  9513. /**
  9514. * Internal only
  9515. * @hidden
  9516. */
  9517. _getEffectiveTarget(target: any, propertyPath: string): any;
  9518. /**
  9519. * Serialize placeholder for child classes
  9520. * @param parent of child
  9521. * @returns the serialized object
  9522. */
  9523. serialize(parent: any): any;
  9524. /**
  9525. * Internal only called by serialize
  9526. * @hidden
  9527. */
  9528. protected _serialize(serializedAction: any, parent?: any): any;
  9529. /**
  9530. * Internal only
  9531. * @hidden
  9532. */
  9533. static _SerializeValueAsString: (value: any) => string;
  9534. /**
  9535. * Internal only
  9536. * @hidden
  9537. */
  9538. static _GetTargetProperty: (target: Scene | Node) => {
  9539. name: string;
  9540. targetType: string;
  9541. value: string;
  9542. };
  9543. }
  9544. }
  9545. declare module BABYLON {
  9546. /**
  9547. * A Condition applied to an Action
  9548. */
  9549. export class Condition {
  9550. /**
  9551. * Internal only - manager for action
  9552. * @hidden
  9553. */
  9554. _actionManager: ActionManager;
  9555. /**
  9556. * Internal only
  9557. * @hidden
  9558. */
  9559. _evaluationId: number;
  9560. /**
  9561. * Internal only
  9562. * @hidden
  9563. */
  9564. _currentResult: boolean;
  9565. /**
  9566. * Creates a new Condition
  9567. * @param actionManager the manager of the action the condition is applied to
  9568. */
  9569. constructor(actionManager: ActionManager);
  9570. /**
  9571. * Check if the current condition is valid
  9572. * @returns a boolean
  9573. */
  9574. isValid(): boolean;
  9575. /**
  9576. * Internal only
  9577. * @hidden
  9578. */
  9579. _getProperty(propertyPath: string): string;
  9580. /**
  9581. * Internal only
  9582. * @hidden
  9583. */
  9584. _getEffectiveTarget(target: any, propertyPath: string): any;
  9585. /**
  9586. * Serialize placeholder for child classes
  9587. * @returns the serialized object
  9588. */
  9589. serialize(): any;
  9590. /**
  9591. * Internal only
  9592. * @hidden
  9593. */
  9594. protected _serialize(serializedCondition: any): any;
  9595. }
  9596. /**
  9597. * Defines specific conditional operators as extensions of Condition
  9598. */
  9599. export class ValueCondition extends Condition {
  9600. /** path to specify the property of the target the conditional operator uses */
  9601. propertyPath: string;
  9602. /** the value compared by the conditional operator against the current value of the property */
  9603. value: any;
  9604. /** the conditional operator, default ValueCondition.IsEqual */
  9605. operator: number;
  9606. /**
  9607. * Internal only
  9608. * @hidden
  9609. */
  9610. private static _IsEqual;
  9611. /**
  9612. * Internal only
  9613. * @hidden
  9614. */
  9615. private static _IsDifferent;
  9616. /**
  9617. * Internal only
  9618. * @hidden
  9619. */
  9620. private static _IsGreater;
  9621. /**
  9622. * Internal only
  9623. * @hidden
  9624. */
  9625. private static _IsLesser;
  9626. /**
  9627. * returns the number for IsEqual
  9628. */
  9629. static get IsEqual(): number;
  9630. /**
  9631. * Returns the number for IsDifferent
  9632. */
  9633. static get IsDifferent(): number;
  9634. /**
  9635. * Returns the number for IsGreater
  9636. */
  9637. static get IsGreater(): number;
  9638. /**
  9639. * Returns the number for IsLesser
  9640. */
  9641. static get IsLesser(): number;
  9642. /**
  9643. * Internal only The action manager for the condition
  9644. * @hidden
  9645. */
  9646. _actionManager: ActionManager;
  9647. /**
  9648. * Internal only
  9649. * @hidden
  9650. */
  9651. private _target;
  9652. /**
  9653. * Internal only
  9654. * @hidden
  9655. */
  9656. private _effectiveTarget;
  9657. /**
  9658. * Internal only
  9659. * @hidden
  9660. */
  9661. private _property;
  9662. /**
  9663. * Creates a new ValueCondition
  9664. * @param actionManager manager for the action the condition applies to
  9665. * @param target for the action
  9666. * @param propertyPath path to specify the property of the target the conditional operator uses
  9667. * @param value the value compared by the conditional operator against the current value of the property
  9668. * @param operator the conditional operator, default ValueCondition.IsEqual
  9669. */
  9670. constructor(actionManager: ActionManager, target: any,
  9671. /** path to specify the property of the target the conditional operator uses */
  9672. propertyPath: string,
  9673. /** the value compared by the conditional operator against the current value of the property */
  9674. value: any,
  9675. /** the conditional operator, default ValueCondition.IsEqual */
  9676. operator?: number);
  9677. /**
  9678. * Compares the given value with the property value for the specified conditional operator
  9679. * @returns the result of the comparison
  9680. */
  9681. isValid(): boolean;
  9682. /**
  9683. * Serialize the ValueCondition into a JSON compatible object
  9684. * @returns serialization object
  9685. */
  9686. serialize(): any;
  9687. /**
  9688. * Gets the name of the conditional operator for the ValueCondition
  9689. * @param operator the conditional operator
  9690. * @returns the name
  9691. */
  9692. static GetOperatorName(operator: number): string;
  9693. }
  9694. /**
  9695. * Defines a predicate condition as an extension of Condition
  9696. */
  9697. export class PredicateCondition extends Condition {
  9698. /** defines the predicate function used to validate the condition */
  9699. predicate: () => boolean;
  9700. /**
  9701. * Internal only - manager for action
  9702. * @hidden
  9703. */
  9704. _actionManager: ActionManager;
  9705. /**
  9706. * Creates a new PredicateCondition
  9707. * @param actionManager manager for the action the condition applies to
  9708. * @param predicate defines the predicate function used to validate the condition
  9709. */
  9710. constructor(actionManager: ActionManager,
  9711. /** defines the predicate function used to validate the condition */
  9712. predicate: () => boolean);
  9713. /**
  9714. * @returns the validity of the predicate condition
  9715. */
  9716. isValid(): boolean;
  9717. }
  9718. /**
  9719. * Defines a state condition as an extension of Condition
  9720. */
  9721. export class StateCondition extends Condition {
  9722. /** Value to compare with target state */
  9723. value: string;
  9724. /**
  9725. * Internal only - manager for action
  9726. * @hidden
  9727. */
  9728. _actionManager: ActionManager;
  9729. /**
  9730. * Internal only
  9731. * @hidden
  9732. */
  9733. private _target;
  9734. /**
  9735. * Creates a new StateCondition
  9736. * @param actionManager manager for the action the condition applies to
  9737. * @param target of the condition
  9738. * @param value to compare with target state
  9739. */
  9740. constructor(actionManager: ActionManager, target: any,
  9741. /** Value to compare with target state */
  9742. value: string);
  9743. /**
  9744. * Gets a boolean indicating if the current condition is met
  9745. * @returns the validity of the state
  9746. */
  9747. isValid(): boolean;
  9748. /**
  9749. * Serialize the StateCondition into a JSON compatible object
  9750. * @returns serialization object
  9751. */
  9752. serialize(): any;
  9753. }
  9754. }
  9755. declare module BABYLON {
  9756. /**
  9757. * This defines an action responsible to toggle a boolean once triggered.
  9758. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9759. */
  9760. export class SwitchBooleanAction extends Action {
  9761. /**
  9762. * The path to the boolean property in the target object
  9763. */
  9764. propertyPath: string;
  9765. private _target;
  9766. private _effectiveTarget;
  9767. private _property;
  9768. /**
  9769. * Instantiate the action
  9770. * @param triggerOptions defines the trigger options
  9771. * @param target defines the object containing the boolean
  9772. * @param propertyPath defines the path to the boolean property in the target object
  9773. * @param condition defines the trigger related conditions
  9774. */
  9775. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9776. /** @hidden */
  9777. _prepare(): void;
  9778. /**
  9779. * Execute the action toggle the boolean value.
  9780. */
  9781. execute(): void;
  9782. /**
  9783. * Serializes the actions and its related information.
  9784. * @param parent defines the object to serialize in
  9785. * @returns the serialized object
  9786. */
  9787. serialize(parent: any): any;
  9788. }
  9789. /**
  9790. * This defines an action responsible to set a the state field of the target
  9791. * to a desired value once triggered.
  9792. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9793. */
  9794. export class SetStateAction extends Action {
  9795. /**
  9796. * The value to store in the state field.
  9797. */
  9798. value: string;
  9799. private _target;
  9800. /**
  9801. * Instantiate the action
  9802. * @param triggerOptions defines the trigger options
  9803. * @param target defines the object containing the state property
  9804. * @param value defines the value to store in the state field
  9805. * @param condition defines the trigger related conditions
  9806. */
  9807. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9808. /**
  9809. * Execute the action and store the value on the target state property.
  9810. */
  9811. execute(): void;
  9812. /**
  9813. * Serializes the actions and its related information.
  9814. * @param parent defines the object to serialize in
  9815. * @returns the serialized object
  9816. */
  9817. serialize(parent: any): any;
  9818. }
  9819. /**
  9820. * This defines an action responsible to set a property of the target
  9821. * to a desired value once triggered.
  9822. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9823. */
  9824. export class SetValueAction extends Action {
  9825. /**
  9826. * The path of the property to set in the target.
  9827. */
  9828. propertyPath: string;
  9829. /**
  9830. * The value to set in the property
  9831. */
  9832. value: any;
  9833. private _target;
  9834. private _effectiveTarget;
  9835. private _property;
  9836. /**
  9837. * Instantiate the action
  9838. * @param triggerOptions defines the trigger options
  9839. * @param target defines the object containing the property
  9840. * @param propertyPath defines the path of the property to set in the target
  9841. * @param value defines the value to set in the property
  9842. * @param condition defines the trigger related conditions
  9843. */
  9844. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9845. /** @hidden */
  9846. _prepare(): void;
  9847. /**
  9848. * Execute the action and set the targetted property to the desired value.
  9849. */
  9850. execute(): void;
  9851. /**
  9852. * Serializes the actions and its related information.
  9853. * @param parent defines the object to serialize in
  9854. * @returns the serialized object
  9855. */
  9856. serialize(parent: any): any;
  9857. }
  9858. /**
  9859. * This defines an action responsible to increment the target value
  9860. * to a desired value once triggered.
  9861. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9862. */
  9863. export class IncrementValueAction extends Action {
  9864. /**
  9865. * The path of the property to increment in the target.
  9866. */
  9867. propertyPath: string;
  9868. /**
  9869. * The value we should increment the property by.
  9870. */
  9871. value: any;
  9872. private _target;
  9873. private _effectiveTarget;
  9874. private _property;
  9875. /**
  9876. * Instantiate the action
  9877. * @param triggerOptions defines the trigger options
  9878. * @param target defines the object containing the property
  9879. * @param propertyPath defines the path of the property to increment in the target
  9880. * @param value defines the value value we should increment the property by
  9881. * @param condition defines the trigger related conditions
  9882. */
  9883. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9884. /** @hidden */
  9885. _prepare(): void;
  9886. /**
  9887. * Execute the action and increment the target of the value amount.
  9888. */
  9889. execute(): void;
  9890. /**
  9891. * Serializes the actions and its related information.
  9892. * @param parent defines the object to serialize in
  9893. * @returns the serialized object
  9894. */
  9895. serialize(parent: any): any;
  9896. }
  9897. /**
  9898. * This defines an action responsible to start an animation once triggered.
  9899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9900. */
  9901. export class PlayAnimationAction extends Action {
  9902. /**
  9903. * Where the animation should start (animation frame)
  9904. */
  9905. from: number;
  9906. /**
  9907. * Where the animation should stop (animation frame)
  9908. */
  9909. to: number;
  9910. /**
  9911. * Define if the animation should loop or stop after the first play.
  9912. */
  9913. loop?: boolean;
  9914. private _target;
  9915. /**
  9916. * Instantiate the action
  9917. * @param triggerOptions defines the trigger options
  9918. * @param target defines the target animation or animation name
  9919. * @param from defines from where the animation should start (animation frame)
  9920. * @param end defines where the animation should stop (animation frame)
  9921. * @param loop defines if the animation should loop or stop after the first play
  9922. * @param condition defines the trigger related conditions
  9923. */
  9924. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9925. /** @hidden */
  9926. _prepare(): void;
  9927. /**
  9928. * Execute the action and play the animation.
  9929. */
  9930. execute(): void;
  9931. /**
  9932. * Serializes the actions and its related information.
  9933. * @param parent defines the object to serialize in
  9934. * @returns the serialized object
  9935. */
  9936. serialize(parent: any): any;
  9937. }
  9938. /**
  9939. * This defines an action responsible to stop an animation once triggered.
  9940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9941. */
  9942. export class StopAnimationAction extends Action {
  9943. private _target;
  9944. /**
  9945. * Instantiate the action
  9946. * @param triggerOptions defines the trigger options
  9947. * @param target defines the target animation or animation name
  9948. * @param condition defines the trigger related conditions
  9949. */
  9950. constructor(triggerOptions: any, target: any, condition?: Condition);
  9951. /** @hidden */
  9952. _prepare(): void;
  9953. /**
  9954. * Execute the action and stop the animation.
  9955. */
  9956. execute(): void;
  9957. /**
  9958. * Serializes the actions and its related information.
  9959. * @param parent defines the object to serialize in
  9960. * @returns the serialized object
  9961. */
  9962. serialize(parent: any): any;
  9963. }
  9964. /**
  9965. * This defines an action responsible that does nothing once triggered.
  9966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class DoNothingAction extends Action {
  9969. /**
  9970. * Instantiate the action
  9971. * @param triggerOptions defines the trigger options
  9972. * @param condition defines the trigger related conditions
  9973. */
  9974. constructor(triggerOptions?: any, condition?: Condition);
  9975. /**
  9976. * Execute the action and do nothing.
  9977. */
  9978. execute(): void;
  9979. /**
  9980. * Serializes the actions and its related information.
  9981. * @param parent defines the object to serialize in
  9982. * @returns the serialized object
  9983. */
  9984. serialize(parent: any): any;
  9985. }
  9986. /**
  9987. * This defines an action responsible to trigger several actions once triggered.
  9988. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9989. */
  9990. export class CombineAction extends Action {
  9991. /**
  9992. * The list of aggregated animations to run.
  9993. */
  9994. children: Action[];
  9995. /**
  9996. * Instantiate the action
  9997. * @param triggerOptions defines the trigger options
  9998. * @param children defines the list of aggregated animations to run
  9999. * @param condition defines the trigger related conditions
  10000. */
  10001. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10002. /** @hidden */
  10003. _prepare(): void;
  10004. /**
  10005. * Execute the action and executes all the aggregated actions.
  10006. */
  10007. execute(evt: ActionEvent): void;
  10008. /**
  10009. * Serializes the actions and its related information.
  10010. * @param parent defines the object to serialize in
  10011. * @returns the serialized object
  10012. */
  10013. serialize(parent: any): any;
  10014. }
  10015. /**
  10016. * This defines an action responsible to run code (external event) once triggered.
  10017. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10018. */
  10019. export class ExecuteCodeAction extends Action {
  10020. /**
  10021. * The callback function to run.
  10022. */
  10023. func: (evt: ActionEvent) => void;
  10024. /**
  10025. * Instantiate the action
  10026. * @param triggerOptions defines the trigger options
  10027. * @param func defines the callback function to run
  10028. * @param condition defines the trigger related conditions
  10029. */
  10030. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10031. /**
  10032. * Execute the action and run the attached code.
  10033. */
  10034. execute(evt: ActionEvent): void;
  10035. }
  10036. /**
  10037. * This defines an action responsible to set the parent property of the target once triggered.
  10038. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10039. */
  10040. export class SetParentAction extends Action {
  10041. private _parent;
  10042. private _target;
  10043. /**
  10044. * Instantiate the action
  10045. * @param triggerOptions defines the trigger options
  10046. * @param target defines the target containing the parent property
  10047. * @param parent defines from where the animation should start (animation frame)
  10048. * @param condition defines the trigger related conditions
  10049. */
  10050. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10051. /** @hidden */
  10052. _prepare(): void;
  10053. /**
  10054. * Execute the action and set the parent property.
  10055. */
  10056. execute(): void;
  10057. /**
  10058. * Serializes the actions and its related information.
  10059. * @param parent defines the object to serialize in
  10060. * @returns the serialized object
  10061. */
  10062. serialize(parent: any): any;
  10063. }
  10064. }
  10065. declare module BABYLON {
  10066. /**
  10067. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10068. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10069. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10070. */
  10071. export class ActionManager extends AbstractActionManager {
  10072. /**
  10073. * Nothing
  10074. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10075. */
  10076. static readonly NothingTrigger: number;
  10077. /**
  10078. * On pick
  10079. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10080. */
  10081. static readonly OnPickTrigger: number;
  10082. /**
  10083. * On left pick
  10084. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10085. */
  10086. static readonly OnLeftPickTrigger: number;
  10087. /**
  10088. * On right pick
  10089. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10090. */
  10091. static readonly OnRightPickTrigger: number;
  10092. /**
  10093. * On center pick
  10094. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10095. */
  10096. static readonly OnCenterPickTrigger: number;
  10097. /**
  10098. * On pick down
  10099. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10100. */
  10101. static readonly OnPickDownTrigger: number;
  10102. /**
  10103. * On double pick
  10104. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10105. */
  10106. static readonly OnDoublePickTrigger: number;
  10107. /**
  10108. * On pick up
  10109. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10110. */
  10111. static readonly OnPickUpTrigger: number;
  10112. /**
  10113. * On pick out.
  10114. * This trigger will only be raised if you also declared a OnPickDown
  10115. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10116. */
  10117. static readonly OnPickOutTrigger: number;
  10118. /**
  10119. * On long press
  10120. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10121. */
  10122. static readonly OnLongPressTrigger: number;
  10123. /**
  10124. * On pointer over
  10125. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10126. */
  10127. static readonly OnPointerOverTrigger: number;
  10128. /**
  10129. * On pointer out
  10130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10131. */
  10132. static readonly OnPointerOutTrigger: number;
  10133. /**
  10134. * On every frame
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10136. */
  10137. static readonly OnEveryFrameTrigger: number;
  10138. /**
  10139. * On intersection enter
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly OnIntersectionEnterTrigger: number;
  10143. /**
  10144. * On intersection exit
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnIntersectionExitTrigger: number;
  10148. /**
  10149. * On key down
  10150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10151. */
  10152. static readonly OnKeyDownTrigger: number;
  10153. /**
  10154. * On key up
  10155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10156. */
  10157. static readonly OnKeyUpTrigger: number;
  10158. private _scene;
  10159. /**
  10160. * Creates a new action manager
  10161. * @param scene defines the hosting scene
  10162. */
  10163. constructor(scene: Scene);
  10164. /**
  10165. * Releases all associated resources
  10166. */
  10167. dispose(): void;
  10168. /**
  10169. * Gets hosting scene
  10170. * @returns the hosting scene
  10171. */
  10172. getScene(): Scene;
  10173. /**
  10174. * Does this action manager handles actions of any of the given triggers
  10175. * @param triggers defines the triggers to be tested
  10176. * @return a boolean indicating whether one (or more) of the triggers is handled
  10177. */
  10178. hasSpecificTriggers(triggers: number[]): boolean;
  10179. /**
  10180. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10181. * speed.
  10182. * @param triggerA defines the trigger to be tested
  10183. * @param triggerB defines the trigger to be tested
  10184. * @return a boolean indicating whether one (or more) of the triggers is handled
  10185. */
  10186. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10187. /**
  10188. * Does this action manager handles actions of a given trigger
  10189. * @param trigger defines the trigger to be tested
  10190. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10191. * @return whether the trigger is handled
  10192. */
  10193. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10194. /**
  10195. * Does this action manager has pointer triggers
  10196. */
  10197. get hasPointerTriggers(): boolean;
  10198. /**
  10199. * Does this action manager has pick triggers
  10200. */
  10201. get hasPickTriggers(): boolean;
  10202. /**
  10203. * Registers an action to this action manager
  10204. * @param action defines the action to be registered
  10205. * @return the action amended (prepared) after registration
  10206. */
  10207. registerAction(action: IAction): Nullable<IAction>;
  10208. /**
  10209. * Unregisters an action to this action manager
  10210. * @param action defines the action to be unregistered
  10211. * @return a boolean indicating whether the action has been unregistered
  10212. */
  10213. unregisterAction(action: IAction): Boolean;
  10214. /**
  10215. * Process a specific trigger
  10216. * @param trigger defines the trigger to process
  10217. * @param evt defines the event details to be processed
  10218. */
  10219. processTrigger(trigger: number, evt?: IActionEvent): void;
  10220. /** @hidden */
  10221. _getEffectiveTarget(target: any, propertyPath: string): any;
  10222. /** @hidden */
  10223. _getProperty(propertyPath: string): string;
  10224. /**
  10225. * Serialize this manager to a JSON object
  10226. * @param name defines the property name to store this manager
  10227. * @returns a JSON representation of this manager
  10228. */
  10229. serialize(name: string): any;
  10230. /**
  10231. * Creates a new ActionManager from a JSON data
  10232. * @param parsedActions defines the JSON data to read from
  10233. * @param object defines the hosting mesh
  10234. * @param scene defines the hosting scene
  10235. */
  10236. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10237. /**
  10238. * Get a trigger name by index
  10239. * @param trigger defines the trigger index
  10240. * @returns a trigger name
  10241. */
  10242. static GetTriggerName(trigger: number): string;
  10243. }
  10244. }
  10245. declare module BABYLON {
  10246. /**
  10247. * Class representing a ray with position and direction
  10248. */
  10249. export class Ray {
  10250. /** origin point */
  10251. origin: Vector3;
  10252. /** direction */
  10253. direction: Vector3;
  10254. /** length of the ray */
  10255. length: number;
  10256. private static readonly _TmpVector3;
  10257. private _tmpRay;
  10258. /**
  10259. * Creates a new ray
  10260. * @param origin origin point
  10261. * @param direction direction
  10262. * @param length length of the ray
  10263. */
  10264. constructor(
  10265. /** origin point */
  10266. origin: Vector3,
  10267. /** direction */
  10268. direction: Vector3,
  10269. /** length of the ray */
  10270. length?: number);
  10271. /**
  10272. * Checks if the ray intersects a box
  10273. * This does not account for the ray lenght by design to improve perfs.
  10274. * @param minimum bound of the box
  10275. * @param maximum bound of the box
  10276. * @param intersectionTreshold extra extend to be added to the box in all direction
  10277. * @returns if the box was hit
  10278. */
  10279. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10280. /**
  10281. * Checks if the ray intersects a box
  10282. * This does not account for the ray lenght by design to improve perfs.
  10283. * @param box the bounding box to check
  10284. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10285. * @returns if the box was hit
  10286. */
  10287. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10288. /**
  10289. * If the ray hits a sphere
  10290. * @param sphere the bounding sphere to check
  10291. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10292. * @returns true if it hits the sphere
  10293. */
  10294. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10295. /**
  10296. * If the ray hits a triange
  10297. * @param vertex0 triangle vertex
  10298. * @param vertex1 triangle vertex
  10299. * @param vertex2 triangle vertex
  10300. * @returns intersection information if hit
  10301. */
  10302. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10303. /**
  10304. * Checks if ray intersects a plane
  10305. * @param plane the plane to check
  10306. * @returns the distance away it was hit
  10307. */
  10308. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10309. /**
  10310. * Calculate the intercept of a ray on a given axis
  10311. * @param axis to check 'x' | 'y' | 'z'
  10312. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10313. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10314. */
  10315. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10316. /**
  10317. * Checks if ray intersects a mesh
  10318. * @param mesh the mesh to check
  10319. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10320. * @returns picking info of the intersecton
  10321. */
  10322. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10323. /**
  10324. * Checks if ray intersects a mesh
  10325. * @param meshes the meshes to check
  10326. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10327. * @param results array to store result in
  10328. * @returns Array of picking infos
  10329. */
  10330. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10331. private _comparePickingInfo;
  10332. private static smallnum;
  10333. private static rayl;
  10334. /**
  10335. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10336. * @param sega the first point of the segment to test the intersection against
  10337. * @param segb the second point of the segment to test the intersection against
  10338. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10339. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10340. */
  10341. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10342. /**
  10343. * Update the ray from viewport position
  10344. * @param x position
  10345. * @param y y position
  10346. * @param viewportWidth viewport width
  10347. * @param viewportHeight viewport height
  10348. * @param world world matrix
  10349. * @param view view matrix
  10350. * @param projection projection matrix
  10351. * @returns this ray updated
  10352. */
  10353. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10354. /**
  10355. * Creates a ray with origin and direction of 0,0,0
  10356. * @returns the new ray
  10357. */
  10358. static Zero(): Ray;
  10359. /**
  10360. * Creates a new ray from screen space and viewport
  10361. * @param x position
  10362. * @param y y position
  10363. * @param viewportWidth viewport width
  10364. * @param viewportHeight viewport height
  10365. * @param world world matrix
  10366. * @param view view matrix
  10367. * @param projection projection matrix
  10368. * @returns new ray
  10369. */
  10370. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10371. /**
  10372. * 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
  10373. * transformed to the given world matrix.
  10374. * @param origin The origin point
  10375. * @param end The end point
  10376. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10377. * @returns the new ray
  10378. */
  10379. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10380. /**
  10381. * Transforms a ray by a matrix
  10382. * @param ray ray to transform
  10383. * @param matrix matrix to apply
  10384. * @returns the resulting new ray
  10385. */
  10386. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10387. /**
  10388. * Transforms a ray by a matrix
  10389. * @param ray ray to transform
  10390. * @param matrix matrix to apply
  10391. * @param result ray to store result in
  10392. */
  10393. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10394. /**
  10395. * Unproject a ray from screen space to object space
  10396. * @param sourceX defines the screen space x coordinate to use
  10397. * @param sourceY defines the screen space y coordinate to use
  10398. * @param viewportWidth defines the current width of the viewport
  10399. * @param viewportHeight defines the current height of the viewport
  10400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10401. * @param view defines the view matrix to use
  10402. * @param projection defines the projection matrix to use
  10403. */
  10404. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10405. }
  10406. /**
  10407. * Type used to define predicate used to select faces when a mesh intersection is detected
  10408. */
  10409. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10410. interface Scene {
  10411. /** @hidden */
  10412. _tempPickingRay: Nullable<Ray>;
  10413. /** @hidden */
  10414. _cachedRayForTransform: Ray;
  10415. /** @hidden */
  10416. _pickWithRayInverseMatrix: Matrix;
  10417. /** @hidden */
  10418. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10419. /** @hidden */
  10420. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10421. /** @hidden */
  10422. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10423. }
  10424. }
  10425. declare module BABYLON {
  10426. /**
  10427. * Groups all the scene component constants in one place to ease maintenance.
  10428. * @hidden
  10429. */
  10430. export class SceneComponentConstants {
  10431. static readonly NAME_EFFECTLAYER: string;
  10432. static readonly NAME_LAYER: string;
  10433. static readonly NAME_LENSFLARESYSTEM: string;
  10434. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10435. static readonly NAME_PARTICLESYSTEM: string;
  10436. static readonly NAME_GAMEPAD: string;
  10437. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10438. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10439. static readonly NAME_PREPASSRENDERER: string;
  10440. static readonly NAME_DEPTHRENDERER: string;
  10441. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10442. static readonly NAME_SPRITE: string;
  10443. static readonly NAME_SUBSURFACE: string;
  10444. static readonly NAME_OUTLINERENDERER: string;
  10445. static readonly NAME_PROCEDURALTEXTURE: string;
  10446. static readonly NAME_SHADOWGENERATOR: string;
  10447. static readonly NAME_OCTREE: string;
  10448. static readonly NAME_PHYSICSENGINE: string;
  10449. static readonly NAME_AUDIO: string;
  10450. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10451. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10452. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10453. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10454. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10455. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10456. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10457. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10458. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10459. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10460. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10461. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10462. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10463. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10464. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10465. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10466. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10467. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10468. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10469. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10470. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10471. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10472. static readonly STEP_AFTERRENDER_AUDIO: number;
  10473. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10474. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10475. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10476. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10477. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10478. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10479. static readonly STEP_POINTERMOVE_SPRITE: number;
  10480. static readonly STEP_POINTERDOWN_SPRITE: number;
  10481. static readonly STEP_POINTERUP_SPRITE: number;
  10482. }
  10483. /**
  10484. * This represents a scene component.
  10485. *
  10486. * This is used to decouple the dependency the scene is having on the different workloads like
  10487. * layers, post processes...
  10488. */
  10489. export interface ISceneComponent {
  10490. /**
  10491. * The name of the component. Each component must have a unique name.
  10492. */
  10493. name: string;
  10494. /**
  10495. * The scene the component belongs to.
  10496. */
  10497. scene: Scene;
  10498. /**
  10499. * Register the component to one instance of a scene.
  10500. */
  10501. register(): void;
  10502. /**
  10503. * Rebuilds the elements related to this component in case of
  10504. * context lost for instance.
  10505. */
  10506. rebuild(): void;
  10507. /**
  10508. * Disposes the component and the associated ressources.
  10509. */
  10510. dispose(): void;
  10511. }
  10512. /**
  10513. * This represents a SERIALIZABLE scene component.
  10514. *
  10515. * This extends Scene Component to add Serialization methods on top.
  10516. */
  10517. export interface ISceneSerializableComponent extends ISceneComponent {
  10518. /**
  10519. * Adds all the elements from the container to the scene
  10520. * @param container the container holding the elements
  10521. */
  10522. addFromContainer(container: AbstractScene): void;
  10523. /**
  10524. * Removes all the elements in the container from the scene
  10525. * @param container contains the elements to remove
  10526. * @param dispose if the removed element should be disposed (default: false)
  10527. */
  10528. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10529. /**
  10530. * Serializes the component data to the specified json object
  10531. * @param serializationObject The object to serialize to
  10532. */
  10533. serialize(serializationObject: any): void;
  10534. }
  10535. /**
  10536. * Strong typing of a Mesh related stage step action
  10537. */
  10538. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10539. /**
  10540. * Strong typing of a Evaluate Sub Mesh related stage step action
  10541. */
  10542. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10543. /**
  10544. * Strong typing of a pre active Mesh related stage step action
  10545. */
  10546. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10547. /**
  10548. * Strong typing of a Camera related stage step action
  10549. */
  10550. export type CameraStageAction = (camera: Camera) => void;
  10551. /**
  10552. * Strong typing of a Camera Frame buffer related stage step action
  10553. */
  10554. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10555. /**
  10556. * Strong typing of a Render Target related stage step action
  10557. */
  10558. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10559. /**
  10560. * Strong typing of a RenderingGroup related stage step action
  10561. */
  10562. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10563. /**
  10564. * Strong typing of a Mesh Render related stage step action
  10565. */
  10566. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10567. /**
  10568. * Strong typing of a simple stage step action
  10569. */
  10570. export type SimpleStageAction = () => void;
  10571. /**
  10572. * Strong typing of a render target action.
  10573. */
  10574. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10575. /**
  10576. * Strong typing of a pointer move action.
  10577. */
  10578. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10579. /**
  10580. * Strong typing of a pointer up/down action.
  10581. */
  10582. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10583. /**
  10584. * Representation of a stage in the scene (Basically a list of ordered steps)
  10585. * @hidden
  10586. */
  10587. export class Stage<T extends Function> extends Array<{
  10588. index: number;
  10589. component: ISceneComponent;
  10590. action: T;
  10591. }> {
  10592. /**
  10593. * Hide ctor from the rest of the world.
  10594. * @param items The items to add.
  10595. */
  10596. private constructor();
  10597. /**
  10598. * Creates a new Stage.
  10599. * @returns A new instance of a Stage
  10600. */
  10601. static Create<T extends Function>(): Stage<T>;
  10602. /**
  10603. * Registers a step in an ordered way in the targeted stage.
  10604. * @param index Defines the position to register the step in
  10605. * @param component Defines the component attached to the step
  10606. * @param action Defines the action to launch during the step
  10607. */
  10608. registerStep(index: number, component: ISceneComponent, action: T): void;
  10609. /**
  10610. * Clears all the steps from the stage.
  10611. */
  10612. clear(): void;
  10613. }
  10614. }
  10615. declare module BABYLON {
  10616. interface Scene {
  10617. /** @hidden */
  10618. _pointerOverSprite: Nullable<Sprite>;
  10619. /** @hidden */
  10620. _pickedDownSprite: Nullable<Sprite>;
  10621. /** @hidden */
  10622. _tempSpritePickingRay: Nullable<Ray>;
  10623. /**
  10624. * All of the sprite managers added to this scene
  10625. * @see https://doc.babylonjs.com/babylon101/sprites
  10626. */
  10627. spriteManagers: Array<ISpriteManager>;
  10628. /**
  10629. * An event triggered when sprites rendering is about to start
  10630. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10631. */
  10632. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10633. /**
  10634. * An event triggered when sprites rendering is done
  10635. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10636. */
  10637. onAfterSpritesRenderingObservable: Observable<Scene>;
  10638. /** @hidden */
  10639. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10640. /** Launch a ray to try to pick a sprite in the scene
  10641. * @param x position on screen
  10642. * @param y position on screen
  10643. * @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
  10644. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10645. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10646. * @returns a PickingInfo
  10647. */
  10648. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10649. /** Use the given ray to pick a sprite in the scene
  10650. * @param ray The ray (in world space) to use to pick meshes
  10651. * @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
  10652. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10653. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10654. * @returns a PickingInfo
  10655. */
  10656. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10657. /** @hidden */
  10658. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10659. /** Launch a ray to try to pick sprites in the scene
  10660. * @param x position on screen
  10661. * @param y position on screen
  10662. * @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
  10663. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10664. * @returns a PickingInfo array
  10665. */
  10666. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10667. /** Use the given ray to pick sprites in the scene
  10668. * @param ray The ray (in world space) to use to pick meshes
  10669. * @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
  10670. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10671. * @returns a PickingInfo array
  10672. */
  10673. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10674. /**
  10675. * Force the sprite under the pointer
  10676. * @param sprite defines the sprite to use
  10677. */
  10678. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10679. /**
  10680. * Gets the sprite under the pointer
  10681. * @returns a Sprite or null if no sprite is under the pointer
  10682. */
  10683. getPointerOverSprite(): Nullable<Sprite>;
  10684. }
  10685. /**
  10686. * Defines the sprite scene component responsible to manage sprites
  10687. * in a given scene.
  10688. */
  10689. export class SpriteSceneComponent implements ISceneComponent {
  10690. /**
  10691. * The component name helpfull to identify the component in the list of scene components.
  10692. */
  10693. readonly name: string;
  10694. /**
  10695. * The scene the component belongs to.
  10696. */
  10697. scene: Scene;
  10698. /** @hidden */
  10699. private _spritePredicate;
  10700. /**
  10701. * Creates a new instance of the component for the given scene
  10702. * @param scene Defines the scene to register the component in
  10703. */
  10704. constructor(scene: Scene);
  10705. /**
  10706. * Registers the component in a given scene
  10707. */
  10708. register(): void;
  10709. /**
  10710. * Rebuilds the elements related to this component in case of
  10711. * context lost for instance.
  10712. */
  10713. rebuild(): void;
  10714. /**
  10715. * Disposes the component and the associated ressources.
  10716. */
  10717. dispose(): void;
  10718. private _pickSpriteButKeepRay;
  10719. private _pointerMove;
  10720. private _pointerDown;
  10721. private _pointerUp;
  10722. }
  10723. }
  10724. declare module BABYLON {
  10725. /**
  10726. * Class used to provide helper for timing
  10727. */
  10728. export class TimingTools {
  10729. /**
  10730. * Polyfill for setImmediate
  10731. * @param action defines the action to execute after the current execution block
  10732. */
  10733. static SetImmediate(action: () => void): void;
  10734. }
  10735. }
  10736. declare module BABYLON {
  10737. /**
  10738. * Class used to enable instatition of objects by class name
  10739. */
  10740. export class InstantiationTools {
  10741. /**
  10742. * Use this object to register external classes like custom textures or material
  10743. * to allow the laoders to instantiate them
  10744. */
  10745. static RegisteredExternalClasses: {
  10746. [key: string]: Object;
  10747. };
  10748. /**
  10749. * Tries to instantiate a new object from a given class name
  10750. * @param className defines the class name to instantiate
  10751. * @returns the new object or null if the system was not able to do the instantiation
  10752. */
  10753. static Instantiate(className: string): any;
  10754. }
  10755. }
  10756. declare module BABYLON {
  10757. /**
  10758. * Class used to host copy specific utilities
  10759. */
  10760. export class CopyTools {
  10761. /**
  10762. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10763. * @param texture defines the texture to read pixels from
  10764. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10765. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10766. * @returns The base64 encoded string or null
  10767. */
  10768. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10769. }
  10770. }
  10771. declare module BABYLON {
  10772. /**
  10773. * Define options used to create a depth texture
  10774. */
  10775. export class DepthTextureCreationOptions {
  10776. /** Specifies whether or not a stencil should be allocated in the texture */
  10777. generateStencil?: boolean;
  10778. /** Specifies whether or not bilinear filtering is enable on the texture */
  10779. bilinearFiltering?: boolean;
  10780. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10781. comparisonFunction?: number;
  10782. /** Specifies if the created texture is a cube texture */
  10783. isCube?: boolean;
  10784. }
  10785. }
  10786. declare module BABYLON {
  10787. interface ThinEngine {
  10788. /**
  10789. * Creates a depth stencil cube texture.
  10790. * This is only available in WebGL 2.
  10791. * @param size The size of face edge in the cube texture.
  10792. * @param options The options defining the cube texture.
  10793. * @returns The cube texture
  10794. */
  10795. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  10796. /**
  10797. * Creates a cube texture
  10798. * @param rootUrl defines the url where the files to load is located
  10799. * @param scene defines the current scene
  10800. * @param files defines the list of files to load (1 per face)
  10801. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10802. * @param onLoad defines an optional callback raised when the texture is loaded
  10803. * @param onError defines an optional callback raised if there is an issue to load the texture
  10804. * @param format defines the format of the data
  10805. * @param forcedExtension defines the extension to use to pick the right loader
  10806. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10807. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10808. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10809. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10810. * @param loaderOptions options to be passed to the loader
  10811. * @returns the cube texture as an InternalTexture
  10812. */
  10813. 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;
  10814. /**
  10815. * Creates a cube texture
  10816. * @param rootUrl defines the url where the files to load is located
  10817. * @param scene defines the current scene
  10818. * @param files defines the list of files to load (1 per face)
  10819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10820. * @param onLoad defines an optional callback raised when the texture is loaded
  10821. * @param onError defines an optional callback raised if there is an issue to load the texture
  10822. * @param format defines the format of the data
  10823. * @param forcedExtension defines the extension to use to pick the right loader
  10824. * @returns the cube texture as an InternalTexture
  10825. */
  10826. 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;
  10827. /**
  10828. * Creates a cube texture
  10829. * @param rootUrl defines the url where the files to load is located
  10830. * @param scene defines the current scene
  10831. * @param files defines the list of files to load (1 per face)
  10832. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10833. * @param onLoad defines an optional callback raised when the texture is loaded
  10834. * @param onError defines an optional callback raised if there is an issue to load the texture
  10835. * @param format defines the format of the data
  10836. * @param forcedExtension defines the extension to use to pick the right loader
  10837. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10838. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10839. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10840. * @returns the cube texture as an InternalTexture
  10841. */
  10842. 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;
  10843. /** @hidden */
  10844. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  10845. /** @hidden */
  10846. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  10847. /** @hidden */
  10848. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10849. /** @hidden */
  10850. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10851. /**
  10852. * @hidden
  10853. */
  10854. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  10855. }
  10856. }
  10857. declare module BABYLON {
  10858. /**
  10859. * Class for creating a cube texture
  10860. */
  10861. export class CubeTexture extends BaseTexture {
  10862. private _delayedOnLoad;
  10863. /**
  10864. * Observable triggered once the texture has been loaded.
  10865. */
  10866. onLoadObservable: Observable<CubeTexture>;
  10867. /**
  10868. * The url of the texture
  10869. */
  10870. url: string;
  10871. /**
  10872. * Gets or sets the center of the bounding box associated with the cube texture.
  10873. * It must define where the camera used to render the texture was set
  10874. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10875. */
  10876. boundingBoxPosition: Vector3;
  10877. private _boundingBoxSize;
  10878. /**
  10879. * Gets or sets the size of the bounding box associated with the cube texture
  10880. * When defined, the cubemap will switch to local mode
  10881. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  10882. * @example https://www.babylonjs-playground.com/#RNASML
  10883. */
  10884. set boundingBoxSize(value: Vector3);
  10885. /**
  10886. * Returns the bounding box size
  10887. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10888. */
  10889. get boundingBoxSize(): Vector3;
  10890. protected _rotationY: number;
  10891. /**
  10892. * Sets texture matrix rotation angle around Y axis in radians.
  10893. */
  10894. set rotationY(value: number);
  10895. /**
  10896. * Gets texture matrix rotation angle around Y axis radians.
  10897. */
  10898. get rotationY(): number;
  10899. /**
  10900. * Are mip maps generated for this texture or not.
  10901. */
  10902. get noMipmap(): boolean;
  10903. private _noMipmap;
  10904. private _files;
  10905. protected _forcedExtension: Nullable<string>;
  10906. private _extensions;
  10907. private _textureMatrix;
  10908. private _format;
  10909. private _createPolynomials;
  10910. private _loaderOptions;
  10911. /**
  10912. * Creates a cube texture from an array of image urls
  10913. * @param files defines an array of image urls
  10914. * @param scene defines the hosting scene
  10915. * @param noMipmap specifies if mip maps are not used
  10916. * @returns a cube texture
  10917. */
  10918. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  10919. /**
  10920. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  10921. * @param url defines the url of the prefiltered texture
  10922. * @param scene defines the scene the texture is attached to
  10923. * @param forcedExtension defines the extension of the file if different from the url
  10924. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10925. * @return the prefiltered texture
  10926. */
  10927. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  10928. /**
  10929. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  10930. * as prefiltered data.
  10931. * @param rootUrl defines the url of the texture or the root name of the six images
  10932. * @param null defines the scene or engine the texture is attached to
  10933. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  10934. * @param noMipmap defines if mipmaps should be created or not
  10935. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  10936. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  10937. * @param onError defines a callback triggered in case of error during load
  10938. * @param format defines the internal format to use for the texture once loaded
  10939. * @param prefiltered defines whether or not the texture is created from prefiltered data
  10940. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  10941. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10942. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10943. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10944. * @param loaderOptions options to be passed to the loader
  10945. * @return the cube texture
  10946. */
  10947. 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);
  10948. /**
  10949. * Get the current class name of the texture useful for serialization or dynamic coding.
  10950. * @returns "CubeTexture"
  10951. */
  10952. getClassName(): string;
  10953. /**
  10954. * Update the url (and optional buffer) of this texture if url was null during construction.
  10955. * @param url the url of the texture
  10956. * @param forcedExtension defines the extension to use
  10957. * @param onLoad callback called when the texture is loaded (defaults to null)
  10958. * @param prefiltered Defines whether the updated texture is prefiltered or not
  10959. */
  10960. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  10961. /**
  10962. * Delays loading of the cube texture
  10963. * @param forcedExtension defines the extension to use
  10964. */
  10965. delayLoad(forcedExtension?: string): void;
  10966. /**
  10967. * Returns the reflection texture matrix
  10968. * @returns the reflection texture matrix
  10969. */
  10970. getReflectionTextureMatrix(): Matrix;
  10971. /**
  10972. * Sets the reflection texture matrix
  10973. * @param value Reflection texture matrix
  10974. */
  10975. setReflectionTextureMatrix(value: Matrix): void;
  10976. /**
  10977. * Parses text to create a cube texture
  10978. * @param parsedTexture define the serialized text to read from
  10979. * @param scene defines the hosting scene
  10980. * @param rootUrl defines the root url of the cube texture
  10981. * @returns a cube texture
  10982. */
  10983. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  10984. /**
  10985. * Makes a clone, or deep copy, of the cube texture
  10986. * @returns a new cube texture
  10987. */
  10988. clone(): CubeTexture;
  10989. }
  10990. }
  10991. declare module BABYLON {
  10992. /**
  10993. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  10994. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  10995. * 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;
  10996. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  10997. */
  10998. export class ColorCurves {
  10999. private _dirty;
  11000. private _tempColor;
  11001. private _globalCurve;
  11002. private _highlightsCurve;
  11003. private _midtonesCurve;
  11004. private _shadowsCurve;
  11005. private _positiveCurve;
  11006. private _negativeCurve;
  11007. private _globalHue;
  11008. private _globalDensity;
  11009. private _globalSaturation;
  11010. private _globalExposure;
  11011. /**
  11012. * Gets the global Hue value.
  11013. * 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).
  11014. */
  11015. get globalHue(): number;
  11016. /**
  11017. * Sets the global Hue value.
  11018. * 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).
  11019. */
  11020. set globalHue(value: number);
  11021. /**
  11022. * Gets the global Density value.
  11023. * 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.
  11024. * Values less than zero provide a filter of opposite hue.
  11025. */
  11026. get globalDensity(): number;
  11027. /**
  11028. * Sets the global Density value.
  11029. * 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.
  11030. * Values less than zero provide a filter of opposite hue.
  11031. */
  11032. set globalDensity(value: number);
  11033. /**
  11034. * Gets the global Saturation value.
  11035. * 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.
  11036. */
  11037. get globalSaturation(): number;
  11038. /**
  11039. * Sets the global Saturation value.
  11040. * 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.
  11041. */
  11042. set globalSaturation(value: number);
  11043. /**
  11044. * Gets the global Exposure value.
  11045. * 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.
  11046. */
  11047. get globalExposure(): number;
  11048. /**
  11049. * Sets the global Exposure value.
  11050. * 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.
  11051. */
  11052. set globalExposure(value: number);
  11053. private _highlightsHue;
  11054. private _highlightsDensity;
  11055. private _highlightsSaturation;
  11056. private _highlightsExposure;
  11057. /**
  11058. * Gets the highlights Hue value.
  11059. * 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).
  11060. */
  11061. get highlightsHue(): number;
  11062. /**
  11063. * Sets the highlights Hue value.
  11064. * 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).
  11065. */
  11066. set highlightsHue(value: number);
  11067. /**
  11068. * Gets the highlights Density value.
  11069. * 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.
  11070. * Values less than zero provide a filter of opposite hue.
  11071. */
  11072. get highlightsDensity(): number;
  11073. /**
  11074. * Sets the highlights Density value.
  11075. * 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.
  11076. * Values less than zero provide a filter of opposite hue.
  11077. */
  11078. set highlightsDensity(value: number);
  11079. /**
  11080. * Gets the highlights Saturation value.
  11081. * 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.
  11082. */
  11083. get highlightsSaturation(): number;
  11084. /**
  11085. * Sets the highlights Saturation value.
  11086. * 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.
  11087. */
  11088. set highlightsSaturation(value: number);
  11089. /**
  11090. * Gets the highlights Exposure value.
  11091. * 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.
  11092. */
  11093. get highlightsExposure(): number;
  11094. /**
  11095. * Sets the highlights Exposure value.
  11096. * 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.
  11097. */
  11098. set highlightsExposure(value: number);
  11099. private _midtonesHue;
  11100. private _midtonesDensity;
  11101. private _midtonesSaturation;
  11102. private _midtonesExposure;
  11103. /**
  11104. * Gets the midtones Hue value.
  11105. * 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).
  11106. */
  11107. get midtonesHue(): number;
  11108. /**
  11109. * Sets the midtones Hue value.
  11110. * 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).
  11111. */
  11112. set midtonesHue(value: number);
  11113. /**
  11114. * Gets the midtones Density value.
  11115. * 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.
  11116. * Values less than zero provide a filter of opposite hue.
  11117. */
  11118. get midtonesDensity(): number;
  11119. /**
  11120. * Sets the midtones Density value.
  11121. * 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.
  11122. * Values less than zero provide a filter of opposite hue.
  11123. */
  11124. set midtonesDensity(value: number);
  11125. /**
  11126. * Gets the midtones Saturation value.
  11127. * 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.
  11128. */
  11129. get midtonesSaturation(): number;
  11130. /**
  11131. * Sets the midtones Saturation value.
  11132. * 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.
  11133. */
  11134. set midtonesSaturation(value: number);
  11135. /**
  11136. * Gets the midtones Exposure value.
  11137. * 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.
  11138. */
  11139. get midtonesExposure(): number;
  11140. /**
  11141. * Sets the midtones Exposure value.
  11142. * 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.
  11143. */
  11144. set midtonesExposure(value: number);
  11145. private _shadowsHue;
  11146. private _shadowsDensity;
  11147. private _shadowsSaturation;
  11148. private _shadowsExposure;
  11149. /**
  11150. * Gets the shadows Hue value.
  11151. * 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).
  11152. */
  11153. get shadowsHue(): number;
  11154. /**
  11155. * Sets the shadows Hue value.
  11156. * 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).
  11157. */
  11158. set shadowsHue(value: number);
  11159. /**
  11160. * Gets the shadows Density value.
  11161. * 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.
  11162. * Values less than zero provide a filter of opposite hue.
  11163. */
  11164. get shadowsDensity(): number;
  11165. /**
  11166. * Sets the shadows Density value.
  11167. * 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.
  11168. * Values less than zero provide a filter of opposite hue.
  11169. */
  11170. set shadowsDensity(value: number);
  11171. /**
  11172. * Gets the shadows Saturation value.
  11173. * 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.
  11174. */
  11175. get shadowsSaturation(): number;
  11176. /**
  11177. * Sets the shadows Saturation value.
  11178. * 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.
  11179. */
  11180. set shadowsSaturation(value: number);
  11181. /**
  11182. * Gets the shadows Exposure value.
  11183. * 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.
  11184. */
  11185. get shadowsExposure(): number;
  11186. /**
  11187. * Sets the shadows Exposure value.
  11188. * 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.
  11189. */
  11190. set shadowsExposure(value: number);
  11191. /**
  11192. * Returns the class name
  11193. * @returns The class name
  11194. */
  11195. getClassName(): string;
  11196. /**
  11197. * Binds the color curves to the shader.
  11198. * @param colorCurves The color curve to bind
  11199. * @param effect The effect to bind to
  11200. * @param positiveUniform The positive uniform shader parameter
  11201. * @param neutralUniform The neutral uniform shader parameter
  11202. * @param negativeUniform The negative uniform shader parameter
  11203. */
  11204. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11205. /**
  11206. * Prepare the list of uniforms associated with the ColorCurves effects.
  11207. * @param uniformsList The list of uniforms used in the effect
  11208. */
  11209. static PrepareUniforms(uniformsList: string[]): void;
  11210. /**
  11211. * Returns color grading data based on a hue, density, saturation and exposure value.
  11212. * @param filterHue The hue of the color filter.
  11213. * @param filterDensity The density of the color filter.
  11214. * @param saturation The saturation.
  11215. * @param exposure The exposure.
  11216. * @param result The result data container.
  11217. */
  11218. private getColorGradingDataToRef;
  11219. /**
  11220. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11221. * @param value The input slider value in range [-100,100].
  11222. * @returns Adjusted value.
  11223. */
  11224. private static applyColorGradingSliderNonlinear;
  11225. /**
  11226. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11227. * @param hue The hue (H) input.
  11228. * @param saturation The saturation (S) input.
  11229. * @param brightness The brightness (B) input.
  11230. * @result An RGBA color represented as Vector4.
  11231. */
  11232. private static fromHSBToRef;
  11233. /**
  11234. * Returns a value clamped between min and max
  11235. * @param value The value to clamp
  11236. * @param min The minimum of value
  11237. * @param max The maximum of value
  11238. * @returns The clamped value.
  11239. */
  11240. private static clamp;
  11241. /**
  11242. * Clones the current color curve instance.
  11243. * @return The cloned curves
  11244. */
  11245. clone(): ColorCurves;
  11246. /**
  11247. * Serializes the current color curve instance to a json representation.
  11248. * @return a JSON representation
  11249. */
  11250. serialize(): any;
  11251. /**
  11252. * Parses the color curve from a json representation.
  11253. * @param source the JSON source to parse
  11254. * @return The parsed curves
  11255. */
  11256. static Parse(source: any): ColorCurves;
  11257. }
  11258. }
  11259. declare module BABYLON {
  11260. /**
  11261. * Interface to follow in your material defines to integrate easily the
  11262. * Image proccessing functions.
  11263. * @hidden
  11264. */
  11265. export interface IImageProcessingConfigurationDefines {
  11266. IMAGEPROCESSING: boolean;
  11267. VIGNETTE: boolean;
  11268. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11269. VIGNETTEBLENDMODEOPAQUE: boolean;
  11270. TONEMAPPING: boolean;
  11271. TONEMAPPING_ACES: boolean;
  11272. CONTRAST: boolean;
  11273. EXPOSURE: boolean;
  11274. COLORCURVES: boolean;
  11275. COLORGRADING: boolean;
  11276. COLORGRADING3D: boolean;
  11277. SAMPLER3DGREENDEPTH: boolean;
  11278. SAMPLER3DBGRMAP: boolean;
  11279. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11280. }
  11281. /**
  11282. * @hidden
  11283. */
  11284. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11285. IMAGEPROCESSING: boolean;
  11286. VIGNETTE: boolean;
  11287. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11288. VIGNETTEBLENDMODEOPAQUE: boolean;
  11289. TONEMAPPING: boolean;
  11290. TONEMAPPING_ACES: boolean;
  11291. CONTRAST: boolean;
  11292. COLORCURVES: boolean;
  11293. COLORGRADING: boolean;
  11294. COLORGRADING3D: boolean;
  11295. SAMPLER3DGREENDEPTH: boolean;
  11296. SAMPLER3DBGRMAP: boolean;
  11297. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11298. EXPOSURE: boolean;
  11299. constructor();
  11300. }
  11301. /**
  11302. * This groups together the common properties used for image processing either in direct forward pass
  11303. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11304. * or not.
  11305. */
  11306. export class ImageProcessingConfiguration {
  11307. /**
  11308. * Default tone mapping applied in BabylonJS.
  11309. */
  11310. static readonly TONEMAPPING_STANDARD: number;
  11311. /**
  11312. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11313. * to other engines rendering to increase portability.
  11314. */
  11315. static readonly TONEMAPPING_ACES: number;
  11316. /**
  11317. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11318. */
  11319. colorCurves: Nullable<ColorCurves>;
  11320. private _colorCurvesEnabled;
  11321. /**
  11322. * Gets wether the color curves effect is enabled.
  11323. */
  11324. get colorCurvesEnabled(): boolean;
  11325. /**
  11326. * Sets wether the color curves effect is enabled.
  11327. */
  11328. set colorCurvesEnabled(value: boolean);
  11329. private _colorGradingTexture;
  11330. /**
  11331. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11332. */
  11333. get colorGradingTexture(): Nullable<BaseTexture>;
  11334. /**
  11335. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11336. */
  11337. set colorGradingTexture(value: Nullable<BaseTexture>);
  11338. private _colorGradingEnabled;
  11339. /**
  11340. * Gets wether the color grading effect is enabled.
  11341. */
  11342. get colorGradingEnabled(): boolean;
  11343. /**
  11344. * Sets wether the color grading effect is enabled.
  11345. */
  11346. set colorGradingEnabled(value: boolean);
  11347. private _colorGradingWithGreenDepth;
  11348. /**
  11349. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11350. */
  11351. get colorGradingWithGreenDepth(): boolean;
  11352. /**
  11353. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11354. */
  11355. set colorGradingWithGreenDepth(value: boolean);
  11356. private _colorGradingBGR;
  11357. /**
  11358. * Gets wether the color grading texture contains BGR values.
  11359. */
  11360. get colorGradingBGR(): boolean;
  11361. /**
  11362. * Sets wether the color grading texture contains BGR values.
  11363. */
  11364. set colorGradingBGR(value: boolean);
  11365. /** @hidden */
  11366. _exposure: number;
  11367. /**
  11368. * Gets the Exposure used in the effect.
  11369. */
  11370. get exposure(): number;
  11371. /**
  11372. * Sets the Exposure used in the effect.
  11373. */
  11374. set exposure(value: number);
  11375. private _toneMappingEnabled;
  11376. /**
  11377. * Gets wether the tone mapping effect is enabled.
  11378. */
  11379. get toneMappingEnabled(): boolean;
  11380. /**
  11381. * Sets wether the tone mapping effect is enabled.
  11382. */
  11383. set toneMappingEnabled(value: boolean);
  11384. private _toneMappingType;
  11385. /**
  11386. * Gets the type of tone mapping effect.
  11387. */
  11388. get toneMappingType(): number;
  11389. /**
  11390. * Sets the type of tone mapping effect used in BabylonJS.
  11391. */
  11392. set toneMappingType(value: number);
  11393. protected _contrast: number;
  11394. /**
  11395. * Gets the contrast used in the effect.
  11396. */
  11397. get contrast(): number;
  11398. /**
  11399. * Sets the contrast used in the effect.
  11400. */
  11401. set contrast(value: number);
  11402. /**
  11403. * Vignette stretch size.
  11404. */
  11405. vignetteStretch: number;
  11406. /**
  11407. * Vignette centre X Offset.
  11408. */
  11409. vignetteCentreX: number;
  11410. /**
  11411. * Vignette centre Y Offset.
  11412. */
  11413. vignetteCentreY: number;
  11414. /**
  11415. * Vignette weight or intensity of the vignette effect.
  11416. */
  11417. vignetteWeight: number;
  11418. /**
  11419. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11420. * if vignetteEnabled is set to true.
  11421. */
  11422. vignetteColor: Color4;
  11423. /**
  11424. * Camera field of view used by the Vignette effect.
  11425. */
  11426. vignetteCameraFov: number;
  11427. private _vignetteBlendMode;
  11428. /**
  11429. * Gets the vignette blend mode allowing different kind of effect.
  11430. */
  11431. get vignetteBlendMode(): number;
  11432. /**
  11433. * Sets the vignette blend mode allowing different kind of effect.
  11434. */
  11435. set vignetteBlendMode(value: number);
  11436. private _vignetteEnabled;
  11437. /**
  11438. * Gets wether the vignette effect is enabled.
  11439. */
  11440. get vignetteEnabled(): boolean;
  11441. /**
  11442. * Sets wether the vignette effect is enabled.
  11443. */
  11444. set vignetteEnabled(value: boolean);
  11445. private _applyByPostProcess;
  11446. /**
  11447. * Gets wether the image processing is applied through a post process or not.
  11448. */
  11449. get applyByPostProcess(): boolean;
  11450. /**
  11451. * Sets wether the image processing is applied through a post process or not.
  11452. */
  11453. set applyByPostProcess(value: boolean);
  11454. private _isEnabled;
  11455. /**
  11456. * Gets wether the image processing is enabled or not.
  11457. */
  11458. get isEnabled(): boolean;
  11459. /**
  11460. * Sets wether the image processing is enabled or not.
  11461. */
  11462. set isEnabled(value: boolean);
  11463. /**
  11464. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11465. */
  11466. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11467. /**
  11468. * Method called each time the image processing information changes requires to recompile the effect.
  11469. */
  11470. protected _updateParameters(): void;
  11471. /**
  11472. * Gets the current class name.
  11473. * @return "ImageProcessingConfiguration"
  11474. */
  11475. getClassName(): string;
  11476. /**
  11477. * Prepare the list of uniforms associated with the Image Processing effects.
  11478. * @param uniforms The list of uniforms used in the effect
  11479. * @param defines the list of defines currently in use
  11480. */
  11481. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11482. /**
  11483. * Prepare the list of samplers associated with the Image Processing effects.
  11484. * @param samplersList The list of uniforms used in the effect
  11485. * @param defines the list of defines currently in use
  11486. */
  11487. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11488. /**
  11489. * Prepare the list of defines associated to the shader.
  11490. * @param defines the list of defines to complete
  11491. * @param forPostProcess Define if we are currently in post process mode or not
  11492. */
  11493. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11494. /**
  11495. * Returns true if all the image processing information are ready.
  11496. * @returns True if ready, otherwise, false
  11497. */
  11498. isReady(): boolean;
  11499. /**
  11500. * Binds the image processing to the shader.
  11501. * @param effect The effect to bind to
  11502. * @param overrideAspectRatio Override the aspect ratio of the effect
  11503. */
  11504. bind(effect: Effect, overrideAspectRatio?: number): void;
  11505. /**
  11506. * Clones the current image processing instance.
  11507. * @return The cloned image processing
  11508. */
  11509. clone(): ImageProcessingConfiguration;
  11510. /**
  11511. * Serializes the current image processing instance to a json representation.
  11512. * @return a JSON representation
  11513. */
  11514. serialize(): any;
  11515. /**
  11516. * Parses the image processing from a json representation.
  11517. * @param source the JSON source to parse
  11518. * @return The parsed image processing
  11519. */
  11520. static Parse(source: any): ImageProcessingConfiguration;
  11521. private static _VIGNETTEMODE_MULTIPLY;
  11522. private static _VIGNETTEMODE_OPAQUE;
  11523. /**
  11524. * Used to apply the vignette as a mix with the pixel color.
  11525. */
  11526. static get VIGNETTEMODE_MULTIPLY(): number;
  11527. /**
  11528. * Used to apply the vignette as a replacement of the pixel color.
  11529. */
  11530. static get VIGNETTEMODE_OPAQUE(): number;
  11531. }
  11532. }
  11533. declare module BABYLON {
  11534. /** @hidden */
  11535. export var postprocessVertexShader: {
  11536. name: string;
  11537. shader: string;
  11538. };
  11539. }
  11540. declare module BABYLON {
  11541. /**
  11542. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11543. */
  11544. export type RenderTargetTextureSize = number | {
  11545. width: number;
  11546. height: number;
  11547. layers?: number;
  11548. };
  11549. interface ThinEngine {
  11550. /**
  11551. * Creates a new render target texture
  11552. * @param size defines the size of the texture
  11553. * @param options defines the options used to create the texture
  11554. * @returns a new render target texture stored in an InternalTexture
  11555. */
  11556. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11557. /**
  11558. * Creates a depth stencil texture.
  11559. * This is only available in WebGL 2 or with the depth texture extension available.
  11560. * @param size The size of face edge in the texture.
  11561. * @param options The options defining the texture.
  11562. * @returns The texture
  11563. */
  11564. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11565. /** @hidden */
  11566. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11567. }
  11568. }
  11569. declare module BABYLON {
  11570. /**
  11571. * Defines the kind of connection point for node based material
  11572. */
  11573. export enum NodeMaterialBlockConnectionPointTypes {
  11574. /** Float */
  11575. Float = 1,
  11576. /** Int */
  11577. Int = 2,
  11578. /** Vector2 */
  11579. Vector2 = 4,
  11580. /** Vector3 */
  11581. Vector3 = 8,
  11582. /** Vector4 */
  11583. Vector4 = 16,
  11584. /** Color3 */
  11585. Color3 = 32,
  11586. /** Color4 */
  11587. Color4 = 64,
  11588. /** Matrix */
  11589. Matrix = 128,
  11590. /** Custom object */
  11591. Object = 256,
  11592. /** Detect type based on connection */
  11593. AutoDetect = 1024,
  11594. /** Output type that will be defined by input type */
  11595. BasedOnInput = 2048
  11596. }
  11597. }
  11598. declare module BABYLON {
  11599. /**
  11600. * Enum used to define the target of a block
  11601. */
  11602. export enum NodeMaterialBlockTargets {
  11603. /** Vertex shader */
  11604. Vertex = 1,
  11605. /** Fragment shader */
  11606. Fragment = 2,
  11607. /** Neutral */
  11608. Neutral = 4,
  11609. /** Vertex and Fragment */
  11610. VertexAndFragment = 3
  11611. }
  11612. }
  11613. declare module BABYLON {
  11614. /**
  11615. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11616. */
  11617. export enum NodeMaterialBlockConnectionPointMode {
  11618. /** Value is an uniform */
  11619. Uniform = 0,
  11620. /** Value is a mesh attribute */
  11621. Attribute = 1,
  11622. /** Value is a varying between vertex and fragment shaders */
  11623. Varying = 2,
  11624. /** Mode is undefined */
  11625. Undefined = 3
  11626. }
  11627. }
  11628. declare module BABYLON {
  11629. /**
  11630. * Enum used to define system values e.g. values automatically provided by the system
  11631. */
  11632. export enum NodeMaterialSystemValues {
  11633. /** World */
  11634. World = 1,
  11635. /** View */
  11636. View = 2,
  11637. /** Projection */
  11638. Projection = 3,
  11639. /** ViewProjection */
  11640. ViewProjection = 4,
  11641. /** WorldView */
  11642. WorldView = 5,
  11643. /** WorldViewProjection */
  11644. WorldViewProjection = 6,
  11645. /** CameraPosition */
  11646. CameraPosition = 7,
  11647. /** Fog Color */
  11648. FogColor = 8,
  11649. /** Delta time */
  11650. DeltaTime = 9
  11651. }
  11652. }
  11653. declare module BABYLON {
  11654. /**
  11655. * Represents a camera frustum
  11656. */
  11657. export class Frustum {
  11658. /**
  11659. * Gets the planes representing the frustum
  11660. * @param transform matrix to be applied to the returned planes
  11661. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11662. */
  11663. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11664. /**
  11665. * Gets the near frustum plane transformed by the transform matrix
  11666. * @param transform transformation matrix to be applied to the resulting frustum plane
  11667. * @param frustumPlane the resuling frustum plane
  11668. */
  11669. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11670. /**
  11671. * Gets the far frustum plane transformed by the transform matrix
  11672. * @param transform transformation matrix to be applied to the resulting frustum plane
  11673. * @param frustumPlane the resuling frustum plane
  11674. */
  11675. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11676. /**
  11677. * Gets the left frustum plane transformed by the transform matrix
  11678. * @param transform transformation matrix to be applied to the resulting frustum plane
  11679. * @param frustumPlane the resuling frustum plane
  11680. */
  11681. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11682. /**
  11683. * Gets the right frustum plane transformed by the transform matrix
  11684. * @param transform transformation matrix to be applied to the resulting frustum plane
  11685. * @param frustumPlane the resuling frustum plane
  11686. */
  11687. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11688. /**
  11689. * Gets the top frustum plane transformed by the transform matrix
  11690. * @param transform transformation matrix to be applied to the resulting frustum plane
  11691. * @param frustumPlane the resuling frustum plane
  11692. */
  11693. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11694. /**
  11695. * Gets the bottom frustum plane transformed by the transform matrix
  11696. * @param transform transformation matrix to be applied to the resulting frustum plane
  11697. * @param frustumPlane the resuling frustum plane
  11698. */
  11699. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11700. /**
  11701. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11702. * @param transform transformation matrix to be applied to the resulting frustum planes
  11703. * @param frustumPlanes the resuling frustum planes
  11704. */
  11705. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11706. }
  11707. }
  11708. declare module BABYLON {
  11709. /**
  11710. * Contains position and normal vectors for a vertex
  11711. */
  11712. export class PositionNormalVertex {
  11713. /** the position of the vertex (defaut: 0,0,0) */
  11714. position: Vector3;
  11715. /** the normal of the vertex (defaut: 0,1,0) */
  11716. normal: Vector3;
  11717. /**
  11718. * Creates a PositionNormalVertex
  11719. * @param position the position of the vertex (defaut: 0,0,0)
  11720. * @param normal the normal of the vertex (defaut: 0,1,0)
  11721. */
  11722. constructor(
  11723. /** the position of the vertex (defaut: 0,0,0) */
  11724. position?: Vector3,
  11725. /** the normal of the vertex (defaut: 0,1,0) */
  11726. normal?: Vector3);
  11727. /**
  11728. * Clones the PositionNormalVertex
  11729. * @returns the cloned PositionNormalVertex
  11730. */
  11731. clone(): PositionNormalVertex;
  11732. }
  11733. /**
  11734. * Contains position, normal and uv vectors for a vertex
  11735. */
  11736. export class PositionNormalTextureVertex {
  11737. /** the position of the vertex (defaut: 0,0,0) */
  11738. position: Vector3;
  11739. /** the normal of the vertex (defaut: 0,1,0) */
  11740. normal: Vector3;
  11741. /** the uv of the vertex (default: 0,0) */
  11742. uv: Vector2;
  11743. /**
  11744. * Creates a PositionNormalTextureVertex
  11745. * @param position the position of the vertex (defaut: 0,0,0)
  11746. * @param normal the normal of the vertex (defaut: 0,1,0)
  11747. * @param uv the uv of the vertex (default: 0,0)
  11748. */
  11749. constructor(
  11750. /** the position of the vertex (defaut: 0,0,0) */
  11751. position?: Vector3,
  11752. /** the normal of the vertex (defaut: 0,1,0) */
  11753. normal?: Vector3,
  11754. /** the uv of the vertex (default: 0,0) */
  11755. uv?: Vector2);
  11756. /**
  11757. * Clones the PositionNormalTextureVertex
  11758. * @returns the cloned PositionNormalTextureVertex
  11759. */
  11760. clone(): PositionNormalTextureVertex;
  11761. }
  11762. }
  11763. declare module BABYLON {
  11764. /**
  11765. * Enum defining the type of animations supported by InputBlock
  11766. */
  11767. export enum AnimatedInputBlockTypes {
  11768. /** No animation */
  11769. None = 0,
  11770. /** Time based animation. Will only work for floats */
  11771. Time = 1
  11772. }
  11773. }
  11774. declare module BABYLON {
  11775. /**
  11776. * Block used to expose an input value
  11777. */
  11778. export class InputBlock extends NodeMaterialBlock {
  11779. private _mode;
  11780. private _associatedVariableName;
  11781. private _storedValue;
  11782. private _valueCallback;
  11783. private _type;
  11784. private _animationType;
  11785. /** Gets or set a value used to limit the range of float values */
  11786. min: number;
  11787. /** Gets or set a value used to limit the range of float values */
  11788. max: number;
  11789. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  11790. isBoolean: boolean;
  11791. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  11792. matrixMode: number;
  11793. /** @hidden */
  11794. _systemValue: Nullable<NodeMaterialSystemValues>;
  11795. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  11796. isConstant: boolean;
  11797. /** Gets or sets the group to use to display this block in the Inspector */
  11798. groupInInspector: string;
  11799. /** Gets an observable raised when the value is changed */
  11800. onValueChangedObservable: Observable<InputBlock>;
  11801. /**
  11802. * Gets or sets the connection point type (default is float)
  11803. */
  11804. get type(): NodeMaterialBlockConnectionPointTypes;
  11805. /**
  11806. * Creates a new InputBlock
  11807. * @param name defines the block name
  11808. * @param target defines the target of that block (Vertex by default)
  11809. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  11810. */
  11811. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  11812. /**
  11813. * Validates if a name is a reserve word.
  11814. * @param newName the new name to be given to the node.
  11815. * @returns false if the name is a reserve word, else true.
  11816. */
  11817. validateBlockName(newName: string): boolean;
  11818. /**
  11819. * Gets the output component
  11820. */
  11821. get output(): NodeMaterialConnectionPoint;
  11822. /**
  11823. * Set the source of this connection point to a vertex attribute
  11824. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  11825. * @returns the current connection point
  11826. */
  11827. setAsAttribute(attributeName?: string): InputBlock;
  11828. /**
  11829. * Set the source of this connection point to a system value
  11830. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  11831. * @returns the current connection point
  11832. */
  11833. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  11834. /**
  11835. * Gets or sets the value of that point.
  11836. * Please note that this value will be ignored if valueCallback is defined
  11837. */
  11838. get value(): any;
  11839. set value(value: any);
  11840. /**
  11841. * Gets or sets a callback used to get the value of that point.
  11842. * Please note that setting this value will force the connection point to ignore the value property
  11843. */
  11844. get valueCallback(): () => any;
  11845. set valueCallback(value: () => any);
  11846. /**
  11847. * Gets or sets the associated variable name in the shader
  11848. */
  11849. get associatedVariableName(): string;
  11850. set associatedVariableName(value: string);
  11851. /** Gets or sets the type of animation applied to the input */
  11852. get animationType(): AnimatedInputBlockTypes;
  11853. set animationType(value: AnimatedInputBlockTypes);
  11854. /**
  11855. * Gets a boolean indicating that this connection point not defined yet
  11856. */
  11857. get isUndefined(): boolean;
  11858. /**
  11859. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  11860. * In this case the connection point name must be the name of the uniform to use.
  11861. * Can only be set on inputs
  11862. */
  11863. get isUniform(): boolean;
  11864. set isUniform(value: boolean);
  11865. /**
  11866. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  11867. * In this case the connection point name must be the name of the attribute to use
  11868. * Can only be set on inputs
  11869. */
  11870. get isAttribute(): boolean;
  11871. set isAttribute(value: boolean);
  11872. /**
  11873. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  11874. * Can only be set on exit points
  11875. */
  11876. get isVarying(): boolean;
  11877. set isVarying(value: boolean);
  11878. /**
  11879. * Gets a boolean indicating that the current connection point is a system value
  11880. */
  11881. get isSystemValue(): boolean;
  11882. /**
  11883. * Gets or sets the current well known value or null if not defined as a system value
  11884. */
  11885. get systemValue(): Nullable<NodeMaterialSystemValues>;
  11886. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  11887. /**
  11888. * Gets the current class name
  11889. * @returns the class name
  11890. */
  11891. getClassName(): string;
  11892. /**
  11893. * Animate the input if animationType !== None
  11894. * @param scene defines the rendering scene
  11895. */
  11896. animate(scene: Scene): void;
  11897. private _emitDefine;
  11898. initialize(state: NodeMaterialBuildState): void;
  11899. /**
  11900. * Set the input block to its default value (based on its type)
  11901. */
  11902. setDefaultValue(): void;
  11903. private _emitConstant;
  11904. /** @hidden */
  11905. get _noContextSwitch(): boolean;
  11906. private _emit;
  11907. /** @hidden */
  11908. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  11909. /** @hidden */
  11910. _transmit(effect: Effect, scene: Scene): void;
  11911. protected _buildBlock(state: NodeMaterialBuildState): void;
  11912. protected _dumpPropertiesCode(): string;
  11913. dispose(): void;
  11914. serialize(): any;
  11915. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  11916. }
  11917. }
  11918. declare module BABYLON {
  11919. /**
  11920. * Enum used to define the compatibility state between two connection points
  11921. */
  11922. export enum NodeMaterialConnectionPointCompatibilityStates {
  11923. /** Points are compatibles */
  11924. Compatible = 0,
  11925. /** Points are incompatible because of their types */
  11926. TypeIncompatible = 1,
  11927. /** Points are incompatible because of their targets (vertex vs fragment) */
  11928. TargetIncompatible = 2
  11929. }
  11930. /**
  11931. * Defines the direction of a connection point
  11932. */
  11933. export enum NodeMaterialConnectionPointDirection {
  11934. /** Input */
  11935. Input = 0,
  11936. /** Output */
  11937. Output = 1
  11938. }
  11939. /**
  11940. * Defines a connection point for a block
  11941. */
  11942. export class NodeMaterialConnectionPoint {
  11943. /**
  11944. * Checks if two types are equivalent
  11945. * @param type1 type 1 to check
  11946. * @param type2 type 2 to check
  11947. * @returns true if both types are equivalent, else false
  11948. */
  11949. static AreEquivalentTypes(type1: number, type2: number): boolean;
  11950. /** @hidden */
  11951. _ownerBlock: NodeMaterialBlock;
  11952. /** @hidden */
  11953. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  11954. private _endpoints;
  11955. private _associatedVariableName;
  11956. private _direction;
  11957. /** @hidden */
  11958. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  11959. /** @hidden */
  11960. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  11961. /** @hidden */
  11962. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  11963. private _type;
  11964. /** @hidden */
  11965. _enforceAssociatedVariableName: boolean;
  11966. /** Gets the direction of the point */
  11967. get direction(): NodeMaterialConnectionPointDirection;
  11968. /** Indicates that this connection point needs dual validation before being connected to another point */
  11969. needDualDirectionValidation: boolean;
  11970. /**
  11971. * Gets or sets the additional types supported by this connection point
  11972. */
  11973. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  11974. /**
  11975. * Gets or sets the additional types excluded by this connection point
  11976. */
  11977. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  11978. /**
  11979. * Observable triggered when this point is connected
  11980. */
  11981. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  11982. /**
  11983. * Gets or sets the associated variable name in the shader
  11984. */
  11985. get associatedVariableName(): string;
  11986. set associatedVariableName(value: string);
  11987. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  11988. get innerType(): NodeMaterialBlockConnectionPointTypes;
  11989. /**
  11990. * Gets or sets the connection point type (default is float)
  11991. */
  11992. get type(): NodeMaterialBlockConnectionPointTypes;
  11993. set type(value: NodeMaterialBlockConnectionPointTypes);
  11994. /**
  11995. * Gets or sets the connection point name
  11996. */
  11997. name: string;
  11998. /**
  11999. * Gets or sets the connection point name
  12000. */
  12001. displayName: string;
  12002. /**
  12003. * Gets or sets a boolean indicating that this connection point can be omitted
  12004. */
  12005. isOptional: boolean;
  12006. /**
  12007. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12008. */
  12009. isExposedOnFrame: boolean;
  12010. /**
  12011. * Gets or sets number indicating the position that the port is exposed to on a frame
  12012. */
  12013. exposedPortPosition: number;
  12014. /**
  12015. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12016. */
  12017. define: string;
  12018. /** @hidden */
  12019. _prioritizeVertex: boolean;
  12020. private _target;
  12021. /** Gets or sets the target of that connection point */
  12022. get target(): NodeMaterialBlockTargets;
  12023. set target(value: NodeMaterialBlockTargets);
  12024. /**
  12025. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12026. */
  12027. get isConnected(): boolean;
  12028. /**
  12029. * Gets a boolean indicating that the current point is connected to an input block
  12030. */
  12031. get isConnectedToInputBlock(): boolean;
  12032. /**
  12033. * Gets a the connected input block (if any)
  12034. */
  12035. get connectInputBlock(): Nullable<InputBlock>;
  12036. /** Get the other side of the connection (if any) */
  12037. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12038. /** Get the block that owns this connection point */
  12039. get ownerBlock(): NodeMaterialBlock;
  12040. /** Get the block connected on the other side of this connection (if any) */
  12041. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12042. /** Get the block connected on the endpoints of this connection (if any) */
  12043. get connectedBlocks(): Array<NodeMaterialBlock>;
  12044. /** Gets the list of connected endpoints */
  12045. get endpoints(): NodeMaterialConnectionPoint[];
  12046. /** Gets a boolean indicating if that output point is connected to at least one input */
  12047. get hasEndpoints(): boolean;
  12048. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12049. get isConnectedInVertexShader(): boolean;
  12050. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12051. get isConnectedInFragmentShader(): boolean;
  12052. /**
  12053. * Creates a block suitable to be used as an input for this input point.
  12054. * If null is returned, a block based on the point type will be created.
  12055. * @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
  12056. */
  12057. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12058. /**
  12059. * Creates a new connection point
  12060. * @param name defines the connection point name
  12061. * @param ownerBlock defines the block hosting this connection point
  12062. * @param direction defines the direction of the connection point
  12063. */
  12064. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12065. /**
  12066. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12067. * @returns the class name
  12068. */
  12069. getClassName(): string;
  12070. /**
  12071. * Gets a boolean indicating if the current point can be connected to another point
  12072. * @param connectionPoint defines the other connection point
  12073. * @returns a boolean
  12074. */
  12075. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12076. /**
  12077. * Gets a number indicating if the current point can be connected to another point
  12078. * @param connectionPoint defines the other connection point
  12079. * @returns a number defining the compatibility state
  12080. */
  12081. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12082. /**
  12083. * Connect this point to another connection point
  12084. * @param connectionPoint defines the other connection point
  12085. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12086. * @returns the current connection point
  12087. */
  12088. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12089. /**
  12090. * Disconnect this point from one of his endpoint
  12091. * @param endpoint defines the other connection point
  12092. * @returns the current connection point
  12093. */
  12094. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12095. /**
  12096. * Serializes this point in a JSON representation
  12097. * @param isInput defines if the connection point is an input (default is true)
  12098. * @returns the serialized point object
  12099. */
  12100. serialize(isInput?: boolean): any;
  12101. /**
  12102. * Release resources
  12103. */
  12104. dispose(): void;
  12105. }
  12106. }
  12107. declare module BABYLON {
  12108. /**
  12109. * Enum used to define the material modes
  12110. */
  12111. export enum NodeMaterialModes {
  12112. /** Regular material */
  12113. Material = 0,
  12114. /** For post process */
  12115. PostProcess = 1,
  12116. /** For particle system */
  12117. Particle = 2,
  12118. /** For procedural texture */
  12119. ProceduralTexture = 3
  12120. }
  12121. }
  12122. declare module BABYLON {
  12123. /** @hidden */
  12124. export var helperFunctions: {
  12125. name: string;
  12126. shader: string;
  12127. };
  12128. }
  12129. declare module BABYLON {
  12130. /**
  12131. * Block used to read a texture from a sampler
  12132. */
  12133. export class TextureBlock extends NodeMaterialBlock {
  12134. private _defineName;
  12135. private _linearDefineName;
  12136. private _gammaDefineName;
  12137. private _tempTextureRead;
  12138. private _samplerName;
  12139. private _transformedUVName;
  12140. private _textureTransformName;
  12141. private _textureInfoName;
  12142. private _mainUVName;
  12143. private _mainUVDefineName;
  12144. private _fragmentOnly;
  12145. /**
  12146. * Gets or sets the texture associated with the node
  12147. */
  12148. texture: Nullable<Texture>;
  12149. /**
  12150. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12151. */
  12152. convertToGammaSpace: boolean;
  12153. /**
  12154. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12155. */
  12156. convertToLinearSpace: boolean;
  12157. /**
  12158. * Create a new TextureBlock
  12159. * @param name defines the block name
  12160. */
  12161. constructor(name: string, fragmentOnly?: boolean);
  12162. /**
  12163. * Gets the current class name
  12164. * @returns the class name
  12165. */
  12166. getClassName(): string;
  12167. /**
  12168. * Gets the uv input component
  12169. */
  12170. get uv(): NodeMaterialConnectionPoint;
  12171. /**
  12172. * Gets the rgba output component
  12173. */
  12174. get rgba(): NodeMaterialConnectionPoint;
  12175. /**
  12176. * Gets the rgb output component
  12177. */
  12178. get rgb(): NodeMaterialConnectionPoint;
  12179. /**
  12180. * Gets the r output component
  12181. */
  12182. get r(): NodeMaterialConnectionPoint;
  12183. /**
  12184. * Gets the g output component
  12185. */
  12186. get g(): NodeMaterialConnectionPoint;
  12187. /**
  12188. * Gets the b output component
  12189. */
  12190. get b(): NodeMaterialConnectionPoint;
  12191. /**
  12192. * Gets the a output component
  12193. */
  12194. get a(): NodeMaterialConnectionPoint;
  12195. get target(): NodeMaterialBlockTargets;
  12196. autoConfigure(material: NodeMaterial): void;
  12197. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12198. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12199. isReady(): boolean;
  12200. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12201. private get _isMixed();
  12202. private _injectVertexCode;
  12203. private _writeTextureRead;
  12204. private _writeOutput;
  12205. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12206. protected _dumpPropertiesCode(): string;
  12207. serialize(): any;
  12208. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12209. }
  12210. }
  12211. declare module BABYLON {
  12212. /** @hidden */
  12213. export var reflectionFunction: {
  12214. name: string;
  12215. shader: string;
  12216. };
  12217. }
  12218. declare module BABYLON {
  12219. /**
  12220. * Base block used to read a reflection texture from a sampler
  12221. */
  12222. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12223. /** @hidden */
  12224. _define3DName: string;
  12225. /** @hidden */
  12226. _defineCubicName: string;
  12227. /** @hidden */
  12228. _defineExplicitName: string;
  12229. /** @hidden */
  12230. _defineProjectionName: string;
  12231. /** @hidden */
  12232. _defineLocalCubicName: string;
  12233. /** @hidden */
  12234. _defineSphericalName: string;
  12235. /** @hidden */
  12236. _definePlanarName: string;
  12237. /** @hidden */
  12238. _defineEquirectangularName: string;
  12239. /** @hidden */
  12240. _defineMirroredEquirectangularFixedName: string;
  12241. /** @hidden */
  12242. _defineEquirectangularFixedName: string;
  12243. /** @hidden */
  12244. _defineSkyboxName: string;
  12245. /** @hidden */
  12246. _defineOppositeZ: string;
  12247. /** @hidden */
  12248. _cubeSamplerName: string;
  12249. /** @hidden */
  12250. _2DSamplerName: string;
  12251. protected _positionUVWName: string;
  12252. protected _directionWName: string;
  12253. protected _reflectionVectorName: string;
  12254. /** @hidden */
  12255. _reflectionCoordsName: string;
  12256. /** @hidden */
  12257. _reflectionMatrixName: string;
  12258. protected _reflectionColorName: string;
  12259. /**
  12260. * Gets or sets the texture associated with the node
  12261. */
  12262. texture: Nullable<BaseTexture>;
  12263. /**
  12264. * Create a new ReflectionTextureBaseBlock
  12265. * @param name defines the block name
  12266. */
  12267. constructor(name: string);
  12268. /**
  12269. * Gets the current class name
  12270. * @returns the class name
  12271. */
  12272. getClassName(): string;
  12273. /**
  12274. * Gets the world position input component
  12275. */
  12276. abstract get position(): NodeMaterialConnectionPoint;
  12277. /**
  12278. * Gets the world position input component
  12279. */
  12280. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12281. /**
  12282. * Gets the world normal input component
  12283. */
  12284. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12285. /**
  12286. * Gets the world input component
  12287. */
  12288. abstract get world(): NodeMaterialConnectionPoint;
  12289. /**
  12290. * Gets the camera (or eye) position component
  12291. */
  12292. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12293. /**
  12294. * Gets the view input component
  12295. */
  12296. abstract get view(): NodeMaterialConnectionPoint;
  12297. protected _getTexture(): Nullable<BaseTexture>;
  12298. autoConfigure(material: NodeMaterial): void;
  12299. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12300. isReady(): boolean;
  12301. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12302. /**
  12303. * Gets the code to inject in the vertex shader
  12304. * @param state current state of the node material building
  12305. * @returns the shader code
  12306. */
  12307. handleVertexSide(state: NodeMaterialBuildState): string;
  12308. /**
  12309. * Handles the inits for the fragment code path
  12310. * @param state node material build state
  12311. */
  12312. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12313. /**
  12314. * Generates the reflection coords code for the fragment code path
  12315. * @param worldNormalVarName name of the world normal variable
  12316. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12317. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12318. * @returns the shader code
  12319. */
  12320. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12321. /**
  12322. * Generates the reflection color code for the fragment code path
  12323. * @param lodVarName name of the lod variable
  12324. * @param swizzleLookupTexture swizzle to use for the final color variable
  12325. * @returns the shader code
  12326. */
  12327. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12328. /**
  12329. * Generates the code corresponding to the connected output points
  12330. * @param state node material build state
  12331. * @param varName name of the variable to output
  12332. * @returns the shader code
  12333. */
  12334. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12335. protected _buildBlock(state: NodeMaterialBuildState): this;
  12336. protected _dumpPropertiesCode(): string;
  12337. serialize(): any;
  12338. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12339. }
  12340. }
  12341. declare module BABYLON {
  12342. /**
  12343. * Defines a connection point to be used for points with a custom object type
  12344. */
  12345. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12346. private _blockType;
  12347. private _blockName;
  12348. private _nameForCheking?;
  12349. /**
  12350. * Creates a new connection point
  12351. * @param name defines the connection point name
  12352. * @param ownerBlock defines the block hosting this connection point
  12353. * @param direction defines the direction of the connection point
  12354. */
  12355. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12356. /**
  12357. * Gets a number indicating if the current point can be connected to another point
  12358. * @param connectionPoint defines the other connection point
  12359. * @returns a number defining the compatibility state
  12360. */
  12361. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12362. /**
  12363. * Creates a block suitable to be used as an input for this input point.
  12364. * If null is returned, a block based on the point type will be created.
  12365. * @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
  12366. */
  12367. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12368. }
  12369. }
  12370. declare module BABYLON {
  12371. /**
  12372. * Enum defining the type of properties that can be edited in the property pages in the NME
  12373. */
  12374. export enum PropertyTypeForEdition {
  12375. /** property is a boolean */
  12376. Boolean = 0,
  12377. /** property is a float */
  12378. Float = 1,
  12379. /** property is a Vector2 */
  12380. Vector2 = 2,
  12381. /** property is a list of values */
  12382. List = 3
  12383. }
  12384. /**
  12385. * Interface that defines an option in a variable of type list
  12386. */
  12387. export interface IEditablePropertyListOption {
  12388. /** label of the option */
  12389. "label": string;
  12390. /** value of the option */
  12391. "value": number;
  12392. }
  12393. /**
  12394. * Interface that defines the options available for an editable property
  12395. */
  12396. export interface IEditablePropertyOption {
  12397. /** min value */
  12398. "min"?: number;
  12399. /** max value */
  12400. "max"?: number;
  12401. /** notifiers: indicates which actions to take when the property is changed */
  12402. "notifiers"?: {
  12403. /** the material should be rebuilt */
  12404. "rebuild"?: boolean;
  12405. /** the preview should be updated */
  12406. "update"?: boolean;
  12407. };
  12408. /** list of the options for a variable of type list */
  12409. "options"?: IEditablePropertyListOption[];
  12410. }
  12411. /**
  12412. * Interface that describes an editable property
  12413. */
  12414. export interface IPropertyDescriptionForEdition {
  12415. /** name of the property */
  12416. "propertyName": string;
  12417. /** display name of the property */
  12418. "displayName": string;
  12419. /** type of the property */
  12420. "type": PropertyTypeForEdition;
  12421. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12422. "groupName": string;
  12423. /** options for the property */
  12424. "options": IEditablePropertyOption;
  12425. }
  12426. /**
  12427. * Decorator that flags a property in a node material block as being editable
  12428. */
  12429. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12430. }
  12431. declare module BABYLON {
  12432. /**
  12433. * Block used to implement the refraction part of the sub surface module of the PBR material
  12434. */
  12435. export class RefractionBlock extends NodeMaterialBlock {
  12436. /** @hidden */
  12437. _define3DName: string;
  12438. /** @hidden */
  12439. _refractionMatrixName: string;
  12440. /** @hidden */
  12441. _defineLODRefractionAlpha: string;
  12442. /** @hidden */
  12443. _defineLinearSpecularRefraction: string;
  12444. /** @hidden */
  12445. _defineOppositeZ: string;
  12446. /** @hidden */
  12447. _cubeSamplerName: string;
  12448. /** @hidden */
  12449. _2DSamplerName: string;
  12450. /** @hidden */
  12451. _vRefractionMicrosurfaceInfosName: string;
  12452. /** @hidden */
  12453. _vRefractionInfosName: string;
  12454. private _scene;
  12455. /**
  12456. * The properties below are set by the main PBR block prior to calling methods of this class.
  12457. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12458. * It's less burden on the user side in the editor part.
  12459. */
  12460. /** @hidden */
  12461. viewConnectionPoint: NodeMaterialConnectionPoint;
  12462. /** @hidden */
  12463. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12464. /**
  12465. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12466. * Materials half opaque for instance using refraction could benefit from this control.
  12467. */
  12468. linkRefractionWithTransparency: boolean;
  12469. /**
  12470. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12471. */
  12472. invertRefractionY: boolean;
  12473. /**
  12474. * Gets or sets the texture associated with the node
  12475. */
  12476. texture: Nullable<BaseTexture>;
  12477. /**
  12478. * Create a new RefractionBlock
  12479. * @param name defines the block name
  12480. */
  12481. constructor(name: string);
  12482. /**
  12483. * Gets the current class name
  12484. * @returns the class name
  12485. */
  12486. getClassName(): string;
  12487. /**
  12488. * Gets the intensity input component
  12489. */
  12490. get intensity(): NodeMaterialConnectionPoint;
  12491. /**
  12492. * Gets the tint at distance input component
  12493. */
  12494. get tintAtDistance(): NodeMaterialConnectionPoint;
  12495. /**
  12496. * Gets the view input component
  12497. */
  12498. get view(): NodeMaterialConnectionPoint;
  12499. /**
  12500. * Gets the refraction object output component
  12501. */
  12502. get refraction(): NodeMaterialConnectionPoint;
  12503. /**
  12504. * Returns true if the block has a texture
  12505. */
  12506. get hasTexture(): boolean;
  12507. protected _getTexture(): Nullable<BaseTexture>;
  12508. autoConfigure(material: NodeMaterial): void;
  12509. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12510. isReady(): boolean;
  12511. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12512. /**
  12513. * Gets the main code of the block (fragment side)
  12514. * @param state current state of the node material building
  12515. * @returns the shader code
  12516. */
  12517. getCode(state: NodeMaterialBuildState): string;
  12518. protected _buildBlock(state: NodeMaterialBuildState): this;
  12519. protected _dumpPropertiesCode(): string;
  12520. serialize(): any;
  12521. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12522. }
  12523. }
  12524. declare module BABYLON {
  12525. /**
  12526. * Base block used as input for post process
  12527. */
  12528. export class CurrentScreenBlock extends NodeMaterialBlock {
  12529. private _samplerName;
  12530. private _linearDefineName;
  12531. private _gammaDefineName;
  12532. private _mainUVName;
  12533. private _tempTextureRead;
  12534. /**
  12535. * Gets or sets the texture associated with the node
  12536. */
  12537. texture: Nullable<BaseTexture>;
  12538. /**
  12539. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12540. */
  12541. convertToGammaSpace: boolean;
  12542. /**
  12543. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12544. */
  12545. convertToLinearSpace: boolean;
  12546. /**
  12547. * Create a new CurrentScreenBlock
  12548. * @param name defines the block name
  12549. */
  12550. constructor(name: string);
  12551. /**
  12552. * Gets the current class name
  12553. * @returns the class name
  12554. */
  12555. getClassName(): string;
  12556. /**
  12557. * Gets the uv input component
  12558. */
  12559. get uv(): NodeMaterialConnectionPoint;
  12560. /**
  12561. * Gets the rgba output component
  12562. */
  12563. get rgba(): NodeMaterialConnectionPoint;
  12564. /**
  12565. * Gets the rgb output component
  12566. */
  12567. get rgb(): NodeMaterialConnectionPoint;
  12568. /**
  12569. * Gets the r output component
  12570. */
  12571. get r(): NodeMaterialConnectionPoint;
  12572. /**
  12573. * Gets the g output component
  12574. */
  12575. get g(): NodeMaterialConnectionPoint;
  12576. /**
  12577. * Gets the b output component
  12578. */
  12579. get b(): NodeMaterialConnectionPoint;
  12580. /**
  12581. * Gets the a output component
  12582. */
  12583. get a(): NodeMaterialConnectionPoint;
  12584. /**
  12585. * Initialize the block and prepare the context for build
  12586. * @param state defines the state that will be used for the build
  12587. */
  12588. initialize(state: NodeMaterialBuildState): void;
  12589. get target(): NodeMaterialBlockTargets;
  12590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12591. isReady(): boolean;
  12592. private _injectVertexCode;
  12593. private _writeTextureRead;
  12594. private _writeOutput;
  12595. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12596. serialize(): any;
  12597. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12598. }
  12599. }
  12600. declare module BABYLON {
  12601. /**
  12602. * Base block used for the particle texture
  12603. */
  12604. export class ParticleTextureBlock extends NodeMaterialBlock {
  12605. private _samplerName;
  12606. private _linearDefineName;
  12607. private _gammaDefineName;
  12608. private _tempTextureRead;
  12609. /**
  12610. * Gets or sets the texture associated with the node
  12611. */
  12612. texture: Nullable<BaseTexture>;
  12613. /**
  12614. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12615. */
  12616. convertToGammaSpace: boolean;
  12617. /**
  12618. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12619. */
  12620. convertToLinearSpace: boolean;
  12621. /**
  12622. * Create a new ParticleTextureBlock
  12623. * @param name defines the block name
  12624. */
  12625. constructor(name: string);
  12626. /**
  12627. * Gets the current class name
  12628. * @returns the class name
  12629. */
  12630. getClassName(): string;
  12631. /**
  12632. * Gets the uv input component
  12633. */
  12634. get uv(): NodeMaterialConnectionPoint;
  12635. /**
  12636. * Gets the rgba output component
  12637. */
  12638. get rgba(): NodeMaterialConnectionPoint;
  12639. /**
  12640. * Gets the rgb output component
  12641. */
  12642. get rgb(): NodeMaterialConnectionPoint;
  12643. /**
  12644. * Gets the r output component
  12645. */
  12646. get r(): NodeMaterialConnectionPoint;
  12647. /**
  12648. * Gets the g output component
  12649. */
  12650. get g(): NodeMaterialConnectionPoint;
  12651. /**
  12652. * Gets the b output component
  12653. */
  12654. get b(): NodeMaterialConnectionPoint;
  12655. /**
  12656. * Gets the a output component
  12657. */
  12658. get a(): NodeMaterialConnectionPoint;
  12659. /**
  12660. * Initialize the block and prepare the context for build
  12661. * @param state defines the state that will be used for the build
  12662. */
  12663. initialize(state: NodeMaterialBuildState): void;
  12664. autoConfigure(material: NodeMaterial): void;
  12665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12666. isReady(): boolean;
  12667. private _writeOutput;
  12668. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12669. serialize(): any;
  12670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12671. }
  12672. }
  12673. declare module BABYLON {
  12674. /**
  12675. * Class used to store shared data between 2 NodeMaterialBuildState
  12676. */
  12677. export class NodeMaterialBuildStateSharedData {
  12678. /**
  12679. * Gets the list of emitted varyings
  12680. */
  12681. temps: string[];
  12682. /**
  12683. * Gets the list of emitted varyings
  12684. */
  12685. varyings: string[];
  12686. /**
  12687. * Gets the varying declaration string
  12688. */
  12689. varyingDeclaration: string;
  12690. /**
  12691. * Input blocks
  12692. */
  12693. inputBlocks: InputBlock[];
  12694. /**
  12695. * Input blocks
  12696. */
  12697. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  12698. /**
  12699. * Bindable blocks (Blocks that need to set data to the effect)
  12700. */
  12701. bindableBlocks: NodeMaterialBlock[];
  12702. /**
  12703. * List of blocks that can provide a compilation fallback
  12704. */
  12705. blocksWithFallbacks: NodeMaterialBlock[];
  12706. /**
  12707. * List of blocks that can provide a define update
  12708. */
  12709. blocksWithDefines: NodeMaterialBlock[];
  12710. /**
  12711. * List of blocks that can provide a repeatable content
  12712. */
  12713. repeatableContentBlocks: NodeMaterialBlock[];
  12714. /**
  12715. * List of blocks that can provide a dynamic list of uniforms
  12716. */
  12717. dynamicUniformBlocks: NodeMaterialBlock[];
  12718. /**
  12719. * List of blocks that can block the isReady function for the material
  12720. */
  12721. blockingBlocks: NodeMaterialBlock[];
  12722. /**
  12723. * Gets the list of animated inputs
  12724. */
  12725. animatedInputs: InputBlock[];
  12726. /**
  12727. * Build Id used to avoid multiple recompilations
  12728. */
  12729. buildId: number;
  12730. /** List of emitted variables */
  12731. variableNames: {
  12732. [key: string]: number;
  12733. };
  12734. /** List of emitted defines */
  12735. defineNames: {
  12736. [key: string]: number;
  12737. };
  12738. /** Should emit comments? */
  12739. emitComments: boolean;
  12740. /** Emit build activity */
  12741. verbose: boolean;
  12742. /** Gets or sets the hosting scene */
  12743. scene: Scene;
  12744. /**
  12745. * Gets the compilation hints emitted at compilation time
  12746. */
  12747. hints: {
  12748. needWorldViewMatrix: boolean;
  12749. needWorldViewProjectionMatrix: boolean;
  12750. needAlphaBlending: boolean;
  12751. needAlphaTesting: boolean;
  12752. };
  12753. /**
  12754. * List of compilation checks
  12755. */
  12756. checks: {
  12757. emitVertex: boolean;
  12758. emitFragment: boolean;
  12759. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  12760. };
  12761. /**
  12762. * Is vertex program allowed to be empty?
  12763. */
  12764. allowEmptyVertexProgram: boolean;
  12765. /** Creates a new shared data */
  12766. constructor();
  12767. /**
  12768. * Emits console errors and exceptions if there is a failing check
  12769. */
  12770. emitErrors(): void;
  12771. }
  12772. }
  12773. declare module BABYLON {
  12774. /**
  12775. * Class used to store node based material build state
  12776. */
  12777. export class NodeMaterialBuildState {
  12778. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  12779. supportUniformBuffers: boolean;
  12780. /**
  12781. * Gets the list of emitted attributes
  12782. */
  12783. attributes: string[];
  12784. /**
  12785. * Gets the list of emitted uniforms
  12786. */
  12787. uniforms: string[];
  12788. /**
  12789. * Gets the list of emitted constants
  12790. */
  12791. constants: string[];
  12792. /**
  12793. * Gets the list of emitted samplers
  12794. */
  12795. samplers: string[];
  12796. /**
  12797. * Gets the list of emitted functions
  12798. */
  12799. functions: {
  12800. [key: string]: string;
  12801. };
  12802. /**
  12803. * Gets the list of emitted extensions
  12804. */
  12805. extensions: {
  12806. [key: string]: string;
  12807. };
  12808. /**
  12809. * Gets the target of the compilation state
  12810. */
  12811. target: NodeMaterialBlockTargets;
  12812. /**
  12813. * Gets the list of emitted counters
  12814. */
  12815. counters: {
  12816. [key: string]: number;
  12817. };
  12818. /**
  12819. * Shared data between multiple NodeMaterialBuildState instances
  12820. */
  12821. sharedData: NodeMaterialBuildStateSharedData;
  12822. /** @hidden */
  12823. _vertexState: NodeMaterialBuildState;
  12824. /** @hidden */
  12825. _attributeDeclaration: string;
  12826. /** @hidden */
  12827. _uniformDeclaration: string;
  12828. /** @hidden */
  12829. _constantDeclaration: string;
  12830. /** @hidden */
  12831. _samplerDeclaration: string;
  12832. /** @hidden */
  12833. _varyingTransfer: string;
  12834. /** @hidden */
  12835. _injectAtEnd: string;
  12836. private _repeatableContentAnchorIndex;
  12837. /** @hidden */
  12838. _builtCompilationString: string;
  12839. /**
  12840. * Gets the emitted compilation strings
  12841. */
  12842. compilationString: string;
  12843. /**
  12844. * Finalize the compilation strings
  12845. * @param state defines the current compilation state
  12846. */
  12847. finalize(state: NodeMaterialBuildState): void;
  12848. /** @hidden */
  12849. get _repeatableContentAnchor(): string;
  12850. /** @hidden */
  12851. _getFreeVariableName(prefix: string): string;
  12852. /** @hidden */
  12853. _getFreeDefineName(prefix: string): string;
  12854. /** @hidden */
  12855. _excludeVariableName(name: string): void;
  12856. /** @hidden */
  12857. _emit2DSampler(name: string): void;
  12858. /** @hidden */
  12859. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  12860. /** @hidden */
  12861. _emitExtension(name: string, extension: string, define?: string): void;
  12862. /** @hidden */
  12863. _emitFunction(name: string, code: string, comments: string): void;
  12864. /** @hidden */
  12865. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  12866. replaceStrings?: {
  12867. search: RegExp;
  12868. replace: string;
  12869. }[];
  12870. repeatKey?: string;
  12871. }): string;
  12872. /** @hidden */
  12873. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  12874. repeatKey?: string;
  12875. removeAttributes?: boolean;
  12876. removeUniforms?: boolean;
  12877. removeVaryings?: boolean;
  12878. removeIfDef?: boolean;
  12879. replaceStrings?: {
  12880. search: RegExp;
  12881. replace: string;
  12882. }[];
  12883. }, storeKey?: string): void;
  12884. /** @hidden */
  12885. _registerTempVariable(name: string): boolean;
  12886. /** @hidden */
  12887. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  12888. /** @hidden */
  12889. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  12890. /** @hidden */
  12891. _emitFloat(value: number): string;
  12892. }
  12893. }
  12894. declare module BABYLON {
  12895. /**
  12896. * Helper class used to generate session unique ID
  12897. */
  12898. export class UniqueIdGenerator {
  12899. private static _UniqueIdCounter;
  12900. /**
  12901. * Gets an unique (relatively to the current scene) Id
  12902. */
  12903. static get UniqueId(): number;
  12904. }
  12905. }
  12906. declare module BABYLON {
  12907. /**
  12908. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12909. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12910. */
  12911. export class EffectFallbacks implements IEffectFallbacks {
  12912. private _defines;
  12913. private _currentRank;
  12914. private _maxRank;
  12915. private _mesh;
  12916. /**
  12917. * Removes the fallback from the bound mesh.
  12918. */
  12919. unBindMesh(): void;
  12920. /**
  12921. * Adds a fallback on the specified property.
  12922. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12923. * @param define The name of the define in the shader
  12924. */
  12925. addFallback(rank: number, define: string): void;
  12926. /**
  12927. * Sets the mesh to use CPU skinning when needing to fallback.
  12928. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12929. * @param mesh The mesh to use the fallbacks.
  12930. */
  12931. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12932. /**
  12933. * Checks to see if more fallbacks are still availible.
  12934. */
  12935. get hasMoreFallbacks(): boolean;
  12936. /**
  12937. * Removes the defines that should be removed when falling back.
  12938. * @param currentDefines defines the current define statements for the shader.
  12939. * @param effect defines the current effect we try to compile
  12940. * @returns The resulting defines with defines of the current rank removed.
  12941. */
  12942. reduce(currentDefines: string, effect: Effect): string;
  12943. }
  12944. }
  12945. declare module BABYLON {
  12946. /**
  12947. * Defines a block that can be used inside a node based material
  12948. */
  12949. export class NodeMaterialBlock {
  12950. private _buildId;
  12951. private _buildTarget;
  12952. private _target;
  12953. private _isFinalMerger;
  12954. private _isInput;
  12955. private _name;
  12956. protected _isUnique: boolean;
  12957. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  12958. inputsAreExclusive: boolean;
  12959. /** @hidden */
  12960. _codeVariableName: string;
  12961. /** @hidden */
  12962. _inputs: NodeMaterialConnectionPoint[];
  12963. /** @hidden */
  12964. _outputs: NodeMaterialConnectionPoint[];
  12965. /** @hidden */
  12966. _preparationId: number;
  12967. /**
  12968. * Gets the name of the block
  12969. */
  12970. get name(): string;
  12971. /**
  12972. * Sets the name of the block. Will check if the name is valid.
  12973. */
  12974. set name(newName: string);
  12975. /**
  12976. * Gets or sets the unique id of the node
  12977. */
  12978. uniqueId: number;
  12979. /**
  12980. * Gets or sets the comments associated with this block
  12981. */
  12982. comments: string;
  12983. /**
  12984. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  12985. */
  12986. get isUnique(): boolean;
  12987. /**
  12988. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  12989. */
  12990. get isFinalMerger(): boolean;
  12991. /**
  12992. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  12993. */
  12994. get isInput(): boolean;
  12995. /**
  12996. * Gets or sets the build Id
  12997. */
  12998. get buildId(): number;
  12999. set buildId(value: number);
  13000. /**
  13001. * Gets or sets the target of the block
  13002. */
  13003. get target(): NodeMaterialBlockTargets;
  13004. set target(value: NodeMaterialBlockTargets);
  13005. /**
  13006. * Gets the list of input points
  13007. */
  13008. get inputs(): NodeMaterialConnectionPoint[];
  13009. /** Gets the list of output points */
  13010. get outputs(): NodeMaterialConnectionPoint[];
  13011. /**
  13012. * Find an input by its name
  13013. * @param name defines the name of the input to look for
  13014. * @returns the input or null if not found
  13015. */
  13016. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13017. /**
  13018. * Find an output by its name
  13019. * @param name defines the name of the outputto look for
  13020. * @returns the output or null if not found
  13021. */
  13022. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13023. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13024. visibleInInspector: boolean;
  13025. /**
  13026. * Creates a new NodeMaterialBlock
  13027. * @param name defines the block name
  13028. * @param target defines the target of that block (Vertex by default)
  13029. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13030. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13031. */
  13032. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13033. /**
  13034. * Initialize the block and prepare the context for build
  13035. * @param state defines the state that will be used for the build
  13036. */
  13037. initialize(state: NodeMaterialBuildState): void;
  13038. /**
  13039. * Bind data to effect. Will only be called for blocks with isBindable === true
  13040. * @param effect defines the effect to bind data to
  13041. * @param nodeMaterial defines the hosting NodeMaterial
  13042. * @param mesh defines the mesh that will be rendered
  13043. * @param subMesh defines the submesh that will be rendered
  13044. */
  13045. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13046. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13047. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13048. protected _writeFloat(value: number): string;
  13049. /**
  13050. * Gets the current class name e.g. "NodeMaterialBlock"
  13051. * @returns the class name
  13052. */
  13053. getClassName(): string;
  13054. /**
  13055. * Register a new input. Must be called inside a block constructor
  13056. * @param name defines the connection point name
  13057. * @param type defines the connection point type
  13058. * @param isOptional defines a boolean indicating that this input can be omitted
  13059. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13060. * @param point an already created connection point. If not provided, create a new one
  13061. * @returns the current block
  13062. */
  13063. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13064. /**
  13065. * Register a new output. Must be called inside a block constructor
  13066. * @param name defines the connection point name
  13067. * @param type defines the connection point type
  13068. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13069. * @param point an already created connection point. If not provided, create a new one
  13070. * @returns the current block
  13071. */
  13072. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13073. /**
  13074. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13075. * @param forOutput defines an optional connection point to check compatibility with
  13076. * @returns the first available input or null
  13077. */
  13078. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13079. /**
  13080. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13081. * @param forBlock defines an optional block to check compatibility with
  13082. * @returns the first available input or null
  13083. */
  13084. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13085. /**
  13086. * Gets the sibling of the given output
  13087. * @param current defines the current output
  13088. * @returns the next output in the list or null
  13089. */
  13090. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13091. /**
  13092. * Connect current block with another block
  13093. * @param other defines the block to connect with
  13094. * @param options define the various options to help pick the right connections
  13095. * @returns the current block
  13096. */
  13097. connectTo(other: NodeMaterialBlock, options?: {
  13098. input?: string;
  13099. output?: string;
  13100. outputSwizzle?: string;
  13101. }): this | undefined;
  13102. protected _buildBlock(state: NodeMaterialBuildState): void;
  13103. /**
  13104. * Add uniforms, samplers and uniform buffers at compilation time
  13105. * @param state defines the state to update
  13106. * @param nodeMaterial defines the node material requesting the update
  13107. * @param defines defines the material defines to update
  13108. * @param uniformBuffers defines the list of uniform buffer names
  13109. */
  13110. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13111. /**
  13112. * Add potential fallbacks if shader compilation fails
  13113. * @param mesh defines the mesh to be rendered
  13114. * @param fallbacks defines the current prioritized list of fallbacks
  13115. */
  13116. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13117. /**
  13118. * Initialize defines for shader compilation
  13119. * @param mesh defines the mesh to be rendered
  13120. * @param nodeMaterial defines the node material requesting the update
  13121. * @param defines defines the material defines to update
  13122. * @param useInstances specifies that instances should be used
  13123. */
  13124. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13125. /**
  13126. * Update defines for shader compilation
  13127. * @param mesh defines the mesh to be rendered
  13128. * @param nodeMaterial defines the node material requesting the update
  13129. * @param defines defines the material defines to update
  13130. * @param useInstances specifies that instances should be used
  13131. * @param subMesh defines which submesh to render
  13132. */
  13133. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13134. /**
  13135. * Lets the block try to connect some inputs automatically
  13136. * @param material defines the hosting NodeMaterial
  13137. */
  13138. autoConfigure(material: NodeMaterial): void;
  13139. /**
  13140. * Function called when a block is declared as repeatable content generator
  13141. * @param vertexShaderState defines the current compilation state for the vertex shader
  13142. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13143. * @param mesh defines the mesh to be rendered
  13144. * @param defines defines the material defines to update
  13145. */
  13146. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13147. /**
  13148. * Checks if the block is ready
  13149. * @param mesh defines the mesh to be rendered
  13150. * @param nodeMaterial defines the node material requesting the update
  13151. * @param defines defines the material defines to update
  13152. * @param useInstances specifies that instances should be used
  13153. * @returns true if the block is ready
  13154. */
  13155. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13156. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13157. private _processBuild;
  13158. /**
  13159. * Validates the new name for the block node.
  13160. * @param newName the new name to be given to the node.
  13161. * @returns false if the name is a reserve word, else true.
  13162. */
  13163. validateBlockName(newName: string): boolean;
  13164. /**
  13165. * Compile the current node and generate the shader code
  13166. * @param state defines the current compilation state (uniforms, samplers, current string)
  13167. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13168. * @returns true if already built
  13169. */
  13170. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13171. protected _inputRename(name: string): string;
  13172. protected _outputRename(name: string): string;
  13173. protected _dumpPropertiesCode(): string;
  13174. /** @hidden */
  13175. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13176. /** @hidden */
  13177. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13178. /**
  13179. * Clone the current block to a new identical block
  13180. * @param scene defines the hosting scene
  13181. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13182. * @returns a copy of the current block
  13183. */
  13184. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13185. /**
  13186. * Serializes this block in a JSON representation
  13187. * @returns the serialized block object
  13188. */
  13189. serialize(): any;
  13190. /** @hidden */
  13191. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13192. private _deserializePortDisplayNamesAndExposedOnFrame;
  13193. /**
  13194. * Release resources
  13195. */
  13196. dispose(): void;
  13197. }
  13198. }
  13199. declare module BABYLON {
  13200. /**
  13201. * Base class of materials working in push mode in babylon JS
  13202. * @hidden
  13203. */
  13204. export class PushMaterial extends Material {
  13205. protected _activeEffect: Effect;
  13206. protected _normalMatrix: Matrix;
  13207. constructor(name: string, scene: Scene);
  13208. getEffect(): Effect;
  13209. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13210. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13211. /**
  13212. * Binds the given world matrix to the active effect
  13213. *
  13214. * @param world the matrix to bind
  13215. */
  13216. bindOnlyWorldMatrix(world: Matrix): void;
  13217. /**
  13218. * Binds the given normal matrix to the active effect
  13219. *
  13220. * @param normalMatrix the matrix to bind
  13221. */
  13222. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13223. bind(world: Matrix, mesh?: Mesh): void;
  13224. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13225. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13226. }
  13227. }
  13228. declare module BABYLON {
  13229. /**
  13230. * Root class for all node material optimizers
  13231. */
  13232. export class NodeMaterialOptimizer {
  13233. /**
  13234. * Function used to optimize a NodeMaterial graph
  13235. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13236. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13237. */
  13238. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13239. }
  13240. }
  13241. declare module BABYLON {
  13242. /**
  13243. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13244. */
  13245. export class TransformBlock extends NodeMaterialBlock {
  13246. /**
  13247. * Defines the value to use to complement W value to transform it to a Vector4
  13248. */
  13249. complementW: number;
  13250. /**
  13251. * Defines the value to use to complement z value to transform it to a Vector4
  13252. */
  13253. complementZ: number;
  13254. /**
  13255. * Creates a new TransformBlock
  13256. * @param name defines the block name
  13257. */
  13258. constructor(name: string);
  13259. /**
  13260. * Gets the current class name
  13261. * @returns the class name
  13262. */
  13263. getClassName(): string;
  13264. /**
  13265. * Gets the vector input
  13266. */
  13267. get vector(): NodeMaterialConnectionPoint;
  13268. /**
  13269. * Gets the output component
  13270. */
  13271. get output(): NodeMaterialConnectionPoint;
  13272. /**
  13273. * Gets the xyz output component
  13274. */
  13275. get xyz(): NodeMaterialConnectionPoint;
  13276. /**
  13277. * Gets the matrix transform input
  13278. */
  13279. get transform(): NodeMaterialConnectionPoint;
  13280. protected _buildBlock(state: NodeMaterialBuildState): this;
  13281. /**
  13282. * Update defines for shader compilation
  13283. * @param mesh defines the mesh to be rendered
  13284. * @param nodeMaterial defines the node material requesting the update
  13285. * @param defines defines the material defines to update
  13286. * @param useInstances specifies that instances should be used
  13287. * @param subMesh defines which submesh to render
  13288. */
  13289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13290. serialize(): any;
  13291. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13292. protected _dumpPropertiesCode(): string;
  13293. }
  13294. }
  13295. declare module BABYLON {
  13296. /**
  13297. * Block used to output the vertex position
  13298. */
  13299. export class VertexOutputBlock extends NodeMaterialBlock {
  13300. /**
  13301. * Creates a new VertexOutputBlock
  13302. * @param name defines the block name
  13303. */
  13304. constructor(name: string);
  13305. /**
  13306. * Gets the current class name
  13307. * @returns the class name
  13308. */
  13309. getClassName(): string;
  13310. /**
  13311. * Gets the vector input component
  13312. */
  13313. get vector(): NodeMaterialConnectionPoint;
  13314. protected _buildBlock(state: NodeMaterialBuildState): this;
  13315. }
  13316. }
  13317. declare module BABYLON {
  13318. /**
  13319. * Block used to output the final color
  13320. */
  13321. export class FragmentOutputBlock extends NodeMaterialBlock {
  13322. /**
  13323. * Create a new FragmentOutputBlock
  13324. * @param name defines the block name
  13325. */
  13326. constructor(name: string);
  13327. /**
  13328. * Gets the current class name
  13329. * @returns the class name
  13330. */
  13331. getClassName(): string;
  13332. /**
  13333. * Gets the rgba input component
  13334. */
  13335. get rgba(): NodeMaterialConnectionPoint;
  13336. /**
  13337. * Gets the rgb input component
  13338. */
  13339. get rgb(): NodeMaterialConnectionPoint;
  13340. /**
  13341. * Gets the a input component
  13342. */
  13343. get a(): NodeMaterialConnectionPoint;
  13344. protected _buildBlock(state: NodeMaterialBuildState): this;
  13345. }
  13346. }
  13347. declare module BABYLON {
  13348. /**
  13349. * Block used for the particle ramp gradient section
  13350. */
  13351. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13352. /**
  13353. * Create a new ParticleRampGradientBlock
  13354. * @param name defines the block name
  13355. */
  13356. constructor(name: string);
  13357. /**
  13358. * Gets the current class name
  13359. * @returns the class name
  13360. */
  13361. getClassName(): string;
  13362. /**
  13363. * Gets the color input component
  13364. */
  13365. get color(): NodeMaterialConnectionPoint;
  13366. /**
  13367. * Gets the rampColor output component
  13368. */
  13369. get rampColor(): NodeMaterialConnectionPoint;
  13370. /**
  13371. * Initialize the block and prepare the context for build
  13372. * @param state defines the state that will be used for the build
  13373. */
  13374. initialize(state: NodeMaterialBuildState): void;
  13375. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13376. }
  13377. }
  13378. declare module BABYLON {
  13379. /**
  13380. * Block used for the particle blend multiply section
  13381. */
  13382. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13383. /**
  13384. * Create a new ParticleBlendMultiplyBlock
  13385. * @param name defines the block name
  13386. */
  13387. constructor(name: string);
  13388. /**
  13389. * Gets the current class name
  13390. * @returns the class name
  13391. */
  13392. getClassName(): string;
  13393. /**
  13394. * Gets the color input component
  13395. */
  13396. get color(): NodeMaterialConnectionPoint;
  13397. /**
  13398. * Gets the alphaTexture input component
  13399. */
  13400. get alphaTexture(): NodeMaterialConnectionPoint;
  13401. /**
  13402. * Gets the alphaColor input component
  13403. */
  13404. get alphaColor(): NodeMaterialConnectionPoint;
  13405. /**
  13406. * Gets the blendColor output component
  13407. */
  13408. get blendColor(): NodeMaterialConnectionPoint;
  13409. /**
  13410. * Initialize the block and prepare the context for build
  13411. * @param state defines the state that will be used for the build
  13412. */
  13413. initialize(state: NodeMaterialBuildState): void;
  13414. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13415. }
  13416. }
  13417. declare module BABYLON {
  13418. /**
  13419. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13420. */
  13421. export class VectorMergerBlock extends NodeMaterialBlock {
  13422. /**
  13423. * Create a new VectorMergerBlock
  13424. * @param name defines the block name
  13425. */
  13426. constructor(name: string);
  13427. /**
  13428. * Gets the current class name
  13429. * @returns the class name
  13430. */
  13431. getClassName(): string;
  13432. /**
  13433. * Gets the xyz component (input)
  13434. */
  13435. get xyzIn(): NodeMaterialConnectionPoint;
  13436. /**
  13437. * Gets the xy component (input)
  13438. */
  13439. get xyIn(): NodeMaterialConnectionPoint;
  13440. /**
  13441. * Gets the x component (input)
  13442. */
  13443. get x(): NodeMaterialConnectionPoint;
  13444. /**
  13445. * Gets the y component (input)
  13446. */
  13447. get y(): NodeMaterialConnectionPoint;
  13448. /**
  13449. * Gets the z component (input)
  13450. */
  13451. get z(): NodeMaterialConnectionPoint;
  13452. /**
  13453. * Gets the w component (input)
  13454. */
  13455. get w(): NodeMaterialConnectionPoint;
  13456. /**
  13457. * Gets the xyzw component (output)
  13458. */
  13459. get xyzw(): NodeMaterialConnectionPoint;
  13460. /**
  13461. * Gets the xyz component (output)
  13462. */
  13463. get xyzOut(): NodeMaterialConnectionPoint;
  13464. /**
  13465. * Gets the xy component (output)
  13466. */
  13467. get xyOut(): NodeMaterialConnectionPoint;
  13468. /**
  13469. * Gets the xy component (output)
  13470. * @deprecated Please use xyOut instead.
  13471. */
  13472. get xy(): NodeMaterialConnectionPoint;
  13473. /**
  13474. * Gets the xyz component (output)
  13475. * @deprecated Please use xyzOut instead.
  13476. */
  13477. get xyz(): NodeMaterialConnectionPoint;
  13478. protected _buildBlock(state: NodeMaterialBuildState): this;
  13479. }
  13480. }
  13481. declare module BABYLON {
  13482. /**
  13483. * Block used to remap a float from a range to a new one
  13484. */
  13485. export class RemapBlock extends NodeMaterialBlock {
  13486. /**
  13487. * Gets or sets the source range
  13488. */
  13489. sourceRange: Vector2;
  13490. /**
  13491. * Gets or sets the target range
  13492. */
  13493. targetRange: Vector2;
  13494. /**
  13495. * Creates a new RemapBlock
  13496. * @param name defines the block name
  13497. */
  13498. constructor(name: string);
  13499. /**
  13500. * Gets the current class name
  13501. * @returns the class name
  13502. */
  13503. getClassName(): string;
  13504. /**
  13505. * Gets the input component
  13506. */
  13507. get input(): NodeMaterialConnectionPoint;
  13508. /**
  13509. * Gets the source min input component
  13510. */
  13511. get sourceMin(): NodeMaterialConnectionPoint;
  13512. /**
  13513. * Gets the source max input component
  13514. */
  13515. get sourceMax(): NodeMaterialConnectionPoint;
  13516. /**
  13517. * Gets the target min input component
  13518. */
  13519. get targetMin(): NodeMaterialConnectionPoint;
  13520. /**
  13521. * Gets the target max input component
  13522. */
  13523. get targetMax(): NodeMaterialConnectionPoint;
  13524. /**
  13525. * Gets the output component
  13526. */
  13527. get output(): NodeMaterialConnectionPoint;
  13528. protected _buildBlock(state: NodeMaterialBuildState): this;
  13529. protected _dumpPropertiesCode(): string;
  13530. serialize(): any;
  13531. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13532. }
  13533. }
  13534. declare module BABYLON {
  13535. /**
  13536. * Block used to multiply 2 values
  13537. */
  13538. export class MultiplyBlock extends NodeMaterialBlock {
  13539. /**
  13540. * Creates a new MultiplyBlock
  13541. * @param name defines the block name
  13542. */
  13543. constructor(name: string);
  13544. /**
  13545. * Gets the current class name
  13546. * @returns the class name
  13547. */
  13548. getClassName(): string;
  13549. /**
  13550. * Gets the left operand input component
  13551. */
  13552. get left(): NodeMaterialConnectionPoint;
  13553. /**
  13554. * Gets the right operand input component
  13555. */
  13556. get right(): NodeMaterialConnectionPoint;
  13557. /**
  13558. * Gets the output component
  13559. */
  13560. get output(): NodeMaterialConnectionPoint;
  13561. protected _buildBlock(state: NodeMaterialBuildState): this;
  13562. }
  13563. }
  13564. declare module BABYLON {
  13565. /** Interface used by value gradients (color, factor, ...) */
  13566. export interface IValueGradient {
  13567. /**
  13568. * Gets or sets the gradient value (between 0 and 1)
  13569. */
  13570. gradient: number;
  13571. }
  13572. /** Class used to store color4 gradient */
  13573. export class ColorGradient implements IValueGradient {
  13574. /**
  13575. * Gets or sets the gradient value (between 0 and 1)
  13576. */
  13577. gradient: number;
  13578. /**
  13579. * Gets or sets first associated color
  13580. */
  13581. color1: Color4;
  13582. /**
  13583. * Gets or sets second associated color
  13584. */
  13585. color2?: Color4 | undefined;
  13586. /**
  13587. * Creates a new color4 gradient
  13588. * @param gradient gets or sets the gradient value (between 0 and 1)
  13589. * @param color1 gets or sets first associated color
  13590. * @param color2 gets or sets first second color
  13591. */
  13592. constructor(
  13593. /**
  13594. * Gets or sets the gradient value (between 0 and 1)
  13595. */
  13596. gradient: number,
  13597. /**
  13598. * Gets or sets first associated color
  13599. */
  13600. color1: Color4,
  13601. /**
  13602. * Gets or sets second associated color
  13603. */
  13604. color2?: Color4 | undefined);
  13605. /**
  13606. * Will get a color picked randomly between color1 and color2.
  13607. * If color2 is undefined then color1 will be used
  13608. * @param result defines the target Color4 to store the result in
  13609. */
  13610. getColorToRef(result: Color4): void;
  13611. }
  13612. /** Class used to store color 3 gradient */
  13613. export class Color3Gradient implements IValueGradient {
  13614. /**
  13615. * Gets or sets the gradient value (between 0 and 1)
  13616. */
  13617. gradient: number;
  13618. /**
  13619. * Gets or sets the associated color
  13620. */
  13621. color: Color3;
  13622. /**
  13623. * Creates a new color3 gradient
  13624. * @param gradient gets or sets the gradient value (between 0 and 1)
  13625. * @param color gets or sets associated color
  13626. */
  13627. constructor(
  13628. /**
  13629. * Gets or sets the gradient value (between 0 and 1)
  13630. */
  13631. gradient: number,
  13632. /**
  13633. * Gets or sets the associated color
  13634. */
  13635. color: Color3);
  13636. }
  13637. /** Class used to store factor gradient */
  13638. export class FactorGradient implements IValueGradient {
  13639. /**
  13640. * Gets or sets the gradient value (between 0 and 1)
  13641. */
  13642. gradient: number;
  13643. /**
  13644. * Gets or sets first associated factor
  13645. */
  13646. factor1: number;
  13647. /**
  13648. * Gets or sets second associated factor
  13649. */
  13650. factor2?: number | undefined;
  13651. /**
  13652. * Creates a new factor gradient
  13653. * @param gradient gets or sets the gradient value (between 0 and 1)
  13654. * @param factor1 gets or sets first associated factor
  13655. * @param factor2 gets or sets second associated factor
  13656. */
  13657. constructor(
  13658. /**
  13659. * Gets or sets the gradient value (between 0 and 1)
  13660. */
  13661. gradient: number,
  13662. /**
  13663. * Gets or sets first associated factor
  13664. */
  13665. factor1: number,
  13666. /**
  13667. * Gets or sets second associated factor
  13668. */
  13669. factor2?: number | undefined);
  13670. /**
  13671. * Will get a number picked randomly between factor1 and factor2.
  13672. * If factor2 is undefined then factor1 will be used
  13673. * @returns the picked number
  13674. */
  13675. getFactor(): number;
  13676. }
  13677. /**
  13678. * Helper used to simplify some generic gradient tasks
  13679. */
  13680. export class GradientHelper {
  13681. /**
  13682. * Gets the current gradient from an array of IValueGradient
  13683. * @param ratio defines the current ratio to get
  13684. * @param gradients defines the array of IValueGradient
  13685. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  13686. */
  13687. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  13688. }
  13689. }
  13690. declare module BABYLON {
  13691. interface ThinEngine {
  13692. /**
  13693. * Creates a raw texture
  13694. * @param data defines the data to store in the texture
  13695. * @param width defines the width of the texture
  13696. * @param height defines the height of the texture
  13697. * @param format defines the format of the data
  13698. * @param generateMipMaps defines if the engine should generate the mip levels
  13699. * @param invertY defines if data must be stored with Y axis inverted
  13700. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  13701. * @param compression defines the compression used (null by default)
  13702. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13703. * @returns the raw texture inside an InternalTexture
  13704. */
  13705. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  13706. /**
  13707. * Update a raw texture
  13708. * @param texture defines the texture to update
  13709. * @param data defines the data to store in the texture
  13710. * @param format defines the format of the data
  13711. * @param invertY defines if data must be stored with Y axis inverted
  13712. */
  13713. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13714. /**
  13715. * Update a raw texture
  13716. * @param texture defines the texture to update
  13717. * @param data defines the data to store in the texture
  13718. * @param format defines the format of the data
  13719. * @param invertY defines if data must be stored with Y axis inverted
  13720. * @param compression defines the compression used (null by default)
  13721. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13722. */
  13723. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  13724. /**
  13725. * Creates a new raw cube texture
  13726. * @param data defines the array of data to use to create each face
  13727. * @param size defines the size of the textures
  13728. * @param format defines the format of the data
  13729. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13730. * @param generateMipMaps defines if the engine should generate the mip levels
  13731. * @param invertY defines if data must be stored with Y axis inverted
  13732. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13733. * @param compression defines the compression used (null by default)
  13734. * @returns the cube texture as an InternalTexture
  13735. */
  13736. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  13737. /**
  13738. * Update a raw cube texture
  13739. * @param texture defines the texture to udpdate
  13740. * @param data defines the data to store
  13741. * @param format defines the data format
  13742. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13743. * @param invertY defines if data must be stored with Y axis inverted
  13744. */
  13745. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  13746. /**
  13747. * Update a raw cube texture
  13748. * @param texture defines the texture to udpdate
  13749. * @param data defines the data to store
  13750. * @param format defines the data format
  13751. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13752. * @param invertY defines if data must be stored with Y axis inverted
  13753. * @param compression defines the compression used (null by default)
  13754. */
  13755. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  13756. /**
  13757. * Update a raw cube texture
  13758. * @param texture defines the texture to udpdate
  13759. * @param data defines the data to store
  13760. * @param format defines the data format
  13761. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13762. * @param invertY defines if data must be stored with Y axis inverted
  13763. * @param compression defines the compression used (null by default)
  13764. * @param level defines which level of the texture to update
  13765. */
  13766. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  13767. /**
  13768. * Creates a new raw cube texture from a specified url
  13769. * @param url defines the url where the data is located
  13770. * @param scene defines the current scene
  13771. * @param size defines the size of the textures
  13772. * @param format defines the format of the data
  13773. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13774. * @param noMipmap defines if the engine should avoid generating the mip levels
  13775. * @param callback defines a callback used to extract texture data from loaded data
  13776. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13777. * @param onLoad defines a callback called when texture is loaded
  13778. * @param onError defines a callback called if there is an error
  13779. * @returns the cube texture as an InternalTexture
  13780. */
  13781. 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;
  13782. /**
  13783. * Creates a new raw cube texture from a specified url
  13784. * @param url defines the url where the data is located
  13785. * @param scene defines the current scene
  13786. * @param size defines the size of the textures
  13787. * @param format defines the format of the data
  13788. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13789. * @param noMipmap defines if the engine should avoid generating the mip levels
  13790. * @param callback defines a callback used to extract texture data from loaded data
  13791. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13792. * @param onLoad defines a callback called when texture is loaded
  13793. * @param onError defines a callback called if there is an error
  13794. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13795. * @param invertY defines if data must be stored with Y axis inverted
  13796. * @returns the cube texture as an InternalTexture
  13797. */
  13798. 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;
  13799. /**
  13800. * Creates a new raw 3D texture
  13801. * @param data defines the data used to create the texture
  13802. * @param width defines the width of the texture
  13803. * @param height defines the height of the texture
  13804. * @param depth defines the depth of the texture
  13805. * @param format defines the format of the texture
  13806. * @param generateMipMaps defines if the engine must generate mip levels
  13807. * @param invertY defines if data must be stored with Y axis inverted
  13808. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13809. * @param compression defines the compressed used (can be null)
  13810. * @param textureType defines the compressed used (can be null)
  13811. * @returns a new raw 3D texture (stored in an InternalTexture)
  13812. */
  13813. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13814. /**
  13815. * Update a raw 3D texture
  13816. * @param texture defines the texture to update
  13817. * @param data defines the data to store
  13818. * @param format defines the data format
  13819. * @param invertY defines if data must be stored with Y axis inverted
  13820. */
  13821. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13822. /**
  13823. * Update a raw 3D texture
  13824. * @param texture defines the texture to update
  13825. * @param data defines the data to store
  13826. * @param format defines the data format
  13827. * @param invertY defines if data must be stored with Y axis inverted
  13828. * @param compression defines the used compression (can be null)
  13829. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13830. */
  13831. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13832. /**
  13833. * Creates a new raw 2D array texture
  13834. * @param data defines the data used to create the texture
  13835. * @param width defines the width of the texture
  13836. * @param height defines the height of the texture
  13837. * @param depth defines the number of layers of the texture
  13838. * @param format defines the format of the texture
  13839. * @param generateMipMaps defines if the engine must generate mip levels
  13840. * @param invertY defines if data must be stored with Y axis inverted
  13841. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13842. * @param compression defines the compressed used (can be null)
  13843. * @param textureType defines the compressed used (can be null)
  13844. * @returns a new raw 2D array texture (stored in an InternalTexture)
  13845. */
  13846. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13847. /**
  13848. * Update a raw 2D array texture
  13849. * @param texture defines the texture to update
  13850. * @param data defines the data to store
  13851. * @param format defines the data format
  13852. * @param invertY defines if data must be stored with Y axis inverted
  13853. */
  13854. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13855. /**
  13856. * Update a raw 2D array texture
  13857. * @param texture defines the texture to update
  13858. * @param data defines the data to store
  13859. * @param format defines the data format
  13860. * @param invertY defines if data must be stored with Y axis inverted
  13861. * @param compression defines the used compression (can be null)
  13862. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13863. */
  13864. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13865. }
  13866. }
  13867. declare module BABYLON {
  13868. /**
  13869. * Raw texture can help creating a texture directly from an array of data.
  13870. * This can be super useful if you either get the data from an uncompressed source or
  13871. * if you wish to create your texture pixel by pixel.
  13872. */
  13873. export class RawTexture extends Texture {
  13874. /**
  13875. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13876. */
  13877. format: number;
  13878. /**
  13879. * Instantiates a new RawTexture.
  13880. * Raw texture can help creating a texture directly from an array of data.
  13881. * This can be super useful if you either get the data from an uncompressed source or
  13882. * if you wish to create your texture pixel by pixel.
  13883. * @param data define the array of data to use to create the texture
  13884. * @param width define the width of the texture
  13885. * @param height define the height of the texture
  13886. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13887. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13888. * @param generateMipMaps define whether mip maps should be generated or not
  13889. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13890. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13891. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13892. */
  13893. constructor(data: ArrayBufferView, width: number, height: number,
  13894. /**
  13895. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13896. */
  13897. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13898. /**
  13899. * Updates the texture underlying data.
  13900. * @param data Define the new data of the texture
  13901. */
  13902. update(data: ArrayBufferView): void;
  13903. /**
  13904. * Creates a luminance texture from some data.
  13905. * @param data Define the texture data
  13906. * @param width Define the width of the texture
  13907. * @param height Define the height of the texture
  13908. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13909. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13910. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13911. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13912. * @returns the luminance texture
  13913. */
  13914. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13915. /**
  13916. * Creates a luminance alpha texture from some data.
  13917. * @param data Define the texture data
  13918. * @param width Define the width of the texture
  13919. * @param height Define the height of the texture
  13920. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13921. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13922. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13923. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13924. * @returns the luminance alpha texture
  13925. */
  13926. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13927. /**
  13928. * Creates an alpha texture from some data.
  13929. * @param data Define the texture data
  13930. * @param width Define the width of the texture
  13931. * @param height Define the height of the texture
  13932. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13933. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13934. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13935. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13936. * @returns the alpha texture
  13937. */
  13938. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13939. /**
  13940. * Creates a RGB texture from some data.
  13941. * @param data Define the texture data
  13942. * @param width Define the width of the texture
  13943. * @param height Define the height of the texture
  13944. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13945. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13946. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13947. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13948. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13949. * @returns the RGB alpha texture
  13950. */
  13951. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13952. /**
  13953. * Creates a RGBA texture from some data.
  13954. * @param data Define the texture data
  13955. * @param width Define the width of the texture
  13956. * @param height Define the height of the texture
  13957. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13958. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13961. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13962. * @returns the RGBA texture
  13963. */
  13964. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13965. /**
  13966. * Creates a R texture from some data.
  13967. * @param data Define the texture data
  13968. * @param width Define the width of the texture
  13969. * @param height Define the height of the texture
  13970. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13974. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13975. * @returns the R texture
  13976. */
  13977. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13978. }
  13979. }
  13980. declare module BABYLON {
  13981. interface ThinEngine {
  13982. /**
  13983. * Update a dynamic index buffer
  13984. * @param indexBuffer defines the target index buffer
  13985. * @param indices defines the data to update
  13986. * @param offset defines the offset in the target index buffer where update should start
  13987. */
  13988. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  13989. /**
  13990. * Updates a dynamic vertex buffer.
  13991. * @param vertexBuffer the vertex buffer to update
  13992. * @param data the data used to update the vertex buffer
  13993. * @param byteOffset the byte offset of the data
  13994. * @param byteLength the byte length of the data
  13995. */
  13996. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  13997. }
  13998. }
  13999. declare module BABYLON {
  14000. interface AbstractScene {
  14001. /**
  14002. * The list of procedural textures added to the scene
  14003. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14004. */
  14005. proceduralTextures: Array<ProceduralTexture>;
  14006. }
  14007. /**
  14008. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14009. * in a given scene.
  14010. */
  14011. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14012. /**
  14013. * The component name helpfull to identify the component in the list of scene components.
  14014. */
  14015. readonly name: string;
  14016. /**
  14017. * The scene the component belongs to.
  14018. */
  14019. scene: Scene;
  14020. /**
  14021. * Creates a new instance of the component for the given scene
  14022. * @param scene Defines the scene to register the component in
  14023. */
  14024. constructor(scene: Scene);
  14025. /**
  14026. * Registers the component in a given scene
  14027. */
  14028. register(): void;
  14029. /**
  14030. * Rebuilds the elements related to this component in case of
  14031. * context lost for instance.
  14032. */
  14033. rebuild(): void;
  14034. /**
  14035. * Disposes the component and the associated ressources.
  14036. */
  14037. dispose(): void;
  14038. private _beforeClear;
  14039. }
  14040. }
  14041. declare module BABYLON {
  14042. interface ThinEngine {
  14043. /**
  14044. * Creates a new render target cube texture
  14045. * @param size defines the size of the texture
  14046. * @param options defines the options used to create the texture
  14047. * @returns a new render target cube texture stored in an InternalTexture
  14048. */
  14049. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14050. }
  14051. }
  14052. declare module BABYLON {
  14053. /** @hidden */
  14054. export var proceduralVertexShader: {
  14055. name: string;
  14056. shader: string;
  14057. };
  14058. }
  14059. declare module BABYLON {
  14060. /**
  14061. * 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.
  14062. * This is the base class of any Procedural texture and contains most of the shareable code.
  14063. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14064. */
  14065. export class ProceduralTexture extends Texture {
  14066. /**
  14067. * Define if the texture is enabled or not (disabled texture will not render)
  14068. */
  14069. isEnabled: boolean;
  14070. /**
  14071. * Define if the texture must be cleared before rendering (default is true)
  14072. */
  14073. autoClear: boolean;
  14074. /**
  14075. * Callback called when the texture is generated
  14076. */
  14077. onGenerated: () => void;
  14078. /**
  14079. * Event raised when the texture is generated
  14080. */
  14081. onGeneratedObservable: Observable<ProceduralTexture>;
  14082. /**
  14083. * Event raised before the texture is generated
  14084. */
  14085. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14086. /**
  14087. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14088. */
  14089. nodeMaterialSource: Nullable<NodeMaterial>;
  14090. /** @hidden */
  14091. _generateMipMaps: boolean;
  14092. /** @hidden **/
  14093. _effect: Effect;
  14094. /** @hidden */
  14095. _textures: {
  14096. [key: string]: Texture;
  14097. };
  14098. /** @hidden */
  14099. protected _fallbackTexture: Nullable<Texture>;
  14100. private _size;
  14101. private _currentRefreshId;
  14102. private _frameId;
  14103. private _refreshRate;
  14104. private _vertexBuffers;
  14105. private _indexBuffer;
  14106. private _uniforms;
  14107. private _samplers;
  14108. private _fragment;
  14109. private _floats;
  14110. private _ints;
  14111. private _floatsArrays;
  14112. private _colors3;
  14113. private _colors4;
  14114. private _vectors2;
  14115. private _vectors3;
  14116. private _matrices;
  14117. private _fallbackTextureUsed;
  14118. private _fullEngine;
  14119. private _cachedDefines;
  14120. private _contentUpdateId;
  14121. private _contentData;
  14122. /**
  14123. * Instantiates a new procedural texture.
  14124. * 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.
  14125. * This is the base class of any Procedural texture and contains most of the shareable code.
  14126. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14127. * @param name Define the name of the texture
  14128. * @param size Define the size of the texture to create
  14129. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14130. * @param scene Define the scene the texture belongs to
  14131. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14132. * @param generateMipMaps Define if the texture should creates mip maps or not
  14133. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14134. * @param textureType The FBO internal texture type
  14135. */
  14136. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14137. /**
  14138. * The effect that is created when initializing the post process.
  14139. * @returns The created effect corresponding the the postprocess.
  14140. */
  14141. getEffect(): Effect;
  14142. /**
  14143. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14144. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14145. */
  14146. getContent(): Nullable<ArrayBufferView>;
  14147. private _createIndexBuffer;
  14148. /** @hidden */
  14149. _rebuild(): void;
  14150. /**
  14151. * Resets the texture in order to recreate its associated resources.
  14152. * This can be called in case of context loss
  14153. */
  14154. reset(): void;
  14155. protected _getDefines(): string;
  14156. /**
  14157. * Is the texture ready to be used ? (rendered at least once)
  14158. * @returns true if ready, otherwise, false.
  14159. */
  14160. isReady(): boolean;
  14161. /**
  14162. * Resets the refresh counter of the texture and start bak from scratch.
  14163. * Could be useful to regenerate the texture if it is setup to render only once.
  14164. */
  14165. resetRefreshCounter(): void;
  14166. /**
  14167. * Set the fragment shader to use in order to render the texture.
  14168. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14169. */
  14170. setFragment(fragment: any): void;
  14171. /**
  14172. * Define the refresh rate of the texture or the rendering frequency.
  14173. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14174. */
  14175. get refreshRate(): number;
  14176. set refreshRate(value: number);
  14177. /** @hidden */
  14178. _shouldRender(): boolean;
  14179. /**
  14180. * Get the size the texture is rendering at.
  14181. * @returns the size (on cube texture it is always squared)
  14182. */
  14183. getRenderSize(): RenderTargetTextureSize;
  14184. /**
  14185. * Resize the texture to new value.
  14186. * @param size Define the new size the texture should have
  14187. * @param generateMipMaps Define whether the new texture should create mip maps
  14188. */
  14189. resize(size: number, generateMipMaps: boolean): void;
  14190. private _checkUniform;
  14191. /**
  14192. * Set a texture in the shader program used to render.
  14193. * @param name Define the name of the uniform samplers as defined in the shader
  14194. * @param texture Define the texture to bind to this sampler
  14195. * @return the texture itself allowing "fluent" like uniform updates
  14196. */
  14197. setTexture(name: string, texture: Texture): ProceduralTexture;
  14198. /**
  14199. * Set a float in the shader.
  14200. * @param name Define the name of the uniform as defined in the shader
  14201. * @param value Define the value to give to the uniform
  14202. * @return the texture itself allowing "fluent" like uniform updates
  14203. */
  14204. setFloat(name: string, value: number): ProceduralTexture;
  14205. /**
  14206. * Set a int in the shader.
  14207. * @param name Define the name of the uniform as defined in the shader
  14208. * @param value Define the value to give to the uniform
  14209. * @return the texture itself allowing "fluent" like uniform updates
  14210. */
  14211. setInt(name: string, value: number): ProceduralTexture;
  14212. /**
  14213. * Set an array of floats in the shader.
  14214. * @param name Define the name of the uniform as defined in the shader
  14215. * @param value Define the value to give to the uniform
  14216. * @return the texture itself allowing "fluent" like uniform updates
  14217. */
  14218. setFloats(name: string, value: number[]): ProceduralTexture;
  14219. /**
  14220. * Set a vec3 in the shader from a Color3.
  14221. * @param name Define the name of the uniform as defined in the shader
  14222. * @param value Define the value to give to the uniform
  14223. * @return the texture itself allowing "fluent" like uniform updates
  14224. */
  14225. setColor3(name: string, value: Color3): ProceduralTexture;
  14226. /**
  14227. * Set a vec4 in the shader from a Color4.
  14228. * @param name Define the name of the uniform as defined in the shader
  14229. * @param value Define the value to give to the uniform
  14230. * @return the texture itself allowing "fluent" like uniform updates
  14231. */
  14232. setColor4(name: string, value: Color4): ProceduralTexture;
  14233. /**
  14234. * Set a vec2 in the shader from a Vector2.
  14235. * @param name Define the name of the uniform as defined in the shader
  14236. * @param value Define the value to give to the uniform
  14237. * @return the texture itself allowing "fluent" like uniform updates
  14238. */
  14239. setVector2(name: string, value: Vector2): ProceduralTexture;
  14240. /**
  14241. * Set a vec3 in the shader from a Vector3.
  14242. * @param name Define the name of the uniform as defined in the shader
  14243. * @param value Define the value to give to the uniform
  14244. * @return the texture itself allowing "fluent" like uniform updates
  14245. */
  14246. setVector3(name: string, value: Vector3): ProceduralTexture;
  14247. /**
  14248. * Set a mat4 in the shader from a MAtrix.
  14249. * @param name Define the name of the uniform as defined in the shader
  14250. * @param value Define the value to give to the uniform
  14251. * @return the texture itself allowing "fluent" like uniform updates
  14252. */
  14253. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14254. /**
  14255. * Render the texture to its associated render target.
  14256. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14257. */
  14258. render(useCameraPostProcess?: boolean): void;
  14259. /**
  14260. * Clone the texture.
  14261. * @returns the cloned texture
  14262. */
  14263. clone(): ProceduralTexture;
  14264. /**
  14265. * Dispose the texture and release its asoociated resources.
  14266. */
  14267. dispose(): void;
  14268. }
  14269. }
  14270. declare module BABYLON {
  14271. /**
  14272. * This represents the base class for particle system in Babylon.
  14273. * 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.
  14274. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14275. * @example https://doc.babylonjs.com/babylon101/particles
  14276. */
  14277. export class BaseParticleSystem {
  14278. /**
  14279. * Source color is added to the destination color without alpha affecting the result
  14280. */
  14281. static BLENDMODE_ONEONE: number;
  14282. /**
  14283. * Blend current color and particle color using particle’s alpha
  14284. */
  14285. static BLENDMODE_STANDARD: number;
  14286. /**
  14287. * Add current color and particle color multiplied by particle’s alpha
  14288. */
  14289. static BLENDMODE_ADD: number;
  14290. /**
  14291. * Multiply current color with particle color
  14292. */
  14293. static BLENDMODE_MULTIPLY: number;
  14294. /**
  14295. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14296. */
  14297. static BLENDMODE_MULTIPLYADD: number;
  14298. /**
  14299. * List of animations used by the particle system.
  14300. */
  14301. animations: Animation[];
  14302. /**
  14303. * Gets or sets the unique id of the particle system
  14304. */
  14305. uniqueId: number;
  14306. /**
  14307. * The id of the Particle system.
  14308. */
  14309. id: string;
  14310. /**
  14311. * The friendly name of the Particle system.
  14312. */
  14313. name: string;
  14314. /**
  14315. * Snippet ID if the particle system was created from the snippet server
  14316. */
  14317. snippetId: string;
  14318. /**
  14319. * The rendering group used by the Particle system to chose when to render.
  14320. */
  14321. renderingGroupId: number;
  14322. /**
  14323. * The emitter represents the Mesh or position we are attaching the particle system to.
  14324. */
  14325. emitter: Nullable<AbstractMesh | Vector3>;
  14326. /**
  14327. * The maximum number of particles to emit per frame
  14328. */
  14329. emitRate: number;
  14330. /**
  14331. * If you want to launch only a few particles at once, that can be done, as well.
  14332. */
  14333. manualEmitCount: number;
  14334. /**
  14335. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14336. */
  14337. updateSpeed: number;
  14338. /**
  14339. * The amount of time the particle system is running (depends of the overall update speed).
  14340. */
  14341. targetStopDuration: number;
  14342. /**
  14343. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14344. */
  14345. disposeOnStop: boolean;
  14346. /**
  14347. * Minimum power of emitting particles.
  14348. */
  14349. minEmitPower: number;
  14350. /**
  14351. * Maximum power of emitting particles.
  14352. */
  14353. maxEmitPower: number;
  14354. /**
  14355. * Minimum life time of emitting particles.
  14356. */
  14357. minLifeTime: number;
  14358. /**
  14359. * Maximum life time of emitting particles.
  14360. */
  14361. maxLifeTime: number;
  14362. /**
  14363. * Minimum Size of emitting particles.
  14364. */
  14365. minSize: number;
  14366. /**
  14367. * Maximum Size of emitting particles.
  14368. */
  14369. maxSize: number;
  14370. /**
  14371. * Minimum scale of emitting particles on X axis.
  14372. */
  14373. minScaleX: number;
  14374. /**
  14375. * Maximum scale of emitting particles on X axis.
  14376. */
  14377. maxScaleX: number;
  14378. /**
  14379. * Minimum scale of emitting particles on Y axis.
  14380. */
  14381. minScaleY: number;
  14382. /**
  14383. * Maximum scale of emitting particles on Y axis.
  14384. */
  14385. maxScaleY: number;
  14386. /**
  14387. * Gets or sets the minimal initial rotation in radians.
  14388. */
  14389. minInitialRotation: number;
  14390. /**
  14391. * Gets or sets the maximal initial rotation in radians.
  14392. */
  14393. maxInitialRotation: number;
  14394. /**
  14395. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14396. */
  14397. minAngularSpeed: number;
  14398. /**
  14399. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14400. */
  14401. maxAngularSpeed: number;
  14402. /**
  14403. * The texture used to render each particle. (this can be a spritesheet)
  14404. */
  14405. particleTexture: Nullable<BaseTexture>;
  14406. /**
  14407. * The layer mask we are rendering the particles through.
  14408. */
  14409. layerMask: number;
  14410. /**
  14411. * This can help using your own shader to render the particle system.
  14412. * The according effect will be created
  14413. */
  14414. customShader: any;
  14415. /**
  14416. * By default particle system starts as soon as they are created. This prevents the
  14417. * automatic start to happen and let you decide when to start emitting particles.
  14418. */
  14419. preventAutoStart: boolean;
  14420. private _noiseTexture;
  14421. /**
  14422. * Gets or sets a texture used to add random noise to particle positions
  14423. */
  14424. get noiseTexture(): Nullable<ProceduralTexture>;
  14425. set noiseTexture(value: Nullable<ProceduralTexture>);
  14426. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14427. noiseStrength: Vector3;
  14428. /**
  14429. * Callback triggered when the particle animation is ending.
  14430. */
  14431. onAnimationEnd: Nullable<() => void>;
  14432. /**
  14433. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14434. */
  14435. blendMode: number;
  14436. /**
  14437. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14438. * to override the particles.
  14439. */
  14440. forceDepthWrite: boolean;
  14441. /** 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 */
  14442. preWarmCycles: number;
  14443. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14444. preWarmStepOffset: number;
  14445. /**
  14446. * 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)
  14447. */
  14448. spriteCellChangeSpeed: number;
  14449. /**
  14450. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14451. */
  14452. startSpriteCellID: number;
  14453. /**
  14454. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14455. */
  14456. endSpriteCellID: number;
  14457. /**
  14458. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14459. */
  14460. spriteCellWidth: number;
  14461. /**
  14462. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14463. */
  14464. spriteCellHeight: number;
  14465. /**
  14466. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14467. */
  14468. spriteRandomStartCell: boolean;
  14469. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14470. translationPivot: Vector2;
  14471. /** @hidden */
  14472. protected _isAnimationSheetEnabled: boolean;
  14473. /**
  14474. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14475. */
  14476. beginAnimationOnStart: boolean;
  14477. /**
  14478. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14479. */
  14480. beginAnimationFrom: number;
  14481. /**
  14482. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14483. */
  14484. beginAnimationTo: number;
  14485. /**
  14486. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14487. */
  14488. beginAnimationLoop: boolean;
  14489. /**
  14490. * Gets or sets a world offset applied to all particles
  14491. */
  14492. worldOffset: Vector3;
  14493. /**
  14494. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14495. */
  14496. get isAnimationSheetEnabled(): boolean;
  14497. set isAnimationSheetEnabled(value: boolean);
  14498. /**
  14499. * Get hosting scene
  14500. * @returns the scene
  14501. */
  14502. getScene(): Nullable<Scene>;
  14503. /**
  14504. * You can use gravity if you want to give an orientation to your particles.
  14505. */
  14506. gravity: Vector3;
  14507. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14508. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14509. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14510. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14511. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14512. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14513. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14514. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14515. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14516. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14517. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14518. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14519. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14520. /**
  14521. * Defines the delay in milliseconds before starting the system (0 by default)
  14522. */
  14523. startDelay: number;
  14524. /**
  14525. * Gets the current list of drag gradients.
  14526. * You must use addDragGradient and removeDragGradient to udpate this list
  14527. * @returns the list of drag gradients
  14528. */
  14529. getDragGradients(): Nullable<Array<FactorGradient>>;
  14530. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14531. limitVelocityDamping: number;
  14532. /**
  14533. * Gets the current list of limit velocity gradients.
  14534. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14535. * @returns the list of limit velocity gradients
  14536. */
  14537. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14538. /**
  14539. * Gets the current list of color gradients.
  14540. * You must use addColorGradient and removeColorGradient to udpate this list
  14541. * @returns the list of color gradients
  14542. */
  14543. getColorGradients(): Nullable<Array<ColorGradient>>;
  14544. /**
  14545. * Gets the current list of size gradients.
  14546. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14547. * @returns the list of size gradients
  14548. */
  14549. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14550. /**
  14551. * Gets the current list of color remap gradients.
  14552. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14553. * @returns the list of color remap gradients
  14554. */
  14555. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14556. /**
  14557. * Gets the current list of alpha remap gradients.
  14558. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14559. * @returns the list of alpha remap gradients
  14560. */
  14561. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14562. /**
  14563. * Gets the current list of life time gradients.
  14564. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14565. * @returns the list of life time gradients
  14566. */
  14567. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14568. /**
  14569. * Gets the current list of angular speed gradients.
  14570. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14571. * @returns the list of angular speed gradients
  14572. */
  14573. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14574. /**
  14575. * Gets the current list of velocity gradients.
  14576. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14577. * @returns the list of velocity gradients
  14578. */
  14579. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14580. /**
  14581. * Gets the current list of start size gradients.
  14582. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14583. * @returns the list of start size gradients
  14584. */
  14585. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14586. /**
  14587. * Gets the current list of emit rate gradients.
  14588. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14589. * @returns the list of emit rate gradients
  14590. */
  14591. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14592. /**
  14593. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14594. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14595. */
  14596. get direction1(): Vector3;
  14597. set direction1(value: Vector3);
  14598. /**
  14599. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14600. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14601. */
  14602. get direction2(): Vector3;
  14603. set direction2(value: Vector3);
  14604. /**
  14605. * 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.
  14606. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14607. */
  14608. get minEmitBox(): Vector3;
  14609. set minEmitBox(value: Vector3);
  14610. /**
  14611. * 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.
  14612. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14613. */
  14614. get maxEmitBox(): Vector3;
  14615. set maxEmitBox(value: Vector3);
  14616. /**
  14617. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14618. */
  14619. color1: Color4;
  14620. /**
  14621. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14622. */
  14623. color2: Color4;
  14624. /**
  14625. * Color the particle will have at the end of its lifetime
  14626. */
  14627. colorDead: Color4;
  14628. /**
  14629. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14630. */
  14631. textureMask: Color4;
  14632. /**
  14633. * The particle emitter type defines the emitter used by the particle system.
  14634. * It can be for example box, sphere, or cone...
  14635. */
  14636. particleEmitterType: IParticleEmitterType;
  14637. /** @hidden */
  14638. _isSubEmitter: boolean;
  14639. /**
  14640. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14641. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14642. */
  14643. billboardMode: number;
  14644. protected _isBillboardBased: boolean;
  14645. /**
  14646. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14647. */
  14648. get isBillboardBased(): boolean;
  14649. set isBillboardBased(value: boolean);
  14650. /**
  14651. * The scene the particle system belongs to.
  14652. */
  14653. protected _scene: Nullable<Scene>;
  14654. /**
  14655. * The engine the particle system belongs to.
  14656. */
  14657. protected _engine: ThinEngine;
  14658. /**
  14659. * Local cache of defines for image processing.
  14660. */
  14661. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14662. /**
  14663. * Default configuration related to image processing available in the standard Material.
  14664. */
  14665. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  14666. /**
  14667. * Gets the image processing configuration used either in this material.
  14668. */
  14669. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  14670. /**
  14671. * Sets the Default image processing configuration used either in the this material.
  14672. *
  14673. * If sets to null, the scene one is in use.
  14674. */
  14675. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  14676. /**
  14677. * Attaches a new image processing configuration to the Standard Material.
  14678. * @param configuration
  14679. */
  14680. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14681. /** @hidden */
  14682. protected _reset(): void;
  14683. /** @hidden */
  14684. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14685. /**
  14686. * Instantiates a particle system.
  14687. * 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.
  14688. * @param name The name of the particle system
  14689. */
  14690. constructor(name: string);
  14691. /**
  14692. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14695. * @returns the emitter
  14696. */
  14697. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14698. /**
  14699. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14700. * @param radius The radius of the hemisphere to emit from
  14701. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14702. * @returns the emitter
  14703. */
  14704. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14705. /**
  14706. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14707. * @param radius The radius of the sphere to emit from
  14708. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14709. * @returns the emitter
  14710. */
  14711. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14712. /**
  14713. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14714. * @param radius The radius of the sphere to emit from
  14715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14717. * @returns the emitter
  14718. */
  14719. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14720. /**
  14721. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14722. * @param radius The radius of the emission cylinder
  14723. * @param height The height of the emission cylinder
  14724. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14725. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14726. * @returns the emitter
  14727. */
  14728. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14729. /**
  14730. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14731. * @param radius The radius of the cylinder to emit from
  14732. * @param height The height of the emission cylinder
  14733. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14734. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14735. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14736. * @returns the emitter
  14737. */
  14738. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14739. /**
  14740. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14741. * @param radius The radius of the cone to emit from
  14742. * @param angle The base angle of the cone
  14743. * @returns the emitter
  14744. */
  14745. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14746. /**
  14747. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14748. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14749. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14750. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14751. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14752. * @returns the emitter
  14753. */
  14754. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14755. }
  14756. }
  14757. declare module BABYLON {
  14758. /**
  14759. * Type of sub emitter
  14760. */
  14761. export enum SubEmitterType {
  14762. /**
  14763. * Attached to the particle over it's lifetime
  14764. */
  14765. ATTACHED = 0,
  14766. /**
  14767. * Created when the particle dies
  14768. */
  14769. END = 1
  14770. }
  14771. /**
  14772. * Sub emitter class used to emit particles from an existing particle
  14773. */
  14774. export class SubEmitter {
  14775. /**
  14776. * the particle system to be used by the sub emitter
  14777. */
  14778. particleSystem: ParticleSystem;
  14779. /**
  14780. * Type of the submitter (Default: END)
  14781. */
  14782. type: SubEmitterType;
  14783. /**
  14784. * 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)
  14785. * Note: This only is supported when using an emitter of type Mesh
  14786. */
  14787. inheritDirection: boolean;
  14788. /**
  14789. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14790. */
  14791. inheritedVelocityAmount: number;
  14792. /**
  14793. * Creates a sub emitter
  14794. * @param particleSystem the particle system to be used by the sub emitter
  14795. */
  14796. constructor(
  14797. /**
  14798. * the particle system to be used by the sub emitter
  14799. */
  14800. particleSystem: ParticleSystem);
  14801. /**
  14802. * Clones the sub emitter
  14803. * @returns the cloned sub emitter
  14804. */
  14805. clone(): SubEmitter;
  14806. /**
  14807. * Serialize current object to a JSON object
  14808. * @returns the serialized object
  14809. */
  14810. serialize(): any;
  14811. /** @hidden */
  14812. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  14813. /**
  14814. * Creates a new SubEmitter from a serialized JSON version
  14815. * @param serializationObject defines the JSON object to read from
  14816. * @param sceneOrEngine defines the hosting scene or the hosting engine
  14817. * @param rootUrl defines the rootUrl for data loading
  14818. * @returns a new SubEmitter
  14819. */
  14820. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  14821. /** Release associated resources */
  14822. dispose(): void;
  14823. }
  14824. }
  14825. declare module BABYLON {
  14826. /** @hidden */
  14827. export var clipPlaneFragmentDeclaration: {
  14828. name: string;
  14829. shader: string;
  14830. };
  14831. }
  14832. declare module BABYLON {
  14833. /** @hidden */
  14834. export var imageProcessingDeclaration: {
  14835. name: string;
  14836. shader: string;
  14837. };
  14838. }
  14839. declare module BABYLON {
  14840. /** @hidden */
  14841. export var imageProcessingFunctions: {
  14842. name: string;
  14843. shader: string;
  14844. };
  14845. }
  14846. declare module BABYLON {
  14847. /** @hidden */
  14848. export var clipPlaneFragment: {
  14849. name: string;
  14850. shader: string;
  14851. };
  14852. }
  14853. declare module BABYLON {
  14854. /** @hidden */
  14855. export var particlesPixelShader: {
  14856. name: string;
  14857. shader: string;
  14858. };
  14859. }
  14860. declare module BABYLON {
  14861. /** @hidden */
  14862. export var clipPlaneVertexDeclaration: {
  14863. name: string;
  14864. shader: string;
  14865. };
  14866. }
  14867. declare module BABYLON {
  14868. /** @hidden */
  14869. export var clipPlaneVertex: {
  14870. name: string;
  14871. shader: string;
  14872. };
  14873. }
  14874. declare module BABYLON {
  14875. /** @hidden */
  14876. export var particlesVertexShader: {
  14877. name: string;
  14878. shader: string;
  14879. };
  14880. }
  14881. declare module BABYLON {
  14882. /**
  14883. * Interface used to define entities containing multiple clip planes
  14884. */
  14885. export interface IClipPlanesHolder {
  14886. /**
  14887. * Gets or sets the active clipplane 1
  14888. */
  14889. clipPlane: Nullable<Plane>;
  14890. /**
  14891. * Gets or sets the active clipplane 2
  14892. */
  14893. clipPlane2: Nullable<Plane>;
  14894. /**
  14895. * Gets or sets the active clipplane 3
  14896. */
  14897. clipPlane3: Nullable<Plane>;
  14898. /**
  14899. * Gets or sets the active clipplane 4
  14900. */
  14901. clipPlane4: Nullable<Plane>;
  14902. /**
  14903. * Gets or sets the active clipplane 5
  14904. */
  14905. clipPlane5: Nullable<Plane>;
  14906. /**
  14907. * Gets or sets the active clipplane 6
  14908. */
  14909. clipPlane6: Nullable<Plane>;
  14910. }
  14911. }
  14912. declare module BABYLON {
  14913. /**
  14914. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  14915. *
  14916. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  14917. *
  14918. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14919. */
  14920. export class ThinMaterialHelper {
  14921. /**
  14922. * Binds the clip plane information from the holder to the effect.
  14923. * @param effect The effect we are binding the data to
  14924. * @param holder The entity containing the clip plane information
  14925. */
  14926. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  14927. }
  14928. }
  14929. declare module BABYLON {
  14930. interface ThinEngine {
  14931. /**
  14932. * Sets alpha constants used by some alpha blending modes
  14933. * @param r defines the red component
  14934. * @param g defines the green component
  14935. * @param b defines the blue component
  14936. * @param a defines the alpha component
  14937. */
  14938. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  14939. /**
  14940. * Sets the current alpha mode
  14941. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  14942. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  14943. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14944. */
  14945. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  14946. /**
  14947. * Gets the current alpha mode
  14948. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14949. * @returns the current alpha mode
  14950. */
  14951. getAlphaMode(): number;
  14952. /**
  14953. * Sets the current alpha equation
  14954. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  14955. */
  14956. setAlphaEquation(equation: number): void;
  14957. /**
  14958. * Gets the current alpha equation.
  14959. * @returns the current alpha equation
  14960. */
  14961. getAlphaEquation(): number;
  14962. }
  14963. }
  14964. declare module BABYLON {
  14965. /**
  14966. * This represents a particle system in Babylon.
  14967. * 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.
  14968. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14969. * @example https://doc.babylonjs.com/babylon101/particles
  14970. */
  14971. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14972. /**
  14973. * Billboard mode will only apply to Y axis
  14974. */
  14975. static readonly BILLBOARDMODE_Y: number;
  14976. /**
  14977. * Billboard mode will apply to all axes
  14978. */
  14979. static readonly BILLBOARDMODE_ALL: number;
  14980. /**
  14981. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14982. */
  14983. static readonly BILLBOARDMODE_STRETCHED: number;
  14984. /**
  14985. * This function can be defined to provide custom update for active particles.
  14986. * This function will be called instead of regular update (age, position, color, etc.).
  14987. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14988. */
  14989. updateFunction: (particles: Particle[]) => void;
  14990. private _emitterWorldMatrix;
  14991. /**
  14992. * This function can be defined to specify initial direction for every new particle.
  14993. * It by default use the emitterType defined function
  14994. */
  14995. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  14996. /**
  14997. * This function can be defined to specify initial position for every new particle.
  14998. * It by default use the emitterType defined function
  14999. */
  15000. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15001. /**
  15002. * @hidden
  15003. */
  15004. _inheritedVelocityOffset: Vector3;
  15005. /**
  15006. * An event triggered when the system is disposed
  15007. */
  15008. onDisposeObservable: Observable<IParticleSystem>;
  15009. /**
  15010. * An event triggered when the system is stopped
  15011. */
  15012. onStoppedObservable: Observable<IParticleSystem>;
  15013. private _onDisposeObserver;
  15014. /**
  15015. * Sets a callback that will be triggered when the system is disposed
  15016. */
  15017. set onDispose(callback: () => void);
  15018. private _particles;
  15019. private _epsilon;
  15020. private _capacity;
  15021. private _stockParticles;
  15022. private _newPartsExcess;
  15023. private _vertexData;
  15024. private _vertexBuffer;
  15025. private _vertexBuffers;
  15026. private _spriteBuffer;
  15027. private _indexBuffer;
  15028. private _effect;
  15029. private _customEffect;
  15030. private _cachedDefines;
  15031. private _scaledColorStep;
  15032. private _colorDiff;
  15033. private _scaledDirection;
  15034. private _scaledGravity;
  15035. private _currentRenderId;
  15036. private _alive;
  15037. private _useInstancing;
  15038. private _vertexArrayObject;
  15039. private _started;
  15040. private _stopped;
  15041. private _actualFrame;
  15042. private _scaledUpdateSpeed;
  15043. private _vertexBufferSize;
  15044. /** @hidden */
  15045. _currentEmitRateGradient: Nullable<FactorGradient>;
  15046. /** @hidden */
  15047. _currentEmitRate1: number;
  15048. /** @hidden */
  15049. _currentEmitRate2: number;
  15050. /** @hidden */
  15051. _currentStartSizeGradient: Nullable<FactorGradient>;
  15052. /** @hidden */
  15053. _currentStartSize1: number;
  15054. /** @hidden */
  15055. _currentStartSize2: number;
  15056. private readonly _rawTextureWidth;
  15057. private _rampGradientsTexture;
  15058. private _useRampGradients;
  15059. /** Gets or sets a matrix to use to compute projection */
  15060. defaultProjectionMatrix: Matrix;
  15061. /** Gets or sets a matrix to use to compute view */
  15062. defaultViewMatrix: Matrix;
  15063. /** Gets or sets a boolean indicating that ramp gradients must be used
  15064. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15065. */
  15066. get useRampGradients(): boolean;
  15067. set useRampGradients(value: boolean);
  15068. /**
  15069. * 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.
  15070. * 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: [])
  15071. */
  15072. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15073. private _subEmitters;
  15074. /**
  15075. * @hidden
  15076. * If the particle systems emitter should be disposed when the particle system is disposed
  15077. */
  15078. _disposeEmitterOnDispose: boolean;
  15079. /**
  15080. * The current active Sub-systems, this property is used by the root particle system only.
  15081. */
  15082. activeSubSystems: Array<ParticleSystem>;
  15083. /**
  15084. * Specifies if the particles are updated in emitter local space or world space
  15085. */
  15086. isLocal: boolean;
  15087. private _rootParticleSystem;
  15088. /**
  15089. * Gets the current list of active particles
  15090. */
  15091. get particles(): Particle[];
  15092. /**
  15093. * Gets the number of particles active at the same time.
  15094. * @returns The number of active particles.
  15095. */
  15096. getActiveCount(): number;
  15097. /**
  15098. * Returns the string "ParticleSystem"
  15099. * @returns a string containing the class name
  15100. */
  15101. getClassName(): string;
  15102. /**
  15103. * Gets a boolean indicating that the system is stopping
  15104. * @returns true if the system is currently stopping
  15105. */
  15106. isStopping(): boolean;
  15107. /**
  15108. * Gets the custom effect used to render the particles
  15109. * @param blendMode Blend mode for which the effect should be retrieved
  15110. * @returns The effect
  15111. */
  15112. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15113. /**
  15114. * Sets the custom effect used to render the particles
  15115. * @param effect The effect to set
  15116. * @param blendMode Blend mode for which the effect should be set
  15117. */
  15118. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15119. /** @hidden */
  15120. private _onBeforeDrawParticlesObservable;
  15121. /**
  15122. * Observable that will be called just before the particles are drawn
  15123. */
  15124. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15125. /**
  15126. * Gets the name of the particle vertex shader
  15127. */
  15128. get vertexShaderName(): string;
  15129. /**
  15130. * Instantiates a particle system.
  15131. * 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.
  15132. * @param name The name of the particle system
  15133. * @param capacity The max number of particles alive at the same time
  15134. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15135. * @param customEffect a custom effect used to change the way particles are rendered by default
  15136. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15137. * @param epsilon Offset used to render the particles
  15138. */
  15139. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15140. private _addFactorGradient;
  15141. private _removeFactorGradient;
  15142. /**
  15143. * Adds a new life time gradient
  15144. * @param gradient defines the gradient to use (between 0 and 1)
  15145. * @param factor defines the life time factor to affect to the specified gradient
  15146. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15147. * @returns the current particle system
  15148. */
  15149. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15150. /**
  15151. * Remove a specific life time gradient
  15152. * @param gradient defines the gradient to remove
  15153. * @returns the current particle system
  15154. */
  15155. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15156. /**
  15157. * Adds a new size gradient
  15158. * @param gradient defines the gradient to use (between 0 and 1)
  15159. * @param factor defines the size factor to affect to the specified gradient
  15160. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15161. * @returns the current particle system
  15162. */
  15163. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15164. /**
  15165. * Remove a specific size gradient
  15166. * @param gradient defines the gradient to remove
  15167. * @returns the current particle system
  15168. */
  15169. removeSizeGradient(gradient: number): IParticleSystem;
  15170. /**
  15171. * Adds a new color remap gradient
  15172. * @param gradient defines the gradient to use (between 0 and 1)
  15173. * @param min defines the color remap minimal range
  15174. * @param max defines the color remap maximal range
  15175. * @returns the current particle system
  15176. */
  15177. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15178. /**
  15179. * Remove a specific color remap gradient
  15180. * @param gradient defines the gradient to remove
  15181. * @returns the current particle system
  15182. */
  15183. removeColorRemapGradient(gradient: number): IParticleSystem;
  15184. /**
  15185. * Adds a new alpha remap gradient
  15186. * @param gradient defines the gradient to use (between 0 and 1)
  15187. * @param min defines the alpha remap minimal range
  15188. * @param max defines the alpha remap maximal range
  15189. * @returns the current particle system
  15190. */
  15191. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15192. /**
  15193. * Remove a specific alpha remap gradient
  15194. * @param gradient defines the gradient to remove
  15195. * @returns the current particle system
  15196. */
  15197. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15198. /**
  15199. * Adds a new angular speed gradient
  15200. * @param gradient defines the gradient to use (between 0 and 1)
  15201. * @param factor defines the angular speed to affect to the specified gradient
  15202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15203. * @returns the current particle system
  15204. */
  15205. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15206. /**
  15207. * Remove a specific angular speed gradient
  15208. * @param gradient defines the gradient to remove
  15209. * @returns the current particle system
  15210. */
  15211. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15212. /**
  15213. * Adds a new velocity gradient
  15214. * @param gradient defines the gradient to use (between 0 and 1)
  15215. * @param factor defines the velocity to affect to the specified gradient
  15216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15217. * @returns the current particle system
  15218. */
  15219. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15220. /**
  15221. * Remove a specific velocity gradient
  15222. * @param gradient defines the gradient to remove
  15223. * @returns the current particle system
  15224. */
  15225. removeVelocityGradient(gradient: number): IParticleSystem;
  15226. /**
  15227. * Adds a new limit velocity gradient
  15228. * @param gradient defines the gradient to use (between 0 and 1)
  15229. * @param factor defines the limit velocity value to affect to the specified gradient
  15230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15231. * @returns the current particle system
  15232. */
  15233. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15234. /**
  15235. * Remove a specific limit velocity gradient
  15236. * @param gradient defines the gradient to remove
  15237. * @returns the current particle system
  15238. */
  15239. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15240. /**
  15241. * Adds a new drag gradient
  15242. * @param gradient defines the gradient to use (between 0 and 1)
  15243. * @param factor defines the drag value to affect to the specified gradient
  15244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15245. * @returns the current particle system
  15246. */
  15247. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15248. /**
  15249. * Remove a specific drag gradient
  15250. * @param gradient defines the gradient to remove
  15251. * @returns the current particle system
  15252. */
  15253. removeDragGradient(gradient: number): IParticleSystem;
  15254. /**
  15255. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15256. * @param gradient defines the gradient to use (between 0 and 1)
  15257. * @param factor defines the emit rate value to affect to the specified gradient
  15258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15259. * @returns the current particle system
  15260. */
  15261. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15262. /**
  15263. * Remove a specific emit rate gradient
  15264. * @param gradient defines the gradient to remove
  15265. * @returns the current particle system
  15266. */
  15267. removeEmitRateGradient(gradient: number): IParticleSystem;
  15268. /**
  15269. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15270. * @param gradient defines the gradient to use (between 0 and 1)
  15271. * @param factor defines the start size value to affect to the specified gradient
  15272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15273. * @returns the current particle system
  15274. */
  15275. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15276. /**
  15277. * Remove a specific start size gradient
  15278. * @param gradient defines the gradient to remove
  15279. * @returns the current particle system
  15280. */
  15281. removeStartSizeGradient(gradient: number): IParticleSystem;
  15282. private _createRampGradientTexture;
  15283. /**
  15284. * Gets the current list of ramp gradients.
  15285. * You must use addRampGradient and removeRampGradient to udpate this list
  15286. * @returns the list of ramp gradients
  15287. */
  15288. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15289. /** Force the system to rebuild all gradients that need to be resync */
  15290. forceRefreshGradients(): void;
  15291. private _syncRampGradientTexture;
  15292. /**
  15293. * Adds a new ramp gradient used to remap particle colors
  15294. * @param gradient defines the gradient to use (between 0 and 1)
  15295. * @param color defines the color to affect to the specified gradient
  15296. * @returns the current particle system
  15297. */
  15298. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15299. /**
  15300. * Remove a specific ramp gradient
  15301. * @param gradient defines the gradient to remove
  15302. * @returns the current particle system
  15303. */
  15304. removeRampGradient(gradient: number): ParticleSystem;
  15305. /**
  15306. * Adds a new color gradient
  15307. * @param gradient defines the gradient to use (between 0 and 1)
  15308. * @param color1 defines the color to affect to the specified gradient
  15309. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15310. * @returns this particle system
  15311. */
  15312. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15313. /**
  15314. * Remove a specific color gradient
  15315. * @param gradient defines the gradient to remove
  15316. * @returns this particle system
  15317. */
  15318. removeColorGradient(gradient: number): IParticleSystem;
  15319. private _fetchR;
  15320. protected _reset(): void;
  15321. private _resetEffect;
  15322. private _createVertexBuffers;
  15323. private _createIndexBuffer;
  15324. /**
  15325. * Gets the maximum number of particles active at the same time.
  15326. * @returns The max number of active particles.
  15327. */
  15328. getCapacity(): number;
  15329. /**
  15330. * Gets whether there are still active particles in the system.
  15331. * @returns True if it is alive, otherwise false.
  15332. */
  15333. isAlive(): boolean;
  15334. /**
  15335. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15336. * @returns True if it has been started, otherwise false.
  15337. */
  15338. isStarted(): boolean;
  15339. private _prepareSubEmitterInternalArray;
  15340. /**
  15341. * Starts the particle system and begins to emit
  15342. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15343. */
  15344. start(delay?: number): void;
  15345. /**
  15346. * Stops the particle system.
  15347. * @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.
  15348. */
  15349. stop(stopSubEmitters?: boolean): void;
  15350. /**
  15351. * Remove all active particles
  15352. */
  15353. reset(): void;
  15354. /**
  15355. * @hidden (for internal use only)
  15356. */
  15357. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15358. /**
  15359. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15360. * Its lifetime will start back at 0.
  15361. */
  15362. recycleParticle: (particle: Particle) => void;
  15363. private _stopSubEmitters;
  15364. private _createParticle;
  15365. private _removeFromRoot;
  15366. private _emitFromParticle;
  15367. private _update;
  15368. /** @hidden */
  15369. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15370. /** @hidden */
  15371. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15372. /**
  15373. * Fill the defines array according to the current settings of the particle system
  15374. * @param defines Array to be updated
  15375. * @param blendMode blend mode to take into account when updating the array
  15376. */
  15377. fillDefines(defines: Array<string>, blendMode: number): void;
  15378. /**
  15379. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15380. * @param uniforms Uniforms array to fill
  15381. * @param attributes Attributes array to fill
  15382. * @param samplers Samplers array to fill
  15383. */
  15384. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15385. /** @hidden */
  15386. private _getEffect;
  15387. /**
  15388. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15389. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15390. */
  15391. animate(preWarmOnly?: boolean): void;
  15392. private _appendParticleVertices;
  15393. /**
  15394. * Rebuilds the particle system.
  15395. */
  15396. rebuild(): void;
  15397. /**
  15398. * Is this system ready to be used/rendered
  15399. * @return true if the system is ready
  15400. */
  15401. isReady(): boolean;
  15402. private _render;
  15403. /**
  15404. * Renders the particle system in its current state.
  15405. * @returns the current number of particles
  15406. */
  15407. render(): number;
  15408. /**
  15409. * Disposes the particle system and free the associated resources
  15410. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15411. */
  15412. dispose(disposeTexture?: boolean): void;
  15413. /**
  15414. * Clones the particle system.
  15415. * @param name The name of the cloned object
  15416. * @param newEmitter The new emitter to use
  15417. * @returns the cloned particle system
  15418. */
  15419. clone(name: string, newEmitter: any): ParticleSystem;
  15420. /**
  15421. * Serializes the particle system to a JSON object
  15422. * @param serializeTexture defines if the texture must be serialized as well
  15423. * @returns the JSON object
  15424. */
  15425. serialize(serializeTexture?: boolean): any;
  15426. /** @hidden */
  15427. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15428. /** @hidden */
  15429. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15430. /**
  15431. * Parses a JSON object to create a particle system.
  15432. * @param parsedParticleSystem The JSON object to parse
  15433. * @param sceneOrEngine The scene or the engine to create the particle system in
  15434. * @param rootUrl The root url to use to load external dependencies like texture
  15435. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15436. * @returns the Parsed particle system
  15437. */
  15438. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15439. }
  15440. }
  15441. declare module BABYLON {
  15442. /**
  15443. * A particle represents one of the element emitted by a particle system.
  15444. * This is mainly define by its coordinates, direction, velocity and age.
  15445. */
  15446. export class Particle {
  15447. /**
  15448. * The particle system the particle belongs to.
  15449. */
  15450. particleSystem: ParticleSystem;
  15451. private static _Count;
  15452. /**
  15453. * Unique ID of the particle
  15454. */
  15455. id: number;
  15456. /**
  15457. * The world position of the particle in the scene.
  15458. */
  15459. position: Vector3;
  15460. /**
  15461. * The world direction of the particle in the scene.
  15462. */
  15463. direction: Vector3;
  15464. /**
  15465. * The color of the particle.
  15466. */
  15467. color: Color4;
  15468. /**
  15469. * The color change of the particle per step.
  15470. */
  15471. colorStep: Color4;
  15472. /**
  15473. * Defines how long will the life of the particle be.
  15474. */
  15475. lifeTime: number;
  15476. /**
  15477. * The current age of the particle.
  15478. */
  15479. age: number;
  15480. /**
  15481. * The current size of the particle.
  15482. */
  15483. size: number;
  15484. /**
  15485. * The current scale of the particle.
  15486. */
  15487. scale: Vector2;
  15488. /**
  15489. * The current angle of the particle.
  15490. */
  15491. angle: number;
  15492. /**
  15493. * Defines how fast is the angle changing.
  15494. */
  15495. angularSpeed: number;
  15496. /**
  15497. * Defines the cell index used by the particle to be rendered from a sprite.
  15498. */
  15499. cellIndex: number;
  15500. /**
  15501. * The information required to support color remapping
  15502. */
  15503. remapData: Vector4;
  15504. /** @hidden */
  15505. _randomCellOffset?: number;
  15506. /** @hidden */
  15507. _initialDirection: Nullable<Vector3>;
  15508. /** @hidden */
  15509. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15510. /** @hidden */
  15511. _initialStartSpriteCellID: number;
  15512. /** @hidden */
  15513. _initialEndSpriteCellID: number;
  15514. /** @hidden */
  15515. _currentColorGradient: Nullable<ColorGradient>;
  15516. /** @hidden */
  15517. _currentColor1: Color4;
  15518. /** @hidden */
  15519. _currentColor2: Color4;
  15520. /** @hidden */
  15521. _currentSizeGradient: Nullable<FactorGradient>;
  15522. /** @hidden */
  15523. _currentSize1: number;
  15524. /** @hidden */
  15525. _currentSize2: number;
  15526. /** @hidden */
  15527. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15528. /** @hidden */
  15529. _currentAngularSpeed1: number;
  15530. /** @hidden */
  15531. _currentAngularSpeed2: number;
  15532. /** @hidden */
  15533. _currentVelocityGradient: Nullable<FactorGradient>;
  15534. /** @hidden */
  15535. _currentVelocity1: number;
  15536. /** @hidden */
  15537. _currentVelocity2: number;
  15538. /** @hidden */
  15539. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15540. /** @hidden */
  15541. _currentLimitVelocity1: number;
  15542. /** @hidden */
  15543. _currentLimitVelocity2: number;
  15544. /** @hidden */
  15545. _currentDragGradient: Nullable<FactorGradient>;
  15546. /** @hidden */
  15547. _currentDrag1: number;
  15548. /** @hidden */
  15549. _currentDrag2: number;
  15550. /** @hidden */
  15551. _randomNoiseCoordinates1: Vector3;
  15552. /** @hidden */
  15553. _randomNoiseCoordinates2: Vector3;
  15554. /** @hidden */
  15555. _localPosition?: Vector3;
  15556. /**
  15557. * Creates a new instance Particle
  15558. * @param particleSystem the particle system the particle belongs to
  15559. */
  15560. constructor(
  15561. /**
  15562. * The particle system the particle belongs to.
  15563. */
  15564. particleSystem: ParticleSystem);
  15565. private updateCellInfoFromSystem;
  15566. /**
  15567. * Defines how the sprite cell index is updated for the particle
  15568. */
  15569. updateCellIndex(): void;
  15570. /** @hidden */
  15571. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15572. /** @hidden */
  15573. _inheritParticleInfoToSubEmitters(): void;
  15574. /** @hidden */
  15575. _reset(): void;
  15576. /**
  15577. * Copy the properties of particle to another one.
  15578. * @param other the particle to copy the information to.
  15579. */
  15580. copyTo(other: Particle): void;
  15581. }
  15582. }
  15583. declare module BABYLON {
  15584. /**
  15585. * Particle emitter represents a volume emitting particles.
  15586. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15587. */
  15588. export interface IParticleEmitterType {
  15589. /**
  15590. * Called by the particle System when the direction is computed for the created particle.
  15591. * @param worldMatrix is the world matrix of the particle system
  15592. * @param directionToUpdate is the direction vector to update with the result
  15593. * @param particle is the particle we are computed the direction for
  15594. * @param isLocal defines if the direction should be set in local space
  15595. */
  15596. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15597. /**
  15598. * Called by the particle System when the position is computed for the created particle.
  15599. * @param worldMatrix is the world matrix of the particle system
  15600. * @param positionToUpdate is the position vector to update with the result
  15601. * @param particle is the particle we are computed the position for
  15602. * @param isLocal defines if the position should be set in local space
  15603. */
  15604. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15605. /**
  15606. * Clones the current emitter and returns a copy of it
  15607. * @returns the new emitter
  15608. */
  15609. clone(): IParticleEmitterType;
  15610. /**
  15611. * Called by the GPUParticleSystem to setup the update shader
  15612. * @param effect defines the update shader
  15613. */
  15614. applyToShader(effect: Effect): void;
  15615. /**
  15616. * Returns a string to use to update the GPU particles update shader
  15617. * @returns the effect defines string
  15618. */
  15619. getEffectDefines(): string;
  15620. /**
  15621. * Returns a string representing the class name
  15622. * @returns a string containing the class name
  15623. */
  15624. getClassName(): string;
  15625. /**
  15626. * Serializes the particle system to a JSON object.
  15627. * @returns the JSON object
  15628. */
  15629. serialize(): any;
  15630. /**
  15631. * Parse properties from a JSON object
  15632. * @param serializationObject defines the JSON object
  15633. * @param scene defines the hosting scene
  15634. */
  15635. parse(serializationObject: any, scene: Nullable<Scene>): void;
  15636. }
  15637. }
  15638. declare module BABYLON {
  15639. /**
  15640. * Particle emitter emitting particles from the inside of a box.
  15641. * It emits the particles randomly between 2 given directions.
  15642. */
  15643. export class BoxParticleEmitter implements IParticleEmitterType {
  15644. /**
  15645. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15646. */
  15647. direction1: Vector3;
  15648. /**
  15649. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15650. */
  15651. direction2: Vector3;
  15652. /**
  15653. * 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.
  15654. */
  15655. minEmitBox: Vector3;
  15656. /**
  15657. * 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.
  15658. */
  15659. maxEmitBox: Vector3;
  15660. /**
  15661. * Creates a new instance BoxParticleEmitter
  15662. */
  15663. constructor();
  15664. /**
  15665. * Called by the particle System when the direction is computed for the created particle.
  15666. * @param worldMatrix is the world matrix of the particle system
  15667. * @param directionToUpdate is the direction vector to update with the result
  15668. * @param particle is the particle we are computed the direction for
  15669. * @param isLocal defines if the direction should be set in local space
  15670. */
  15671. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15672. /**
  15673. * Called by the particle System when the position is computed for the created particle.
  15674. * @param worldMatrix is the world matrix of the particle system
  15675. * @param positionToUpdate is the position vector to update with the result
  15676. * @param particle is the particle we are computed the position for
  15677. * @param isLocal defines if the position should be set in local space
  15678. */
  15679. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15680. /**
  15681. * Clones the current emitter and returns a copy of it
  15682. * @returns the new emitter
  15683. */
  15684. clone(): BoxParticleEmitter;
  15685. /**
  15686. * Called by the GPUParticleSystem to setup the update shader
  15687. * @param effect defines the update shader
  15688. */
  15689. applyToShader(effect: Effect): void;
  15690. /**
  15691. * Returns a string to use to update the GPU particles update shader
  15692. * @returns a string containng the defines string
  15693. */
  15694. getEffectDefines(): string;
  15695. /**
  15696. * Returns the string "BoxParticleEmitter"
  15697. * @returns a string containing the class name
  15698. */
  15699. getClassName(): string;
  15700. /**
  15701. * Serializes the particle system to a JSON object.
  15702. * @returns the JSON object
  15703. */
  15704. serialize(): any;
  15705. /**
  15706. * Parse properties from a JSON object
  15707. * @param serializationObject defines the JSON object
  15708. */
  15709. parse(serializationObject: any): void;
  15710. }
  15711. }
  15712. declare module BABYLON {
  15713. /**
  15714. * Particle emitter emitting particles from the inside of a cone.
  15715. * It emits the particles alongside the cone volume from the base to the particle.
  15716. * The emission direction might be randomized.
  15717. */
  15718. export class ConeParticleEmitter implements IParticleEmitterType {
  15719. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15720. directionRandomizer: number;
  15721. private _radius;
  15722. private _angle;
  15723. private _height;
  15724. /**
  15725. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15726. */
  15727. radiusRange: number;
  15728. /**
  15729. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15730. */
  15731. heightRange: number;
  15732. /**
  15733. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15734. */
  15735. emitFromSpawnPointOnly: boolean;
  15736. /**
  15737. * Gets or sets the radius of the emission cone
  15738. */
  15739. get radius(): number;
  15740. set radius(value: number);
  15741. /**
  15742. * Gets or sets the angle of the emission cone
  15743. */
  15744. get angle(): number;
  15745. set angle(value: number);
  15746. private _buildHeight;
  15747. /**
  15748. * Creates a new instance ConeParticleEmitter
  15749. * @param radius the radius of the emission cone (1 by default)
  15750. * @param angle the cone base angle (PI by default)
  15751. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15752. */
  15753. constructor(radius?: number, angle?: number,
  15754. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15755. directionRandomizer?: number);
  15756. /**
  15757. * Called by the particle System when the direction is computed for the created particle.
  15758. * @param worldMatrix is the world matrix of the particle system
  15759. * @param directionToUpdate is the direction vector to update with the result
  15760. * @param particle is the particle we are computed the direction for
  15761. * @param isLocal defines if the direction should be set in local space
  15762. */
  15763. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15764. /**
  15765. * Called by the particle System when the position is computed for the created particle.
  15766. * @param worldMatrix is the world matrix of the particle system
  15767. * @param positionToUpdate is the position vector to update with the result
  15768. * @param particle is the particle we are computed the position for
  15769. * @param isLocal defines if the position should be set in local space
  15770. */
  15771. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15772. /**
  15773. * Clones the current emitter and returns a copy of it
  15774. * @returns the new emitter
  15775. */
  15776. clone(): ConeParticleEmitter;
  15777. /**
  15778. * Called by the GPUParticleSystem to setup the update shader
  15779. * @param effect defines the update shader
  15780. */
  15781. applyToShader(effect: Effect): void;
  15782. /**
  15783. * Returns a string to use to update the GPU particles update shader
  15784. * @returns a string containng the defines string
  15785. */
  15786. getEffectDefines(): string;
  15787. /**
  15788. * Returns the string "ConeParticleEmitter"
  15789. * @returns a string containing the class name
  15790. */
  15791. getClassName(): string;
  15792. /**
  15793. * Serializes the particle system to a JSON object.
  15794. * @returns the JSON object
  15795. */
  15796. serialize(): any;
  15797. /**
  15798. * Parse properties from a JSON object
  15799. * @param serializationObject defines the JSON object
  15800. */
  15801. parse(serializationObject: any): void;
  15802. }
  15803. }
  15804. declare module BABYLON {
  15805. /**
  15806. * Particle emitter emitting particles from the inside of a cylinder.
  15807. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15808. */
  15809. export class CylinderParticleEmitter implements IParticleEmitterType {
  15810. /**
  15811. * The radius of the emission cylinder.
  15812. */
  15813. radius: number;
  15814. /**
  15815. * The height of the emission cylinder.
  15816. */
  15817. height: number;
  15818. /**
  15819. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15820. */
  15821. radiusRange: number;
  15822. /**
  15823. * How much to randomize the particle direction [0-1].
  15824. */
  15825. directionRandomizer: number;
  15826. /**
  15827. * Creates a new instance CylinderParticleEmitter
  15828. * @param radius the radius of the emission cylinder (1 by default)
  15829. * @param height the height of the emission cylinder (1 by default)
  15830. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15831. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15832. */
  15833. constructor(
  15834. /**
  15835. * The radius of the emission cylinder.
  15836. */
  15837. radius?: number,
  15838. /**
  15839. * The height of the emission cylinder.
  15840. */
  15841. height?: number,
  15842. /**
  15843. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15844. */
  15845. radiusRange?: number,
  15846. /**
  15847. * How much to randomize the particle direction [0-1].
  15848. */
  15849. directionRandomizer?: number);
  15850. /**
  15851. * Called by the particle System when the direction is computed for the created particle.
  15852. * @param worldMatrix is the world matrix of the particle system
  15853. * @param directionToUpdate is the direction vector to update with the result
  15854. * @param particle is the particle we are computed the direction for
  15855. * @param isLocal defines if the direction should be set in local space
  15856. */
  15857. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15858. /**
  15859. * Called by the particle System when the position is computed for the created particle.
  15860. * @param worldMatrix is the world matrix of the particle system
  15861. * @param positionToUpdate is the position vector to update with the result
  15862. * @param particle is the particle we are computed the position for
  15863. * @param isLocal defines if the position should be set in local space
  15864. */
  15865. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15866. /**
  15867. * Clones the current emitter and returns a copy of it
  15868. * @returns the new emitter
  15869. */
  15870. clone(): CylinderParticleEmitter;
  15871. /**
  15872. * Called by the GPUParticleSystem to setup the update shader
  15873. * @param effect defines the update shader
  15874. */
  15875. applyToShader(effect: Effect): void;
  15876. /**
  15877. * Returns a string to use to update the GPU particles update shader
  15878. * @returns a string containng the defines string
  15879. */
  15880. getEffectDefines(): string;
  15881. /**
  15882. * Returns the string "CylinderParticleEmitter"
  15883. * @returns a string containing the class name
  15884. */
  15885. getClassName(): string;
  15886. /**
  15887. * Serializes the particle system to a JSON object.
  15888. * @returns the JSON object
  15889. */
  15890. serialize(): any;
  15891. /**
  15892. * Parse properties from a JSON object
  15893. * @param serializationObject defines the JSON object
  15894. */
  15895. parse(serializationObject: any): void;
  15896. }
  15897. /**
  15898. * Particle emitter emitting particles from the inside of a cylinder.
  15899. * It emits the particles randomly between two vectors.
  15900. */
  15901. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15902. /**
  15903. * The min limit of the emission direction.
  15904. */
  15905. direction1: Vector3;
  15906. /**
  15907. * The max limit of the emission direction.
  15908. */
  15909. direction2: Vector3;
  15910. /**
  15911. * Creates a new instance CylinderDirectedParticleEmitter
  15912. * @param radius the radius of the emission cylinder (1 by default)
  15913. * @param height the height of the emission cylinder (1 by default)
  15914. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15915. * @param direction1 the min limit of the emission direction (up vector by default)
  15916. * @param direction2 the max limit of the emission direction (up vector by default)
  15917. */
  15918. constructor(radius?: number, height?: number, radiusRange?: number,
  15919. /**
  15920. * The min limit of the emission direction.
  15921. */
  15922. direction1?: Vector3,
  15923. /**
  15924. * The max limit of the emission direction.
  15925. */
  15926. direction2?: Vector3);
  15927. /**
  15928. * Called by the particle System when the direction is computed for the created particle.
  15929. * @param worldMatrix is the world matrix of the particle system
  15930. * @param directionToUpdate is the direction vector to update with the result
  15931. * @param particle is the particle we are computed the direction for
  15932. */
  15933. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15934. /**
  15935. * Clones the current emitter and returns a copy of it
  15936. * @returns the new emitter
  15937. */
  15938. clone(): CylinderDirectedParticleEmitter;
  15939. /**
  15940. * Called by the GPUParticleSystem to setup the update shader
  15941. * @param effect defines the update shader
  15942. */
  15943. applyToShader(effect: Effect): void;
  15944. /**
  15945. * Returns a string to use to update the GPU particles update shader
  15946. * @returns a string containng the defines string
  15947. */
  15948. getEffectDefines(): string;
  15949. /**
  15950. * Returns the string "CylinderDirectedParticleEmitter"
  15951. * @returns a string containing the class name
  15952. */
  15953. getClassName(): string;
  15954. /**
  15955. * Serializes the particle system to a JSON object.
  15956. * @returns the JSON object
  15957. */
  15958. serialize(): any;
  15959. /**
  15960. * Parse properties from a JSON object
  15961. * @param serializationObject defines the JSON object
  15962. */
  15963. parse(serializationObject: any): void;
  15964. }
  15965. }
  15966. declare module BABYLON {
  15967. /**
  15968. * Particle emitter emitting particles from the inside of a hemisphere.
  15969. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15970. */
  15971. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15972. /**
  15973. * The radius of the emission hemisphere.
  15974. */
  15975. radius: number;
  15976. /**
  15977. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15978. */
  15979. radiusRange: number;
  15980. /**
  15981. * How much to randomize the particle direction [0-1].
  15982. */
  15983. directionRandomizer: number;
  15984. /**
  15985. * Creates a new instance HemisphericParticleEmitter
  15986. * @param radius the radius of the emission hemisphere (1 by default)
  15987. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15988. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15989. */
  15990. constructor(
  15991. /**
  15992. * The radius of the emission hemisphere.
  15993. */
  15994. radius?: number,
  15995. /**
  15996. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15997. */
  15998. radiusRange?: number,
  15999. /**
  16000. * How much to randomize the particle direction [0-1].
  16001. */
  16002. directionRandomizer?: number);
  16003. /**
  16004. * Called by the particle System when the direction is computed for the created particle.
  16005. * @param worldMatrix is the world matrix of the particle system
  16006. * @param directionToUpdate is the direction vector to update with the result
  16007. * @param particle is the particle we are computed the direction for
  16008. * @param isLocal defines if the direction should be set in local space
  16009. */
  16010. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16011. /**
  16012. * Called by the particle System when the position is computed for the created particle.
  16013. * @param worldMatrix is the world matrix of the particle system
  16014. * @param positionToUpdate is the position vector to update with the result
  16015. * @param particle is the particle we are computed the position for
  16016. * @param isLocal defines if the position should be set in local space
  16017. */
  16018. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16019. /**
  16020. * Clones the current emitter and returns a copy of it
  16021. * @returns the new emitter
  16022. */
  16023. clone(): HemisphericParticleEmitter;
  16024. /**
  16025. * Called by the GPUParticleSystem to setup the update shader
  16026. * @param effect defines the update shader
  16027. */
  16028. applyToShader(effect: Effect): void;
  16029. /**
  16030. * Returns a string to use to update the GPU particles update shader
  16031. * @returns a string containng the defines string
  16032. */
  16033. getEffectDefines(): string;
  16034. /**
  16035. * Returns the string "HemisphericParticleEmitter"
  16036. * @returns a string containing the class name
  16037. */
  16038. getClassName(): string;
  16039. /**
  16040. * Serializes the particle system to a JSON object.
  16041. * @returns the JSON object
  16042. */
  16043. serialize(): any;
  16044. /**
  16045. * Parse properties from a JSON object
  16046. * @param serializationObject defines the JSON object
  16047. */
  16048. parse(serializationObject: any): void;
  16049. }
  16050. }
  16051. declare module BABYLON {
  16052. /**
  16053. * Particle emitter emitting particles from a point.
  16054. * It emits the particles randomly between 2 given directions.
  16055. */
  16056. export class PointParticleEmitter implements IParticleEmitterType {
  16057. /**
  16058. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16059. */
  16060. direction1: Vector3;
  16061. /**
  16062. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16063. */
  16064. direction2: Vector3;
  16065. /**
  16066. * Creates a new instance PointParticleEmitter
  16067. */
  16068. constructor();
  16069. /**
  16070. * Called by the particle System when the direction is computed for the created particle.
  16071. * @param worldMatrix is the world matrix of the particle system
  16072. * @param directionToUpdate is the direction vector to update with the result
  16073. * @param particle is the particle we are computed the direction for
  16074. * @param isLocal defines if the direction should be set in local space
  16075. */
  16076. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16077. /**
  16078. * Called by the particle System when the position is computed for the created particle.
  16079. * @param worldMatrix is the world matrix of the particle system
  16080. * @param positionToUpdate is the position vector to update with the result
  16081. * @param particle is the particle we are computed the position for
  16082. * @param isLocal defines if the position should be set in local space
  16083. */
  16084. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16085. /**
  16086. * Clones the current emitter and returns a copy of it
  16087. * @returns the new emitter
  16088. */
  16089. clone(): PointParticleEmitter;
  16090. /**
  16091. * Called by the GPUParticleSystem to setup the update shader
  16092. * @param effect defines the update shader
  16093. */
  16094. applyToShader(effect: Effect): void;
  16095. /**
  16096. * Returns a string to use to update the GPU particles update shader
  16097. * @returns a string containng the defines string
  16098. */
  16099. getEffectDefines(): string;
  16100. /**
  16101. * Returns the string "PointParticleEmitter"
  16102. * @returns a string containing the class name
  16103. */
  16104. getClassName(): string;
  16105. /**
  16106. * Serializes the particle system to a JSON object.
  16107. * @returns the JSON object
  16108. */
  16109. serialize(): any;
  16110. /**
  16111. * Parse properties from a JSON object
  16112. * @param serializationObject defines the JSON object
  16113. */
  16114. parse(serializationObject: any): void;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. /**
  16119. * Particle emitter emitting particles from the inside of a sphere.
  16120. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16121. */
  16122. export class SphereParticleEmitter implements IParticleEmitterType {
  16123. /**
  16124. * The radius of the emission sphere.
  16125. */
  16126. radius: number;
  16127. /**
  16128. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16129. */
  16130. radiusRange: number;
  16131. /**
  16132. * How much to randomize the particle direction [0-1].
  16133. */
  16134. directionRandomizer: number;
  16135. /**
  16136. * Creates a new instance SphereParticleEmitter
  16137. * @param radius the radius of the emission sphere (1 by default)
  16138. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16139. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16140. */
  16141. constructor(
  16142. /**
  16143. * The radius of the emission sphere.
  16144. */
  16145. radius?: number,
  16146. /**
  16147. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16148. */
  16149. radiusRange?: number,
  16150. /**
  16151. * How much to randomize the particle direction [0-1].
  16152. */
  16153. directionRandomizer?: number);
  16154. /**
  16155. * Called by the particle System when the direction is computed for the created particle.
  16156. * @param worldMatrix is the world matrix of the particle system
  16157. * @param directionToUpdate is the direction vector to update with the result
  16158. * @param particle is the particle we are computed the direction for
  16159. * @param isLocal defines if the direction should be set in local space
  16160. */
  16161. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16162. /**
  16163. * Called by the particle System when the position is computed for the created particle.
  16164. * @param worldMatrix is the world matrix of the particle system
  16165. * @param positionToUpdate is the position vector to update with the result
  16166. * @param particle is the particle we are computed the position for
  16167. * @param isLocal defines if the position should be set in local space
  16168. */
  16169. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16170. /**
  16171. * Clones the current emitter and returns a copy of it
  16172. * @returns the new emitter
  16173. */
  16174. clone(): SphereParticleEmitter;
  16175. /**
  16176. * Called by the GPUParticleSystem to setup the update shader
  16177. * @param effect defines the update shader
  16178. */
  16179. applyToShader(effect: Effect): void;
  16180. /**
  16181. * Returns a string to use to update the GPU particles update shader
  16182. * @returns a string containng the defines string
  16183. */
  16184. getEffectDefines(): string;
  16185. /**
  16186. * Returns the string "SphereParticleEmitter"
  16187. * @returns a string containing the class name
  16188. */
  16189. getClassName(): string;
  16190. /**
  16191. * Serializes the particle system to a JSON object.
  16192. * @returns the JSON object
  16193. */
  16194. serialize(): any;
  16195. /**
  16196. * Parse properties from a JSON object
  16197. * @param serializationObject defines the JSON object
  16198. */
  16199. parse(serializationObject: any): void;
  16200. }
  16201. /**
  16202. * Particle emitter emitting particles from the inside of a sphere.
  16203. * It emits the particles randomly between two vectors.
  16204. */
  16205. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16206. /**
  16207. * The min limit of the emission direction.
  16208. */
  16209. direction1: Vector3;
  16210. /**
  16211. * The max limit of the emission direction.
  16212. */
  16213. direction2: Vector3;
  16214. /**
  16215. * Creates a new instance SphereDirectedParticleEmitter
  16216. * @param radius the radius of the emission sphere (1 by default)
  16217. * @param direction1 the min limit of the emission direction (up vector by default)
  16218. * @param direction2 the max limit of the emission direction (up vector by default)
  16219. */
  16220. constructor(radius?: number,
  16221. /**
  16222. * The min limit of the emission direction.
  16223. */
  16224. direction1?: Vector3,
  16225. /**
  16226. * The max limit of the emission direction.
  16227. */
  16228. direction2?: Vector3);
  16229. /**
  16230. * Called by the particle System when the direction is computed for the created particle.
  16231. * @param worldMatrix is the world matrix of the particle system
  16232. * @param directionToUpdate is the direction vector to update with the result
  16233. * @param particle is the particle we are computed the direction for
  16234. */
  16235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16236. /**
  16237. * Clones the current emitter and returns a copy of it
  16238. * @returns the new emitter
  16239. */
  16240. clone(): SphereDirectedParticleEmitter;
  16241. /**
  16242. * Called by the GPUParticleSystem to setup the update shader
  16243. * @param effect defines the update shader
  16244. */
  16245. applyToShader(effect: Effect): void;
  16246. /**
  16247. * Returns a string to use to update the GPU particles update shader
  16248. * @returns a string containng the defines string
  16249. */
  16250. getEffectDefines(): string;
  16251. /**
  16252. * Returns the string "SphereDirectedParticleEmitter"
  16253. * @returns a string containing the class name
  16254. */
  16255. getClassName(): string;
  16256. /**
  16257. * Serializes the particle system to a JSON object.
  16258. * @returns the JSON object
  16259. */
  16260. serialize(): any;
  16261. /**
  16262. * Parse properties from a JSON object
  16263. * @param serializationObject defines the JSON object
  16264. */
  16265. parse(serializationObject: any): void;
  16266. }
  16267. }
  16268. declare module BABYLON {
  16269. /**
  16270. * Particle emitter emitting particles from a custom list of positions.
  16271. */
  16272. export class CustomParticleEmitter implements IParticleEmitterType {
  16273. /**
  16274. * Gets or sets the position generator that will create the inital position of each particle.
  16275. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16276. */
  16277. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16278. /**
  16279. * Gets or sets the destination generator that will create the final destination of each particle.
  16280. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16281. */
  16282. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16283. /**
  16284. * Creates a new instance CustomParticleEmitter
  16285. */
  16286. constructor();
  16287. /**
  16288. * Called by the particle System when the direction is computed for the created particle.
  16289. * @param worldMatrix is the world matrix of the particle system
  16290. * @param directionToUpdate is the direction vector to update with the result
  16291. * @param particle is the particle we are computed the direction for
  16292. * @param isLocal defines if the direction should be set in local space
  16293. */
  16294. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16295. /**
  16296. * Called by the particle System when the position is computed for the created particle.
  16297. * @param worldMatrix is the world matrix of the particle system
  16298. * @param positionToUpdate is the position vector to update with the result
  16299. * @param particle is the particle we are computed the position for
  16300. * @param isLocal defines if the position should be set in local space
  16301. */
  16302. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16303. /**
  16304. * Clones the current emitter and returns a copy of it
  16305. * @returns the new emitter
  16306. */
  16307. clone(): CustomParticleEmitter;
  16308. /**
  16309. * Called by the GPUParticleSystem to setup the update shader
  16310. * @param effect defines the update shader
  16311. */
  16312. applyToShader(effect: Effect): void;
  16313. /**
  16314. * Returns a string to use to update the GPU particles update shader
  16315. * @returns a string containng the defines string
  16316. */
  16317. getEffectDefines(): string;
  16318. /**
  16319. * Returns the string "PointParticleEmitter"
  16320. * @returns a string containing the class name
  16321. */
  16322. getClassName(): string;
  16323. /**
  16324. * Serializes the particle system to a JSON object.
  16325. * @returns the JSON object
  16326. */
  16327. serialize(): any;
  16328. /**
  16329. * Parse properties from a JSON object
  16330. * @param serializationObject defines the JSON object
  16331. */
  16332. parse(serializationObject: any): void;
  16333. }
  16334. }
  16335. declare module BABYLON {
  16336. /**
  16337. * Particle emitter emitting particles from the inside of a box.
  16338. * It emits the particles randomly between 2 given directions.
  16339. */
  16340. export class MeshParticleEmitter implements IParticleEmitterType {
  16341. private _indices;
  16342. private _positions;
  16343. private _normals;
  16344. private _storedNormal;
  16345. private _mesh;
  16346. /**
  16347. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16348. */
  16349. direction1: Vector3;
  16350. /**
  16351. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16352. */
  16353. direction2: Vector3;
  16354. /**
  16355. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16356. */
  16357. useMeshNormalsForDirection: boolean;
  16358. /** Defines the mesh to use as source */
  16359. get mesh(): Nullable<AbstractMesh>;
  16360. set mesh(value: Nullable<AbstractMesh>);
  16361. /**
  16362. * Creates a new instance MeshParticleEmitter
  16363. * @param mesh defines the mesh to use as source
  16364. */
  16365. constructor(mesh?: Nullable<AbstractMesh>);
  16366. /**
  16367. * Called by the particle System when the direction is computed for the created particle.
  16368. * @param worldMatrix is the world matrix of the particle system
  16369. * @param directionToUpdate is the direction vector to update with the result
  16370. * @param particle is the particle we are computed the direction for
  16371. * @param isLocal defines if the direction should be set in local space
  16372. */
  16373. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16374. /**
  16375. * Called by the particle System when the position is computed for the created particle.
  16376. * @param worldMatrix is the world matrix of the particle system
  16377. * @param positionToUpdate is the position vector to update with the result
  16378. * @param particle is the particle we are computed the position for
  16379. * @param isLocal defines if the position should be set in local space
  16380. */
  16381. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16382. /**
  16383. * Clones the current emitter and returns a copy of it
  16384. * @returns the new emitter
  16385. */
  16386. clone(): MeshParticleEmitter;
  16387. /**
  16388. * Called by the GPUParticleSystem to setup the update shader
  16389. * @param effect defines the update shader
  16390. */
  16391. applyToShader(effect: Effect): void;
  16392. /**
  16393. * Returns a string to use to update the GPU particles update shader
  16394. * @returns a string containng the defines string
  16395. */
  16396. getEffectDefines(): string;
  16397. /**
  16398. * Returns the string "BoxParticleEmitter"
  16399. * @returns a string containing the class name
  16400. */
  16401. getClassName(): string;
  16402. /**
  16403. * Serializes the particle system to a JSON object.
  16404. * @returns the JSON object
  16405. */
  16406. serialize(): any;
  16407. /**
  16408. * Parse properties from a JSON object
  16409. * @param serializationObject defines the JSON object
  16410. * @param scene defines the hosting scene
  16411. */
  16412. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16413. }
  16414. }
  16415. declare module BABYLON {
  16416. /**
  16417. * Interface representing a particle system in Babylon.js.
  16418. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16419. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16420. */
  16421. export interface IParticleSystem {
  16422. /**
  16423. * List of animations used by the particle system.
  16424. */
  16425. animations: Animation[];
  16426. /**
  16427. * The id of the Particle system.
  16428. */
  16429. id: string;
  16430. /**
  16431. * The name of the Particle system.
  16432. */
  16433. name: string;
  16434. /**
  16435. * The emitter represents the Mesh or position we are attaching the particle system to.
  16436. */
  16437. emitter: Nullable<AbstractMesh | Vector3>;
  16438. /**
  16439. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16440. */
  16441. isBillboardBased: boolean;
  16442. /**
  16443. * The rendering group used by the Particle system to chose when to render.
  16444. */
  16445. renderingGroupId: number;
  16446. /**
  16447. * The layer mask we are rendering the particles through.
  16448. */
  16449. layerMask: number;
  16450. /**
  16451. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16452. */
  16453. updateSpeed: number;
  16454. /**
  16455. * The amount of time the particle system is running (depends of the overall update speed).
  16456. */
  16457. targetStopDuration: number;
  16458. /**
  16459. * The texture used to render each particle. (this can be a spritesheet)
  16460. */
  16461. particleTexture: Nullable<BaseTexture>;
  16462. /**
  16463. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16464. */
  16465. blendMode: number;
  16466. /**
  16467. * Minimum life time of emitting particles.
  16468. */
  16469. minLifeTime: number;
  16470. /**
  16471. * Maximum life time of emitting particles.
  16472. */
  16473. maxLifeTime: number;
  16474. /**
  16475. * Minimum Size of emitting particles.
  16476. */
  16477. minSize: number;
  16478. /**
  16479. * Maximum Size of emitting particles.
  16480. */
  16481. maxSize: number;
  16482. /**
  16483. * Minimum scale of emitting particles on X axis.
  16484. */
  16485. minScaleX: number;
  16486. /**
  16487. * Maximum scale of emitting particles on X axis.
  16488. */
  16489. maxScaleX: number;
  16490. /**
  16491. * Minimum scale of emitting particles on Y axis.
  16492. */
  16493. minScaleY: number;
  16494. /**
  16495. * Maximum scale of emitting particles on Y axis.
  16496. */
  16497. maxScaleY: number;
  16498. /**
  16499. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16500. */
  16501. color1: Color4;
  16502. /**
  16503. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16504. */
  16505. color2: Color4;
  16506. /**
  16507. * Color the particle will have at the end of its lifetime.
  16508. */
  16509. colorDead: Color4;
  16510. /**
  16511. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16512. */
  16513. emitRate: number;
  16514. /**
  16515. * You can use gravity if you want to give an orientation to your particles.
  16516. */
  16517. gravity: Vector3;
  16518. /**
  16519. * Minimum power of emitting particles.
  16520. */
  16521. minEmitPower: number;
  16522. /**
  16523. * Maximum power of emitting particles.
  16524. */
  16525. maxEmitPower: number;
  16526. /**
  16527. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16528. */
  16529. minAngularSpeed: number;
  16530. /**
  16531. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16532. */
  16533. maxAngularSpeed: number;
  16534. /**
  16535. * Gets or sets the minimal initial rotation in radians.
  16536. */
  16537. minInitialRotation: number;
  16538. /**
  16539. * Gets or sets the maximal initial rotation in radians.
  16540. */
  16541. maxInitialRotation: number;
  16542. /**
  16543. * The particle emitter type defines the emitter used by the particle system.
  16544. * It can be for example box, sphere, or cone...
  16545. */
  16546. particleEmitterType: Nullable<IParticleEmitterType>;
  16547. /**
  16548. * Defines the delay in milliseconds before starting the system (0 by default)
  16549. */
  16550. startDelay: number;
  16551. /**
  16552. * 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
  16553. */
  16554. preWarmCycles: number;
  16555. /**
  16556. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16557. */
  16558. preWarmStepOffset: number;
  16559. /**
  16560. * 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)
  16561. */
  16562. spriteCellChangeSpeed: number;
  16563. /**
  16564. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16565. */
  16566. startSpriteCellID: number;
  16567. /**
  16568. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16569. */
  16570. endSpriteCellID: number;
  16571. /**
  16572. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16573. */
  16574. spriteCellWidth: number;
  16575. /**
  16576. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16577. */
  16578. spriteCellHeight: number;
  16579. /**
  16580. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16581. */
  16582. spriteRandomStartCell: boolean;
  16583. /**
  16584. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16585. */
  16586. isAnimationSheetEnabled: boolean;
  16587. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16588. translationPivot: Vector2;
  16589. /**
  16590. * Gets or sets a texture used to add random noise to particle positions
  16591. */
  16592. noiseTexture: Nullable<BaseTexture>;
  16593. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16594. noiseStrength: Vector3;
  16595. /**
  16596. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16597. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16598. */
  16599. billboardMode: number;
  16600. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16601. limitVelocityDamping: number;
  16602. /**
  16603. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16604. */
  16605. beginAnimationOnStart: boolean;
  16606. /**
  16607. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16608. */
  16609. beginAnimationFrom: number;
  16610. /**
  16611. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16612. */
  16613. beginAnimationTo: number;
  16614. /**
  16615. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16616. */
  16617. beginAnimationLoop: boolean;
  16618. /**
  16619. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16620. */
  16621. disposeOnStop: boolean;
  16622. /**
  16623. * Specifies if the particles are updated in emitter local space or world space
  16624. */
  16625. isLocal: boolean;
  16626. /** Snippet ID if the particle system was created from the snippet server */
  16627. snippetId: string;
  16628. /** Gets or sets a matrix to use to compute projection */
  16629. defaultProjectionMatrix: Matrix;
  16630. /**
  16631. * Gets the maximum number of particles active at the same time.
  16632. * @returns The max number of active particles.
  16633. */
  16634. getCapacity(): number;
  16635. /**
  16636. * Gets the number of particles active at the same time.
  16637. * @returns The number of active particles.
  16638. */
  16639. getActiveCount(): number;
  16640. /**
  16641. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16642. * @returns True if it has been started, otherwise false.
  16643. */
  16644. isStarted(): boolean;
  16645. /**
  16646. * Animates the particle system for this frame.
  16647. */
  16648. animate(): void;
  16649. /**
  16650. * Renders the particle system in its current state.
  16651. * @returns the current number of particles
  16652. */
  16653. render(): number;
  16654. /**
  16655. * Dispose the particle system and frees its associated resources.
  16656. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16657. */
  16658. dispose(disposeTexture?: boolean): void;
  16659. /**
  16660. * An event triggered when the system is disposed
  16661. */
  16662. onDisposeObservable: Observable<IParticleSystem>;
  16663. /**
  16664. * An event triggered when the system is stopped
  16665. */
  16666. onStoppedObservable: Observable<IParticleSystem>;
  16667. /**
  16668. * Clones the particle system.
  16669. * @param name The name of the cloned object
  16670. * @param newEmitter The new emitter to use
  16671. * @returns the cloned particle system
  16672. */
  16673. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16674. /**
  16675. * Serializes the particle system to a JSON object
  16676. * @param serializeTexture defines if the texture must be serialized as well
  16677. * @returns the JSON object
  16678. */
  16679. serialize(serializeTexture: boolean): any;
  16680. /**
  16681. * Rebuild the particle system
  16682. */
  16683. rebuild(): void;
  16684. /** Force the system to rebuild all gradients that need to be resync */
  16685. forceRefreshGradients(): void;
  16686. /**
  16687. * Starts the particle system and begins to emit
  16688. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16689. */
  16690. start(delay?: number): void;
  16691. /**
  16692. * Stops the particle system.
  16693. */
  16694. stop(): void;
  16695. /**
  16696. * Remove all active particles
  16697. */
  16698. reset(): void;
  16699. /**
  16700. * Gets a boolean indicating that the system is stopping
  16701. * @returns true if the system is currently stopping
  16702. */
  16703. isStopping(): boolean;
  16704. /**
  16705. * Is this system ready to be used/rendered
  16706. * @return true if the system is ready
  16707. */
  16708. isReady(): boolean;
  16709. /**
  16710. * Returns the string "ParticleSystem"
  16711. * @returns a string containing the class name
  16712. */
  16713. getClassName(): string;
  16714. /**
  16715. * Gets the custom effect used to render the particles
  16716. * @param blendMode Blend mode for which the effect should be retrieved
  16717. * @returns The effect
  16718. */
  16719. getCustomEffect(blendMode: number): Nullable<Effect>;
  16720. /**
  16721. * Sets the custom effect used to render the particles
  16722. * @param effect The effect to set
  16723. * @param blendMode Blend mode for which the effect should be set
  16724. */
  16725. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  16726. /**
  16727. * Fill the defines array according to the current settings of the particle system
  16728. * @param defines Array to be updated
  16729. * @param blendMode blend mode to take into account when updating the array
  16730. */
  16731. fillDefines(defines: Array<string>, blendMode: number): void;
  16732. /**
  16733. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16734. * @param uniforms Uniforms array to fill
  16735. * @param attributes Attributes array to fill
  16736. * @param samplers Samplers array to fill
  16737. */
  16738. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16739. /**
  16740. * Observable that will be called just before the particles are drawn
  16741. */
  16742. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  16743. /**
  16744. * Gets the name of the particle vertex shader
  16745. */
  16746. vertexShaderName: string;
  16747. /**
  16748. * Adds a new color gradient
  16749. * @param gradient defines the gradient to use (between 0 and 1)
  16750. * @param color1 defines the color to affect to the specified gradient
  16751. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16752. * @returns the current particle system
  16753. */
  16754. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16755. /**
  16756. * Remove a specific color gradient
  16757. * @param gradient defines the gradient to remove
  16758. * @returns the current particle system
  16759. */
  16760. removeColorGradient(gradient: number): IParticleSystem;
  16761. /**
  16762. * Adds a new size gradient
  16763. * @param gradient defines the gradient to use (between 0 and 1)
  16764. * @param factor defines the size factor to affect to the specified gradient
  16765. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16766. * @returns the current particle system
  16767. */
  16768. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16769. /**
  16770. * Remove a specific size gradient
  16771. * @param gradient defines the gradient to remove
  16772. * @returns the current particle system
  16773. */
  16774. removeSizeGradient(gradient: number): IParticleSystem;
  16775. /**
  16776. * Gets the current list of color gradients.
  16777. * You must use addColorGradient and removeColorGradient to udpate this list
  16778. * @returns the list of color gradients
  16779. */
  16780. getColorGradients(): Nullable<Array<ColorGradient>>;
  16781. /**
  16782. * Gets the current list of size gradients.
  16783. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16784. * @returns the list of size gradients
  16785. */
  16786. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16787. /**
  16788. * Gets the current list of angular speed gradients.
  16789. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16790. * @returns the list of angular speed gradients
  16791. */
  16792. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16793. /**
  16794. * Adds a new angular speed gradient
  16795. * @param gradient defines the gradient to use (between 0 and 1)
  16796. * @param factor defines the angular speed to affect to the specified gradient
  16797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16798. * @returns the current particle system
  16799. */
  16800. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16801. /**
  16802. * Remove a specific angular speed gradient
  16803. * @param gradient defines the gradient to remove
  16804. * @returns the current particle system
  16805. */
  16806. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16807. /**
  16808. * Gets the current list of velocity gradients.
  16809. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16810. * @returns the list of velocity gradients
  16811. */
  16812. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16813. /**
  16814. * Adds a new velocity gradient
  16815. * @param gradient defines the gradient to use (between 0 and 1)
  16816. * @param factor defines the velocity to affect to the specified gradient
  16817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16818. * @returns the current particle system
  16819. */
  16820. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16821. /**
  16822. * Remove a specific velocity gradient
  16823. * @param gradient defines the gradient to remove
  16824. * @returns the current particle system
  16825. */
  16826. removeVelocityGradient(gradient: number): IParticleSystem;
  16827. /**
  16828. * Gets the current list of limit velocity gradients.
  16829. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16830. * @returns the list of limit velocity gradients
  16831. */
  16832. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16833. /**
  16834. * Adds a new limit velocity gradient
  16835. * @param gradient defines the gradient to use (between 0 and 1)
  16836. * @param factor defines the limit velocity to affect to the specified gradient
  16837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16838. * @returns the current particle system
  16839. */
  16840. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16841. /**
  16842. * Remove a specific limit velocity gradient
  16843. * @param gradient defines the gradient to remove
  16844. * @returns the current particle system
  16845. */
  16846. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16847. /**
  16848. * Adds a new drag gradient
  16849. * @param gradient defines the gradient to use (between 0 and 1)
  16850. * @param factor defines the drag to affect to the specified gradient
  16851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16852. * @returns the current particle system
  16853. */
  16854. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16855. /**
  16856. * Remove a specific drag gradient
  16857. * @param gradient defines the gradient to remove
  16858. * @returns the current particle system
  16859. */
  16860. removeDragGradient(gradient: number): IParticleSystem;
  16861. /**
  16862. * Gets the current list of drag gradients.
  16863. * You must use addDragGradient and removeDragGradient to udpate this list
  16864. * @returns the list of drag gradients
  16865. */
  16866. getDragGradients(): Nullable<Array<FactorGradient>>;
  16867. /**
  16868. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16869. * @param gradient defines the gradient to use (between 0 and 1)
  16870. * @param factor defines the emit rate to affect to the specified gradient
  16871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16872. * @returns the current particle system
  16873. */
  16874. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16875. /**
  16876. * Remove a specific emit rate gradient
  16877. * @param gradient defines the gradient to remove
  16878. * @returns the current particle system
  16879. */
  16880. removeEmitRateGradient(gradient: number): IParticleSystem;
  16881. /**
  16882. * Gets the current list of emit rate gradients.
  16883. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16884. * @returns the list of emit rate gradients
  16885. */
  16886. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16887. /**
  16888. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16889. * @param gradient defines the gradient to use (between 0 and 1)
  16890. * @param factor defines the start size to affect to the specified gradient
  16891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16892. * @returns the current particle system
  16893. */
  16894. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16895. /**
  16896. * Remove a specific start size gradient
  16897. * @param gradient defines the gradient to remove
  16898. * @returns the current particle system
  16899. */
  16900. removeStartSizeGradient(gradient: number): IParticleSystem;
  16901. /**
  16902. * Gets the current list of start size gradients.
  16903. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16904. * @returns the list of start size gradients
  16905. */
  16906. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16907. /**
  16908. * Adds a new life time gradient
  16909. * @param gradient defines the gradient to use (between 0 and 1)
  16910. * @param factor defines the life time factor to affect to the specified gradient
  16911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16912. * @returns the current particle system
  16913. */
  16914. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16915. /**
  16916. * Remove a specific life time gradient
  16917. * @param gradient defines the gradient to remove
  16918. * @returns the current particle system
  16919. */
  16920. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16921. /**
  16922. * Gets the current list of life time gradients.
  16923. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16924. * @returns the list of life time gradients
  16925. */
  16926. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16927. /**
  16928. * Gets the current list of color gradients.
  16929. * You must use addColorGradient and removeColorGradient to udpate this list
  16930. * @returns the list of color gradients
  16931. */
  16932. getColorGradients(): Nullable<Array<ColorGradient>>;
  16933. /**
  16934. * Adds a new ramp gradient used to remap particle colors
  16935. * @param gradient defines the gradient to use (between 0 and 1)
  16936. * @param color defines the color to affect to the specified gradient
  16937. * @returns the current particle system
  16938. */
  16939. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16940. /**
  16941. * Gets the current list of ramp gradients.
  16942. * You must use addRampGradient and removeRampGradient to udpate this list
  16943. * @returns the list of ramp gradients
  16944. */
  16945. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16946. /** Gets or sets a boolean indicating that ramp gradients must be used
  16947. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16948. */
  16949. useRampGradients: boolean;
  16950. /**
  16951. * Adds a new color remap gradient
  16952. * @param gradient defines the gradient to use (between 0 and 1)
  16953. * @param min defines the color remap minimal range
  16954. * @param max defines the color remap maximal range
  16955. * @returns the current particle system
  16956. */
  16957. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16958. /**
  16959. * Gets the current list of color remap gradients.
  16960. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16961. * @returns the list of color remap gradients
  16962. */
  16963. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16964. /**
  16965. * Adds a new alpha remap gradient
  16966. * @param gradient defines the gradient to use (between 0 and 1)
  16967. * @param min defines the alpha remap minimal range
  16968. * @param max defines the alpha remap maximal range
  16969. * @returns the current particle system
  16970. */
  16971. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16972. /**
  16973. * Gets the current list of alpha remap gradients.
  16974. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16975. * @returns the list of alpha remap gradients
  16976. */
  16977. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16978. /**
  16979. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16980. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16981. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16982. * @returns the emitter
  16983. */
  16984. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16985. /**
  16986. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16987. * @param radius The radius of the hemisphere to emit from
  16988. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16989. * @returns the emitter
  16990. */
  16991. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16992. /**
  16993. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16994. * @param radius The radius of the sphere to emit from
  16995. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16996. * @returns the emitter
  16997. */
  16998. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16999. /**
  17000. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17001. * @param radius The radius of the sphere to emit from
  17002. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17003. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17004. * @returns the emitter
  17005. */
  17006. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17007. /**
  17008. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17009. * @param radius The radius of the emission cylinder
  17010. * @param height The height of the emission cylinder
  17011. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17012. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17013. * @returns the emitter
  17014. */
  17015. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17016. /**
  17017. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17018. * @param radius The radius of the cylinder to emit from
  17019. * @param height The height of the emission cylinder
  17020. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17021. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17022. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17023. * @returns the emitter
  17024. */
  17025. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17026. /**
  17027. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17028. * @param radius The radius of the cone to emit from
  17029. * @param angle The base angle of the cone
  17030. * @returns the emitter
  17031. */
  17032. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17033. /**
  17034. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17035. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17036. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17037. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17038. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17039. * @returns the emitter
  17040. */
  17041. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17042. /**
  17043. * Get hosting scene
  17044. * @returns the scene
  17045. */
  17046. getScene(): Nullable<Scene>;
  17047. }
  17048. }
  17049. declare module BABYLON {
  17050. /**
  17051. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17052. */
  17053. export class ColorSplitterBlock extends NodeMaterialBlock {
  17054. /**
  17055. * Create a new ColorSplitterBlock
  17056. * @param name defines the block name
  17057. */
  17058. constructor(name: string);
  17059. /**
  17060. * Gets the current class name
  17061. * @returns the class name
  17062. */
  17063. getClassName(): string;
  17064. /**
  17065. * Gets the rgba component (input)
  17066. */
  17067. get rgba(): NodeMaterialConnectionPoint;
  17068. /**
  17069. * Gets the rgb component (input)
  17070. */
  17071. get rgbIn(): NodeMaterialConnectionPoint;
  17072. /**
  17073. * Gets the rgb component (output)
  17074. */
  17075. get rgbOut(): NodeMaterialConnectionPoint;
  17076. /**
  17077. * Gets the r component (output)
  17078. */
  17079. get r(): NodeMaterialConnectionPoint;
  17080. /**
  17081. * Gets the g component (output)
  17082. */
  17083. get g(): NodeMaterialConnectionPoint;
  17084. /**
  17085. * Gets the b component (output)
  17086. */
  17087. get b(): NodeMaterialConnectionPoint;
  17088. /**
  17089. * Gets the a component (output)
  17090. */
  17091. get a(): NodeMaterialConnectionPoint;
  17092. protected _inputRename(name: string): string;
  17093. protected _outputRename(name: string): string;
  17094. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17095. }
  17096. }
  17097. declare module BABYLON {
  17098. /**
  17099. * Operations supported by the Trigonometry block
  17100. */
  17101. export enum TrigonometryBlockOperations {
  17102. /** Cos */
  17103. Cos = 0,
  17104. /** Sin */
  17105. Sin = 1,
  17106. /** Abs */
  17107. Abs = 2,
  17108. /** Exp */
  17109. Exp = 3,
  17110. /** Exp2 */
  17111. Exp2 = 4,
  17112. /** Round */
  17113. Round = 5,
  17114. /** Floor */
  17115. Floor = 6,
  17116. /** Ceiling */
  17117. Ceiling = 7,
  17118. /** Square root */
  17119. Sqrt = 8,
  17120. /** Log */
  17121. Log = 9,
  17122. /** Tangent */
  17123. Tan = 10,
  17124. /** Arc tangent */
  17125. ArcTan = 11,
  17126. /** Arc cosinus */
  17127. ArcCos = 12,
  17128. /** Arc sinus */
  17129. ArcSin = 13,
  17130. /** Fraction */
  17131. Fract = 14,
  17132. /** Sign */
  17133. Sign = 15,
  17134. /** To radians (from degrees) */
  17135. Radians = 16,
  17136. /** To degrees (from radians) */
  17137. Degrees = 17
  17138. }
  17139. /**
  17140. * Block used to apply trigonometry operation to floats
  17141. */
  17142. export class TrigonometryBlock extends NodeMaterialBlock {
  17143. /**
  17144. * Gets or sets the operation applied by the block
  17145. */
  17146. operation: TrigonometryBlockOperations;
  17147. /**
  17148. * Creates a new TrigonometryBlock
  17149. * @param name defines the block name
  17150. */
  17151. constructor(name: string);
  17152. /**
  17153. * Gets the current class name
  17154. * @returns the class name
  17155. */
  17156. getClassName(): string;
  17157. /**
  17158. * Gets the input component
  17159. */
  17160. get input(): NodeMaterialConnectionPoint;
  17161. /**
  17162. * Gets the output component
  17163. */
  17164. get output(): NodeMaterialConnectionPoint;
  17165. protected _buildBlock(state: NodeMaterialBuildState): this;
  17166. serialize(): any;
  17167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17168. protected _dumpPropertiesCode(): string;
  17169. }
  17170. }
  17171. declare module BABYLON {
  17172. /**
  17173. * Interface used to configure the node material editor
  17174. */
  17175. export interface INodeMaterialEditorOptions {
  17176. /** Define the URl to load node editor script */
  17177. editorURL?: string;
  17178. }
  17179. /** @hidden */
  17180. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17181. NORMAL: boolean;
  17182. TANGENT: boolean;
  17183. UV1: boolean;
  17184. /** BONES */
  17185. NUM_BONE_INFLUENCERS: number;
  17186. BonesPerMesh: number;
  17187. BONETEXTURE: boolean;
  17188. /** MORPH TARGETS */
  17189. MORPHTARGETS: boolean;
  17190. MORPHTARGETS_NORMAL: boolean;
  17191. MORPHTARGETS_TANGENT: boolean;
  17192. MORPHTARGETS_UV: boolean;
  17193. NUM_MORPH_INFLUENCERS: number;
  17194. /** IMAGE PROCESSING */
  17195. IMAGEPROCESSING: boolean;
  17196. VIGNETTE: boolean;
  17197. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17198. VIGNETTEBLENDMODEOPAQUE: boolean;
  17199. TONEMAPPING: boolean;
  17200. TONEMAPPING_ACES: boolean;
  17201. CONTRAST: boolean;
  17202. EXPOSURE: boolean;
  17203. COLORCURVES: boolean;
  17204. COLORGRADING: boolean;
  17205. COLORGRADING3D: boolean;
  17206. SAMPLER3DGREENDEPTH: boolean;
  17207. SAMPLER3DBGRMAP: boolean;
  17208. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17209. /** MISC. */
  17210. BUMPDIRECTUV: number;
  17211. constructor();
  17212. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17213. }
  17214. /**
  17215. * Class used to configure NodeMaterial
  17216. */
  17217. export interface INodeMaterialOptions {
  17218. /**
  17219. * Defines if blocks should emit comments
  17220. */
  17221. emitComments: boolean;
  17222. }
  17223. /**
  17224. * Class used to create a node based material built by assembling shader blocks
  17225. */
  17226. export class NodeMaterial extends PushMaterial {
  17227. private static _BuildIdGenerator;
  17228. private _options;
  17229. private _vertexCompilationState;
  17230. private _fragmentCompilationState;
  17231. private _sharedData;
  17232. private _buildId;
  17233. private _buildWasSuccessful;
  17234. private _cachedWorldViewMatrix;
  17235. private _cachedWorldViewProjectionMatrix;
  17236. private _optimizers;
  17237. private _animationFrame;
  17238. /** Define the Url to load node editor script */
  17239. static EditorURL: string;
  17240. /** Define the Url to load snippets */
  17241. static SnippetUrl: string;
  17242. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17243. static IgnoreTexturesAtLoadTime: boolean;
  17244. private BJSNODEMATERIALEDITOR;
  17245. /** Get the inspector from bundle or global */
  17246. private _getGlobalNodeMaterialEditor;
  17247. /**
  17248. * Snippet ID if the material was created from the snippet server
  17249. */
  17250. snippetId: string;
  17251. /**
  17252. * Gets or sets data used by visual editor
  17253. * @see https://nme.babylonjs.com
  17254. */
  17255. editorData: any;
  17256. /**
  17257. * 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)
  17258. */
  17259. ignoreAlpha: boolean;
  17260. /**
  17261. * Defines the maximum number of lights that can be used in the material
  17262. */
  17263. maxSimultaneousLights: number;
  17264. /**
  17265. * Observable raised when the material is built
  17266. */
  17267. onBuildObservable: Observable<NodeMaterial>;
  17268. /**
  17269. * Gets or sets the root nodes of the material vertex shader
  17270. */
  17271. _vertexOutputNodes: NodeMaterialBlock[];
  17272. /**
  17273. * Gets or sets the root nodes of the material fragment (pixel) shader
  17274. */
  17275. _fragmentOutputNodes: NodeMaterialBlock[];
  17276. /** Gets or sets options to control the node material overall behavior */
  17277. get options(): INodeMaterialOptions;
  17278. set options(options: INodeMaterialOptions);
  17279. /**
  17280. * Default configuration related to image processing available in the standard Material.
  17281. */
  17282. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17283. /**
  17284. * Gets the image processing configuration used either in this material.
  17285. */
  17286. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17287. /**
  17288. * Sets the Default image processing configuration used either in the this material.
  17289. *
  17290. * If sets to null, the scene one is in use.
  17291. */
  17292. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17293. /**
  17294. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17295. */
  17296. attachedBlocks: NodeMaterialBlock[];
  17297. /**
  17298. * Specifies the mode of the node material
  17299. * @hidden
  17300. */
  17301. _mode: NodeMaterialModes;
  17302. /**
  17303. * Gets the mode property
  17304. */
  17305. get mode(): NodeMaterialModes;
  17306. /**
  17307. * A free comment about the material
  17308. */
  17309. comment: string;
  17310. /**
  17311. * Create a new node based material
  17312. * @param name defines the material name
  17313. * @param scene defines the hosting scene
  17314. * @param options defines creation option
  17315. */
  17316. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17317. /**
  17318. * Gets the current class name of the material e.g. "NodeMaterial"
  17319. * @returns the class name
  17320. */
  17321. getClassName(): string;
  17322. /**
  17323. * Keep track of the image processing observer to allow dispose and replace.
  17324. */
  17325. private _imageProcessingObserver;
  17326. /**
  17327. * Attaches a new image processing configuration to the Standard Material.
  17328. * @param configuration
  17329. */
  17330. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17331. /**
  17332. * Get a block by its name
  17333. * @param name defines the name of the block to retrieve
  17334. * @returns the required block or null if not found
  17335. */
  17336. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17337. /**
  17338. * Get a block by its name
  17339. * @param predicate defines the predicate used to find the good candidate
  17340. * @returns the required block or null if not found
  17341. */
  17342. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17343. /**
  17344. * Get an input block by its name
  17345. * @param predicate defines the predicate used to find the good candidate
  17346. * @returns the required input block or null if not found
  17347. */
  17348. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17349. /**
  17350. * Gets the list of input blocks attached to this material
  17351. * @returns an array of InputBlocks
  17352. */
  17353. getInputBlocks(): InputBlock[];
  17354. /**
  17355. * Adds a new optimizer to the list of optimizers
  17356. * @param optimizer defines the optimizers to add
  17357. * @returns the current material
  17358. */
  17359. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17360. /**
  17361. * Remove an optimizer from the list of optimizers
  17362. * @param optimizer defines the optimizers to remove
  17363. * @returns the current material
  17364. */
  17365. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17366. /**
  17367. * Add a new block to the list of output nodes
  17368. * @param node defines the node to add
  17369. * @returns the current material
  17370. */
  17371. addOutputNode(node: NodeMaterialBlock): this;
  17372. /**
  17373. * Remove a block from the list of root nodes
  17374. * @param node defines the node to remove
  17375. * @returns the current material
  17376. */
  17377. removeOutputNode(node: NodeMaterialBlock): this;
  17378. private _addVertexOutputNode;
  17379. private _removeVertexOutputNode;
  17380. private _addFragmentOutputNode;
  17381. private _removeFragmentOutputNode;
  17382. /**
  17383. * Specifies if the material will require alpha blending
  17384. * @returns a boolean specifying if alpha blending is needed
  17385. */
  17386. needAlphaBlending(): boolean;
  17387. /**
  17388. * Specifies if this material should be rendered in alpha test mode
  17389. * @returns a boolean specifying if an alpha test is needed.
  17390. */
  17391. needAlphaTesting(): boolean;
  17392. private _initializeBlock;
  17393. private _resetDualBlocks;
  17394. /**
  17395. * Remove a block from the current node material
  17396. * @param block defines the block to remove
  17397. */
  17398. removeBlock(block: NodeMaterialBlock): void;
  17399. /**
  17400. * Build the material and generates the inner effect
  17401. * @param verbose defines if the build should log activity
  17402. */
  17403. build(verbose?: boolean): void;
  17404. /**
  17405. * Runs an otpimization phase to try to improve the shader code
  17406. */
  17407. optimize(): void;
  17408. private _prepareDefinesForAttributes;
  17409. /**
  17410. * Create a post process from the material
  17411. * @param camera The camera to apply the render pass to.
  17412. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17414. * @param engine The engine which the post process will be applied. (default: current engine)
  17415. * @param reusable If the post process can be reused on the same frame. (default: false)
  17416. * @param textureType Type of textures used when performing the post process. (default: 0)
  17417. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17418. * @returns the post process created
  17419. */
  17420. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17421. /**
  17422. * Create the post process effect from the material
  17423. * @param postProcess The post process to create the effect for
  17424. */
  17425. createEffectForPostProcess(postProcess: PostProcess): void;
  17426. private _createEffectForPostProcess;
  17427. /**
  17428. * Create a new procedural texture based on this node material
  17429. * @param size defines the size of the texture
  17430. * @param scene defines the hosting scene
  17431. * @returns the new procedural texture attached to this node material
  17432. */
  17433. createProceduralTexture(size: number | {
  17434. width: number;
  17435. height: number;
  17436. layers?: number;
  17437. }, scene: Scene): Nullable<ProceduralTexture>;
  17438. private _createEffectForParticles;
  17439. private _checkInternals;
  17440. /**
  17441. * Create the effect to be used as the custom effect for a particle system
  17442. * @param particleSystem Particle system to create the effect for
  17443. * @param onCompiled defines a function to call when the effect creation is successful
  17444. * @param onError defines a function to call when the effect creation has failed
  17445. */
  17446. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17447. private _processDefines;
  17448. /**
  17449. * Get if the submesh is ready to be used and all its information available.
  17450. * Child classes can use it to update shaders
  17451. * @param mesh defines the mesh to check
  17452. * @param subMesh defines which submesh to check
  17453. * @param useInstances specifies that instances should be used
  17454. * @returns a boolean indicating that the submesh is ready or not
  17455. */
  17456. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17457. /**
  17458. * Get a string representing the shaders built by the current node graph
  17459. */
  17460. get compiledShaders(): string;
  17461. /**
  17462. * Binds the world matrix to the material
  17463. * @param world defines the world transformation matrix
  17464. */
  17465. bindOnlyWorldMatrix(world: Matrix): void;
  17466. /**
  17467. * Binds the submesh to this material by preparing the effect and shader to draw
  17468. * @param world defines the world transformation matrix
  17469. * @param mesh defines the mesh containing the submesh
  17470. * @param subMesh defines the submesh to bind the material to
  17471. */
  17472. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17473. /**
  17474. * Gets the active textures from the material
  17475. * @returns an array of textures
  17476. */
  17477. getActiveTextures(): BaseTexture[];
  17478. /**
  17479. * Gets the list of texture blocks
  17480. * @returns an array of texture blocks
  17481. */
  17482. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  17483. /**
  17484. * Specifies if the material uses a texture
  17485. * @param texture defines the texture to check against the material
  17486. * @returns a boolean specifying if the material uses the texture
  17487. */
  17488. hasTexture(texture: BaseTexture): boolean;
  17489. /**
  17490. * Disposes the material
  17491. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17492. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17493. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17494. */
  17495. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17496. /** Creates the node editor window. */
  17497. private _createNodeEditor;
  17498. /**
  17499. * Launch the node material editor
  17500. * @param config Define the configuration of the editor
  17501. * @return a promise fulfilled when the node editor is visible
  17502. */
  17503. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  17504. /**
  17505. * Clear the current material
  17506. */
  17507. clear(): void;
  17508. /**
  17509. * Clear the current material and set it to a default state
  17510. */
  17511. setToDefault(): void;
  17512. /**
  17513. * Clear the current material and set it to a default state for post process
  17514. */
  17515. setToDefaultPostProcess(): void;
  17516. /**
  17517. * Clear the current material and set it to a default state for procedural texture
  17518. */
  17519. setToDefaultProceduralTexture(): void;
  17520. /**
  17521. * Clear the current material and set it to a default state for particle
  17522. */
  17523. setToDefaultParticle(): void;
  17524. /**
  17525. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  17526. * @param url defines the url to load from
  17527. * @returns a promise that will fullfil when the material is fully loaded
  17528. */
  17529. loadAsync(url: string): Promise<void>;
  17530. private _gatherBlocks;
  17531. /**
  17532. * Generate a string containing the code declaration required to create an equivalent of this material
  17533. * @returns a string
  17534. */
  17535. generateCode(): string;
  17536. /**
  17537. * Serializes this material in a JSON representation
  17538. * @returns the serialized material object
  17539. */
  17540. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  17541. private _restoreConnections;
  17542. /**
  17543. * Clear the current graph and load a new one from a serialization object
  17544. * @param source defines the JSON representation of the material
  17545. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17546. * @param merge defines whether or not the source must be merged or replace the current content
  17547. */
  17548. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  17549. /**
  17550. * Makes a duplicate of the current material.
  17551. * @param name - name to use for the new material.
  17552. */
  17553. clone(name: string): NodeMaterial;
  17554. /**
  17555. * Creates a node material from parsed material data
  17556. * @param source defines the JSON representation of the material
  17557. * @param scene defines the hosting scene
  17558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17559. * @returns a new node material
  17560. */
  17561. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  17562. /**
  17563. * Creates a node material from a snippet saved in a remote file
  17564. * @param name defines the name of the material to create
  17565. * @param url defines the url to load from
  17566. * @param scene defines the hosting scene
  17567. * @returns a promise that will resolve to the new node material
  17568. */
  17569. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  17570. /**
  17571. * Creates a node material from a snippet saved by the node material editor
  17572. * @param snippetId defines the snippet to load
  17573. * @param scene defines the hosting scene
  17574. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17575. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  17576. * @returns a promise that will resolve to the new node material
  17577. */
  17578. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  17579. /**
  17580. * Creates a new node material set to default basic configuration
  17581. * @param name defines the name of the material
  17582. * @param scene defines the hosting scene
  17583. * @returns a new NodeMaterial
  17584. */
  17585. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  17586. }
  17587. }
  17588. declare module BABYLON {
  17589. interface ThinEngine {
  17590. /**
  17591. * Unbind a list of render target textures from the webGL context
  17592. * This is used only when drawBuffer extension or webGL2 are active
  17593. * @param textures defines the render target textures to unbind
  17594. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  17595. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  17596. */
  17597. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  17598. /**
  17599. * Create a multi render target texture
  17600. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  17601. * @param size defines the size of the texture
  17602. * @param options defines the creation options
  17603. * @returns the cube texture as an InternalTexture
  17604. */
  17605. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  17606. /**
  17607. * Update the sample count for a given multiple render target texture
  17608. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  17609. * @param textures defines the textures to update
  17610. * @param samples defines the sample count to set
  17611. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  17612. */
  17613. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  17614. /**
  17615. * Select a subsets of attachments to draw to.
  17616. * @param attachments gl attachments
  17617. */
  17618. bindAttachments(attachments: number[]): void;
  17619. /**
  17620. * Creates a layout object to draw/clear on specific textures in a MRT
  17621. * @param textureStatus textureStatus[i] indicates if the i-th is active
  17622. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  17623. */
  17624. buildTextureLayout(textureStatus: boolean[]): number[];
  17625. /**
  17626. * Restores the webgl state to only draw on the main color attachment
  17627. */
  17628. restoreSingleAttachment(): void;
  17629. }
  17630. }
  17631. declare module BABYLON {
  17632. /**
  17633. * Creation options of the multi render target texture.
  17634. */
  17635. export interface IMultiRenderTargetOptions {
  17636. /**
  17637. * Define if the texture needs to create mip maps after render.
  17638. */
  17639. generateMipMaps?: boolean;
  17640. /**
  17641. * Define the types of all the draw buffers we want to create
  17642. */
  17643. types?: number[];
  17644. /**
  17645. * Define the sampling modes of all the draw buffers we want to create
  17646. */
  17647. samplingModes?: number[];
  17648. /**
  17649. * Define if a depth buffer is required
  17650. */
  17651. generateDepthBuffer?: boolean;
  17652. /**
  17653. * Define if a stencil buffer is required
  17654. */
  17655. generateStencilBuffer?: boolean;
  17656. /**
  17657. * Define if a depth texture is required instead of a depth buffer
  17658. */
  17659. generateDepthTexture?: boolean;
  17660. /**
  17661. * Define the number of desired draw buffers
  17662. */
  17663. textureCount?: number;
  17664. /**
  17665. * Define if aspect ratio should be adapted to the texture or stay the scene one
  17666. */
  17667. doNotChangeAspectRatio?: boolean;
  17668. /**
  17669. * Define the default type of the buffers we are creating
  17670. */
  17671. defaultType?: number;
  17672. }
  17673. /**
  17674. * A multi render target, like a render target provides the ability to render to a texture.
  17675. * Unlike the render target, it can render to several draw buffers in one draw.
  17676. * This is specially interesting in deferred rendering or for any effects requiring more than
  17677. * just one color from a single pass.
  17678. */
  17679. export class MultiRenderTarget extends RenderTargetTexture {
  17680. private _internalTextures;
  17681. private _textures;
  17682. private _multiRenderTargetOptions;
  17683. private _count;
  17684. /**
  17685. * Get if draw buffers are currently supported by the used hardware and browser.
  17686. */
  17687. get isSupported(): boolean;
  17688. /**
  17689. * Get the list of textures generated by the multi render target.
  17690. */
  17691. get textures(): Texture[];
  17692. /**
  17693. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  17694. */
  17695. get count(): number;
  17696. /**
  17697. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  17698. */
  17699. get depthTexture(): Texture;
  17700. /**
  17701. * Set the wrapping mode on U of all the textures we are rendering to.
  17702. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17703. */
  17704. set wrapU(wrap: number);
  17705. /**
  17706. * Set the wrapping mode on V of all the textures we are rendering to.
  17707. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17708. */
  17709. set wrapV(wrap: number);
  17710. /**
  17711. * Instantiate a new multi render target texture.
  17712. * A multi render target, like a render target provides the ability to render to a texture.
  17713. * Unlike the render target, it can render to several draw buffers in one draw.
  17714. * This is specially interesting in deferred rendering or for any effects requiring more than
  17715. * just one color from a single pass.
  17716. * @param name Define the name of the texture
  17717. * @param size Define the size of the buffers to render to
  17718. * @param count Define the number of target we are rendering into
  17719. * @param scene Define the scene the texture belongs to
  17720. * @param options Define the options used to create the multi render target
  17721. */
  17722. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  17723. private _initTypes;
  17724. /** @hidden */
  17725. _rebuild(forceFullRebuild?: boolean): void;
  17726. private _createInternalTextures;
  17727. private _createTextures;
  17728. /**
  17729. * Replaces a texture within the MRT.
  17730. * @param texture The new texture to insert in the MRT
  17731. * @param index The index of the texture to replace
  17732. */
  17733. replaceTexture(texture: Texture, index: number): void;
  17734. /**
  17735. * Define the number of samples used if MSAA is enabled.
  17736. */
  17737. get samples(): number;
  17738. set samples(value: number);
  17739. /**
  17740. * Resize all the textures in the multi render target.
  17741. * Be careful as it will recreate all the data in the new texture.
  17742. * @param size Define the new size
  17743. */
  17744. resize(size: any): void;
  17745. /**
  17746. * Changes the number of render targets in this MRT
  17747. * Be careful as it will recreate all the data in the new texture.
  17748. * @param count new texture count
  17749. * @param options Specifies texture types and sampling modes for new textures
  17750. */
  17751. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  17752. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17753. /**
  17754. * Dispose the render targets and their associated resources
  17755. */
  17756. dispose(): void;
  17757. /**
  17758. * Release all the underlying texture used as draw buffers.
  17759. */
  17760. releaseInternalTextures(): void;
  17761. }
  17762. }
  17763. declare module BABYLON {
  17764. /** @hidden */
  17765. export var imageProcessingPixelShader: {
  17766. name: string;
  17767. shader: string;
  17768. };
  17769. }
  17770. declare module BABYLON {
  17771. /**
  17772. * ImageProcessingPostProcess
  17773. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  17774. */
  17775. export class ImageProcessingPostProcess extends PostProcess {
  17776. /**
  17777. * Default configuration related to image processing available in the PBR Material.
  17778. */
  17779. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17780. /**
  17781. * Gets the image processing configuration used either in this material.
  17782. */
  17783. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17784. /**
  17785. * Sets the Default image processing configuration used either in the this material.
  17786. *
  17787. * If sets to null, the scene one is in use.
  17788. */
  17789. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17790. /**
  17791. * Keep track of the image processing observer to allow dispose and replace.
  17792. */
  17793. private _imageProcessingObserver;
  17794. /**
  17795. * Attaches a new image processing configuration to the PBR Material.
  17796. * @param configuration
  17797. */
  17798. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  17799. /**
  17800. * If the post process is supported.
  17801. */
  17802. get isSupported(): boolean;
  17803. /**
  17804. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17805. */
  17806. get colorCurves(): Nullable<ColorCurves>;
  17807. /**
  17808. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17809. */
  17810. set colorCurves(value: Nullable<ColorCurves>);
  17811. /**
  17812. * Gets wether the color curves effect is enabled.
  17813. */
  17814. get colorCurvesEnabled(): boolean;
  17815. /**
  17816. * Sets wether the color curves effect is enabled.
  17817. */
  17818. set colorCurvesEnabled(value: boolean);
  17819. /**
  17820. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17821. */
  17822. get colorGradingTexture(): Nullable<BaseTexture>;
  17823. /**
  17824. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17825. */
  17826. set colorGradingTexture(value: Nullable<BaseTexture>);
  17827. /**
  17828. * Gets wether the color grading effect is enabled.
  17829. */
  17830. get colorGradingEnabled(): boolean;
  17831. /**
  17832. * Gets wether the color grading effect is enabled.
  17833. */
  17834. set colorGradingEnabled(value: boolean);
  17835. /**
  17836. * Gets exposure used in the effect.
  17837. */
  17838. get exposure(): number;
  17839. /**
  17840. * Sets exposure used in the effect.
  17841. */
  17842. set exposure(value: number);
  17843. /**
  17844. * Gets wether tonemapping is enabled or not.
  17845. */
  17846. get toneMappingEnabled(): boolean;
  17847. /**
  17848. * Sets wether tonemapping is enabled or not
  17849. */
  17850. set toneMappingEnabled(value: boolean);
  17851. /**
  17852. * Gets the type of tone mapping effect.
  17853. */
  17854. get toneMappingType(): number;
  17855. /**
  17856. * Sets the type of tone mapping effect.
  17857. */
  17858. set toneMappingType(value: number);
  17859. /**
  17860. * Gets contrast used in the effect.
  17861. */
  17862. get contrast(): number;
  17863. /**
  17864. * Sets contrast used in the effect.
  17865. */
  17866. set contrast(value: number);
  17867. /**
  17868. * Gets Vignette stretch size.
  17869. */
  17870. get vignetteStretch(): number;
  17871. /**
  17872. * Sets Vignette stretch size.
  17873. */
  17874. set vignetteStretch(value: number);
  17875. /**
  17876. * Gets Vignette centre X Offset.
  17877. */
  17878. get vignetteCentreX(): number;
  17879. /**
  17880. * Sets Vignette centre X Offset.
  17881. */
  17882. set vignetteCentreX(value: number);
  17883. /**
  17884. * Gets Vignette centre Y Offset.
  17885. */
  17886. get vignetteCentreY(): number;
  17887. /**
  17888. * Sets Vignette centre Y Offset.
  17889. */
  17890. set vignetteCentreY(value: number);
  17891. /**
  17892. * Gets Vignette weight or intensity of the vignette effect.
  17893. */
  17894. get vignetteWeight(): number;
  17895. /**
  17896. * Sets Vignette weight or intensity of the vignette effect.
  17897. */
  17898. set vignetteWeight(value: number);
  17899. /**
  17900. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17901. * if vignetteEnabled is set to true.
  17902. */
  17903. get vignetteColor(): Color4;
  17904. /**
  17905. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17906. * if vignetteEnabled is set to true.
  17907. */
  17908. set vignetteColor(value: Color4);
  17909. /**
  17910. * Gets Camera field of view used by the Vignette effect.
  17911. */
  17912. get vignetteCameraFov(): number;
  17913. /**
  17914. * Sets Camera field of view used by the Vignette effect.
  17915. */
  17916. set vignetteCameraFov(value: number);
  17917. /**
  17918. * Gets the vignette blend mode allowing different kind of effect.
  17919. */
  17920. get vignetteBlendMode(): number;
  17921. /**
  17922. * Sets the vignette blend mode allowing different kind of effect.
  17923. */
  17924. set vignetteBlendMode(value: number);
  17925. /**
  17926. * Gets wether the vignette effect is enabled.
  17927. */
  17928. get vignetteEnabled(): boolean;
  17929. /**
  17930. * Sets wether the vignette effect is enabled.
  17931. */
  17932. set vignetteEnabled(value: boolean);
  17933. private _fromLinearSpace;
  17934. /**
  17935. * Gets wether the input of the processing is in Gamma or Linear Space.
  17936. */
  17937. get fromLinearSpace(): boolean;
  17938. /**
  17939. * Sets wether the input of the processing is in Gamma or Linear Space.
  17940. */
  17941. set fromLinearSpace(value: boolean);
  17942. /**
  17943. * Defines cache preventing GC.
  17944. */
  17945. private _defines;
  17946. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  17947. /**
  17948. * "ImageProcessingPostProcess"
  17949. * @returns "ImageProcessingPostProcess"
  17950. */
  17951. getClassName(): string;
  17952. /**
  17953. * @hidden
  17954. */
  17955. _updateParameters(): void;
  17956. dispose(camera?: Camera): void;
  17957. }
  17958. }
  17959. declare module BABYLON {
  17960. /**
  17961. * Interface for defining prepass effects in the prepass post-process pipeline
  17962. */
  17963. export interface PrePassEffectConfiguration {
  17964. /**
  17965. * Name of the effect
  17966. */
  17967. name: string;
  17968. /**
  17969. * Post process to attach for this effect
  17970. */
  17971. postProcess?: PostProcess;
  17972. /**
  17973. * Textures required in the MRT
  17974. */
  17975. texturesRequired: number[];
  17976. /**
  17977. * Is the effect enabled
  17978. */
  17979. enabled: boolean;
  17980. /**
  17981. * Disposes the effect configuration
  17982. */
  17983. dispose?: () => void;
  17984. /**
  17985. * Creates the associated post process
  17986. */
  17987. createPostProcess?: () => PostProcess;
  17988. }
  17989. }
  17990. declare module BABYLON {
  17991. /**
  17992. * Options to be used when creating a FresnelParameters.
  17993. */
  17994. export type IFresnelParametersCreationOptions = {
  17995. /**
  17996. * Define the color used on edges (grazing angle)
  17997. */
  17998. leftColor?: Color3;
  17999. /**
  18000. * Define the color used on center
  18001. */
  18002. rightColor?: Color3;
  18003. /**
  18004. * Define bias applied to computed fresnel term
  18005. */
  18006. bias?: number;
  18007. /**
  18008. * Defined the power exponent applied to fresnel term
  18009. */
  18010. power?: number;
  18011. /**
  18012. * Define if the fresnel effect is enable or not.
  18013. */
  18014. isEnabled?: boolean;
  18015. };
  18016. /**
  18017. * Serialized format for FresnelParameters.
  18018. */
  18019. export type IFresnelParametersSerialized = {
  18020. /**
  18021. * Define the color used on edges (grazing angle) [as an array]
  18022. */
  18023. leftColor: number[];
  18024. /**
  18025. * Define the color used on center [as an array]
  18026. */
  18027. rightColor: number[];
  18028. /**
  18029. * Define bias applied to computed fresnel term
  18030. */
  18031. bias: number;
  18032. /**
  18033. * Defined the power exponent applied to fresnel term
  18034. */
  18035. power?: number;
  18036. /**
  18037. * Define if the fresnel effect is enable or not.
  18038. */
  18039. isEnabled: boolean;
  18040. };
  18041. /**
  18042. * This represents all the required information to add a fresnel effect on a material:
  18043. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18044. */
  18045. export class FresnelParameters {
  18046. private _isEnabled;
  18047. /**
  18048. * Define if the fresnel effect is enable or not.
  18049. */
  18050. get isEnabled(): boolean;
  18051. set isEnabled(value: boolean);
  18052. /**
  18053. * Define the color used on edges (grazing angle)
  18054. */
  18055. leftColor: Color3;
  18056. /**
  18057. * Define the color used on center
  18058. */
  18059. rightColor: Color3;
  18060. /**
  18061. * Define bias applied to computed fresnel term
  18062. */
  18063. bias: number;
  18064. /**
  18065. * Defined the power exponent applied to fresnel term
  18066. */
  18067. power: number;
  18068. /**
  18069. * Creates a new FresnelParameters object.
  18070. *
  18071. * @param options provide your own settings to optionally to override defaults
  18072. */
  18073. constructor(options?: IFresnelParametersCreationOptions);
  18074. /**
  18075. * Clones the current fresnel and its valuues
  18076. * @returns a clone fresnel configuration
  18077. */
  18078. clone(): FresnelParameters;
  18079. /**
  18080. * Determines equality between FresnelParameters objects
  18081. * @param otherFresnelParameters defines the second operand
  18082. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18083. */
  18084. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18085. /**
  18086. * Serializes the current fresnel parameters to a JSON representation.
  18087. * @return the JSON serialization
  18088. */
  18089. serialize(): IFresnelParametersSerialized;
  18090. /**
  18091. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18092. * @param parsedFresnelParameters Define the JSON representation
  18093. * @returns the parsed parameters
  18094. */
  18095. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18096. }
  18097. }
  18098. declare module BABYLON {
  18099. /**
  18100. * This groups all the flags used to control the materials channel.
  18101. */
  18102. export class MaterialFlags {
  18103. private static _DiffuseTextureEnabled;
  18104. /**
  18105. * Are diffuse textures enabled in the application.
  18106. */
  18107. static get DiffuseTextureEnabled(): boolean;
  18108. static set DiffuseTextureEnabled(value: boolean);
  18109. private static _DetailTextureEnabled;
  18110. /**
  18111. * Are detail textures enabled in the application.
  18112. */
  18113. static get DetailTextureEnabled(): boolean;
  18114. static set DetailTextureEnabled(value: boolean);
  18115. private static _AmbientTextureEnabled;
  18116. /**
  18117. * Are ambient textures enabled in the application.
  18118. */
  18119. static get AmbientTextureEnabled(): boolean;
  18120. static set AmbientTextureEnabled(value: boolean);
  18121. private static _OpacityTextureEnabled;
  18122. /**
  18123. * Are opacity textures enabled in the application.
  18124. */
  18125. static get OpacityTextureEnabled(): boolean;
  18126. static set OpacityTextureEnabled(value: boolean);
  18127. private static _ReflectionTextureEnabled;
  18128. /**
  18129. * Are reflection textures enabled in the application.
  18130. */
  18131. static get ReflectionTextureEnabled(): boolean;
  18132. static set ReflectionTextureEnabled(value: boolean);
  18133. private static _EmissiveTextureEnabled;
  18134. /**
  18135. * Are emissive textures enabled in the application.
  18136. */
  18137. static get EmissiveTextureEnabled(): boolean;
  18138. static set EmissiveTextureEnabled(value: boolean);
  18139. private static _SpecularTextureEnabled;
  18140. /**
  18141. * Are specular textures enabled in the application.
  18142. */
  18143. static get SpecularTextureEnabled(): boolean;
  18144. static set SpecularTextureEnabled(value: boolean);
  18145. private static _BumpTextureEnabled;
  18146. /**
  18147. * Are bump textures enabled in the application.
  18148. */
  18149. static get BumpTextureEnabled(): boolean;
  18150. static set BumpTextureEnabled(value: boolean);
  18151. private static _LightmapTextureEnabled;
  18152. /**
  18153. * Are lightmap textures enabled in the application.
  18154. */
  18155. static get LightmapTextureEnabled(): boolean;
  18156. static set LightmapTextureEnabled(value: boolean);
  18157. private static _RefractionTextureEnabled;
  18158. /**
  18159. * Are refraction textures enabled in the application.
  18160. */
  18161. static get RefractionTextureEnabled(): boolean;
  18162. static set RefractionTextureEnabled(value: boolean);
  18163. private static _ColorGradingTextureEnabled;
  18164. /**
  18165. * Are color grading textures enabled in the application.
  18166. */
  18167. static get ColorGradingTextureEnabled(): boolean;
  18168. static set ColorGradingTextureEnabled(value: boolean);
  18169. private static _FresnelEnabled;
  18170. /**
  18171. * Are fresnels enabled in the application.
  18172. */
  18173. static get FresnelEnabled(): boolean;
  18174. static set FresnelEnabled(value: boolean);
  18175. private static _ClearCoatTextureEnabled;
  18176. /**
  18177. * Are clear coat textures enabled in the application.
  18178. */
  18179. static get ClearCoatTextureEnabled(): boolean;
  18180. static set ClearCoatTextureEnabled(value: boolean);
  18181. private static _ClearCoatBumpTextureEnabled;
  18182. /**
  18183. * Are clear coat bump textures enabled in the application.
  18184. */
  18185. static get ClearCoatBumpTextureEnabled(): boolean;
  18186. static set ClearCoatBumpTextureEnabled(value: boolean);
  18187. private static _ClearCoatTintTextureEnabled;
  18188. /**
  18189. * Are clear coat tint textures enabled in the application.
  18190. */
  18191. static get ClearCoatTintTextureEnabled(): boolean;
  18192. static set ClearCoatTintTextureEnabled(value: boolean);
  18193. private static _SheenTextureEnabled;
  18194. /**
  18195. * Are sheen textures enabled in the application.
  18196. */
  18197. static get SheenTextureEnabled(): boolean;
  18198. static set SheenTextureEnabled(value: boolean);
  18199. private static _AnisotropicTextureEnabled;
  18200. /**
  18201. * Are anisotropic textures enabled in the application.
  18202. */
  18203. static get AnisotropicTextureEnabled(): boolean;
  18204. static set AnisotropicTextureEnabled(value: boolean);
  18205. private static _ThicknessTextureEnabled;
  18206. /**
  18207. * Are thickness textures enabled in the application.
  18208. */
  18209. static get ThicknessTextureEnabled(): boolean;
  18210. static set ThicknessTextureEnabled(value: boolean);
  18211. }
  18212. }
  18213. declare module BABYLON {
  18214. /** @hidden */
  18215. export var defaultFragmentDeclaration: {
  18216. name: string;
  18217. shader: string;
  18218. };
  18219. }
  18220. declare module BABYLON {
  18221. /** @hidden */
  18222. export var defaultUboDeclaration: {
  18223. name: string;
  18224. shader: string;
  18225. };
  18226. }
  18227. declare module BABYLON {
  18228. /** @hidden */
  18229. export var prePassDeclaration: {
  18230. name: string;
  18231. shader: string;
  18232. };
  18233. }
  18234. declare module BABYLON {
  18235. /** @hidden */
  18236. export var lightFragmentDeclaration: {
  18237. name: string;
  18238. shader: string;
  18239. };
  18240. }
  18241. declare module BABYLON {
  18242. /** @hidden */
  18243. export var lightUboDeclaration: {
  18244. name: string;
  18245. shader: string;
  18246. };
  18247. }
  18248. declare module BABYLON {
  18249. /** @hidden */
  18250. export var lightsFragmentFunctions: {
  18251. name: string;
  18252. shader: string;
  18253. };
  18254. }
  18255. declare module BABYLON {
  18256. /** @hidden */
  18257. export var shadowsFragmentFunctions: {
  18258. name: string;
  18259. shader: string;
  18260. };
  18261. }
  18262. declare module BABYLON {
  18263. /** @hidden */
  18264. export var fresnelFunction: {
  18265. name: string;
  18266. shader: string;
  18267. };
  18268. }
  18269. declare module BABYLON {
  18270. /** @hidden */
  18271. export var bumpFragmentMainFunctions: {
  18272. name: string;
  18273. shader: string;
  18274. };
  18275. }
  18276. declare module BABYLON {
  18277. /** @hidden */
  18278. export var bumpFragmentFunctions: {
  18279. name: string;
  18280. shader: string;
  18281. };
  18282. }
  18283. declare module BABYLON {
  18284. /** @hidden */
  18285. export var logDepthDeclaration: {
  18286. name: string;
  18287. shader: string;
  18288. };
  18289. }
  18290. declare module BABYLON {
  18291. /** @hidden */
  18292. export var fogFragmentDeclaration: {
  18293. name: string;
  18294. shader: string;
  18295. };
  18296. }
  18297. declare module BABYLON {
  18298. /** @hidden */
  18299. export var bumpFragment: {
  18300. name: string;
  18301. shader: string;
  18302. };
  18303. }
  18304. declare module BABYLON {
  18305. /** @hidden */
  18306. export var depthPrePass: {
  18307. name: string;
  18308. shader: string;
  18309. };
  18310. }
  18311. declare module BABYLON {
  18312. /** @hidden */
  18313. export var lightFragment: {
  18314. name: string;
  18315. shader: string;
  18316. };
  18317. }
  18318. declare module BABYLON {
  18319. /** @hidden */
  18320. export var logDepthFragment: {
  18321. name: string;
  18322. shader: string;
  18323. };
  18324. }
  18325. declare module BABYLON {
  18326. /** @hidden */
  18327. export var fogFragment: {
  18328. name: string;
  18329. shader: string;
  18330. };
  18331. }
  18332. declare module BABYLON {
  18333. /** @hidden */
  18334. export var defaultPixelShader: {
  18335. name: string;
  18336. shader: string;
  18337. };
  18338. }
  18339. declare module BABYLON {
  18340. /** @hidden */
  18341. export var defaultVertexDeclaration: {
  18342. name: string;
  18343. shader: string;
  18344. };
  18345. }
  18346. declare module BABYLON {
  18347. /** @hidden */
  18348. export var bonesDeclaration: {
  18349. name: string;
  18350. shader: string;
  18351. };
  18352. }
  18353. declare module BABYLON {
  18354. /** @hidden */
  18355. export var instancesDeclaration: {
  18356. name: string;
  18357. shader: string;
  18358. };
  18359. }
  18360. declare module BABYLON {
  18361. /** @hidden */
  18362. export var prePassVertexDeclaration: {
  18363. name: string;
  18364. shader: string;
  18365. };
  18366. }
  18367. declare module BABYLON {
  18368. /** @hidden */
  18369. export var bumpVertexDeclaration: {
  18370. name: string;
  18371. shader: string;
  18372. };
  18373. }
  18374. declare module BABYLON {
  18375. /** @hidden */
  18376. export var fogVertexDeclaration: {
  18377. name: string;
  18378. shader: string;
  18379. };
  18380. }
  18381. declare module BABYLON {
  18382. /** @hidden */
  18383. export var morphTargetsVertexGlobalDeclaration: {
  18384. name: string;
  18385. shader: string;
  18386. };
  18387. }
  18388. declare module BABYLON {
  18389. /** @hidden */
  18390. export var morphTargetsVertexDeclaration: {
  18391. name: string;
  18392. shader: string;
  18393. };
  18394. }
  18395. declare module BABYLON {
  18396. /** @hidden */
  18397. export var morphTargetsVertex: {
  18398. name: string;
  18399. shader: string;
  18400. };
  18401. }
  18402. declare module BABYLON {
  18403. /** @hidden */
  18404. export var instancesVertex: {
  18405. name: string;
  18406. shader: string;
  18407. };
  18408. }
  18409. declare module BABYLON {
  18410. /** @hidden */
  18411. export var bonesVertex: {
  18412. name: string;
  18413. shader: string;
  18414. };
  18415. }
  18416. declare module BABYLON {
  18417. /** @hidden */
  18418. export var prePassVertex: {
  18419. name: string;
  18420. shader: string;
  18421. };
  18422. }
  18423. declare module BABYLON {
  18424. /** @hidden */
  18425. export var bumpVertex: {
  18426. name: string;
  18427. shader: string;
  18428. };
  18429. }
  18430. declare module BABYLON {
  18431. /** @hidden */
  18432. export var fogVertex: {
  18433. name: string;
  18434. shader: string;
  18435. };
  18436. }
  18437. declare module BABYLON {
  18438. /** @hidden */
  18439. export var shadowsVertex: {
  18440. name: string;
  18441. shader: string;
  18442. };
  18443. }
  18444. declare module BABYLON {
  18445. /** @hidden */
  18446. export var pointCloudVertex: {
  18447. name: string;
  18448. shader: string;
  18449. };
  18450. }
  18451. declare module BABYLON {
  18452. /** @hidden */
  18453. export var logDepthVertex: {
  18454. name: string;
  18455. shader: string;
  18456. };
  18457. }
  18458. declare module BABYLON {
  18459. /** @hidden */
  18460. export var defaultVertexShader: {
  18461. name: string;
  18462. shader: string;
  18463. };
  18464. }
  18465. declare module BABYLON {
  18466. /**
  18467. * @hidden
  18468. */
  18469. export interface IMaterialDetailMapDefines {
  18470. DETAIL: boolean;
  18471. DETAILDIRECTUV: number;
  18472. DETAIL_NORMALBLENDMETHOD: number;
  18473. /** @hidden */
  18474. _areTexturesDirty: boolean;
  18475. }
  18476. /**
  18477. * Define the code related to the detail map parameters of a material
  18478. *
  18479. * Inspired from:
  18480. * 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
  18481. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  18482. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  18483. */
  18484. export class DetailMapConfiguration {
  18485. private _texture;
  18486. /**
  18487. * The detail texture of the material.
  18488. */
  18489. texture: Nullable<BaseTexture>;
  18490. /**
  18491. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  18492. * Bigger values mean stronger blending
  18493. */
  18494. diffuseBlendLevel: number;
  18495. /**
  18496. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  18497. * Bigger values mean stronger blending. Only used with PBR materials
  18498. */
  18499. roughnessBlendLevel: number;
  18500. /**
  18501. * Defines how strong the bump effect from the detail map is
  18502. * Bigger values mean stronger effect
  18503. */
  18504. bumpLevel: number;
  18505. private _normalBlendMethod;
  18506. /**
  18507. * The method used to blend the bump and detail normals together
  18508. */
  18509. normalBlendMethod: number;
  18510. private _isEnabled;
  18511. /**
  18512. * Enable or disable the detail map on this material
  18513. */
  18514. isEnabled: boolean;
  18515. /** @hidden */
  18516. private _internalMarkAllSubMeshesAsTexturesDirty;
  18517. /** @hidden */
  18518. _markAllSubMeshesAsTexturesDirty(): void;
  18519. /**
  18520. * Instantiate a new detail map
  18521. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  18522. */
  18523. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  18524. /**
  18525. * Gets whether the submesh is ready to be used or not.
  18526. * @param defines the list of "defines" to update.
  18527. * @param scene defines the scene the material belongs to.
  18528. * @returns - boolean indicating that the submesh is ready or not.
  18529. */
  18530. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  18531. /**
  18532. * Update the defines for detail map usage
  18533. * @param defines the list of "defines" to update.
  18534. * @param scene defines the scene the material belongs to.
  18535. */
  18536. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  18537. /**
  18538. * Binds the material data.
  18539. * @param uniformBuffer defines the Uniform buffer to fill in.
  18540. * @param scene defines the scene the material belongs to.
  18541. * @param isFrozen defines whether the material is frozen or not.
  18542. */
  18543. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  18544. /**
  18545. * Checks to see if a texture is used in the material.
  18546. * @param texture - Base texture to use.
  18547. * @returns - Boolean specifying if a texture is used in the material.
  18548. */
  18549. hasTexture(texture: BaseTexture): boolean;
  18550. /**
  18551. * Returns an array of the actively used textures.
  18552. * @param activeTextures Array of BaseTextures
  18553. */
  18554. getActiveTextures(activeTextures: BaseTexture[]): void;
  18555. /**
  18556. * Returns the animatable textures.
  18557. * @param animatables Array of animatable textures.
  18558. */
  18559. getAnimatables(animatables: IAnimatable[]): void;
  18560. /**
  18561. * Disposes the resources of the material.
  18562. * @param forceDisposeTextures - Forces the disposal of all textures.
  18563. */
  18564. dispose(forceDisposeTextures?: boolean): void;
  18565. /**
  18566. * Get the current class name useful for serialization or dynamic coding.
  18567. * @returns "DetailMap"
  18568. */
  18569. getClassName(): string;
  18570. /**
  18571. * Add the required uniforms to the current list.
  18572. * @param uniforms defines the current uniform list.
  18573. */
  18574. static AddUniforms(uniforms: string[]): void;
  18575. /**
  18576. * Add the required samplers to the current list.
  18577. * @param samplers defines the current sampler list.
  18578. */
  18579. static AddSamplers(samplers: string[]): void;
  18580. /**
  18581. * Add the required uniforms to the current buffer.
  18582. * @param uniformBuffer defines the current uniform buffer.
  18583. */
  18584. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  18585. /**
  18586. * Makes a duplicate of the current instance into another one.
  18587. * @param detailMap define the instance where to copy the info
  18588. */
  18589. copyTo(detailMap: DetailMapConfiguration): void;
  18590. /**
  18591. * Serializes this detail map instance
  18592. * @returns - An object with the serialized instance.
  18593. */
  18594. serialize(): any;
  18595. /**
  18596. * Parses a detail map setting from a serialized object.
  18597. * @param source - Serialized object.
  18598. * @param scene Defines the scene we are parsing for
  18599. * @param rootUrl Defines the rootUrl to load from
  18600. */
  18601. parse(source: any, scene: Scene, rootUrl: string): void;
  18602. }
  18603. }
  18604. declare module BABYLON {
  18605. /** @hidden */
  18606. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  18607. MAINUV1: boolean;
  18608. MAINUV2: boolean;
  18609. DIFFUSE: boolean;
  18610. DIFFUSEDIRECTUV: number;
  18611. DETAIL: boolean;
  18612. DETAILDIRECTUV: number;
  18613. DETAIL_NORMALBLENDMETHOD: number;
  18614. AMBIENT: boolean;
  18615. AMBIENTDIRECTUV: number;
  18616. OPACITY: boolean;
  18617. OPACITYDIRECTUV: number;
  18618. OPACITYRGB: boolean;
  18619. REFLECTION: boolean;
  18620. EMISSIVE: boolean;
  18621. EMISSIVEDIRECTUV: number;
  18622. SPECULAR: boolean;
  18623. SPECULARDIRECTUV: number;
  18624. BUMP: boolean;
  18625. BUMPDIRECTUV: number;
  18626. PARALLAX: boolean;
  18627. PARALLAXOCCLUSION: boolean;
  18628. SPECULAROVERALPHA: boolean;
  18629. CLIPPLANE: boolean;
  18630. CLIPPLANE2: boolean;
  18631. CLIPPLANE3: boolean;
  18632. CLIPPLANE4: boolean;
  18633. CLIPPLANE5: boolean;
  18634. CLIPPLANE6: boolean;
  18635. ALPHATEST: boolean;
  18636. DEPTHPREPASS: boolean;
  18637. ALPHAFROMDIFFUSE: boolean;
  18638. POINTSIZE: boolean;
  18639. FOG: boolean;
  18640. SPECULARTERM: boolean;
  18641. DIFFUSEFRESNEL: boolean;
  18642. OPACITYFRESNEL: boolean;
  18643. REFLECTIONFRESNEL: boolean;
  18644. REFRACTIONFRESNEL: boolean;
  18645. EMISSIVEFRESNEL: boolean;
  18646. FRESNEL: boolean;
  18647. NORMAL: boolean;
  18648. UV1: boolean;
  18649. UV2: boolean;
  18650. VERTEXCOLOR: boolean;
  18651. VERTEXALPHA: boolean;
  18652. NUM_BONE_INFLUENCERS: number;
  18653. BonesPerMesh: number;
  18654. BONETEXTURE: boolean;
  18655. BONES_VELOCITY_ENABLED: boolean;
  18656. INSTANCES: boolean;
  18657. THIN_INSTANCES: boolean;
  18658. GLOSSINESS: boolean;
  18659. ROUGHNESS: boolean;
  18660. EMISSIVEASILLUMINATION: boolean;
  18661. LINKEMISSIVEWITHDIFFUSE: boolean;
  18662. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18663. LIGHTMAP: boolean;
  18664. LIGHTMAPDIRECTUV: number;
  18665. OBJECTSPACE_NORMALMAP: boolean;
  18666. USELIGHTMAPASSHADOWMAP: boolean;
  18667. REFLECTIONMAP_3D: boolean;
  18668. REFLECTIONMAP_SPHERICAL: boolean;
  18669. REFLECTIONMAP_PLANAR: boolean;
  18670. REFLECTIONMAP_CUBIC: boolean;
  18671. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18672. REFLECTIONMAP_PROJECTION: boolean;
  18673. REFLECTIONMAP_SKYBOX: boolean;
  18674. REFLECTIONMAP_EXPLICIT: boolean;
  18675. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18676. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18677. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18678. INVERTCUBICMAP: boolean;
  18679. LOGARITHMICDEPTH: boolean;
  18680. REFRACTION: boolean;
  18681. REFRACTIONMAP_3D: boolean;
  18682. REFLECTIONOVERALPHA: boolean;
  18683. TWOSIDEDLIGHTING: boolean;
  18684. SHADOWFLOAT: boolean;
  18685. MORPHTARGETS: boolean;
  18686. MORPHTARGETS_NORMAL: boolean;
  18687. MORPHTARGETS_TANGENT: boolean;
  18688. MORPHTARGETS_UV: boolean;
  18689. NUM_MORPH_INFLUENCERS: number;
  18690. NONUNIFORMSCALING: boolean;
  18691. PREMULTIPLYALPHA: boolean;
  18692. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  18693. ALPHABLEND: boolean;
  18694. PREPASS: boolean;
  18695. PREPASS_IRRADIANCE: boolean;
  18696. PREPASS_IRRADIANCE_INDEX: number;
  18697. PREPASS_ALBEDO: boolean;
  18698. PREPASS_ALBEDO_INDEX: number;
  18699. PREPASS_DEPTHNORMAL: boolean;
  18700. PREPASS_DEPTHNORMAL_INDEX: number;
  18701. PREPASS_POSITION: boolean;
  18702. PREPASS_POSITION_INDEX: number;
  18703. PREPASS_VELOCITY: boolean;
  18704. PREPASS_VELOCITY_INDEX: number;
  18705. PREPASS_REFLECTIVITY: boolean;
  18706. PREPASS_REFLECTIVITY_INDEX: number;
  18707. SCENE_MRT_COUNT: number;
  18708. RGBDLIGHTMAP: boolean;
  18709. RGBDREFLECTION: boolean;
  18710. RGBDREFRACTION: boolean;
  18711. IMAGEPROCESSING: boolean;
  18712. VIGNETTE: boolean;
  18713. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18714. VIGNETTEBLENDMODEOPAQUE: boolean;
  18715. TONEMAPPING: boolean;
  18716. TONEMAPPING_ACES: boolean;
  18717. CONTRAST: boolean;
  18718. COLORCURVES: boolean;
  18719. COLORGRADING: boolean;
  18720. COLORGRADING3D: boolean;
  18721. SAMPLER3DGREENDEPTH: boolean;
  18722. SAMPLER3DBGRMAP: boolean;
  18723. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18724. MULTIVIEW: boolean;
  18725. /**
  18726. * If the reflection texture on this material is in linear color space
  18727. * @hidden
  18728. */
  18729. IS_REFLECTION_LINEAR: boolean;
  18730. /**
  18731. * If the refraction texture on this material is in linear color space
  18732. * @hidden
  18733. */
  18734. IS_REFRACTION_LINEAR: boolean;
  18735. EXPOSURE: boolean;
  18736. constructor();
  18737. setReflectionMode(modeToEnable: string): void;
  18738. }
  18739. /**
  18740. * This is the default material used in Babylon. It is the best trade off between quality
  18741. * and performances.
  18742. * @see https://doc.babylonjs.com/babylon101/materials
  18743. */
  18744. export class StandardMaterial extends PushMaterial {
  18745. private _diffuseTexture;
  18746. /**
  18747. * The basic texture of the material as viewed under a light.
  18748. */
  18749. diffuseTexture: Nullable<BaseTexture>;
  18750. private _ambientTexture;
  18751. /**
  18752. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18753. */
  18754. ambientTexture: Nullable<BaseTexture>;
  18755. private _opacityTexture;
  18756. /**
  18757. * Define the transparency of the material from a texture.
  18758. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18759. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18760. */
  18761. opacityTexture: Nullable<BaseTexture>;
  18762. private _reflectionTexture;
  18763. /**
  18764. * Define the texture used to display the reflection.
  18765. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18766. */
  18767. reflectionTexture: Nullable<BaseTexture>;
  18768. private _emissiveTexture;
  18769. /**
  18770. * Define texture of the material as if self lit.
  18771. * This will be mixed in the final result even in the absence of light.
  18772. */
  18773. emissiveTexture: Nullable<BaseTexture>;
  18774. private _specularTexture;
  18775. /**
  18776. * Define how the color and intensity of the highlight given by the light in the material.
  18777. */
  18778. specularTexture: Nullable<BaseTexture>;
  18779. private _bumpTexture;
  18780. /**
  18781. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  18782. * 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.
  18783. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  18784. */
  18785. bumpTexture: Nullable<BaseTexture>;
  18786. private _lightmapTexture;
  18787. /**
  18788. * Complex lighting can be computationally expensive to compute at runtime.
  18789. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  18790. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  18791. */
  18792. lightmapTexture: Nullable<BaseTexture>;
  18793. private _refractionTexture;
  18794. /**
  18795. * Define the texture used to display the refraction.
  18796. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18797. */
  18798. refractionTexture: Nullable<BaseTexture>;
  18799. /**
  18800. * The color of the material lit by the environmental background lighting.
  18801. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  18802. */
  18803. ambientColor: Color3;
  18804. /**
  18805. * The basic color of the material as viewed under a light.
  18806. */
  18807. diffuseColor: Color3;
  18808. /**
  18809. * Define how the color and intensity of the highlight given by the light in the material.
  18810. */
  18811. specularColor: Color3;
  18812. /**
  18813. * Define the color of the material as if self lit.
  18814. * This will be mixed in the final result even in the absence of light.
  18815. */
  18816. emissiveColor: Color3;
  18817. /**
  18818. * Defines how sharp are the highlights in the material.
  18819. * The bigger the value the sharper giving a more glossy feeling to the result.
  18820. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  18821. */
  18822. specularPower: number;
  18823. private _useAlphaFromDiffuseTexture;
  18824. /**
  18825. * Does the transparency come from the diffuse texture alpha channel.
  18826. */
  18827. useAlphaFromDiffuseTexture: boolean;
  18828. private _useEmissiveAsIllumination;
  18829. /**
  18830. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  18831. */
  18832. useEmissiveAsIllumination: boolean;
  18833. private _linkEmissiveWithDiffuse;
  18834. /**
  18835. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  18836. * the emissive level when the final color is close to one.
  18837. */
  18838. linkEmissiveWithDiffuse: boolean;
  18839. private _useSpecularOverAlpha;
  18840. /**
  18841. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  18842. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  18843. */
  18844. useSpecularOverAlpha: boolean;
  18845. private _useReflectionOverAlpha;
  18846. /**
  18847. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  18848. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  18849. */
  18850. useReflectionOverAlpha: boolean;
  18851. private _disableLighting;
  18852. /**
  18853. * Does lights from the scene impacts this material.
  18854. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  18855. */
  18856. disableLighting: boolean;
  18857. private _useObjectSpaceNormalMap;
  18858. /**
  18859. * Allows using an object space normal map (instead of tangent space).
  18860. */
  18861. useObjectSpaceNormalMap: boolean;
  18862. private _useParallax;
  18863. /**
  18864. * Is parallax enabled or not.
  18865. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18866. */
  18867. useParallax: boolean;
  18868. private _useParallaxOcclusion;
  18869. /**
  18870. * Is parallax occlusion enabled or not.
  18871. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  18872. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18873. */
  18874. useParallaxOcclusion: boolean;
  18875. /**
  18876. * 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.
  18877. */
  18878. parallaxScaleBias: number;
  18879. private _roughness;
  18880. /**
  18881. * Helps to define how blurry the reflections should appears in the material.
  18882. */
  18883. roughness: number;
  18884. /**
  18885. * In case of refraction, define the value of the index of refraction.
  18886. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18887. */
  18888. indexOfRefraction: number;
  18889. /**
  18890. * Invert the refraction texture alongside the y axis.
  18891. * It can be useful with procedural textures or probe for instance.
  18892. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18893. */
  18894. invertRefractionY: boolean;
  18895. /**
  18896. * Defines the alpha limits in alpha test mode.
  18897. */
  18898. alphaCutOff: number;
  18899. private _useLightmapAsShadowmap;
  18900. /**
  18901. * In case of light mapping, define whether the map contains light or shadow informations.
  18902. */
  18903. useLightmapAsShadowmap: boolean;
  18904. private _diffuseFresnelParameters;
  18905. /**
  18906. * Define the diffuse fresnel parameters of the material.
  18907. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18908. */
  18909. diffuseFresnelParameters: FresnelParameters;
  18910. private _opacityFresnelParameters;
  18911. /**
  18912. * Define the opacity fresnel parameters of the material.
  18913. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18914. */
  18915. opacityFresnelParameters: FresnelParameters;
  18916. private _reflectionFresnelParameters;
  18917. /**
  18918. * Define the reflection fresnel parameters of the material.
  18919. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18920. */
  18921. reflectionFresnelParameters: FresnelParameters;
  18922. private _refractionFresnelParameters;
  18923. /**
  18924. * Define the refraction fresnel parameters of the material.
  18925. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18926. */
  18927. refractionFresnelParameters: FresnelParameters;
  18928. private _emissiveFresnelParameters;
  18929. /**
  18930. * Define the emissive fresnel parameters of the material.
  18931. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18932. */
  18933. emissiveFresnelParameters: FresnelParameters;
  18934. private _useReflectionFresnelFromSpecular;
  18935. /**
  18936. * If true automatically deducts the fresnels values from the material specularity.
  18937. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18938. */
  18939. useReflectionFresnelFromSpecular: boolean;
  18940. private _useGlossinessFromSpecularMapAlpha;
  18941. /**
  18942. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  18943. */
  18944. useGlossinessFromSpecularMapAlpha: boolean;
  18945. private _maxSimultaneousLights;
  18946. /**
  18947. * Defines the maximum number of lights that can be used in the material
  18948. */
  18949. maxSimultaneousLights: number;
  18950. private _invertNormalMapX;
  18951. /**
  18952. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18953. */
  18954. invertNormalMapX: boolean;
  18955. private _invertNormalMapY;
  18956. /**
  18957. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  18958. */
  18959. invertNormalMapY: boolean;
  18960. private _twoSidedLighting;
  18961. /**
  18962. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  18963. */
  18964. twoSidedLighting: boolean;
  18965. /**
  18966. * Default configuration related to image processing available in the standard Material.
  18967. */
  18968. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18969. /**
  18970. * Gets the image processing configuration used either in this material.
  18971. */
  18972. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18973. /**
  18974. * Sets the Default image processing configuration used either in the this material.
  18975. *
  18976. * If sets to null, the scene one is in use.
  18977. */
  18978. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18979. /**
  18980. * Keep track of the image processing observer to allow dispose and replace.
  18981. */
  18982. private _imageProcessingObserver;
  18983. /**
  18984. * Attaches a new image processing configuration to the Standard Material.
  18985. * @param configuration
  18986. */
  18987. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18988. /**
  18989. * Defines additionnal PrePass parameters for the material.
  18990. */
  18991. readonly prePassConfiguration: PrePassConfiguration;
  18992. /**
  18993. * Gets wether the color curves effect is enabled.
  18994. */
  18995. get cameraColorCurvesEnabled(): boolean;
  18996. /**
  18997. * Sets wether the color curves effect is enabled.
  18998. */
  18999. set cameraColorCurvesEnabled(value: boolean);
  19000. /**
  19001. * Gets wether the color grading effect is enabled.
  19002. */
  19003. get cameraColorGradingEnabled(): boolean;
  19004. /**
  19005. * Gets wether the color grading effect is enabled.
  19006. */
  19007. set cameraColorGradingEnabled(value: boolean);
  19008. /**
  19009. * Gets wether tonemapping is enabled or not.
  19010. */
  19011. get cameraToneMappingEnabled(): boolean;
  19012. /**
  19013. * Sets wether tonemapping is enabled or not
  19014. */
  19015. set cameraToneMappingEnabled(value: boolean);
  19016. /**
  19017. * The camera exposure used on this material.
  19018. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19019. * This corresponds to a photographic exposure.
  19020. */
  19021. get cameraExposure(): number;
  19022. /**
  19023. * The camera exposure used on this material.
  19024. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19025. * This corresponds to a photographic exposure.
  19026. */
  19027. set cameraExposure(value: number);
  19028. /**
  19029. * Gets The camera contrast used on this material.
  19030. */
  19031. get cameraContrast(): number;
  19032. /**
  19033. * Sets The camera contrast used on this material.
  19034. */
  19035. set cameraContrast(value: number);
  19036. /**
  19037. * Gets the Color Grading 2D Lookup Texture.
  19038. */
  19039. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19040. /**
  19041. * Sets the Color Grading 2D Lookup Texture.
  19042. */
  19043. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19044. /**
  19045. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19046. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19047. * 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;
  19048. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19049. */
  19050. get cameraColorCurves(): Nullable<ColorCurves>;
  19051. /**
  19052. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19053. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19054. * 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;
  19055. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19056. */
  19057. set cameraColorCurves(value: Nullable<ColorCurves>);
  19058. /**
  19059. * Can this material render to several textures at once
  19060. */
  19061. get canRenderToMRT(): boolean;
  19062. /**
  19063. * Defines the detail map parameters for the material.
  19064. */
  19065. readonly detailMap: DetailMapConfiguration;
  19066. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19067. protected _worldViewProjectionMatrix: Matrix;
  19068. protected _globalAmbientColor: Color3;
  19069. protected _useLogarithmicDepth: boolean;
  19070. protected _rebuildInParallel: boolean;
  19071. /**
  19072. * Instantiates a new standard material.
  19073. * This is the default material used in Babylon. It is the best trade off between quality
  19074. * and performances.
  19075. * @see https://doc.babylonjs.com/babylon101/materials
  19076. * @param name Define the name of the material in the scene
  19077. * @param scene Define the scene the material belong to
  19078. */
  19079. constructor(name: string, scene: Scene);
  19080. /**
  19081. * Gets a boolean indicating that current material needs to register RTT
  19082. */
  19083. get hasRenderTargetTextures(): boolean;
  19084. /**
  19085. * Gets the current class name of the material e.g. "StandardMaterial"
  19086. * Mainly use in serialization.
  19087. * @returns the class name
  19088. */
  19089. getClassName(): string;
  19090. /**
  19091. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19092. * You can try switching to logarithmic depth.
  19093. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19094. */
  19095. get useLogarithmicDepth(): boolean;
  19096. set useLogarithmicDepth(value: boolean);
  19097. /**
  19098. * Specifies if the material will require alpha blending
  19099. * @returns a boolean specifying if alpha blending is needed
  19100. */
  19101. needAlphaBlending(): boolean;
  19102. /**
  19103. * Specifies if this material should be rendered in alpha test mode
  19104. * @returns a boolean specifying if an alpha test is needed.
  19105. */
  19106. needAlphaTesting(): boolean;
  19107. /**
  19108. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19109. */
  19110. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19111. /**
  19112. * Specifies whether or not there is a usable alpha channel for transparency.
  19113. */
  19114. protected _hasAlphaChannel(): boolean;
  19115. /**
  19116. * Get the texture used for alpha test purpose.
  19117. * @returns the diffuse texture in case of the standard material.
  19118. */
  19119. getAlphaTestTexture(): Nullable<BaseTexture>;
  19120. /**
  19121. * Get if the submesh is ready to be used and all its information available.
  19122. * Child classes can use it to update shaders
  19123. * @param mesh defines the mesh to check
  19124. * @param subMesh defines which submesh to check
  19125. * @param useInstances specifies that instances should be used
  19126. * @returns a boolean indicating that the submesh is ready or not
  19127. */
  19128. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19129. /**
  19130. * Builds the material UBO layouts.
  19131. * Used internally during the effect preparation.
  19132. */
  19133. buildUniformLayout(): void;
  19134. /**
  19135. * Unbinds the material from the mesh
  19136. */
  19137. unbind(): void;
  19138. /**
  19139. * Binds the submesh to this material by preparing the effect and shader to draw
  19140. * @param world defines the world transformation matrix
  19141. * @param mesh defines the mesh containing the submesh
  19142. * @param subMesh defines the submesh to bind the material to
  19143. */
  19144. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19145. /**
  19146. * Get the list of animatables in the material.
  19147. * @returns the list of animatables object used in the material
  19148. */
  19149. getAnimatables(): IAnimatable[];
  19150. /**
  19151. * Gets the active textures from the material
  19152. * @returns an array of textures
  19153. */
  19154. getActiveTextures(): BaseTexture[];
  19155. /**
  19156. * Specifies if the material uses a texture
  19157. * @param texture defines the texture to check against the material
  19158. * @returns a boolean specifying if the material uses the texture
  19159. */
  19160. hasTexture(texture: BaseTexture): boolean;
  19161. /**
  19162. * Disposes the material
  19163. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19164. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19165. */
  19166. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19167. /**
  19168. * Makes a duplicate of the material, and gives it a new name
  19169. * @param name defines the new name for the duplicated material
  19170. * @returns the cloned material
  19171. */
  19172. clone(name: string): StandardMaterial;
  19173. /**
  19174. * Serializes this material in a JSON representation
  19175. * @returns the serialized material object
  19176. */
  19177. serialize(): any;
  19178. /**
  19179. * Creates a standard material from parsed material data
  19180. * @param source defines the JSON representation of the material
  19181. * @param scene defines the hosting scene
  19182. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19183. * @returns a new standard material
  19184. */
  19185. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19186. /**
  19187. * Are diffuse textures enabled in the application.
  19188. */
  19189. static get DiffuseTextureEnabled(): boolean;
  19190. static set DiffuseTextureEnabled(value: boolean);
  19191. /**
  19192. * Are detail textures enabled in the application.
  19193. */
  19194. static get DetailTextureEnabled(): boolean;
  19195. static set DetailTextureEnabled(value: boolean);
  19196. /**
  19197. * Are ambient textures enabled in the application.
  19198. */
  19199. static get AmbientTextureEnabled(): boolean;
  19200. static set AmbientTextureEnabled(value: boolean);
  19201. /**
  19202. * Are opacity textures enabled in the application.
  19203. */
  19204. static get OpacityTextureEnabled(): boolean;
  19205. static set OpacityTextureEnabled(value: boolean);
  19206. /**
  19207. * Are reflection textures enabled in the application.
  19208. */
  19209. static get ReflectionTextureEnabled(): boolean;
  19210. static set ReflectionTextureEnabled(value: boolean);
  19211. /**
  19212. * Are emissive textures enabled in the application.
  19213. */
  19214. static get EmissiveTextureEnabled(): boolean;
  19215. static set EmissiveTextureEnabled(value: boolean);
  19216. /**
  19217. * Are specular textures enabled in the application.
  19218. */
  19219. static get SpecularTextureEnabled(): boolean;
  19220. static set SpecularTextureEnabled(value: boolean);
  19221. /**
  19222. * Are bump textures enabled in the application.
  19223. */
  19224. static get BumpTextureEnabled(): boolean;
  19225. static set BumpTextureEnabled(value: boolean);
  19226. /**
  19227. * Are lightmap textures enabled in the application.
  19228. */
  19229. static get LightmapTextureEnabled(): boolean;
  19230. static set LightmapTextureEnabled(value: boolean);
  19231. /**
  19232. * Are refraction textures enabled in the application.
  19233. */
  19234. static get RefractionTextureEnabled(): boolean;
  19235. static set RefractionTextureEnabled(value: boolean);
  19236. /**
  19237. * Are color grading textures enabled in the application.
  19238. */
  19239. static get ColorGradingTextureEnabled(): boolean;
  19240. static set ColorGradingTextureEnabled(value: boolean);
  19241. /**
  19242. * Are fresnels enabled in the application.
  19243. */
  19244. static get FresnelEnabled(): boolean;
  19245. static set FresnelEnabled(value: boolean);
  19246. }
  19247. }
  19248. declare module BABYLON {
  19249. /** @hidden */
  19250. export var rgbdDecodePixelShader: {
  19251. name: string;
  19252. shader: string;
  19253. };
  19254. }
  19255. declare module BABYLON {
  19256. /**
  19257. * Class used to host RGBD texture specific utilities
  19258. */
  19259. export class RGBDTextureTools {
  19260. /**
  19261. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19262. * @param texture the texture to expand.
  19263. */
  19264. static ExpandRGBDTexture(texture: Texture): void;
  19265. }
  19266. }
  19267. declare module BABYLON {
  19268. /**
  19269. * Class used to host texture specific utilities
  19270. */
  19271. export class BRDFTextureTools {
  19272. /**
  19273. * Prevents texture cache collision
  19274. */
  19275. private static _instanceNumber;
  19276. /**
  19277. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19278. * @param scene defines the hosting scene
  19279. * @returns the environment BRDF texture
  19280. */
  19281. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19282. private static _environmentBRDFBase64Texture;
  19283. }
  19284. }
  19285. declare module BABYLON {
  19286. /**
  19287. * @hidden
  19288. */
  19289. export interface IMaterialClearCoatDefines {
  19290. CLEARCOAT: boolean;
  19291. CLEARCOAT_DEFAULTIOR: boolean;
  19292. CLEARCOAT_TEXTURE: boolean;
  19293. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19294. CLEARCOAT_TEXTUREDIRECTUV: number;
  19295. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19296. CLEARCOAT_BUMP: boolean;
  19297. CLEARCOAT_BUMPDIRECTUV: number;
  19298. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19299. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19300. CLEARCOAT_REMAP_F0: boolean;
  19301. CLEARCOAT_TINT: boolean;
  19302. CLEARCOAT_TINT_TEXTURE: boolean;
  19303. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19304. /** @hidden */
  19305. _areTexturesDirty: boolean;
  19306. }
  19307. /**
  19308. * Define the code related to the clear coat parameters of the pbr material.
  19309. */
  19310. export class PBRClearCoatConfiguration {
  19311. /**
  19312. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19313. * The default fits with a polyurethane material.
  19314. * @hidden
  19315. */
  19316. static readonly _DefaultIndexOfRefraction: number;
  19317. private _isEnabled;
  19318. /**
  19319. * Defines if the clear coat is enabled in the material.
  19320. */
  19321. isEnabled: boolean;
  19322. /**
  19323. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19324. */
  19325. intensity: number;
  19326. /**
  19327. * Defines the clear coat layer roughness.
  19328. */
  19329. roughness: number;
  19330. private _indexOfRefraction;
  19331. /**
  19332. * Defines the index of refraction of the clear coat.
  19333. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19334. * The default fits with a polyurethane material.
  19335. * Changing the default value is more performance intensive.
  19336. */
  19337. indexOfRefraction: number;
  19338. private _texture;
  19339. /**
  19340. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  19341. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  19342. * if textureRoughness is not empty, else no texture roughness is used
  19343. */
  19344. texture: Nullable<BaseTexture>;
  19345. private _useRoughnessFromMainTexture;
  19346. /**
  19347. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  19348. * If false, the green channel from textureRoughness is used for roughness
  19349. */
  19350. useRoughnessFromMainTexture: boolean;
  19351. private _textureRoughness;
  19352. /**
  19353. * Stores the clear coat roughness in a texture (green channel)
  19354. * Not used if useRoughnessFromMainTexture is true
  19355. */
  19356. textureRoughness: Nullable<BaseTexture>;
  19357. private _remapF0OnInterfaceChange;
  19358. /**
  19359. * Defines if the F0 value should be remapped to account for the interface change in the material.
  19360. */
  19361. remapF0OnInterfaceChange: boolean;
  19362. private _bumpTexture;
  19363. /**
  19364. * Define the clear coat specific bump texture.
  19365. */
  19366. bumpTexture: Nullable<BaseTexture>;
  19367. private _isTintEnabled;
  19368. /**
  19369. * Defines if the clear coat tint is enabled in the material.
  19370. */
  19371. isTintEnabled: boolean;
  19372. /**
  19373. * Defines the clear coat tint of the material.
  19374. * This is only use if tint is enabled
  19375. */
  19376. tintColor: Color3;
  19377. /**
  19378. * Defines the distance at which the tint color should be found in the
  19379. * clear coat media.
  19380. * This is only use if tint is enabled
  19381. */
  19382. tintColorAtDistance: number;
  19383. /**
  19384. * Defines the clear coat layer thickness.
  19385. * This is only use if tint is enabled
  19386. */
  19387. tintThickness: number;
  19388. private _tintTexture;
  19389. /**
  19390. * Stores the clear tint values in a texture.
  19391. * rgb is tint
  19392. * a is a thickness factor
  19393. */
  19394. tintTexture: Nullable<BaseTexture>;
  19395. /** @hidden */
  19396. private _internalMarkAllSubMeshesAsTexturesDirty;
  19397. /** @hidden */
  19398. _markAllSubMeshesAsTexturesDirty(): void;
  19399. /**
  19400. * Instantiate a new istance of clear coat configuration.
  19401. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19402. */
  19403. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19404. /**
  19405. * Gets wehter the submesh is ready to be used or not.
  19406. * @param defines the list of "defines" to update.
  19407. * @param scene defines the scene the material belongs to.
  19408. * @param engine defines the engine the material belongs to.
  19409. * @param disableBumpMap defines wether the material disables bump or not.
  19410. * @returns - boolean indicating that the submesh is ready or not.
  19411. */
  19412. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  19413. /**
  19414. * Checks to see if a texture is used in the material.
  19415. * @param defines the list of "defines" to update.
  19416. * @param scene defines the scene to the material belongs to.
  19417. */
  19418. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  19419. /**
  19420. * Binds the material data.
  19421. * @param uniformBuffer defines the Uniform buffer to fill in.
  19422. * @param scene defines the scene the material belongs to.
  19423. * @param engine defines the engine the material belongs to.
  19424. * @param disableBumpMap defines wether the material disables bump or not.
  19425. * @param isFrozen defines wether the material is frozen or not.
  19426. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  19427. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  19428. * @param subMesh the submesh to bind data for
  19429. */
  19430. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  19431. /**
  19432. * Checks to see if a texture is used in the material.
  19433. * @param texture - Base texture to use.
  19434. * @returns - Boolean specifying if a texture is used in the material.
  19435. */
  19436. hasTexture(texture: BaseTexture): boolean;
  19437. /**
  19438. * Returns an array of the actively used textures.
  19439. * @param activeTextures Array of BaseTextures
  19440. */
  19441. getActiveTextures(activeTextures: BaseTexture[]): void;
  19442. /**
  19443. * Returns the animatable textures.
  19444. * @param animatables Array of animatable textures.
  19445. */
  19446. getAnimatables(animatables: IAnimatable[]): void;
  19447. /**
  19448. * Disposes the resources of the material.
  19449. * @param forceDisposeTextures - Forces the disposal of all textures.
  19450. */
  19451. dispose(forceDisposeTextures?: boolean): void;
  19452. /**
  19453. * Get the current class name of the texture useful for serialization or dynamic coding.
  19454. * @returns "PBRClearCoatConfiguration"
  19455. */
  19456. getClassName(): string;
  19457. /**
  19458. * Add fallbacks to the effect fallbacks list.
  19459. * @param defines defines the Base texture to use.
  19460. * @param fallbacks defines the current fallback list.
  19461. * @param currentRank defines the current fallback rank.
  19462. * @returns the new fallback rank.
  19463. */
  19464. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19465. /**
  19466. * Add the required uniforms to the current list.
  19467. * @param uniforms defines the current uniform list.
  19468. */
  19469. static AddUniforms(uniforms: string[]): void;
  19470. /**
  19471. * Add the required samplers to the current list.
  19472. * @param samplers defines the current sampler list.
  19473. */
  19474. static AddSamplers(samplers: string[]): void;
  19475. /**
  19476. * Add the required uniforms to the current buffer.
  19477. * @param uniformBuffer defines the current uniform buffer.
  19478. */
  19479. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19480. /**
  19481. * Makes a duplicate of the current configuration into another one.
  19482. * @param clearCoatConfiguration define the config where to copy the info
  19483. */
  19484. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  19485. /**
  19486. * Serializes this clear coat configuration.
  19487. * @returns - An object with the serialized config.
  19488. */
  19489. serialize(): any;
  19490. /**
  19491. * Parses a anisotropy Configuration from a serialized object.
  19492. * @param source - Serialized object.
  19493. * @param scene Defines the scene we are parsing for
  19494. * @param rootUrl Defines the rootUrl to load from
  19495. */
  19496. parse(source: any, scene: Scene, rootUrl: string): void;
  19497. }
  19498. }
  19499. declare module BABYLON {
  19500. /**
  19501. * @hidden
  19502. */
  19503. export interface IMaterialAnisotropicDefines {
  19504. ANISOTROPIC: boolean;
  19505. ANISOTROPIC_TEXTURE: boolean;
  19506. ANISOTROPIC_TEXTUREDIRECTUV: number;
  19507. MAINUV1: boolean;
  19508. _areTexturesDirty: boolean;
  19509. _needUVs: boolean;
  19510. }
  19511. /**
  19512. * Define the code related to the anisotropic parameters of the pbr material.
  19513. */
  19514. export class PBRAnisotropicConfiguration {
  19515. private _isEnabled;
  19516. /**
  19517. * Defines if the anisotropy is enabled in the material.
  19518. */
  19519. isEnabled: boolean;
  19520. /**
  19521. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  19522. */
  19523. intensity: number;
  19524. /**
  19525. * Defines if the effect is along the tangents, bitangents or in between.
  19526. * By default, the effect is "strectching" the highlights along the tangents.
  19527. */
  19528. direction: Vector2;
  19529. private _texture;
  19530. /**
  19531. * Stores the anisotropy values in a texture.
  19532. * rg is direction (like normal from -1 to 1)
  19533. * b is a intensity
  19534. */
  19535. texture: Nullable<BaseTexture>;
  19536. /** @hidden */
  19537. private _internalMarkAllSubMeshesAsTexturesDirty;
  19538. /** @hidden */
  19539. _markAllSubMeshesAsTexturesDirty(): void;
  19540. /**
  19541. * Instantiate a new istance of anisotropy configuration.
  19542. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19543. */
  19544. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19545. /**
  19546. * Specifies that the submesh is ready to be used.
  19547. * @param defines the list of "defines" to update.
  19548. * @param scene defines the scene the material belongs to.
  19549. * @returns - boolean indicating that the submesh is ready or not.
  19550. */
  19551. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  19552. /**
  19553. * Checks to see if a texture is used in the material.
  19554. * @param defines the list of "defines" to update.
  19555. * @param mesh the mesh we are preparing the defines for.
  19556. * @param scene defines the scene the material belongs to.
  19557. */
  19558. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  19559. /**
  19560. * Binds the material data.
  19561. * @param uniformBuffer defines the Uniform buffer to fill in.
  19562. * @param scene defines the scene the material belongs to.
  19563. * @param isFrozen defines wether the material is frozen or not.
  19564. */
  19565. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19566. /**
  19567. * Checks to see if a texture is used in the material.
  19568. * @param texture - Base texture to use.
  19569. * @returns - Boolean specifying if a texture is used in the material.
  19570. */
  19571. hasTexture(texture: BaseTexture): boolean;
  19572. /**
  19573. * Returns an array of the actively used textures.
  19574. * @param activeTextures Array of BaseTextures
  19575. */
  19576. getActiveTextures(activeTextures: BaseTexture[]): void;
  19577. /**
  19578. * Returns the animatable textures.
  19579. * @param animatables Array of animatable textures.
  19580. */
  19581. getAnimatables(animatables: IAnimatable[]): void;
  19582. /**
  19583. * Disposes the resources of the material.
  19584. * @param forceDisposeTextures - Forces the disposal of all textures.
  19585. */
  19586. dispose(forceDisposeTextures?: boolean): void;
  19587. /**
  19588. * Get the current class name of the texture useful for serialization or dynamic coding.
  19589. * @returns "PBRAnisotropicConfiguration"
  19590. */
  19591. getClassName(): string;
  19592. /**
  19593. * Add fallbacks to the effect fallbacks list.
  19594. * @param defines defines the Base texture to use.
  19595. * @param fallbacks defines the current fallback list.
  19596. * @param currentRank defines the current fallback rank.
  19597. * @returns the new fallback rank.
  19598. */
  19599. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19600. /**
  19601. * Add the required uniforms to the current list.
  19602. * @param uniforms defines the current uniform list.
  19603. */
  19604. static AddUniforms(uniforms: string[]): void;
  19605. /**
  19606. * Add the required uniforms to the current buffer.
  19607. * @param uniformBuffer defines the current uniform buffer.
  19608. */
  19609. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19610. /**
  19611. * Add the required samplers to the current list.
  19612. * @param samplers defines the current sampler list.
  19613. */
  19614. static AddSamplers(samplers: string[]): void;
  19615. /**
  19616. * Makes a duplicate of the current configuration into another one.
  19617. * @param anisotropicConfiguration define the config where to copy the info
  19618. */
  19619. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  19620. /**
  19621. * Serializes this anisotropy configuration.
  19622. * @returns - An object with the serialized config.
  19623. */
  19624. serialize(): any;
  19625. /**
  19626. * Parses a anisotropy Configuration from a serialized object.
  19627. * @param source - Serialized object.
  19628. * @param scene Defines the scene we are parsing for
  19629. * @param rootUrl Defines the rootUrl to load from
  19630. */
  19631. parse(source: any, scene: Scene, rootUrl: string): void;
  19632. }
  19633. }
  19634. declare module BABYLON {
  19635. /**
  19636. * @hidden
  19637. */
  19638. export interface IMaterialBRDFDefines {
  19639. BRDF_V_HEIGHT_CORRELATED: boolean;
  19640. MS_BRDF_ENERGY_CONSERVATION: boolean;
  19641. SPHERICAL_HARMONICS: boolean;
  19642. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  19643. /** @hidden */
  19644. _areMiscDirty: boolean;
  19645. }
  19646. /**
  19647. * Define the code related to the BRDF parameters of the pbr material.
  19648. */
  19649. export class PBRBRDFConfiguration {
  19650. /**
  19651. * Default value used for the energy conservation.
  19652. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19653. */
  19654. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  19655. /**
  19656. * Default value used for the Smith Visibility Height Correlated mode.
  19657. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19658. */
  19659. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  19660. /**
  19661. * Default value used for the IBL diffuse part.
  19662. * This can help switching back to the polynomials mode globally which is a tiny bit
  19663. * less GPU intensive at the drawback of a lower quality.
  19664. */
  19665. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  19666. /**
  19667. * Default value used for activating energy conservation for the specular workflow.
  19668. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19669. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19670. */
  19671. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  19672. private _useEnergyConservation;
  19673. /**
  19674. * Defines if the material uses energy conservation.
  19675. */
  19676. useEnergyConservation: boolean;
  19677. private _useSmithVisibilityHeightCorrelated;
  19678. /**
  19679. * LEGACY Mode set to false
  19680. * Defines if the material uses height smith correlated visibility term.
  19681. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  19682. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  19683. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  19684. * Not relying on height correlated will also disable energy conservation.
  19685. */
  19686. useSmithVisibilityHeightCorrelated: boolean;
  19687. private _useSphericalHarmonics;
  19688. /**
  19689. * LEGACY Mode set to false
  19690. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  19691. * diffuse part of the IBL.
  19692. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  19693. * to the ground truth.
  19694. */
  19695. useSphericalHarmonics: boolean;
  19696. private _useSpecularGlossinessInputEnergyConservation;
  19697. /**
  19698. * Defines if the material uses energy conservation, when the specular workflow is active.
  19699. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19700. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19701. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  19702. */
  19703. useSpecularGlossinessInputEnergyConservation: boolean;
  19704. /** @hidden */
  19705. private _internalMarkAllSubMeshesAsMiscDirty;
  19706. /** @hidden */
  19707. _markAllSubMeshesAsMiscDirty(): void;
  19708. /**
  19709. * Instantiate a new istance of clear coat configuration.
  19710. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  19711. */
  19712. constructor(markAllSubMeshesAsMiscDirty: () => void);
  19713. /**
  19714. * Checks to see if a texture is used in the material.
  19715. * @param defines the list of "defines" to update.
  19716. */
  19717. prepareDefines(defines: IMaterialBRDFDefines): void;
  19718. /**
  19719. * Get the current class name of the texture useful for serialization or dynamic coding.
  19720. * @returns "PBRClearCoatConfiguration"
  19721. */
  19722. getClassName(): string;
  19723. /**
  19724. * Makes a duplicate of the current configuration into another one.
  19725. * @param brdfConfiguration define the config where to copy the info
  19726. */
  19727. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  19728. /**
  19729. * Serializes this BRDF configuration.
  19730. * @returns - An object with the serialized config.
  19731. */
  19732. serialize(): any;
  19733. /**
  19734. * Parses a anisotropy Configuration from a serialized object.
  19735. * @param source - Serialized object.
  19736. * @param scene Defines the scene we are parsing for
  19737. * @param rootUrl Defines the rootUrl to load from
  19738. */
  19739. parse(source: any, scene: Scene, rootUrl: string): void;
  19740. }
  19741. }
  19742. declare module BABYLON {
  19743. /**
  19744. * @hidden
  19745. */
  19746. export interface IMaterialSheenDefines {
  19747. SHEEN: boolean;
  19748. SHEEN_TEXTURE: boolean;
  19749. SHEEN_TEXTURE_ROUGHNESS: boolean;
  19750. SHEEN_TEXTUREDIRECTUV: number;
  19751. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  19752. SHEEN_LINKWITHALBEDO: boolean;
  19753. SHEEN_ROUGHNESS: boolean;
  19754. SHEEN_ALBEDOSCALING: boolean;
  19755. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19756. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19757. /** @hidden */
  19758. _areTexturesDirty: boolean;
  19759. }
  19760. /**
  19761. * Define the code related to the Sheen parameters of the pbr material.
  19762. */
  19763. export class PBRSheenConfiguration {
  19764. private _isEnabled;
  19765. /**
  19766. * Defines if the material uses sheen.
  19767. */
  19768. isEnabled: boolean;
  19769. private _linkSheenWithAlbedo;
  19770. /**
  19771. * Defines if the sheen is linked to the sheen color.
  19772. */
  19773. linkSheenWithAlbedo: boolean;
  19774. /**
  19775. * Defines the sheen intensity.
  19776. */
  19777. intensity: number;
  19778. /**
  19779. * Defines the sheen color.
  19780. */
  19781. color: Color3;
  19782. private _texture;
  19783. /**
  19784. * Stores the sheen tint values in a texture.
  19785. * rgb is tint
  19786. * 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)
  19787. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  19788. */
  19789. texture: Nullable<BaseTexture>;
  19790. private _useRoughnessFromMainTexture;
  19791. /**
  19792. * Indicates that the alpha channel of the texture property will be used for roughness.
  19793. * Has no effect if the roughness (and texture!) property is not defined
  19794. */
  19795. useRoughnessFromMainTexture: boolean;
  19796. private _roughness;
  19797. /**
  19798. * Defines the sheen roughness.
  19799. * It is not taken into account if linkSheenWithAlbedo is true.
  19800. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  19801. */
  19802. roughness: Nullable<number>;
  19803. private _textureRoughness;
  19804. /**
  19805. * Stores the sheen roughness in a texture.
  19806. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  19807. */
  19808. textureRoughness: Nullable<BaseTexture>;
  19809. private _albedoScaling;
  19810. /**
  19811. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  19812. * It allows the strength of the sheen effect to not depend on the base color of the material,
  19813. * making it easier to setup and tweak the effect
  19814. */
  19815. albedoScaling: boolean;
  19816. /** @hidden */
  19817. private _internalMarkAllSubMeshesAsTexturesDirty;
  19818. /** @hidden */
  19819. _markAllSubMeshesAsTexturesDirty(): void;
  19820. /**
  19821. * Instantiate a new istance of clear coat configuration.
  19822. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19823. */
  19824. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19825. /**
  19826. * Specifies that the submesh is ready to be used.
  19827. * @param defines the list of "defines" to update.
  19828. * @param scene defines the scene the material belongs to.
  19829. * @returns - boolean indicating that the submesh is ready or not.
  19830. */
  19831. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  19832. /**
  19833. * Checks to see if a texture is used in the material.
  19834. * @param defines the list of "defines" to update.
  19835. * @param scene defines the scene the material belongs to.
  19836. */
  19837. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  19838. /**
  19839. * Binds the material data.
  19840. * @param uniformBuffer defines the Uniform buffer to fill in.
  19841. * @param scene defines the scene the material belongs to.
  19842. * @param isFrozen defines wether the material is frozen or not.
  19843. * @param subMesh the submesh to bind data for
  19844. */
  19845. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  19846. /**
  19847. * Checks to see if a texture is used in the material.
  19848. * @param texture - Base texture to use.
  19849. * @returns - Boolean specifying if a texture is used in the material.
  19850. */
  19851. hasTexture(texture: BaseTexture): boolean;
  19852. /**
  19853. * Returns an array of the actively used textures.
  19854. * @param activeTextures Array of BaseTextures
  19855. */
  19856. getActiveTextures(activeTextures: BaseTexture[]): void;
  19857. /**
  19858. * Returns the animatable textures.
  19859. * @param animatables Array of animatable textures.
  19860. */
  19861. getAnimatables(animatables: IAnimatable[]): void;
  19862. /**
  19863. * Disposes the resources of the material.
  19864. * @param forceDisposeTextures - Forces the disposal of all textures.
  19865. */
  19866. dispose(forceDisposeTextures?: boolean): void;
  19867. /**
  19868. * Get the current class name of the texture useful for serialization or dynamic coding.
  19869. * @returns "PBRSheenConfiguration"
  19870. */
  19871. getClassName(): string;
  19872. /**
  19873. * Add fallbacks to the effect fallbacks list.
  19874. * @param defines defines the Base texture to use.
  19875. * @param fallbacks defines the current fallback list.
  19876. * @param currentRank defines the current fallback rank.
  19877. * @returns the new fallback rank.
  19878. */
  19879. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19880. /**
  19881. * Add the required uniforms to the current list.
  19882. * @param uniforms defines the current uniform list.
  19883. */
  19884. static AddUniforms(uniforms: string[]): void;
  19885. /**
  19886. * Add the required uniforms to the current buffer.
  19887. * @param uniformBuffer defines the current uniform buffer.
  19888. */
  19889. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19890. /**
  19891. * Add the required samplers to the current list.
  19892. * @param samplers defines the current sampler list.
  19893. */
  19894. static AddSamplers(samplers: string[]): void;
  19895. /**
  19896. * Makes a duplicate of the current configuration into another one.
  19897. * @param sheenConfiguration define the config where to copy the info
  19898. */
  19899. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  19900. /**
  19901. * Serializes this BRDF configuration.
  19902. * @returns - An object with the serialized config.
  19903. */
  19904. serialize(): any;
  19905. /**
  19906. * Parses a anisotropy Configuration from a serialized object.
  19907. * @param source - Serialized object.
  19908. * @param scene Defines the scene we are parsing for
  19909. * @param rootUrl Defines the rootUrl to load from
  19910. */
  19911. parse(source: any, scene: Scene, rootUrl: string): void;
  19912. }
  19913. }
  19914. declare module BABYLON {
  19915. /**
  19916. * @hidden
  19917. */
  19918. export interface IMaterialSubSurfaceDefines {
  19919. SUBSURFACE: boolean;
  19920. SS_REFRACTION: boolean;
  19921. SS_TRANSLUCENCY: boolean;
  19922. SS_SCATTERING: boolean;
  19923. SS_THICKNESSANDMASK_TEXTURE: boolean;
  19924. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  19925. SS_REFRACTIONMAP_3D: boolean;
  19926. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  19927. SS_LODINREFRACTIONALPHA: boolean;
  19928. SS_GAMMAREFRACTION: boolean;
  19929. SS_RGBDREFRACTION: boolean;
  19930. SS_LINEARSPECULARREFRACTION: boolean;
  19931. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  19932. SS_ALBEDOFORREFRACTIONTINT: boolean;
  19933. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  19934. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  19935. /** @hidden */
  19936. _areTexturesDirty: boolean;
  19937. }
  19938. /**
  19939. * Define the code related to the sub surface parameters of the pbr material.
  19940. */
  19941. export class PBRSubSurfaceConfiguration {
  19942. private _isRefractionEnabled;
  19943. /**
  19944. * Defines if the refraction is enabled in the material.
  19945. */
  19946. isRefractionEnabled: boolean;
  19947. private _isTranslucencyEnabled;
  19948. /**
  19949. * Defines if the translucency is enabled in the material.
  19950. */
  19951. isTranslucencyEnabled: boolean;
  19952. private _isScatteringEnabled;
  19953. /**
  19954. * Defines if the sub surface scattering is enabled in the material.
  19955. */
  19956. isScatteringEnabled: boolean;
  19957. private _scatteringDiffusionProfileIndex;
  19958. /**
  19959. * Diffusion profile for subsurface scattering.
  19960. * Useful for better scattering in the skins or foliages.
  19961. */
  19962. get scatteringDiffusionProfile(): Nullable<Color3>;
  19963. set scatteringDiffusionProfile(c: Nullable<Color3>);
  19964. /**
  19965. * Defines the refraction intensity of the material.
  19966. * The refraction when enabled replaces the Diffuse part of the material.
  19967. * The intensity helps transitionning between diffuse and refraction.
  19968. */
  19969. refractionIntensity: number;
  19970. /**
  19971. * Defines the translucency intensity of the material.
  19972. * When translucency has been enabled, this defines how much of the "translucency"
  19973. * is addded to the diffuse part of the material.
  19974. */
  19975. translucencyIntensity: number;
  19976. /**
  19977. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  19978. */
  19979. useAlbedoToTintRefraction: boolean;
  19980. private _thicknessTexture;
  19981. /**
  19982. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  19983. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  19984. * 0 would mean minimumThickness
  19985. * 1 would mean maximumThickness
  19986. * The other channels might be use as a mask to vary the different effects intensity.
  19987. */
  19988. thicknessTexture: Nullable<BaseTexture>;
  19989. private _refractionTexture;
  19990. /**
  19991. * Defines the texture to use for refraction.
  19992. */
  19993. refractionTexture: Nullable<BaseTexture>;
  19994. private _indexOfRefraction;
  19995. /**
  19996. * Index of refraction of the material base layer.
  19997. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  19998. *
  19999. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20000. *
  20001. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20002. */
  20003. indexOfRefraction: number;
  20004. private _volumeIndexOfRefraction;
  20005. /**
  20006. * Index of refraction of the material's volume.
  20007. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20008. *
  20009. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20010. * the volume will use the same IOR as the surface.
  20011. */
  20012. get volumeIndexOfRefraction(): number;
  20013. set volumeIndexOfRefraction(value: number);
  20014. private _invertRefractionY;
  20015. /**
  20016. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20017. */
  20018. invertRefractionY: boolean;
  20019. private _linkRefractionWithTransparency;
  20020. /**
  20021. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20022. * Materials half opaque for instance using refraction could benefit from this control.
  20023. */
  20024. linkRefractionWithTransparency: boolean;
  20025. /**
  20026. * Defines the minimum thickness stored in the thickness map.
  20027. * If no thickness map is defined, this value will be used to simulate thickness.
  20028. */
  20029. minimumThickness: number;
  20030. /**
  20031. * Defines the maximum thickness stored in the thickness map.
  20032. */
  20033. maximumThickness: number;
  20034. /**
  20035. * Defines the volume tint of the material.
  20036. * This is used for both translucency and scattering.
  20037. */
  20038. tintColor: Color3;
  20039. /**
  20040. * Defines the distance at which the tint color should be found in the media.
  20041. * This is used for refraction only.
  20042. */
  20043. tintColorAtDistance: number;
  20044. /**
  20045. * Defines how far each channel transmit through the media.
  20046. * It is defined as a color to simplify it selection.
  20047. */
  20048. diffusionDistance: Color3;
  20049. private _useMaskFromThicknessTexture;
  20050. /**
  20051. * Stores the intensity of the different subsurface effects in the thickness texture.
  20052. * * the green channel is the translucency intensity.
  20053. * * the blue channel is the scattering intensity.
  20054. * * the alpha channel is the refraction intensity.
  20055. */
  20056. useMaskFromThicknessTexture: boolean;
  20057. private _scene;
  20058. private _useMaskFromThicknessTextureGltf;
  20059. /**
  20060. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20061. * matches the channel-packing that is used by glTF.
  20062. * * the red channel is the transmission/translucency intensity.
  20063. * * the green channel is the thickness.
  20064. */
  20065. useMaskFromThicknessTextureGltf: boolean;
  20066. /** @hidden */
  20067. private _internalMarkAllSubMeshesAsTexturesDirty;
  20068. private _internalMarkScenePrePassDirty;
  20069. /** @hidden */
  20070. _markAllSubMeshesAsTexturesDirty(): void;
  20071. /** @hidden */
  20072. _markScenePrePassDirty(): void;
  20073. /**
  20074. * Instantiate a new istance of sub surface configuration.
  20075. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20076. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20077. * @param scene The scene
  20078. */
  20079. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20080. /**
  20081. * Gets wehter the submesh is ready to be used or not.
  20082. * @param defines the list of "defines" to update.
  20083. * @param scene defines the scene the material belongs to.
  20084. * @returns - boolean indicating that the submesh is ready or not.
  20085. */
  20086. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20087. /**
  20088. * Checks to see if a texture is used in the material.
  20089. * @param defines the list of "defines" to update.
  20090. * @param scene defines the scene to the material belongs to.
  20091. */
  20092. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20093. /**
  20094. * Binds the material data.
  20095. * @param uniformBuffer defines the Uniform buffer to fill in.
  20096. * @param scene defines the scene the material belongs to.
  20097. * @param engine defines the engine the material belongs to.
  20098. * @param isFrozen defines whether the material is frozen or not.
  20099. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20100. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20101. */
  20102. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20103. /**
  20104. * Unbinds the material from the mesh.
  20105. * @param activeEffect defines the effect that should be unbound from.
  20106. * @returns true if unbound, otherwise false
  20107. */
  20108. unbind(activeEffect: Effect): boolean;
  20109. /**
  20110. * Returns the texture used for refraction or null if none is used.
  20111. * @param scene defines the scene the material belongs to.
  20112. * @returns - Refraction texture if present. If no refraction texture and refraction
  20113. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20114. */
  20115. private _getRefractionTexture;
  20116. /**
  20117. * Returns true if alpha blending should be disabled.
  20118. */
  20119. get disableAlphaBlending(): boolean;
  20120. /**
  20121. * Fills the list of render target textures.
  20122. * @param renderTargets the list of render targets to update
  20123. */
  20124. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20125. /**
  20126. * Checks to see if a texture is used in the material.
  20127. * @param texture - Base texture to use.
  20128. * @returns - Boolean specifying if a texture is used in the material.
  20129. */
  20130. hasTexture(texture: BaseTexture): boolean;
  20131. /**
  20132. * Gets a boolean indicating that current material needs to register RTT
  20133. * @returns true if this uses a render target otherwise false.
  20134. */
  20135. hasRenderTargetTextures(): boolean;
  20136. /**
  20137. * Returns an array of the actively used textures.
  20138. * @param activeTextures Array of BaseTextures
  20139. */
  20140. getActiveTextures(activeTextures: BaseTexture[]): void;
  20141. /**
  20142. * Returns the animatable textures.
  20143. * @param animatables Array of animatable textures.
  20144. */
  20145. getAnimatables(animatables: IAnimatable[]): void;
  20146. /**
  20147. * Disposes the resources of the material.
  20148. * @param forceDisposeTextures - Forces the disposal of all textures.
  20149. */
  20150. dispose(forceDisposeTextures?: boolean): void;
  20151. /**
  20152. * Get the current class name of the texture useful for serialization or dynamic coding.
  20153. * @returns "PBRSubSurfaceConfiguration"
  20154. */
  20155. getClassName(): string;
  20156. /**
  20157. * Add fallbacks to the effect fallbacks list.
  20158. * @param defines defines the Base texture to use.
  20159. * @param fallbacks defines the current fallback list.
  20160. * @param currentRank defines the current fallback rank.
  20161. * @returns the new fallback rank.
  20162. */
  20163. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20164. /**
  20165. * Add the required uniforms to the current list.
  20166. * @param uniforms defines the current uniform list.
  20167. */
  20168. static AddUniforms(uniforms: string[]): void;
  20169. /**
  20170. * Add the required samplers to the current list.
  20171. * @param samplers defines the current sampler list.
  20172. */
  20173. static AddSamplers(samplers: string[]): void;
  20174. /**
  20175. * Add the required uniforms to the current buffer.
  20176. * @param uniformBuffer defines the current uniform buffer.
  20177. */
  20178. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20179. /**
  20180. * Makes a duplicate of the current configuration into another one.
  20181. * @param configuration define the config where to copy the info
  20182. */
  20183. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20184. /**
  20185. * Serializes this Sub Surface configuration.
  20186. * @returns - An object with the serialized config.
  20187. */
  20188. serialize(): any;
  20189. /**
  20190. * Parses a anisotropy Configuration from a serialized object.
  20191. * @param source - Serialized object.
  20192. * @param scene Defines the scene we are parsing for
  20193. * @param rootUrl Defines the rootUrl to load from
  20194. */
  20195. parse(source: any, scene: Scene, rootUrl: string): void;
  20196. }
  20197. }
  20198. declare module BABYLON {
  20199. /**
  20200. * Class representing spherical harmonics coefficients to the 3rd degree
  20201. */
  20202. export class SphericalHarmonics {
  20203. /**
  20204. * Defines whether or not the harmonics have been prescaled for rendering.
  20205. */
  20206. preScaled: boolean;
  20207. /**
  20208. * The l0,0 coefficients of the spherical harmonics
  20209. */
  20210. l00: Vector3;
  20211. /**
  20212. * The l1,-1 coefficients of the spherical harmonics
  20213. */
  20214. l1_1: Vector3;
  20215. /**
  20216. * The l1,0 coefficients of the spherical harmonics
  20217. */
  20218. l10: Vector3;
  20219. /**
  20220. * The l1,1 coefficients of the spherical harmonics
  20221. */
  20222. l11: Vector3;
  20223. /**
  20224. * The l2,-2 coefficients of the spherical harmonics
  20225. */
  20226. l2_2: Vector3;
  20227. /**
  20228. * The l2,-1 coefficients of the spherical harmonics
  20229. */
  20230. l2_1: Vector3;
  20231. /**
  20232. * The l2,0 coefficients of the spherical harmonics
  20233. */
  20234. l20: Vector3;
  20235. /**
  20236. * The l2,1 coefficients of the spherical harmonics
  20237. */
  20238. l21: Vector3;
  20239. /**
  20240. * The l2,2 coefficients of the spherical harmonics
  20241. */
  20242. l22: Vector3;
  20243. /**
  20244. * Adds a light to the spherical harmonics
  20245. * @param direction the direction of the light
  20246. * @param color the color of the light
  20247. * @param deltaSolidAngle the delta solid angle of the light
  20248. */
  20249. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20250. /**
  20251. * Scales the spherical harmonics by the given amount
  20252. * @param scale the amount to scale
  20253. */
  20254. scaleInPlace(scale: number): void;
  20255. /**
  20256. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20257. *
  20258. * ```
  20259. * E_lm = A_l * L_lm
  20260. * ```
  20261. *
  20262. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20263. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20264. * the scaling factors are given in equation 9.
  20265. */
  20266. convertIncidentRadianceToIrradiance(): void;
  20267. /**
  20268. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20269. *
  20270. * ```
  20271. * L = (1/pi) * E * rho
  20272. * ```
  20273. *
  20274. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20275. */
  20276. convertIrradianceToLambertianRadiance(): void;
  20277. /**
  20278. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20279. * required operations at run time.
  20280. *
  20281. * This is simply done by scaling back the SH with Ylm constants parameter.
  20282. * The trigonometric part being applied by the shader at run time.
  20283. */
  20284. preScaleForRendering(): void;
  20285. /**
  20286. * Constructs a spherical harmonics from an array.
  20287. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20288. * @returns the spherical harmonics
  20289. */
  20290. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20291. /**
  20292. * Gets the spherical harmonics from polynomial
  20293. * @param polynomial the spherical polynomial
  20294. * @returns the spherical harmonics
  20295. */
  20296. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20297. }
  20298. /**
  20299. * Class representing spherical polynomial coefficients to the 3rd degree
  20300. */
  20301. export class SphericalPolynomial {
  20302. private _harmonics;
  20303. /**
  20304. * The spherical harmonics used to create the polynomials.
  20305. */
  20306. get preScaledHarmonics(): SphericalHarmonics;
  20307. /**
  20308. * The x coefficients of the spherical polynomial
  20309. */
  20310. x: Vector3;
  20311. /**
  20312. * The y coefficients of the spherical polynomial
  20313. */
  20314. y: Vector3;
  20315. /**
  20316. * The z coefficients of the spherical polynomial
  20317. */
  20318. z: Vector3;
  20319. /**
  20320. * The xx coefficients of the spherical polynomial
  20321. */
  20322. xx: Vector3;
  20323. /**
  20324. * The yy coefficients of the spherical polynomial
  20325. */
  20326. yy: Vector3;
  20327. /**
  20328. * The zz coefficients of the spherical polynomial
  20329. */
  20330. zz: Vector3;
  20331. /**
  20332. * The xy coefficients of the spherical polynomial
  20333. */
  20334. xy: Vector3;
  20335. /**
  20336. * The yz coefficients of the spherical polynomial
  20337. */
  20338. yz: Vector3;
  20339. /**
  20340. * The zx coefficients of the spherical polynomial
  20341. */
  20342. zx: Vector3;
  20343. /**
  20344. * Adds an ambient color to the spherical polynomial
  20345. * @param color the color to add
  20346. */
  20347. addAmbient(color: Color3): void;
  20348. /**
  20349. * Scales the spherical polynomial by the given amount
  20350. * @param scale the amount to scale
  20351. */
  20352. scaleInPlace(scale: number): void;
  20353. /**
  20354. * Gets the spherical polynomial from harmonics
  20355. * @param harmonics the spherical harmonics
  20356. * @returns the spherical polynomial
  20357. */
  20358. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  20359. /**
  20360. * Constructs a spherical polynomial from an array.
  20361. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  20362. * @returns the spherical polynomial
  20363. */
  20364. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  20365. }
  20366. }
  20367. declare module BABYLON {
  20368. /**
  20369. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  20370. */
  20371. export interface CubeMapInfo {
  20372. /**
  20373. * The pixel array for the front face.
  20374. * This is stored in format, left to right, up to down format.
  20375. */
  20376. front: Nullable<ArrayBufferView>;
  20377. /**
  20378. * The pixel array for the back face.
  20379. * This is stored in format, left to right, up to down format.
  20380. */
  20381. back: Nullable<ArrayBufferView>;
  20382. /**
  20383. * The pixel array for the left face.
  20384. * This is stored in format, left to right, up to down format.
  20385. */
  20386. left: Nullable<ArrayBufferView>;
  20387. /**
  20388. * The pixel array for the right face.
  20389. * This is stored in format, left to right, up to down format.
  20390. */
  20391. right: Nullable<ArrayBufferView>;
  20392. /**
  20393. * The pixel array for the up face.
  20394. * This is stored in format, left to right, up to down format.
  20395. */
  20396. up: Nullable<ArrayBufferView>;
  20397. /**
  20398. * The pixel array for the down face.
  20399. * This is stored in format, left to right, up to down format.
  20400. */
  20401. down: Nullable<ArrayBufferView>;
  20402. /**
  20403. * The size of the cubemap stored.
  20404. *
  20405. * Each faces will be size * size pixels.
  20406. */
  20407. size: number;
  20408. /**
  20409. * The format of the texture.
  20410. *
  20411. * RGBA, RGB.
  20412. */
  20413. format: number;
  20414. /**
  20415. * The type of the texture data.
  20416. *
  20417. * UNSIGNED_INT, FLOAT.
  20418. */
  20419. type: number;
  20420. /**
  20421. * Specifies whether the texture is in gamma space.
  20422. */
  20423. gammaSpace: boolean;
  20424. }
  20425. /**
  20426. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  20427. */
  20428. export class PanoramaToCubeMapTools {
  20429. private static FACE_LEFT;
  20430. private static FACE_RIGHT;
  20431. private static FACE_FRONT;
  20432. private static FACE_BACK;
  20433. private static FACE_DOWN;
  20434. private static FACE_UP;
  20435. /**
  20436. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  20437. *
  20438. * @param float32Array The source data.
  20439. * @param inputWidth The width of the input panorama.
  20440. * @param inputHeight The height of the input panorama.
  20441. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  20442. * @return The cubemap data
  20443. */
  20444. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  20445. private static CreateCubemapTexture;
  20446. private static CalcProjectionSpherical;
  20447. }
  20448. }
  20449. declare module BABYLON {
  20450. /**
  20451. * Helper class dealing with the extraction of spherical polynomial dataArray
  20452. * from a cube map.
  20453. */
  20454. export class CubeMapToSphericalPolynomialTools {
  20455. private static FileFaces;
  20456. /**
  20457. * Converts a texture to the according Spherical Polynomial data.
  20458. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20459. *
  20460. * @param texture The texture to extract the information from.
  20461. * @return The Spherical Polynomial data.
  20462. */
  20463. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  20464. /**
  20465. * Converts a cubemap to the according Spherical Polynomial data.
  20466. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20467. *
  20468. * @param cubeInfo The Cube map to extract the information from.
  20469. * @return The Spherical Polynomial data.
  20470. */
  20471. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  20472. }
  20473. }
  20474. declare module BABYLON {
  20475. interface BaseTexture {
  20476. /**
  20477. * Get the polynomial representation of the texture data.
  20478. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  20479. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  20480. */
  20481. sphericalPolynomial: Nullable<SphericalPolynomial>;
  20482. }
  20483. }
  20484. declare module BABYLON {
  20485. /** @hidden */
  20486. export var pbrFragmentDeclaration: {
  20487. name: string;
  20488. shader: string;
  20489. };
  20490. }
  20491. declare module BABYLON {
  20492. /** @hidden */
  20493. export var pbrUboDeclaration: {
  20494. name: string;
  20495. shader: string;
  20496. };
  20497. }
  20498. declare module BABYLON {
  20499. /** @hidden */
  20500. export var pbrFragmentExtraDeclaration: {
  20501. name: string;
  20502. shader: string;
  20503. };
  20504. }
  20505. declare module BABYLON {
  20506. /** @hidden */
  20507. export var pbrFragmentSamplersDeclaration: {
  20508. name: string;
  20509. shader: string;
  20510. };
  20511. }
  20512. declare module BABYLON {
  20513. /** @hidden */
  20514. export var subSurfaceScatteringFunctions: {
  20515. name: string;
  20516. shader: string;
  20517. };
  20518. }
  20519. declare module BABYLON {
  20520. /** @hidden */
  20521. export var importanceSampling: {
  20522. name: string;
  20523. shader: string;
  20524. };
  20525. }
  20526. declare module BABYLON {
  20527. /** @hidden */
  20528. export var pbrHelperFunctions: {
  20529. name: string;
  20530. shader: string;
  20531. };
  20532. }
  20533. declare module BABYLON {
  20534. /** @hidden */
  20535. export var harmonicsFunctions: {
  20536. name: string;
  20537. shader: string;
  20538. };
  20539. }
  20540. declare module BABYLON {
  20541. /** @hidden */
  20542. export var pbrDirectLightingSetupFunctions: {
  20543. name: string;
  20544. shader: string;
  20545. };
  20546. }
  20547. declare module BABYLON {
  20548. /** @hidden */
  20549. export var pbrDirectLightingFalloffFunctions: {
  20550. name: string;
  20551. shader: string;
  20552. };
  20553. }
  20554. declare module BABYLON {
  20555. /** @hidden */
  20556. export var pbrBRDFFunctions: {
  20557. name: string;
  20558. shader: string;
  20559. };
  20560. }
  20561. declare module BABYLON {
  20562. /** @hidden */
  20563. export var hdrFilteringFunctions: {
  20564. name: string;
  20565. shader: string;
  20566. };
  20567. }
  20568. declare module BABYLON {
  20569. /** @hidden */
  20570. export var pbrDirectLightingFunctions: {
  20571. name: string;
  20572. shader: string;
  20573. };
  20574. }
  20575. declare module BABYLON {
  20576. /** @hidden */
  20577. export var pbrIBLFunctions: {
  20578. name: string;
  20579. shader: string;
  20580. };
  20581. }
  20582. declare module BABYLON {
  20583. /** @hidden */
  20584. export var pbrBlockAlbedoOpacity: {
  20585. name: string;
  20586. shader: string;
  20587. };
  20588. }
  20589. declare module BABYLON {
  20590. /** @hidden */
  20591. export var pbrBlockReflectivity: {
  20592. name: string;
  20593. shader: string;
  20594. };
  20595. }
  20596. declare module BABYLON {
  20597. /** @hidden */
  20598. export var pbrBlockAmbientOcclusion: {
  20599. name: string;
  20600. shader: string;
  20601. };
  20602. }
  20603. declare module BABYLON {
  20604. /** @hidden */
  20605. export var pbrBlockAlphaFresnel: {
  20606. name: string;
  20607. shader: string;
  20608. };
  20609. }
  20610. declare module BABYLON {
  20611. /** @hidden */
  20612. export var pbrBlockAnisotropic: {
  20613. name: string;
  20614. shader: string;
  20615. };
  20616. }
  20617. declare module BABYLON {
  20618. /** @hidden */
  20619. export var pbrBlockReflection: {
  20620. name: string;
  20621. shader: string;
  20622. };
  20623. }
  20624. declare module BABYLON {
  20625. /** @hidden */
  20626. export var pbrBlockSheen: {
  20627. name: string;
  20628. shader: string;
  20629. };
  20630. }
  20631. declare module BABYLON {
  20632. /** @hidden */
  20633. export var pbrBlockClearcoat: {
  20634. name: string;
  20635. shader: string;
  20636. };
  20637. }
  20638. declare module BABYLON {
  20639. /** @hidden */
  20640. export var pbrBlockSubSurface: {
  20641. name: string;
  20642. shader: string;
  20643. };
  20644. }
  20645. declare module BABYLON {
  20646. /** @hidden */
  20647. export var pbrBlockNormalGeometric: {
  20648. name: string;
  20649. shader: string;
  20650. };
  20651. }
  20652. declare module BABYLON {
  20653. /** @hidden */
  20654. export var pbrBlockNormalFinal: {
  20655. name: string;
  20656. shader: string;
  20657. };
  20658. }
  20659. declare module BABYLON {
  20660. /** @hidden */
  20661. export var pbrBlockLightmapInit: {
  20662. name: string;
  20663. shader: string;
  20664. };
  20665. }
  20666. declare module BABYLON {
  20667. /** @hidden */
  20668. export var pbrBlockGeometryInfo: {
  20669. name: string;
  20670. shader: string;
  20671. };
  20672. }
  20673. declare module BABYLON {
  20674. /** @hidden */
  20675. export var pbrBlockReflectance0: {
  20676. name: string;
  20677. shader: string;
  20678. };
  20679. }
  20680. declare module BABYLON {
  20681. /** @hidden */
  20682. export var pbrBlockReflectance: {
  20683. name: string;
  20684. shader: string;
  20685. };
  20686. }
  20687. declare module BABYLON {
  20688. /** @hidden */
  20689. export var pbrBlockDirectLighting: {
  20690. name: string;
  20691. shader: string;
  20692. };
  20693. }
  20694. declare module BABYLON {
  20695. /** @hidden */
  20696. export var pbrBlockFinalLitComponents: {
  20697. name: string;
  20698. shader: string;
  20699. };
  20700. }
  20701. declare module BABYLON {
  20702. /** @hidden */
  20703. export var pbrBlockFinalUnlitComponents: {
  20704. name: string;
  20705. shader: string;
  20706. };
  20707. }
  20708. declare module BABYLON {
  20709. /** @hidden */
  20710. export var pbrBlockFinalColorComposition: {
  20711. name: string;
  20712. shader: string;
  20713. };
  20714. }
  20715. declare module BABYLON {
  20716. /** @hidden */
  20717. export var pbrBlockImageProcessing: {
  20718. name: string;
  20719. shader: string;
  20720. };
  20721. }
  20722. declare module BABYLON {
  20723. /** @hidden */
  20724. export var pbrDebug: {
  20725. name: string;
  20726. shader: string;
  20727. };
  20728. }
  20729. declare module BABYLON {
  20730. /** @hidden */
  20731. export var pbrPixelShader: {
  20732. name: string;
  20733. shader: string;
  20734. };
  20735. }
  20736. declare module BABYLON {
  20737. /** @hidden */
  20738. export var pbrVertexDeclaration: {
  20739. name: string;
  20740. shader: string;
  20741. };
  20742. }
  20743. declare module BABYLON {
  20744. /** @hidden */
  20745. export var pbrVertexShader: {
  20746. name: string;
  20747. shader: string;
  20748. };
  20749. }
  20750. declare module BABYLON {
  20751. /**
  20752. * Manages the defines for the PBR Material.
  20753. * @hidden
  20754. */
  20755. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  20756. PBR: boolean;
  20757. NUM_SAMPLES: string;
  20758. REALTIME_FILTERING: boolean;
  20759. MAINUV1: boolean;
  20760. MAINUV2: boolean;
  20761. UV1: boolean;
  20762. UV2: boolean;
  20763. ALBEDO: boolean;
  20764. GAMMAALBEDO: boolean;
  20765. ALBEDODIRECTUV: number;
  20766. VERTEXCOLOR: boolean;
  20767. DETAIL: boolean;
  20768. DETAILDIRECTUV: number;
  20769. DETAIL_NORMALBLENDMETHOD: number;
  20770. AMBIENT: boolean;
  20771. AMBIENTDIRECTUV: number;
  20772. AMBIENTINGRAYSCALE: boolean;
  20773. OPACITY: boolean;
  20774. VERTEXALPHA: boolean;
  20775. OPACITYDIRECTUV: number;
  20776. OPACITYRGB: boolean;
  20777. ALPHATEST: boolean;
  20778. DEPTHPREPASS: boolean;
  20779. ALPHABLEND: boolean;
  20780. ALPHAFROMALBEDO: boolean;
  20781. ALPHATESTVALUE: string;
  20782. SPECULAROVERALPHA: boolean;
  20783. RADIANCEOVERALPHA: boolean;
  20784. ALPHAFRESNEL: boolean;
  20785. LINEARALPHAFRESNEL: boolean;
  20786. PREMULTIPLYALPHA: boolean;
  20787. EMISSIVE: boolean;
  20788. EMISSIVEDIRECTUV: number;
  20789. REFLECTIVITY: boolean;
  20790. REFLECTIVITYDIRECTUV: number;
  20791. SPECULARTERM: boolean;
  20792. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  20793. MICROSURFACEAUTOMATIC: boolean;
  20794. LODBASEDMICROSFURACE: boolean;
  20795. MICROSURFACEMAP: boolean;
  20796. MICROSURFACEMAPDIRECTUV: number;
  20797. METALLICWORKFLOW: boolean;
  20798. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  20799. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  20800. METALLNESSSTOREINMETALMAPBLUE: boolean;
  20801. AOSTOREINMETALMAPRED: boolean;
  20802. METALLIC_REFLECTANCE: boolean;
  20803. METALLIC_REFLECTANCEDIRECTUV: number;
  20804. ENVIRONMENTBRDF: boolean;
  20805. ENVIRONMENTBRDF_RGBD: boolean;
  20806. NORMAL: boolean;
  20807. TANGENT: boolean;
  20808. BUMP: boolean;
  20809. BUMPDIRECTUV: number;
  20810. OBJECTSPACE_NORMALMAP: boolean;
  20811. PARALLAX: boolean;
  20812. PARALLAXOCCLUSION: boolean;
  20813. NORMALXYSCALE: boolean;
  20814. LIGHTMAP: boolean;
  20815. LIGHTMAPDIRECTUV: number;
  20816. USELIGHTMAPASSHADOWMAP: boolean;
  20817. GAMMALIGHTMAP: boolean;
  20818. RGBDLIGHTMAP: boolean;
  20819. REFLECTION: boolean;
  20820. REFLECTIONMAP_3D: boolean;
  20821. REFLECTIONMAP_SPHERICAL: boolean;
  20822. REFLECTIONMAP_PLANAR: boolean;
  20823. REFLECTIONMAP_CUBIC: boolean;
  20824. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  20825. REFLECTIONMAP_PROJECTION: boolean;
  20826. REFLECTIONMAP_SKYBOX: boolean;
  20827. REFLECTIONMAP_EXPLICIT: boolean;
  20828. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  20829. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  20830. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  20831. INVERTCUBICMAP: boolean;
  20832. USESPHERICALFROMREFLECTIONMAP: boolean;
  20833. USEIRRADIANCEMAP: boolean;
  20834. SPHERICAL_HARMONICS: boolean;
  20835. USESPHERICALINVERTEX: boolean;
  20836. REFLECTIONMAP_OPPOSITEZ: boolean;
  20837. LODINREFLECTIONALPHA: boolean;
  20838. GAMMAREFLECTION: boolean;
  20839. RGBDREFLECTION: boolean;
  20840. LINEARSPECULARREFLECTION: boolean;
  20841. RADIANCEOCCLUSION: boolean;
  20842. HORIZONOCCLUSION: boolean;
  20843. INSTANCES: boolean;
  20844. THIN_INSTANCES: boolean;
  20845. PREPASS: boolean;
  20846. PREPASS_IRRADIANCE: boolean;
  20847. PREPASS_IRRADIANCE_INDEX: number;
  20848. PREPASS_ALBEDO: boolean;
  20849. PREPASS_ALBEDO_INDEX: number;
  20850. PREPASS_DEPTHNORMAL: boolean;
  20851. PREPASS_DEPTHNORMAL_INDEX: number;
  20852. PREPASS_POSITION: boolean;
  20853. PREPASS_POSITION_INDEX: number;
  20854. PREPASS_VELOCITY: boolean;
  20855. PREPASS_VELOCITY_INDEX: number;
  20856. PREPASS_REFLECTIVITY: boolean;
  20857. PREPASS_REFLECTIVITY_INDEX: number;
  20858. SCENE_MRT_COUNT: number;
  20859. NUM_BONE_INFLUENCERS: number;
  20860. BonesPerMesh: number;
  20861. BONETEXTURE: boolean;
  20862. BONES_VELOCITY_ENABLED: boolean;
  20863. NONUNIFORMSCALING: boolean;
  20864. MORPHTARGETS: boolean;
  20865. MORPHTARGETS_NORMAL: boolean;
  20866. MORPHTARGETS_TANGENT: boolean;
  20867. MORPHTARGETS_UV: boolean;
  20868. NUM_MORPH_INFLUENCERS: number;
  20869. IMAGEPROCESSING: boolean;
  20870. VIGNETTE: boolean;
  20871. VIGNETTEBLENDMODEMULTIPLY: boolean;
  20872. VIGNETTEBLENDMODEOPAQUE: boolean;
  20873. TONEMAPPING: boolean;
  20874. TONEMAPPING_ACES: boolean;
  20875. CONTRAST: boolean;
  20876. COLORCURVES: boolean;
  20877. COLORGRADING: boolean;
  20878. COLORGRADING3D: boolean;
  20879. SAMPLER3DGREENDEPTH: boolean;
  20880. SAMPLER3DBGRMAP: boolean;
  20881. IMAGEPROCESSINGPOSTPROCESS: boolean;
  20882. EXPOSURE: boolean;
  20883. MULTIVIEW: boolean;
  20884. USEPHYSICALLIGHTFALLOFF: boolean;
  20885. USEGLTFLIGHTFALLOFF: boolean;
  20886. TWOSIDEDLIGHTING: boolean;
  20887. SHADOWFLOAT: boolean;
  20888. CLIPPLANE: boolean;
  20889. CLIPPLANE2: boolean;
  20890. CLIPPLANE3: boolean;
  20891. CLIPPLANE4: boolean;
  20892. CLIPPLANE5: boolean;
  20893. CLIPPLANE6: boolean;
  20894. POINTSIZE: boolean;
  20895. FOG: boolean;
  20896. LOGARITHMICDEPTH: boolean;
  20897. FORCENORMALFORWARD: boolean;
  20898. SPECULARAA: boolean;
  20899. CLEARCOAT: boolean;
  20900. CLEARCOAT_DEFAULTIOR: boolean;
  20901. CLEARCOAT_TEXTURE: boolean;
  20902. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20903. CLEARCOAT_TEXTUREDIRECTUV: number;
  20904. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20905. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20906. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20907. CLEARCOAT_BUMP: boolean;
  20908. CLEARCOAT_BUMPDIRECTUV: number;
  20909. CLEARCOAT_REMAP_F0: boolean;
  20910. CLEARCOAT_TINT: boolean;
  20911. CLEARCOAT_TINT_TEXTURE: boolean;
  20912. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20913. ANISOTROPIC: boolean;
  20914. ANISOTROPIC_TEXTURE: boolean;
  20915. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20916. BRDF_V_HEIGHT_CORRELATED: boolean;
  20917. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20918. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20919. SHEEN: boolean;
  20920. SHEEN_TEXTURE: boolean;
  20921. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20922. SHEEN_TEXTUREDIRECTUV: number;
  20923. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20924. SHEEN_LINKWITHALBEDO: boolean;
  20925. SHEEN_ROUGHNESS: boolean;
  20926. SHEEN_ALBEDOSCALING: boolean;
  20927. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20928. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20929. SUBSURFACE: boolean;
  20930. SS_REFRACTION: boolean;
  20931. SS_TRANSLUCENCY: boolean;
  20932. SS_SCATTERING: boolean;
  20933. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20934. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20935. SS_REFRACTIONMAP_3D: boolean;
  20936. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20937. SS_LODINREFRACTIONALPHA: boolean;
  20938. SS_GAMMAREFRACTION: boolean;
  20939. SS_RGBDREFRACTION: boolean;
  20940. SS_LINEARSPECULARREFRACTION: boolean;
  20941. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20942. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20943. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20944. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20945. UNLIT: boolean;
  20946. DEBUGMODE: number;
  20947. /**
  20948. * Initializes the PBR Material defines.
  20949. */
  20950. constructor();
  20951. /**
  20952. * Resets the PBR Material defines.
  20953. */
  20954. reset(): void;
  20955. }
  20956. /**
  20957. * The Physically based material base class of BJS.
  20958. *
  20959. * This offers the main features of a standard PBR material.
  20960. * For more information, please refer to the documentation :
  20961. * https://doc.babylonjs.com/how_to/physically_based_rendering
  20962. */
  20963. export abstract class PBRBaseMaterial extends PushMaterial {
  20964. /**
  20965. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  20966. */
  20967. static readonly PBRMATERIAL_OPAQUE: number;
  20968. /**
  20969. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  20970. */
  20971. static readonly PBRMATERIAL_ALPHATEST: number;
  20972. /**
  20973. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20974. */
  20975. static readonly PBRMATERIAL_ALPHABLEND: number;
  20976. /**
  20977. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20978. * They are also discarded below the alpha cutoff threshold to improve performances.
  20979. */
  20980. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  20981. /**
  20982. * Defines the default value of how much AO map is occluding the analytical lights
  20983. * (point spot...).
  20984. */
  20985. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  20986. /**
  20987. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  20988. */
  20989. static readonly LIGHTFALLOFF_PHYSICAL: number;
  20990. /**
  20991. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  20992. * to enhance interoperability with other engines.
  20993. */
  20994. static readonly LIGHTFALLOFF_GLTF: number;
  20995. /**
  20996. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  20997. * to enhance interoperability with other materials.
  20998. */
  20999. static readonly LIGHTFALLOFF_STANDARD: number;
  21000. /**
  21001. * Intensity of the direct lights e.g. the four lights available in your scene.
  21002. * This impacts both the direct diffuse and specular highlights.
  21003. */
  21004. protected _directIntensity: number;
  21005. /**
  21006. * Intensity of the emissive part of the material.
  21007. * This helps controlling the emissive effect without modifying the emissive color.
  21008. */
  21009. protected _emissiveIntensity: number;
  21010. /**
  21011. * Intensity of the environment e.g. how much the environment will light the object
  21012. * either through harmonics for rough material or through the refelction for shiny ones.
  21013. */
  21014. protected _environmentIntensity: number;
  21015. /**
  21016. * This is a special control allowing the reduction of the specular highlights coming from the
  21017. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21018. */
  21019. protected _specularIntensity: number;
  21020. /**
  21021. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21022. */
  21023. private _lightingInfos;
  21024. /**
  21025. * Debug Control allowing disabling the bump map on this material.
  21026. */
  21027. protected _disableBumpMap: boolean;
  21028. /**
  21029. * AKA Diffuse Texture in standard nomenclature.
  21030. */
  21031. protected _albedoTexture: Nullable<BaseTexture>;
  21032. /**
  21033. * AKA Occlusion Texture in other nomenclature.
  21034. */
  21035. protected _ambientTexture: Nullable<BaseTexture>;
  21036. /**
  21037. * AKA Occlusion Texture Intensity in other nomenclature.
  21038. */
  21039. protected _ambientTextureStrength: number;
  21040. /**
  21041. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21042. * 1 means it completely occludes it
  21043. * 0 mean it has no impact
  21044. */
  21045. protected _ambientTextureImpactOnAnalyticalLights: number;
  21046. /**
  21047. * Stores the alpha values in a texture.
  21048. */
  21049. protected _opacityTexture: Nullable<BaseTexture>;
  21050. /**
  21051. * Stores the reflection values in a texture.
  21052. */
  21053. protected _reflectionTexture: Nullable<BaseTexture>;
  21054. /**
  21055. * Stores the emissive values in a texture.
  21056. */
  21057. protected _emissiveTexture: Nullable<BaseTexture>;
  21058. /**
  21059. * AKA Specular texture in other nomenclature.
  21060. */
  21061. protected _reflectivityTexture: Nullable<BaseTexture>;
  21062. /**
  21063. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21064. */
  21065. protected _metallicTexture: Nullable<BaseTexture>;
  21066. /**
  21067. * Specifies the metallic scalar of the metallic/roughness workflow.
  21068. * Can also be used to scale the metalness values of the metallic texture.
  21069. */
  21070. protected _metallic: Nullable<number>;
  21071. /**
  21072. * Specifies the roughness scalar of the metallic/roughness workflow.
  21073. * Can also be used to scale the roughness values of the metallic texture.
  21074. */
  21075. protected _roughness: Nullable<number>;
  21076. /**
  21077. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21078. * By default the indexOfrefraction is used to compute F0;
  21079. *
  21080. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21081. *
  21082. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21083. * F90 = metallicReflectanceColor;
  21084. */
  21085. protected _metallicF0Factor: number;
  21086. /**
  21087. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21088. * By default the F90 is always 1;
  21089. *
  21090. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21091. *
  21092. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21093. * F90 = metallicReflectanceColor;
  21094. */
  21095. protected _metallicReflectanceColor: Color3;
  21096. /**
  21097. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21098. * This is multiply against the scalar values defined in the material.
  21099. */
  21100. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21101. /**
  21102. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21103. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21104. */
  21105. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21106. /**
  21107. * Stores surface normal data used to displace a mesh in a texture.
  21108. */
  21109. protected _bumpTexture: Nullable<BaseTexture>;
  21110. /**
  21111. * Stores the pre-calculated light information of a mesh in a texture.
  21112. */
  21113. protected _lightmapTexture: Nullable<BaseTexture>;
  21114. /**
  21115. * The color of a material in ambient lighting.
  21116. */
  21117. protected _ambientColor: Color3;
  21118. /**
  21119. * AKA Diffuse Color in other nomenclature.
  21120. */
  21121. protected _albedoColor: Color3;
  21122. /**
  21123. * AKA Specular Color in other nomenclature.
  21124. */
  21125. protected _reflectivityColor: Color3;
  21126. /**
  21127. * The color applied when light is reflected from a material.
  21128. */
  21129. protected _reflectionColor: Color3;
  21130. /**
  21131. * The color applied when light is emitted from a material.
  21132. */
  21133. protected _emissiveColor: Color3;
  21134. /**
  21135. * AKA Glossiness in other nomenclature.
  21136. */
  21137. protected _microSurface: number;
  21138. /**
  21139. * Specifies that the material will use the light map as a show map.
  21140. */
  21141. protected _useLightmapAsShadowmap: boolean;
  21142. /**
  21143. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21144. * makes the reflect vector face the model (under horizon).
  21145. */
  21146. protected _useHorizonOcclusion: boolean;
  21147. /**
  21148. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21149. * too much the area relying on ambient texture to define their ambient occlusion.
  21150. */
  21151. protected _useRadianceOcclusion: boolean;
  21152. /**
  21153. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21154. */
  21155. protected _useAlphaFromAlbedoTexture: boolean;
  21156. /**
  21157. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21158. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21159. */
  21160. protected _useSpecularOverAlpha: boolean;
  21161. /**
  21162. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21163. */
  21164. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21165. /**
  21166. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21167. */
  21168. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21169. /**
  21170. * Specifies if the metallic texture contains the roughness information in its green channel.
  21171. */
  21172. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21173. /**
  21174. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21175. */
  21176. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21177. /**
  21178. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21179. */
  21180. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21181. /**
  21182. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21183. */
  21184. protected _useAmbientInGrayScale: boolean;
  21185. /**
  21186. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21187. * The material will try to infer what glossiness each pixel should be.
  21188. */
  21189. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21190. /**
  21191. * Defines the falloff type used in this material.
  21192. * It by default is Physical.
  21193. */
  21194. protected _lightFalloff: number;
  21195. /**
  21196. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21197. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21198. */
  21199. protected _useRadianceOverAlpha: boolean;
  21200. /**
  21201. * Allows using an object space normal map (instead of tangent space).
  21202. */
  21203. protected _useObjectSpaceNormalMap: boolean;
  21204. /**
  21205. * Allows using the bump map in parallax mode.
  21206. */
  21207. protected _useParallax: boolean;
  21208. /**
  21209. * Allows using the bump map in parallax occlusion mode.
  21210. */
  21211. protected _useParallaxOcclusion: boolean;
  21212. /**
  21213. * Controls the scale bias of the parallax mode.
  21214. */
  21215. protected _parallaxScaleBias: number;
  21216. /**
  21217. * If sets to true, disables all the lights affecting the material.
  21218. */
  21219. protected _disableLighting: boolean;
  21220. /**
  21221. * Number of Simultaneous lights allowed on the material.
  21222. */
  21223. protected _maxSimultaneousLights: number;
  21224. /**
  21225. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21226. */
  21227. protected _invertNormalMapX: boolean;
  21228. /**
  21229. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21230. */
  21231. protected _invertNormalMapY: boolean;
  21232. /**
  21233. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21234. */
  21235. protected _twoSidedLighting: boolean;
  21236. /**
  21237. * Defines the alpha limits in alpha test mode.
  21238. */
  21239. protected _alphaCutOff: number;
  21240. /**
  21241. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21242. */
  21243. protected _forceAlphaTest: boolean;
  21244. /**
  21245. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21246. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21247. */
  21248. protected _useAlphaFresnel: boolean;
  21249. /**
  21250. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21251. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21252. */
  21253. protected _useLinearAlphaFresnel: boolean;
  21254. /**
  21255. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  21256. * from cos thetav and roughness:
  21257. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  21258. */
  21259. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  21260. /**
  21261. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21262. */
  21263. protected _forceIrradianceInFragment: boolean;
  21264. private _realTimeFiltering;
  21265. /**
  21266. * Enables realtime filtering on the texture.
  21267. */
  21268. get realTimeFiltering(): boolean;
  21269. set realTimeFiltering(b: boolean);
  21270. private _realTimeFilteringQuality;
  21271. /**
  21272. * Quality switch for realtime filtering
  21273. */
  21274. get realTimeFilteringQuality(): number;
  21275. set realTimeFilteringQuality(n: number);
  21276. /**
  21277. * Can this material render to several textures at once
  21278. */
  21279. get canRenderToMRT(): boolean;
  21280. /**
  21281. * Force normal to face away from face.
  21282. */
  21283. protected _forceNormalForward: boolean;
  21284. /**
  21285. * Enables specular anti aliasing in the PBR shader.
  21286. * It will both interacts on the Geometry for analytical and IBL lighting.
  21287. * It also prefilter the roughness map based on the bump values.
  21288. */
  21289. protected _enableSpecularAntiAliasing: boolean;
  21290. /**
  21291. * Default configuration related to image processing available in the PBR Material.
  21292. */
  21293. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21294. /**
  21295. * Keep track of the image processing observer to allow dispose and replace.
  21296. */
  21297. private _imageProcessingObserver;
  21298. /**
  21299. * Attaches a new image processing configuration to the PBR Material.
  21300. * @param configuration
  21301. */
  21302. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  21303. /**
  21304. * Stores the available render targets.
  21305. */
  21306. private _renderTargets;
  21307. /**
  21308. * Sets the global ambient color for the material used in lighting calculations.
  21309. */
  21310. private _globalAmbientColor;
  21311. /**
  21312. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  21313. */
  21314. private _useLogarithmicDepth;
  21315. /**
  21316. * If set to true, no lighting calculations will be applied.
  21317. */
  21318. private _unlit;
  21319. private _debugMode;
  21320. /**
  21321. * @hidden
  21322. * This is reserved for the inspector.
  21323. * Defines the material debug mode.
  21324. * It helps seeing only some components of the material while troubleshooting.
  21325. */
  21326. debugMode: number;
  21327. /**
  21328. * @hidden
  21329. * This is reserved for the inspector.
  21330. * Specify from where on screen the debug mode should start.
  21331. * The value goes from -1 (full screen) to 1 (not visible)
  21332. * It helps with side by side comparison against the final render
  21333. * This defaults to -1
  21334. */
  21335. private debugLimit;
  21336. /**
  21337. * @hidden
  21338. * This is reserved for the inspector.
  21339. * As the default viewing range might not be enough (if the ambient is really small for instance)
  21340. * You can use the factor to better multiply the final value.
  21341. */
  21342. private debugFactor;
  21343. /**
  21344. * Defines the clear coat layer parameters for the material.
  21345. */
  21346. readonly clearCoat: PBRClearCoatConfiguration;
  21347. /**
  21348. * Defines the anisotropic parameters for the material.
  21349. */
  21350. readonly anisotropy: PBRAnisotropicConfiguration;
  21351. /**
  21352. * Defines the BRDF parameters for the material.
  21353. */
  21354. readonly brdf: PBRBRDFConfiguration;
  21355. /**
  21356. * Defines the Sheen parameters for the material.
  21357. */
  21358. readonly sheen: PBRSheenConfiguration;
  21359. /**
  21360. * Defines the SubSurface parameters for the material.
  21361. */
  21362. readonly subSurface: PBRSubSurfaceConfiguration;
  21363. /**
  21364. * Defines additionnal PrePass parameters for the material.
  21365. */
  21366. readonly prePassConfiguration: PrePassConfiguration;
  21367. /**
  21368. * Defines the detail map parameters for the material.
  21369. */
  21370. readonly detailMap: DetailMapConfiguration;
  21371. protected _rebuildInParallel: boolean;
  21372. /**
  21373. * Instantiates a new PBRMaterial instance.
  21374. *
  21375. * @param name The material name
  21376. * @param scene The scene the material will be use in.
  21377. */
  21378. constructor(name: string, scene: Scene);
  21379. /**
  21380. * Gets a boolean indicating that current material needs to register RTT
  21381. */
  21382. get hasRenderTargetTextures(): boolean;
  21383. /**
  21384. * Gets the name of the material class.
  21385. */
  21386. getClassName(): string;
  21387. /**
  21388. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21389. */
  21390. get useLogarithmicDepth(): boolean;
  21391. /**
  21392. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21393. */
  21394. set useLogarithmicDepth(value: boolean);
  21395. /**
  21396. * Returns true if alpha blending should be disabled.
  21397. */
  21398. protected get _disableAlphaBlending(): boolean;
  21399. /**
  21400. * Specifies whether or not this material should be rendered in alpha blend mode.
  21401. */
  21402. needAlphaBlending(): boolean;
  21403. /**
  21404. * Specifies whether or not this material should be rendered in alpha test mode.
  21405. */
  21406. needAlphaTesting(): boolean;
  21407. /**
  21408. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  21409. */
  21410. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  21411. /**
  21412. * Specifies whether or not there is a usable alpha channel for transparency.
  21413. */
  21414. protected _hasAlphaChannel(): boolean;
  21415. /**
  21416. * Gets the texture used for the alpha test.
  21417. */
  21418. getAlphaTestTexture(): Nullable<BaseTexture>;
  21419. /**
  21420. * Specifies that the submesh is ready to be used.
  21421. * @param mesh - BJS mesh.
  21422. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  21423. * @param useInstances - Specifies that instances should be used.
  21424. * @returns - boolean indicating that the submesh is ready or not.
  21425. */
  21426. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  21427. /**
  21428. * Specifies if the material uses metallic roughness workflow.
  21429. * @returns boolean specifiying if the material uses metallic roughness workflow.
  21430. */
  21431. isMetallicWorkflow(): boolean;
  21432. private _prepareEffect;
  21433. private _prepareDefines;
  21434. /**
  21435. * Force shader compilation
  21436. */
  21437. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  21438. /**
  21439. * Initializes the uniform buffer layout for the shader.
  21440. */
  21441. buildUniformLayout(): void;
  21442. /**
  21443. * Unbinds the material from the mesh
  21444. */
  21445. unbind(): void;
  21446. /**
  21447. * Binds the submesh data.
  21448. * @param world - The world matrix.
  21449. * @param mesh - The BJS mesh.
  21450. * @param subMesh - A submesh of the BJS mesh.
  21451. */
  21452. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21453. /**
  21454. * Returns the animatable textures.
  21455. * @returns - Array of animatable textures.
  21456. */
  21457. getAnimatables(): IAnimatable[];
  21458. /**
  21459. * Returns the texture used for reflections.
  21460. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  21461. */
  21462. private _getReflectionTexture;
  21463. /**
  21464. * Returns an array of the actively used textures.
  21465. * @returns - Array of BaseTextures
  21466. */
  21467. getActiveTextures(): BaseTexture[];
  21468. /**
  21469. * Checks to see if a texture is used in the material.
  21470. * @param texture - Base texture to use.
  21471. * @returns - Boolean specifying if a texture is used in the material.
  21472. */
  21473. hasTexture(texture: BaseTexture): boolean;
  21474. /**
  21475. * Sets the required values to the prepass renderer.
  21476. * @param prePassRenderer defines the prepass renderer to setup
  21477. */
  21478. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  21479. /**
  21480. * Disposes the resources of the material.
  21481. * @param forceDisposeEffect - Forces the disposal of effects.
  21482. * @param forceDisposeTextures - Forces the disposal of all textures.
  21483. */
  21484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  21485. }
  21486. }
  21487. declare module BABYLON {
  21488. /**
  21489. * The Physically based material of BJS.
  21490. *
  21491. * This offers the main features of a standard PBR material.
  21492. * For more information, please refer to the documentation :
  21493. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21494. */
  21495. export class PBRMaterial extends PBRBaseMaterial {
  21496. /**
  21497. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21498. */
  21499. static readonly PBRMATERIAL_OPAQUE: number;
  21500. /**
  21501. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21502. */
  21503. static readonly PBRMATERIAL_ALPHATEST: number;
  21504. /**
  21505. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21506. */
  21507. static readonly PBRMATERIAL_ALPHABLEND: number;
  21508. /**
  21509. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21510. * They are also discarded below the alpha cutoff threshold to improve performances.
  21511. */
  21512. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21513. /**
  21514. * Defines the default value of how much AO map is occluding the analytical lights
  21515. * (point spot...).
  21516. */
  21517. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21518. /**
  21519. * Intensity of the direct lights e.g. the four lights available in your scene.
  21520. * This impacts both the direct diffuse and specular highlights.
  21521. */
  21522. directIntensity: number;
  21523. /**
  21524. * Intensity of the emissive part of the material.
  21525. * This helps controlling the emissive effect without modifying the emissive color.
  21526. */
  21527. emissiveIntensity: number;
  21528. /**
  21529. * Intensity of the environment e.g. how much the environment will light the object
  21530. * either through harmonics for rough material or through the refelction for shiny ones.
  21531. */
  21532. environmentIntensity: number;
  21533. /**
  21534. * This is a special control allowing the reduction of the specular highlights coming from the
  21535. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21536. */
  21537. specularIntensity: number;
  21538. /**
  21539. * Debug Control allowing disabling the bump map on this material.
  21540. */
  21541. disableBumpMap: boolean;
  21542. /**
  21543. * AKA Diffuse Texture in standard nomenclature.
  21544. */
  21545. albedoTexture: BaseTexture;
  21546. /**
  21547. * AKA Occlusion Texture in other nomenclature.
  21548. */
  21549. ambientTexture: BaseTexture;
  21550. /**
  21551. * AKA Occlusion Texture Intensity in other nomenclature.
  21552. */
  21553. ambientTextureStrength: number;
  21554. /**
  21555. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21556. * 1 means it completely occludes it
  21557. * 0 mean it has no impact
  21558. */
  21559. ambientTextureImpactOnAnalyticalLights: number;
  21560. /**
  21561. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  21562. */
  21563. opacityTexture: BaseTexture;
  21564. /**
  21565. * Stores the reflection values in a texture.
  21566. */
  21567. reflectionTexture: Nullable<BaseTexture>;
  21568. /**
  21569. * Stores the emissive values in a texture.
  21570. */
  21571. emissiveTexture: BaseTexture;
  21572. /**
  21573. * AKA Specular texture in other nomenclature.
  21574. */
  21575. reflectivityTexture: BaseTexture;
  21576. /**
  21577. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21578. */
  21579. metallicTexture: BaseTexture;
  21580. /**
  21581. * Specifies the metallic scalar of the metallic/roughness workflow.
  21582. * Can also be used to scale the metalness values of the metallic texture.
  21583. */
  21584. metallic: Nullable<number>;
  21585. /**
  21586. * Specifies the roughness scalar of the metallic/roughness workflow.
  21587. * Can also be used to scale the roughness values of the metallic texture.
  21588. */
  21589. roughness: Nullable<number>;
  21590. /**
  21591. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21592. * By default the indexOfrefraction is used to compute F0;
  21593. *
  21594. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21595. *
  21596. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21597. * F90 = metallicReflectanceColor;
  21598. */
  21599. metallicF0Factor: number;
  21600. /**
  21601. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21602. * By default the F90 is always 1;
  21603. *
  21604. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21605. *
  21606. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21607. * F90 = metallicReflectanceColor;
  21608. */
  21609. metallicReflectanceColor: Color3;
  21610. /**
  21611. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21612. * This is multiply against the scalar values defined in the material.
  21613. */
  21614. metallicReflectanceTexture: Nullable<BaseTexture>;
  21615. /**
  21616. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21617. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21618. */
  21619. microSurfaceTexture: BaseTexture;
  21620. /**
  21621. * Stores surface normal data used to displace a mesh in a texture.
  21622. */
  21623. bumpTexture: BaseTexture;
  21624. /**
  21625. * Stores the pre-calculated light information of a mesh in a texture.
  21626. */
  21627. lightmapTexture: BaseTexture;
  21628. /**
  21629. * Stores the refracted light information in a texture.
  21630. */
  21631. get refractionTexture(): Nullable<BaseTexture>;
  21632. set refractionTexture(value: Nullable<BaseTexture>);
  21633. /**
  21634. * The color of a material in ambient lighting.
  21635. */
  21636. ambientColor: Color3;
  21637. /**
  21638. * AKA Diffuse Color in other nomenclature.
  21639. */
  21640. albedoColor: Color3;
  21641. /**
  21642. * AKA Specular Color in other nomenclature.
  21643. */
  21644. reflectivityColor: Color3;
  21645. /**
  21646. * The color reflected from the material.
  21647. */
  21648. reflectionColor: Color3;
  21649. /**
  21650. * The color emitted from the material.
  21651. */
  21652. emissiveColor: Color3;
  21653. /**
  21654. * AKA Glossiness in other nomenclature.
  21655. */
  21656. microSurface: number;
  21657. /**
  21658. * Index of refraction of the material base layer.
  21659. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21660. *
  21661. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21662. *
  21663. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21664. */
  21665. get indexOfRefraction(): number;
  21666. set indexOfRefraction(value: number);
  21667. /**
  21668. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21669. */
  21670. get invertRefractionY(): boolean;
  21671. set invertRefractionY(value: boolean);
  21672. /**
  21673. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21674. * Materials half opaque for instance using refraction could benefit from this control.
  21675. */
  21676. get linkRefractionWithTransparency(): boolean;
  21677. set linkRefractionWithTransparency(value: boolean);
  21678. /**
  21679. * If true, the light map contains occlusion information instead of lighting info.
  21680. */
  21681. useLightmapAsShadowmap: boolean;
  21682. /**
  21683. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21684. */
  21685. useAlphaFromAlbedoTexture: boolean;
  21686. /**
  21687. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21688. */
  21689. forceAlphaTest: boolean;
  21690. /**
  21691. * Defines the alpha limits in alpha test mode.
  21692. */
  21693. alphaCutOff: number;
  21694. /**
  21695. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  21696. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21697. */
  21698. useSpecularOverAlpha: boolean;
  21699. /**
  21700. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21701. */
  21702. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21703. /**
  21704. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21705. */
  21706. useRoughnessFromMetallicTextureAlpha: boolean;
  21707. /**
  21708. * Specifies if the metallic texture contains the roughness information in its green channel.
  21709. */
  21710. useRoughnessFromMetallicTextureGreen: boolean;
  21711. /**
  21712. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21713. */
  21714. useMetallnessFromMetallicTextureBlue: boolean;
  21715. /**
  21716. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21717. */
  21718. useAmbientOcclusionFromMetallicTextureRed: boolean;
  21719. /**
  21720. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21721. */
  21722. useAmbientInGrayScale: boolean;
  21723. /**
  21724. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21725. * The material will try to infer what glossiness each pixel should be.
  21726. */
  21727. useAutoMicroSurfaceFromReflectivityMap: boolean;
  21728. /**
  21729. * BJS is using an harcoded light falloff based on a manually sets up range.
  21730. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21731. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21732. */
  21733. get usePhysicalLightFalloff(): boolean;
  21734. /**
  21735. * BJS is using an harcoded light falloff based on a manually sets up range.
  21736. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21737. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21738. */
  21739. set usePhysicalLightFalloff(value: boolean);
  21740. /**
  21741. * In order to support the falloff compatibility with gltf, a special mode has been added
  21742. * to reproduce the gltf light falloff.
  21743. */
  21744. get useGLTFLightFalloff(): boolean;
  21745. /**
  21746. * In order to support the falloff compatibility with gltf, a special mode has been added
  21747. * to reproduce the gltf light falloff.
  21748. */
  21749. set useGLTFLightFalloff(value: boolean);
  21750. /**
  21751. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21752. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21753. */
  21754. useRadianceOverAlpha: boolean;
  21755. /**
  21756. * Allows using an object space normal map (instead of tangent space).
  21757. */
  21758. useObjectSpaceNormalMap: boolean;
  21759. /**
  21760. * Allows using the bump map in parallax mode.
  21761. */
  21762. useParallax: boolean;
  21763. /**
  21764. * Allows using the bump map in parallax occlusion mode.
  21765. */
  21766. useParallaxOcclusion: boolean;
  21767. /**
  21768. * Controls the scale bias of the parallax mode.
  21769. */
  21770. parallaxScaleBias: number;
  21771. /**
  21772. * If sets to true, disables all the lights affecting the material.
  21773. */
  21774. disableLighting: boolean;
  21775. /**
  21776. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21777. */
  21778. forceIrradianceInFragment: boolean;
  21779. /**
  21780. * Number of Simultaneous lights allowed on the material.
  21781. */
  21782. maxSimultaneousLights: number;
  21783. /**
  21784. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  21785. */
  21786. invertNormalMapX: boolean;
  21787. /**
  21788. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  21789. */
  21790. invertNormalMapY: boolean;
  21791. /**
  21792. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21793. */
  21794. twoSidedLighting: boolean;
  21795. /**
  21796. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21797. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21798. */
  21799. useAlphaFresnel: boolean;
  21800. /**
  21801. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21802. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21803. */
  21804. useLinearAlphaFresnel: boolean;
  21805. /**
  21806. * Let user defines the brdf lookup texture used for IBL.
  21807. * A default 8bit version is embedded but you could point at :
  21808. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  21809. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  21810. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  21811. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  21812. */
  21813. environmentBRDFTexture: Nullable<BaseTexture>;
  21814. /**
  21815. * Force normal to face away from face.
  21816. */
  21817. forceNormalForward: boolean;
  21818. /**
  21819. * Enables specular anti aliasing in the PBR shader.
  21820. * It will both interacts on the Geometry for analytical and IBL lighting.
  21821. * It also prefilter the roughness map based on the bump values.
  21822. */
  21823. enableSpecularAntiAliasing: boolean;
  21824. /**
  21825. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21826. * makes the reflect vector face the model (under horizon).
  21827. */
  21828. useHorizonOcclusion: boolean;
  21829. /**
  21830. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21831. * too much the area relying on ambient texture to define their ambient occlusion.
  21832. */
  21833. useRadianceOcclusion: boolean;
  21834. /**
  21835. * If set to true, no lighting calculations will be applied.
  21836. */
  21837. unlit: boolean;
  21838. /**
  21839. * Gets the image processing configuration used either in this material.
  21840. */
  21841. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  21842. /**
  21843. * Sets the Default image processing configuration used either in the this material.
  21844. *
  21845. * If sets to null, the scene one is in use.
  21846. */
  21847. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  21848. /**
  21849. * Gets wether the color curves effect is enabled.
  21850. */
  21851. get cameraColorCurvesEnabled(): boolean;
  21852. /**
  21853. * Sets wether the color curves effect is enabled.
  21854. */
  21855. set cameraColorCurvesEnabled(value: boolean);
  21856. /**
  21857. * Gets wether the color grading effect is enabled.
  21858. */
  21859. get cameraColorGradingEnabled(): boolean;
  21860. /**
  21861. * Gets wether the color grading effect is enabled.
  21862. */
  21863. set cameraColorGradingEnabled(value: boolean);
  21864. /**
  21865. * Gets wether tonemapping is enabled or not.
  21866. */
  21867. get cameraToneMappingEnabled(): boolean;
  21868. /**
  21869. * Sets wether tonemapping is enabled or not
  21870. */
  21871. set cameraToneMappingEnabled(value: boolean);
  21872. /**
  21873. * The camera exposure used on this material.
  21874. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21875. * This corresponds to a photographic exposure.
  21876. */
  21877. get cameraExposure(): number;
  21878. /**
  21879. * The camera exposure used on this material.
  21880. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21881. * This corresponds to a photographic exposure.
  21882. */
  21883. set cameraExposure(value: number);
  21884. /**
  21885. * Gets The camera contrast used on this material.
  21886. */
  21887. get cameraContrast(): number;
  21888. /**
  21889. * Sets The camera contrast used on this material.
  21890. */
  21891. set cameraContrast(value: number);
  21892. /**
  21893. * Gets the Color Grading 2D Lookup Texture.
  21894. */
  21895. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  21896. /**
  21897. * Sets the Color Grading 2D Lookup Texture.
  21898. */
  21899. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  21900. /**
  21901. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21902. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21903. * 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;
  21904. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21905. */
  21906. get cameraColorCurves(): Nullable<ColorCurves>;
  21907. /**
  21908. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21909. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21910. * 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;
  21911. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21912. */
  21913. set cameraColorCurves(value: Nullable<ColorCurves>);
  21914. /**
  21915. * Instantiates a new PBRMaterial instance.
  21916. *
  21917. * @param name The material name
  21918. * @param scene The scene the material will be use in.
  21919. */
  21920. constructor(name: string, scene: Scene);
  21921. /**
  21922. * Returns the name of this material class.
  21923. */
  21924. getClassName(): string;
  21925. /**
  21926. * Makes a duplicate of the current material.
  21927. * @param name - name to use for the new material.
  21928. */
  21929. clone(name: string): PBRMaterial;
  21930. /**
  21931. * Serializes this PBR Material.
  21932. * @returns - An object with the serialized material.
  21933. */
  21934. serialize(): any;
  21935. /**
  21936. * Parses a PBR Material from a serialized object.
  21937. * @param source - Serialized object.
  21938. * @param scene - BJS scene instance.
  21939. * @param rootUrl - url for the scene object
  21940. * @returns - PBRMaterial
  21941. */
  21942. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  21943. }
  21944. }
  21945. declare module BABYLON {
  21946. /** @hidden */
  21947. export var mrtFragmentDeclaration: {
  21948. name: string;
  21949. shader: string;
  21950. };
  21951. }
  21952. declare module BABYLON {
  21953. /** @hidden */
  21954. export var geometryPixelShader: {
  21955. name: string;
  21956. shader: string;
  21957. };
  21958. }
  21959. declare module BABYLON {
  21960. /** @hidden */
  21961. export var geometryVertexShader: {
  21962. name: string;
  21963. shader: string;
  21964. };
  21965. }
  21966. declare module BABYLON {
  21967. /** @hidden */
  21968. interface ISavedTransformationMatrix {
  21969. world: Matrix;
  21970. viewProjection: Matrix;
  21971. }
  21972. /**
  21973. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  21974. */
  21975. export class GeometryBufferRenderer {
  21976. /**
  21977. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  21978. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  21979. */
  21980. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  21981. /**
  21982. * Constant used to retrieve the position texture index in the G-Buffer textures array
  21983. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  21984. */
  21985. static readonly POSITION_TEXTURE_TYPE: number;
  21986. /**
  21987. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  21988. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  21989. */
  21990. static readonly VELOCITY_TEXTURE_TYPE: number;
  21991. /**
  21992. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  21993. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  21994. */
  21995. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  21996. /**
  21997. * Dictionary used to store the previous transformation matrices of each rendered mesh
  21998. * in order to compute objects velocities when enableVelocity is set to "true"
  21999. * @hidden
  22000. */
  22001. _previousTransformationMatrices: {
  22002. [index: number]: ISavedTransformationMatrix;
  22003. };
  22004. /**
  22005. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22006. * in order to compute objects velocities when enableVelocity is set to "true"
  22007. * @hidden
  22008. */
  22009. _previousBonesTransformationMatrices: {
  22010. [index: number]: Float32Array;
  22011. };
  22012. /**
  22013. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22014. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22015. */
  22016. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22017. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22018. renderTransparentMeshes: boolean;
  22019. private _scene;
  22020. private _resizeObserver;
  22021. private _multiRenderTarget;
  22022. private _ratio;
  22023. private _enablePosition;
  22024. private _enableVelocity;
  22025. private _enableReflectivity;
  22026. private _positionIndex;
  22027. private _velocityIndex;
  22028. private _reflectivityIndex;
  22029. private _depthNormalIndex;
  22030. private _linkedWithPrePass;
  22031. private _prePassRenderer;
  22032. private _attachments;
  22033. protected _effect: Effect;
  22034. protected _cachedDefines: string;
  22035. /**
  22036. * @hidden
  22037. * Sets up internal structures to share outputs with PrePassRenderer
  22038. * This method should only be called by the PrePassRenderer itself
  22039. */
  22040. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22041. /**
  22042. * @hidden
  22043. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22044. * This method should only be called by the PrePassRenderer itself
  22045. */
  22046. _unlinkPrePassRenderer(): void;
  22047. /**
  22048. * @hidden
  22049. * Resets the geometry buffer layout
  22050. */
  22051. _resetLayout(): void;
  22052. /**
  22053. * @hidden
  22054. * Replaces a texture in the geometry buffer renderer
  22055. * Useful when linking textures of the prepass renderer
  22056. */
  22057. _forceTextureType(geometryBufferType: number, index: number): void;
  22058. /**
  22059. * @hidden
  22060. * Sets texture attachments
  22061. * Useful when linking textures of the prepass renderer
  22062. */
  22063. _setAttachments(attachments: number[]): void;
  22064. /**
  22065. * @hidden
  22066. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22067. * Useful when linking textures of the prepass renderer
  22068. */
  22069. _linkInternalTexture(internalTexture: InternalTexture): void;
  22070. /**
  22071. * Gets the render list (meshes to be rendered) used in the G buffer.
  22072. */
  22073. get renderList(): Nullable<AbstractMesh[]>;
  22074. /**
  22075. * Set the render list (meshes to be rendered) used in the G buffer.
  22076. */
  22077. set renderList(meshes: Nullable<AbstractMesh[]>);
  22078. /**
  22079. * Gets wether or not G buffer are supported by the running hardware.
  22080. * This requires draw buffer supports
  22081. */
  22082. get isSupported(): boolean;
  22083. /**
  22084. * Returns the index of the given texture type in the G-Buffer textures array
  22085. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22086. * @returns the index of the given texture type in the G-Buffer textures array
  22087. */
  22088. getTextureIndex(textureType: number): number;
  22089. /**
  22090. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22091. */
  22092. get enablePosition(): boolean;
  22093. /**
  22094. * Sets whether or not objects positions are enabled for the G buffer.
  22095. */
  22096. set enablePosition(enable: boolean);
  22097. /**
  22098. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22099. */
  22100. get enableVelocity(): boolean;
  22101. /**
  22102. * Sets wether or not objects velocities are enabled for the G buffer.
  22103. */
  22104. set enableVelocity(enable: boolean);
  22105. /**
  22106. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22107. */
  22108. get enableReflectivity(): boolean;
  22109. /**
  22110. * Sets wether or not objects roughness are enabled for the G buffer.
  22111. */
  22112. set enableReflectivity(enable: boolean);
  22113. /**
  22114. * Gets the scene associated with the buffer.
  22115. */
  22116. get scene(): Scene;
  22117. /**
  22118. * Gets the ratio used by the buffer during its creation.
  22119. * How big is the buffer related to the main canvas.
  22120. */
  22121. get ratio(): number;
  22122. /** @hidden */
  22123. static _SceneComponentInitialization: (scene: Scene) => void;
  22124. /**
  22125. * Creates a new G Buffer for the scene
  22126. * @param scene The scene the buffer belongs to
  22127. * @param ratio How big is the buffer related to the main canvas.
  22128. */
  22129. constructor(scene: Scene, ratio?: number);
  22130. /**
  22131. * Checks wether everything is ready to render a submesh to the G buffer.
  22132. * @param subMesh the submesh to check readiness for
  22133. * @param useInstances is the mesh drawn using instance or not
  22134. * @returns true if ready otherwise false
  22135. */
  22136. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22137. /**
  22138. * Gets the current underlying G Buffer.
  22139. * @returns the buffer
  22140. */
  22141. getGBuffer(): MultiRenderTarget;
  22142. /**
  22143. * Gets the number of samples used to render the buffer (anti aliasing).
  22144. */
  22145. get samples(): number;
  22146. /**
  22147. * Sets the number of samples used to render the buffer (anti aliasing).
  22148. */
  22149. set samples(value: number);
  22150. /**
  22151. * Disposes the renderer and frees up associated resources.
  22152. */
  22153. dispose(): void;
  22154. private _assignRenderTargetIndices;
  22155. protected _createRenderTargets(): void;
  22156. private _copyBonesTransformationMatrices;
  22157. }
  22158. }
  22159. declare module BABYLON {
  22160. /**
  22161. * Renders a pre pass of the scene
  22162. * This means every mesh in the scene will be rendered to a render target texture
  22163. * And then this texture will be composited to the rendering canvas with post processes
  22164. * It is necessary for effects like subsurface scattering or deferred shading
  22165. */
  22166. export class PrePassRenderer {
  22167. /** @hidden */
  22168. static _SceneComponentInitialization: (scene: Scene) => void;
  22169. private _textureFormats;
  22170. /**
  22171. * To save performance, we can excluded skinned meshes from the prepass
  22172. */
  22173. excludedSkinnedMesh: AbstractMesh[];
  22174. /**
  22175. * Force material to be excluded from the prepass
  22176. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22177. * and you don't want a material to show in the effect.
  22178. */
  22179. excludedMaterials: Material[];
  22180. private _textureIndices;
  22181. private _scene;
  22182. private _engine;
  22183. private _isDirty;
  22184. /**
  22185. * Number of textures in the multi render target texture where the scene is directly rendered
  22186. */
  22187. mrtCount: number;
  22188. /**
  22189. * The render target where the scene is directly rendered
  22190. */
  22191. prePassRT: MultiRenderTarget;
  22192. private _multiRenderAttachments;
  22193. private _defaultAttachments;
  22194. private _clearAttachments;
  22195. private _postProcesses;
  22196. private readonly _clearColor;
  22197. /**
  22198. * Image processing post process for composition
  22199. */
  22200. imageProcessingPostProcess: ImageProcessingPostProcess;
  22201. /**
  22202. * Configuration for prepass effects
  22203. */
  22204. private _effectConfigurations;
  22205. private _mrtFormats;
  22206. private _mrtLayout;
  22207. private _enabled;
  22208. /**
  22209. * Indicates if the prepass is enabled
  22210. */
  22211. get enabled(): boolean;
  22212. /**
  22213. * How many samples are used for MSAA of the scene render target
  22214. */
  22215. get samples(): number;
  22216. set samples(n: number);
  22217. private _geometryBuffer;
  22218. private _useGeometryBufferFallback;
  22219. /**
  22220. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22221. */
  22222. get useGeometryBufferFallback(): boolean;
  22223. set useGeometryBufferFallback(value: boolean);
  22224. /**
  22225. * Instanciates a prepass renderer
  22226. * @param scene The scene
  22227. */
  22228. constructor(scene: Scene);
  22229. private _initializeAttachments;
  22230. private _createCompositionEffect;
  22231. /**
  22232. * Indicates if rendering a prepass is supported
  22233. */
  22234. get isSupported(): boolean;
  22235. /**
  22236. * Sets the proper output textures to draw in the engine.
  22237. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  22238. * @param subMesh Submesh on which the effect is applied
  22239. */
  22240. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  22241. /**
  22242. * @hidden
  22243. */
  22244. _beforeCameraDraw(): void;
  22245. /**
  22246. * @hidden
  22247. */
  22248. _afterCameraDraw(): void;
  22249. private _checkRTSize;
  22250. private _bindFrameBuffer;
  22251. /**
  22252. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  22253. */
  22254. clear(): void;
  22255. private _setState;
  22256. private _updateGeometryBufferLayout;
  22257. /**
  22258. * Adds an effect configuration to the prepass.
  22259. * If an effect has already been added, it won't add it twice and will return the configuration
  22260. * already present.
  22261. * @param cfg the effect configuration
  22262. * @return the effect configuration now used by the prepass
  22263. */
  22264. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  22265. /**
  22266. * Returns the index of a texture in the multi render target texture array.
  22267. * @param type Texture type
  22268. * @return The index
  22269. */
  22270. getIndex(type: number): number;
  22271. private _enable;
  22272. private _disable;
  22273. private _resetLayout;
  22274. private _resetPostProcessChain;
  22275. private _bindPostProcessChain;
  22276. /**
  22277. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  22278. */
  22279. markAsDirty(): void;
  22280. /**
  22281. * Enables a texture on the MultiRenderTarget for prepass
  22282. */
  22283. private _enableTextures;
  22284. private _update;
  22285. private _markAllMaterialsAsPrePassDirty;
  22286. /**
  22287. * Disposes the prepass renderer.
  22288. */
  22289. dispose(): void;
  22290. }
  22291. }
  22292. declare module BABYLON {
  22293. /**
  22294. * Size options for a post process
  22295. */
  22296. export type PostProcessOptions = {
  22297. width: number;
  22298. height: number;
  22299. };
  22300. /**
  22301. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22302. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22303. */
  22304. export class PostProcess {
  22305. /**
  22306. * Gets or sets the unique id of the post process
  22307. */
  22308. uniqueId: number;
  22309. /** Name of the PostProcess. */
  22310. name: string;
  22311. /**
  22312. * Width of the texture to apply the post process on
  22313. */
  22314. width: number;
  22315. /**
  22316. * Height of the texture to apply the post process on
  22317. */
  22318. height: number;
  22319. /**
  22320. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22321. */
  22322. nodeMaterialSource: Nullable<NodeMaterial>;
  22323. /**
  22324. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22325. * @hidden
  22326. */
  22327. _outputTexture: Nullable<InternalTexture>;
  22328. /**
  22329. * Sampling mode used by the shader
  22330. * See https://doc.babylonjs.com/classes/3.1/texture
  22331. */
  22332. renderTargetSamplingMode: number;
  22333. /**
  22334. * Clear color to use when screen clearing
  22335. */
  22336. clearColor: Color4;
  22337. /**
  22338. * If the buffer needs to be cleared before applying the post process. (default: true)
  22339. * Should be set to false if shader will overwrite all previous pixels.
  22340. */
  22341. autoClear: boolean;
  22342. /**
  22343. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22344. */
  22345. alphaMode: number;
  22346. /**
  22347. * Sets the setAlphaBlendConstants of the babylon engine
  22348. */
  22349. alphaConstants: Color4;
  22350. /**
  22351. * Animations to be used for the post processing
  22352. */
  22353. animations: Animation[];
  22354. /**
  22355. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22356. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22357. */
  22358. enablePixelPerfectMode: boolean;
  22359. /**
  22360. * Force the postprocess to be applied without taking in account viewport
  22361. */
  22362. forceFullscreenViewport: boolean;
  22363. /**
  22364. * List of inspectable custom properties (used by the Inspector)
  22365. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22366. */
  22367. inspectableCustomProperties: IInspectable[];
  22368. /**
  22369. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22370. *
  22371. * | Value | Type | Description |
  22372. * | ----- | ----------------------------------- | ----------- |
  22373. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22374. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22375. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22376. *
  22377. */
  22378. scaleMode: number;
  22379. /**
  22380. * Force textures to be a power of two (default: false)
  22381. */
  22382. alwaysForcePOT: boolean;
  22383. private _samples;
  22384. /**
  22385. * Number of sample textures (default: 1)
  22386. */
  22387. get samples(): number;
  22388. set samples(n: number);
  22389. /**
  22390. * Modify the scale of the post process to be the same as the viewport (default: false)
  22391. */
  22392. adaptScaleToCurrentViewport: boolean;
  22393. private _camera;
  22394. protected _scene: Scene;
  22395. private _engine;
  22396. private _options;
  22397. private _reusable;
  22398. private _textureType;
  22399. private _textureFormat;
  22400. /**
  22401. * Smart array of input and output textures for the post process.
  22402. * @hidden
  22403. */
  22404. _textures: SmartArray<InternalTexture>;
  22405. /**
  22406. * The index in _textures that corresponds to the output texture.
  22407. * @hidden
  22408. */
  22409. _currentRenderTextureInd: number;
  22410. private _effect;
  22411. private _samplers;
  22412. private _fragmentUrl;
  22413. private _vertexUrl;
  22414. private _parameters;
  22415. private _scaleRatio;
  22416. protected _indexParameters: any;
  22417. private _shareOutputWithPostProcess;
  22418. private _texelSize;
  22419. private _forcedOutputTexture;
  22420. /**
  22421. * Prepass configuration in case this post process needs a texture from prepass
  22422. * @hidden
  22423. */
  22424. _prePassEffectConfiguration: PrePassEffectConfiguration;
  22425. /**
  22426. * Returns the fragment url or shader name used in the post process.
  22427. * @returns the fragment url or name in the shader store.
  22428. */
  22429. getEffectName(): string;
  22430. /**
  22431. * An event triggered when the postprocess is activated.
  22432. */
  22433. onActivateObservable: Observable<Camera>;
  22434. private _onActivateObserver;
  22435. /**
  22436. * A function that is added to the onActivateObservable
  22437. */
  22438. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22439. /**
  22440. * An event triggered when the postprocess changes its size.
  22441. */
  22442. onSizeChangedObservable: Observable<PostProcess>;
  22443. private _onSizeChangedObserver;
  22444. /**
  22445. * A function that is added to the onSizeChangedObservable
  22446. */
  22447. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22448. /**
  22449. * An event triggered when the postprocess applies its effect.
  22450. */
  22451. onApplyObservable: Observable<Effect>;
  22452. private _onApplyObserver;
  22453. /**
  22454. * A function that is added to the onApplyObservable
  22455. */
  22456. set onApply(callback: (effect: Effect) => void);
  22457. /**
  22458. * An event triggered before rendering the postprocess
  22459. */
  22460. onBeforeRenderObservable: Observable<Effect>;
  22461. private _onBeforeRenderObserver;
  22462. /**
  22463. * A function that is added to the onBeforeRenderObservable
  22464. */
  22465. set onBeforeRender(callback: (effect: Effect) => void);
  22466. /**
  22467. * An event triggered after rendering the postprocess
  22468. */
  22469. onAfterRenderObservable: Observable<Effect>;
  22470. private _onAfterRenderObserver;
  22471. /**
  22472. * A function that is added to the onAfterRenderObservable
  22473. */
  22474. set onAfterRender(callback: (efect: Effect) => void);
  22475. /**
  22476. * 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
  22477. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22478. */
  22479. get inputTexture(): InternalTexture;
  22480. set inputTexture(value: InternalTexture);
  22481. /**
  22482. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22483. * the only way to unset it is to use this function to restore its internal state
  22484. */
  22485. restoreDefaultInputTexture(): void;
  22486. /**
  22487. * Gets the camera which post process is applied to.
  22488. * @returns The camera the post process is applied to.
  22489. */
  22490. getCamera(): Camera;
  22491. /**
  22492. * Gets the texel size of the postprocess.
  22493. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22494. */
  22495. get texelSize(): Vector2;
  22496. /**
  22497. * Creates a new instance PostProcess
  22498. * @param name The name of the PostProcess.
  22499. * @param fragmentUrl The url of the fragment shader to be used.
  22500. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22501. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22502. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22503. * @param camera The camera to apply the render pass to.
  22504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22505. * @param engine The engine which the post process will be applied. (default: current engine)
  22506. * @param reusable If the post process can be reused on the same frame. (default: false)
  22507. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22508. * @param textureType Type of textures used when performing the post process. (default: 0)
  22509. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22510. * @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
  22511. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22512. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22513. */
  22514. 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);
  22515. /**
  22516. * Gets a string identifying the name of the class
  22517. * @returns "PostProcess" string
  22518. */
  22519. getClassName(): string;
  22520. /**
  22521. * Gets the engine which this post process belongs to.
  22522. * @returns The engine the post process was enabled with.
  22523. */
  22524. getEngine(): Engine;
  22525. /**
  22526. * The effect that is created when initializing the post process.
  22527. * @returns The created effect corresponding the the postprocess.
  22528. */
  22529. getEffect(): Effect;
  22530. /**
  22531. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22532. * @param postProcess The post process to share the output with.
  22533. * @returns This post process.
  22534. */
  22535. shareOutputWith(postProcess: PostProcess): PostProcess;
  22536. /**
  22537. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22538. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22539. */
  22540. useOwnOutput(): void;
  22541. /**
  22542. * Updates the effect with the current post process compile time values and recompiles the shader.
  22543. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22544. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22545. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22546. * @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
  22547. * @param onCompiled Called when the shader has been compiled.
  22548. * @param onError Called if there is an error when compiling a shader.
  22549. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22550. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22551. */
  22552. 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;
  22553. /**
  22554. * The post process is reusable if it can be used multiple times within one frame.
  22555. * @returns If the post process is reusable
  22556. */
  22557. isReusable(): boolean;
  22558. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22559. markTextureDirty(): void;
  22560. /**
  22561. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22562. * 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.
  22563. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22564. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22565. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22566. * @returns The target texture that was bound to be written to.
  22567. */
  22568. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22569. /**
  22570. * If the post process is supported.
  22571. */
  22572. get isSupported(): boolean;
  22573. /**
  22574. * The aspect ratio of the output texture.
  22575. */
  22576. get aspectRatio(): number;
  22577. /**
  22578. * Get a value indicating if the post-process is ready to be used
  22579. * @returns true if the post-process is ready (shader is compiled)
  22580. */
  22581. isReady(): boolean;
  22582. /**
  22583. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22584. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22585. */
  22586. apply(): Nullable<Effect>;
  22587. private _disposeTextures;
  22588. /**
  22589. * Sets the required values to the prepass renderer.
  22590. * @param prePassRenderer defines the prepass renderer to setup.
  22591. * @returns true if the pre pass is needed.
  22592. */
  22593. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22594. /**
  22595. * Disposes the post process.
  22596. * @param camera The camera to dispose the post process on.
  22597. */
  22598. dispose(camera?: Camera): void;
  22599. /**
  22600. * Serializes the particle system to a JSON object
  22601. * @returns the JSON object
  22602. */
  22603. serialize(): any;
  22604. /**
  22605. * Creates a material from parsed material data
  22606. * @param parsedPostProcess defines parsed post process data
  22607. * @param scene defines the hosting scene
  22608. * @param rootUrl defines the root URL to use to load textures
  22609. * @returns a new post process
  22610. */
  22611. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22612. }
  22613. }
  22614. declare module BABYLON {
  22615. /** @hidden */
  22616. export var kernelBlurVaryingDeclaration: {
  22617. name: string;
  22618. shader: string;
  22619. };
  22620. }
  22621. declare module BABYLON {
  22622. /** @hidden */
  22623. export var packingFunctions: {
  22624. name: string;
  22625. shader: string;
  22626. };
  22627. }
  22628. declare module BABYLON {
  22629. /** @hidden */
  22630. export var kernelBlurFragment: {
  22631. name: string;
  22632. shader: string;
  22633. };
  22634. }
  22635. declare module BABYLON {
  22636. /** @hidden */
  22637. export var kernelBlurFragment2: {
  22638. name: string;
  22639. shader: string;
  22640. };
  22641. }
  22642. declare module BABYLON {
  22643. /** @hidden */
  22644. export var kernelBlurPixelShader: {
  22645. name: string;
  22646. shader: string;
  22647. };
  22648. }
  22649. declare module BABYLON {
  22650. /** @hidden */
  22651. export var kernelBlurVertex: {
  22652. name: string;
  22653. shader: string;
  22654. };
  22655. }
  22656. declare module BABYLON {
  22657. /** @hidden */
  22658. export var kernelBlurVertexShader: {
  22659. name: string;
  22660. shader: string;
  22661. };
  22662. }
  22663. declare module BABYLON {
  22664. /**
  22665. * The Blur Post Process which blurs an image based on a kernel and direction.
  22666. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22667. */
  22668. export class BlurPostProcess extends PostProcess {
  22669. private blockCompilation;
  22670. protected _kernel: number;
  22671. protected _idealKernel: number;
  22672. protected _packedFloat: boolean;
  22673. private _staticDefines;
  22674. /** The direction in which to blur the image. */
  22675. direction: Vector2;
  22676. /**
  22677. * Sets the length in pixels of the blur sample region
  22678. */
  22679. set kernel(v: number);
  22680. /**
  22681. * Gets the length in pixels of the blur sample region
  22682. */
  22683. get kernel(): number;
  22684. /**
  22685. * Sets wether or not the blur needs to unpack/repack floats
  22686. */
  22687. set packedFloat(v: boolean);
  22688. /**
  22689. * Gets wether or not the blur is unpacking/repacking floats
  22690. */
  22691. get packedFloat(): boolean;
  22692. /**
  22693. * Gets a string identifying the name of the class
  22694. * @returns "BlurPostProcess" string
  22695. */
  22696. getClassName(): string;
  22697. /**
  22698. * Creates a new instance BlurPostProcess
  22699. * @param name The name of the effect.
  22700. * @param direction The direction in which to blur the image.
  22701. * @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.
  22702. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22703. * @param camera The camera to apply the render pass to.
  22704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22705. * @param engine The engine which the post process will be applied. (default: current engine)
  22706. * @param reusable If the post process can be reused on the same frame. (default: false)
  22707. * @param textureType Type of textures used when performing the post process. (default: 0)
  22708. * @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)
  22709. */
  22710. 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);
  22711. /**
  22712. * Updates the effect with the current post process compile time values and recompiles the shader.
  22713. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22714. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22715. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22716. * @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
  22717. * @param onCompiled Called when the shader has been compiled.
  22718. * @param onError Called if there is an error when compiling a shader.
  22719. */
  22720. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22721. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22722. /**
  22723. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22724. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22725. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22726. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22727. * The gaps between physical kernels are compensated for in the weighting of the samples
  22728. * @param idealKernel Ideal blur kernel.
  22729. * @return Nearest best kernel.
  22730. */
  22731. protected _nearestBestKernel(idealKernel: number): number;
  22732. /**
  22733. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22734. * @param x The point on the Gaussian distribution to sample.
  22735. * @return the value of the Gaussian function at x.
  22736. */
  22737. protected _gaussianWeight(x: number): number;
  22738. /**
  22739. * Generates a string that can be used as a floating point number in GLSL.
  22740. * @param x Value to print.
  22741. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22742. * @return GLSL float string.
  22743. */
  22744. protected _glslFloat(x: number, decimalFigures?: number): string;
  22745. /** @hidden */
  22746. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  22747. }
  22748. }
  22749. declare module BABYLON {
  22750. /**
  22751. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22752. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22753. * You can then easily use it as a reflectionTexture on a flat surface.
  22754. * In case the surface is not a plane, please consider relying on reflection probes.
  22755. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22756. */
  22757. export class MirrorTexture extends RenderTargetTexture {
  22758. private scene;
  22759. /**
  22760. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22761. * 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.
  22762. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22763. */
  22764. mirrorPlane: Plane;
  22765. /**
  22766. * Define the blur ratio used to blur the reflection if needed.
  22767. */
  22768. set blurRatio(value: number);
  22769. get blurRatio(): number;
  22770. /**
  22771. * Define the adaptive blur kernel used to blur the reflection if needed.
  22772. * This will autocompute the closest best match for the `blurKernel`
  22773. */
  22774. set adaptiveBlurKernel(value: number);
  22775. /**
  22776. * Define the blur kernel used to blur the reflection if needed.
  22777. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22778. */
  22779. set blurKernel(value: number);
  22780. /**
  22781. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22782. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22783. */
  22784. set blurKernelX(value: number);
  22785. get blurKernelX(): number;
  22786. /**
  22787. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22788. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22789. */
  22790. set blurKernelY(value: number);
  22791. get blurKernelY(): number;
  22792. private _autoComputeBlurKernel;
  22793. protected _onRatioRescale(): void;
  22794. private _updateGammaSpace;
  22795. private _imageProcessingConfigChangeObserver;
  22796. private _transformMatrix;
  22797. private _mirrorMatrix;
  22798. private _savedViewMatrix;
  22799. private _blurX;
  22800. private _blurY;
  22801. private _adaptiveBlurKernel;
  22802. private _blurKernelX;
  22803. private _blurKernelY;
  22804. private _blurRatio;
  22805. /**
  22806. * Instantiates a Mirror Texture.
  22807. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22808. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22809. * You can then easily use it as a reflectionTexture on a flat surface.
  22810. * In case the surface is not a plane, please consider relying on reflection probes.
  22811. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22812. * @param name
  22813. * @param size
  22814. * @param scene
  22815. * @param generateMipMaps
  22816. * @param type
  22817. * @param samplingMode
  22818. * @param generateDepthBuffer
  22819. */
  22820. constructor(name: string, size: number | {
  22821. width: number;
  22822. height: number;
  22823. } | {
  22824. ratio: number;
  22825. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22826. private _preparePostProcesses;
  22827. /**
  22828. * Clone the mirror texture.
  22829. * @returns the cloned texture
  22830. */
  22831. clone(): MirrorTexture;
  22832. /**
  22833. * Serialize the texture to a JSON representation you could use in Parse later on
  22834. * @returns the serialized JSON representation
  22835. */
  22836. serialize(): any;
  22837. /**
  22838. * Dispose the texture and release its associated resources.
  22839. */
  22840. dispose(): void;
  22841. }
  22842. }
  22843. declare module BABYLON {
  22844. /**
  22845. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22846. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22847. */
  22848. export class Texture extends BaseTexture {
  22849. /**
  22850. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22851. */
  22852. static SerializeBuffers: boolean;
  22853. /**
  22854. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  22855. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  22856. */
  22857. static ForceSerializeBuffers: boolean;
  22858. /** @hidden */
  22859. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22860. /** @hidden */
  22861. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22862. /** @hidden */
  22863. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22864. /** nearest is mag = nearest and min = nearest and mip = linear */
  22865. static readonly NEAREST_SAMPLINGMODE: number;
  22866. /** nearest is mag = nearest and min = nearest and mip = linear */
  22867. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22868. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22869. static readonly BILINEAR_SAMPLINGMODE: number;
  22870. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22871. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22872. /** Trilinear is mag = linear and min = linear and mip = linear */
  22873. static readonly TRILINEAR_SAMPLINGMODE: number;
  22874. /** Trilinear is mag = linear and min = linear and mip = linear */
  22875. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22876. /** mag = nearest and min = nearest and mip = nearest */
  22877. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22878. /** mag = nearest and min = linear and mip = nearest */
  22879. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22880. /** mag = nearest and min = linear and mip = linear */
  22881. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22882. /** mag = nearest and min = linear and mip = none */
  22883. static readonly NEAREST_LINEAR: number;
  22884. /** mag = nearest and min = nearest and mip = none */
  22885. static readonly NEAREST_NEAREST: number;
  22886. /** mag = linear and min = nearest and mip = nearest */
  22887. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22888. /** mag = linear and min = nearest and mip = linear */
  22889. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22890. /** mag = linear and min = linear and mip = none */
  22891. static readonly LINEAR_LINEAR: number;
  22892. /** mag = linear and min = nearest and mip = none */
  22893. static readonly LINEAR_NEAREST: number;
  22894. /** Explicit coordinates mode */
  22895. static readonly EXPLICIT_MODE: number;
  22896. /** Spherical coordinates mode */
  22897. static readonly SPHERICAL_MODE: number;
  22898. /** Planar coordinates mode */
  22899. static readonly PLANAR_MODE: number;
  22900. /** Cubic coordinates mode */
  22901. static readonly CUBIC_MODE: number;
  22902. /** Projection coordinates mode */
  22903. static readonly PROJECTION_MODE: number;
  22904. /** Inverse Cubic coordinates mode */
  22905. static readonly SKYBOX_MODE: number;
  22906. /** Inverse Cubic coordinates mode */
  22907. static readonly INVCUBIC_MODE: number;
  22908. /** Equirectangular coordinates mode */
  22909. static readonly EQUIRECTANGULAR_MODE: number;
  22910. /** Equirectangular Fixed coordinates mode */
  22911. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22912. /** Equirectangular Fixed Mirrored coordinates mode */
  22913. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22914. /** Texture is not repeating outside of 0..1 UVs */
  22915. static readonly CLAMP_ADDRESSMODE: number;
  22916. /** Texture is repeating outside of 0..1 UVs */
  22917. static readonly WRAP_ADDRESSMODE: number;
  22918. /** Texture is repeating and mirrored */
  22919. static readonly MIRROR_ADDRESSMODE: number;
  22920. /**
  22921. * 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
  22922. */
  22923. static UseSerializedUrlIfAny: boolean;
  22924. /**
  22925. * Define the url of the texture.
  22926. */
  22927. url: Nullable<string>;
  22928. /**
  22929. * Define an offset on the texture to offset the u coordinates of the UVs
  22930. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22931. */
  22932. uOffset: number;
  22933. /**
  22934. * Define an offset on the texture to offset the v coordinates of the UVs
  22935. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22936. */
  22937. vOffset: number;
  22938. /**
  22939. * Define an offset on the texture to scale the u coordinates of the UVs
  22940. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22941. */
  22942. uScale: number;
  22943. /**
  22944. * Define an offset on the texture to scale the v coordinates of the UVs
  22945. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22946. */
  22947. vScale: number;
  22948. /**
  22949. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22950. * @see https://doc.babylonjs.com/how_to/more_materials
  22951. */
  22952. uAng: number;
  22953. /**
  22954. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22955. * @see https://doc.babylonjs.com/how_to/more_materials
  22956. */
  22957. vAng: number;
  22958. /**
  22959. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22960. * @see https://doc.babylonjs.com/how_to/more_materials
  22961. */
  22962. wAng: number;
  22963. /**
  22964. * Defines the center of rotation (U)
  22965. */
  22966. uRotationCenter: number;
  22967. /**
  22968. * Defines the center of rotation (V)
  22969. */
  22970. vRotationCenter: number;
  22971. /**
  22972. * Defines the center of rotation (W)
  22973. */
  22974. wRotationCenter: number;
  22975. /**
  22976. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  22977. */
  22978. homogeneousRotationInUVTransform: boolean;
  22979. /**
  22980. * Are mip maps generated for this texture or not.
  22981. */
  22982. get noMipmap(): boolean;
  22983. /**
  22984. * List of inspectable custom properties (used by the Inspector)
  22985. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22986. */
  22987. inspectableCustomProperties: Nullable<IInspectable[]>;
  22988. private _noMipmap;
  22989. /** @hidden */
  22990. _invertY: boolean;
  22991. private _rowGenerationMatrix;
  22992. private _cachedTextureMatrix;
  22993. private _projectionModeMatrix;
  22994. private _t0;
  22995. private _t1;
  22996. private _t2;
  22997. private _cachedUOffset;
  22998. private _cachedVOffset;
  22999. private _cachedUScale;
  23000. private _cachedVScale;
  23001. private _cachedUAng;
  23002. private _cachedVAng;
  23003. private _cachedWAng;
  23004. private _cachedProjectionMatrixId;
  23005. private _cachedURotationCenter;
  23006. private _cachedVRotationCenter;
  23007. private _cachedWRotationCenter;
  23008. private _cachedHomogeneousRotationInUVTransform;
  23009. private _cachedCoordinatesMode;
  23010. /** @hidden */
  23011. protected _initialSamplingMode: number;
  23012. /** @hidden */
  23013. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23014. private _deleteBuffer;
  23015. protected _format: Nullable<number>;
  23016. private _delayedOnLoad;
  23017. private _delayedOnError;
  23018. private _mimeType?;
  23019. private _loaderOptions?;
  23020. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23021. get mimeType(): string | undefined;
  23022. /**
  23023. * Observable triggered once the texture has been loaded.
  23024. */
  23025. onLoadObservable: Observable<Texture>;
  23026. protected _isBlocking: boolean;
  23027. /**
  23028. * Is the texture preventing material to render while loading.
  23029. * If false, a default texture will be used instead of the loading one during the preparation step.
  23030. */
  23031. set isBlocking(value: boolean);
  23032. get isBlocking(): boolean;
  23033. /**
  23034. * Get the current sampling mode associated with the texture.
  23035. */
  23036. get samplingMode(): number;
  23037. /**
  23038. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23039. */
  23040. get invertY(): boolean;
  23041. /**
  23042. * Instantiates a new texture.
  23043. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23044. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23045. * @param url defines the url of the picture to load as a texture
  23046. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23047. * @param noMipmap defines if the texture will require mip maps or not
  23048. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23049. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23050. * @param onLoad defines a callback triggered when the texture has been loaded
  23051. * @param onError defines a callback triggered when an error occurred during the loading session
  23052. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23053. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23054. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23055. * @param mimeType defines an optional mime type information
  23056. * @param loaderOptions options to be passed to the loader
  23057. */
  23058. 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);
  23059. /**
  23060. * Update the url (and optional buffer) of this texture if url was null during construction.
  23061. * @param url the url of the texture
  23062. * @param buffer the buffer of the texture (defaults to null)
  23063. * @param onLoad callback called when the texture is loaded (defaults to null)
  23064. */
  23065. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23066. /**
  23067. * Finish the loading sequence of a texture flagged as delayed load.
  23068. * @hidden
  23069. */
  23070. delayLoad(): void;
  23071. private _prepareRowForTextureGeneration;
  23072. /**
  23073. * Checks if the texture has the same transform matrix than another texture
  23074. * @param texture texture to check against
  23075. * @returns true if the transforms are the same, else false
  23076. */
  23077. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23078. /**
  23079. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23080. * @returns the transform matrix of the texture.
  23081. */
  23082. getTextureMatrix(uBase?: number): Matrix;
  23083. /**
  23084. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23085. * @returns The reflection texture transform
  23086. */
  23087. getReflectionTextureMatrix(): Matrix;
  23088. /**
  23089. * Clones the texture.
  23090. * @returns the cloned texture
  23091. */
  23092. clone(): Texture;
  23093. /**
  23094. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23095. * @returns The JSON representation of the texture
  23096. */
  23097. serialize(): any;
  23098. /**
  23099. * Get the current class name of the texture useful for serialization or dynamic coding.
  23100. * @returns "Texture"
  23101. */
  23102. getClassName(): string;
  23103. /**
  23104. * Dispose the texture and release its associated resources.
  23105. */
  23106. dispose(): void;
  23107. /**
  23108. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23109. * @param parsedTexture Define the JSON representation of the texture
  23110. * @param scene Define the scene the parsed texture should be instantiated in
  23111. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23112. * @returns The parsed texture if successful
  23113. */
  23114. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23115. /**
  23116. * Creates a texture from its base 64 representation.
  23117. * @param data Define the base64 payload without the data: prefix
  23118. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23119. * @param scene Define the scene the texture should belong to
  23120. * @param noMipmap Forces the texture to not create mip map information if true
  23121. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23122. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23123. * @param onLoad define a callback triggered when the texture has been loaded
  23124. * @param onError define a callback triggered when an error occurred during the loading session
  23125. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23126. * @returns the created texture
  23127. */
  23128. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23129. /**
  23130. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23131. * @param data Define the base64 payload without the data: prefix
  23132. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23133. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23134. * @param scene Define the scene the texture should belong to
  23135. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23136. * @param noMipmap Forces the texture to not create mip map information if true
  23137. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23138. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23139. * @param onLoad define a callback triggered when the texture has been loaded
  23140. * @param onError define a callback triggered when an error occurred during the loading session
  23141. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23142. * @returns the created texture
  23143. */
  23144. 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;
  23145. }
  23146. }
  23147. declare module BABYLON {
  23148. /** @hidden */
  23149. export var imageProcessingCompatibility: {
  23150. name: string;
  23151. shader: string;
  23152. };
  23153. }
  23154. declare module BABYLON {
  23155. /** @hidden */
  23156. export var spritesPixelShader: {
  23157. name: string;
  23158. shader: string;
  23159. };
  23160. }
  23161. declare module BABYLON {
  23162. /** @hidden */
  23163. export var spritesVertexShader: {
  23164. name: string;
  23165. shader: string;
  23166. };
  23167. }
  23168. declare module BABYLON {
  23169. /**
  23170. * Defines the minimum interface to fullfil in order to be a sprite manager.
  23171. */
  23172. export interface ISpriteManager extends IDisposable {
  23173. /**
  23174. * Gets manager's name
  23175. */
  23176. name: string;
  23177. /**
  23178. * Restricts the camera to viewing objects with the same layerMask.
  23179. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  23180. */
  23181. layerMask: number;
  23182. /**
  23183. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23184. */
  23185. isPickable: boolean;
  23186. /**
  23187. * Gets the hosting scene
  23188. */
  23189. scene: Scene;
  23190. /**
  23191. * Specifies the rendering group id for this mesh (0 by default)
  23192. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23193. */
  23194. renderingGroupId: number;
  23195. /**
  23196. * Defines the list of sprites managed by the manager.
  23197. */
  23198. sprites: Array<Sprite>;
  23199. /**
  23200. * Gets or sets the spritesheet texture
  23201. */
  23202. texture: Texture;
  23203. /** Defines the default width of a cell in the spritesheet */
  23204. cellWidth: number;
  23205. /** Defines the default height of a cell in the spritesheet */
  23206. cellHeight: number;
  23207. /**
  23208. * Tests the intersection of a sprite with a specific ray.
  23209. * @param ray The ray we are sending to test the collision
  23210. * @param camera The camera space we are sending rays in
  23211. * @param predicate A predicate allowing excluding sprites from the list of object to test
  23212. * @param fastCheck defines if the first intersection will be used (and not the closest)
  23213. * @returns picking info or null.
  23214. */
  23215. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23216. /**
  23217. * Intersects the sprites with a ray
  23218. * @param ray defines the ray to intersect with
  23219. * @param camera defines the current active camera
  23220. * @param predicate defines a predicate used to select candidate sprites
  23221. * @returns null if no hit or a PickingInfo array
  23222. */
  23223. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23224. /**
  23225. * Renders the list of sprites on screen.
  23226. */
  23227. render(): void;
  23228. }
  23229. /**
  23230. * Class used to manage multiple sprites on the same spritesheet
  23231. * @see https://doc.babylonjs.com/babylon101/sprites
  23232. */
  23233. export class SpriteManager implements ISpriteManager {
  23234. /** defines the manager's name */
  23235. name: string;
  23236. /** Define the Url to load snippets */
  23237. static SnippetUrl: string;
  23238. /** Snippet ID if the manager was created from the snippet server */
  23239. snippetId: string;
  23240. /** Gets the list of sprites */
  23241. sprites: Sprite[];
  23242. /** Gets or sets the rendering group id (0 by default) */
  23243. renderingGroupId: number;
  23244. /** Gets or sets camera layer mask */
  23245. layerMask: number;
  23246. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  23247. fogEnabled: boolean;
  23248. /** Gets or sets a boolean indicating if the sprites are pickable */
  23249. isPickable: boolean;
  23250. /** Defines the default width of a cell in the spritesheet */
  23251. cellWidth: number;
  23252. /** Defines the default height of a cell in the spritesheet */
  23253. cellHeight: number;
  23254. /** Associative array from JSON sprite data file */
  23255. private _cellData;
  23256. /** Array of sprite names from JSON sprite data file */
  23257. private _spriteMap;
  23258. /** True when packed cell data from JSON file is ready*/
  23259. private _packedAndReady;
  23260. private _textureContent;
  23261. private _useInstancing;
  23262. /**
  23263. * An event triggered when the manager is disposed.
  23264. */
  23265. onDisposeObservable: Observable<SpriteManager>;
  23266. private _onDisposeObserver;
  23267. /**
  23268. * Callback called when the manager is disposed
  23269. */
  23270. set onDispose(callback: () => void);
  23271. private _capacity;
  23272. private _fromPacked;
  23273. private _spriteTexture;
  23274. private _epsilon;
  23275. private _scene;
  23276. private _vertexData;
  23277. private _buffer;
  23278. private _vertexBuffers;
  23279. private _spriteBuffer;
  23280. private _indexBuffer;
  23281. private _effectBase;
  23282. private _effectFog;
  23283. private _vertexBufferSize;
  23284. /**
  23285. * Gets or sets the unique id of the sprite
  23286. */
  23287. uniqueId: number;
  23288. /**
  23289. * Gets the array of sprites
  23290. */
  23291. get children(): Sprite[];
  23292. /**
  23293. * Gets the hosting scene
  23294. */
  23295. get scene(): Scene;
  23296. /**
  23297. * Gets the capacity of the manager
  23298. */
  23299. get capacity(): number;
  23300. /**
  23301. * Gets or sets the spritesheet texture
  23302. */
  23303. get texture(): Texture;
  23304. set texture(value: Texture);
  23305. private _blendMode;
  23306. /**
  23307. * Blend mode use to render the particle, it can be any of
  23308. * the static Constants.ALPHA_x properties provided in this class.
  23309. * Default value is Constants.ALPHA_COMBINE
  23310. */
  23311. get blendMode(): number;
  23312. set blendMode(blendMode: number);
  23313. /** Disables writing to the depth buffer when rendering the sprites.
  23314. * It can be handy to disable depth writing when using textures without alpha channel
  23315. * and setting some specific blend modes.
  23316. */
  23317. disableDepthWrite: boolean;
  23318. /**
  23319. * Creates a new sprite manager
  23320. * @param name defines the manager's name
  23321. * @param imgUrl defines the sprite sheet url
  23322. * @param capacity defines the maximum allowed number of sprites
  23323. * @param cellSize defines the size of a sprite cell
  23324. * @param scene defines the hosting scene
  23325. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23326. * @param samplingMode defines the smapling mode to use with spritesheet
  23327. * @param fromPacked set to false; do not alter
  23328. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  23329. */
  23330. constructor(
  23331. /** defines the manager's name */
  23332. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  23333. /**
  23334. * Returns the string "SpriteManager"
  23335. * @returns "SpriteManager"
  23336. */
  23337. getClassName(): string;
  23338. private _makePacked;
  23339. private _appendSpriteVertex;
  23340. private _checkTextureAlpha;
  23341. /**
  23342. * Intersects the sprites with a ray
  23343. * @param ray defines the ray to intersect with
  23344. * @param camera defines the current active camera
  23345. * @param predicate defines a predicate used to select candidate sprites
  23346. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  23347. * @returns null if no hit or a PickingInfo
  23348. */
  23349. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23350. /**
  23351. * Intersects the sprites with a ray
  23352. * @param ray defines the ray to intersect with
  23353. * @param camera defines the current active camera
  23354. * @param predicate defines a predicate used to select candidate sprites
  23355. * @returns null if no hit or a PickingInfo array
  23356. */
  23357. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23358. /**
  23359. * Render all child sprites
  23360. */
  23361. render(): void;
  23362. /**
  23363. * Release associated resources
  23364. */
  23365. dispose(): void;
  23366. /**
  23367. * Serializes the sprite manager to a JSON object
  23368. * @param serializeTexture defines if the texture must be serialized as well
  23369. * @returns the JSON object
  23370. */
  23371. serialize(serializeTexture?: boolean): any;
  23372. /**
  23373. * Parses a JSON object to create a new sprite manager.
  23374. * @param parsedManager The JSON object to parse
  23375. * @param scene The scene to create the sprite managerin
  23376. * @param rootUrl The root url to use to load external dependencies like texture
  23377. * @returns the new sprite manager
  23378. */
  23379. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  23380. /**
  23381. * Creates a sprite manager from a snippet saved in a remote file
  23382. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  23383. * @param url defines the url to load from
  23384. * @param scene defines the hosting scene
  23385. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23386. * @returns a promise that will resolve to the new sprite manager
  23387. */
  23388. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23389. /**
  23390. * Creates a sprite manager from a snippet saved by the sprite editor
  23391. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  23392. * @param scene defines the hosting scene
  23393. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23394. * @returns a promise that will resolve to the new sprite manager
  23395. */
  23396. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23397. }
  23398. }
  23399. declare module BABYLON {
  23400. /**
  23401. * Class used to represent a sprite
  23402. * @see https://doc.babylonjs.com/babylon101/sprites
  23403. */
  23404. export class Sprite implements IAnimatable {
  23405. /** defines the name */
  23406. name: string;
  23407. /** Gets or sets the current world position */
  23408. position: Vector3;
  23409. /** Gets or sets the main color */
  23410. color: Color4;
  23411. /** Gets or sets the width */
  23412. width: number;
  23413. /** Gets or sets the height */
  23414. height: number;
  23415. /** Gets or sets rotation angle */
  23416. angle: number;
  23417. /** Gets or sets the cell index in the sprite sheet */
  23418. cellIndex: number;
  23419. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23420. cellRef: string;
  23421. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23422. invertU: boolean;
  23423. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23424. invertV: boolean;
  23425. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  23426. disposeWhenFinishedAnimating: boolean;
  23427. /** Gets the list of attached animations */
  23428. animations: Nullable<Array<Animation>>;
  23429. /** Gets or sets a boolean indicating if the sprite can be picked */
  23430. isPickable: boolean;
  23431. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  23432. useAlphaForPicking: boolean;
  23433. /** @hidden */
  23434. _xOffset: number;
  23435. /** @hidden */
  23436. _yOffset: number;
  23437. /** @hidden */
  23438. _xSize: number;
  23439. /** @hidden */
  23440. _ySize: number;
  23441. /**
  23442. * Gets or sets the associated action manager
  23443. */
  23444. actionManager: Nullable<ActionManager>;
  23445. /**
  23446. * An event triggered when the control has been disposed
  23447. */
  23448. onDisposeObservable: Observable<Sprite>;
  23449. private _animationStarted;
  23450. private _loopAnimation;
  23451. private _fromIndex;
  23452. private _toIndex;
  23453. private _delay;
  23454. private _direction;
  23455. private _manager;
  23456. private _time;
  23457. private _onAnimationEnd;
  23458. /**
  23459. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  23460. */
  23461. isVisible: boolean;
  23462. /**
  23463. * Gets or sets the sprite size
  23464. */
  23465. get size(): number;
  23466. set size(value: number);
  23467. /**
  23468. * Returns a boolean indicating if the animation is started
  23469. */
  23470. get animationStarted(): boolean;
  23471. /**
  23472. * Gets or sets the unique id of the sprite
  23473. */
  23474. uniqueId: number;
  23475. /**
  23476. * Gets the manager of this sprite
  23477. */
  23478. get manager(): ISpriteManager;
  23479. /**
  23480. * Creates a new Sprite
  23481. * @param name defines the name
  23482. * @param manager defines the manager
  23483. */
  23484. constructor(
  23485. /** defines the name */
  23486. name: string, manager: ISpriteManager);
  23487. /**
  23488. * Returns the string "Sprite"
  23489. * @returns "Sprite"
  23490. */
  23491. getClassName(): string;
  23492. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  23493. get fromIndex(): number;
  23494. set fromIndex(value: number);
  23495. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23496. get toIndex(): number;
  23497. set toIndex(value: number);
  23498. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23499. get loopAnimation(): boolean;
  23500. set loopAnimation(value: boolean);
  23501. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23502. get delay(): number;
  23503. set delay(value: number);
  23504. /**
  23505. * Starts an animation
  23506. * @param from defines the initial key
  23507. * @param to defines the end key
  23508. * @param loop defines if the animation must loop
  23509. * @param delay defines the start delay (in ms)
  23510. * @param onAnimationEnd defines a callback to call when animation ends
  23511. */
  23512. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  23513. /** Stops current animation (if any) */
  23514. stopAnimation(): void;
  23515. /** @hidden */
  23516. _animate(deltaTime: number): void;
  23517. /** Release associated resources */
  23518. dispose(): void;
  23519. /**
  23520. * Serializes the sprite to a JSON object
  23521. * @returns the JSON object
  23522. */
  23523. serialize(): any;
  23524. /**
  23525. * Parses a JSON object to create a new sprite
  23526. * @param parsedSprite The JSON object to parse
  23527. * @param manager defines the hosting manager
  23528. * @returns the new sprite
  23529. */
  23530. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  23531. }
  23532. }
  23533. declare module BABYLON {
  23534. /**
  23535. * Information about the result of picking within a scene
  23536. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23537. */
  23538. export class PickingInfo {
  23539. /** @hidden */
  23540. _pickingUnavailable: boolean;
  23541. /**
  23542. * If the pick collided with an object
  23543. */
  23544. hit: boolean;
  23545. /**
  23546. * Distance away where the pick collided
  23547. */
  23548. distance: number;
  23549. /**
  23550. * The location of pick collision
  23551. */
  23552. pickedPoint: Nullable<Vector3>;
  23553. /**
  23554. * The mesh corresponding the the pick collision
  23555. */
  23556. pickedMesh: Nullable<AbstractMesh>;
  23557. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  23558. bu: number;
  23559. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  23560. bv: number;
  23561. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23562. faceId: number;
  23563. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23564. subMeshFaceId: number;
  23565. /** Id of the the submesh that was picked */
  23566. subMeshId: number;
  23567. /** If a sprite was picked, this will be the sprite the pick collided with */
  23568. pickedSprite: Nullable<Sprite>;
  23569. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  23570. thinInstanceIndex: number;
  23571. /**
  23572. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23573. */
  23574. originMesh: Nullable<AbstractMesh>;
  23575. /**
  23576. * The ray that was used to perform the picking.
  23577. */
  23578. ray: Nullable<Ray>;
  23579. /**
  23580. * Gets the normal correspodning to the face the pick collided with
  23581. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23582. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23583. * @returns The normal correspodning to the face the pick collided with
  23584. */
  23585. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  23586. /**
  23587. * Gets the texture coordinates of where the pick occured
  23588. * @returns the vector containing the coordnates of the texture
  23589. */
  23590. getTextureCoordinates(): Nullable<Vector2>;
  23591. }
  23592. }
  23593. declare module BABYLON {
  23594. /**
  23595. * Gather the list of pointer event types as constants.
  23596. */
  23597. export class PointerEventTypes {
  23598. /**
  23599. * 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.
  23600. */
  23601. static readonly POINTERDOWN: number;
  23602. /**
  23603. * The pointerup event is fired when a pointer is no longer active.
  23604. */
  23605. static readonly POINTERUP: number;
  23606. /**
  23607. * The pointermove event is fired when a pointer changes coordinates.
  23608. */
  23609. static readonly POINTERMOVE: number;
  23610. /**
  23611. * The pointerwheel event is fired when a mouse wheel has been rotated.
  23612. */
  23613. static readonly POINTERWHEEL: number;
  23614. /**
  23615. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  23616. */
  23617. static readonly POINTERPICK: number;
  23618. /**
  23619. * The pointertap event is fired when a the object has been touched and released without drag.
  23620. */
  23621. static readonly POINTERTAP: number;
  23622. /**
  23623. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  23624. */
  23625. static readonly POINTERDOUBLETAP: number;
  23626. }
  23627. /**
  23628. * Base class of pointer info types.
  23629. */
  23630. export class PointerInfoBase {
  23631. /**
  23632. * Defines the type of event (PointerEventTypes)
  23633. */
  23634. type: number;
  23635. /**
  23636. * Defines the related dom event
  23637. */
  23638. event: PointerEvent | MouseWheelEvent;
  23639. /**
  23640. * Instantiates the base class of pointers info.
  23641. * @param type Defines the type of event (PointerEventTypes)
  23642. * @param event Defines the related dom event
  23643. */
  23644. constructor(
  23645. /**
  23646. * Defines the type of event (PointerEventTypes)
  23647. */
  23648. type: number,
  23649. /**
  23650. * Defines the related dom event
  23651. */
  23652. event: PointerEvent | MouseWheelEvent);
  23653. }
  23654. /**
  23655. * This class is used to store pointer related info for the onPrePointerObservable event.
  23656. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  23657. */
  23658. export class PointerInfoPre extends PointerInfoBase {
  23659. /**
  23660. * Ray from a pointer if availible (eg. 6dof controller)
  23661. */
  23662. ray: Nullable<Ray>;
  23663. /**
  23664. * Defines the local position of the pointer on the canvas.
  23665. */
  23666. localPosition: Vector2;
  23667. /**
  23668. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  23669. */
  23670. skipOnPointerObservable: boolean;
  23671. /**
  23672. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  23673. * @param type Defines the type of event (PointerEventTypes)
  23674. * @param event Defines the related dom event
  23675. * @param localX Defines the local x coordinates of the pointer when the event occured
  23676. * @param localY Defines the local y coordinates of the pointer when the event occured
  23677. */
  23678. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  23679. }
  23680. /**
  23681. * This type contains all the data related to a pointer event in Babylon.js.
  23682. * 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.
  23683. */
  23684. export class PointerInfo extends PointerInfoBase {
  23685. /**
  23686. * Defines the picking info associated to the info (if any)\
  23687. */
  23688. pickInfo: Nullable<PickingInfo>;
  23689. /**
  23690. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  23691. * @param type Defines the type of event (PointerEventTypes)
  23692. * @param event Defines the related dom event
  23693. * @param pickInfo Defines the picking info associated to the info (if any)\
  23694. */
  23695. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  23696. /**
  23697. * Defines the picking info associated to the info (if any)\
  23698. */
  23699. pickInfo: Nullable<PickingInfo>);
  23700. }
  23701. /**
  23702. * Data relating to a touch event on the screen.
  23703. */
  23704. export interface PointerTouch {
  23705. /**
  23706. * X coordinate of touch.
  23707. */
  23708. x: number;
  23709. /**
  23710. * Y coordinate of touch.
  23711. */
  23712. y: number;
  23713. /**
  23714. * Id of touch. Unique for each finger.
  23715. */
  23716. pointerId: number;
  23717. /**
  23718. * Event type passed from DOM.
  23719. */
  23720. type: any;
  23721. }
  23722. }
  23723. declare module BABYLON {
  23724. /**
  23725. * Manage the mouse inputs to control the movement of a free camera.
  23726. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23727. */
  23728. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  23729. /**
  23730. * Define if touch is enabled in the mouse input
  23731. */
  23732. touchEnabled: boolean;
  23733. /**
  23734. * Defines the camera the input is attached to.
  23735. */
  23736. camera: FreeCamera;
  23737. /**
  23738. * Defines the buttons associated with the input to handle camera move.
  23739. */
  23740. buttons: number[];
  23741. /**
  23742. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  23743. */
  23744. angularSensibility: number;
  23745. private _pointerInput;
  23746. private _onMouseMove;
  23747. private _observer;
  23748. private previousPosition;
  23749. /**
  23750. * Observable for when a pointer move event occurs containing the move offset
  23751. */
  23752. onPointerMovedObservable: Observable<{
  23753. offsetX: number;
  23754. offsetY: number;
  23755. }>;
  23756. /**
  23757. * @hidden
  23758. * If the camera should be rotated automatically based on pointer movement
  23759. */
  23760. _allowCameraRotation: boolean;
  23761. /**
  23762. * Manage the mouse inputs to control the movement of a free camera.
  23763. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23764. * @param touchEnabled Defines if touch is enabled or not
  23765. */
  23766. constructor(
  23767. /**
  23768. * Define if touch is enabled in the mouse input
  23769. */
  23770. touchEnabled?: boolean);
  23771. /**
  23772. * Attach the input controls to a specific dom element to get the input from.
  23773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23774. */
  23775. attachControl(noPreventDefault?: boolean): void;
  23776. /**
  23777. * Called on JS contextmenu event.
  23778. * Override this method to provide functionality.
  23779. */
  23780. protected onContextMenu(evt: PointerEvent): void;
  23781. /**
  23782. * Detach the current controls from the specified dom element.
  23783. */
  23784. detachControl(): void;
  23785. /**
  23786. * Gets the class name of the current intput.
  23787. * @returns the class name
  23788. */
  23789. getClassName(): string;
  23790. /**
  23791. * Get the friendly name associated with the input class.
  23792. * @returns the input friendly name
  23793. */
  23794. getSimpleName(): string;
  23795. }
  23796. }
  23797. declare module BABYLON {
  23798. /**
  23799. * Base class for mouse wheel input..
  23800. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  23801. * for example usage.
  23802. */
  23803. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  23804. /**
  23805. * Defines the camera the input is attached to.
  23806. */
  23807. abstract camera: Camera;
  23808. /**
  23809. * How fast is the camera moves in relation to X axis mouseWheel events.
  23810. * Use negative value to reverse direction.
  23811. */
  23812. wheelPrecisionX: number;
  23813. /**
  23814. * How fast is the camera moves in relation to Y axis mouseWheel events.
  23815. * Use negative value to reverse direction.
  23816. */
  23817. wheelPrecisionY: number;
  23818. /**
  23819. * How fast is the camera moves in relation to Z axis mouseWheel events.
  23820. * Use negative value to reverse direction.
  23821. */
  23822. wheelPrecisionZ: number;
  23823. /**
  23824. * Observable for when a mouse wheel move event occurs.
  23825. */
  23826. onChangedObservable: Observable<{
  23827. wheelDeltaX: number;
  23828. wheelDeltaY: number;
  23829. wheelDeltaZ: number;
  23830. }>;
  23831. private _wheel;
  23832. private _observer;
  23833. /**
  23834. * Attach the input controls to a specific dom element to get the input from.
  23835. * @param noPreventDefault Defines whether event caught by the controls
  23836. * should call preventdefault().
  23837. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23838. */
  23839. attachControl(noPreventDefault?: boolean): void;
  23840. /**
  23841. * Detach the current controls from the specified dom element.
  23842. */
  23843. detachControl(): void;
  23844. /**
  23845. * Called for each rendered frame.
  23846. */
  23847. checkInputs(): void;
  23848. /**
  23849. * Gets the class name of the current intput.
  23850. * @returns the class name
  23851. */
  23852. getClassName(): string;
  23853. /**
  23854. * Get the friendly name associated with the input class.
  23855. * @returns the input friendly name
  23856. */
  23857. getSimpleName(): string;
  23858. /**
  23859. * Incremental value of multiple mouse wheel movements of the X axis.
  23860. * Should be zero-ed when read.
  23861. */
  23862. protected _wheelDeltaX: number;
  23863. /**
  23864. * Incremental value of multiple mouse wheel movements of the Y axis.
  23865. * Should be zero-ed when read.
  23866. */
  23867. protected _wheelDeltaY: number;
  23868. /**
  23869. * Incremental value of multiple mouse wheel movements of the Z axis.
  23870. * Should be zero-ed when read.
  23871. */
  23872. protected _wheelDeltaZ: number;
  23873. /**
  23874. * Firefox uses a different scheme to report scroll distances to other
  23875. * browsers. Rather than use complicated methods to calculate the exact
  23876. * multiple we need to apply, let's just cheat and use a constant.
  23877. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  23878. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  23879. */
  23880. private readonly _ffMultiplier;
  23881. /**
  23882. * Different event attributes for wheel data fall into a few set ranges.
  23883. * Some relevant but dated date here:
  23884. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  23885. */
  23886. private readonly _normalize;
  23887. }
  23888. }
  23889. declare module BABYLON {
  23890. /**
  23891. * Manage the mouse wheel inputs to control a free camera.
  23892. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23893. */
  23894. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  23895. /**
  23896. * Defines the camera the input is attached to.
  23897. */
  23898. camera: FreeCamera;
  23899. /**
  23900. * Gets the class name of the current input.
  23901. * @returns the class name
  23902. */
  23903. getClassName(): string;
  23904. /**
  23905. * Set which movement axis (relative to camera's orientation) the mouse
  23906. * wheel's X axis controls.
  23907. * @param axis The axis to be moved. Set null to clear.
  23908. */
  23909. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  23910. /**
  23911. * Get the configured movement axis (relative to camera's orientation) the
  23912. * mouse wheel's X axis controls.
  23913. * @returns The configured axis or null if none.
  23914. */
  23915. get wheelXMoveRelative(): Nullable<Coordinate>;
  23916. /**
  23917. * Set which movement axis (relative to camera's orientation) the mouse
  23918. * wheel's Y axis controls.
  23919. * @param axis The axis to be moved. Set null to clear.
  23920. */
  23921. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  23922. /**
  23923. * Get the configured movement axis (relative to camera's orientation) the
  23924. * mouse wheel's Y axis controls.
  23925. * @returns The configured axis or null if none.
  23926. */
  23927. get wheelYMoveRelative(): Nullable<Coordinate>;
  23928. /**
  23929. * Set which movement axis (relative to camera's orientation) the mouse
  23930. * wheel's Z axis controls.
  23931. * @param axis The axis to be moved. Set null to clear.
  23932. */
  23933. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  23934. /**
  23935. * Get the configured movement axis (relative to camera's orientation) the
  23936. * mouse wheel's Z axis controls.
  23937. * @returns The configured axis or null if none.
  23938. */
  23939. get wheelZMoveRelative(): Nullable<Coordinate>;
  23940. /**
  23941. * Set which rotation axis (relative to camera's orientation) the mouse
  23942. * wheel's X axis controls.
  23943. * @param axis The axis to be moved. Set null to clear.
  23944. */
  23945. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  23946. /**
  23947. * Get the configured rotation axis (relative to camera's orientation) the
  23948. * mouse wheel's X axis controls.
  23949. * @returns The configured axis or null if none.
  23950. */
  23951. get wheelXRotateRelative(): Nullable<Coordinate>;
  23952. /**
  23953. * Set which rotation axis (relative to camera's orientation) the mouse
  23954. * wheel's Y axis controls.
  23955. * @param axis The axis to be moved. Set null to clear.
  23956. */
  23957. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  23958. /**
  23959. * Get the configured rotation axis (relative to camera's orientation) the
  23960. * mouse wheel's Y axis controls.
  23961. * @returns The configured axis or null if none.
  23962. */
  23963. get wheelYRotateRelative(): Nullable<Coordinate>;
  23964. /**
  23965. * Set which rotation axis (relative to camera's orientation) the mouse
  23966. * wheel's Z axis controls.
  23967. * @param axis The axis to be moved. Set null to clear.
  23968. */
  23969. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  23970. /**
  23971. * Get the configured rotation axis (relative to camera's orientation) the
  23972. * mouse wheel's Z axis controls.
  23973. * @returns The configured axis or null if none.
  23974. */
  23975. get wheelZRotateRelative(): Nullable<Coordinate>;
  23976. /**
  23977. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  23978. * controls.
  23979. * @param axis The axis to be moved. Set null to clear.
  23980. */
  23981. set wheelXMoveScene(axis: Nullable<Coordinate>);
  23982. /**
  23983. * Get the configured movement axis (relative to the scene) the mouse wheel's
  23984. * X axis controls.
  23985. * @returns The configured axis or null if none.
  23986. */
  23987. get wheelXMoveScene(): Nullable<Coordinate>;
  23988. /**
  23989. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  23990. * controls.
  23991. * @param axis The axis to be moved. Set null to clear.
  23992. */
  23993. set wheelYMoveScene(axis: Nullable<Coordinate>);
  23994. /**
  23995. * Get the configured movement axis (relative to the scene) the mouse wheel's
  23996. * Y axis controls.
  23997. * @returns The configured axis or null if none.
  23998. */
  23999. get wheelYMoveScene(): Nullable<Coordinate>;
  24000. /**
  24001. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24002. * controls.
  24003. * @param axis The axis to be moved. Set null to clear.
  24004. */
  24005. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24006. /**
  24007. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24008. * Z axis controls.
  24009. * @returns The configured axis or null if none.
  24010. */
  24011. get wheelZMoveScene(): Nullable<Coordinate>;
  24012. /**
  24013. * Called for each rendered frame.
  24014. */
  24015. checkInputs(): void;
  24016. private _moveRelative;
  24017. private _rotateRelative;
  24018. private _moveScene;
  24019. /**
  24020. * These are set to the desired default behaviour.
  24021. */
  24022. private _wheelXAction;
  24023. private _wheelXActionCoordinate;
  24024. private _wheelYAction;
  24025. private _wheelYActionCoordinate;
  24026. private _wheelZAction;
  24027. private _wheelZActionCoordinate;
  24028. /**
  24029. * Update the camera according to any configured properties for the 3
  24030. * mouse-wheel axis.
  24031. */
  24032. private _updateCamera;
  24033. }
  24034. }
  24035. declare module BABYLON {
  24036. /**
  24037. * Manage the touch inputs to control the movement of a free camera.
  24038. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24039. */
  24040. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24041. /**
  24042. * Define if mouse events can be treated as touch events
  24043. */
  24044. allowMouse: boolean;
  24045. /**
  24046. * Defines the camera the input is attached to.
  24047. */
  24048. camera: FreeCamera;
  24049. /**
  24050. * Defines the touch sensibility for rotation.
  24051. * The higher the faster.
  24052. */
  24053. touchAngularSensibility: number;
  24054. /**
  24055. * Defines the touch sensibility for move.
  24056. * The higher the faster.
  24057. */
  24058. touchMoveSensibility: number;
  24059. private _offsetX;
  24060. private _offsetY;
  24061. private _pointerPressed;
  24062. private _pointerInput?;
  24063. private _observer;
  24064. private _onLostFocus;
  24065. /**
  24066. * Manage the touch inputs to control the movement of a free camera.
  24067. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24068. * @param allowMouse Defines if mouse events can be treated as touch events
  24069. */
  24070. constructor(
  24071. /**
  24072. * Define if mouse events can be treated as touch events
  24073. */
  24074. allowMouse?: boolean);
  24075. /**
  24076. * Attach the input controls to a specific dom element to get the input from.
  24077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24078. */
  24079. attachControl(noPreventDefault?: boolean): void;
  24080. /**
  24081. * Detach the current controls from the specified dom element.
  24082. */
  24083. detachControl(): void;
  24084. /**
  24085. * Update the current camera state depending on the inputs that have been used this frame.
  24086. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24087. */
  24088. checkInputs(): void;
  24089. /**
  24090. * Gets the class name of the current intput.
  24091. * @returns the class name
  24092. */
  24093. getClassName(): string;
  24094. /**
  24095. * Get the friendly name associated with the input class.
  24096. * @returns the input friendly name
  24097. */
  24098. getSimpleName(): string;
  24099. }
  24100. }
  24101. declare module BABYLON {
  24102. /**
  24103. * Default Inputs manager for the FreeCamera.
  24104. * It groups all the default supported inputs for ease of use.
  24105. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24106. */
  24107. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24108. /**
  24109. * @hidden
  24110. */
  24111. _mouseInput: Nullable<FreeCameraMouseInput>;
  24112. /**
  24113. * @hidden
  24114. */
  24115. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24116. /**
  24117. * Instantiates a new FreeCameraInputsManager.
  24118. * @param camera Defines the camera the inputs belong to
  24119. */
  24120. constructor(camera: FreeCamera);
  24121. /**
  24122. * Add keyboard input support to the input manager.
  24123. * @returns the current input manager
  24124. */
  24125. addKeyboard(): FreeCameraInputsManager;
  24126. /**
  24127. * Add mouse input support to the input manager.
  24128. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  24129. * @returns the current input manager
  24130. */
  24131. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  24132. /**
  24133. * Removes the mouse input support from the manager
  24134. * @returns the current input manager
  24135. */
  24136. removeMouse(): FreeCameraInputsManager;
  24137. /**
  24138. * Add mouse wheel input support to the input manager.
  24139. * @returns the current input manager
  24140. */
  24141. addMouseWheel(): FreeCameraInputsManager;
  24142. /**
  24143. * Removes the mouse wheel input support from the manager
  24144. * @returns the current input manager
  24145. */
  24146. removeMouseWheel(): FreeCameraInputsManager;
  24147. /**
  24148. * Add touch input support to the input manager.
  24149. * @returns the current input manager
  24150. */
  24151. addTouch(): FreeCameraInputsManager;
  24152. /**
  24153. * Remove all attached input methods from a camera
  24154. */
  24155. clear(): void;
  24156. }
  24157. }
  24158. declare module BABYLON {
  24159. /**
  24160. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24161. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  24162. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24163. */
  24164. export class FreeCamera extends TargetCamera {
  24165. /**
  24166. * Define the collision ellipsoid of the camera.
  24167. * This is helpful to simulate a camera body like the player body around the camera
  24168. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  24169. */
  24170. ellipsoid: Vector3;
  24171. /**
  24172. * Define an offset for the position of the ellipsoid around the camera.
  24173. * This can be helpful to determine the center of the body near the gravity center of the body
  24174. * instead of its head.
  24175. */
  24176. ellipsoidOffset: Vector3;
  24177. /**
  24178. * Enable or disable collisions of the camera with the rest of the scene objects.
  24179. */
  24180. checkCollisions: boolean;
  24181. /**
  24182. * Enable or disable gravity on the camera.
  24183. */
  24184. applyGravity: boolean;
  24185. /**
  24186. * Define the input manager associated to the camera.
  24187. */
  24188. inputs: FreeCameraInputsManager;
  24189. /**
  24190. * Gets the input sensibility for a mouse input. (default is 2000.0)
  24191. * Higher values reduce sensitivity.
  24192. */
  24193. get angularSensibility(): number;
  24194. /**
  24195. * Sets the input sensibility for a mouse input. (default is 2000.0)
  24196. * Higher values reduce sensitivity.
  24197. */
  24198. set angularSensibility(value: number);
  24199. /**
  24200. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  24201. */
  24202. get keysUp(): number[];
  24203. set keysUp(value: number[]);
  24204. /**
  24205. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  24206. */
  24207. get keysUpward(): number[];
  24208. set keysUpward(value: number[]);
  24209. /**
  24210. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  24211. */
  24212. get keysDown(): number[];
  24213. set keysDown(value: number[]);
  24214. /**
  24215. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  24216. */
  24217. get keysDownward(): number[];
  24218. set keysDownward(value: number[]);
  24219. /**
  24220. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  24221. */
  24222. get keysLeft(): number[];
  24223. set keysLeft(value: number[]);
  24224. /**
  24225. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  24226. */
  24227. get keysRight(): number[];
  24228. set keysRight(value: number[]);
  24229. /**
  24230. * Event raised when the camera collide with a mesh in the scene.
  24231. */
  24232. onCollide: (collidedMesh: AbstractMesh) => void;
  24233. private _collider;
  24234. private _needMoveForGravity;
  24235. private _oldPosition;
  24236. private _diffPosition;
  24237. private _newPosition;
  24238. /** @hidden */
  24239. _localDirection: Vector3;
  24240. /** @hidden */
  24241. _transformedDirection: Vector3;
  24242. /**
  24243. * Instantiates a Free Camera.
  24244. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24245. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  24246. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24247. * @param name Define the name of the camera in the scene
  24248. * @param position Define the start position of the camera in the scene
  24249. * @param scene Define the scene the camera belongs to
  24250. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  24251. */
  24252. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24253. /**
  24254. * Attach the input controls to a specific dom element to get the input from.
  24255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24256. */
  24257. attachControl(noPreventDefault?: boolean): void;
  24258. /**
  24259. * Attach the input controls to a specific dom element to get the input from.
  24260. * @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
  24261. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24262. * BACK COMPAT SIGNATURE ONLY.
  24263. */
  24264. attachControl(ignored: any, noPreventDefault?: boolean): void;
  24265. /**
  24266. * Detach the current controls from the specified dom element.
  24267. */
  24268. detachControl(): void;
  24269. /**
  24270. * Detach the current controls from the specified dom element.
  24271. * @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
  24272. */
  24273. detachControl(ignored: any): void;
  24274. private _collisionMask;
  24275. /**
  24276. * Define a collision mask to limit the list of object the camera can collide with
  24277. */
  24278. get collisionMask(): number;
  24279. set collisionMask(mask: number);
  24280. /** @hidden */
  24281. _collideWithWorld(displacement: Vector3): void;
  24282. private _onCollisionPositionChange;
  24283. /** @hidden */
  24284. _checkInputs(): void;
  24285. /** @hidden */
  24286. _decideIfNeedsToMove(): boolean;
  24287. /** @hidden */
  24288. _updatePosition(): void;
  24289. /**
  24290. * Destroy the camera and release the current resources hold by it.
  24291. */
  24292. dispose(): void;
  24293. /**
  24294. * Gets the current object class name.
  24295. * @return the class name
  24296. */
  24297. getClassName(): string;
  24298. }
  24299. }
  24300. declare module BABYLON {
  24301. /**
  24302. * Represents a gamepad control stick position
  24303. */
  24304. export class StickValues {
  24305. /**
  24306. * The x component of the control stick
  24307. */
  24308. x: number;
  24309. /**
  24310. * The y component of the control stick
  24311. */
  24312. y: number;
  24313. /**
  24314. * Initializes the gamepad x and y control stick values
  24315. * @param x The x component of the gamepad control stick value
  24316. * @param y The y component of the gamepad control stick value
  24317. */
  24318. constructor(
  24319. /**
  24320. * The x component of the control stick
  24321. */
  24322. x: number,
  24323. /**
  24324. * The y component of the control stick
  24325. */
  24326. y: number);
  24327. }
  24328. /**
  24329. * An interface which manages callbacks for gamepad button changes
  24330. */
  24331. export interface GamepadButtonChanges {
  24332. /**
  24333. * Called when a gamepad has been changed
  24334. */
  24335. changed: boolean;
  24336. /**
  24337. * Called when a gamepad press event has been triggered
  24338. */
  24339. pressChanged: boolean;
  24340. /**
  24341. * Called when a touch event has been triggered
  24342. */
  24343. touchChanged: boolean;
  24344. /**
  24345. * Called when a value has changed
  24346. */
  24347. valueChanged: boolean;
  24348. }
  24349. /**
  24350. * Represents a gamepad
  24351. */
  24352. export class Gamepad {
  24353. /**
  24354. * The id of the gamepad
  24355. */
  24356. id: string;
  24357. /**
  24358. * The index of the gamepad
  24359. */
  24360. index: number;
  24361. /**
  24362. * The browser gamepad
  24363. */
  24364. browserGamepad: any;
  24365. /**
  24366. * Specifies what type of gamepad this represents
  24367. */
  24368. type: number;
  24369. private _leftStick;
  24370. private _rightStick;
  24371. /** @hidden */
  24372. _isConnected: boolean;
  24373. private _leftStickAxisX;
  24374. private _leftStickAxisY;
  24375. private _rightStickAxisX;
  24376. private _rightStickAxisY;
  24377. /**
  24378. * Triggered when the left control stick has been changed
  24379. */
  24380. private _onleftstickchanged;
  24381. /**
  24382. * Triggered when the right control stick has been changed
  24383. */
  24384. private _onrightstickchanged;
  24385. /**
  24386. * Represents a gamepad controller
  24387. */
  24388. static GAMEPAD: number;
  24389. /**
  24390. * Represents a generic controller
  24391. */
  24392. static GENERIC: number;
  24393. /**
  24394. * Represents an XBox controller
  24395. */
  24396. static XBOX: number;
  24397. /**
  24398. * Represents a pose-enabled controller
  24399. */
  24400. static POSE_ENABLED: number;
  24401. /**
  24402. * Represents an Dual Shock controller
  24403. */
  24404. static DUALSHOCK: number;
  24405. /**
  24406. * Specifies whether the left control stick should be Y-inverted
  24407. */
  24408. protected _invertLeftStickY: boolean;
  24409. /**
  24410. * Specifies if the gamepad has been connected
  24411. */
  24412. get isConnected(): boolean;
  24413. /**
  24414. * Initializes the gamepad
  24415. * @param id The id of the gamepad
  24416. * @param index The index of the gamepad
  24417. * @param browserGamepad The browser gamepad
  24418. * @param leftStickX The x component of the left joystick
  24419. * @param leftStickY The y component of the left joystick
  24420. * @param rightStickX The x component of the right joystick
  24421. * @param rightStickY The y component of the right joystick
  24422. */
  24423. constructor(
  24424. /**
  24425. * The id of the gamepad
  24426. */
  24427. id: string,
  24428. /**
  24429. * The index of the gamepad
  24430. */
  24431. index: number,
  24432. /**
  24433. * The browser gamepad
  24434. */
  24435. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  24436. /**
  24437. * Callback triggered when the left joystick has changed
  24438. * @param callback
  24439. */
  24440. onleftstickchanged(callback: (values: StickValues) => void): void;
  24441. /**
  24442. * Callback triggered when the right joystick has changed
  24443. * @param callback
  24444. */
  24445. onrightstickchanged(callback: (values: StickValues) => void): void;
  24446. /**
  24447. * Gets the left joystick
  24448. */
  24449. get leftStick(): StickValues;
  24450. /**
  24451. * Sets the left joystick values
  24452. */
  24453. set leftStick(newValues: StickValues);
  24454. /**
  24455. * Gets the right joystick
  24456. */
  24457. get rightStick(): StickValues;
  24458. /**
  24459. * Sets the right joystick value
  24460. */
  24461. set rightStick(newValues: StickValues);
  24462. /**
  24463. * Updates the gamepad joystick positions
  24464. */
  24465. update(): void;
  24466. /**
  24467. * Disposes the gamepad
  24468. */
  24469. dispose(): void;
  24470. }
  24471. /**
  24472. * Represents a generic gamepad
  24473. */
  24474. export class GenericPad extends Gamepad {
  24475. private _buttons;
  24476. private _onbuttondown;
  24477. private _onbuttonup;
  24478. /**
  24479. * Observable triggered when a button has been pressed
  24480. */
  24481. onButtonDownObservable: Observable<number>;
  24482. /**
  24483. * Observable triggered when a button has been released
  24484. */
  24485. onButtonUpObservable: Observable<number>;
  24486. /**
  24487. * Callback triggered when a button has been pressed
  24488. * @param callback Called when a button has been pressed
  24489. */
  24490. onbuttondown(callback: (buttonPressed: number) => void): void;
  24491. /**
  24492. * Callback triggered when a button has been released
  24493. * @param callback Called when a button has been released
  24494. */
  24495. onbuttonup(callback: (buttonReleased: number) => void): void;
  24496. /**
  24497. * Initializes the generic gamepad
  24498. * @param id The id of the generic gamepad
  24499. * @param index The index of the generic gamepad
  24500. * @param browserGamepad The browser gamepad
  24501. */
  24502. constructor(id: string, index: number, browserGamepad: any);
  24503. private _setButtonValue;
  24504. /**
  24505. * Updates the generic gamepad
  24506. */
  24507. update(): void;
  24508. /**
  24509. * Disposes the generic gamepad
  24510. */
  24511. dispose(): void;
  24512. }
  24513. }
  24514. declare module BABYLON {
  24515. /**
  24516. * Defines a runtime animation
  24517. */
  24518. export class RuntimeAnimation {
  24519. private _events;
  24520. /**
  24521. * The current frame of the runtime animation
  24522. */
  24523. private _currentFrame;
  24524. /**
  24525. * The animation used by the runtime animation
  24526. */
  24527. private _animation;
  24528. /**
  24529. * The target of the runtime animation
  24530. */
  24531. private _target;
  24532. /**
  24533. * The initiating animatable
  24534. */
  24535. private _host;
  24536. /**
  24537. * The original value of the runtime animation
  24538. */
  24539. private _originalValue;
  24540. /**
  24541. * The original blend value of the runtime animation
  24542. */
  24543. private _originalBlendValue;
  24544. /**
  24545. * The offsets cache of the runtime animation
  24546. */
  24547. private _offsetsCache;
  24548. /**
  24549. * The high limits cache of the runtime animation
  24550. */
  24551. private _highLimitsCache;
  24552. /**
  24553. * Specifies if the runtime animation has been stopped
  24554. */
  24555. private _stopped;
  24556. /**
  24557. * The blending factor of the runtime animation
  24558. */
  24559. private _blendingFactor;
  24560. /**
  24561. * The BabylonJS scene
  24562. */
  24563. private _scene;
  24564. /**
  24565. * The current value of the runtime animation
  24566. */
  24567. private _currentValue;
  24568. /** @hidden */
  24569. _animationState: _IAnimationState;
  24570. /**
  24571. * The active target of the runtime animation
  24572. */
  24573. private _activeTargets;
  24574. private _currentActiveTarget;
  24575. private _directTarget;
  24576. /**
  24577. * The target path of the runtime animation
  24578. */
  24579. private _targetPath;
  24580. /**
  24581. * The weight of the runtime animation
  24582. */
  24583. private _weight;
  24584. /**
  24585. * The ratio offset of the runtime animation
  24586. */
  24587. private _ratioOffset;
  24588. /**
  24589. * The previous delay of the runtime animation
  24590. */
  24591. private _previousDelay;
  24592. /**
  24593. * The previous ratio of the runtime animation
  24594. */
  24595. private _previousRatio;
  24596. private _enableBlending;
  24597. private _keys;
  24598. private _minFrame;
  24599. private _maxFrame;
  24600. private _minValue;
  24601. private _maxValue;
  24602. private _targetIsArray;
  24603. /**
  24604. * Gets the current frame of the runtime animation
  24605. */
  24606. get currentFrame(): number;
  24607. /**
  24608. * Gets the weight of the runtime animation
  24609. */
  24610. get weight(): number;
  24611. /**
  24612. * Gets the current value of the runtime animation
  24613. */
  24614. get currentValue(): any;
  24615. /**
  24616. * Gets the target path of the runtime animation
  24617. */
  24618. get targetPath(): string;
  24619. /**
  24620. * Gets the actual target of the runtime animation
  24621. */
  24622. get target(): any;
  24623. /**
  24624. * Gets the additive state of the runtime animation
  24625. */
  24626. get isAdditive(): boolean;
  24627. /** @hidden */
  24628. _onLoop: () => void;
  24629. /**
  24630. * Create a new RuntimeAnimation object
  24631. * @param target defines the target of the animation
  24632. * @param animation defines the source animation object
  24633. * @param scene defines the hosting scene
  24634. * @param host defines the initiating Animatable
  24635. */
  24636. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  24637. private _preparePath;
  24638. /**
  24639. * Gets the animation from the runtime animation
  24640. */
  24641. get animation(): Animation;
  24642. /**
  24643. * Resets the runtime animation to the beginning
  24644. * @param restoreOriginal defines whether to restore the target property to the original value
  24645. */
  24646. reset(restoreOriginal?: boolean): void;
  24647. /**
  24648. * Specifies if the runtime animation is stopped
  24649. * @returns Boolean specifying if the runtime animation is stopped
  24650. */
  24651. isStopped(): boolean;
  24652. /**
  24653. * Disposes of the runtime animation
  24654. */
  24655. dispose(): void;
  24656. /**
  24657. * Apply the interpolated value to the target
  24658. * @param currentValue defines the value computed by the animation
  24659. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  24660. */
  24661. setValue(currentValue: any, weight: number): void;
  24662. private _getOriginalValues;
  24663. private _setValue;
  24664. /**
  24665. * Gets the loop pmode of the runtime animation
  24666. * @returns Loop Mode
  24667. */
  24668. private _getCorrectLoopMode;
  24669. /**
  24670. * Move the current animation to a given frame
  24671. * @param frame defines the frame to move to
  24672. */
  24673. goToFrame(frame: number): void;
  24674. /**
  24675. * @hidden Internal use only
  24676. */
  24677. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  24678. /**
  24679. * Execute the current animation
  24680. * @param delay defines the delay to add to the current frame
  24681. * @param from defines the lower bound of the animation range
  24682. * @param to defines the upper bound of the animation range
  24683. * @param loop defines if the current animation must loop
  24684. * @param speedRatio defines the current speed ratio
  24685. * @param weight defines the weight of the animation (default is -1 so no weight)
  24686. * @param onLoop optional callback called when animation loops
  24687. * @returns a boolean indicating if the animation is running
  24688. */
  24689. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  24690. }
  24691. }
  24692. declare module BABYLON {
  24693. /**
  24694. * Class used to store an actual running animation
  24695. */
  24696. export class Animatable {
  24697. /** defines the target object */
  24698. target: any;
  24699. /** defines the starting frame number (default is 0) */
  24700. fromFrame: number;
  24701. /** defines the ending frame number (default is 100) */
  24702. toFrame: number;
  24703. /** defines if the animation must loop (default is false) */
  24704. loopAnimation: boolean;
  24705. /** defines a callback to call when animation ends if it is not looping */
  24706. onAnimationEnd?: (() => void) | null | undefined;
  24707. /** defines a callback to call when animation loops */
  24708. onAnimationLoop?: (() => void) | null | undefined;
  24709. /** defines whether the animation should be evaluated additively */
  24710. isAdditive: boolean;
  24711. private _localDelayOffset;
  24712. private _pausedDelay;
  24713. private _runtimeAnimations;
  24714. private _paused;
  24715. private _scene;
  24716. private _speedRatio;
  24717. private _weight;
  24718. private _syncRoot;
  24719. /**
  24720. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24721. * This will only apply for non looping animation (default is true)
  24722. */
  24723. disposeOnEnd: boolean;
  24724. /**
  24725. * Gets a boolean indicating if the animation has started
  24726. */
  24727. animationStarted: boolean;
  24728. /**
  24729. * Observer raised when the animation ends
  24730. */
  24731. onAnimationEndObservable: Observable<Animatable>;
  24732. /**
  24733. * Observer raised when the animation loops
  24734. */
  24735. onAnimationLoopObservable: Observable<Animatable>;
  24736. /**
  24737. * Gets the root Animatable used to synchronize and normalize animations
  24738. */
  24739. get syncRoot(): Nullable<Animatable>;
  24740. /**
  24741. * Gets the current frame of the first RuntimeAnimation
  24742. * Used to synchronize Animatables
  24743. */
  24744. get masterFrame(): number;
  24745. /**
  24746. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24747. */
  24748. get weight(): number;
  24749. set weight(value: number);
  24750. /**
  24751. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24752. */
  24753. get speedRatio(): number;
  24754. set speedRatio(value: number);
  24755. /**
  24756. * Creates a new Animatable
  24757. * @param scene defines the hosting scene
  24758. * @param target defines the target object
  24759. * @param fromFrame defines the starting frame number (default is 0)
  24760. * @param toFrame defines the ending frame number (default is 100)
  24761. * @param loopAnimation defines if the animation must loop (default is false)
  24762. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24763. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24764. * @param animations defines a group of animation to add to the new Animatable
  24765. * @param onAnimationLoop defines a callback to call when animation loops
  24766. * @param isAdditive defines whether the animation should be evaluated additively
  24767. */
  24768. constructor(scene: Scene,
  24769. /** defines the target object */
  24770. target: any,
  24771. /** defines the starting frame number (default is 0) */
  24772. fromFrame?: number,
  24773. /** defines the ending frame number (default is 100) */
  24774. toFrame?: number,
  24775. /** defines if the animation must loop (default is false) */
  24776. loopAnimation?: boolean, speedRatio?: number,
  24777. /** defines a callback to call when animation ends if it is not looping */
  24778. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24779. /** defines a callback to call when animation loops */
  24780. onAnimationLoop?: (() => void) | null | undefined,
  24781. /** defines whether the animation should be evaluated additively */
  24782. isAdditive?: boolean);
  24783. /**
  24784. * Synchronize and normalize current Animatable with a source Animatable
  24785. * This is useful when using animation weights and when animations are not of the same length
  24786. * @param root defines the root Animatable to synchronize with
  24787. * @returns the current Animatable
  24788. */
  24789. syncWith(root: Animatable): Animatable;
  24790. /**
  24791. * Gets the list of runtime animations
  24792. * @returns an array of RuntimeAnimation
  24793. */
  24794. getAnimations(): RuntimeAnimation[];
  24795. /**
  24796. * Adds more animations to the current animatable
  24797. * @param target defines the target of the animations
  24798. * @param animations defines the new animations to add
  24799. */
  24800. appendAnimations(target: any, animations: Animation[]): void;
  24801. /**
  24802. * Gets the source animation for a specific property
  24803. * @param property defines the propertyu to look for
  24804. * @returns null or the source animation for the given property
  24805. */
  24806. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24807. /**
  24808. * Gets the runtime animation for a specific property
  24809. * @param property defines the propertyu to look for
  24810. * @returns null or the runtime animation for the given property
  24811. */
  24812. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24813. /**
  24814. * Resets the animatable to its original state
  24815. */
  24816. reset(): void;
  24817. /**
  24818. * Allows the animatable to blend with current running animations
  24819. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24820. * @param blendingSpeed defines the blending speed to use
  24821. */
  24822. enableBlending(blendingSpeed: number): void;
  24823. /**
  24824. * Disable animation blending
  24825. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24826. */
  24827. disableBlending(): void;
  24828. /**
  24829. * Jump directly to a given frame
  24830. * @param frame defines the frame to jump to
  24831. */
  24832. goToFrame(frame: number): void;
  24833. /**
  24834. * Pause the animation
  24835. */
  24836. pause(): void;
  24837. /**
  24838. * Restart the animation
  24839. */
  24840. restart(): void;
  24841. private _raiseOnAnimationEnd;
  24842. /**
  24843. * Stop and delete the current animation
  24844. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  24845. * @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)
  24846. */
  24847. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  24848. /**
  24849. * Wait asynchronously for the animation to end
  24850. * @returns a promise which will be fullfilled when the animation ends
  24851. */
  24852. waitAsync(): Promise<Animatable>;
  24853. /** @hidden */
  24854. _animate(delay: number): boolean;
  24855. }
  24856. interface Scene {
  24857. /** @hidden */
  24858. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  24859. /** @hidden */
  24860. _processLateAnimationBindingsForMatrices(holder: {
  24861. totalWeight: number;
  24862. totalAdditiveWeight: number;
  24863. animations: RuntimeAnimation[];
  24864. additiveAnimations: RuntimeAnimation[];
  24865. originalValue: Matrix;
  24866. }): any;
  24867. /** @hidden */
  24868. _processLateAnimationBindingsForQuaternions(holder: {
  24869. totalWeight: number;
  24870. totalAdditiveWeight: number;
  24871. animations: RuntimeAnimation[];
  24872. additiveAnimations: RuntimeAnimation[];
  24873. originalValue: Quaternion;
  24874. }, refQuaternion: Quaternion): Quaternion;
  24875. /** @hidden */
  24876. _processLateAnimationBindings(): void;
  24877. /**
  24878. * Will start the animation sequence of a given target
  24879. * @param target defines the target
  24880. * @param from defines from which frame should animation start
  24881. * @param to defines until which frame should animation run.
  24882. * @param weight defines the weight to apply to the animation (1.0 by default)
  24883. * @param loop defines if the animation loops
  24884. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24885. * @param onAnimationEnd defines the function to be executed when the animation ends
  24886. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24887. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24888. * @param onAnimationLoop defines the callback to call when an animation loops
  24889. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  24890. * @returns the animatable object created for this animation
  24891. */
  24892. 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;
  24893. /**
  24894. * Will start the animation sequence of a given target
  24895. * @param target defines the target
  24896. * @param from defines from which frame should animation start
  24897. * @param to defines until which frame should animation run.
  24898. * @param loop defines if the animation loops
  24899. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24900. * @param onAnimationEnd defines the function to be executed when the animation ends
  24901. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24902. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24903. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  24904. * @param onAnimationLoop defines the callback to call when an animation loops
  24905. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  24906. * @returns the animatable object created for this animation
  24907. */
  24908. 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;
  24909. /**
  24910. * Will start the animation sequence of a given target and its hierarchy
  24911. * @param target defines the target
  24912. * @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.
  24913. * @param from defines from which frame should animation start
  24914. * @param to defines until which frame should animation run.
  24915. * @param loop defines if the animation loops
  24916. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24917. * @param onAnimationEnd defines the function to be executed when the animation ends
  24918. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24919. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24920. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24921. * @param onAnimationLoop defines the callback to call when an animation loops
  24922. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  24923. * @returns the list of created animatables
  24924. */
  24925. 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[];
  24926. /**
  24927. * Begin a new animation on a given node
  24928. * @param target defines the target where the animation will take place
  24929. * @param animations defines the list of animations to start
  24930. * @param from defines the initial value
  24931. * @param to defines the final value
  24932. * @param loop defines if you want animation to loop (off by default)
  24933. * @param speedRatio defines the speed ratio to apply to all animations
  24934. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24935. * @param onAnimationLoop defines the callback to call when an animation loops
  24936. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  24937. * @returns the list of created animatables
  24938. */
  24939. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  24940. /**
  24941. * Begin a new animation on a given node and its hierarchy
  24942. * @param target defines the root node where the animation will take place
  24943. * @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.
  24944. * @param animations defines the list of animations to start
  24945. * @param from defines the initial value
  24946. * @param to defines the final value
  24947. * @param loop defines if you want animation to loop (off by default)
  24948. * @param speedRatio defines the speed ratio to apply to all animations
  24949. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24950. * @param onAnimationLoop defines the callback to call when an animation loops
  24951. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  24952. * @returns the list of animatables created for all nodes
  24953. */
  24954. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  24955. /**
  24956. * Gets the animatable associated with a specific target
  24957. * @param target defines the target of the animatable
  24958. * @returns the required animatable if found
  24959. */
  24960. getAnimatableByTarget(target: any): Nullable<Animatable>;
  24961. /**
  24962. * Gets all animatables associated with a given target
  24963. * @param target defines the target to look animatables for
  24964. * @returns an array of Animatables
  24965. */
  24966. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  24967. /**
  24968. * Stops and removes all animations that have been applied to the scene
  24969. */
  24970. stopAllAnimations(): void;
  24971. /**
  24972. * Gets the current delta time used by animation engine
  24973. */
  24974. deltaTime: number;
  24975. }
  24976. interface Bone {
  24977. /**
  24978. * Copy an animation range from another bone
  24979. * @param source defines the source bone
  24980. * @param rangeName defines the range name to copy
  24981. * @param frameOffset defines the frame offset
  24982. * @param rescaleAsRequired defines if rescaling must be applied if required
  24983. * @param skelDimensionsRatio defines the scaling ratio
  24984. * @returns true if operation was successful
  24985. */
  24986. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  24987. }
  24988. }
  24989. declare module BABYLON {
  24990. /**
  24991. * Class used to override all child animations of a given target
  24992. */
  24993. export class AnimationPropertiesOverride {
  24994. /**
  24995. * Gets or sets a value indicating if animation blending must be used
  24996. */
  24997. enableBlending: boolean;
  24998. /**
  24999. * Gets or sets the blending speed to use when enableBlending is true
  25000. */
  25001. blendingSpeed: number;
  25002. /**
  25003. * Gets or sets the default loop mode to use
  25004. */
  25005. loopMode: number;
  25006. }
  25007. }
  25008. declare module BABYLON {
  25009. /**
  25010. * Class used to handle skinning animations
  25011. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25012. */
  25013. export class Skeleton implements IAnimatable {
  25014. /** defines the skeleton name */
  25015. name: string;
  25016. /** defines the skeleton Id */
  25017. id: string;
  25018. /**
  25019. * Defines the list of child bones
  25020. */
  25021. bones: Bone[];
  25022. /**
  25023. * Defines an estimate of the dimension of the skeleton at rest
  25024. */
  25025. dimensionsAtRest: Vector3;
  25026. /**
  25027. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25028. */
  25029. needInitialSkinMatrix: boolean;
  25030. /**
  25031. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25032. */
  25033. overrideMesh: Nullable<AbstractMesh>;
  25034. /**
  25035. * Gets the list of animations attached to this skeleton
  25036. */
  25037. animations: Array<Animation>;
  25038. private _scene;
  25039. private _isDirty;
  25040. private _transformMatrices;
  25041. private _transformMatrixTexture;
  25042. private _meshesWithPoseMatrix;
  25043. private _animatables;
  25044. private _identity;
  25045. private _synchronizedWithMesh;
  25046. private _ranges;
  25047. private _lastAbsoluteTransformsUpdateId;
  25048. private _canUseTextureForBones;
  25049. private _uniqueId;
  25050. /** @hidden */
  25051. _numBonesWithLinkedTransformNode: number;
  25052. /** @hidden */
  25053. _hasWaitingData: Nullable<boolean>;
  25054. /** @hidden */
  25055. _waitingOverrideMeshId: Nullable<string>;
  25056. /**
  25057. * Specifies if the skeleton should be serialized
  25058. */
  25059. doNotSerialize: boolean;
  25060. private _useTextureToStoreBoneMatrices;
  25061. /**
  25062. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25063. * Please note that this option is not available if the hardware does not support it
  25064. */
  25065. get useTextureToStoreBoneMatrices(): boolean;
  25066. set useTextureToStoreBoneMatrices(value: boolean);
  25067. private _animationPropertiesOverride;
  25068. /**
  25069. * Gets or sets the animation properties override
  25070. */
  25071. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25072. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25073. /**
  25074. * List of inspectable custom properties (used by the Inspector)
  25075. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25076. */
  25077. inspectableCustomProperties: IInspectable[];
  25078. /**
  25079. * An observable triggered before computing the skeleton's matrices
  25080. */
  25081. onBeforeComputeObservable: Observable<Skeleton>;
  25082. /**
  25083. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25084. */
  25085. get isUsingTextureForMatrices(): boolean;
  25086. /**
  25087. * Gets the unique ID of this skeleton
  25088. */
  25089. get uniqueId(): number;
  25090. /**
  25091. * Creates a new skeleton
  25092. * @param name defines the skeleton name
  25093. * @param id defines the skeleton Id
  25094. * @param scene defines the hosting scene
  25095. */
  25096. constructor(
  25097. /** defines the skeleton name */
  25098. name: string,
  25099. /** defines the skeleton Id */
  25100. id: string, scene: Scene);
  25101. /**
  25102. * Gets the current object class name.
  25103. * @return the class name
  25104. */
  25105. getClassName(): string;
  25106. /**
  25107. * Returns an array containing the root bones
  25108. * @returns an array containing the root bones
  25109. */
  25110. getChildren(): Array<Bone>;
  25111. /**
  25112. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25113. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25114. * @returns a Float32Array containing matrices data
  25115. */
  25116. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25117. /**
  25118. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25119. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25120. * @returns a raw texture containing the data
  25121. */
  25122. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25123. /**
  25124. * Gets the current hosting scene
  25125. * @returns a scene object
  25126. */
  25127. getScene(): Scene;
  25128. /**
  25129. * Gets a string representing the current skeleton data
  25130. * @param fullDetails defines a boolean indicating if we want a verbose version
  25131. * @returns a string representing the current skeleton data
  25132. */
  25133. toString(fullDetails?: boolean): string;
  25134. /**
  25135. * Get bone's index searching by name
  25136. * @param name defines bone's name to search for
  25137. * @return the indice of the bone. Returns -1 if not found
  25138. */
  25139. getBoneIndexByName(name: string): number;
  25140. /**
  25141. * Creater a new animation range
  25142. * @param name defines the name of the range
  25143. * @param from defines the start key
  25144. * @param to defines the end key
  25145. */
  25146. createAnimationRange(name: string, from: number, to: number): void;
  25147. /**
  25148. * Delete a specific animation range
  25149. * @param name defines the name of the range
  25150. * @param deleteFrames defines if frames must be removed as well
  25151. */
  25152. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25153. /**
  25154. * Gets a specific animation range
  25155. * @param name defines the name of the range to look for
  25156. * @returns the requested animation range or null if not found
  25157. */
  25158. getAnimationRange(name: string): Nullable<AnimationRange>;
  25159. /**
  25160. * Gets the list of all animation ranges defined on this skeleton
  25161. * @returns an array
  25162. */
  25163. getAnimationRanges(): Nullable<AnimationRange>[];
  25164. /**
  25165. * Copy animation range from a source skeleton.
  25166. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  25167. * @param source defines the source skeleton
  25168. * @param name defines the name of the range to copy
  25169. * @param rescaleAsRequired defines if rescaling must be applied if required
  25170. * @returns true if operation was successful
  25171. */
  25172. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  25173. /**
  25174. * Forces the skeleton to go to rest pose
  25175. */
  25176. returnToRest(): void;
  25177. private _getHighestAnimationFrame;
  25178. /**
  25179. * Begin a specific animation range
  25180. * @param name defines the name of the range to start
  25181. * @param loop defines if looping must be turned on (false by default)
  25182. * @param speedRatio defines the speed ratio to apply (1 by default)
  25183. * @param onAnimationEnd defines a callback which will be called when animation will end
  25184. * @returns a new animatable
  25185. */
  25186. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25187. /**
  25188. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  25189. * @param skeleton defines the Skeleton containing the animation range to convert
  25190. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  25191. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  25192. * @returns the original skeleton
  25193. */
  25194. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  25195. /** @hidden */
  25196. _markAsDirty(): void;
  25197. /** @hidden */
  25198. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25199. /** @hidden */
  25200. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25201. private _computeTransformMatrices;
  25202. /**
  25203. * Build all resources required to render a skeleton
  25204. */
  25205. prepare(): void;
  25206. /**
  25207. * Gets the list of animatables currently running for this skeleton
  25208. * @returns an array of animatables
  25209. */
  25210. getAnimatables(): IAnimatable[];
  25211. /**
  25212. * Clone the current skeleton
  25213. * @param name defines the name of the new skeleton
  25214. * @param id defines the id of the new skeleton
  25215. * @returns the new skeleton
  25216. */
  25217. clone(name: string, id?: string): Skeleton;
  25218. /**
  25219. * Enable animation blending for this skeleton
  25220. * @param blendingSpeed defines the blending speed to apply
  25221. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25222. */
  25223. enableBlending(blendingSpeed?: number): void;
  25224. /**
  25225. * Releases all resources associated with the current skeleton
  25226. */
  25227. dispose(): void;
  25228. /**
  25229. * Serialize the skeleton in a JSON object
  25230. * @returns a JSON object
  25231. */
  25232. serialize(): any;
  25233. /**
  25234. * Creates a new skeleton from serialized data
  25235. * @param parsedSkeleton defines the serialized data
  25236. * @param scene defines the hosting scene
  25237. * @returns a new skeleton
  25238. */
  25239. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  25240. /**
  25241. * Compute all node absolute transforms
  25242. * @param forceUpdate defines if computation must be done even if cache is up to date
  25243. */
  25244. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  25245. /**
  25246. * Gets the root pose matrix
  25247. * @returns a matrix
  25248. */
  25249. getPoseMatrix(): Nullable<Matrix>;
  25250. /**
  25251. * Sorts bones per internal index
  25252. */
  25253. sortBones(): void;
  25254. private _sortBones;
  25255. /**
  25256. * Set the current local matrix as the restPose for all bones in the skeleton.
  25257. */
  25258. setCurrentPoseAsRest(): void;
  25259. }
  25260. }
  25261. declare module BABYLON {
  25262. /**
  25263. * Class used to store bone information
  25264. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25265. */
  25266. export class Bone extends Node {
  25267. /**
  25268. * defines the bone name
  25269. */
  25270. name: string;
  25271. private static _tmpVecs;
  25272. private static _tmpQuat;
  25273. private static _tmpMats;
  25274. /**
  25275. * Gets the list of child bones
  25276. */
  25277. children: Bone[];
  25278. /** Gets the animations associated with this bone */
  25279. animations: Animation[];
  25280. /**
  25281. * Gets or sets bone length
  25282. */
  25283. length: number;
  25284. /**
  25285. * @hidden Internal only
  25286. * Set this value to map this bone to a different index in the transform matrices
  25287. * Set this value to -1 to exclude the bone from the transform matrices
  25288. */
  25289. _index: Nullable<number>;
  25290. private _skeleton;
  25291. private _localMatrix;
  25292. private _restPose;
  25293. private _bindPose;
  25294. private _baseMatrix;
  25295. private _absoluteTransform;
  25296. private _invertedAbsoluteTransform;
  25297. private _parent;
  25298. private _scalingDeterminant;
  25299. private _worldTransform;
  25300. private _localScaling;
  25301. private _localRotation;
  25302. private _localPosition;
  25303. private _needToDecompose;
  25304. private _needToCompose;
  25305. /** @hidden */
  25306. _linkedTransformNode: Nullable<TransformNode>;
  25307. /** @hidden */
  25308. _waitingTransformNodeId: Nullable<string>;
  25309. /** @hidden */
  25310. get _matrix(): Matrix;
  25311. /** @hidden */
  25312. set _matrix(value: Matrix);
  25313. /**
  25314. * Create a new bone
  25315. * @param name defines the bone name
  25316. * @param skeleton defines the parent skeleton
  25317. * @param parentBone defines the parent (can be null if the bone is the root)
  25318. * @param localMatrix defines the local matrix
  25319. * @param restPose defines the rest pose matrix
  25320. * @param baseMatrix defines the base matrix
  25321. * @param index defines index of the bone in the hiearchy
  25322. */
  25323. constructor(
  25324. /**
  25325. * defines the bone name
  25326. */
  25327. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  25328. /**
  25329. * Gets the current object class name.
  25330. * @return the class name
  25331. */
  25332. getClassName(): string;
  25333. /**
  25334. * Gets the parent skeleton
  25335. * @returns a skeleton
  25336. */
  25337. getSkeleton(): Skeleton;
  25338. /**
  25339. * Gets parent bone
  25340. * @returns a bone or null if the bone is the root of the bone hierarchy
  25341. */
  25342. getParent(): Nullable<Bone>;
  25343. /**
  25344. * Returns an array containing the root bones
  25345. * @returns an array containing the root bones
  25346. */
  25347. getChildren(): Array<Bone>;
  25348. /**
  25349. * Gets the node index in matrix array generated for rendering
  25350. * @returns the node index
  25351. */
  25352. getIndex(): number;
  25353. /**
  25354. * Sets the parent bone
  25355. * @param parent defines the parent (can be null if the bone is the root)
  25356. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25357. */
  25358. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  25359. /**
  25360. * Gets the local matrix
  25361. * @returns a matrix
  25362. */
  25363. getLocalMatrix(): Matrix;
  25364. /**
  25365. * Gets the base matrix (initial matrix which remains unchanged)
  25366. * @returns a matrix
  25367. */
  25368. getBaseMatrix(): Matrix;
  25369. /**
  25370. * Gets the rest pose matrix
  25371. * @returns a matrix
  25372. */
  25373. getRestPose(): Matrix;
  25374. /**
  25375. * Sets the rest pose matrix
  25376. * @param matrix the local-space rest pose to set for this bone
  25377. */
  25378. setRestPose(matrix: Matrix): void;
  25379. /**
  25380. * Gets the bind pose matrix
  25381. * @returns the bind pose matrix
  25382. */
  25383. getBindPose(): Matrix;
  25384. /**
  25385. * Sets the bind pose matrix
  25386. * @param matrix the local-space bind pose to set for this bone
  25387. */
  25388. setBindPose(matrix: Matrix): void;
  25389. /**
  25390. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  25391. */
  25392. getWorldMatrix(): Matrix;
  25393. /**
  25394. * Sets the local matrix to rest pose matrix
  25395. */
  25396. returnToRest(): void;
  25397. /**
  25398. * Gets the inverse of the absolute transform matrix.
  25399. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  25400. * @returns a matrix
  25401. */
  25402. getInvertedAbsoluteTransform(): Matrix;
  25403. /**
  25404. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  25405. * @returns a matrix
  25406. */
  25407. getAbsoluteTransform(): Matrix;
  25408. /**
  25409. * Links with the given transform node.
  25410. * The local matrix of this bone is copied from the transform node every frame.
  25411. * @param transformNode defines the transform node to link to
  25412. */
  25413. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  25414. /**
  25415. * Gets the node used to drive the bone's transformation
  25416. * @returns a transform node or null
  25417. */
  25418. getTransformNode(): Nullable<TransformNode>;
  25419. /** Gets or sets current position (in local space) */
  25420. get position(): Vector3;
  25421. set position(newPosition: Vector3);
  25422. /** Gets or sets current rotation (in local space) */
  25423. get rotation(): Vector3;
  25424. set rotation(newRotation: Vector3);
  25425. /** Gets or sets current rotation quaternion (in local space) */
  25426. get rotationQuaternion(): Quaternion;
  25427. set rotationQuaternion(newRotation: Quaternion);
  25428. /** Gets or sets current scaling (in local space) */
  25429. get scaling(): Vector3;
  25430. set scaling(newScaling: Vector3);
  25431. /**
  25432. * Gets the animation properties override
  25433. */
  25434. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25435. private _decompose;
  25436. private _compose;
  25437. /**
  25438. * Update the base and local matrices
  25439. * @param matrix defines the new base or local matrix
  25440. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25441. * @param updateLocalMatrix defines if the local matrix should be updated
  25442. */
  25443. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  25444. /** @hidden */
  25445. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  25446. /**
  25447. * Flag the bone as dirty (Forcing it to update everything)
  25448. */
  25449. markAsDirty(): void;
  25450. /** @hidden */
  25451. _markAsDirtyAndCompose(): void;
  25452. private _markAsDirtyAndDecompose;
  25453. /**
  25454. * Translate the bone in local or world space
  25455. * @param vec The amount to translate the bone
  25456. * @param space The space that the translation is in
  25457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25458. */
  25459. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25460. /**
  25461. * Set the postion of the bone in local or world space
  25462. * @param position The position to set the bone
  25463. * @param space The space that the position is in
  25464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25465. */
  25466. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25467. /**
  25468. * Set the absolute position of the bone (world space)
  25469. * @param position The position to set the bone
  25470. * @param mesh The mesh that this bone is attached to
  25471. */
  25472. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  25473. /**
  25474. * Scale the bone on the x, y and z axes (in local space)
  25475. * @param x The amount to scale the bone on the x axis
  25476. * @param y The amount to scale the bone on the y axis
  25477. * @param z The amount to scale the bone on the z axis
  25478. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  25479. */
  25480. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  25481. /**
  25482. * Set the bone scaling in local space
  25483. * @param scale defines the scaling vector
  25484. */
  25485. setScale(scale: Vector3): void;
  25486. /**
  25487. * Gets the current scaling in local space
  25488. * @returns the current scaling vector
  25489. */
  25490. getScale(): Vector3;
  25491. /**
  25492. * Gets the current scaling in local space and stores it in a target vector
  25493. * @param result defines the target vector
  25494. */
  25495. getScaleToRef(result: Vector3): void;
  25496. /**
  25497. * Set the yaw, pitch, and roll of the bone in local or world space
  25498. * @param yaw The rotation of the bone on the y axis
  25499. * @param pitch The rotation of the bone on the x axis
  25500. * @param roll The rotation of the bone on the z axis
  25501. * @param space The space that the axes of rotation are in
  25502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25503. */
  25504. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  25505. /**
  25506. * Add a rotation to the bone on an axis in local or world space
  25507. * @param axis The axis to rotate the bone on
  25508. * @param amount The amount to rotate the bone
  25509. * @param space The space that the axis is in
  25510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25511. */
  25512. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  25513. /**
  25514. * Set the rotation of the bone to a particular axis angle in local or world space
  25515. * @param axis The axis to rotate the bone on
  25516. * @param angle The angle that the bone should be rotated to
  25517. * @param space The space that the axis is in
  25518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25519. */
  25520. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  25521. /**
  25522. * Set the euler rotation of the bone in local or world space
  25523. * @param rotation The euler rotation that the bone should be set to
  25524. * @param space The space that the rotation is in
  25525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25526. */
  25527. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25528. /**
  25529. * Set the quaternion rotation of the bone in local or world space
  25530. * @param quat The quaternion rotation that the bone should be set to
  25531. * @param space The space that the rotation is in
  25532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25533. */
  25534. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  25535. /**
  25536. * Set the rotation matrix of the bone in local or world space
  25537. * @param rotMat The rotation matrix that the bone should be set to
  25538. * @param space The space that the rotation is in
  25539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25540. */
  25541. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  25542. private _rotateWithMatrix;
  25543. private _getNegativeRotationToRef;
  25544. /**
  25545. * Get the position of the bone in local or world space
  25546. * @param space The space that the returned position is in
  25547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25548. * @returns The position of the bone
  25549. */
  25550. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25551. /**
  25552. * Copy the position of the bone to a vector3 in local or world space
  25553. * @param space The space that the returned position is in
  25554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25555. * @param result The vector3 to copy the position to
  25556. */
  25557. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  25558. /**
  25559. * Get the absolute position of the bone (world space)
  25560. * @param mesh The mesh that this bone is attached to
  25561. * @returns The absolute position of the bone
  25562. */
  25563. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  25564. /**
  25565. * Copy the absolute position of the bone (world space) to the result param
  25566. * @param mesh The mesh that this bone is attached to
  25567. * @param result The vector3 to copy the absolute position to
  25568. */
  25569. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  25570. /**
  25571. * Compute the absolute transforms of this bone and its children
  25572. */
  25573. computeAbsoluteTransforms(): void;
  25574. /**
  25575. * Get the world direction from an axis that is in the local space of the bone
  25576. * @param localAxis The local direction that is used to compute the world direction
  25577. * @param mesh The mesh that this bone is attached to
  25578. * @returns The world direction
  25579. */
  25580. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25581. /**
  25582. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  25583. * @param localAxis The local direction that is used to compute the world direction
  25584. * @param mesh The mesh that this bone is attached to
  25585. * @param result The vector3 that the world direction will be copied to
  25586. */
  25587. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25588. /**
  25589. * Get the euler rotation of the bone in local or world space
  25590. * @param space The space that the rotation should be in
  25591. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25592. * @returns The euler rotation
  25593. */
  25594. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25595. /**
  25596. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  25597. * @param space The space that the rotation should be in
  25598. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25599. * @param result The vector3 that the rotation should be copied to
  25600. */
  25601. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25602. /**
  25603. * Get the quaternion rotation of the bone in either local or world space
  25604. * @param space The space that the rotation should be in
  25605. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25606. * @returns The quaternion rotation
  25607. */
  25608. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  25609. /**
  25610. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  25611. * @param space The space that the rotation should be in
  25612. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25613. * @param result The quaternion that the rotation should be copied to
  25614. */
  25615. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  25616. /**
  25617. * Get the rotation matrix of the bone in local or world space
  25618. * @param space The space that the rotation should be in
  25619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25620. * @returns The rotation matrix
  25621. */
  25622. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  25623. /**
  25624. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  25625. * @param space The space that the rotation should be in
  25626. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25627. * @param result The quaternion that the rotation should be copied to
  25628. */
  25629. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  25630. /**
  25631. * Get the world position of a point that is in the local space of the bone
  25632. * @param position The local position
  25633. * @param mesh The mesh that this bone is attached to
  25634. * @returns The world position
  25635. */
  25636. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25637. /**
  25638. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  25639. * @param position The local position
  25640. * @param mesh The mesh that this bone is attached to
  25641. * @param result The vector3 that the world position should be copied to
  25642. */
  25643. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25644. /**
  25645. * Get the local position of a point that is in world space
  25646. * @param position The world position
  25647. * @param mesh The mesh that this bone is attached to
  25648. * @returns The local position
  25649. */
  25650. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25651. /**
  25652. * Get the local position of a point that is in world space and copy it to the result param
  25653. * @param position The world position
  25654. * @param mesh The mesh that this bone is attached to
  25655. * @param result The vector3 that the local position should be copied to
  25656. */
  25657. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25658. /**
  25659. * Set the current local matrix as the restPose for this bone.
  25660. */
  25661. setCurrentPoseAsRest(): void;
  25662. }
  25663. }
  25664. declare module BABYLON {
  25665. /**
  25666. * 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.
  25667. * @see https://doc.babylonjs.com/how_to/transformnode
  25668. */
  25669. export class TransformNode extends Node {
  25670. /**
  25671. * Object will not rotate to face the camera
  25672. */
  25673. static BILLBOARDMODE_NONE: number;
  25674. /**
  25675. * Object will rotate to face the camera but only on the x axis
  25676. */
  25677. static BILLBOARDMODE_X: number;
  25678. /**
  25679. * Object will rotate to face the camera but only on the y axis
  25680. */
  25681. static BILLBOARDMODE_Y: number;
  25682. /**
  25683. * Object will rotate to face the camera but only on the z axis
  25684. */
  25685. static BILLBOARDMODE_Z: number;
  25686. /**
  25687. * Object will rotate to face the camera
  25688. */
  25689. static BILLBOARDMODE_ALL: number;
  25690. /**
  25691. * Object will rotate to face the camera's position instead of orientation
  25692. */
  25693. static BILLBOARDMODE_USE_POSITION: number;
  25694. private static _TmpRotation;
  25695. private static _TmpScaling;
  25696. private static _TmpTranslation;
  25697. private _forward;
  25698. private _forwardInverted;
  25699. private _up;
  25700. private _right;
  25701. private _rightInverted;
  25702. private _position;
  25703. private _rotation;
  25704. private _rotationQuaternion;
  25705. protected _scaling: Vector3;
  25706. protected _isDirty: boolean;
  25707. private _transformToBoneReferal;
  25708. private _isAbsoluteSynced;
  25709. private _billboardMode;
  25710. /**
  25711. * Gets or sets the billboard mode. Default is 0.
  25712. *
  25713. * | Value | Type | Description |
  25714. * | --- | --- | --- |
  25715. * | 0 | BILLBOARDMODE_NONE | |
  25716. * | 1 | BILLBOARDMODE_X | |
  25717. * | 2 | BILLBOARDMODE_Y | |
  25718. * | 4 | BILLBOARDMODE_Z | |
  25719. * | 7 | BILLBOARDMODE_ALL | |
  25720. *
  25721. */
  25722. get billboardMode(): number;
  25723. set billboardMode(value: number);
  25724. private _preserveParentRotationForBillboard;
  25725. /**
  25726. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  25727. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  25728. */
  25729. get preserveParentRotationForBillboard(): boolean;
  25730. set preserveParentRotationForBillboard(value: boolean);
  25731. /**
  25732. * 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
  25733. */
  25734. scalingDeterminant: number;
  25735. private _infiniteDistance;
  25736. /**
  25737. * Gets or sets the distance of the object to max, often used by skybox
  25738. */
  25739. get infiniteDistance(): boolean;
  25740. set infiniteDistance(value: boolean);
  25741. /**
  25742. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  25743. * By default the system will update normals to compensate
  25744. */
  25745. ignoreNonUniformScaling: boolean;
  25746. /**
  25747. * 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
  25748. */
  25749. reIntegrateRotationIntoRotationQuaternion: boolean;
  25750. /** @hidden */
  25751. _poseMatrix: Nullable<Matrix>;
  25752. /** @hidden */
  25753. _localMatrix: Matrix;
  25754. private _usePivotMatrix;
  25755. private _absolutePosition;
  25756. private _absoluteScaling;
  25757. private _absoluteRotationQuaternion;
  25758. private _pivotMatrix;
  25759. private _pivotMatrixInverse;
  25760. /** @hidden */
  25761. _postMultiplyPivotMatrix: boolean;
  25762. protected _isWorldMatrixFrozen: boolean;
  25763. /** @hidden */
  25764. _indexInSceneTransformNodesArray: number;
  25765. /**
  25766. * An event triggered after the world matrix is updated
  25767. */
  25768. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  25769. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  25770. /**
  25771. * Gets a string identifying the name of the class
  25772. * @returns "TransformNode" string
  25773. */
  25774. getClassName(): string;
  25775. /**
  25776. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  25777. */
  25778. get position(): Vector3;
  25779. set position(newPosition: Vector3);
  25780. /**
  25781. * 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)).
  25782. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  25783. */
  25784. get rotation(): Vector3;
  25785. set rotation(newRotation: Vector3);
  25786. /**
  25787. * 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)).
  25788. */
  25789. get scaling(): Vector3;
  25790. set scaling(newScaling: Vector3);
  25791. /**
  25792. * 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).
  25793. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  25794. */
  25795. get rotationQuaternion(): Nullable<Quaternion>;
  25796. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  25797. /**
  25798. * The forward direction of that transform in world space.
  25799. */
  25800. get forward(): Vector3;
  25801. /**
  25802. * The up direction of that transform in world space.
  25803. */
  25804. get up(): Vector3;
  25805. /**
  25806. * The right direction of that transform in world space.
  25807. */
  25808. get right(): Vector3;
  25809. /**
  25810. * Copies the parameter passed Matrix into the mesh Pose matrix.
  25811. * @param matrix the matrix to copy the pose from
  25812. * @returns this TransformNode.
  25813. */
  25814. updatePoseMatrix(matrix: Matrix): TransformNode;
  25815. /**
  25816. * Returns the mesh Pose matrix.
  25817. * @returns the pose matrix
  25818. */
  25819. getPoseMatrix(): Matrix;
  25820. /** @hidden */
  25821. _isSynchronized(): boolean;
  25822. /** @hidden */
  25823. _initCache(): void;
  25824. /**
  25825. * Flag the transform node as dirty (Forcing it to update everything)
  25826. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  25827. * @returns this transform node
  25828. */
  25829. markAsDirty(property: string): TransformNode;
  25830. /**
  25831. * Returns the current mesh absolute position.
  25832. * Returns a Vector3.
  25833. */
  25834. get absolutePosition(): Vector3;
  25835. /**
  25836. * Returns the current mesh absolute scaling.
  25837. * Returns a Vector3.
  25838. */
  25839. get absoluteScaling(): Vector3;
  25840. /**
  25841. * Returns the current mesh absolute rotation.
  25842. * Returns a Quaternion.
  25843. */
  25844. get absoluteRotationQuaternion(): Quaternion;
  25845. /**
  25846. * Sets a new matrix to apply before all other transformation
  25847. * @param matrix defines the transform matrix
  25848. * @returns the current TransformNode
  25849. */
  25850. setPreTransformMatrix(matrix: Matrix): TransformNode;
  25851. /**
  25852. * Sets a new pivot matrix to the current node
  25853. * @param matrix defines the new pivot matrix to use
  25854. * @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
  25855. * @returns the current TransformNode
  25856. */
  25857. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  25858. /**
  25859. * Returns the mesh pivot matrix.
  25860. * Default : Identity.
  25861. * @returns the matrix
  25862. */
  25863. getPivotMatrix(): Matrix;
  25864. /**
  25865. * Instantiate (when possible) or clone that node with its hierarchy
  25866. * @param newParent defines the new parent to use for the instance (or clone)
  25867. * @param options defines options to configure how copy is done
  25868. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  25869. * @returns an instance (or a clone) of the current node with its hiearchy
  25870. */
  25871. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25872. doNotInstantiate: boolean;
  25873. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25874. /**
  25875. * Prevents the World matrix to be computed any longer
  25876. * @param newWorldMatrix defines an optional matrix to use as world matrix
  25877. * @returns the TransformNode.
  25878. */
  25879. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  25880. /**
  25881. * Allows back the World matrix computation.
  25882. * @returns the TransformNode.
  25883. */
  25884. unfreezeWorldMatrix(): this;
  25885. /**
  25886. * True if the World matrix has been frozen.
  25887. */
  25888. get isWorldMatrixFrozen(): boolean;
  25889. /**
  25890. * Retuns the mesh absolute position in the World.
  25891. * @returns a Vector3.
  25892. */
  25893. getAbsolutePosition(): Vector3;
  25894. /**
  25895. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  25896. * @param absolutePosition the absolute position to set
  25897. * @returns the TransformNode.
  25898. */
  25899. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  25900. /**
  25901. * Sets the mesh position in its local space.
  25902. * @param vector3 the position to set in localspace
  25903. * @returns the TransformNode.
  25904. */
  25905. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  25906. /**
  25907. * Returns the mesh position in the local space from the current World matrix values.
  25908. * @returns a new Vector3.
  25909. */
  25910. getPositionExpressedInLocalSpace(): Vector3;
  25911. /**
  25912. * Translates the mesh along the passed Vector3 in its local space.
  25913. * @param vector3 the distance to translate in localspace
  25914. * @returns the TransformNode.
  25915. */
  25916. locallyTranslate(vector3: Vector3): TransformNode;
  25917. private static _lookAtVectorCache;
  25918. /**
  25919. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  25920. * @param targetPoint the position (must be in same space as current mesh) to look at
  25921. * @param yawCor optional yaw (y-axis) correction in radians
  25922. * @param pitchCor optional pitch (x-axis) correction in radians
  25923. * @param rollCor optional roll (z-axis) correction in radians
  25924. * @param space the choosen space of the target
  25925. * @returns the TransformNode.
  25926. */
  25927. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  25928. /**
  25929. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  25930. * This Vector3 is expressed in the World space.
  25931. * @param localAxis axis to rotate
  25932. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  25933. */
  25934. getDirection(localAxis: Vector3): Vector3;
  25935. /**
  25936. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  25937. * localAxis is expressed in the mesh local space.
  25938. * result is computed in the Wordl space from the mesh World matrix.
  25939. * @param localAxis axis to rotate
  25940. * @param result the resulting transformnode
  25941. * @returns this TransformNode.
  25942. */
  25943. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  25944. /**
  25945. * Sets this transform node rotation to the given local axis.
  25946. * @param localAxis the axis in local space
  25947. * @param yawCor optional yaw (y-axis) correction in radians
  25948. * @param pitchCor optional pitch (x-axis) correction in radians
  25949. * @param rollCor optional roll (z-axis) correction in radians
  25950. * @returns this TransformNode
  25951. */
  25952. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  25953. /**
  25954. * Sets a new pivot point to the current node
  25955. * @param point defines the new pivot point to use
  25956. * @param space defines if the point is in world or local space (local by default)
  25957. * @returns the current TransformNode
  25958. */
  25959. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  25960. /**
  25961. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  25962. * @returns the pivot point
  25963. */
  25964. getPivotPoint(): Vector3;
  25965. /**
  25966. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  25967. * @param result the vector3 to store the result
  25968. * @returns this TransformNode.
  25969. */
  25970. getPivotPointToRef(result: Vector3): TransformNode;
  25971. /**
  25972. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  25973. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  25974. */
  25975. getAbsolutePivotPoint(): Vector3;
  25976. /**
  25977. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  25978. * @param result vector3 to store the result
  25979. * @returns this TransformNode.
  25980. */
  25981. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  25982. /**
  25983. * Defines the passed node as the parent of the current node.
  25984. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  25985. * @see https://doc.babylonjs.com/how_to/parenting
  25986. * @param node the node ot set as the parent
  25987. * @returns this TransformNode.
  25988. */
  25989. setParent(node: Nullable<Node>): TransformNode;
  25990. private _nonUniformScaling;
  25991. /**
  25992. * True if the scaling property of this object is non uniform eg. (1,2,1)
  25993. */
  25994. get nonUniformScaling(): boolean;
  25995. /** @hidden */
  25996. _updateNonUniformScalingState(value: boolean): boolean;
  25997. /**
  25998. * Attach the current TransformNode to another TransformNode associated with a bone
  25999. * @param bone Bone affecting the TransformNode
  26000. * @param affectedTransformNode TransformNode associated with the bone
  26001. * @returns this object
  26002. */
  26003. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26004. /**
  26005. * Detach the transform node if its associated with a bone
  26006. * @returns this object
  26007. */
  26008. detachFromBone(): TransformNode;
  26009. private static _rotationAxisCache;
  26010. /**
  26011. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26012. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26013. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26014. * The passed axis is also normalized.
  26015. * @param axis the axis to rotate around
  26016. * @param amount the amount to rotate in radians
  26017. * @param space Space to rotate in (Default: local)
  26018. * @returns the TransformNode.
  26019. */
  26020. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26021. /**
  26022. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26023. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26024. * The passed axis is also normalized. .
  26025. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26026. * @param point the point to rotate around
  26027. * @param axis the axis to rotate around
  26028. * @param amount the amount to rotate in radians
  26029. * @returns the TransformNode
  26030. */
  26031. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26032. /**
  26033. * Translates the mesh along the axis vector for the passed distance in the given space.
  26034. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26035. * @param axis the axis to translate in
  26036. * @param distance the distance to translate
  26037. * @param space Space to rotate in (Default: local)
  26038. * @returns the TransformNode.
  26039. */
  26040. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26041. /**
  26042. * Adds a rotation step to the mesh current rotation.
  26043. * x, y, z are Euler angles expressed in radians.
  26044. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26045. * This means this rotation is made in the mesh local space only.
  26046. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26047. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26048. * ```javascript
  26049. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26050. * ```
  26051. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26052. * 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.
  26053. * @param x Rotation to add
  26054. * @param y Rotation to add
  26055. * @param z Rotation to add
  26056. * @returns the TransformNode.
  26057. */
  26058. addRotation(x: number, y: number, z: number): TransformNode;
  26059. /**
  26060. * @hidden
  26061. */
  26062. protected _getEffectiveParent(): Nullable<Node>;
  26063. /**
  26064. * Computes the world matrix of the node
  26065. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26066. * @returns the world matrix
  26067. */
  26068. computeWorldMatrix(force?: boolean): Matrix;
  26069. /**
  26070. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26071. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26072. */
  26073. resetLocalMatrix(independentOfChildren?: boolean): void;
  26074. protected _afterComputeWorldMatrix(): void;
  26075. /**
  26076. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26077. * @param func callback function to add
  26078. *
  26079. * @returns the TransformNode.
  26080. */
  26081. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26082. /**
  26083. * Removes a registered callback function.
  26084. * @param func callback function to remove
  26085. * @returns the TransformNode.
  26086. */
  26087. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26088. /**
  26089. * Gets the position of the current mesh in camera space
  26090. * @param camera defines the camera to use
  26091. * @returns a position
  26092. */
  26093. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26094. /**
  26095. * Returns the distance from the mesh to the active camera
  26096. * @param camera defines the camera to use
  26097. * @returns the distance
  26098. */
  26099. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26100. /**
  26101. * Clone the current transform node
  26102. * @param name Name of the new clone
  26103. * @param newParent New parent for the clone
  26104. * @param doNotCloneChildren Do not clone children hierarchy
  26105. * @returns the new transform node
  26106. */
  26107. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26108. /**
  26109. * Serializes the objects information.
  26110. * @param currentSerializationObject defines the object to serialize in
  26111. * @returns the serialized object
  26112. */
  26113. serialize(currentSerializationObject?: any): any;
  26114. /**
  26115. * Returns a new TransformNode object parsed from the source provided.
  26116. * @param parsedTransformNode is the source.
  26117. * @param scene the scne the object belongs to
  26118. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26119. * @returns a new TransformNode object parsed from the source provided.
  26120. */
  26121. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26122. /**
  26123. * Get all child-transformNodes of this node
  26124. * @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
  26125. * @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
  26126. * @returns an array of TransformNode
  26127. */
  26128. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26129. /**
  26130. * Releases resources associated with this transform node.
  26131. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26132. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26133. */
  26134. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26135. /**
  26136. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26137. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26138. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26139. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26140. * @returns the current mesh
  26141. */
  26142. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  26143. private _syncAbsoluteScalingAndRotation;
  26144. }
  26145. }
  26146. declare module BABYLON {
  26147. /**
  26148. * Defines the types of pose enabled controllers that are supported
  26149. */
  26150. export enum PoseEnabledControllerType {
  26151. /**
  26152. * HTC Vive
  26153. */
  26154. VIVE = 0,
  26155. /**
  26156. * Oculus Rift
  26157. */
  26158. OCULUS = 1,
  26159. /**
  26160. * Windows mixed reality
  26161. */
  26162. WINDOWS = 2,
  26163. /**
  26164. * Samsung gear VR
  26165. */
  26166. GEAR_VR = 3,
  26167. /**
  26168. * Google Daydream
  26169. */
  26170. DAYDREAM = 4,
  26171. /**
  26172. * Generic
  26173. */
  26174. GENERIC = 5
  26175. }
  26176. /**
  26177. * Defines the MutableGamepadButton interface for the state of a gamepad button
  26178. */
  26179. export interface MutableGamepadButton {
  26180. /**
  26181. * Value of the button/trigger
  26182. */
  26183. value: number;
  26184. /**
  26185. * If the button/trigger is currently touched
  26186. */
  26187. touched: boolean;
  26188. /**
  26189. * If the button/trigger is currently pressed
  26190. */
  26191. pressed: boolean;
  26192. }
  26193. /**
  26194. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  26195. * @hidden
  26196. */
  26197. export interface ExtendedGamepadButton extends GamepadButton {
  26198. /**
  26199. * If the button/trigger is currently pressed
  26200. */
  26201. readonly pressed: boolean;
  26202. /**
  26203. * If the button/trigger is currently touched
  26204. */
  26205. readonly touched: boolean;
  26206. /**
  26207. * Value of the button/trigger
  26208. */
  26209. readonly value: number;
  26210. }
  26211. /** @hidden */
  26212. export interface _GamePadFactory {
  26213. /**
  26214. * Returns whether or not the current gamepad can be created for this type of controller.
  26215. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26216. * @returns true if it can be created, otherwise false
  26217. */
  26218. canCreate(gamepadInfo: any): boolean;
  26219. /**
  26220. * Creates a new instance of the Gamepad.
  26221. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26222. * @returns the new gamepad instance
  26223. */
  26224. create(gamepadInfo: any): Gamepad;
  26225. }
  26226. /**
  26227. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26228. */
  26229. export class PoseEnabledControllerHelper {
  26230. /** @hidden */
  26231. static _ControllerFactories: _GamePadFactory[];
  26232. /** @hidden */
  26233. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  26234. /**
  26235. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26236. * @param vrGamepad the gamepad to initialized
  26237. * @returns a vr controller of the type the gamepad identified as
  26238. */
  26239. static InitiateController(vrGamepad: any): Gamepad;
  26240. }
  26241. /**
  26242. * Defines the PoseEnabledController object that contains state of a vr capable controller
  26243. */
  26244. export class PoseEnabledController extends Gamepad implements PoseControlled {
  26245. /**
  26246. * If the controller is used in a webXR session
  26247. */
  26248. isXR: boolean;
  26249. private _deviceRoomPosition;
  26250. private _deviceRoomRotationQuaternion;
  26251. /**
  26252. * The device position in babylon space
  26253. */
  26254. devicePosition: Vector3;
  26255. /**
  26256. * The device rotation in babylon space
  26257. */
  26258. deviceRotationQuaternion: Quaternion;
  26259. /**
  26260. * The scale factor of the device in babylon space
  26261. */
  26262. deviceScaleFactor: number;
  26263. /**
  26264. * (Likely devicePosition should be used instead) The device position in its room space
  26265. */
  26266. position: Vector3;
  26267. /**
  26268. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  26269. */
  26270. rotationQuaternion: Quaternion;
  26271. /**
  26272. * The type of controller (Eg. Windows mixed reality)
  26273. */
  26274. controllerType: PoseEnabledControllerType;
  26275. protected _calculatedPosition: Vector3;
  26276. private _calculatedRotation;
  26277. /**
  26278. * The raw pose from the device
  26279. */
  26280. rawPose: DevicePose;
  26281. private _trackPosition;
  26282. private _maxRotationDistFromHeadset;
  26283. private _draggedRoomRotation;
  26284. /**
  26285. * @hidden
  26286. */
  26287. _disableTrackPosition(fixedPosition: Vector3): void;
  26288. /**
  26289. * Internal, the mesh attached to the controller
  26290. * @hidden
  26291. */
  26292. _mesh: Nullable<AbstractMesh>;
  26293. private _poseControlledCamera;
  26294. private _leftHandSystemQuaternion;
  26295. /**
  26296. * Internal, matrix used to convert room space to babylon space
  26297. * @hidden
  26298. */
  26299. _deviceToWorld: Matrix;
  26300. /**
  26301. * Node to be used when casting a ray from the controller
  26302. * @hidden
  26303. */
  26304. _pointingPoseNode: Nullable<TransformNode>;
  26305. /**
  26306. * Name of the child mesh that can be used to cast a ray from the controller
  26307. */
  26308. static readonly POINTING_POSE: string;
  26309. /**
  26310. * Creates a new PoseEnabledController from a gamepad
  26311. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  26312. */
  26313. constructor(browserGamepad: any);
  26314. private _workingMatrix;
  26315. /**
  26316. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  26317. */
  26318. update(): void;
  26319. /**
  26320. * Updates only the pose device and mesh without doing any button event checking
  26321. */
  26322. protected _updatePoseAndMesh(): void;
  26323. /**
  26324. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  26325. * @param poseData raw pose fromthe device
  26326. */
  26327. updateFromDevice(poseData: DevicePose): void;
  26328. /**
  26329. * @hidden
  26330. */
  26331. _meshAttachedObservable: Observable<AbstractMesh>;
  26332. /**
  26333. * Attaches a mesh to the controller
  26334. * @param mesh the mesh to be attached
  26335. */
  26336. attachToMesh(mesh: AbstractMesh): void;
  26337. /**
  26338. * Attaches the controllers mesh to a camera
  26339. * @param camera the camera the mesh should be attached to
  26340. */
  26341. attachToPoseControlledCamera(camera: TargetCamera): void;
  26342. /**
  26343. * Disposes of the controller
  26344. */
  26345. dispose(): void;
  26346. /**
  26347. * The mesh that is attached to the controller
  26348. */
  26349. get mesh(): Nullable<AbstractMesh>;
  26350. /**
  26351. * Gets the ray of the controller in the direction the controller is pointing
  26352. * @param length the length the resulting ray should be
  26353. * @returns a ray in the direction the controller is pointing
  26354. */
  26355. getForwardRay(length?: number): Ray;
  26356. }
  26357. }
  26358. declare module BABYLON {
  26359. /**
  26360. * Defines the WebVRController object that represents controllers tracked in 3D space
  26361. */
  26362. export abstract class WebVRController extends PoseEnabledController {
  26363. /**
  26364. * Internal, the default controller model for the controller
  26365. */
  26366. protected _defaultModel: Nullable<AbstractMesh>;
  26367. /**
  26368. * Fired when the trigger state has changed
  26369. */
  26370. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  26371. /**
  26372. * Fired when the main button state has changed
  26373. */
  26374. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26375. /**
  26376. * Fired when the secondary button state has changed
  26377. */
  26378. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26379. /**
  26380. * Fired when the pad state has changed
  26381. */
  26382. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  26383. /**
  26384. * Fired when controllers stick values have changed
  26385. */
  26386. onPadValuesChangedObservable: Observable<StickValues>;
  26387. /**
  26388. * Array of button availible on the controller
  26389. */
  26390. protected _buttons: Array<MutableGamepadButton>;
  26391. private _onButtonStateChange;
  26392. /**
  26393. * Fired when a controller button's state has changed
  26394. * @param callback the callback containing the button that was modified
  26395. */
  26396. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  26397. /**
  26398. * X and Y axis corresponding to the controllers joystick
  26399. */
  26400. pad: StickValues;
  26401. /**
  26402. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  26403. */
  26404. hand: string;
  26405. /**
  26406. * The default controller model for the controller
  26407. */
  26408. get defaultModel(): Nullable<AbstractMesh>;
  26409. /**
  26410. * Creates a new WebVRController from a gamepad
  26411. * @param vrGamepad the gamepad that the WebVRController should be created from
  26412. */
  26413. constructor(vrGamepad: any);
  26414. /**
  26415. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  26416. */
  26417. update(): void;
  26418. /**
  26419. * Function to be called when a button is modified
  26420. */
  26421. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26422. /**
  26423. * Loads a mesh and attaches it to the controller
  26424. * @param scene the scene the mesh should be added to
  26425. * @param meshLoaded callback for when the mesh has been loaded
  26426. */
  26427. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26428. private _setButtonValue;
  26429. private _changes;
  26430. private _checkChanges;
  26431. /**
  26432. * Disposes of th webVRCOntroller
  26433. */
  26434. dispose(): void;
  26435. }
  26436. }
  26437. declare module BABYLON {
  26438. /**
  26439. * The HemisphericLight simulates the ambient environment light,
  26440. * so the passed direction is the light reflection direction, not the incoming direction.
  26441. */
  26442. export class HemisphericLight extends Light {
  26443. /**
  26444. * The groundColor is the light in the opposite direction to the one specified during creation.
  26445. * 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.
  26446. */
  26447. groundColor: Color3;
  26448. /**
  26449. * The light reflection direction, not the incoming direction.
  26450. */
  26451. direction: Vector3;
  26452. /**
  26453. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  26454. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  26455. * The HemisphericLight can't cast shadows.
  26456. * Documentation : https://doc.babylonjs.com/babylon101/lights
  26457. * @param name The friendly name of the light
  26458. * @param direction The direction of the light reflection
  26459. * @param scene The scene the light belongs to
  26460. */
  26461. constructor(name: string, direction: Vector3, scene: Scene);
  26462. protected _buildUniformLayout(): void;
  26463. /**
  26464. * Returns the string "HemisphericLight".
  26465. * @return The class name
  26466. */
  26467. getClassName(): string;
  26468. /**
  26469. * Sets the HemisphericLight direction towards the passed target (Vector3).
  26470. * Returns the updated direction.
  26471. * @param target The target the direction should point to
  26472. * @return The computed direction
  26473. */
  26474. setDirectionToTarget(target: Vector3): Vector3;
  26475. /**
  26476. * Returns the shadow generator associated to the light.
  26477. * @returns Always null for hemispheric lights because it does not support shadows.
  26478. */
  26479. getShadowGenerator(): Nullable<IShadowGenerator>;
  26480. /**
  26481. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  26482. * @param effect The effect to update
  26483. * @param lightIndex The index of the light in the effect to update
  26484. * @returns The hemispheric light
  26485. */
  26486. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  26487. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  26488. /**
  26489. * Computes the world matrix of the node
  26490. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26491. * @param useWasUpdatedFlag defines a reserved property
  26492. * @returns the world matrix
  26493. */
  26494. computeWorldMatrix(): Matrix;
  26495. /**
  26496. * Returns the integer 3.
  26497. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  26498. */
  26499. getTypeID(): number;
  26500. /**
  26501. * Prepares the list of defines specific to the light type.
  26502. * @param defines the list of defines
  26503. * @param lightIndex defines the index of the light for the effect
  26504. */
  26505. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  26506. }
  26507. }
  26508. declare module BABYLON {
  26509. /** @hidden */
  26510. export var vrMultiviewToSingleviewPixelShader: {
  26511. name: string;
  26512. shader: string;
  26513. };
  26514. }
  26515. declare module BABYLON {
  26516. /**
  26517. * Renders to multiple views with a single draw call
  26518. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  26519. */
  26520. export class MultiviewRenderTarget extends RenderTargetTexture {
  26521. /**
  26522. * Creates a multiview render target
  26523. * @param scene scene used with the render target
  26524. * @param size the size of the render target (used for each view)
  26525. */
  26526. constructor(scene: Scene, size?: number | {
  26527. width: number;
  26528. height: number;
  26529. } | {
  26530. ratio: number;
  26531. });
  26532. /**
  26533. * @hidden
  26534. * @param faceIndex the face index, if its a cube texture
  26535. */
  26536. _bindFrameBuffer(faceIndex?: number): void;
  26537. /**
  26538. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  26539. * @returns the view count
  26540. */
  26541. getViewCount(): number;
  26542. }
  26543. }
  26544. declare module BABYLON {
  26545. interface Engine {
  26546. /**
  26547. * Creates a new multiview render target
  26548. * @param width defines the width of the texture
  26549. * @param height defines the height of the texture
  26550. * @returns the created multiview texture
  26551. */
  26552. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  26553. /**
  26554. * Binds a multiview framebuffer to be drawn to
  26555. * @param multiviewTexture texture to bind
  26556. */
  26557. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  26558. }
  26559. interface Camera {
  26560. /**
  26561. * @hidden
  26562. * 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)
  26563. */
  26564. _useMultiviewToSingleView: boolean;
  26565. /**
  26566. * @hidden
  26567. * 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)
  26568. */
  26569. _multiviewTexture: Nullable<RenderTargetTexture>;
  26570. /**
  26571. * @hidden
  26572. * ensures the multiview texture of the camera exists and has the specified width/height
  26573. * @param width height to set on the multiview texture
  26574. * @param height width to set on the multiview texture
  26575. */
  26576. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  26577. }
  26578. interface Scene {
  26579. /** @hidden */
  26580. _transformMatrixR: Matrix;
  26581. /** @hidden */
  26582. _multiviewSceneUbo: Nullable<UniformBuffer>;
  26583. /** @hidden */
  26584. _createMultiviewUbo(): void;
  26585. /** @hidden */
  26586. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  26587. /** @hidden */
  26588. _renderMultiviewToSingleView(camera: Camera): void;
  26589. }
  26590. }
  26591. declare module BABYLON {
  26592. /**
  26593. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  26594. * This will not be used for webXR as it supports displaying texture arrays directly
  26595. */
  26596. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  26597. /**
  26598. * Gets a string identifying the name of the class
  26599. * @returns "VRMultiviewToSingleviewPostProcess" string
  26600. */
  26601. getClassName(): string;
  26602. /**
  26603. * Initializes a VRMultiviewToSingleview
  26604. * @param name name of the post process
  26605. * @param camera camera to be applied to
  26606. * @param scaleFactor scaling factor to the size of the output texture
  26607. */
  26608. constructor(name: string, camera: Camera, scaleFactor: number);
  26609. }
  26610. }
  26611. declare module BABYLON {
  26612. /**
  26613. * Interface used to define additional presentation attributes
  26614. */
  26615. export interface IVRPresentationAttributes {
  26616. /**
  26617. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  26618. */
  26619. highRefreshRate: boolean;
  26620. /**
  26621. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  26622. */
  26623. foveationLevel: number;
  26624. }
  26625. interface Engine {
  26626. /** @hidden */
  26627. _vrDisplay: any;
  26628. /** @hidden */
  26629. _vrSupported: boolean;
  26630. /** @hidden */
  26631. _oldSize: Size;
  26632. /** @hidden */
  26633. _oldHardwareScaleFactor: number;
  26634. /** @hidden */
  26635. _vrExclusivePointerMode: boolean;
  26636. /** @hidden */
  26637. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  26638. /** @hidden */
  26639. _onVRDisplayPointerRestricted: () => void;
  26640. /** @hidden */
  26641. _onVRDisplayPointerUnrestricted: () => void;
  26642. /** @hidden */
  26643. _onVrDisplayConnect: Nullable<(display: any) => void>;
  26644. /** @hidden */
  26645. _onVrDisplayDisconnect: Nullable<() => void>;
  26646. /** @hidden */
  26647. _onVrDisplayPresentChange: Nullable<() => void>;
  26648. /**
  26649. * Observable signaled when VR display mode changes
  26650. */
  26651. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26652. /**
  26653. * Observable signaled when VR request present is complete
  26654. */
  26655. onVRRequestPresentComplete: Observable<boolean>;
  26656. /**
  26657. * Observable signaled when VR request present starts
  26658. */
  26659. onVRRequestPresentStart: Observable<Engine>;
  26660. /**
  26661. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26662. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26663. */
  26664. isInVRExclusivePointerMode: boolean;
  26665. /**
  26666. * Gets a boolean indicating if a webVR device was detected
  26667. * @returns true if a webVR device was detected
  26668. */
  26669. isVRDevicePresent(): boolean;
  26670. /**
  26671. * Gets the current webVR device
  26672. * @returns the current webVR device (or null)
  26673. */
  26674. getVRDevice(): any;
  26675. /**
  26676. * Initializes a webVR display and starts listening to display change events
  26677. * The onVRDisplayChangedObservable will be notified upon these changes
  26678. * @returns A promise containing a VRDisplay and if vr is supported
  26679. */
  26680. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  26681. /** @hidden */
  26682. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  26683. /**
  26684. * Gets or sets the presentation attributes used to configure VR rendering
  26685. */
  26686. vrPresentationAttributes?: IVRPresentationAttributes;
  26687. /**
  26688. * Call this function to switch to webVR mode
  26689. * Will do nothing if webVR is not supported or if there is no webVR device
  26690. * @param options the webvr options provided to the camera. mainly used for multiview
  26691. * @see https://doc.babylonjs.com/how_to/webvr_camera
  26692. */
  26693. enableVR(options: WebVROptions): void;
  26694. /** @hidden */
  26695. _onVRFullScreenTriggered(): void;
  26696. }
  26697. }
  26698. declare module BABYLON {
  26699. /**
  26700. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  26701. * IMPORTANT!! The data is right-hand data.
  26702. * @export
  26703. * @interface DevicePose
  26704. */
  26705. export interface DevicePose {
  26706. /**
  26707. * The position of the device, values in array are [x,y,z].
  26708. */
  26709. readonly position: Nullable<Float32Array>;
  26710. /**
  26711. * The linearVelocity of the device, values in array are [x,y,z].
  26712. */
  26713. readonly linearVelocity: Nullable<Float32Array>;
  26714. /**
  26715. * The linearAcceleration of the device, values in array are [x,y,z].
  26716. */
  26717. readonly linearAcceleration: Nullable<Float32Array>;
  26718. /**
  26719. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  26720. */
  26721. readonly orientation: Nullable<Float32Array>;
  26722. /**
  26723. * The angularVelocity of the device, values in array are [x,y,z].
  26724. */
  26725. readonly angularVelocity: Nullable<Float32Array>;
  26726. /**
  26727. * The angularAcceleration of the device, values in array are [x,y,z].
  26728. */
  26729. readonly angularAcceleration: Nullable<Float32Array>;
  26730. }
  26731. /**
  26732. * Interface representing a pose controlled object in Babylon.
  26733. * A pose controlled object has both regular pose values as well as pose values
  26734. * from an external device such as a VR head mounted display
  26735. */
  26736. export interface PoseControlled {
  26737. /**
  26738. * The position of the object in babylon space.
  26739. */
  26740. position: Vector3;
  26741. /**
  26742. * The rotation quaternion of the object in babylon space.
  26743. */
  26744. rotationQuaternion: Quaternion;
  26745. /**
  26746. * The position of the device in babylon space.
  26747. */
  26748. devicePosition?: Vector3;
  26749. /**
  26750. * The rotation quaternion of the device in babylon space.
  26751. */
  26752. deviceRotationQuaternion: Quaternion;
  26753. /**
  26754. * The raw pose coming from the device.
  26755. */
  26756. rawPose: Nullable<DevicePose>;
  26757. /**
  26758. * The scale of the device to be used when translating from device space to babylon space.
  26759. */
  26760. deviceScaleFactor: number;
  26761. /**
  26762. * Updates the poseControlled values based on the input device pose.
  26763. * @param poseData the pose data to update the object with
  26764. */
  26765. updateFromDevice(poseData: DevicePose): void;
  26766. }
  26767. /**
  26768. * Set of options to customize the webVRCamera
  26769. */
  26770. export interface WebVROptions {
  26771. /**
  26772. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  26773. */
  26774. trackPosition?: boolean;
  26775. /**
  26776. * Sets the scale of the vrDevice in babylon space. (default: 1)
  26777. */
  26778. positionScale?: number;
  26779. /**
  26780. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  26781. */
  26782. displayName?: string;
  26783. /**
  26784. * Should the native controller meshes be initialized. (default: true)
  26785. */
  26786. controllerMeshes?: boolean;
  26787. /**
  26788. * Creating a default HemiLight only on controllers. (default: true)
  26789. */
  26790. defaultLightingOnControllers?: boolean;
  26791. /**
  26792. * If you don't want to use the default VR button of the helper. (default: false)
  26793. */
  26794. useCustomVRButton?: boolean;
  26795. /**
  26796. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  26797. */
  26798. customVRButton?: HTMLButtonElement;
  26799. /**
  26800. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  26801. */
  26802. rayLength?: number;
  26803. /**
  26804. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  26805. */
  26806. defaultHeight?: number;
  26807. /**
  26808. * If multiview should be used if availible (default: false)
  26809. */
  26810. useMultiview?: boolean;
  26811. }
  26812. /**
  26813. * This represents a WebVR camera.
  26814. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  26815. * @example https://doc.babylonjs.com/how_to/webvr_camera
  26816. */
  26817. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  26818. private webVROptions;
  26819. /**
  26820. * @hidden
  26821. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  26822. */
  26823. _vrDevice: any;
  26824. /**
  26825. * The rawPose of the vrDevice.
  26826. */
  26827. rawPose: Nullable<DevicePose>;
  26828. private _onVREnabled;
  26829. private _specsVersion;
  26830. private _attached;
  26831. private _frameData;
  26832. protected _descendants: Array<Node>;
  26833. private _deviceRoomPosition;
  26834. /** @hidden */
  26835. _deviceRoomRotationQuaternion: Quaternion;
  26836. private _standingMatrix;
  26837. /**
  26838. * Represents device position in babylon space.
  26839. */
  26840. devicePosition: Vector3;
  26841. /**
  26842. * Represents device rotation in babylon space.
  26843. */
  26844. deviceRotationQuaternion: Quaternion;
  26845. /**
  26846. * The scale of the device to be used when translating from device space to babylon space.
  26847. */
  26848. deviceScaleFactor: number;
  26849. private _deviceToWorld;
  26850. private _worldToDevice;
  26851. /**
  26852. * References to the webVR controllers for the vrDevice.
  26853. */
  26854. controllers: Array<WebVRController>;
  26855. /**
  26856. * Emits an event when a controller is attached.
  26857. */
  26858. onControllersAttachedObservable: Observable<WebVRController[]>;
  26859. /**
  26860. * Emits an event when a controller's mesh has been loaded;
  26861. */
  26862. onControllerMeshLoadedObservable: Observable<WebVRController>;
  26863. /**
  26864. * Emits an event when the HMD's pose has been updated.
  26865. */
  26866. onPoseUpdatedFromDeviceObservable: Observable<any>;
  26867. private _poseSet;
  26868. /**
  26869. * If the rig cameras be used as parent instead of this camera.
  26870. */
  26871. rigParenting: boolean;
  26872. private _lightOnControllers;
  26873. private _defaultHeight?;
  26874. /**
  26875. * Instantiates a WebVRFreeCamera.
  26876. * @param name The name of the WebVRFreeCamera
  26877. * @param position The starting anchor position for the camera
  26878. * @param scene The scene the camera belongs to
  26879. * @param webVROptions a set of customizable options for the webVRCamera
  26880. */
  26881. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  26882. /**
  26883. * Gets the device distance from the ground in meters.
  26884. * @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.
  26885. */
  26886. deviceDistanceToRoomGround(): number;
  26887. /**
  26888. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  26889. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  26890. */
  26891. useStandingMatrix(callback?: (bool: boolean) => void): void;
  26892. /**
  26893. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  26894. * @returns A promise with a boolean set to if the standing matrix is supported.
  26895. */
  26896. useStandingMatrixAsync(): Promise<boolean>;
  26897. /**
  26898. * Disposes the camera
  26899. */
  26900. dispose(): void;
  26901. /**
  26902. * Gets a vrController by name.
  26903. * @param name The name of the controller to retreive
  26904. * @returns the controller matching the name specified or null if not found
  26905. */
  26906. getControllerByName(name: string): Nullable<WebVRController>;
  26907. private _leftController;
  26908. /**
  26909. * The controller corresponding to the users left hand.
  26910. */
  26911. get leftController(): Nullable<WebVRController>;
  26912. private _rightController;
  26913. /**
  26914. * The controller corresponding to the users right hand.
  26915. */
  26916. get rightController(): Nullable<WebVRController>;
  26917. /**
  26918. * Casts a ray forward from the vrCamera's gaze.
  26919. * @param length Length of the ray (default: 100)
  26920. * @returns the ray corresponding to the gaze
  26921. */
  26922. getForwardRay(length?: number): Ray;
  26923. /**
  26924. * @hidden
  26925. * Updates the camera based on device's frame data
  26926. */
  26927. _checkInputs(): void;
  26928. /**
  26929. * Updates the poseControlled values based on the input device pose.
  26930. * @param poseData Pose coming from the device
  26931. */
  26932. updateFromDevice(poseData: DevicePose): void;
  26933. private _detachIfAttached;
  26934. /**
  26935. * WebVR's attach control will start broadcasting frames to the device.
  26936. * Note that in certain browsers (chrome for example) this function must be called
  26937. * within a user-interaction callback. Example:
  26938. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  26939. *
  26940. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  26941. */
  26942. attachControl(noPreventDefault?: boolean): void;
  26943. /**
  26944. * Detach the current controls from the specified dom element.
  26945. */
  26946. detachControl(): void;
  26947. /**
  26948. * @returns the name of this class
  26949. */
  26950. getClassName(): string;
  26951. /**
  26952. * Calls resetPose on the vrDisplay
  26953. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  26954. */
  26955. resetToCurrentRotation(): void;
  26956. /**
  26957. * @hidden
  26958. * Updates the rig cameras (left and right eye)
  26959. */
  26960. _updateRigCameras(): void;
  26961. private _workingVector;
  26962. private _oneVector;
  26963. private _workingMatrix;
  26964. private updateCacheCalled;
  26965. private _correctPositionIfNotTrackPosition;
  26966. /**
  26967. * @hidden
  26968. * Updates the cached values of the camera
  26969. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  26970. */
  26971. _updateCache(ignoreParentClass?: boolean): void;
  26972. /**
  26973. * @hidden
  26974. * Get current device position in babylon world
  26975. */
  26976. _computeDevicePosition(): void;
  26977. /**
  26978. * Updates the current device position and rotation in the babylon world
  26979. */
  26980. update(): void;
  26981. /**
  26982. * @hidden
  26983. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  26984. * @returns an identity matrix
  26985. */
  26986. _getViewMatrix(): Matrix;
  26987. private _tmpMatrix;
  26988. /**
  26989. * This function is called by the two RIG cameras.
  26990. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  26991. * @hidden
  26992. */
  26993. _getWebVRViewMatrix(): Matrix;
  26994. /** @hidden */
  26995. _getWebVRProjectionMatrix(): Matrix;
  26996. private _onGamepadConnectedObserver;
  26997. private _onGamepadDisconnectedObserver;
  26998. private _updateCacheWhenTrackingDisabledObserver;
  26999. /**
  27000. * Initializes the controllers and their meshes
  27001. */
  27002. initControllers(): void;
  27003. }
  27004. }
  27005. declare module BABYLON {
  27006. /**
  27007. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27008. *
  27009. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27010. *
  27011. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27012. */
  27013. export class MaterialHelper {
  27014. /**
  27015. * Bind the current view position to an effect.
  27016. * @param effect The effect to be bound
  27017. * @param scene The scene the eyes position is used from
  27018. * @param variableName name of the shader variable that will hold the eye position
  27019. */
  27020. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  27021. /**
  27022. * Helps preparing the defines values about the UVs in used in the effect.
  27023. * UVs are shared as much as we can accross channels in the shaders.
  27024. * @param texture The texture we are preparing the UVs for
  27025. * @param defines The defines to update
  27026. * @param key The channel key "diffuse", "specular"... used in the shader
  27027. */
  27028. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27029. /**
  27030. * Binds a texture matrix value to its corrsponding uniform
  27031. * @param texture The texture to bind the matrix for
  27032. * @param uniformBuffer The uniform buffer receivin the data
  27033. * @param key The channel key "diffuse", "specular"... used in the shader
  27034. */
  27035. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27036. /**
  27037. * Gets the current status of the fog (should it be enabled?)
  27038. * @param mesh defines the mesh to evaluate for fog support
  27039. * @param scene defines the hosting scene
  27040. * @returns true if fog must be enabled
  27041. */
  27042. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27043. /**
  27044. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27045. * @param mesh defines the current mesh
  27046. * @param scene defines the current scene
  27047. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27048. * @param pointsCloud defines if point cloud rendering has to be turned on
  27049. * @param fogEnabled defines if fog has to be turned on
  27050. * @param alphaTest defines if alpha testing has to be turned on
  27051. * @param defines defines the current list of defines
  27052. */
  27053. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27054. /**
  27055. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27056. * @param scene defines the current scene
  27057. * @param engine defines the current engine
  27058. * @param defines specifies the list of active defines
  27059. * @param useInstances defines if instances have to be turned on
  27060. * @param useClipPlane defines if clip plane have to be turned on
  27061. * @param useInstances defines if instances have to be turned on
  27062. * @param useThinInstances defines if thin instances have to be turned on
  27063. */
  27064. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27065. /**
  27066. * Prepares the defines for bones
  27067. * @param mesh The mesh containing the geometry data we will draw
  27068. * @param defines The defines to update
  27069. */
  27070. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27071. /**
  27072. * Prepares the defines for morph targets
  27073. * @param mesh The mesh containing the geometry data we will draw
  27074. * @param defines The defines to update
  27075. */
  27076. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27077. /**
  27078. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27079. * @param mesh The mesh containing the geometry data we will draw
  27080. * @param defines The defines to update
  27081. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27082. * @param useBones Precise whether bones should be used or not (override mesh info)
  27083. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27084. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27085. * @returns false if defines are considered not dirty and have not been checked
  27086. */
  27087. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27088. /**
  27089. * Prepares the defines related to multiview
  27090. * @param scene The scene we are intending to draw
  27091. * @param defines The defines to update
  27092. */
  27093. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27094. /**
  27095. * Prepares the defines related to the prepass
  27096. * @param scene The scene we are intending to draw
  27097. * @param defines The defines to update
  27098. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27099. */
  27100. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27101. /**
  27102. * Prepares the defines related to the light information passed in parameter
  27103. * @param scene The scene we are intending to draw
  27104. * @param mesh The mesh the effect is compiling for
  27105. * @param light The light the effect is compiling for
  27106. * @param lightIndex The index of the light
  27107. * @param defines The defines to update
  27108. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27109. * @param state Defines the current state regarding what is needed (normals, etc...)
  27110. */
  27111. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27112. needNormals: boolean;
  27113. needRebuild: boolean;
  27114. shadowEnabled: boolean;
  27115. specularEnabled: boolean;
  27116. lightmapMode: boolean;
  27117. }): void;
  27118. /**
  27119. * Prepares the defines related to the light information passed in parameter
  27120. * @param scene The scene we are intending to draw
  27121. * @param mesh The mesh the effect is compiling for
  27122. * @param defines The defines to update
  27123. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27124. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27125. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27126. * @returns true if normals will be required for the rest of the effect
  27127. */
  27128. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27129. /**
  27130. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27131. * @param lightIndex defines the light index
  27132. * @param uniformsList The uniform list
  27133. * @param samplersList The sampler list
  27134. * @param projectedLightTexture defines if projected texture must be used
  27135. * @param uniformBuffersList defines an optional list of uniform buffers
  27136. */
  27137. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  27138. /**
  27139. * Prepares the uniforms and samplers list to be used in the effect
  27140. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  27141. * @param samplersList The sampler list
  27142. * @param defines The defines helping in the list generation
  27143. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  27144. */
  27145. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  27146. /**
  27147. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  27148. * @param defines The defines to update while falling back
  27149. * @param fallbacks The authorized effect fallbacks
  27150. * @param maxSimultaneousLights The maximum number of lights allowed
  27151. * @param rank the current rank of the Effect
  27152. * @returns The newly affected rank
  27153. */
  27154. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  27155. private static _TmpMorphInfluencers;
  27156. /**
  27157. * Prepares the list of attributes required for morph targets according to the effect defines.
  27158. * @param attribs The current list of supported attribs
  27159. * @param mesh The mesh to prepare the morph targets attributes for
  27160. * @param influencers The number of influencers
  27161. */
  27162. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  27163. /**
  27164. * Prepares the list of attributes required for morph targets according to the effect defines.
  27165. * @param attribs The current list of supported attribs
  27166. * @param mesh The mesh to prepare the morph targets attributes for
  27167. * @param defines The current Defines of the effect
  27168. */
  27169. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  27170. /**
  27171. * Prepares the list of attributes required for bones according to the effect defines.
  27172. * @param attribs The current list of supported attribs
  27173. * @param mesh The mesh to prepare the bones attributes for
  27174. * @param defines The current Defines of the effect
  27175. * @param fallbacks The current efffect fallback strategy
  27176. */
  27177. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  27178. /**
  27179. * Check and prepare the list of attributes required for instances according to the effect defines.
  27180. * @param attribs The current list of supported attribs
  27181. * @param defines The current MaterialDefines of the effect
  27182. */
  27183. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  27184. /**
  27185. * Add the list of attributes required for instances to the attribs array.
  27186. * @param attribs The current list of supported attribs
  27187. */
  27188. static PushAttributesForInstances(attribs: string[]): void;
  27189. /**
  27190. * Binds the light information to the effect.
  27191. * @param light The light containing the generator
  27192. * @param effect The effect we are binding the data to
  27193. * @param lightIndex The light index in the effect used to render
  27194. */
  27195. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  27196. /**
  27197. * Binds the lights information from the scene to the effect for the given mesh.
  27198. * @param light Light to bind
  27199. * @param lightIndex Light index
  27200. * @param scene The scene where the light belongs to
  27201. * @param effect The effect we are binding the data to
  27202. * @param useSpecular Defines if specular is supported
  27203. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27204. */
  27205. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  27206. /**
  27207. * Binds the lights information from the scene to the effect for the given mesh.
  27208. * @param scene The scene the lights belongs to
  27209. * @param mesh The mesh we are binding the information to render
  27210. * @param effect The effect we are binding the data to
  27211. * @param defines The generated defines for the effect
  27212. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  27213. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27214. */
  27215. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  27216. private static _tempFogColor;
  27217. /**
  27218. * Binds the fog information from the scene to the effect for the given mesh.
  27219. * @param scene The scene the lights belongs to
  27220. * @param mesh The mesh we are binding the information to render
  27221. * @param effect The effect we are binding the data to
  27222. * @param linearSpace Defines if the fog effect is applied in linear space
  27223. */
  27224. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  27225. /**
  27226. * Binds the bones information from the mesh to the effect.
  27227. * @param mesh The mesh we are binding the information to render
  27228. * @param effect The effect we are binding the data to
  27229. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  27230. */
  27231. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  27232. private static _CopyBonesTransformationMatrices;
  27233. /**
  27234. * Binds the morph targets information from the mesh to the effect.
  27235. * @param abstractMesh The mesh we are binding the information to render
  27236. * @param effect The effect we are binding the data to
  27237. */
  27238. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  27239. /**
  27240. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  27241. * @param defines The generated defines used in the effect
  27242. * @param effect The effect we are binding the data to
  27243. * @param scene The scene we are willing to render with logarithmic scale for
  27244. */
  27245. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  27246. /**
  27247. * Binds the clip plane information from the scene to the effect.
  27248. * @param scene The scene the clip plane information are extracted from
  27249. * @param effect The effect we are binding the data to
  27250. */
  27251. static BindClipPlane(effect: Effect, scene: Scene): void;
  27252. }
  27253. }
  27254. declare module BABYLON {
  27255. /** @hidden */
  27256. export var bayerDitherFunctions: {
  27257. name: string;
  27258. shader: string;
  27259. };
  27260. }
  27261. declare module BABYLON {
  27262. /** @hidden */
  27263. export var shadowMapFragmentDeclaration: {
  27264. name: string;
  27265. shader: string;
  27266. };
  27267. }
  27268. declare module BABYLON {
  27269. /** @hidden */
  27270. export var shadowMapFragment: {
  27271. name: string;
  27272. shader: string;
  27273. };
  27274. }
  27275. declare module BABYLON {
  27276. /** @hidden */
  27277. export var shadowMapPixelShader: {
  27278. name: string;
  27279. shader: string;
  27280. };
  27281. }
  27282. declare module BABYLON {
  27283. /** @hidden */
  27284. export var shadowMapVertexDeclaration: {
  27285. name: string;
  27286. shader: string;
  27287. };
  27288. }
  27289. declare module BABYLON {
  27290. /** @hidden */
  27291. export var shadowMapVertexNormalBias: {
  27292. name: string;
  27293. shader: string;
  27294. };
  27295. }
  27296. declare module BABYLON {
  27297. /** @hidden */
  27298. export var shadowMapVertexMetric: {
  27299. name: string;
  27300. shader: string;
  27301. };
  27302. }
  27303. declare module BABYLON {
  27304. /** @hidden */
  27305. export var shadowMapVertexShader: {
  27306. name: string;
  27307. shader: string;
  27308. };
  27309. }
  27310. declare module BABYLON {
  27311. /** @hidden */
  27312. export var depthBoxBlurPixelShader: {
  27313. name: string;
  27314. shader: string;
  27315. };
  27316. }
  27317. declare module BABYLON {
  27318. /** @hidden */
  27319. export var shadowMapFragmentSoftTransparentShadow: {
  27320. name: string;
  27321. shader: string;
  27322. };
  27323. }
  27324. declare module BABYLON {
  27325. /**
  27326. * Creates an instance based on a source mesh.
  27327. */
  27328. export class InstancedMesh extends AbstractMesh {
  27329. private _sourceMesh;
  27330. private _currentLOD;
  27331. /** @hidden */
  27332. _indexInSourceMeshInstanceArray: number;
  27333. constructor(name: string, source: Mesh);
  27334. /**
  27335. * Returns the string "InstancedMesh".
  27336. */
  27337. getClassName(): string;
  27338. /** Gets the list of lights affecting that mesh */
  27339. get lightSources(): Light[];
  27340. _resyncLightSources(): void;
  27341. _resyncLightSource(light: Light): void;
  27342. _removeLightSource(light: Light, dispose: boolean): void;
  27343. /**
  27344. * If the source mesh receives shadows
  27345. */
  27346. get receiveShadows(): boolean;
  27347. /**
  27348. * The material of the source mesh
  27349. */
  27350. get material(): Nullable<Material>;
  27351. /**
  27352. * Visibility of the source mesh
  27353. */
  27354. get visibility(): number;
  27355. /**
  27356. * Skeleton of the source mesh
  27357. */
  27358. get skeleton(): Nullable<Skeleton>;
  27359. /**
  27360. * Rendering ground id of the source mesh
  27361. */
  27362. get renderingGroupId(): number;
  27363. set renderingGroupId(value: number);
  27364. /**
  27365. * Returns the total number of vertices (integer).
  27366. */
  27367. getTotalVertices(): number;
  27368. /**
  27369. * Returns a positive integer : the total number of indices in this mesh geometry.
  27370. * @returns the numner of indices or zero if the mesh has no geometry.
  27371. */
  27372. getTotalIndices(): number;
  27373. /**
  27374. * The source mesh of the instance
  27375. */
  27376. get sourceMesh(): Mesh;
  27377. /**
  27378. * Creates a new InstancedMesh object from the mesh model.
  27379. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27380. * @param name defines the name of the new instance
  27381. * @returns a new InstancedMesh
  27382. */
  27383. createInstance(name: string): InstancedMesh;
  27384. /**
  27385. * Is this node ready to be used/rendered
  27386. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27387. * @return {boolean} is it ready
  27388. */
  27389. isReady(completeCheck?: boolean): boolean;
  27390. /**
  27391. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27392. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  27393. * @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.
  27394. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  27395. */
  27396. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  27397. /**
  27398. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27399. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27400. * The `data` are either a numeric array either a Float32Array.
  27401. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  27402. * 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).
  27403. * Note that a new underlying VertexBuffer object is created each call.
  27404. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27405. *
  27406. * Possible `kind` values :
  27407. * - VertexBuffer.PositionKind
  27408. * - VertexBuffer.UVKind
  27409. * - VertexBuffer.UV2Kind
  27410. * - VertexBuffer.UV3Kind
  27411. * - VertexBuffer.UV4Kind
  27412. * - VertexBuffer.UV5Kind
  27413. * - VertexBuffer.UV6Kind
  27414. * - VertexBuffer.ColorKind
  27415. * - VertexBuffer.MatricesIndicesKind
  27416. * - VertexBuffer.MatricesIndicesExtraKind
  27417. * - VertexBuffer.MatricesWeightsKind
  27418. * - VertexBuffer.MatricesWeightsExtraKind
  27419. *
  27420. * Returns the Mesh.
  27421. */
  27422. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27423. /**
  27424. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27425. * If the mesh has no geometry, it is simply returned as it is.
  27426. * The `data` are either a numeric array either a Float32Array.
  27427. * No new underlying VertexBuffer object is created.
  27428. * 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.
  27429. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  27430. *
  27431. * Possible `kind` values :
  27432. * - VertexBuffer.PositionKind
  27433. * - VertexBuffer.UVKind
  27434. * - VertexBuffer.UV2Kind
  27435. * - VertexBuffer.UV3Kind
  27436. * - VertexBuffer.UV4Kind
  27437. * - VertexBuffer.UV5Kind
  27438. * - VertexBuffer.UV6Kind
  27439. * - VertexBuffer.ColorKind
  27440. * - VertexBuffer.MatricesIndicesKind
  27441. * - VertexBuffer.MatricesIndicesExtraKind
  27442. * - VertexBuffer.MatricesWeightsKind
  27443. * - VertexBuffer.MatricesWeightsExtraKind
  27444. *
  27445. * Returns the Mesh.
  27446. */
  27447. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27448. /**
  27449. * Sets the mesh indices.
  27450. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  27451. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27452. * This method creates a new index buffer each call.
  27453. * Returns the Mesh.
  27454. */
  27455. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  27456. /**
  27457. * Boolean : True if the mesh owns the requested kind of data.
  27458. */
  27459. isVerticesDataPresent(kind: string): boolean;
  27460. /**
  27461. * Returns an array of indices (IndicesArray).
  27462. */
  27463. getIndices(): Nullable<IndicesArray>;
  27464. get _positions(): Nullable<Vector3[]>;
  27465. /**
  27466. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27467. * This means the mesh underlying bounding box and sphere are recomputed.
  27468. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27469. * @returns the current mesh
  27470. */
  27471. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  27472. /** @hidden */
  27473. _preActivate(): InstancedMesh;
  27474. /** @hidden */
  27475. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27476. /** @hidden */
  27477. _postActivate(): void;
  27478. getWorldMatrix(): Matrix;
  27479. get isAnInstance(): boolean;
  27480. /**
  27481. * Returns the current associated LOD AbstractMesh.
  27482. */
  27483. getLOD(camera: Camera): AbstractMesh;
  27484. /** @hidden */
  27485. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27486. /** @hidden */
  27487. _syncSubMeshes(): InstancedMesh;
  27488. /** @hidden */
  27489. _generatePointsArray(): boolean;
  27490. /** @hidden */
  27491. _updateBoundingInfo(): AbstractMesh;
  27492. /**
  27493. * Creates a new InstancedMesh from the current mesh.
  27494. * - name (string) : the cloned mesh name
  27495. * - newParent (optional Node) : the optional Node to parent the clone to.
  27496. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  27497. *
  27498. * Returns the clone.
  27499. */
  27500. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  27501. /**
  27502. * Disposes the InstancedMesh.
  27503. * Returns nothing.
  27504. */
  27505. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27506. }
  27507. interface Mesh {
  27508. /**
  27509. * Register a custom buffer that will be instanced
  27510. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27511. * @param kind defines the buffer kind
  27512. * @param stride defines the stride in floats
  27513. */
  27514. registerInstancedBuffer(kind: string, stride: number): void;
  27515. /**
  27516. * true to use the edge renderer for all instances of this mesh
  27517. */
  27518. edgesShareWithInstances: boolean;
  27519. /** @hidden */
  27520. _userInstancedBuffersStorage: {
  27521. data: {
  27522. [key: string]: Float32Array;
  27523. };
  27524. sizes: {
  27525. [key: string]: number;
  27526. };
  27527. vertexBuffers: {
  27528. [key: string]: Nullable<VertexBuffer>;
  27529. };
  27530. strides: {
  27531. [key: string]: number;
  27532. };
  27533. };
  27534. }
  27535. interface AbstractMesh {
  27536. /**
  27537. * Object used to store instanced buffers defined by user
  27538. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27539. */
  27540. instancedBuffers: {
  27541. [key: string]: any;
  27542. };
  27543. }
  27544. }
  27545. declare module BABYLON {
  27546. /**
  27547. * Defines the options associated with the creation of a shader material.
  27548. */
  27549. export interface IShaderMaterialOptions {
  27550. /**
  27551. * Does the material work in alpha blend mode
  27552. */
  27553. needAlphaBlending: boolean;
  27554. /**
  27555. * Does the material work in alpha test mode
  27556. */
  27557. needAlphaTesting: boolean;
  27558. /**
  27559. * The list of attribute names used in the shader
  27560. */
  27561. attributes: string[];
  27562. /**
  27563. * The list of unifrom names used in the shader
  27564. */
  27565. uniforms: string[];
  27566. /**
  27567. * The list of UBO names used in the shader
  27568. */
  27569. uniformBuffers: string[];
  27570. /**
  27571. * The list of sampler names used in the shader
  27572. */
  27573. samplers: string[];
  27574. /**
  27575. * The list of defines used in the shader
  27576. */
  27577. defines: string[];
  27578. }
  27579. /**
  27580. * 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.
  27581. *
  27582. * This returned material effects how the mesh will look based on the code in the shaders.
  27583. *
  27584. * @see https://doc.babylonjs.com/how_to/shader_material
  27585. */
  27586. export class ShaderMaterial extends Material {
  27587. private _shaderPath;
  27588. private _options;
  27589. private _textures;
  27590. private _textureArrays;
  27591. private _floats;
  27592. private _ints;
  27593. private _floatsArrays;
  27594. private _colors3;
  27595. private _colors3Arrays;
  27596. private _colors4;
  27597. private _colors4Arrays;
  27598. private _vectors2;
  27599. private _vectors3;
  27600. private _vectors4;
  27601. private _matrices;
  27602. private _matrixArrays;
  27603. private _matrices3x3;
  27604. private _matrices2x2;
  27605. private _vectors2Arrays;
  27606. private _vectors3Arrays;
  27607. private _vectors4Arrays;
  27608. private _cachedWorldViewMatrix;
  27609. private _cachedWorldViewProjectionMatrix;
  27610. private _renderId;
  27611. private _multiview;
  27612. private _cachedDefines;
  27613. /** Define the Url to load snippets */
  27614. static SnippetUrl: string;
  27615. /** Snippet ID if the material was created from the snippet server */
  27616. snippetId: string;
  27617. /**
  27618. * Instantiate a new shader material.
  27619. * 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.
  27620. * This returned material effects how the mesh will look based on the code in the shaders.
  27621. * @see https://doc.babylonjs.com/how_to/shader_material
  27622. * @param name Define the name of the material in the scene
  27623. * @param scene Define the scene the material belongs to
  27624. * @param shaderPath Defines the route to the shader code in one of three ways:
  27625. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  27626. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  27627. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  27628. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  27629. * @param options Define the options used to create the shader
  27630. */
  27631. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  27632. /**
  27633. * Gets the shader path used to define the shader code
  27634. * It can be modified to trigger a new compilation
  27635. */
  27636. get shaderPath(): any;
  27637. /**
  27638. * Sets the shader path used to define the shader code
  27639. * It can be modified to trigger a new compilation
  27640. */
  27641. set shaderPath(shaderPath: any);
  27642. /**
  27643. * Gets the options used to compile the shader.
  27644. * They can be modified to trigger a new compilation
  27645. */
  27646. get options(): IShaderMaterialOptions;
  27647. /**
  27648. * Gets the current class name of the material e.g. "ShaderMaterial"
  27649. * Mainly use in serialization.
  27650. * @returns the class name
  27651. */
  27652. getClassName(): string;
  27653. /**
  27654. * Specifies if the material will require alpha blending
  27655. * @returns a boolean specifying if alpha blending is needed
  27656. */
  27657. needAlphaBlending(): boolean;
  27658. /**
  27659. * Specifies if this material should be rendered in alpha test mode
  27660. * @returns a boolean specifying if an alpha test is needed.
  27661. */
  27662. needAlphaTesting(): boolean;
  27663. private _checkUniform;
  27664. /**
  27665. * Set a texture in the shader.
  27666. * @param name Define the name of the uniform samplers as defined in the shader
  27667. * @param texture Define the texture to bind to this sampler
  27668. * @return the material itself allowing "fluent" like uniform updates
  27669. */
  27670. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  27671. /**
  27672. * Set a texture array in the shader.
  27673. * @param name Define the name of the uniform sampler array as defined in the shader
  27674. * @param textures Define the list of textures to bind to this sampler
  27675. * @return the material itself allowing "fluent" like uniform updates
  27676. */
  27677. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  27678. /**
  27679. * Set a float in the shader.
  27680. * @param name Define the name of the uniform as defined in the shader
  27681. * @param value Define the value to give to the uniform
  27682. * @return the material itself allowing "fluent" like uniform updates
  27683. */
  27684. setFloat(name: string, value: number): ShaderMaterial;
  27685. /**
  27686. * Set a int in the shader.
  27687. * @param name Define the name of the uniform as defined in the shader
  27688. * @param value Define the value to give to the uniform
  27689. * @return the material itself allowing "fluent" like uniform updates
  27690. */
  27691. setInt(name: string, value: number): ShaderMaterial;
  27692. /**
  27693. * Set an array of floats in the shader.
  27694. * @param name Define the name of the uniform as defined in the shader
  27695. * @param value Define the value to give to the uniform
  27696. * @return the material itself allowing "fluent" like uniform updates
  27697. */
  27698. setFloats(name: string, value: number[]): ShaderMaterial;
  27699. /**
  27700. * Set a vec3 in the shader from a Color3.
  27701. * @param name Define the name of the uniform as defined in the shader
  27702. * @param value Define the value to give to the uniform
  27703. * @return the material itself allowing "fluent" like uniform updates
  27704. */
  27705. setColor3(name: string, value: Color3): ShaderMaterial;
  27706. /**
  27707. * Set a vec3 array in the shader from a Color3 array.
  27708. * @param name Define the name of the uniform as defined in the shader
  27709. * @param value Define the value to give to the uniform
  27710. * @return the material itself allowing "fluent" like uniform updates
  27711. */
  27712. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  27713. /**
  27714. * Set a vec4 in the shader from a Color4.
  27715. * @param name Define the name of the uniform as defined in the shader
  27716. * @param value Define the value to give to the uniform
  27717. * @return the material itself allowing "fluent" like uniform updates
  27718. */
  27719. setColor4(name: string, value: Color4): ShaderMaterial;
  27720. /**
  27721. * Set a vec4 array in the shader from a Color4 array.
  27722. * @param name Define the name of the uniform as defined in the shader
  27723. * @param value Define the value to give to the uniform
  27724. * @return the material itself allowing "fluent" like uniform updates
  27725. */
  27726. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  27727. /**
  27728. * Set a vec2 in the shader from a Vector2.
  27729. * @param name Define the name of the uniform as defined in the shader
  27730. * @param value Define the value to give to the uniform
  27731. * @return the material itself allowing "fluent" like uniform updates
  27732. */
  27733. setVector2(name: string, value: Vector2): ShaderMaterial;
  27734. /**
  27735. * Set a vec3 in the shader from a Vector3.
  27736. * @param name Define the name of the uniform as defined in the shader
  27737. * @param value Define the value to give to the uniform
  27738. * @return the material itself allowing "fluent" like uniform updates
  27739. */
  27740. setVector3(name: string, value: Vector3): ShaderMaterial;
  27741. /**
  27742. * Set a vec4 in the shader from a Vector4.
  27743. * @param name Define the name of the uniform as defined in the shader
  27744. * @param value Define the value to give to the uniform
  27745. * @return the material itself allowing "fluent" like uniform updates
  27746. */
  27747. setVector4(name: string, value: Vector4): ShaderMaterial;
  27748. /**
  27749. * Set a mat4 in the shader from a Matrix.
  27750. * @param name Define the name of the uniform as defined in the shader
  27751. * @param value Define the value to give to the uniform
  27752. * @return the material itself allowing "fluent" like uniform updates
  27753. */
  27754. setMatrix(name: string, value: Matrix): ShaderMaterial;
  27755. /**
  27756. * Set a float32Array in the shader from a matrix array.
  27757. * @param name Define the name of the uniform as defined in the shader
  27758. * @param value Define the value to give to the uniform
  27759. * @return the material itself allowing "fluent" like uniform updates
  27760. */
  27761. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  27762. /**
  27763. * Set a mat3 in the shader from a Float32Array.
  27764. * @param name Define the name of the uniform as defined in the shader
  27765. * @param value Define the value to give to the uniform
  27766. * @return the material itself allowing "fluent" like uniform updates
  27767. */
  27768. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27769. /**
  27770. * Set a mat2 in the shader from a Float32Array.
  27771. * @param name Define the name of the uniform as defined in the shader
  27772. * @param value Define the value to give to the uniform
  27773. * @return the material itself allowing "fluent" like uniform updates
  27774. */
  27775. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27776. /**
  27777. * Set a vec2 array in the shader from a number array.
  27778. * @param name Define the name of the uniform as defined in the shader
  27779. * @param value Define the value to give to the uniform
  27780. * @return the material itself allowing "fluent" like uniform updates
  27781. */
  27782. setArray2(name: string, value: number[]): ShaderMaterial;
  27783. /**
  27784. * Set a vec3 array in the shader from a number array.
  27785. * @param name Define the name of the uniform as defined in the shader
  27786. * @param value Define the value to give to the uniform
  27787. * @return the material itself allowing "fluent" like uniform updates
  27788. */
  27789. setArray3(name: string, value: number[]): ShaderMaterial;
  27790. /**
  27791. * Set a vec4 array in the shader from a number array.
  27792. * @param name Define the name of the uniform as defined in the shader
  27793. * @param value Define the value to give to the uniform
  27794. * @return the material itself allowing "fluent" like uniform updates
  27795. */
  27796. setArray4(name: string, value: number[]): ShaderMaterial;
  27797. private _checkCache;
  27798. /**
  27799. * Specifies that the submesh is ready to be used
  27800. * @param mesh defines the mesh to check
  27801. * @param subMesh defines which submesh to check
  27802. * @param useInstances specifies that instances should be used
  27803. * @returns a boolean indicating that the submesh is ready or not
  27804. */
  27805. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27806. /**
  27807. * Checks if the material is ready to render the requested mesh
  27808. * @param mesh Define the mesh to render
  27809. * @param useInstances Define whether or not the material is used with instances
  27810. * @returns true if ready, otherwise false
  27811. */
  27812. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27813. /**
  27814. * Binds the world matrix to the material
  27815. * @param world defines the world transformation matrix
  27816. * @param effectOverride - If provided, use this effect instead of internal effect
  27817. */
  27818. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  27819. /**
  27820. * Binds the submesh to this material by preparing the effect and shader to draw
  27821. * @param world defines the world transformation matrix
  27822. * @param mesh defines the mesh containing the submesh
  27823. * @param subMesh defines the submesh to bind the material to
  27824. */
  27825. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27826. /**
  27827. * Binds the material to the mesh
  27828. * @param world defines the world transformation matrix
  27829. * @param mesh defines the mesh to bind the material to
  27830. * @param effectOverride - If provided, use this effect instead of internal effect
  27831. */
  27832. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  27833. protected _afterBind(mesh?: Mesh): void;
  27834. /**
  27835. * Gets the active textures from the material
  27836. * @returns an array of textures
  27837. */
  27838. getActiveTextures(): BaseTexture[];
  27839. /**
  27840. * Specifies if the material uses a texture
  27841. * @param texture defines the texture to check against the material
  27842. * @returns a boolean specifying if the material uses the texture
  27843. */
  27844. hasTexture(texture: BaseTexture): boolean;
  27845. /**
  27846. * Makes a duplicate of the material, and gives it a new name
  27847. * @param name defines the new name for the duplicated material
  27848. * @returns the cloned material
  27849. */
  27850. clone(name: string): ShaderMaterial;
  27851. /**
  27852. * Disposes the material
  27853. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27854. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27855. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  27856. */
  27857. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  27858. /**
  27859. * Serializes this material in a JSON representation
  27860. * @returns the serialized material object
  27861. */
  27862. serialize(): any;
  27863. /**
  27864. * Creates a shader material from parsed shader material data
  27865. * @param source defines the JSON represnetation of the material
  27866. * @param scene defines the hosting scene
  27867. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27868. * @returns a new material
  27869. */
  27870. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  27871. /**
  27872. * Creates a new ShaderMaterial from a snippet saved in a remote file
  27873. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  27874. * @param url defines the url to load from
  27875. * @param scene defines the hosting scene
  27876. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27877. * @returns a promise that will resolve to the new ShaderMaterial
  27878. */
  27879. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  27880. /**
  27881. * Creates a ShaderMaterial from a snippet saved by the Inspector
  27882. * @param snippetId defines the snippet to load
  27883. * @param scene defines the hosting scene
  27884. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27885. * @returns a promise that will resolve to the new ShaderMaterial
  27886. */
  27887. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  27888. }
  27889. }
  27890. declare module BABYLON {
  27891. /** @hidden */
  27892. export var colorPixelShader: {
  27893. name: string;
  27894. shader: string;
  27895. };
  27896. }
  27897. declare module BABYLON {
  27898. /** @hidden */
  27899. export var colorVertexShader: {
  27900. name: string;
  27901. shader: string;
  27902. };
  27903. }
  27904. declare module BABYLON {
  27905. /**
  27906. * Line mesh
  27907. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  27908. */
  27909. export class LinesMesh extends Mesh {
  27910. /**
  27911. * If vertex color should be applied to the mesh
  27912. */
  27913. readonly useVertexColor?: boolean | undefined;
  27914. /**
  27915. * If vertex alpha should be applied to the mesh
  27916. */
  27917. readonly useVertexAlpha?: boolean | undefined;
  27918. /**
  27919. * Color of the line (Default: White)
  27920. */
  27921. color: Color3;
  27922. /**
  27923. * Alpha of the line (Default: 1)
  27924. */
  27925. alpha: number;
  27926. /**
  27927. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  27928. * This margin is expressed in world space coordinates, so its value may vary.
  27929. * Default value is 0.1
  27930. */
  27931. intersectionThreshold: number;
  27932. private _colorShader;
  27933. private color4;
  27934. /**
  27935. * Creates a new LinesMesh
  27936. * @param name defines the name
  27937. * @param scene defines the hosting scene
  27938. * @param parent defines the parent mesh if any
  27939. * @param source defines the optional source LinesMesh used to clone data from
  27940. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27941. * When false, achieved by calling a clone(), also passing False.
  27942. * This will make creation of children, recursive.
  27943. * @param useVertexColor defines if this LinesMesh supports vertex color
  27944. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  27945. */
  27946. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  27947. /**
  27948. * If vertex color should be applied to the mesh
  27949. */
  27950. useVertexColor?: boolean | undefined,
  27951. /**
  27952. * If vertex alpha should be applied to the mesh
  27953. */
  27954. useVertexAlpha?: boolean | undefined);
  27955. private _addClipPlaneDefine;
  27956. private _removeClipPlaneDefine;
  27957. isReady(): boolean;
  27958. /**
  27959. * Returns the string "LineMesh"
  27960. */
  27961. getClassName(): string;
  27962. /**
  27963. * @hidden
  27964. */
  27965. get material(): Material;
  27966. /**
  27967. * @hidden
  27968. */
  27969. set material(value: Material);
  27970. /**
  27971. * @hidden
  27972. */
  27973. get checkCollisions(): boolean;
  27974. /** @hidden */
  27975. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27976. /** @hidden */
  27977. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27978. /**
  27979. * Disposes of the line mesh
  27980. * @param doNotRecurse If children should be disposed
  27981. */
  27982. dispose(doNotRecurse?: boolean): void;
  27983. /**
  27984. * Returns a new LineMesh object cloned from the current one.
  27985. */
  27986. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  27987. /**
  27988. * Creates a new InstancedLinesMesh object from the mesh model.
  27989. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27990. * @param name defines the name of the new instance
  27991. * @returns a new InstancedLinesMesh
  27992. */
  27993. createInstance(name: string): InstancedLinesMesh;
  27994. }
  27995. /**
  27996. * Creates an instance based on a source LinesMesh
  27997. */
  27998. export class InstancedLinesMesh extends InstancedMesh {
  27999. /**
  28000. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28001. * This margin is expressed in world space coordinates, so its value may vary.
  28002. * Initilized with the intersectionThreshold value of the source LinesMesh
  28003. */
  28004. intersectionThreshold: number;
  28005. constructor(name: string, source: LinesMesh);
  28006. /**
  28007. * Returns the string "InstancedLinesMesh".
  28008. */
  28009. getClassName(): string;
  28010. }
  28011. }
  28012. declare module BABYLON {
  28013. /** @hidden */
  28014. export var linePixelShader: {
  28015. name: string;
  28016. shader: string;
  28017. };
  28018. }
  28019. declare module BABYLON {
  28020. /** @hidden */
  28021. export var lineVertexShader: {
  28022. name: string;
  28023. shader: string;
  28024. };
  28025. }
  28026. declare module BABYLON {
  28027. interface Scene {
  28028. /** @hidden */
  28029. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28030. }
  28031. interface AbstractMesh {
  28032. /**
  28033. * Gets the edgesRenderer associated with the mesh
  28034. */
  28035. edgesRenderer: Nullable<EdgesRenderer>;
  28036. }
  28037. interface LinesMesh {
  28038. /**
  28039. * Enables the edge rendering mode on the mesh.
  28040. * This mode makes the mesh edges visible
  28041. * @param epsilon defines the maximal distance between two angles to detect a face
  28042. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28043. * @returns the currentAbstractMesh
  28044. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28045. */
  28046. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28047. }
  28048. interface InstancedLinesMesh {
  28049. /**
  28050. * Enables the edge rendering mode on the mesh.
  28051. * This mode makes the mesh edges visible
  28052. * @param epsilon defines the maximal distance between two angles to detect a face
  28053. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28054. * @returns the current InstancedLinesMesh
  28055. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28056. */
  28057. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28058. }
  28059. /**
  28060. * Defines the minimum contract an Edges renderer should follow.
  28061. */
  28062. export interface IEdgesRenderer extends IDisposable {
  28063. /**
  28064. * Gets or sets a boolean indicating if the edgesRenderer is active
  28065. */
  28066. isEnabled: boolean;
  28067. /**
  28068. * Renders the edges of the attached mesh,
  28069. */
  28070. render(): void;
  28071. /**
  28072. * Checks wether or not the edges renderer is ready to render.
  28073. * @return true if ready, otherwise false.
  28074. */
  28075. isReady(): boolean;
  28076. /**
  28077. * List of instances to render in case the source mesh has instances
  28078. */
  28079. customInstances: SmartArray<Matrix>;
  28080. }
  28081. /**
  28082. * Defines the additional options of the edges renderer
  28083. */
  28084. export interface IEdgesRendererOptions {
  28085. /**
  28086. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28087. * If not defined, the default value is true
  28088. */
  28089. useAlternateEdgeFinder?: boolean;
  28090. /**
  28091. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28092. * If not defined, the default value is true.
  28093. * 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)
  28094. * This option is used only if useAlternateEdgeFinder = true
  28095. */
  28096. useFastVertexMerger?: boolean;
  28097. /**
  28098. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28099. * The default value is 1e-6
  28100. * This option is used only if useAlternateEdgeFinder = true
  28101. */
  28102. epsilonVertexMerge?: number;
  28103. /**
  28104. * 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
  28105. * 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.
  28106. * This option is used only if useAlternateEdgeFinder = true
  28107. */
  28108. applyTessellation?: boolean;
  28109. /**
  28110. * 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
  28111. * The default value is 1e-6
  28112. * This option is used only if useAlternateEdgeFinder = true
  28113. */
  28114. epsilonVertexAligned?: number;
  28115. }
  28116. /**
  28117. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28118. */
  28119. export class EdgesRenderer implements IEdgesRenderer {
  28120. /**
  28121. * Define the size of the edges with an orthographic camera
  28122. */
  28123. edgesWidthScalerForOrthographic: number;
  28124. /**
  28125. * Define the size of the edges with a perspective camera
  28126. */
  28127. edgesWidthScalerForPerspective: number;
  28128. protected _source: AbstractMesh;
  28129. protected _linesPositions: number[];
  28130. protected _linesNormals: number[];
  28131. protected _linesIndices: number[];
  28132. protected _epsilon: number;
  28133. protected _indicesCount: number;
  28134. protected _lineShader: ShaderMaterial;
  28135. protected _ib: DataBuffer;
  28136. protected _buffers: {
  28137. [key: string]: Nullable<VertexBuffer>;
  28138. };
  28139. protected _buffersForInstances: {
  28140. [key: string]: Nullable<VertexBuffer>;
  28141. };
  28142. protected _checkVerticesInsteadOfIndices: boolean;
  28143. protected _options: Nullable<IEdgesRendererOptions>;
  28144. private _meshRebuildObserver;
  28145. private _meshDisposeObserver;
  28146. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28147. isEnabled: boolean;
  28148. /** Gets the vertices generated by the edge renderer */
  28149. get linesPositions(): Immutable<Array<number>>;
  28150. /** Gets the normals generated by the edge renderer */
  28151. get linesNormals(): Immutable<Array<number>>;
  28152. /** Gets the indices generated by the edge renderer */
  28153. get linesIndices(): Immutable<Array<number>>;
  28154. /**
  28155. * List of instances to render in case the source mesh has instances
  28156. */
  28157. customInstances: SmartArray<Matrix>;
  28158. private static GetShader;
  28159. /**
  28160. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28161. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28162. * @param source Mesh used to create edges
  28163. * @param epsilon sum of angles in adjacency to check for edge
  28164. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  28165. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28166. * @param options The options to apply when generating the edges
  28167. */
  28168. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  28169. protected _prepareRessources(): void;
  28170. /** @hidden */
  28171. _rebuild(): void;
  28172. /**
  28173. * Releases the required resources for the edges renderer
  28174. */
  28175. dispose(): void;
  28176. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28177. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28178. /**
  28179. * Checks if the pair of p0 and p1 is en edge
  28180. * @param faceIndex
  28181. * @param edge
  28182. * @param faceNormals
  28183. * @param p0
  28184. * @param p1
  28185. * @private
  28186. */
  28187. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28188. /**
  28189. * push line into the position, normal and index buffer
  28190. * @protected
  28191. */
  28192. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  28193. /**
  28194. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  28195. */
  28196. private _tessellateTriangle;
  28197. private _generateEdgesLinesAlternate;
  28198. /**
  28199. * Generates lines edges from adjacencjes
  28200. * @private
  28201. */
  28202. _generateEdgesLines(): void;
  28203. /**
  28204. * Checks wether or not the edges renderer is ready to render.
  28205. * @return true if ready, otherwise false.
  28206. */
  28207. isReady(): boolean;
  28208. /**
  28209. * Renders the edges of the attached mesh,
  28210. */
  28211. render(): void;
  28212. }
  28213. /**
  28214. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28215. */
  28216. export class LineEdgesRenderer extends EdgesRenderer {
  28217. /**
  28218. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28219. * @param source LineMesh used to generate edges
  28220. * @param epsilon not important (specified angle for edge detection)
  28221. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28222. */
  28223. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28224. /**
  28225. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28226. */
  28227. _generateEdgesLines(): void;
  28228. }
  28229. }
  28230. declare module BABYLON {
  28231. /**
  28232. * This represents the object necessary to create a rendering group.
  28233. * This is exclusively used and created by the rendering manager.
  28234. * To modify the behavior, you use the available helpers in your scene or meshes.
  28235. * @hidden
  28236. */
  28237. export class RenderingGroup {
  28238. index: number;
  28239. private static _zeroVector;
  28240. private _scene;
  28241. private _opaqueSubMeshes;
  28242. private _transparentSubMeshes;
  28243. private _alphaTestSubMeshes;
  28244. private _depthOnlySubMeshes;
  28245. private _particleSystems;
  28246. private _spriteManagers;
  28247. private _opaqueSortCompareFn;
  28248. private _alphaTestSortCompareFn;
  28249. private _transparentSortCompareFn;
  28250. private _renderOpaque;
  28251. private _renderAlphaTest;
  28252. private _renderTransparent;
  28253. /** @hidden */
  28254. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  28255. onBeforeTransparentRendering: () => void;
  28256. /**
  28257. * Set the opaque sort comparison function.
  28258. * If null the sub meshes will be render in the order they were created
  28259. */
  28260. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28261. /**
  28262. * Set the alpha test sort comparison function.
  28263. * If null the sub meshes will be render in the order they were created
  28264. */
  28265. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28266. /**
  28267. * Set the transparent sort comparison function.
  28268. * If null the sub meshes will be render in the order they were created
  28269. */
  28270. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28271. /**
  28272. * Creates a new rendering group.
  28273. * @param index The rendering group index
  28274. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28275. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28276. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28277. */
  28278. 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>);
  28279. /**
  28280. * Render all the sub meshes contained in the group.
  28281. * @param customRenderFunction Used to override the default render behaviour of the group.
  28282. * @returns true if rendered some submeshes.
  28283. */
  28284. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28285. /**
  28286. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28287. * @param subMeshes The submeshes to render
  28288. */
  28289. private renderOpaqueSorted;
  28290. /**
  28291. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28292. * @param subMeshes The submeshes to render
  28293. */
  28294. private renderAlphaTestSorted;
  28295. /**
  28296. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28297. * @param subMeshes The submeshes to render
  28298. */
  28299. private renderTransparentSorted;
  28300. /**
  28301. * Renders the submeshes in a specified order.
  28302. * @param subMeshes The submeshes to sort before render
  28303. * @param sortCompareFn The comparison function use to sort
  28304. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28305. * @param transparent Specifies to activate blending if true
  28306. */
  28307. private static renderSorted;
  28308. /**
  28309. * Renders the submeshes in the order they were dispatched (no sort applied).
  28310. * @param subMeshes The submeshes to render
  28311. */
  28312. private static renderUnsorted;
  28313. /**
  28314. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28315. * are rendered back to front if in the same alpha index.
  28316. *
  28317. * @param a The first submesh
  28318. * @param b The second submesh
  28319. * @returns The result of the comparison
  28320. */
  28321. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28322. /**
  28323. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28324. * are rendered back to front.
  28325. *
  28326. * @param a The first submesh
  28327. * @param b The second submesh
  28328. * @returns The result of the comparison
  28329. */
  28330. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28331. /**
  28332. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28333. * are rendered front to back (prevent overdraw).
  28334. *
  28335. * @param a The first submesh
  28336. * @param b The second submesh
  28337. * @returns The result of the comparison
  28338. */
  28339. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28340. /**
  28341. * Resets the different lists of submeshes to prepare a new frame.
  28342. */
  28343. prepare(): void;
  28344. dispose(): void;
  28345. /**
  28346. * Inserts the submesh in its correct queue depending on its material.
  28347. * @param subMesh The submesh to dispatch
  28348. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28349. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28350. */
  28351. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28352. dispatchSprites(spriteManager: ISpriteManager): void;
  28353. dispatchParticles(particleSystem: IParticleSystem): void;
  28354. private _renderParticles;
  28355. private _renderSprites;
  28356. }
  28357. }
  28358. declare module BABYLON {
  28359. /**
  28360. * Interface describing the different options available in the rendering manager
  28361. * regarding Auto Clear between groups.
  28362. */
  28363. export interface IRenderingManagerAutoClearSetup {
  28364. /**
  28365. * Defines whether or not autoclear is enable.
  28366. */
  28367. autoClear: boolean;
  28368. /**
  28369. * Defines whether or not to autoclear the depth buffer.
  28370. */
  28371. depth: boolean;
  28372. /**
  28373. * Defines whether or not to autoclear the stencil buffer.
  28374. */
  28375. stencil: boolean;
  28376. }
  28377. /**
  28378. * This class is used by the onRenderingGroupObservable
  28379. */
  28380. export class RenderingGroupInfo {
  28381. /**
  28382. * The Scene that being rendered
  28383. */
  28384. scene: Scene;
  28385. /**
  28386. * The camera currently used for the rendering pass
  28387. */
  28388. camera: Nullable<Camera>;
  28389. /**
  28390. * The ID of the renderingGroup being processed
  28391. */
  28392. renderingGroupId: number;
  28393. }
  28394. /**
  28395. * This is the manager responsible of all the rendering for meshes sprites and particles.
  28396. * It is enable to manage the different groups as well as the different necessary sort functions.
  28397. * This should not be used directly aside of the few static configurations
  28398. */
  28399. export class RenderingManager {
  28400. /**
  28401. * The max id used for rendering groups (not included)
  28402. */
  28403. static MAX_RENDERINGGROUPS: number;
  28404. /**
  28405. * The min id used for rendering groups (included)
  28406. */
  28407. static MIN_RENDERINGGROUPS: number;
  28408. /**
  28409. * Used to globally prevent autoclearing scenes.
  28410. */
  28411. static AUTOCLEAR: boolean;
  28412. /**
  28413. * @hidden
  28414. */
  28415. _useSceneAutoClearSetup: boolean;
  28416. private _scene;
  28417. private _renderingGroups;
  28418. private _depthStencilBufferAlreadyCleaned;
  28419. private _autoClearDepthStencil;
  28420. private _customOpaqueSortCompareFn;
  28421. private _customAlphaTestSortCompareFn;
  28422. private _customTransparentSortCompareFn;
  28423. private _renderingGroupInfo;
  28424. /**
  28425. * Instantiates a new rendering group for a particular scene
  28426. * @param scene Defines the scene the groups belongs to
  28427. */
  28428. constructor(scene: Scene);
  28429. private _clearDepthStencilBuffer;
  28430. /**
  28431. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  28432. * @hidden
  28433. */
  28434. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28435. /**
  28436. * Resets the different information of the group to prepare a new frame
  28437. * @hidden
  28438. */
  28439. reset(): void;
  28440. /**
  28441. * Dispose and release the group and its associated resources.
  28442. * @hidden
  28443. */
  28444. dispose(): void;
  28445. /**
  28446. * Clear the info related to rendering groups preventing retention points during dispose.
  28447. */
  28448. freeRenderingGroups(): void;
  28449. private _prepareRenderingGroup;
  28450. /**
  28451. * Add a sprite manager to the rendering manager in order to render it this frame.
  28452. * @param spriteManager Define the sprite manager to render
  28453. */
  28454. dispatchSprites(spriteManager: ISpriteManager): void;
  28455. /**
  28456. * Add a particle system to the rendering manager in order to render it this frame.
  28457. * @param particleSystem Define the particle system to render
  28458. */
  28459. dispatchParticles(particleSystem: IParticleSystem): void;
  28460. /**
  28461. * Add a submesh to the manager in order to render it this frame
  28462. * @param subMesh The submesh to dispatch
  28463. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28464. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28465. */
  28466. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28467. /**
  28468. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28469. * This allowed control for front to back rendering or reversly depending of the special needs.
  28470. *
  28471. * @param renderingGroupId The rendering group id corresponding to its index
  28472. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28473. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28474. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28475. */
  28476. 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;
  28477. /**
  28478. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28479. *
  28480. * @param renderingGroupId The rendering group id corresponding to its index
  28481. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28482. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28483. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28484. */
  28485. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28486. /**
  28487. * Gets the current auto clear configuration for one rendering group of the rendering
  28488. * manager.
  28489. * @param index the rendering group index to get the information for
  28490. * @returns The auto clear setup for the requested rendering group
  28491. */
  28492. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28493. }
  28494. }
  28495. declare module BABYLON {
  28496. /**
  28497. * Defines the options associated with the creation of a custom shader for a shadow generator.
  28498. */
  28499. export interface ICustomShaderOptions {
  28500. /**
  28501. * Gets or sets the custom shader name to use
  28502. */
  28503. shaderName: string;
  28504. /**
  28505. * The list of attribute names used in the shader
  28506. */
  28507. attributes?: string[];
  28508. /**
  28509. * The list of unifrom names used in the shader
  28510. */
  28511. uniforms?: string[];
  28512. /**
  28513. * The list of sampler names used in the shader
  28514. */
  28515. samplers?: string[];
  28516. /**
  28517. * The list of defines used in the shader
  28518. */
  28519. defines?: string[];
  28520. }
  28521. /**
  28522. * Interface to implement to create a shadow generator compatible with BJS.
  28523. */
  28524. export interface IShadowGenerator {
  28525. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28526. id: string;
  28527. /**
  28528. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28529. * @returns The render target texture if present otherwise, null
  28530. */
  28531. getShadowMap(): Nullable<RenderTargetTexture>;
  28532. /**
  28533. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  28534. * @param subMesh The submesh we want to render in the shadow map
  28535. * @param useInstances Defines wether will draw in the map using instances
  28536. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  28537. * @returns true if ready otherwise, false
  28538. */
  28539. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  28540. /**
  28541. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  28542. * @param defines Defines of the material we want to update
  28543. * @param lightIndex Index of the light in the enabled light list of the material
  28544. */
  28545. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  28546. /**
  28547. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  28548. * defined in the generator but impacting the effect).
  28549. * It implies the unifroms available on the materials are the standard BJS ones.
  28550. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  28551. * @param effect The effect we are binfing the information for
  28552. */
  28553. bindShadowLight(lightIndex: string, effect: Effect): void;
  28554. /**
  28555. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  28556. * (eq to shadow prjection matrix * light transform matrix)
  28557. * @returns The transform matrix used to create the shadow map
  28558. */
  28559. getTransformMatrix(): Matrix;
  28560. /**
  28561. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  28562. * Cube and 2D textures for instance.
  28563. */
  28564. recreateShadowMap(): void;
  28565. /**
  28566. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28567. * @param onCompiled Callback triggered at the and of the effects compilation
  28568. * @param options Sets of optional options forcing the compilation with different modes
  28569. */
  28570. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  28571. useInstances: boolean;
  28572. }>): void;
  28573. /**
  28574. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28575. * @param options Sets of optional options forcing the compilation with different modes
  28576. * @returns A promise that resolves when the compilation completes
  28577. */
  28578. forceCompilationAsync(options?: Partial<{
  28579. useInstances: boolean;
  28580. }>): Promise<void>;
  28581. /**
  28582. * Serializes the shadow generator setup to a json object.
  28583. * @returns The serialized JSON object
  28584. */
  28585. serialize(): any;
  28586. /**
  28587. * Disposes the Shadow map and related Textures and effects.
  28588. */
  28589. dispose(): void;
  28590. }
  28591. /**
  28592. * Default implementation IShadowGenerator.
  28593. * This is the main object responsible of generating shadows in the framework.
  28594. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  28595. */
  28596. export class ShadowGenerator implements IShadowGenerator {
  28597. /**
  28598. * Name of the shadow generator class
  28599. */
  28600. static CLASSNAME: string;
  28601. /**
  28602. * Shadow generator mode None: no filtering applied.
  28603. */
  28604. static readonly FILTER_NONE: number;
  28605. /**
  28606. * Shadow generator mode ESM: Exponential Shadow Mapping.
  28607. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28608. */
  28609. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  28610. /**
  28611. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  28612. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  28613. */
  28614. static readonly FILTER_POISSONSAMPLING: number;
  28615. /**
  28616. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  28617. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28618. */
  28619. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  28620. /**
  28621. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  28622. * edge artifacts on steep falloff.
  28623. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28624. */
  28625. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  28626. /**
  28627. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  28628. * edge artifacts on steep falloff.
  28629. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28630. */
  28631. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  28632. /**
  28633. * Shadow generator mode PCF: Percentage Closer Filtering
  28634. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28635. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  28636. */
  28637. static readonly FILTER_PCF: number;
  28638. /**
  28639. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  28640. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28641. * Contact Hardening
  28642. */
  28643. static readonly FILTER_PCSS: number;
  28644. /**
  28645. * Reserved for PCF and PCSS
  28646. * Highest Quality.
  28647. *
  28648. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  28649. *
  28650. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  28651. */
  28652. static readonly QUALITY_HIGH: number;
  28653. /**
  28654. * Reserved for PCF and PCSS
  28655. * Good tradeoff for quality/perf cross devices
  28656. *
  28657. * Execute PCF on a 3*3 kernel.
  28658. *
  28659. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  28660. */
  28661. static readonly QUALITY_MEDIUM: number;
  28662. /**
  28663. * Reserved for PCF and PCSS
  28664. * The lowest quality but the fastest.
  28665. *
  28666. * Execute PCF on a 1*1 kernel.
  28667. *
  28668. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  28669. */
  28670. static readonly QUALITY_LOW: number;
  28671. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28672. id: string;
  28673. /** Gets or sets the custom shader name to use */
  28674. customShaderOptions: ICustomShaderOptions;
  28675. /**
  28676. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  28677. */
  28678. onBeforeShadowMapRenderObservable: Observable<Effect>;
  28679. /**
  28680. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  28681. */
  28682. onAfterShadowMapRenderObservable: Observable<Effect>;
  28683. /**
  28684. * Observable triggered before a mesh is rendered in the shadow map.
  28685. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  28686. */
  28687. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  28688. /**
  28689. * Observable triggered after a mesh is rendered in the shadow map.
  28690. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  28691. */
  28692. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  28693. protected _bias: number;
  28694. /**
  28695. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  28696. */
  28697. get bias(): number;
  28698. /**
  28699. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  28700. */
  28701. set bias(bias: number);
  28702. protected _normalBias: number;
  28703. /**
  28704. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28705. */
  28706. get normalBias(): number;
  28707. /**
  28708. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28709. */
  28710. set normalBias(normalBias: number);
  28711. protected _blurBoxOffset: number;
  28712. /**
  28713. * Gets the blur box offset: offset applied during the blur pass.
  28714. * Only useful if useKernelBlur = false
  28715. */
  28716. get blurBoxOffset(): number;
  28717. /**
  28718. * Sets the blur box offset: offset applied during the blur pass.
  28719. * Only useful if useKernelBlur = false
  28720. */
  28721. set blurBoxOffset(value: number);
  28722. protected _blurScale: number;
  28723. /**
  28724. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  28725. * 2 means half of the size.
  28726. */
  28727. get blurScale(): number;
  28728. /**
  28729. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  28730. * 2 means half of the size.
  28731. */
  28732. set blurScale(value: number);
  28733. protected _blurKernel: number;
  28734. /**
  28735. * Gets the blur kernel: kernel size of the blur pass.
  28736. * Only useful if useKernelBlur = true
  28737. */
  28738. get blurKernel(): number;
  28739. /**
  28740. * Sets the blur kernel: kernel size of the blur pass.
  28741. * Only useful if useKernelBlur = true
  28742. */
  28743. set blurKernel(value: number);
  28744. protected _useKernelBlur: boolean;
  28745. /**
  28746. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  28747. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28748. */
  28749. get useKernelBlur(): boolean;
  28750. /**
  28751. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  28752. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28753. */
  28754. set useKernelBlur(value: boolean);
  28755. protected _depthScale: number;
  28756. /**
  28757. * Gets the depth scale used in ESM mode.
  28758. */
  28759. get depthScale(): number;
  28760. /**
  28761. * Sets the depth scale used in ESM mode.
  28762. * This can override the scale stored on the light.
  28763. */
  28764. set depthScale(value: number);
  28765. protected _validateFilter(filter: number): number;
  28766. protected _filter: number;
  28767. /**
  28768. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  28769. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28770. */
  28771. get filter(): number;
  28772. /**
  28773. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  28774. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28775. */
  28776. set filter(value: number);
  28777. /**
  28778. * Gets if the current filter is set to Poisson Sampling.
  28779. */
  28780. get usePoissonSampling(): boolean;
  28781. /**
  28782. * Sets the current filter to Poisson Sampling.
  28783. */
  28784. set usePoissonSampling(value: boolean);
  28785. /**
  28786. * Gets if the current filter is set to ESM.
  28787. */
  28788. get useExponentialShadowMap(): boolean;
  28789. /**
  28790. * Sets the current filter is to ESM.
  28791. */
  28792. set useExponentialShadowMap(value: boolean);
  28793. /**
  28794. * Gets if the current filter is set to filtered ESM.
  28795. */
  28796. get useBlurExponentialShadowMap(): boolean;
  28797. /**
  28798. * Gets if the current filter is set to filtered ESM.
  28799. */
  28800. set useBlurExponentialShadowMap(value: boolean);
  28801. /**
  28802. * Gets if the current filter is set to "close ESM" (using the inverse of the
  28803. * exponential to prevent steep falloff artifacts).
  28804. */
  28805. get useCloseExponentialShadowMap(): boolean;
  28806. /**
  28807. * Sets the current filter to "close ESM" (using the inverse of the
  28808. * exponential to prevent steep falloff artifacts).
  28809. */
  28810. set useCloseExponentialShadowMap(value: boolean);
  28811. /**
  28812. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  28813. * exponential to prevent steep falloff artifacts).
  28814. */
  28815. get useBlurCloseExponentialShadowMap(): boolean;
  28816. /**
  28817. * Sets the current filter to filtered "close ESM" (using the inverse of the
  28818. * exponential to prevent steep falloff artifacts).
  28819. */
  28820. set useBlurCloseExponentialShadowMap(value: boolean);
  28821. /**
  28822. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  28823. */
  28824. get usePercentageCloserFiltering(): boolean;
  28825. /**
  28826. * Sets the current filter to "PCF" (percentage closer filtering).
  28827. */
  28828. set usePercentageCloserFiltering(value: boolean);
  28829. protected _filteringQuality: number;
  28830. /**
  28831. * Gets the PCF or PCSS Quality.
  28832. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28833. */
  28834. get filteringQuality(): number;
  28835. /**
  28836. * Sets the PCF or PCSS Quality.
  28837. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28838. */
  28839. set filteringQuality(filteringQuality: number);
  28840. /**
  28841. * Gets if the current filter is set to "PCSS" (contact hardening).
  28842. */
  28843. get useContactHardeningShadow(): boolean;
  28844. /**
  28845. * Sets the current filter to "PCSS" (contact hardening).
  28846. */
  28847. set useContactHardeningShadow(value: boolean);
  28848. protected _contactHardeningLightSizeUVRatio: number;
  28849. /**
  28850. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28851. * Using a ratio helps keeping shape stability independently of the map size.
  28852. *
  28853. * It does not account for the light projection as it was having too much
  28854. * instability during the light setup or during light position changes.
  28855. *
  28856. * Only valid if useContactHardeningShadow is true.
  28857. */
  28858. get contactHardeningLightSizeUVRatio(): number;
  28859. /**
  28860. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28861. * Using a ratio helps keeping shape stability independently of the map size.
  28862. *
  28863. * It does not account for the light projection as it was having too much
  28864. * instability during the light setup or during light position changes.
  28865. *
  28866. * Only valid if useContactHardeningShadow is true.
  28867. */
  28868. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  28869. protected _darkness: number;
  28870. /** Gets or sets the actual darkness of a shadow */
  28871. get darkness(): number;
  28872. set darkness(value: number);
  28873. /**
  28874. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  28875. * 0 means strongest and 1 would means no shadow.
  28876. * @returns the darkness.
  28877. */
  28878. getDarkness(): number;
  28879. /**
  28880. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  28881. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  28882. * @returns the shadow generator allowing fluent coding.
  28883. */
  28884. setDarkness(darkness: number): ShadowGenerator;
  28885. protected _transparencyShadow: boolean;
  28886. /** Gets or sets the ability to have transparent shadow */
  28887. get transparencyShadow(): boolean;
  28888. set transparencyShadow(value: boolean);
  28889. /**
  28890. * Sets the ability to have transparent shadow (boolean).
  28891. * @param transparent True if transparent else False
  28892. * @returns the shadow generator allowing fluent coding
  28893. */
  28894. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  28895. /**
  28896. * Enables or disables shadows with varying strength based on the transparency
  28897. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  28898. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  28899. * mesh.visibility * alphaTexture.a
  28900. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  28901. */
  28902. enableSoftTransparentShadow: boolean;
  28903. protected _shadowMap: Nullable<RenderTargetTexture>;
  28904. protected _shadowMap2: Nullable<RenderTargetTexture>;
  28905. /**
  28906. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28907. * @returns The render target texture if present otherwise, null
  28908. */
  28909. getShadowMap(): Nullable<RenderTargetTexture>;
  28910. /**
  28911. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  28912. * @returns The render target texture if the shadow map is present otherwise, null
  28913. */
  28914. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  28915. /**
  28916. * Gets the class name of that object
  28917. * @returns "ShadowGenerator"
  28918. */
  28919. getClassName(): string;
  28920. /**
  28921. * Helper function to add a mesh and its descendants to the list of shadow casters.
  28922. * @param mesh Mesh to add
  28923. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  28924. * @returns the Shadow Generator itself
  28925. */
  28926. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  28927. /**
  28928. * Helper function to remove a mesh and its descendants from the list of shadow casters
  28929. * @param mesh Mesh to remove
  28930. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  28931. * @returns the Shadow Generator itself
  28932. */
  28933. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  28934. /**
  28935. * Controls the extent to which the shadows fade out at the edge of the frustum
  28936. */
  28937. frustumEdgeFalloff: number;
  28938. protected _light: IShadowLight;
  28939. /**
  28940. * Returns the associated light object.
  28941. * @returns the light generating the shadow
  28942. */
  28943. getLight(): IShadowLight;
  28944. /**
  28945. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  28946. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  28947. * It might on the other hand introduce peter panning.
  28948. */
  28949. forceBackFacesOnly: boolean;
  28950. protected _scene: Scene;
  28951. protected _lightDirection: Vector3;
  28952. protected _effect: Effect;
  28953. protected _viewMatrix: Matrix;
  28954. protected _projectionMatrix: Matrix;
  28955. protected _transformMatrix: Matrix;
  28956. protected _cachedPosition: Vector3;
  28957. protected _cachedDirection: Vector3;
  28958. protected _cachedDefines: string;
  28959. protected _currentRenderID: number;
  28960. protected _boxBlurPostprocess: Nullable<PostProcess>;
  28961. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  28962. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  28963. protected _blurPostProcesses: PostProcess[];
  28964. protected _mapSize: number;
  28965. protected _currentFaceIndex: number;
  28966. protected _currentFaceIndexCache: number;
  28967. protected _textureType: number;
  28968. protected _defaultTextureMatrix: Matrix;
  28969. protected _storedUniqueId: Nullable<number>;
  28970. /** @hidden */
  28971. static _SceneComponentInitialization: (scene: Scene) => void;
  28972. /**
  28973. * Gets or sets the size of the texture what stores the shadows
  28974. */
  28975. get mapSize(): number;
  28976. set mapSize(size: number);
  28977. /**
  28978. * Creates a ShadowGenerator object.
  28979. * A ShadowGenerator is the required tool to use the shadows.
  28980. * Each light casting shadows needs to use its own ShadowGenerator.
  28981. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  28982. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  28983. * @param light The light object generating the shadows.
  28984. * @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.
  28985. */
  28986. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  28987. protected _initializeGenerator(): void;
  28988. protected _createTargetRenderTexture(): void;
  28989. protected _initializeShadowMap(): void;
  28990. protected _initializeBlurRTTAndPostProcesses(): void;
  28991. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  28992. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  28993. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  28994. protected _applyFilterValues(): void;
  28995. /**
  28996. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28997. * @param onCompiled Callback triggered at the and of the effects compilation
  28998. * @param options Sets of optional options forcing the compilation with different modes
  28999. */
  29000. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29001. useInstances: boolean;
  29002. }>): void;
  29003. /**
  29004. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29005. * @param options Sets of optional options forcing the compilation with different modes
  29006. * @returns A promise that resolves when the compilation completes
  29007. */
  29008. forceCompilationAsync(options?: Partial<{
  29009. useInstances: boolean;
  29010. }>): Promise<void>;
  29011. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29012. private _prepareShadowDefines;
  29013. /**
  29014. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29015. * @param subMesh The submesh we want to render in the shadow map
  29016. * @param useInstances Defines wether will draw in the map using instances
  29017. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29018. * @returns true if ready otherwise, false
  29019. */
  29020. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29021. /**
  29022. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29023. * @param defines Defines of the material we want to update
  29024. * @param lightIndex Index of the light in the enabled light list of the material
  29025. */
  29026. prepareDefines(defines: any, lightIndex: number): void;
  29027. /**
  29028. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29029. * defined in the generator but impacting the effect).
  29030. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29031. * @param effect The effect we are binfing the information for
  29032. */
  29033. bindShadowLight(lightIndex: string, effect: Effect): void;
  29034. /**
  29035. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29036. * (eq to shadow prjection matrix * light transform matrix)
  29037. * @returns The transform matrix used to create the shadow map
  29038. */
  29039. getTransformMatrix(): Matrix;
  29040. /**
  29041. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29042. * Cube and 2D textures for instance.
  29043. */
  29044. recreateShadowMap(): void;
  29045. protected _disposeBlurPostProcesses(): void;
  29046. protected _disposeRTTandPostProcesses(): void;
  29047. /**
  29048. * Disposes the ShadowGenerator.
  29049. * Returns nothing.
  29050. */
  29051. dispose(): void;
  29052. /**
  29053. * Serializes the shadow generator setup to a json object.
  29054. * @returns The serialized JSON object
  29055. */
  29056. serialize(): any;
  29057. /**
  29058. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29059. * @param parsedShadowGenerator The JSON object to parse
  29060. * @param scene The scene to create the shadow map for
  29061. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29062. * @returns The parsed shadow generator
  29063. */
  29064. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29065. }
  29066. }
  29067. declare module BABYLON {
  29068. /**
  29069. * Options to be used when creating a shadow depth material
  29070. */
  29071. export interface IIOptionShadowDepthMaterial {
  29072. /** Variables in the vertex shader code that need to have their names remapped.
  29073. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29074. * "var_name" should be either: worldPos or vNormalW
  29075. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29076. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29077. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29078. */
  29079. remappedVariables?: string[];
  29080. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29081. standalone?: boolean;
  29082. }
  29083. /**
  29084. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29085. */
  29086. export class ShadowDepthWrapper {
  29087. private _scene;
  29088. private _options?;
  29089. private _baseMaterial;
  29090. private _onEffectCreatedObserver;
  29091. private _subMeshToEffect;
  29092. private _subMeshToDepthEffect;
  29093. private _meshes;
  29094. /** @hidden */
  29095. _matriceNames: any;
  29096. /** Gets the standalone status of the wrapper */
  29097. get standalone(): boolean;
  29098. /** Gets the base material the wrapper is built upon */
  29099. get baseMaterial(): Material;
  29100. /**
  29101. * Instantiate a new shadow depth wrapper.
  29102. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29103. * generate the shadow depth map. For more information, please refer to the documentation:
  29104. * https://doc.babylonjs.com/babylon101/shadows
  29105. * @param baseMaterial Material to wrap
  29106. * @param scene Define the scene the material belongs to
  29107. * @param options Options used to create the wrapper
  29108. */
  29109. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29110. /**
  29111. * Gets the effect to use to generate the depth map
  29112. * @param subMesh subMesh to get the effect for
  29113. * @param shadowGenerator shadow generator to get the effect for
  29114. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29115. */
  29116. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29117. /**
  29118. * Specifies that the submesh is ready to be used for depth rendering
  29119. * @param subMesh submesh to check
  29120. * @param defines the list of defines to take into account when checking the effect
  29121. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29122. * @param useInstances specifies that instances should be used
  29123. * @returns a boolean indicating that the submesh is ready or not
  29124. */
  29125. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29126. /**
  29127. * Disposes the resources
  29128. */
  29129. dispose(): void;
  29130. private _makeEffect;
  29131. }
  29132. }
  29133. declare module BABYLON {
  29134. /**
  29135. * Options for compiling materials.
  29136. */
  29137. export interface IMaterialCompilationOptions {
  29138. /**
  29139. * Defines whether clip planes are enabled.
  29140. */
  29141. clipPlane: boolean;
  29142. /**
  29143. * Defines whether instances are enabled.
  29144. */
  29145. useInstances: boolean;
  29146. }
  29147. /**
  29148. * Options passed when calling customShaderNameResolve
  29149. */
  29150. export interface ICustomShaderNameResolveOptions {
  29151. /**
  29152. * 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
  29153. */
  29154. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29155. }
  29156. /**
  29157. * Base class for the main features of a material in Babylon.js
  29158. */
  29159. export class Material implements IAnimatable {
  29160. /**
  29161. * Returns the triangle fill mode
  29162. */
  29163. static readonly TriangleFillMode: number;
  29164. /**
  29165. * Returns the wireframe mode
  29166. */
  29167. static readonly WireFrameFillMode: number;
  29168. /**
  29169. * Returns the point fill mode
  29170. */
  29171. static readonly PointFillMode: number;
  29172. /**
  29173. * Returns the point list draw mode
  29174. */
  29175. static readonly PointListDrawMode: number;
  29176. /**
  29177. * Returns the line list draw mode
  29178. */
  29179. static readonly LineListDrawMode: number;
  29180. /**
  29181. * Returns the line loop draw mode
  29182. */
  29183. static readonly LineLoopDrawMode: number;
  29184. /**
  29185. * Returns the line strip draw mode
  29186. */
  29187. static readonly LineStripDrawMode: number;
  29188. /**
  29189. * Returns the triangle strip draw mode
  29190. */
  29191. static readonly TriangleStripDrawMode: number;
  29192. /**
  29193. * Returns the triangle fan draw mode
  29194. */
  29195. static readonly TriangleFanDrawMode: number;
  29196. /**
  29197. * Stores the clock-wise side orientation
  29198. */
  29199. static readonly ClockWiseSideOrientation: number;
  29200. /**
  29201. * Stores the counter clock-wise side orientation
  29202. */
  29203. static readonly CounterClockWiseSideOrientation: number;
  29204. /**
  29205. * The dirty texture flag value
  29206. */
  29207. static readonly TextureDirtyFlag: number;
  29208. /**
  29209. * The dirty light flag value
  29210. */
  29211. static readonly LightDirtyFlag: number;
  29212. /**
  29213. * The dirty fresnel flag value
  29214. */
  29215. static readonly FresnelDirtyFlag: number;
  29216. /**
  29217. * The dirty attribute flag value
  29218. */
  29219. static readonly AttributesDirtyFlag: number;
  29220. /**
  29221. * The dirty misc flag value
  29222. */
  29223. static readonly MiscDirtyFlag: number;
  29224. /**
  29225. * The dirty prepass flag value
  29226. */
  29227. static readonly PrePassDirtyFlag: number;
  29228. /**
  29229. * The all dirty flag value
  29230. */
  29231. static readonly AllDirtyFlag: number;
  29232. /**
  29233. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29234. */
  29235. static readonly MATERIAL_OPAQUE: number;
  29236. /**
  29237. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29238. */
  29239. static readonly MATERIAL_ALPHATEST: number;
  29240. /**
  29241. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29242. */
  29243. static readonly MATERIAL_ALPHABLEND: number;
  29244. /**
  29245. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29246. * They are also discarded below the alpha cutoff threshold to improve performances.
  29247. */
  29248. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29249. /**
  29250. * The Whiteout method is used to blend normals.
  29251. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29252. */
  29253. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29254. /**
  29255. * The Reoriented Normal Mapping method is used to blend normals.
  29256. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29257. */
  29258. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29259. /**
  29260. * Custom callback helping to override the default shader used in the material.
  29261. */
  29262. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29263. /**
  29264. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29265. */
  29266. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29267. /**
  29268. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29269. * This means that the material can keep using a previous shader while a new one is being compiled.
  29270. * This is mostly used when shader parallel compilation is supported (true by default)
  29271. */
  29272. allowShaderHotSwapping: boolean;
  29273. /**
  29274. * The ID of the material
  29275. */
  29276. id: string;
  29277. /**
  29278. * Gets or sets the unique id of the material
  29279. */
  29280. uniqueId: number;
  29281. /**
  29282. * The name of the material
  29283. */
  29284. name: string;
  29285. /**
  29286. * Gets or sets user defined metadata
  29287. */
  29288. metadata: any;
  29289. /**
  29290. * For internal use only. Please do not use.
  29291. */
  29292. reservedDataStore: any;
  29293. /**
  29294. * Specifies if the ready state should be checked on each call
  29295. */
  29296. checkReadyOnEveryCall: boolean;
  29297. /**
  29298. * Specifies if the ready state should be checked once
  29299. */
  29300. checkReadyOnlyOnce: boolean;
  29301. /**
  29302. * The state of the material
  29303. */
  29304. state: string;
  29305. /**
  29306. * If the material can be rendered to several textures with MRT extension
  29307. */
  29308. get canRenderToMRT(): boolean;
  29309. /**
  29310. * The alpha value of the material
  29311. */
  29312. protected _alpha: number;
  29313. /**
  29314. * List of inspectable custom properties (used by the Inspector)
  29315. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29316. */
  29317. inspectableCustomProperties: IInspectable[];
  29318. /**
  29319. * Sets the alpha value of the material
  29320. */
  29321. set alpha(value: number);
  29322. /**
  29323. * Gets the alpha value of the material
  29324. */
  29325. get alpha(): number;
  29326. /**
  29327. * Specifies if back face culling is enabled
  29328. */
  29329. protected _backFaceCulling: boolean;
  29330. /**
  29331. * Sets the back-face culling state
  29332. */
  29333. set backFaceCulling(value: boolean);
  29334. /**
  29335. * Gets the back-face culling state
  29336. */
  29337. get backFaceCulling(): boolean;
  29338. /**
  29339. * Stores the value for side orientation
  29340. */
  29341. sideOrientation: number;
  29342. /**
  29343. * Callback triggered when the material is compiled
  29344. */
  29345. onCompiled: Nullable<(effect: Effect) => void>;
  29346. /**
  29347. * Callback triggered when an error occurs
  29348. */
  29349. onError: Nullable<(effect: Effect, errors: string) => void>;
  29350. /**
  29351. * Callback triggered to get the render target textures
  29352. */
  29353. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29354. /**
  29355. * Gets a boolean indicating that current material needs to register RTT
  29356. */
  29357. get hasRenderTargetTextures(): boolean;
  29358. /**
  29359. * Specifies if the material should be serialized
  29360. */
  29361. doNotSerialize: boolean;
  29362. /**
  29363. * @hidden
  29364. */
  29365. _storeEffectOnSubMeshes: boolean;
  29366. /**
  29367. * Stores the animations for the material
  29368. */
  29369. animations: Nullable<Array<Animation>>;
  29370. /**
  29371. * An event triggered when the material is disposed
  29372. */
  29373. onDisposeObservable: Observable<Material>;
  29374. /**
  29375. * An observer which watches for dispose events
  29376. */
  29377. private _onDisposeObserver;
  29378. private _onUnBindObservable;
  29379. /**
  29380. * Called during a dispose event
  29381. */
  29382. set onDispose(callback: () => void);
  29383. private _onBindObservable;
  29384. /**
  29385. * An event triggered when the material is bound
  29386. */
  29387. get onBindObservable(): Observable<AbstractMesh>;
  29388. /**
  29389. * An observer which watches for bind events
  29390. */
  29391. private _onBindObserver;
  29392. /**
  29393. * Called during a bind event
  29394. */
  29395. set onBind(callback: (Mesh: AbstractMesh) => void);
  29396. /**
  29397. * An event triggered when the material is unbound
  29398. */
  29399. get onUnBindObservable(): Observable<Material>;
  29400. protected _onEffectCreatedObservable: Nullable<Observable<{
  29401. effect: Effect;
  29402. subMesh: Nullable<SubMesh>;
  29403. }>>;
  29404. /**
  29405. * An event triggered when the effect is (re)created
  29406. */
  29407. get onEffectCreatedObservable(): Observable<{
  29408. effect: Effect;
  29409. subMesh: Nullable<SubMesh>;
  29410. }>;
  29411. /**
  29412. * Stores the value of the alpha mode
  29413. */
  29414. private _alphaMode;
  29415. /**
  29416. * Sets the value of the alpha mode.
  29417. *
  29418. * | Value | Type | Description |
  29419. * | --- | --- | --- |
  29420. * | 0 | ALPHA_DISABLE | |
  29421. * | 1 | ALPHA_ADD | |
  29422. * | 2 | ALPHA_COMBINE | |
  29423. * | 3 | ALPHA_SUBTRACT | |
  29424. * | 4 | ALPHA_MULTIPLY | |
  29425. * | 5 | ALPHA_MAXIMIZED | |
  29426. * | 6 | ALPHA_ONEONE | |
  29427. * | 7 | ALPHA_PREMULTIPLIED | |
  29428. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29429. * | 9 | ALPHA_INTERPOLATE | |
  29430. * | 10 | ALPHA_SCREENMODE | |
  29431. *
  29432. */
  29433. set alphaMode(value: number);
  29434. /**
  29435. * Gets the value of the alpha mode
  29436. */
  29437. get alphaMode(): number;
  29438. /**
  29439. * Stores the state of the need depth pre-pass value
  29440. */
  29441. private _needDepthPrePass;
  29442. /**
  29443. * Sets the need depth pre-pass value
  29444. */
  29445. set needDepthPrePass(value: boolean);
  29446. /**
  29447. * Gets the depth pre-pass value
  29448. */
  29449. get needDepthPrePass(): boolean;
  29450. /**
  29451. * Specifies if depth writing should be disabled
  29452. */
  29453. disableDepthWrite: boolean;
  29454. /**
  29455. * Specifies if color writing should be disabled
  29456. */
  29457. disableColorWrite: boolean;
  29458. /**
  29459. * Specifies if depth writing should be forced
  29460. */
  29461. forceDepthWrite: boolean;
  29462. /**
  29463. * Specifies the depth function that should be used. 0 means the default engine function
  29464. */
  29465. depthFunction: number;
  29466. /**
  29467. * Specifies if there should be a separate pass for culling
  29468. */
  29469. separateCullingPass: boolean;
  29470. /**
  29471. * Stores the state specifing if fog should be enabled
  29472. */
  29473. private _fogEnabled;
  29474. /**
  29475. * Sets the state for enabling fog
  29476. */
  29477. set fogEnabled(value: boolean);
  29478. /**
  29479. * Gets the value of the fog enabled state
  29480. */
  29481. get fogEnabled(): boolean;
  29482. /**
  29483. * Stores the size of points
  29484. */
  29485. pointSize: number;
  29486. /**
  29487. * Stores the z offset value
  29488. */
  29489. zOffset: number;
  29490. get wireframe(): boolean;
  29491. /**
  29492. * Sets the state of wireframe mode
  29493. */
  29494. set wireframe(value: boolean);
  29495. /**
  29496. * Gets the value specifying if point clouds are enabled
  29497. */
  29498. get pointsCloud(): boolean;
  29499. /**
  29500. * Sets the state of point cloud mode
  29501. */
  29502. set pointsCloud(value: boolean);
  29503. /**
  29504. * Gets the material fill mode
  29505. */
  29506. get fillMode(): number;
  29507. /**
  29508. * Sets the material fill mode
  29509. */
  29510. set fillMode(value: number);
  29511. /**
  29512. * @hidden
  29513. * Stores the effects for the material
  29514. */
  29515. _effect: Nullable<Effect>;
  29516. /**
  29517. * Specifies if uniform buffers should be used
  29518. */
  29519. private _useUBO;
  29520. /**
  29521. * Stores a reference to the scene
  29522. */
  29523. private _scene;
  29524. /**
  29525. * Stores the fill mode state
  29526. */
  29527. private _fillMode;
  29528. /**
  29529. * Specifies if the depth write state should be cached
  29530. */
  29531. private _cachedDepthWriteState;
  29532. /**
  29533. * Specifies if the color write state should be cached
  29534. */
  29535. private _cachedColorWriteState;
  29536. /**
  29537. * Specifies if the depth function state should be cached
  29538. */
  29539. private _cachedDepthFunctionState;
  29540. /**
  29541. * Stores the uniform buffer
  29542. */
  29543. protected _uniformBuffer: UniformBuffer;
  29544. /** @hidden */
  29545. _indexInSceneMaterialArray: number;
  29546. /** @hidden */
  29547. meshMap: Nullable<{
  29548. [id: string]: AbstractMesh | undefined;
  29549. }>;
  29550. /**
  29551. * Creates a material instance
  29552. * @param name defines the name of the material
  29553. * @param scene defines the scene to reference
  29554. * @param doNotAdd specifies if the material should be added to the scene
  29555. */
  29556. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29557. /**
  29558. * Returns a string representation of the current material
  29559. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29560. * @returns a string with material information
  29561. */
  29562. toString(fullDetails?: boolean): string;
  29563. /**
  29564. * Gets the class name of the material
  29565. * @returns a string with the class name of the material
  29566. */
  29567. getClassName(): string;
  29568. /**
  29569. * Specifies if updates for the material been locked
  29570. */
  29571. get isFrozen(): boolean;
  29572. /**
  29573. * Locks updates for the material
  29574. */
  29575. freeze(): void;
  29576. /**
  29577. * Unlocks updates for the material
  29578. */
  29579. unfreeze(): void;
  29580. /**
  29581. * Specifies if the material is ready to be used
  29582. * @param mesh defines the mesh to check
  29583. * @param useInstances specifies if instances should be used
  29584. * @returns a boolean indicating if the material is ready to be used
  29585. */
  29586. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29587. /**
  29588. * Specifies that the submesh is ready to be used
  29589. * @param mesh defines the mesh to check
  29590. * @param subMesh defines which submesh to check
  29591. * @param useInstances specifies that instances should be used
  29592. * @returns a boolean indicating that the submesh is ready or not
  29593. */
  29594. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29595. /**
  29596. * Returns the material effect
  29597. * @returns the effect associated with the material
  29598. */
  29599. getEffect(): Nullable<Effect>;
  29600. /**
  29601. * Returns the current scene
  29602. * @returns a Scene
  29603. */
  29604. getScene(): Scene;
  29605. /**
  29606. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29607. */
  29608. protected _forceAlphaTest: boolean;
  29609. /**
  29610. * The transparency mode of the material.
  29611. */
  29612. protected _transparencyMode: Nullable<number>;
  29613. /**
  29614. * Gets the current transparency mode.
  29615. */
  29616. get transparencyMode(): Nullable<number>;
  29617. /**
  29618. * Sets the transparency mode of the material.
  29619. *
  29620. * | Value | Type | Description |
  29621. * | ----- | ----------------------------------- | ----------- |
  29622. * | 0 | OPAQUE | |
  29623. * | 1 | ALPHATEST | |
  29624. * | 2 | ALPHABLEND | |
  29625. * | 3 | ALPHATESTANDBLEND | |
  29626. *
  29627. */
  29628. set transparencyMode(value: Nullable<number>);
  29629. /**
  29630. * Returns true if alpha blending should be disabled.
  29631. */
  29632. protected get _disableAlphaBlending(): boolean;
  29633. /**
  29634. * Specifies whether or not this material should be rendered in alpha blend mode.
  29635. * @returns a boolean specifying if alpha blending is needed
  29636. */
  29637. needAlphaBlending(): boolean;
  29638. /**
  29639. * Specifies if the mesh will require alpha blending
  29640. * @param mesh defines the mesh to check
  29641. * @returns a boolean specifying if alpha blending is needed for the mesh
  29642. */
  29643. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29644. /**
  29645. * Specifies whether or not this material should be rendered in alpha test mode.
  29646. * @returns a boolean specifying if an alpha test is needed.
  29647. */
  29648. needAlphaTesting(): boolean;
  29649. /**
  29650. * Specifies if material alpha testing should be turned on for the mesh
  29651. * @param mesh defines the mesh to check
  29652. */
  29653. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29654. /**
  29655. * Gets the texture used for the alpha test
  29656. * @returns the texture to use for alpha testing
  29657. */
  29658. getAlphaTestTexture(): Nullable<BaseTexture>;
  29659. /**
  29660. * Marks the material to indicate that it needs to be re-calculated
  29661. */
  29662. markDirty(): void;
  29663. /** @hidden */
  29664. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29665. /**
  29666. * Binds the material to the mesh
  29667. * @param world defines the world transformation matrix
  29668. * @param mesh defines the mesh to bind the material to
  29669. */
  29670. bind(world: Matrix, mesh?: Mesh): void;
  29671. /**
  29672. * Binds the submesh to the material
  29673. * @param world defines the world transformation matrix
  29674. * @param mesh defines the mesh containing the submesh
  29675. * @param subMesh defines the submesh to bind the material to
  29676. */
  29677. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29678. /**
  29679. * Binds the world matrix to the material
  29680. * @param world defines the world transformation matrix
  29681. */
  29682. bindOnlyWorldMatrix(world: Matrix): void;
  29683. /**
  29684. * Binds the scene's uniform buffer to the effect.
  29685. * @param effect defines the effect to bind to the scene uniform buffer
  29686. * @param sceneUbo defines the uniform buffer storing scene data
  29687. */
  29688. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29689. /**
  29690. * Binds the view matrix to the effect
  29691. * @param effect defines the effect to bind the view matrix to
  29692. */
  29693. bindView(effect: Effect): void;
  29694. /**
  29695. * Binds the view projection matrix to the effect
  29696. * @param effect defines the effect to bind the view projection matrix to
  29697. */
  29698. bindViewProjection(effect: Effect): void;
  29699. /**
  29700. * Processes to execute after binding the material to a mesh
  29701. * @param mesh defines the rendered mesh
  29702. */
  29703. protected _afterBind(mesh?: Mesh): void;
  29704. /**
  29705. * Unbinds the material from the mesh
  29706. */
  29707. unbind(): void;
  29708. /**
  29709. * Gets the active textures from the material
  29710. * @returns an array of textures
  29711. */
  29712. getActiveTextures(): BaseTexture[];
  29713. /**
  29714. * Specifies if the material uses a texture
  29715. * @param texture defines the texture to check against the material
  29716. * @returns a boolean specifying if the material uses the texture
  29717. */
  29718. hasTexture(texture: BaseTexture): boolean;
  29719. /**
  29720. * Makes a duplicate of the material, and gives it a new name
  29721. * @param name defines the new name for the duplicated material
  29722. * @returns the cloned material
  29723. */
  29724. clone(name: string): Nullable<Material>;
  29725. /**
  29726. * Gets the meshes bound to the material
  29727. * @returns an array of meshes bound to the material
  29728. */
  29729. getBindedMeshes(): AbstractMesh[];
  29730. /**
  29731. * Force shader compilation
  29732. * @param mesh defines the mesh associated with this material
  29733. * @param onCompiled defines a function to execute once the material is compiled
  29734. * @param options defines the options to configure the compilation
  29735. * @param onError defines a function to execute if the material fails compiling
  29736. */
  29737. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29738. /**
  29739. * Force shader compilation
  29740. * @param mesh defines the mesh that will use this material
  29741. * @param options defines additional options for compiling the shaders
  29742. * @returns a promise that resolves when the compilation completes
  29743. */
  29744. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29745. private static readonly _AllDirtyCallBack;
  29746. private static readonly _ImageProcessingDirtyCallBack;
  29747. private static readonly _TextureDirtyCallBack;
  29748. private static readonly _FresnelDirtyCallBack;
  29749. private static readonly _MiscDirtyCallBack;
  29750. private static readonly _PrePassDirtyCallBack;
  29751. private static readonly _LightsDirtyCallBack;
  29752. private static readonly _AttributeDirtyCallBack;
  29753. private static _FresnelAndMiscDirtyCallBack;
  29754. private static _TextureAndMiscDirtyCallBack;
  29755. private static readonly _DirtyCallbackArray;
  29756. private static readonly _RunDirtyCallBacks;
  29757. /**
  29758. * Marks a define in the material to indicate that it needs to be re-computed
  29759. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29760. */
  29761. markAsDirty(flag: number): void;
  29762. /**
  29763. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29764. * @param func defines a function which checks material defines against the submeshes
  29765. */
  29766. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29767. /**
  29768. * Indicates that the scene should check if the rendering now needs a prepass
  29769. */
  29770. protected _markScenePrePassDirty(): void;
  29771. /**
  29772. * Indicates that we need to re-calculated for all submeshes
  29773. */
  29774. protected _markAllSubMeshesAsAllDirty(): void;
  29775. /**
  29776. * Indicates that image processing needs to be re-calculated for all submeshes
  29777. */
  29778. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29779. /**
  29780. * Indicates that textures need to be re-calculated for all submeshes
  29781. */
  29782. protected _markAllSubMeshesAsTexturesDirty(): void;
  29783. /**
  29784. * Indicates that fresnel needs to be re-calculated for all submeshes
  29785. */
  29786. protected _markAllSubMeshesAsFresnelDirty(): void;
  29787. /**
  29788. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29789. */
  29790. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29791. /**
  29792. * Indicates that lights need to be re-calculated for all submeshes
  29793. */
  29794. protected _markAllSubMeshesAsLightsDirty(): void;
  29795. /**
  29796. * Indicates that attributes need to be re-calculated for all submeshes
  29797. */
  29798. protected _markAllSubMeshesAsAttributesDirty(): void;
  29799. /**
  29800. * Indicates that misc needs to be re-calculated for all submeshes
  29801. */
  29802. protected _markAllSubMeshesAsMiscDirty(): void;
  29803. /**
  29804. * Indicates that prepass needs to be re-calculated for all submeshes
  29805. */
  29806. protected _markAllSubMeshesAsPrePassDirty(): void;
  29807. /**
  29808. * Indicates that textures and misc need to be re-calculated for all submeshes
  29809. */
  29810. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29811. /**
  29812. * Sets the required values to the prepass renderer.
  29813. * @param prePassRenderer defines the prepass renderer to setup.
  29814. * @returns true if the pre pass is needed.
  29815. */
  29816. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29817. /**
  29818. * Disposes the material
  29819. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29820. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29821. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29822. */
  29823. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29824. /** @hidden */
  29825. private releaseVertexArrayObject;
  29826. /**
  29827. * Serializes this material
  29828. * @returns the serialized material object
  29829. */
  29830. serialize(): any;
  29831. /**
  29832. * Creates a material from parsed material data
  29833. * @param parsedMaterial defines parsed material data
  29834. * @param scene defines the hosting scene
  29835. * @param rootUrl defines the root URL to use to load textures
  29836. * @returns a new material
  29837. */
  29838. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29839. }
  29840. }
  29841. declare module BABYLON {
  29842. /**
  29843. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29844. * separate meshes. This can be use to improve performances.
  29845. * @see https://doc.babylonjs.com/how_to/multi_materials
  29846. */
  29847. export class MultiMaterial extends Material {
  29848. private _subMaterials;
  29849. /**
  29850. * Gets or Sets the list of Materials used within the multi material.
  29851. * They need to be ordered according to the submeshes order in the associated mesh
  29852. */
  29853. get subMaterials(): Nullable<Material>[];
  29854. set subMaterials(value: Nullable<Material>[]);
  29855. /**
  29856. * Function used to align with Node.getChildren()
  29857. * @returns the list of Materials used within the multi material
  29858. */
  29859. getChildren(): Nullable<Material>[];
  29860. /**
  29861. * Instantiates a new Multi Material
  29862. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29863. * separate meshes. This can be use to improve performances.
  29864. * @see https://doc.babylonjs.com/how_to/multi_materials
  29865. * @param name Define the name in the scene
  29866. * @param scene Define the scene the material belongs to
  29867. */
  29868. constructor(name: string, scene: Scene);
  29869. private _hookArray;
  29870. /**
  29871. * Get one of the submaterial by its index in the submaterials array
  29872. * @param index The index to look the sub material at
  29873. * @returns The Material if the index has been defined
  29874. */
  29875. getSubMaterial(index: number): Nullable<Material>;
  29876. /**
  29877. * Get the list of active textures for the whole sub materials list.
  29878. * @returns All the textures that will be used during the rendering
  29879. */
  29880. getActiveTextures(): BaseTexture[];
  29881. /**
  29882. * Gets the current class name of the material e.g. "MultiMaterial"
  29883. * Mainly use in serialization.
  29884. * @returns the class name
  29885. */
  29886. getClassName(): string;
  29887. /**
  29888. * Checks if the material is ready to render the requested sub mesh
  29889. * @param mesh Define the mesh the submesh belongs to
  29890. * @param subMesh Define the sub mesh to look readyness for
  29891. * @param useInstances Define whether or not the material is used with instances
  29892. * @returns true if ready, otherwise false
  29893. */
  29894. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29895. /**
  29896. * Clones the current material and its related sub materials
  29897. * @param name Define the name of the newly cloned material
  29898. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29899. * @returns the cloned material
  29900. */
  29901. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29902. /**
  29903. * Serializes the materials into a JSON representation.
  29904. * @returns the JSON representation
  29905. */
  29906. serialize(): any;
  29907. /**
  29908. * Dispose the material and release its associated resources
  29909. * @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)
  29910. * @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)
  29911. * @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)
  29912. */
  29913. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29914. /**
  29915. * Creates a MultiMaterial from parsed MultiMaterial data.
  29916. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29917. * @param scene defines the hosting scene
  29918. * @returns a new MultiMaterial
  29919. */
  29920. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29921. }
  29922. }
  29923. declare module BABYLON {
  29924. /**
  29925. * Defines a subdivision inside a mesh
  29926. */
  29927. export class SubMesh implements ICullable {
  29928. /** the material index to use */
  29929. materialIndex: number;
  29930. /** vertex index start */
  29931. verticesStart: number;
  29932. /** vertices count */
  29933. verticesCount: number;
  29934. /** index start */
  29935. indexStart: number;
  29936. /** indices count */
  29937. indexCount: number;
  29938. /** @hidden */
  29939. _materialDefines: Nullable<MaterialDefines>;
  29940. /** @hidden */
  29941. _materialEffect: Nullable<Effect>;
  29942. /** @hidden */
  29943. _effectOverride: Nullable<Effect>;
  29944. /**
  29945. * Gets material defines used by the effect associated to the sub mesh
  29946. */
  29947. get materialDefines(): Nullable<MaterialDefines>;
  29948. /**
  29949. * Sets material defines used by the effect associated to the sub mesh
  29950. */
  29951. set materialDefines(defines: Nullable<MaterialDefines>);
  29952. /**
  29953. * Gets associated effect
  29954. */
  29955. get effect(): Nullable<Effect>;
  29956. /**
  29957. * Sets associated effect (effect used to render this submesh)
  29958. * @param effect defines the effect to associate with
  29959. * @param defines defines the set of defines used to compile this effect
  29960. */
  29961. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29962. /** @hidden */
  29963. _linesIndexCount: number;
  29964. private _mesh;
  29965. private _renderingMesh;
  29966. private _boundingInfo;
  29967. private _linesIndexBuffer;
  29968. /** @hidden */
  29969. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29970. /** @hidden */
  29971. _trianglePlanes: Plane[];
  29972. /** @hidden */
  29973. _lastColliderTransformMatrix: Nullable<Matrix>;
  29974. /** @hidden */
  29975. _renderId: number;
  29976. /** @hidden */
  29977. _alphaIndex: number;
  29978. /** @hidden */
  29979. _distanceToCamera: number;
  29980. /** @hidden */
  29981. _id: number;
  29982. private _currentMaterial;
  29983. /**
  29984. * Add a new submesh to a mesh
  29985. * @param materialIndex defines the material index to use
  29986. * @param verticesStart defines vertex index start
  29987. * @param verticesCount defines vertices count
  29988. * @param indexStart defines index start
  29989. * @param indexCount defines indices count
  29990. * @param mesh defines the parent mesh
  29991. * @param renderingMesh defines an optional rendering mesh
  29992. * @param createBoundingBox defines if bounding box should be created for this submesh
  29993. * @returns the new submesh
  29994. */
  29995. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29996. /**
  29997. * Creates a new submesh
  29998. * @param materialIndex defines the material index to use
  29999. * @param verticesStart defines vertex index start
  30000. * @param verticesCount defines vertices count
  30001. * @param indexStart defines index start
  30002. * @param indexCount defines indices count
  30003. * @param mesh defines the parent mesh
  30004. * @param renderingMesh defines an optional rendering mesh
  30005. * @param createBoundingBox defines if bounding box should be created for this submesh
  30006. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30007. */
  30008. constructor(
  30009. /** the material index to use */
  30010. materialIndex: number,
  30011. /** vertex index start */
  30012. verticesStart: number,
  30013. /** vertices count */
  30014. verticesCount: number,
  30015. /** index start */
  30016. indexStart: number,
  30017. /** indices count */
  30018. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30019. /**
  30020. * Returns true if this submesh covers the entire parent mesh
  30021. * @ignorenaming
  30022. */
  30023. get IsGlobal(): boolean;
  30024. /**
  30025. * Returns the submesh BoudingInfo object
  30026. * @returns current bounding info (or mesh's one if the submesh is global)
  30027. */
  30028. getBoundingInfo(): BoundingInfo;
  30029. /**
  30030. * Sets the submesh BoundingInfo
  30031. * @param boundingInfo defines the new bounding info to use
  30032. * @returns the SubMesh
  30033. */
  30034. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30035. /**
  30036. * Returns the mesh of the current submesh
  30037. * @return the parent mesh
  30038. */
  30039. getMesh(): AbstractMesh;
  30040. /**
  30041. * Returns the rendering mesh of the submesh
  30042. * @returns the rendering mesh (could be different from parent mesh)
  30043. */
  30044. getRenderingMesh(): Mesh;
  30045. /**
  30046. * Returns the replacement mesh of the submesh
  30047. * @returns the replacement mesh (could be different from parent mesh)
  30048. */
  30049. getReplacementMesh(): Nullable<AbstractMesh>;
  30050. /**
  30051. * Returns the effective mesh of the submesh
  30052. * @returns the effective mesh (could be different from parent mesh)
  30053. */
  30054. getEffectiveMesh(): AbstractMesh;
  30055. /**
  30056. * Returns the submesh material
  30057. * @returns null or the current material
  30058. */
  30059. getMaterial(): Nullable<Material>;
  30060. private _IsMultiMaterial;
  30061. /**
  30062. * Sets a new updated BoundingInfo object to the submesh
  30063. * @param data defines an optional position array to use to determine the bounding info
  30064. * @returns the SubMesh
  30065. */
  30066. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30067. /** @hidden */
  30068. _checkCollision(collider: Collider): boolean;
  30069. /**
  30070. * Updates the submesh BoundingInfo
  30071. * @param world defines the world matrix to use to update the bounding info
  30072. * @returns the submesh
  30073. */
  30074. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30075. /**
  30076. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30077. * @param frustumPlanes defines the frustum planes
  30078. * @returns true if the submesh is intersecting with the frustum
  30079. */
  30080. isInFrustum(frustumPlanes: Plane[]): boolean;
  30081. /**
  30082. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30083. * @param frustumPlanes defines the frustum planes
  30084. * @returns true if the submesh is inside the frustum
  30085. */
  30086. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30087. /**
  30088. * Renders the submesh
  30089. * @param enableAlphaMode defines if alpha needs to be used
  30090. * @returns the submesh
  30091. */
  30092. render(enableAlphaMode: boolean): SubMesh;
  30093. /**
  30094. * @hidden
  30095. */
  30096. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30097. /**
  30098. * Checks if the submesh intersects with a ray
  30099. * @param ray defines the ray to test
  30100. * @returns true is the passed ray intersects the submesh bounding box
  30101. */
  30102. canIntersects(ray: Ray): boolean;
  30103. /**
  30104. * Intersects current submesh with a ray
  30105. * @param ray defines the ray to test
  30106. * @param positions defines mesh's positions array
  30107. * @param indices defines mesh's indices array
  30108. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30109. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30110. * @returns intersection info or null if no intersection
  30111. */
  30112. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30113. /** @hidden */
  30114. private _intersectLines;
  30115. /** @hidden */
  30116. private _intersectUnIndexedLines;
  30117. /** @hidden */
  30118. private _intersectTriangles;
  30119. /** @hidden */
  30120. private _intersectUnIndexedTriangles;
  30121. /** @hidden */
  30122. _rebuild(): void;
  30123. /**
  30124. * Creates a new submesh from the passed mesh
  30125. * @param newMesh defines the new hosting mesh
  30126. * @param newRenderingMesh defines an optional rendering mesh
  30127. * @returns the new submesh
  30128. */
  30129. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30130. /**
  30131. * Release associated resources
  30132. */
  30133. dispose(): void;
  30134. /**
  30135. * Gets the class name
  30136. * @returns the string "SubMesh".
  30137. */
  30138. getClassName(): string;
  30139. /**
  30140. * Creates a new submesh from indices data
  30141. * @param materialIndex the index of the main mesh material
  30142. * @param startIndex the index where to start the copy in the mesh indices array
  30143. * @param indexCount the number of indices to copy then from the startIndex
  30144. * @param mesh the main mesh to create the submesh from
  30145. * @param renderingMesh the optional rendering mesh
  30146. * @returns a new submesh
  30147. */
  30148. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30149. }
  30150. }
  30151. declare module BABYLON {
  30152. /**
  30153. * Class used to represent data loading progression
  30154. */
  30155. export class SceneLoaderFlags {
  30156. private static _ForceFullSceneLoadingForIncremental;
  30157. private static _ShowLoadingScreen;
  30158. private static _CleanBoneMatrixWeights;
  30159. private static _loggingLevel;
  30160. /**
  30161. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30162. */
  30163. static get ForceFullSceneLoadingForIncremental(): boolean;
  30164. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30165. /**
  30166. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30167. */
  30168. static get ShowLoadingScreen(): boolean;
  30169. static set ShowLoadingScreen(value: boolean);
  30170. /**
  30171. * Defines the current logging level (while loading the scene)
  30172. * @ignorenaming
  30173. */
  30174. static get loggingLevel(): number;
  30175. static set loggingLevel(value: number);
  30176. /**
  30177. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30178. */
  30179. static get CleanBoneMatrixWeights(): boolean;
  30180. static set CleanBoneMatrixWeights(value: boolean);
  30181. }
  30182. }
  30183. declare module BABYLON {
  30184. /**
  30185. * Class used to store geometry data (vertex buffers + index buffer)
  30186. */
  30187. export class Geometry implements IGetSetVerticesData {
  30188. /**
  30189. * Gets or sets the ID of the geometry
  30190. */
  30191. id: string;
  30192. /**
  30193. * Gets or sets the unique ID of the geometry
  30194. */
  30195. uniqueId: number;
  30196. /**
  30197. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30198. */
  30199. delayLoadState: number;
  30200. /**
  30201. * Gets the file containing the data to load when running in delay load state
  30202. */
  30203. delayLoadingFile: Nullable<string>;
  30204. /**
  30205. * Callback called when the geometry is updated
  30206. */
  30207. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30208. private _scene;
  30209. private _engine;
  30210. private _meshes;
  30211. private _totalVertices;
  30212. /** @hidden */
  30213. _indices: IndicesArray;
  30214. /** @hidden */
  30215. _vertexBuffers: {
  30216. [key: string]: VertexBuffer;
  30217. };
  30218. private _isDisposed;
  30219. private _extend;
  30220. private _boundingBias;
  30221. /** @hidden */
  30222. _delayInfo: Array<string>;
  30223. private _indexBuffer;
  30224. private _indexBufferIsUpdatable;
  30225. /** @hidden */
  30226. _boundingInfo: Nullable<BoundingInfo>;
  30227. /** @hidden */
  30228. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30229. /** @hidden */
  30230. _softwareSkinningFrameId: number;
  30231. private _vertexArrayObjects;
  30232. private _updatable;
  30233. /** @hidden */
  30234. _positions: Nullable<Vector3[]>;
  30235. private _positionsCache;
  30236. /**
  30237. * 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
  30238. */
  30239. get boundingBias(): Vector2;
  30240. /**
  30241. * 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
  30242. */
  30243. set boundingBias(value: Vector2);
  30244. /**
  30245. * Static function used to attach a new empty geometry to a mesh
  30246. * @param mesh defines the mesh to attach the geometry to
  30247. * @returns the new Geometry
  30248. */
  30249. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30250. /** Get the list of meshes using this geometry */
  30251. get meshes(): Mesh[];
  30252. /**
  30253. * 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
  30254. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30255. */
  30256. useBoundingInfoFromGeometry: boolean;
  30257. /**
  30258. * Creates a new geometry
  30259. * @param id defines the unique ID
  30260. * @param scene defines the hosting scene
  30261. * @param vertexData defines the VertexData used to get geometry data
  30262. * @param updatable defines if geometry must be updatable (false by default)
  30263. * @param mesh defines the mesh that will be associated with the geometry
  30264. */
  30265. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30266. /**
  30267. * Gets the current extend of the geometry
  30268. */
  30269. get extend(): {
  30270. minimum: Vector3;
  30271. maximum: Vector3;
  30272. };
  30273. /**
  30274. * Gets the hosting scene
  30275. * @returns the hosting Scene
  30276. */
  30277. getScene(): Scene;
  30278. /**
  30279. * Gets the hosting engine
  30280. * @returns the hosting Engine
  30281. */
  30282. getEngine(): Engine;
  30283. /**
  30284. * Defines if the geometry is ready to use
  30285. * @returns true if the geometry is ready to be used
  30286. */
  30287. isReady(): boolean;
  30288. /**
  30289. * Gets a value indicating that the geometry should not be serialized
  30290. */
  30291. get doNotSerialize(): boolean;
  30292. /** @hidden */
  30293. _rebuild(): void;
  30294. /**
  30295. * Affects all geometry data in one call
  30296. * @param vertexData defines the geometry data
  30297. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30298. */
  30299. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30300. /**
  30301. * Set specific vertex data
  30302. * @param kind defines the data kind (Position, normal, etc...)
  30303. * @param data defines the vertex data to use
  30304. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30305. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30306. */
  30307. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30308. /**
  30309. * Removes a specific vertex data
  30310. * @param kind defines the data kind (Position, normal, etc...)
  30311. */
  30312. removeVerticesData(kind: string): void;
  30313. /**
  30314. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30315. * @param buffer defines the vertex buffer to use
  30316. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30317. */
  30318. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30319. /**
  30320. * Update a specific vertex buffer
  30321. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30322. * It will do nothing if the buffer is not updatable
  30323. * @param kind defines the data kind (Position, normal, etc...)
  30324. * @param data defines the data to use
  30325. * @param offset defines the offset in the target buffer where to store the data
  30326. * @param useBytes set to true if the offset is in bytes
  30327. */
  30328. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30329. /**
  30330. * Update a specific vertex buffer
  30331. * This function will create a new buffer if the current one is not updatable
  30332. * @param kind defines the data kind (Position, normal, etc...)
  30333. * @param data defines the data to use
  30334. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30335. */
  30336. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30337. private _updateBoundingInfo;
  30338. /** @hidden */
  30339. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30340. /**
  30341. * Gets total number of vertices
  30342. * @returns the total number of vertices
  30343. */
  30344. getTotalVertices(): number;
  30345. /**
  30346. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30347. * @param kind defines the data kind (Position, normal, etc...)
  30348. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30349. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30350. * @returns a float array containing vertex data
  30351. */
  30352. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30353. /**
  30354. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30355. * @param kind defines the data kind (Position, normal, etc...)
  30356. * @returns true if the vertex buffer with the specified kind is updatable
  30357. */
  30358. isVertexBufferUpdatable(kind: string): boolean;
  30359. /**
  30360. * Gets a specific vertex buffer
  30361. * @param kind defines the data kind (Position, normal, etc...)
  30362. * @returns a VertexBuffer
  30363. */
  30364. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30365. /**
  30366. * Returns all vertex buffers
  30367. * @return an object holding all vertex buffers indexed by kind
  30368. */
  30369. getVertexBuffers(): Nullable<{
  30370. [key: string]: VertexBuffer;
  30371. }>;
  30372. /**
  30373. * Gets a boolean indicating if specific vertex buffer is present
  30374. * @param kind defines the data kind (Position, normal, etc...)
  30375. * @returns true if data is present
  30376. */
  30377. isVerticesDataPresent(kind: string): boolean;
  30378. /**
  30379. * Gets a list of all attached data kinds (Position, normal, etc...)
  30380. * @returns a list of string containing all kinds
  30381. */
  30382. getVerticesDataKinds(): string[];
  30383. /**
  30384. * Update index buffer
  30385. * @param indices defines the indices to store in the index buffer
  30386. * @param offset defines the offset in the target buffer where to store the data
  30387. * @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)
  30388. */
  30389. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30390. /**
  30391. * Creates a new index buffer
  30392. * @param indices defines the indices to store in the index buffer
  30393. * @param totalVertices defines the total number of vertices (could be null)
  30394. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30395. */
  30396. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30397. /**
  30398. * Return the total number of indices
  30399. * @returns the total number of indices
  30400. */
  30401. getTotalIndices(): number;
  30402. /**
  30403. * Gets the index buffer array
  30404. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30405. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30406. * @returns the index buffer array
  30407. */
  30408. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30409. /**
  30410. * Gets the index buffer
  30411. * @return the index buffer
  30412. */
  30413. getIndexBuffer(): Nullable<DataBuffer>;
  30414. /** @hidden */
  30415. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30416. /**
  30417. * Release the associated resources for a specific mesh
  30418. * @param mesh defines the source mesh
  30419. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30420. */
  30421. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30422. /**
  30423. * Apply current geometry to a given mesh
  30424. * @param mesh defines the mesh to apply geometry to
  30425. */
  30426. applyToMesh(mesh: Mesh): void;
  30427. private _updateExtend;
  30428. private _applyToMesh;
  30429. private notifyUpdate;
  30430. /**
  30431. * Load the geometry if it was flagged as delay loaded
  30432. * @param scene defines the hosting scene
  30433. * @param onLoaded defines a callback called when the geometry is loaded
  30434. */
  30435. load(scene: Scene, onLoaded?: () => void): void;
  30436. private _queueLoad;
  30437. /**
  30438. * Invert the geometry to move from a right handed system to a left handed one.
  30439. */
  30440. toLeftHanded(): void;
  30441. /** @hidden */
  30442. _resetPointsArrayCache(): void;
  30443. /** @hidden */
  30444. _generatePointsArray(): boolean;
  30445. /**
  30446. * Gets a value indicating if the geometry is disposed
  30447. * @returns true if the geometry was disposed
  30448. */
  30449. isDisposed(): boolean;
  30450. private _disposeVertexArrayObjects;
  30451. /**
  30452. * Free all associated resources
  30453. */
  30454. dispose(): void;
  30455. /**
  30456. * Clone the current geometry into a new geometry
  30457. * @param id defines the unique ID of the new geometry
  30458. * @returns a new geometry object
  30459. */
  30460. copy(id: string): Geometry;
  30461. /**
  30462. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30463. * @return a JSON representation of the current geometry data (without the vertices data)
  30464. */
  30465. serialize(): any;
  30466. private toNumberArray;
  30467. /**
  30468. * Serialize all vertices data into a JSON oject
  30469. * @returns a JSON representation of the current geometry data
  30470. */
  30471. serializeVerticeData(): any;
  30472. /**
  30473. * Extracts a clone of a mesh geometry
  30474. * @param mesh defines the source mesh
  30475. * @param id defines the unique ID of the new geometry object
  30476. * @returns the new geometry object
  30477. */
  30478. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30479. /**
  30480. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30481. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30482. * Be aware Math.random() could cause collisions, but:
  30483. * "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"
  30484. * @returns a string containing a new GUID
  30485. */
  30486. static RandomId(): string;
  30487. /** @hidden */
  30488. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30489. private static _CleanMatricesWeights;
  30490. /**
  30491. * Create a new geometry from persisted data (Using .babylon file format)
  30492. * @param parsedVertexData defines the persisted data
  30493. * @param scene defines the hosting scene
  30494. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30495. * @returns the new geometry object
  30496. */
  30497. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30498. }
  30499. }
  30500. declare module BABYLON {
  30501. /**
  30502. * Defines a target to use with MorphTargetManager
  30503. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30504. */
  30505. export class MorphTarget implements IAnimatable {
  30506. /** defines the name of the target */
  30507. name: string;
  30508. /**
  30509. * Gets or sets the list of animations
  30510. */
  30511. animations: Animation[];
  30512. private _scene;
  30513. private _positions;
  30514. private _normals;
  30515. private _tangents;
  30516. private _uvs;
  30517. private _influence;
  30518. private _uniqueId;
  30519. /**
  30520. * Observable raised when the influence changes
  30521. */
  30522. onInfluenceChanged: Observable<boolean>;
  30523. /** @hidden */
  30524. _onDataLayoutChanged: Observable<void>;
  30525. /**
  30526. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30527. */
  30528. get influence(): number;
  30529. set influence(influence: number);
  30530. /**
  30531. * Gets or sets the id of the morph Target
  30532. */
  30533. id: string;
  30534. private _animationPropertiesOverride;
  30535. /**
  30536. * Gets or sets the animation properties override
  30537. */
  30538. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30539. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30540. /**
  30541. * Creates a new MorphTarget
  30542. * @param name defines the name of the target
  30543. * @param influence defines the influence to use
  30544. * @param scene defines the scene the morphtarget belongs to
  30545. */
  30546. constructor(
  30547. /** defines the name of the target */
  30548. name: string, influence?: number, scene?: Nullable<Scene>);
  30549. /**
  30550. * Gets the unique ID of this manager
  30551. */
  30552. get uniqueId(): number;
  30553. /**
  30554. * Gets a boolean defining if the target contains position data
  30555. */
  30556. get hasPositions(): boolean;
  30557. /**
  30558. * Gets a boolean defining if the target contains normal data
  30559. */
  30560. get hasNormals(): boolean;
  30561. /**
  30562. * Gets a boolean defining if the target contains tangent data
  30563. */
  30564. get hasTangents(): boolean;
  30565. /**
  30566. * Gets a boolean defining if the target contains texture coordinates data
  30567. */
  30568. get hasUVs(): boolean;
  30569. /**
  30570. * Affects position data to this target
  30571. * @param data defines the position data to use
  30572. */
  30573. setPositions(data: Nullable<FloatArray>): void;
  30574. /**
  30575. * Gets the position data stored in this target
  30576. * @returns a FloatArray containing the position data (or null if not present)
  30577. */
  30578. getPositions(): Nullable<FloatArray>;
  30579. /**
  30580. * Affects normal data to this target
  30581. * @param data defines the normal data to use
  30582. */
  30583. setNormals(data: Nullable<FloatArray>): void;
  30584. /**
  30585. * Gets the normal data stored in this target
  30586. * @returns a FloatArray containing the normal data (or null if not present)
  30587. */
  30588. getNormals(): Nullable<FloatArray>;
  30589. /**
  30590. * Affects tangent data to this target
  30591. * @param data defines the tangent data to use
  30592. */
  30593. setTangents(data: Nullable<FloatArray>): void;
  30594. /**
  30595. * Gets the tangent data stored in this target
  30596. * @returns a FloatArray containing the tangent data (or null if not present)
  30597. */
  30598. getTangents(): Nullable<FloatArray>;
  30599. /**
  30600. * Affects texture coordinates data to this target
  30601. * @param data defines the texture coordinates data to use
  30602. */
  30603. setUVs(data: Nullable<FloatArray>): void;
  30604. /**
  30605. * Gets the texture coordinates data stored in this target
  30606. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30607. */
  30608. getUVs(): Nullable<FloatArray>;
  30609. /**
  30610. * Clone the current target
  30611. * @returns a new MorphTarget
  30612. */
  30613. clone(): MorphTarget;
  30614. /**
  30615. * Serializes the current target into a Serialization object
  30616. * @returns the serialized object
  30617. */
  30618. serialize(): any;
  30619. /**
  30620. * Returns the string "MorphTarget"
  30621. * @returns "MorphTarget"
  30622. */
  30623. getClassName(): string;
  30624. /**
  30625. * Creates a new target from serialized data
  30626. * @param serializationObject defines the serialized data to use
  30627. * @returns a new MorphTarget
  30628. */
  30629. static Parse(serializationObject: any): MorphTarget;
  30630. /**
  30631. * Creates a MorphTarget from mesh data
  30632. * @param mesh defines the source mesh
  30633. * @param name defines the name to use for the new target
  30634. * @param influence defines the influence to attach to the target
  30635. * @returns a new MorphTarget
  30636. */
  30637. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30638. }
  30639. }
  30640. declare module BABYLON {
  30641. /**
  30642. * This class is used to deform meshes using morphing between different targets
  30643. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30644. */
  30645. export class MorphTargetManager {
  30646. private _targets;
  30647. private _targetInfluenceChangedObservers;
  30648. private _targetDataLayoutChangedObservers;
  30649. private _activeTargets;
  30650. private _scene;
  30651. private _influences;
  30652. private _supportsNormals;
  30653. private _supportsTangents;
  30654. private _supportsUVs;
  30655. private _vertexCount;
  30656. private _uniqueId;
  30657. private _tempInfluences;
  30658. /**
  30659. * Gets or sets a boolean indicating if normals must be morphed
  30660. */
  30661. enableNormalMorphing: boolean;
  30662. /**
  30663. * Gets or sets a boolean indicating if tangents must be morphed
  30664. */
  30665. enableTangentMorphing: boolean;
  30666. /**
  30667. * Gets or sets a boolean indicating if UV must be morphed
  30668. */
  30669. enableUVMorphing: boolean;
  30670. /**
  30671. * Creates a new MorphTargetManager
  30672. * @param scene defines the current scene
  30673. */
  30674. constructor(scene?: Nullable<Scene>);
  30675. /**
  30676. * Gets the unique ID of this manager
  30677. */
  30678. get uniqueId(): number;
  30679. /**
  30680. * Gets the number of vertices handled by this manager
  30681. */
  30682. get vertexCount(): number;
  30683. /**
  30684. * Gets a boolean indicating if this manager supports morphing of normals
  30685. */
  30686. get supportsNormals(): boolean;
  30687. /**
  30688. * Gets a boolean indicating if this manager supports morphing of tangents
  30689. */
  30690. get supportsTangents(): boolean;
  30691. /**
  30692. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  30693. */
  30694. get supportsUVs(): boolean;
  30695. /**
  30696. * Gets the number of targets stored in this manager
  30697. */
  30698. get numTargets(): number;
  30699. /**
  30700. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30701. */
  30702. get numInfluencers(): number;
  30703. /**
  30704. * Gets the list of influences (one per target)
  30705. */
  30706. get influences(): Float32Array;
  30707. /**
  30708. * Gets the active target at specified index. An active target is a target with an influence > 0
  30709. * @param index defines the index to check
  30710. * @returns the requested target
  30711. */
  30712. getActiveTarget(index: number): MorphTarget;
  30713. /**
  30714. * Gets the target at specified index
  30715. * @param index defines the index to check
  30716. * @returns the requested target
  30717. */
  30718. getTarget(index: number): MorphTarget;
  30719. /**
  30720. * Add a new target to this manager
  30721. * @param target defines the target to add
  30722. */
  30723. addTarget(target: MorphTarget): void;
  30724. /**
  30725. * Removes a target from the manager
  30726. * @param target defines the target to remove
  30727. */
  30728. removeTarget(target: MorphTarget): void;
  30729. /**
  30730. * Clone the current manager
  30731. * @returns a new MorphTargetManager
  30732. */
  30733. clone(): MorphTargetManager;
  30734. /**
  30735. * Serializes the current manager into a Serialization object
  30736. * @returns the serialized object
  30737. */
  30738. serialize(): any;
  30739. private _syncActiveTargets;
  30740. /**
  30741. * Syncrhonize the targets with all the meshes using this morph target manager
  30742. */
  30743. synchronize(): void;
  30744. /**
  30745. * Creates a new MorphTargetManager from serialized data
  30746. * @param serializationObject defines the serialized data
  30747. * @param scene defines the hosting scene
  30748. * @returns the new MorphTargetManager
  30749. */
  30750. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30751. }
  30752. }
  30753. declare module BABYLON {
  30754. /**
  30755. * Class used to represent a specific level of detail of a mesh
  30756. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  30757. */
  30758. export class MeshLODLevel {
  30759. /** Defines the distance where this level should start being displayed */
  30760. distance: number;
  30761. /** Defines the mesh to use to render this level */
  30762. mesh: Nullable<Mesh>;
  30763. /**
  30764. * Creates a new LOD level
  30765. * @param distance defines the distance where this level should star being displayed
  30766. * @param mesh defines the mesh to use to render this level
  30767. */
  30768. constructor(
  30769. /** Defines the distance where this level should start being displayed */
  30770. distance: number,
  30771. /** Defines the mesh to use to render this level */
  30772. mesh: Nullable<Mesh>);
  30773. }
  30774. }
  30775. declare module BABYLON {
  30776. /**
  30777. * Helper class used to generate a canvas to manipulate images
  30778. */
  30779. export class CanvasGenerator {
  30780. /**
  30781. * Create a new canvas (or offscreen canvas depending on the context)
  30782. * @param width defines the expected width
  30783. * @param height defines the expected height
  30784. * @return a new canvas or offscreen canvas
  30785. */
  30786. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  30787. }
  30788. }
  30789. declare module BABYLON {
  30790. /**
  30791. * Mesh representing the gorund
  30792. */
  30793. export class GroundMesh extends Mesh {
  30794. /** If octree should be generated */
  30795. generateOctree: boolean;
  30796. private _heightQuads;
  30797. /** @hidden */
  30798. _subdivisionsX: number;
  30799. /** @hidden */
  30800. _subdivisionsY: number;
  30801. /** @hidden */
  30802. _width: number;
  30803. /** @hidden */
  30804. _height: number;
  30805. /** @hidden */
  30806. _minX: number;
  30807. /** @hidden */
  30808. _maxX: number;
  30809. /** @hidden */
  30810. _minZ: number;
  30811. /** @hidden */
  30812. _maxZ: number;
  30813. constructor(name: string, scene: Scene);
  30814. /**
  30815. * "GroundMesh"
  30816. * @returns "GroundMesh"
  30817. */
  30818. getClassName(): string;
  30819. /**
  30820. * The minimum of x and y subdivisions
  30821. */
  30822. get subdivisions(): number;
  30823. /**
  30824. * X subdivisions
  30825. */
  30826. get subdivisionsX(): number;
  30827. /**
  30828. * Y subdivisions
  30829. */
  30830. get subdivisionsY(): number;
  30831. /**
  30832. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  30833. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  30834. * @param chunksCount the number of subdivisions for x and y
  30835. * @param octreeBlocksSize (Default: 32)
  30836. */
  30837. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  30838. /**
  30839. * Returns a height (y) value in the Worl system :
  30840. * the ground altitude at the coordinates (x, z) expressed in the World system.
  30841. * @param x x coordinate
  30842. * @param z z coordinate
  30843. * @returns the ground y position if (x, z) are outside the ground surface.
  30844. */
  30845. getHeightAtCoordinates(x: number, z: number): number;
  30846. /**
  30847. * Returns a normalized vector (Vector3) orthogonal to the ground
  30848. * at the ground coordinates (x, z) expressed in the World system.
  30849. * @param x x coordinate
  30850. * @param z z coordinate
  30851. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  30852. */
  30853. getNormalAtCoordinates(x: number, z: number): Vector3;
  30854. /**
  30855. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  30856. * at the ground coordinates (x, z) expressed in the World system.
  30857. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  30858. * @param x x coordinate
  30859. * @param z z coordinate
  30860. * @param ref vector to store the result
  30861. * @returns the GroundMesh.
  30862. */
  30863. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  30864. /**
  30865. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  30866. * if the ground has been updated.
  30867. * This can be used in the render loop.
  30868. * @returns the GroundMesh.
  30869. */
  30870. updateCoordinateHeights(): GroundMesh;
  30871. private _getFacetAt;
  30872. private _initHeightQuads;
  30873. private _computeHeightQuads;
  30874. /**
  30875. * Serializes this ground mesh
  30876. * @param serializationObject object to write serialization to
  30877. */
  30878. serialize(serializationObject: any): void;
  30879. /**
  30880. * Parses a serialized ground mesh
  30881. * @param parsedMesh the serialized mesh
  30882. * @param scene the scene to create the ground mesh in
  30883. * @returns the created ground mesh
  30884. */
  30885. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  30886. }
  30887. }
  30888. declare module BABYLON {
  30889. /**
  30890. * Interface for Physics-Joint data
  30891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30892. */
  30893. export interface PhysicsJointData {
  30894. /**
  30895. * The main pivot of the joint
  30896. */
  30897. mainPivot?: Vector3;
  30898. /**
  30899. * The connected pivot of the joint
  30900. */
  30901. connectedPivot?: Vector3;
  30902. /**
  30903. * The main axis of the joint
  30904. */
  30905. mainAxis?: Vector3;
  30906. /**
  30907. * The connected axis of the joint
  30908. */
  30909. connectedAxis?: Vector3;
  30910. /**
  30911. * The collision of the joint
  30912. */
  30913. collision?: boolean;
  30914. /**
  30915. * Native Oimo/Cannon/Energy data
  30916. */
  30917. nativeParams?: any;
  30918. }
  30919. /**
  30920. * This is a holder class for the physics joint created by the physics plugin
  30921. * It holds a set of functions to control the underlying joint
  30922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30923. */
  30924. export class PhysicsJoint {
  30925. /**
  30926. * The type of the physics joint
  30927. */
  30928. type: number;
  30929. /**
  30930. * The data for the physics joint
  30931. */
  30932. jointData: PhysicsJointData;
  30933. private _physicsJoint;
  30934. protected _physicsPlugin: IPhysicsEnginePlugin;
  30935. /**
  30936. * Initializes the physics joint
  30937. * @param type The type of the physics joint
  30938. * @param jointData The data for the physics joint
  30939. */
  30940. constructor(
  30941. /**
  30942. * The type of the physics joint
  30943. */
  30944. type: number,
  30945. /**
  30946. * The data for the physics joint
  30947. */
  30948. jointData: PhysicsJointData);
  30949. /**
  30950. * Gets the physics joint
  30951. */
  30952. get physicsJoint(): any;
  30953. /**
  30954. * Sets the physics joint
  30955. */
  30956. set physicsJoint(newJoint: any);
  30957. /**
  30958. * Sets the physics plugin
  30959. */
  30960. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  30961. /**
  30962. * Execute a function that is physics-plugin specific.
  30963. * @param {Function} func the function that will be executed.
  30964. * It accepts two parameters: the physics world and the physics joint
  30965. */
  30966. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  30967. /**
  30968. * Distance-Joint type
  30969. */
  30970. static DistanceJoint: number;
  30971. /**
  30972. * Hinge-Joint type
  30973. */
  30974. static HingeJoint: number;
  30975. /**
  30976. * Ball-and-Socket joint type
  30977. */
  30978. static BallAndSocketJoint: number;
  30979. /**
  30980. * Wheel-Joint type
  30981. */
  30982. static WheelJoint: number;
  30983. /**
  30984. * Slider-Joint type
  30985. */
  30986. static SliderJoint: number;
  30987. /**
  30988. * Prismatic-Joint type
  30989. */
  30990. static PrismaticJoint: number;
  30991. /**
  30992. * Universal-Joint type
  30993. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  30994. */
  30995. static UniversalJoint: number;
  30996. /**
  30997. * Hinge-Joint 2 type
  30998. */
  30999. static Hinge2Joint: number;
  31000. /**
  31001. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31002. */
  31003. static PointToPointJoint: number;
  31004. /**
  31005. * Spring-Joint type
  31006. */
  31007. static SpringJoint: number;
  31008. /**
  31009. * Lock-Joint type
  31010. */
  31011. static LockJoint: number;
  31012. }
  31013. /**
  31014. * A class representing a physics distance joint
  31015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31016. */
  31017. export class DistanceJoint extends PhysicsJoint {
  31018. /**
  31019. *
  31020. * @param jointData The data for the Distance-Joint
  31021. */
  31022. constructor(jointData: DistanceJointData);
  31023. /**
  31024. * Update the predefined distance.
  31025. * @param maxDistance The maximum preferred distance
  31026. * @param minDistance The minimum preferred distance
  31027. */
  31028. updateDistance(maxDistance: number, minDistance?: number): void;
  31029. }
  31030. /**
  31031. * Represents a Motor-Enabled Joint
  31032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31033. */
  31034. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31035. /**
  31036. * Initializes the Motor-Enabled Joint
  31037. * @param type The type of the joint
  31038. * @param jointData The physica joint data for the joint
  31039. */
  31040. constructor(type: number, jointData: PhysicsJointData);
  31041. /**
  31042. * Set the motor values.
  31043. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31044. * @param force the force to apply
  31045. * @param maxForce max force for this motor.
  31046. */
  31047. setMotor(force?: number, maxForce?: number): void;
  31048. /**
  31049. * Set the motor's limits.
  31050. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31051. * @param upperLimit The upper limit of the motor
  31052. * @param lowerLimit The lower limit of the motor
  31053. */
  31054. setLimit(upperLimit: number, lowerLimit?: number): void;
  31055. }
  31056. /**
  31057. * This class represents a single physics Hinge-Joint
  31058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31059. */
  31060. export class HingeJoint extends MotorEnabledJoint {
  31061. /**
  31062. * Initializes the Hinge-Joint
  31063. * @param jointData The joint data for the Hinge-Joint
  31064. */
  31065. constructor(jointData: PhysicsJointData);
  31066. /**
  31067. * Set the motor values.
  31068. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31069. * @param {number} force the force to apply
  31070. * @param {number} maxForce max force for this motor.
  31071. */
  31072. setMotor(force?: number, maxForce?: number): void;
  31073. /**
  31074. * Set the motor's limits.
  31075. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31076. * @param upperLimit The upper limit of the motor
  31077. * @param lowerLimit The lower limit of the motor
  31078. */
  31079. setLimit(upperLimit: number, lowerLimit?: number): void;
  31080. }
  31081. /**
  31082. * This class represents a dual hinge physics joint (same as wheel joint)
  31083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31084. */
  31085. export class Hinge2Joint extends MotorEnabledJoint {
  31086. /**
  31087. * Initializes the Hinge2-Joint
  31088. * @param jointData The joint data for the Hinge2-Joint
  31089. */
  31090. constructor(jointData: PhysicsJointData);
  31091. /**
  31092. * Set the motor values.
  31093. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31094. * @param {number} targetSpeed the speed the motor is to reach
  31095. * @param {number} maxForce max force for this motor.
  31096. * @param {motorIndex} the motor's index, 0 or 1.
  31097. */
  31098. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31099. /**
  31100. * Set the motor limits.
  31101. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31102. * @param {number} upperLimit the upper limit
  31103. * @param {number} lowerLimit lower limit
  31104. * @param {motorIndex} the motor's index, 0 or 1.
  31105. */
  31106. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31107. }
  31108. /**
  31109. * Interface for a motor enabled joint
  31110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31111. */
  31112. export interface IMotorEnabledJoint {
  31113. /**
  31114. * Physics joint
  31115. */
  31116. physicsJoint: any;
  31117. /**
  31118. * Sets the motor of the motor-enabled joint
  31119. * @param force The force of the motor
  31120. * @param maxForce The maximum force of the motor
  31121. * @param motorIndex The index of the motor
  31122. */
  31123. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31124. /**
  31125. * Sets the limit of the motor
  31126. * @param upperLimit The upper limit of the motor
  31127. * @param lowerLimit The lower limit of the motor
  31128. * @param motorIndex The index of the motor
  31129. */
  31130. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31131. }
  31132. /**
  31133. * Joint data for a Distance-Joint
  31134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31135. */
  31136. export interface DistanceJointData extends PhysicsJointData {
  31137. /**
  31138. * Max distance the 2 joint objects can be apart
  31139. */
  31140. maxDistance: number;
  31141. }
  31142. /**
  31143. * Joint data from a spring joint
  31144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31145. */
  31146. export interface SpringJointData extends PhysicsJointData {
  31147. /**
  31148. * Length of the spring
  31149. */
  31150. length: number;
  31151. /**
  31152. * Stiffness of the spring
  31153. */
  31154. stiffness: number;
  31155. /**
  31156. * Damping of the spring
  31157. */
  31158. damping: number;
  31159. /** this callback will be called when applying the force to the impostors. */
  31160. forceApplicationCallback: () => void;
  31161. }
  31162. }
  31163. declare module BABYLON {
  31164. /**
  31165. * Holds the data for the raycast result
  31166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31167. */
  31168. export class PhysicsRaycastResult {
  31169. private _hasHit;
  31170. private _hitDistance;
  31171. private _hitNormalWorld;
  31172. private _hitPointWorld;
  31173. private _rayFromWorld;
  31174. private _rayToWorld;
  31175. /**
  31176. * Gets if there was a hit
  31177. */
  31178. get hasHit(): boolean;
  31179. /**
  31180. * Gets the distance from the hit
  31181. */
  31182. get hitDistance(): number;
  31183. /**
  31184. * Gets the hit normal/direction in the world
  31185. */
  31186. get hitNormalWorld(): Vector3;
  31187. /**
  31188. * Gets the hit point in the world
  31189. */
  31190. get hitPointWorld(): Vector3;
  31191. /**
  31192. * Gets the ray "start point" of the ray in the world
  31193. */
  31194. get rayFromWorld(): Vector3;
  31195. /**
  31196. * Gets the ray "end point" of the ray in the world
  31197. */
  31198. get rayToWorld(): Vector3;
  31199. /**
  31200. * Sets the hit data (normal & point in world space)
  31201. * @param hitNormalWorld defines the normal in world space
  31202. * @param hitPointWorld defines the point in world space
  31203. */
  31204. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31205. /**
  31206. * Sets the distance from the start point to the hit point
  31207. * @param distance
  31208. */
  31209. setHitDistance(distance: number): void;
  31210. /**
  31211. * Calculates the distance manually
  31212. */
  31213. calculateHitDistance(): void;
  31214. /**
  31215. * Resets all the values to default
  31216. * @param from The from point on world space
  31217. * @param to The to point on world space
  31218. */
  31219. reset(from?: Vector3, to?: Vector3): void;
  31220. }
  31221. /**
  31222. * Interface for the size containing width and height
  31223. */
  31224. interface IXYZ {
  31225. /**
  31226. * X
  31227. */
  31228. x: number;
  31229. /**
  31230. * Y
  31231. */
  31232. y: number;
  31233. /**
  31234. * Z
  31235. */
  31236. z: number;
  31237. }
  31238. }
  31239. declare module BABYLON {
  31240. /**
  31241. * Interface used to describe a physics joint
  31242. */
  31243. export interface PhysicsImpostorJoint {
  31244. /** Defines the main impostor to which the joint is linked */
  31245. mainImpostor: PhysicsImpostor;
  31246. /** Defines the impostor that is connected to the main impostor using this joint */
  31247. connectedImpostor: PhysicsImpostor;
  31248. /** Defines the joint itself */
  31249. joint: PhysicsJoint;
  31250. }
  31251. /** @hidden */
  31252. export interface IPhysicsEnginePlugin {
  31253. world: any;
  31254. name: string;
  31255. setGravity(gravity: Vector3): void;
  31256. setTimeStep(timeStep: number): void;
  31257. getTimeStep(): number;
  31258. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31259. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31260. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31261. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31262. removePhysicsBody(impostor: PhysicsImpostor): void;
  31263. generateJoint(joint: PhysicsImpostorJoint): void;
  31264. removeJoint(joint: PhysicsImpostorJoint): void;
  31265. isSupported(): boolean;
  31266. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31267. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31268. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31269. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31270. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31271. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31272. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31273. getBodyMass(impostor: PhysicsImpostor): number;
  31274. getBodyFriction(impostor: PhysicsImpostor): number;
  31275. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31276. getBodyRestitution(impostor: PhysicsImpostor): number;
  31277. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31278. getBodyPressure?(impostor: PhysicsImpostor): number;
  31279. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31280. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31281. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31282. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31283. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31284. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31285. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31286. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31287. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31288. sleepBody(impostor: PhysicsImpostor): void;
  31289. wakeUpBody(impostor: PhysicsImpostor): void;
  31290. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31291. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31292. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31293. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31294. getRadius(impostor: PhysicsImpostor): number;
  31295. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31296. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31297. dispose(): void;
  31298. }
  31299. /**
  31300. * Interface used to define a physics engine
  31301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31302. */
  31303. export interface IPhysicsEngine {
  31304. /**
  31305. * Gets the gravity vector used by the simulation
  31306. */
  31307. gravity: Vector3;
  31308. /**
  31309. * Sets the gravity vector used by the simulation
  31310. * @param gravity defines the gravity vector to use
  31311. */
  31312. setGravity(gravity: Vector3): void;
  31313. /**
  31314. * Set the time step of the physics engine.
  31315. * Default is 1/60.
  31316. * To slow it down, enter 1/600 for example.
  31317. * To speed it up, 1/30
  31318. * @param newTimeStep the new timestep to apply to this world.
  31319. */
  31320. setTimeStep(newTimeStep: number): void;
  31321. /**
  31322. * Get the time step of the physics engine.
  31323. * @returns the current time step
  31324. */
  31325. getTimeStep(): number;
  31326. /**
  31327. * Set the sub time step of the physics engine.
  31328. * Default is 0 meaning there is no sub steps
  31329. * To increase physics resolution precision, set a small value (like 1 ms)
  31330. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31331. */
  31332. setSubTimeStep(subTimeStep: number): void;
  31333. /**
  31334. * Get the sub time step of the physics engine.
  31335. * @returns the current sub time step
  31336. */
  31337. getSubTimeStep(): number;
  31338. /**
  31339. * Release all resources
  31340. */
  31341. dispose(): void;
  31342. /**
  31343. * Gets the name of the current physics plugin
  31344. * @returns the name of the plugin
  31345. */
  31346. getPhysicsPluginName(): string;
  31347. /**
  31348. * Adding a new impostor for the impostor tracking.
  31349. * This will be done by the impostor itself.
  31350. * @param impostor the impostor to add
  31351. */
  31352. addImpostor(impostor: PhysicsImpostor): void;
  31353. /**
  31354. * Remove an impostor from the engine.
  31355. * This impostor and its mesh will not longer be updated by the physics engine.
  31356. * @param impostor the impostor to remove
  31357. */
  31358. removeImpostor(impostor: PhysicsImpostor): void;
  31359. /**
  31360. * Add a joint to the physics engine
  31361. * @param mainImpostor defines the main impostor to which the joint is added.
  31362. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31363. * @param joint defines the joint that will connect both impostors.
  31364. */
  31365. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31366. /**
  31367. * Removes a joint from the simulation
  31368. * @param mainImpostor defines the impostor used with the joint
  31369. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31370. * @param joint defines the joint to remove
  31371. */
  31372. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31373. /**
  31374. * Gets the current plugin used to run the simulation
  31375. * @returns current plugin
  31376. */
  31377. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31378. /**
  31379. * Gets the list of physic impostors
  31380. * @returns an array of PhysicsImpostor
  31381. */
  31382. getImpostors(): Array<PhysicsImpostor>;
  31383. /**
  31384. * Gets the impostor for a physics enabled object
  31385. * @param object defines the object impersonated by the impostor
  31386. * @returns the PhysicsImpostor or null if not found
  31387. */
  31388. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31389. /**
  31390. * Gets the impostor for a physics body object
  31391. * @param body defines physics body used by the impostor
  31392. * @returns the PhysicsImpostor or null if not found
  31393. */
  31394. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31395. /**
  31396. * Does a raycast in the physics world
  31397. * @param from when should the ray start?
  31398. * @param to when should the ray end?
  31399. * @returns PhysicsRaycastResult
  31400. */
  31401. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31402. /**
  31403. * Called by the scene. No need to call it.
  31404. * @param delta defines the timespam between frames
  31405. */
  31406. _step(delta: number): void;
  31407. }
  31408. }
  31409. declare module BABYLON {
  31410. /**
  31411. * The interface for the physics imposter parameters
  31412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31413. */
  31414. export interface PhysicsImpostorParameters {
  31415. /**
  31416. * The mass of the physics imposter
  31417. */
  31418. mass: number;
  31419. /**
  31420. * The friction of the physics imposter
  31421. */
  31422. friction?: number;
  31423. /**
  31424. * The coefficient of restitution of the physics imposter
  31425. */
  31426. restitution?: number;
  31427. /**
  31428. * The native options of the physics imposter
  31429. */
  31430. nativeOptions?: any;
  31431. /**
  31432. * Specifies if the parent should be ignored
  31433. */
  31434. ignoreParent?: boolean;
  31435. /**
  31436. * Specifies if bi-directional transformations should be disabled
  31437. */
  31438. disableBidirectionalTransformation?: boolean;
  31439. /**
  31440. * The pressure inside the physics imposter, soft object only
  31441. */
  31442. pressure?: number;
  31443. /**
  31444. * The stiffness the physics imposter, soft object only
  31445. */
  31446. stiffness?: number;
  31447. /**
  31448. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31449. */
  31450. velocityIterations?: number;
  31451. /**
  31452. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31453. */
  31454. positionIterations?: number;
  31455. /**
  31456. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31457. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31458. * Add to fix multiple points
  31459. */
  31460. fixedPoints?: number;
  31461. /**
  31462. * The collision margin around a soft object
  31463. */
  31464. margin?: number;
  31465. /**
  31466. * The collision margin around a soft object
  31467. */
  31468. damping?: number;
  31469. /**
  31470. * The path for a rope based on an extrusion
  31471. */
  31472. path?: any;
  31473. /**
  31474. * The shape of an extrusion used for a rope based on an extrusion
  31475. */
  31476. shape?: any;
  31477. }
  31478. /**
  31479. * Interface for a physics-enabled object
  31480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31481. */
  31482. export interface IPhysicsEnabledObject {
  31483. /**
  31484. * The position of the physics-enabled object
  31485. */
  31486. position: Vector3;
  31487. /**
  31488. * The rotation of the physics-enabled object
  31489. */
  31490. rotationQuaternion: Nullable<Quaternion>;
  31491. /**
  31492. * The scale of the physics-enabled object
  31493. */
  31494. scaling: Vector3;
  31495. /**
  31496. * The rotation of the physics-enabled object
  31497. */
  31498. rotation?: Vector3;
  31499. /**
  31500. * The parent of the physics-enabled object
  31501. */
  31502. parent?: any;
  31503. /**
  31504. * The bounding info of the physics-enabled object
  31505. * @returns The bounding info of the physics-enabled object
  31506. */
  31507. getBoundingInfo(): BoundingInfo;
  31508. /**
  31509. * Computes the world matrix
  31510. * @param force Specifies if the world matrix should be computed by force
  31511. * @returns A world matrix
  31512. */
  31513. computeWorldMatrix(force: boolean): Matrix;
  31514. /**
  31515. * Gets the world matrix
  31516. * @returns A world matrix
  31517. */
  31518. getWorldMatrix?(): Matrix;
  31519. /**
  31520. * Gets the child meshes
  31521. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31522. * @returns An array of abstract meshes
  31523. */
  31524. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31525. /**
  31526. * Gets the vertex data
  31527. * @param kind The type of vertex data
  31528. * @returns A nullable array of numbers, or a float32 array
  31529. */
  31530. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31531. /**
  31532. * Gets the indices from the mesh
  31533. * @returns A nullable array of index arrays
  31534. */
  31535. getIndices?(): Nullable<IndicesArray>;
  31536. /**
  31537. * Gets the scene from the mesh
  31538. * @returns the indices array or null
  31539. */
  31540. getScene?(): Scene;
  31541. /**
  31542. * Gets the absolute position from the mesh
  31543. * @returns the absolute position
  31544. */
  31545. getAbsolutePosition(): Vector3;
  31546. /**
  31547. * Gets the absolute pivot point from the mesh
  31548. * @returns the absolute pivot point
  31549. */
  31550. getAbsolutePivotPoint(): Vector3;
  31551. /**
  31552. * Rotates the mesh
  31553. * @param axis The axis of rotation
  31554. * @param amount The amount of rotation
  31555. * @param space The space of the rotation
  31556. * @returns The rotation transform node
  31557. */
  31558. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31559. /**
  31560. * Translates the mesh
  31561. * @param axis The axis of translation
  31562. * @param distance The distance of translation
  31563. * @param space The space of the translation
  31564. * @returns The transform node
  31565. */
  31566. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31567. /**
  31568. * Sets the absolute position of the mesh
  31569. * @param absolutePosition The absolute position of the mesh
  31570. * @returns The transform node
  31571. */
  31572. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31573. /**
  31574. * Gets the class name of the mesh
  31575. * @returns The class name
  31576. */
  31577. getClassName(): string;
  31578. }
  31579. /**
  31580. * Represents a physics imposter
  31581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31582. */
  31583. export class PhysicsImpostor {
  31584. /**
  31585. * The physics-enabled object used as the physics imposter
  31586. */
  31587. object: IPhysicsEnabledObject;
  31588. /**
  31589. * The type of the physics imposter
  31590. */
  31591. type: number;
  31592. private _options;
  31593. private _scene?;
  31594. /**
  31595. * The default object size of the imposter
  31596. */
  31597. static DEFAULT_OBJECT_SIZE: Vector3;
  31598. /**
  31599. * The identity quaternion of the imposter
  31600. */
  31601. static IDENTITY_QUATERNION: Quaternion;
  31602. /** @hidden */
  31603. _pluginData: any;
  31604. private _physicsEngine;
  31605. private _physicsBody;
  31606. private _bodyUpdateRequired;
  31607. private _onBeforePhysicsStepCallbacks;
  31608. private _onAfterPhysicsStepCallbacks;
  31609. /** @hidden */
  31610. _onPhysicsCollideCallbacks: Array<{
  31611. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31612. otherImpostors: Array<PhysicsImpostor>;
  31613. }>;
  31614. private _deltaPosition;
  31615. private _deltaRotation;
  31616. private _deltaRotationConjugated;
  31617. /** @hidden */
  31618. _isFromLine: boolean;
  31619. private _parent;
  31620. private _isDisposed;
  31621. private static _tmpVecs;
  31622. private static _tmpQuat;
  31623. /**
  31624. * Specifies if the physics imposter is disposed
  31625. */
  31626. get isDisposed(): boolean;
  31627. /**
  31628. * Gets the mass of the physics imposter
  31629. */
  31630. get mass(): number;
  31631. set mass(value: number);
  31632. /**
  31633. * Gets the coefficient of friction
  31634. */
  31635. get friction(): number;
  31636. /**
  31637. * Sets the coefficient of friction
  31638. */
  31639. set friction(value: number);
  31640. /**
  31641. * Gets the coefficient of restitution
  31642. */
  31643. get restitution(): number;
  31644. /**
  31645. * Sets the coefficient of restitution
  31646. */
  31647. set restitution(value: number);
  31648. /**
  31649. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31650. */
  31651. get pressure(): number;
  31652. /**
  31653. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31654. */
  31655. set pressure(value: number);
  31656. /**
  31657. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31658. */
  31659. get stiffness(): number;
  31660. /**
  31661. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31662. */
  31663. set stiffness(value: number);
  31664. /**
  31665. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31666. */
  31667. get velocityIterations(): number;
  31668. /**
  31669. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31670. */
  31671. set velocityIterations(value: number);
  31672. /**
  31673. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31674. */
  31675. get positionIterations(): number;
  31676. /**
  31677. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31678. */
  31679. set positionIterations(value: number);
  31680. /**
  31681. * The unique id of the physics imposter
  31682. * set by the physics engine when adding this impostor to the array
  31683. */
  31684. uniqueId: number;
  31685. /**
  31686. * @hidden
  31687. */
  31688. soft: boolean;
  31689. /**
  31690. * @hidden
  31691. */
  31692. segments: number;
  31693. private _joints;
  31694. /**
  31695. * Initializes the physics imposter
  31696. * @param object The physics-enabled object used as the physics imposter
  31697. * @param type The type of the physics imposter
  31698. * @param _options The options for the physics imposter
  31699. * @param _scene The Babylon scene
  31700. */
  31701. constructor(
  31702. /**
  31703. * The physics-enabled object used as the physics imposter
  31704. */
  31705. object: IPhysicsEnabledObject,
  31706. /**
  31707. * The type of the physics imposter
  31708. */
  31709. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31710. /**
  31711. * This function will completly initialize this impostor.
  31712. * It will create a new body - but only if this mesh has no parent.
  31713. * If it has, this impostor will not be used other than to define the impostor
  31714. * of the child mesh.
  31715. * @hidden
  31716. */
  31717. _init(): void;
  31718. private _getPhysicsParent;
  31719. /**
  31720. * Should a new body be generated.
  31721. * @returns boolean specifying if body initialization is required
  31722. */
  31723. isBodyInitRequired(): boolean;
  31724. /**
  31725. * Sets the updated scaling
  31726. * @param updated Specifies if the scaling is updated
  31727. */
  31728. setScalingUpdated(): void;
  31729. /**
  31730. * Force a regeneration of this or the parent's impostor's body.
  31731. * Use under cautious - This will remove all joints already implemented.
  31732. */
  31733. forceUpdate(): void;
  31734. /**
  31735. * Gets the body that holds this impostor. Either its own, or its parent.
  31736. */
  31737. get physicsBody(): any;
  31738. /**
  31739. * Get the parent of the physics imposter
  31740. * @returns Physics imposter or null
  31741. */
  31742. get parent(): Nullable<PhysicsImpostor>;
  31743. /**
  31744. * Sets the parent of the physics imposter
  31745. */
  31746. set parent(value: Nullable<PhysicsImpostor>);
  31747. /**
  31748. * Set the physics body. Used mainly by the physics engine/plugin
  31749. */
  31750. set physicsBody(physicsBody: any);
  31751. /**
  31752. * Resets the update flags
  31753. */
  31754. resetUpdateFlags(): void;
  31755. /**
  31756. * Gets the object extend size
  31757. * @returns the object extend size
  31758. */
  31759. getObjectExtendSize(): Vector3;
  31760. /**
  31761. * Gets the object center
  31762. * @returns The object center
  31763. */
  31764. getObjectCenter(): Vector3;
  31765. /**
  31766. * Get a specific parameter from the options parameters
  31767. * @param paramName The object parameter name
  31768. * @returns The object parameter
  31769. */
  31770. getParam(paramName: string): any;
  31771. /**
  31772. * Sets a specific parameter in the options given to the physics plugin
  31773. * @param paramName The parameter name
  31774. * @param value The value of the parameter
  31775. */
  31776. setParam(paramName: string, value: number): void;
  31777. /**
  31778. * Specifically change the body's mass option. Won't recreate the physics body object
  31779. * @param mass The mass of the physics imposter
  31780. */
  31781. setMass(mass: number): void;
  31782. /**
  31783. * Gets the linear velocity
  31784. * @returns linear velocity or null
  31785. */
  31786. getLinearVelocity(): Nullable<Vector3>;
  31787. /**
  31788. * Sets the linear velocity
  31789. * @param velocity linear velocity or null
  31790. */
  31791. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31792. /**
  31793. * Gets the angular velocity
  31794. * @returns angular velocity or null
  31795. */
  31796. getAngularVelocity(): Nullable<Vector3>;
  31797. /**
  31798. * Sets the angular velocity
  31799. * @param velocity The velocity or null
  31800. */
  31801. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31802. /**
  31803. * Execute a function with the physics plugin native code
  31804. * Provide a function the will have two variables - the world object and the physics body object
  31805. * @param func The function to execute with the physics plugin native code
  31806. */
  31807. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31808. /**
  31809. * Register a function that will be executed before the physics world is stepping forward
  31810. * @param func The function to execute before the physics world is stepped forward
  31811. */
  31812. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31813. /**
  31814. * Unregister a function that will be executed before the physics world is stepping forward
  31815. * @param func The function to execute before the physics world is stepped forward
  31816. */
  31817. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31818. /**
  31819. * Register a function that will be executed after the physics step
  31820. * @param func The function to execute after physics step
  31821. */
  31822. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31823. /**
  31824. * Unregisters a function that will be executed after the physics step
  31825. * @param func The function to execute after physics step
  31826. */
  31827. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31828. /**
  31829. * register a function that will be executed when this impostor collides against a different body
  31830. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  31831. * @param func Callback that is executed on collision
  31832. */
  31833. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  31834. /**
  31835. * Unregisters the physics imposter on contact
  31836. * @param collideAgainst The physics object to collide against
  31837. * @param func Callback to execute on collision
  31838. */
  31839. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  31840. private _tmpQuat;
  31841. private _tmpQuat2;
  31842. /**
  31843. * Get the parent rotation
  31844. * @returns The parent rotation
  31845. */
  31846. getParentsRotation(): Quaternion;
  31847. /**
  31848. * this function is executed by the physics engine.
  31849. */
  31850. beforeStep: () => void;
  31851. /**
  31852. * this function is executed by the physics engine
  31853. */
  31854. afterStep: () => void;
  31855. /**
  31856. * Legacy collision detection event support
  31857. */
  31858. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  31859. /**
  31860. * event and body object due to cannon's event-based architecture.
  31861. */
  31862. onCollide: (e: {
  31863. body: any;
  31864. point: Nullable<Vector3>;
  31865. }) => void;
  31866. /**
  31867. * Apply a force
  31868. * @param force The force to apply
  31869. * @param contactPoint The contact point for the force
  31870. * @returns The physics imposter
  31871. */
  31872. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  31873. /**
  31874. * Apply an impulse
  31875. * @param force The impulse force
  31876. * @param contactPoint The contact point for the impulse force
  31877. * @returns The physics imposter
  31878. */
  31879. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  31880. /**
  31881. * A help function to create a joint
  31882. * @param otherImpostor A physics imposter used to create a joint
  31883. * @param jointType The type of joint
  31884. * @param jointData The data for the joint
  31885. * @returns The physics imposter
  31886. */
  31887. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  31888. /**
  31889. * Add a joint to this impostor with a different impostor
  31890. * @param otherImpostor A physics imposter used to add a joint
  31891. * @param joint The joint to add
  31892. * @returns The physics imposter
  31893. */
  31894. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  31895. /**
  31896. * Add an anchor to a cloth impostor
  31897. * @param otherImpostor rigid impostor to anchor to
  31898. * @param width ratio across width from 0 to 1
  31899. * @param height ratio up height from 0 to 1
  31900. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  31901. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  31902. * @returns impostor the soft imposter
  31903. */
  31904. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  31905. /**
  31906. * Add a hook to a rope impostor
  31907. * @param otherImpostor rigid impostor to anchor to
  31908. * @param length ratio across rope from 0 to 1
  31909. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  31910. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  31911. * @returns impostor the rope imposter
  31912. */
  31913. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  31914. /**
  31915. * Will keep this body still, in a sleep mode.
  31916. * @returns the physics imposter
  31917. */
  31918. sleep(): PhysicsImpostor;
  31919. /**
  31920. * Wake the body up.
  31921. * @returns The physics imposter
  31922. */
  31923. wakeUp(): PhysicsImpostor;
  31924. /**
  31925. * Clones the physics imposter
  31926. * @param newObject The physics imposter clones to this physics-enabled object
  31927. * @returns A nullable physics imposter
  31928. */
  31929. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31930. /**
  31931. * Disposes the physics imposter
  31932. */
  31933. dispose(): void;
  31934. /**
  31935. * Sets the delta position
  31936. * @param position The delta position amount
  31937. */
  31938. setDeltaPosition(position: Vector3): void;
  31939. /**
  31940. * Sets the delta rotation
  31941. * @param rotation The delta rotation amount
  31942. */
  31943. setDeltaRotation(rotation: Quaternion): void;
  31944. /**
  31945. * Gets the box size of the physics imposter and stores the result in the input parameter
  31946. * @param result Stores the box size
  31947. * @returns The physics imposter
  31948. */
  31949. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  31950. /**
  31951. * Gets the radius of the physics imposter
  31952. * @returns Radius of the physics imposter
  31953. */
  31954. getRadius(): number;
  31955. /**
  31956. * Sync a bone with this impostor
  31957. * @param bone The bone to sync to the impostor.
  31958. * @param boneMesh The mesh that the bone is influencing.
  31959. * @param jointPivot The pivot of the joint / bone in local space.
  31960. * @param distToJoint Optional distance from the impostor to the joint.
  31961. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  31962. */
  31963. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  31964. /**
  31965. * Sync impostor to a bone
  31966. * @param bone The bone that the impostor will be synced to.
  31967. * @param boneMesh The mesh that the bone is influencing.
  31968. * @param jointPivot The pivot of the joint / bone in local space.
  31969. * @param distToJoint Optional distance from the impostor to the joint.
  31970. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  31971. * @param boneAxis Optional vector3 axis the bone is aligned with
  31972. */
  31973. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  31974. /**
  31975. * No-Imposter type
  31976. */
  31977. static NoImpostor: number;
  31978. /**
  31979. * Sphere-Imposter type
  31980. */
  31981. static SphereImpostor: number;
  31982. /**
  31983. * Box-Imposter type
  31984. */
  31985. static BoxImpostor: number;
  31986. /**
  31987. * Plane-Imposter type
  31988. */
  31989. static PlaneImpostor: number;
  31990. /**
  31991. * Mesh-imposter type
  31992. */
  31993. static MeshImpostor: number;
  31994. /**
  31995. * Capsule-Impostor type (Ammo.js plugin only)
  31996. */
  31997. static CapsuleImpostor: number;
  31998. /**
  31999. * Cylinder-Imposter type
  32000. */
  32001. static CylinderImpostor: number;
  32002. /**
  32003. * Particle-Imposter type
  32004. */
  32005. static ParticleImpostor: number;
  32006. /**
  32007. * Heightmap-Imposter type
  32008. */
  32009. static HeightmapImpostor: number;
  32010. /**
  32011. * ConvexHull-Impostor type (Ammo.js plugin only)
  32012. */
  32013. static ConvexHullImpostor: number;
  32014. /**
  32015. * Custom-Imposter type (Ammo.js plugin only)
  32016. */
  32017. static CustomImpostor: number;
  32018. /**
  32019. * Rope-Imposter type
  32020. */
  32021. static RopeImpostor: number;
  32022. /**
  32023. * Cloth-Imposter type
  32024. */
  32025. static ClothImpostor: number;
  32026. /**
  32027. * Softbody-Imposter type
  32028. */
  32029. static SoftbodyImpostor: number;
  32030. }
  32031. }
  32032. declare module BABYLON {
  32033. /**
  32034. * @hidden
  32035. **/
  32036. export class _CreationDataStorage {
  32037. closePath?: boolean;
  32038. closeArray?: boolean;
  32039. idx: number[];
  32040. dashSize: number;
  32041. gapSize: number;
  32042. path3D: Path3D;
  32043. pathArray: Vector3[][];
  32044. arc: number;
  32045. radius: number;
  32046. cap: number;
  32047. tessellation: number;
  32048. }
  32049. /**
  32050. * @hidden
  32051. **/
  32052. class _InstanceDataStorage {
  32053. visibleInstances: any;
  32054. batchCache: _InstancesBatch;
  32055. instancesBufferSize: number;
  32056. instancesBuffer: Nullable<Buffer>;
  32057. instancesData: Float32Array;
  32058. overridenInstanceCount: number;
  32059. isFrozen: boolean;
  32060. previousBatch: Nullable<_InstancesBatch>;
  32061. hardwareInstancedRendering: boolean;
  32062. sideOrientation: number;
  32063. manualUpdate: boolean;
  32064. previousRenderId: number;
  32065. }
  32066. /**
  32067. * @hidden
  32068. **/
  32069. export class _InstancesBatch {
  32070. mustReturn: boolean;
  32071. visibleInstances: Nullable<InstancedMesh[]>[];
  32072. renderSelf: boolean[];
  32073. hardwareInstancedRendering: boolean[];
  32074. }
  32075. /**
  32076. * @hidden
  32077. **/
  32078. class _ThinInstanceDataStorage {
  32079. instancesCount: number;
  32080. matrixBuffer: Nullable<Buffer>;
  32081. matrixBufferSize: number;
  32082. matrixData: Nullable<Float32Array>;
  32083. boundingVectors: Array<Vector3>;
  32084. worldMatrices: Nullable<Matrix[]>;
  32085. }
  32086. /**
  32087. * Class used to represent renderable models
  32088. */
  32089. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32090. /**
  32091. * Mesh side orientation : usually the external or front surface
  32092. */
  32093. static readonly FRONTSIDE: number;
  32094. /**
  32095. * Mesh side orientation : usually the internal or back surface
  32096. */
  32097. static readonly BACKSIDE: number;
  32098. /**
  32099. * Mesh side orientation : both internal and external or front and back surfaces
  32100. */
  32101. static readonly DOUBLESIDE: number;
  32102. /**
  32103. * Mesh side orientation : by default, `FRONTSIDE`
  32104. */
  32105. static readonly DEFAULTSIDE: number;
  32106. /**
  32107. * Mesh cap setting : no cap
  32108. */
  32109. static readonly NO_CAP: number;
  32110. /**
  32111. * Mesh cap setting : one cap at the beginning of the mesh
  32112. */
  32113. static readonly CAP_START: number;
  32114. /**
  32115. * Mesh cap setting : one cap at the end of the mesh
  32116. */
  32117. static readonly CAP_END: number;
  32118. /**
  32119. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32120. */
  32121. static readonly CAP_ALL: number;
  32122. /**
  32123. * Mesh pattern setting : no flip or rotate
  32124. */
  32125. static readonly NO_FLIP: number;
  32126. /**
  32127. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32128. */
  32129. static readonly FLIP_TILE: number;
  32130. /**
  32131. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32132. */
  32133. static readonly ROTATE_TILE: number;
  32134. /**
  32135. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32136. */
  32137. static readonly FLIP_ROW: number;
  32138. /**
  32139. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32140. */
  32141. static readonly ROTATE_ROW: number;
  32142. /**
  32143. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32144. */
  32145. static readonly FLIP_N_ROTATE_TILE: number;
  32146. /**
  32147. * Mesh pattern setting : rotate pattern and rotate
  32148. */
  32149. static readonly FLIP_N_ROTATE_ROW: number;
  32150. /**
  32151. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32152. */
  32153. static readonly CENTER: number;
  32154. /**
  32155. * Mesh tile positioning : part tiles on left
  32156. */
  32157. static readonly LEFT: number;
  32158. /**
  32159. * Mesh tile positioning : part tiles on right
  32160. */
  32161. static readonly RIGHT: number;
  32162. /**
  32163. * Mesh tile positioning : part tiles on top
  32164. */
  32165. static readonly TOP: number;
  32166. /**
  32167. * Mesh tile positioning : part tiles on bottom
  32168. */
  32169. static readonly BOTTOM: number;
  32170. /**
  32171. * Gets the default side orientation.
  32172. * @param orientation the orientation to value to attempt to get
  32173. * @returns the default orientation
  32174. * @hidden
  32175. */
  32176. static _GetDefaultSideOrientation(orientation?: number): number;
  32177. private _internalMeshDataInfo;
  32178. get computeBonesUsingShaders(): boolean;
  32179. set computeBonesUsingShaders(value: boolean);
  32180. /**
  32181. * An event triggered before rendering the mesh
  32182. */
  32183. get onBeforeRenderObservable(): Observable<Mesh>;
  32184. /**
  32185. * An event triggered before binding the mesh
  32186. */
  32187. get onBeforeBindObservable(): Observable<Mesh>;
  32188. /**
  32189. * An event triggered after rendering the mesh
  32190. */
  32191. get onAfterRenderObservable(): Observable<Mesh>;
  32192. /**
  32193. * An event triggered before drawing the mesh
  32194. */
  32195. get onBeforeDrawObservable(): Observable<Mesh>;
  32196. private _onBeforeDrawObserver;
  32197. /**
  32198. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32199. */
  32200. set onBeforeDraw(callback: () => void);
  32201. get hasInstances(): boolean;
  32202. get hasThinInstances(): boolean;
  32203. /**
  32204. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32205. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32206. */
  32207. delayLoadState: number;
  32208. /**
  32209. * Gets the list of instances created from this mesh
  32210. * it is not supposed to be modified manually.
  32211. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32212. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32213. */
  32214. instances: InstancedMesh[];
  32215. /**
  32216. * Gets the file containing delay loading data for this mesh
  32217. */
  32218. delayLoadingFile: string;
  32219. /** @hidden */
  32220. _binaryInfo: any;
  32221. /**
  32222. * User defined function used to change how LOD level selection is done
  32223. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32224. */
  32225. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32226. /**
  32227. * Gets or sets the morph target manager
  32228. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32229. */
  32230. get morphTargetManager(): Nullable<MorphTargetManager>;
  32231. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32232. /** @hidden */
  32233. _creationDataStorage: Nullable<_CreationDataStorage>;
  32234. /** @hidden */
  32235. _geometry: Nullable<Geometry>;
  32236. /** @hidden */
  32237. _delayInfo: Array<string>;
  32238. /** @hidden */
  32239. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32240. /** @hidden */
  32241. _instanceDataStorage: _InstanceDataStorage;
  32242. /** @hidden */
  32243. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32244. private _effectiveMaterial;
  32245. /** @hidden */
  32246. _shouldGenerateFlatShading: boolean;
  32247. /** @hidden */
  32248. _originalBuilderSideOrientation: number;
  32249. /**
  32250. * Use this property to change the original side orientation defined at construction time
  32251. */
  32252. overrideMaterialSideOrientation: Nullable<number>;
  32253. /**
  32254. * Gets the source mesh (the one used to clone this one from)
  32255. */
  32256. get source(): Nullable<Mesh>;
  32257. /**
  32258. * Gets the list of clones of this mesh
  32259. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32260. * Note that useClonedMeshMap=true is the default setting
  32261. */
  32262. get cloneMeshMap(): Nullable<{
  32263. [id: string]: Mesh | undefined;
  32264. }>;
  32265. /**
  32266. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32267. */
  32268. get isUnIndexed(): boolean;
  32269. set isUnIndexed(value: boolean);
  32270. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32271. get worldMatrixInstancedBuffer(): Float32Array;
  32272. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32273. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32274. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32275. /**
  32276. * @constructor
  32277. * @param name The value used by scene.getMeshByName() to do a lookup.
  32278. * @param scene The scene to add this mesh to.
  32279. * @param parent The parent of this mesh, if it has one
  32280. * @param source An optional Mesh from which geometry is shared, cloned.
  32281. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32282. * When false, achieved by calling a clone(), also passing False.
  32283. * This will make creation of children, recursive.
  32284. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32285. */
  32286. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32287. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32288. doNotInstantiate: boolean;
  32289. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32290. /**
  32291. * Gets the class name
  32292. * @returns the string "Mesh".
  32293. */
  32294. getClassName(): string;
  32295. /** @hidden */
  32296. get _isMesh(): boolean;
  32297. /**
  32298. * Returns a description of this mesh
  32299. * @param fullDetails define if full details about this mesh must be used
  32300. * @returns a descriptive string representing this mesh
  32301. */
  32302. toString(fullDetails?: boolean): string;
  32303. /** @hidden */
  32304. _unBindEffect(): void;
  32305. /**
  32306. * Gets a boolean indicating if this mesh has LOD
  32307. */
  32308. get hasLODLevels(): boolean;
  32309. /**
  32310. * Gets the list of MeshLODLevel associated with the current mesh
  32311. * @returns an array of MeshLODLevel
  32312. */
  32313. getLODLevels(): MeshLODLevel[];
  32314. private _sortLODLevels;
  32315. /**
  32316. * Add a mesh as LOD level triggered at the given distance.
  32317. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32318. * @param distance The distance from the center of the object to show this level
  32319. * @param mesh The mesh to be added as LOD level (can be null)
  32320. * @return This mesh (for chaining)
  32321. */
  32322. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32323. /**
  32324. * Returns the LOD level mesh at the passed distance or null if not found.
  32325. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32326. * @param distance The distance from the center of the object to show this level
  32327. * @returns a Mesh or `null`
  32328. */
  32329. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32330. /**
  32331. * Remove a mesh from the LOD array
  32332. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32333. * @param mesh defines the mesh to be removed
  32334. * @return This mesh (for chaining)
  32335. */
  32336. removeLODLevel(mesh: Mesh): Mesh;
  32337. /**
  32338. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32339. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32340. * @param camera defines the camera to use to compute distance
  32341. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32342. * @return This mesh (for chaining)
  32343. */
  32344. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32345. /**
  32346. * Gets the mesh internal Geometry object
  32347. */
  32348. get geometry(): Nullable<Geometry>;
  32349. /**
  32350. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32351. * @returns the total number of vertices
  32352. */
  32353. getTotalVertices(): number;
  32354. /**
  32355. * Returns the content of an associated vertex buffer
  32356. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32357. * - VertexBuffer.PositionKind
  32358. * - VertexBuffer.UVKind
  32359. * - VertexBuffer.UV2Kind
  32360. * - VertexBuffer.UV3Kind
  32361. * - VertexBuffer.UV4Kind
  32362. * - VertexBuffer.UV5Kind
  32363. * - VertexBuffer.UV6Kind
  32364. * - VertexBuffer.ColorKind
  32365. * - VertexBuffer.MatricesIndicesKind
  32366. * - VertexBuffer.MatricesIndicesExtraKind
  32367. * - VertexBuffer.MatricesWeightsKind
  32368. * - VertexBuffer.MatricesWeightsExtraKind
  32369. * @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
  32370. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32371. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32372. */
  32373. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32374. /**
  32375. * Returns the mesh VertexBuffer object from the requested `kind`
  32376. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32377. * - VertexBuffer.PositionKind
  32378. * - VertexBuffer.NormalKind
  32379. * - VertexBuffer.UVKind
  32380. * - VertexBuffer.UV2Kind
  32381. * - VertexBuffer.UV3Kind
  32382. * - VertexBuffer.UV4Kind
  32383. * - VertexBuffer.UV5Kind
  32384. * - VertexBuffer.UV6Kind
  32385. * - VertexBuffer.ColorKind
  32386. * - VertexBuffer.MatricesIndicesKind
  32387. * - VertexBuffer.MatricesIndicesExtraKind
  32388. * - VertexBuffer.MatricesWeightsKind
  32389. * - VertexBuffer.MatricesWeightsExtraKind
  32390. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32391. */
  32392. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32393. /**
  32394. * Tests if a specific vertex buffer is associated with this mesh
  32395. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32396. * - VertexBuffer.PositionKind
  32397. * - VertexBuffer.NormalKind
  32398. * - VertexBuffer.UVKind
  32399. * - VertexBuffer.UV2Kind
  32400. * - VertexBuffer.UV3Kind
  32401. * - VertexBuffer.UV4Kind
  32402. * - VertexBuffer.UV5Kind
  32403. * - VertexBuffer.UV6Kind
  32404. * - VertexBuffer.ColorKind
  32405. * - VertexBuffer.MatricesIndicesKind
  32406. * - VertexBuffer.MatricesIndicesExtraKind
  32407. * - VertexBuffer.MatricesWeightsKind
  32408. * - VertexBuffer.MatricesWeightsExtraKind
  32409. * @returns a boolean
  32410. */
  32411. isVerticesDataPresent(kind: string): boolean;
  32412. /**
  32413. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32414. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32415. * - VertexBuffer.PositionKind
  32416. * - VertexBuffer.UVKind
  32417. * - VertexBuffer.UV2Kind
  32418. * - VertexBuffer.UV3Kind
  32419. * - VertexBuffer.UV4Kind
  32420. * - VertexBuffer.UV5Kind
  32421. * - VertexBuffer.UV6Kind
  32422. * - VertexBuffer.ColorKind
  32423. * - VertexBuffer.MatricesIndicesKind
  32424. * - VertexBuffer.MatricesIndicesExtraKind
  32425. * - VertexBuffer.MatricesWeightsKind
  32426. * - VertexBuffer.MatricesWeightsExtraKind
  32427. * @returns a boolean
  32428. */
  32429. isVertexBufferUpdatable(kind: string): boolean;
  32430. /**
  32431. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32432. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32433. * - VertexBuffer.PositionKind
  32434. * - VertexBuffer.NormalKind
  32435. * - VertexBuffer.UVKind
  32436. * - VertexBuffer.UV2Kind
  32437. * - VertexBuffer.UV3Kind
  32438. * - VertexBuffer.UV4Kind
  32439. * - VertexBuffer.UV5Kind
  32440. * - VertexBuffer.UV6Kind
  32441. * - VertexBuffer.ColorKind
  32442. * - VertexBuffer.MatricesIndicesKind
  32443. * - VertexBuffer.MatricesIndicesExtraKind
  32444. * - VertexBuffer.MatricesWeightsKind
  32445. * - VertexBuffer.MatricesWeightsExtraKind
  32446. * @returns an array of strings
  32447. */
  32448. getVerticesDataKinds(): string[];
  32449. /**
  32450. * Returns a positive integer : the total number of indices in this mesh geometry.
  32451. * @returns the numner of indices or zero if the mesh has no geometry.
  32452. */
  32453. getTotalIndices(): number;
  32454. /**
  32455. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32456. * @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.
  32457. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32458. * @returns the indices array or an empty array if the mesh has no geometry
  32459. */
  32460. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32461. get isBlocked(): boolean;
  32462. /**
  32463. * Determine if the current mesh is ready to be rendered
  32464. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32465. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32466. * @returns true if all associated assets are ready (material, textures, shaders)
  32467. */
  32468. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32469. /**
  32470. * 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.
  32471. */
  32472. get areNormalsFrozen(): boolean;
  32473. /**
  32474. * 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.
  32475. * @returns the current mesh
  32476. */
  32477. freezeNormals(): Mesh;
  32478. /**
  32479. * 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
  32480. * @returns the current mesh
  32481. */
  32482. unfreezeNormals(): Mesh;
  32483. /**
  32484. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32485. */
  32486. set overridenInstanceCount(count: number);
  32487. /** @hidden */
  32488. _preActivate(): Mesh;
  32489. /** @hidden */
  32490. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32491. /** @hidden */
  32492. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32493. protected _afterComputeWorldMatrix(): void;
  32494. /** @hidden */
  32495. _postActivate(): void;
  32496. /**
  32497. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32498. * This means the mesh underlying bounding box and sphere are recomputed.
  32499. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32500. * @returns the current mesh
  32501. */
  32502. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32503. /** @hidden */
  32504. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32505. /**
  32506. * This function will subdivide the mesh into multiple submeshes
  32507. * @param count defines the expected number of submeshes
  32508. */
  32509. subdivide(count: number): void;
  32510. /**
  32511. * Copy a FloatArray into a specific associated vertex buffer
  32512. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32513. * - VertexBuffer.PositionKind
  32514. * - VertexBuffer.UVKind
  32515. * - VertexBuffer.UV2Kind
  32516. * - VertexBuffer.UV3Kind
  32517. * - VertexBuffer.UV4Kind
  32518. * - VertexBuffer.UV5Kind
  32519. * - VertexBuffer.UV6Kind
  32520. * - VertexBuffer.ColorKind
  32521. * - VertexBuffer.MatricesIndicesKind
  32522. * - VertexBuffer.MatricesIndicesExtraKind
  32523. * - VertexBuffer.MatricesWeightsKind
  32524. * - VertexBuffer.MatricesWeightsExtraKind
  32525. * @param data defines the data source
  32526. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32527. * @param stride defines the data stride size (can be null)
  32528. * @returns the current mesh
  32529. */
  32530. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32531. /**
  32532. * Delete a vertex buffer associated with this mesh
  32533. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32534. * - VertexBuffer.PositionKind
  32535. * - VertexBuffer.UVKind
  32536. * - VertexBuffer.UV2Kind
  32537. * - VertexBuffer.UV3Kind
  32538. * - VertexBuffer.UV4Kind
  32539. * - VertexBuffer.UV5Kind
  32540. * - VertexBuffer.UV6Kind
  32541. * - VertexBuffer.ColorKind
  32542. * - VertexBuffer.MatricesIndicesKind
  32543. * - VertexBuffer.MatricesIndicesExtraKind
  32544. * - VertexBuffer.MatricesWeightsKind
  32545. * - VertexBuffer.MatricesWeightsExtraKind
  32546. */
  32547. removeVerticesData(kind: string): void;
  32548. /**
  32549. * Flags an associated vertex buffer as updatable
  32550. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32551. * - VertexBuffer.PositionKind
  32552. * - VertexBuffer.UVKind
  32553. * - VertexBuffer.UV2Kind
  32554. * - VertexBuffer.UV3Kind
  32555. * - VertexBuffer.UV4Kind
  32556. * - VertexBuffer.UV5Kind
  32557. * - VertexBuffer.UV6Kind
  32558. * - VertexBuffer.ColorKind
  32559. * - VertexBuffer.MatricesIndicesKind
  32560. * - VertexBuffer.MatricesIndicesExtraKind
  32561. * - VertexBuffer.MatricesWeightsKind
  32562. * - VertexBuffer.MatricesWeightsExtraKind
  32563. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32564. */
  32565. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32566. /**
  32567. * Sets the mesh global Vertex Buffer
  32568. * @param buffer defines the buffer to use
  32569. * @returns the current mesh
  32570. */
  32571. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32572. /**
  32573. * Update a specific associated vertex buffer
  32574. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32575. * - VertexBuffer.PositionKind
  32576. * - VertexBuffer.UVKind
  32577. * - VertexBuffer.UV2Kind
  32578. * - VertexBuffer.UV3Kind
  32579. * - VertexBuffer.UV4Kind
  32580. * - VertexBuffer.UV5Kind
  32581. * - VertexBuffer.UV6Kind
  32582. * - VertexBuffer.ColorKind
  32583. * - VertexBuffer.MatricesIndicesKind
  32584. * - VertexBuffer.MatricesIndicesExtraKind
  32585. * - VertexBuffer.MatricesWeightsKind
  32586. * - VertexBuffer.MatricesWeightsExtraKind
  32587. * @param data defines the data source
  32588. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32589. * @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)
  32590. * @returns the current mesh
  32591. */
  32592. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32593. /**
  32594. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32595. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32596. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32597. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32598. * @returns the current mesh
  32599. */
  32600. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32601. /**
  32602. * Creates a un-shared specific occurence of the geometry for the mesh.
  32603. * @returns the current mesh
  32604. */
  32605. makeGeometryUnique(): Mesh;
  32606. /**
  32607. * Set the index buffer of this mesh
  32608. * @param indices defines the source data
  32609. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32610. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32611. * @returns the current mesh
  32612. */
  32613. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32614. /**
  32615. * Update the current index buffer
  32616. * @param indices defines the source data
  32617. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32618. * @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)
  32619. * @returns the current mesh
  32620. */
  32621. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32622. /**
  32623. * Invert the geometry to move from a right handed system to a left handed one.
  32624. * @returns the current mesh
  32625. */
  32626. toLeftHanded(): Mesh;
  32627. /** @hidden */
  32628. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32629. /** @hidden */
  32630. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32631. /**
  32632. * Registers for this mesh a javascript function called just before the rendering process
  32633. * @param func defines the function to call before rendering this mesh
  32634. * @returns the current mesh
  32635. */
  32636. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32637. /**
  32638. * Disposes a previously registered javascript function called before the rendering
  32639. * @param func defines the function to remove
  32640. * @returns the current mesh
  32641. */
  32642. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32643. /**
  32644. * Registers for this mesh a javascript function called just after the rendering is complete
  32645. * @param func defines the function to call after rendering this mesh
  32646. * @returns the current mesh
  32647. */
  32648. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32649. /**
  32650. * Disposes a previously registered javascript function called after the rendering.
  32651. * @param func defines the function to remove
  32652. * @returns the current mesh
  32653. */
  32654. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32655. /** @hidden */
  32656. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32657. /** @hidden */
  32658. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32659. /** @hidden */
  32660. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32661. /** @hidden */
  32662. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32663. /** @hidden */
  32664. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32665. /** @hidden */
  32666. _rebuild(): void;
  32667. /** @hidden */
  32668. _freeze(): void;
  32669. /** @hidden */
  32670. _unFreeze(): void;
  32671. /**
  32672. * 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
  32673. * @param subMesh defines the subMesh to render
  32674. * @param enableAlphaMode defines if alpha mode can be changed
  32675. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  32676. * @returns the current mesh
  32677. */
  32678. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  32679. private _onBeforeDraw;
  32680. /**
  32681. * Renormalize the mesh and patch it up if there are no weights
  32682. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  32683. * However in the case of zero weights then we set just a single influence to 1.
  32684. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  32685. */
  32686. cleanMatrixWeights(): void;
  32687. private normalizeSkinFourWeights;
  32688. private normalizeSkinWeightsAndExtra;
  32689. /**
  32690. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  32691. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  32692. * the user know there was an issue with importing the mesh
  32693. * @returns a validation object with skinned, valid and report string
  32694. */
  32695. validateSkinning(): {
  32696. skinned: boolean;
  32697. valid: boolean;
  32698. report: string;
  32699. };
  32700. /** @hidden */
  32701. _checkDelayState(): Mesh;
  32702. private _queueLoad;
  32703. /**
  32704. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32705. * A mesh is in the frustum if its bounding box intersects the frustum
  32706. * @param frustumPlanes defines the frustum to test
  32707. * @returns true if the mesh is in the frustum planes
  32708. */
  32709. isInFrustum(frustumPlanes: Plane[]): boolean;
  32710. /**
  32711. * Sets the mesh material by the material or multiMaterial `id` property
  32712. * @param id is a string identifying the material or the multiMaterial
  32713. * @returns the current mesh
  32714. */
  32715. setMaterialByID(id: string): Mesh;
  32716. /**
  32717. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  32718. * @returns an array of IAnimatable
  32719. */
  32720. getAnimatables(): IAnimatable[];
  32721. /**
  32722. * Modifies the mesh geometry according to the passed transformation matrix.
  32723. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  32724. * The mesh normals are modified using the same transformation.
  32725. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32726. * @param transform defines the transform matrix to use
  32727. * @see https://doc.babylonjs.com/resources/baking_transformations
  32728. * @returns the current mesh
  32729. */
  32730. bakeTransformIntoVertices(transform: Matrix): Mesh;
  32731. /**
  32732. * Modifies the mesh geometry according to its own current World Matrix.
  32733. * The mesh World Matrix is then reset.
  32734. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  32735. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32736. * @see https://doc.babylonjs.com/resources/baking_transformations
  32737. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  32738. * @returns the current mesh
  32739. */
  32740. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  32741. /** @hidden */
  32742. get _positions(): Nullable<Vector3[]>;
  32743. /** @hidden */
  32744. _resetPointsArrayCache(): Mesh;
  32745. /** @hidden */
  32746. _generatePointsArray(): boolean;
  32747. /**
  32748. * Returns a new Mesh object generated from the current mesh properties.
  32749. * This method must not get confused with createInstance()
  32750. * @param name is a string, the name given to the new mesh
  32751. * @param newParent can be any Node object (default `null`)
  32752. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  32753. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  32754. * @returns a new mesh
  32755. */
  32756. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  32757. /**
  32758. * Releases resources associated with this mesh.
  32759. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32760. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32761. */
  32762. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32763. /** @hidden */
  32764. _disposeInstanceSpecificData(): void;
  32765. /** @hidden */
  32766. _disposeThinInstanceSpecificData(): void;
  32767. /**
  32768. * Modifies the mesh geometry according to a displacement map.
  32769. * 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.
  32770. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32771. * @param url is a string, the URL from the image file is to be downloaded.
  32772. * @param minHeight is the lower limit of the displacement.
  32773. * @param maxHeight is the upper limit of the displacement.
  32774. * @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.
  32775. * @param uvOffset is an optional vector2 used to offset UV.
  32776. * @param uvScale is an optional vector2 used to scale UV.
  32777. * @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.
  32778. * @returns the Mesh.
  32779. */
  32780. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32781. /**
  32782. * Modifies the mesh geometry according to a displacementMap buffer.
  32783. * 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.
  32784. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32785. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  32786. * @param heightMapWidth is the width of the buffer image.
  32787. * @param heightMapHeight is the height of the buffer image.
  32788. * @param minHeight is the lower limit of the displacement.
  32789. * @param maxHeight is the upper limit of the displacement.
  32790. * @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.
  32791. * @param uvOffset is an optional vector2 used to offset UV.
  32792. * @param uvScale is an optional vector2 used to scale UV.
  32793. * @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.
  32794. * @returns the Mesh.
  32795. */
  32796. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32797. /**
  32798. * Modify the mesh to get a flat shading rendering.
  32799. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  32800. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  32801. * @returns current mesh
  32802. */
  32803. convertToFlatShadedMesh(): Mesh;
  32804. /**
  32805. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  32806. * In other words, more vertices, no more indices and a single bigger VBO.
  32807. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  32808. * @returns current mesh
  32809. */
  32810. convertToUnIndexedMesh(): Mesh;
  32811. /**
  32812. * Inverses facet orientations.
  32813. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32814. * @param flipNormals will also inverts the normals
  32815. * @returns current mesh
  32816. */
  32817. flipFaces(flipNormals?: boolean): Mesh;
  32818. /**
  32819. * Increase the number of facets and hence vertices in a mesh
  32820. * Vertex normals are interpolated from existing vertex normals
  32821. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32822. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  32823. */
  32824. increaseVertices(numberPerEdge: number): void;
  32825. /**
  32826. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  32827. * This will undo any application of covertToFlatShadedMesh
  32828. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32829. */
  32830. forceSharedVertices(): void;
  32831. /** @hidden */
  32832. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  32833. /** @hidden */
  32834. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  32835. /**
  32836. * Creates a new InstancedMesh object from the mesh model.
  32837. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32838. * @param name defines the name of the new instance
  32839. * @returns a new InstancedMesh
  32840. */
  32841. createInstance(name: string): InstancedMesh;
  32842. /**
  32843. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  32844. * After this call, all the mesh instances have the same submeshes than the current mesh.
  32845. * @returns the current mesh
  32846. */
  32847. synchronizeInstances(): Mesh;
  32848. /**
  32849. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  32850. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  32851. * This should be used together with the simplification to avoid disappearing triangles.
  32852. * @param successCallback an optional success callback to be called after the optimization finished.
  32853. * @returns the current mesh
  32854. */
  32855. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  32856. /**
  32857. * Serialize current mesh
  32858. * @param serializationObject defines the object which will receive the serialization data
  32859. */
  32860. serialize(serializationObject: any): void;
  32861. /** @hidden */
  32862. _syncGeometryWithMorphTargetManager(): void;
  32863. /** @hidden */
  32864. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  32865. /**
  32866. * Returns a new Mesh object parsed from the source provided.
  32867. * @param parsedMesh is the source
  32868. * @param scene defines the hosting scene
  32869. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  32870. * @returns a new Mesh
  32871. */
  32872. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  32873. /**
  32874. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  32875. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  32876. * @param name defines the name of the mesh to create
  32877. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  32878. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  32879. * @param closePath creates a seam between the first and the last points of each path of the path array
  32880. * @param offset is taken in account only if the `pathArray` is containing a single path
  32881. * @param scene defines the hosting scene
  32882. * @param updatable defines if the mesh must be flagged as updatable
  32883. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  32884. * @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)
  32885. * @returns a new Mesh
  32886. */
  32887. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  32888. /**
  32889. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  32890. * @param name defines the name of the mesh to create
  32891. * @param radius sets the radius size (float) of the polygon (default 0.5)
  32892. * @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
  32893. * @param scene defines the hosting scene
  32894. * @param updatable defines if the mesh must be flagged as updatable
  32895. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  32896. * @returns a new Mesh
  32897. */
  32898. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  32899. /**
  32900. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  32901. * @param name defines the name of the mesh to create
  32902. * @param size sets the size (float) of each box side (default 1)
  32903. * @param scene defines the hosting scene
  32904. * @param updatable defines if the mesh must be flagged as updatable
  32905. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  32906. * @returns a new Mesh
  32907. */
  32908. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  32909. /**
  32910. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  32911. * @param name defines the name of the mesh to create
  32912. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  32913. * @param diameter sets the diameter size (float) of the sphere (default 1)
  32914. * @param scene defines the hosting scene
  32915. * @param updatable defines if the mesh must be flagged as updatable
  32916. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  32917. * @returns a new Mesh
  32918. */
  32919. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  32920. /**
  32921. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  32922. * @param name defines the name of the mesh to create
  32923. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  32924. * @param diameter sets the diameter size (float) of the sphere (default 1)
  32925. * @param scene defines the hosting scene
  32926. * @returns a new Mesh
  32927. */
  32928. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  32929. /**
  32930. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  32931. * @param name defines the name of the mesh to create
  32932. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  32933. * @param diameterTop set the top cap diameter (floats, default 1)
  32934. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  32935. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  32936. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  32937. * @param scene defines the hosting scene
  32938. * @param updatable defines if the mesh must be flagged as updatable
  32939. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  32940. * @returns a new Mesh
  32941. */
  32942. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  32943. /**
  32944. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  32945. * @param name defines the name of the mesh to create
  32946. * @param diameter sets the diameter size (float) of the torus (default 1)
  32947. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  32948. * @param tessellation sets the number of torus sides (postive integer, default 16)
  32949. * @param scene defines the hosting scene
  32950. * @param updatable defines if the mesh must be flagged as updatable
  32951. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  32952. * @returns a new Mesh
  32953. */
  32954. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  32955. /**
  32956. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  32957. * @param name defines the name of the mesh to create
  32958. * @param radius sets the global radius size (float) of the torus knot (default 2)
  32959. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  32960. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  32961. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  32962. * @param p the number of windings on X axis (positive integers, default 2)
  32963. * @param q the number of windings on Y axis (positive integers, default 3)
  32964. * @param scene defines the hosting scene
  32965. * @param updatable defines if the mesh must be flagged as updatable
  32966. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  32967. * @returns a new Mesh
  32968. */
  32969. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  32970. /**
  32971. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  32972. * @param name defines the name of the mesh to create
  32973. * @param points is an array successive Vector3
  32974. * @param scene defines the hosting scene
  32975. * @param updatable defines if the mesh must be flagged as updatable
  32976. * @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).
  32977. * @returns a new Mesh
  32978. */
  32979. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  32980. /**
  32981. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  32982. * @param name defines the name of the mesh to create
  32983. * @param points is an array successive Vector3
  32984. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  32985. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  32986. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  32987. * @param scene defines the hosting scene
  32988. * @param updatable defines if the mesh must be flagged as updatable
  32989. * @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)
  32990. * @returns a new Mesh
  32991. */
  32992. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  32993. /**
  32994. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  32995. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  32996. * 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.
  32997. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32998. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  32999. * Remember you can only change the shape positions, not their number when updating a polygon.
  33000. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33001. * @param name defines the name of the mesh to create
  33002. * @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
  33003. * @param scene defines the hosting scene
  33004. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33005. * @param updatable defines if the mesh must be flagged as updatable
  33006. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33007. * @param earcutInjection can be used to inject your own earcut reference
  33008. * @returns a new Mesh
  33009. */
  33010. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33011. /**
  33012. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33013. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33014. * @param name defines the name of the mesh to create
  33015. * @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
  33016. * @param depth defines the height of extrusion
  33017. * @param scene defines the hosting scene
  33018. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33019. * @param updatable defines if the mesh must be flagged as updatable
  33020. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33021. * @param earcutInjection can be used to inject your own earcut reference
  33022. * @returns a new Mesh
  33023. */
  33024. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33025. /**
  33026. * Creates an extruded shape mesh.
  33027. * 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
  33028. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33030. * @param name defines the name of the mesh to create
  33031. * @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
  33032. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33033. * @param scale is the value to scale the shape
  33034. * @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
  33035. * @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
  33036. * @param scene defines the hosting scene
  33037. * @param updatable defines if the mesh must be flagged as updatable
  33038. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33039. * @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)
  33040. * @returns a new Mesh
  33041. */
  33042. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33043. /**
  33044. * Creates an custom extruded shape mesh.
  33045. * The custom extrusion is a parametric shape.
  33046. * It has no predefined shape. Its final shape will depend on the input parameters.
  33047. * Please consider using the same method from the MeshBuilder class instead
  33048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33049. * @param name defines the name of the mesh to create
  33050. * @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
  33051. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33052. * @param scaleFunction is a custom Javascript function called on each path point
  33053. * @param rotationFunction is a custom Javascript function called on each path point
  33054. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33055. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33056. * @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
  33057. * @param scene defines the hosting scene
  33058. * @param updatable defines if the mesh must be flagged as updatable
  33059. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33060. * @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)
  33061. * @returns a new Mesh
  33062. */
  33063. 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;
  33064. /**
  33065. * Creates lathe mesh.
  33066. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33067. * Please consider using the same method from the MeshBuilder class instead
  33068. * @param name defines the name of the mesh to create
  33069. * @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
  33070. * @param radius is the radius value of the lathe
  33071. * @param tessellation is the side number of the lathe.
  33072. * @param scene defines the hosting scene
  33073. * @param updatable defines if the mesh must be flagged as updatable
  33074. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33075. * @returns a new Mesh
  33076. */
  33077. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33078. /**
  33079. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33080. * @param name defines the name of the mesh to create
  33081. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33082. * @param scene defines the hosting scene
  33083. * @param updatable defines if the mesh must be flagged as updatable
  33084. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33085. * @returns a new Mesh
  33086. */
  33087. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33088. /**
  33089. * Creates a ground mesh.
  33090. * Please consider using the same method from the MeshBuilder class instead
  33091. * @param name defines the name of the mesh to create
  33092. * @param width set the width of the ground
  33093. * @param height set the height of the ground
  33094. * @param subdivisions sets the number of subdivisions per side
  33095. * @param scene defines the hosting scene
  33096. * @param updatable defines if the mesh must be flagged as updatable
  33097. * @returns a new Mesh
  33098. */
  33099. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33100. /**
  33101. * Creates a tiled ground mesh.
  33102. * Please consider using the same method from the MeshBuilder class instead
  33103. * @param name defines the name of the mesh to create
  33104. * @param xmin set the ground minimum X coordinate
  33105. * @param zmin set the ground minimum Y coordinate
  33106. * @param xmax set the ground maximum X coordinate
  33107. * @param zmax set the ground maximum Z coordinate
  33108. * @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
  33109. * @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
  33110. * @param scene defines the hosting scene
  33111. * @param updatable defines if the mesh must be flagged as updatable
  33112. * @returns a new Mesh
  33113. */
  33114. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33115. w: number;
  33116. h: number;
  33117. }, precision: {
  33118. w: number;
  33119. h: number;
  33120. }, scene: Scene, updatable?: boolean): Mesh;
  33121. /**
  33122. * Creates a ground mesh from a height map.
  33123. * Please consider using the same method from the MeshBuilder class instead
  33124. * @see https://doc.babylonjs.com/babylon101/height_map
  33125. * @param name defines the name of the mesh to create
  33126. * @param url sets the URL of the height map image resource
  33127. * @param width set the ground width size
  33128. * @param height set the ground height size
  33129. * @param subdivisions sets the number of subdivision per side
  33130. * @param minHeight is the minimum altitude on the ground
  33131. * @param maxHeight is the maximum altitude on the ground
  33132. * @param scene defines the hosting scene
  33133. * @param updatable defines if the mesh must be flagged as updatable
  33134. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33135. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33136. * @returns a new Mesh
  33137. */
  33138. 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;
  33139. /**
  33140. * Creates a tube mesh.
  33141. * The tube is a parametric shape.
  33142. * It has no predefined shape. Its final shape will depend on the input parameters.
  33143. * Please consider using the same method from the MeshBuilder class instead
  33144. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33145. * @param name defines the name of the mesh to create
  33146. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33147. * @param radius sets the tube radius size
  33148. * @param tessellation is the number of sides on the tubular surface
  33149. * @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
  33150. * @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
  33151. * @param scene defines the hosting scene
  33152. * @param updatable defines if the mesh must be flagged as updatable
  33153. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33154. * @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)
  33155. * @returns a new Mesh
  33156. */
  33157. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33158. (i: number, distance: number): number;
  33159. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33160. /**
  33161. * Creates a polyhedron mesh.
  33162. * Please consider using the same method from the MeshBuilder class instead.
  33163. * * 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
  33164. * * The parameter `size` (positive float, default 1) sets the polygon size
  33165. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33166. * * 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`
  33167. * * 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
  33168. * * 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)`)
  33169. * * 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
  33170. * * 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
  33171. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33172. * * 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
  33173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33174. * @param name defines the name of the mesh to create
  33175. * @param options defines the options used to create the mesh
  33176. * @param scene defines the hosting scene
  33177. * @returns a new Mesh
  33178. */
  33179. static CreatePolyhedron(name: string, options: {
  33180. type?: number;
  33181. size?: number;
  33182. sizeX?: number;
  33183. sizeY?: number;
  33184. sizeZ?: number;
  33185. custom?: any;
  33186. faceUV?: Vector4[];
  33187. faceColors?: Color4[];
  33188. updatable?: boolean;
  33189. sideOrientation?: number;
  33190. }, scene: Scene): Mesh;
  33191. /**
  33192. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33193. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33194. * * 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`)
  33195. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33196. * * 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
  33197. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33198. * * 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
  33199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33200. * @param name defines the name of the mesh
  33201. * @param options defines the options used to create the mesh
  33202. * @param scene defines the hosting scene
  33203. * @returns a new Mesh
  33204. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33205. */
  33206. static CreateIcoSphere(name: string, options: {
  33207. radius?: number;
  33208. flat?: boolean;
  33209. subdivisions?: number;
  33210. sideOrientation?: number;
  33211. updatable?: boolean;
  33212. }, scene: Scene): Mesh;
  33213. /**
  33214. * Creates a decal mesh.
  33215. * Please consider using the same method from the MeshBuilder class instead.
  33216. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33217. * @param name defines the name of the mesh
  33218. * @param sourceMesh defines the mesh receiving the decal
  33219. * @param position sets the position of the decal in world coordinates
  33220. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33221. * @param size sets the decal scaling
  33222. * @param angle sets the angle to rotate the decal
  33223. * @returns a new Mesh
  33224. */
  33225. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33226. /** Creates a Capsule Mesh
  33227. * @param name defines the name of the mesh.
  33228. * @param options the constructors options used to shape the mesh.
  33229. * @param scene defines the scene the mesh is scoped to.
  33230. * @returns the capsule mesh
  33231. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33232. */
  33233. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33234. /**
  33235. * Prepare internal position array for software CPU skinning
  33236. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33237. */
  33238. setPositionsForCPUSkinning(): Float32Array;
  33239. /**
  33240. * Prepare internal normal array for software CPU skinning
  33241. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33242. */
  33243. setNormalsForCPUSkinning(): Float32Array;
  33244. /**
  33245. * Updates the vertex buffer by applying transformation from the bones
  33246. * @param skeleton defines the skeleton to apply to current mesh
  33247. * @returns the current mesh
  33248. */
  33249. applySkeleton(skeleton: Skeleton): Mesh;
  33250. /**
  33251. * 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
  33252. * @param meshes defines the list of meshes to scan
  33253. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33254. */
  33255. static MinMax(meshes: AbstractMesh[]): {
  33256. min: Vector3;
  33257. max: Vector3;
  33258. };
  33259. /**
  33260. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33261. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33262. * @returns a vector3
  33263. */
  33264. static Center(meshesOrMinMaxVector: {
  33265. min: Vector3;
  33266. max: Vector3;
  33267. } | AbstractMesh[]): Vector3;
  33268. /**
  33269. * Merge the array of meshes into a single mesh for performance reasons.
  33270. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33271. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33272. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33273. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33274. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33275. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33276. * @returns a new mesh
  33277. */
  33278. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33279. /** @hidden */
  33280. addInstance(instance: InstancedMesh): void;
  33281. /** @hidden */
  33282. removeInstance(instance: InstancedMesh): void;
  33283. }
  33284. }
  33285. declare module BABYLON {
  33286. /**
  33287. * The options Interface for creating a Capsule Mesh
  33288. */
  33289. export interface ICreateCapsuleOptions {
  33290. /** The Orientation of the capsule. Default : Vector3.Up() */
  33291. orientation?: Vector3;
  33292. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  33293. subdivisions: number;
  33294. /** Number of cylindrical segments on the capsule. */
  33295. tessellation: number;
  33296. /** Height or Length of the capsule. */
  33297. height: number;
  33298. /** Radius of the capsule. */
  33299. radius: number;
  33300. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  33301. capSubdivisions: number;
  33302. /** Overwrite for the top radius. */
  33303. radiusTop?: number;
  33304. /** Overwrite for the bottom radius. */
  33305. radiusBottom?: number;
  33306. /** Overwrite for the top capSubdivisions. */
  33307. topCapSubdivisions?: number;
  33308. /** Overwrite for the bottom capSubdivisions. */
  33309. bottomCapSubdivisions?: number;
  33310. }
  33311. /**
  33312. * Class containing static functions to help procedurally build meshes
  33313. */
  33314. export class CapsuleBuilder {
  33315. /**
  33316. * Creates a capsule or a pill mesh
  33317. * @param name defines the name of the mesh
  33318. * @param options The constructors options.
  33319. * @param scene The scene the mesh is scoped to.
  33320. * @returns Capsule Mesh
  33321. */
  33322. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  33323. }
  33324. }
  33325. declare module BABYLON {
  33326. /**
  33327. * Define an interface for all classes that will get and set the data on vertices
  33328. */
  33329. export interface IGetSetVerticesData {
  33330. /**
  33331. * Gets a boolean indicating if specific vertex data is present
  33332. * @param kind defines the vertex data kind to use
  33333. * @returns true is data kind is present
  33334. */
  33335. isVerticesDataPresent(kind: string): boolean;
  33336. /**
  33337. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  33338. * @param kind defines the data kind (Position, normal, etc...)
  33339. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  33340. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33341. * @returns a float array containing vertex data
  33342. */
  33343. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33344. /**
  33345. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33346. * @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.
  33347. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33348. * @returns the indices array or an empty array if the mesh has no geometry
  33349. */
  33350. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33351. /**
  33352. * Set specific vertex data
  33353. * @param kind defines the data kind (Position, normal, etc...)
  33354. * @param data defines the vertex data to use
  33355. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  33356. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  33357. */
  33358. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  33359. /**
  33360. * Update a specific associated vertex buffer
  33361. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33362. * - VertexBuffer.PositionKind
  33363. * - VertexBuffer.UVKind
  33364. * - VertexBuffer.UV2Kind
  33365. * - VertexBuffer.UV3Kind
  33366. * - VertexBuffer.UV4Kind
  33367. * - VertexBuffer.UV5Kind
  33368. * - VertexBuffer.UV6Kind
  33369. * - VertexBuffer.ColorKind
  33370. * - VertexBuffer.MatricesIndicesKind
  33371. * - VertexBuffer.MatricesIndicesExtraKind
  33372. * - VertexBuffer.MatricesWeightsKind
  33373. * - VertexBuffer.MatricesWeightsExtraKind
  33374. * @param data defines the data source
  33375. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33376. * @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)
  33377. */
  33378. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  33379. /**
  33380. * Creates a new index buffer
  33381. * @param indices defines the indices to store in the index buffer
  33382. * @param totalVertices defines the total number of vertices (could be null)
  33383. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  33384. */
  33385. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  33386. }
  33387. /**
  33388. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  33389. */
  33390. export class VertexData {
  33391. /**
  33392. * Mesh side orientation : usually the external or front surface
  33393. */
  33394. static readonly FRONTSIDE: number;
  33395. /**
  33396. * Mesh side orientation : usually the internal or back surface
  33397. */
  33398. static readonly BACKSIDE: number;
  33399. /**
  33400. * Mesh side orientation : both internal and external or front and back surfaces
  33401. */
  33402. static readonly DOUBLESIDE: number;
  33403. /**
  33404. * Mesh side orientation : by default, `FRONTSIDE`
  33405. */
  33406. static readonly DEFAULTSIDE: number;
  33407. /**
  33408. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  33409. */
  33410. positions: Nullable<FloatArray>;
  33411. /**
  33412. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  33413. */
  33414. normals: Nullable<FloatArray>;
  33415. /**
  33416. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  33417. */
  33418. tangents: Nullable<FloatArray>;
  33419. /**
  33420. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33421. */
  33422. uvs: Nullable<FloatArray>;
  33423. /**
  33424. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33425. */
  33426. uvs2: Nullable<FloatArray>;
  33427. /**
  33428. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33429. */
  33430. uvs3: Nullable<FloatArray>;
  33431. /**
  33432. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33433. */
  33434. uvs4: Nullable<FloatArray>;
  33435. /**
  33436. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33437. */
  33438. uvs5: Nullable<FloatArray>;
  33439. /**
  33440. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33441. */
  33442. uvs6: Nullable<FloatArray>;
  33443. /**
  33444. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  33445. */
  33446. colors: Nullable<FloatArray>;
  33447. /**
  33448. * 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).
  33449. */
  33450. matricesIndices: Nullable<FloatArray>;
  33451. /**
  33452. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  33453. */
  33454. matricesWeights: Nullable<FloatArray>;
  33455. /**
  33456. * An array extending the number of possible indices
  33457. */
  33458. matricesIndicesExtra: Nullable<FloatArray>;
  33459. /**
  33460. * An array extending the number of possible weights when the number of indices is extended
  33461. */
  33462. matricesWeightsExtra: Nullable<FloatArray>;
  33463. /**
  33464. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  33465. */
  33466. indices: Nullable<IndicesArray>;
  33467. /**
  33468. * Uses the passed data array to set the set the values for the specified kind of data
  33469. * @param data a linear array of floating numbers
  33470. * @param kind the type of data that is being set, eg positions, colors etc
  33471. */
  33472. set(data: FloatArray, kind: string): void;
  33473. /**
  33474. * Associates the vertexData to the passed Mesh.
  33475. * Sets it as updatable or not (default `false`)
  33476. * @param mesh the mesh the vertexData is applied to
  33477. * @param updatable when used and having the value true allows new data to update the vertexData
  33478. * @returns the VertexData
  33479. */
  33480. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  33481. /**
  33482. * Associates the vertexData to the passed Geometry.
  33483. * Sets it as updatable or not (default `false`)
  33484. * @param geometry the geometry the vertexData is applied to
  33485. * @param updatable when used and having the value true allows new data to update the vertexData
  33486. * @returns VertexData
  33487. */
  33488. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  33489. /**
  33490. * Updates the associated mesh
  33491. * @param mesh the mesh to be updated
  33492. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33493. * @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
  33494. * @returns VertexData
  33495. */
  33496. updateMesh(mesh: Mesh): VertexData;
  33497. /**
  33498. * Updates the associated geometry
  33499. * @param geometry the geometry to be updated
  33500. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33501. * @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
  33502. * @returns VertexData.
  33503. */
  33504. updateGeometry(geometry: Geometry): VertexData;
  33505. private _applyTo;
  33506. private _update;
  33507. /**
  33508. * Transforms each position and each normal of the vertexData according to the passed Matrix
  33509. * @param matrix the transforming matrix
  33510. * @returns the VertexData
  33511. */
  33512. transform(matrix: Matrix): VertexData;
  33513. /**
  33514. * Merges the passed VertexData into the current one
  33515. * @param other the VertexData to be merged into the current one
  33516. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  33517. * @returns the modified VertexData
  33518. */
  33519. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  33520. private _mergeElement;
  33521. private _validate;
  33522. /**
  33523. * Serializes the VertexData
  33524. * @returns a serialized object
  33525. */
  33526. serialize(): any;
  33527. /**
  33528. * Extracts the vertexData from a mesh
  33529. * @param mesh the mesh from which to extract the VertexData
  33530. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  33531. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33532. * @returns the object VertexData associated to the passed mesh
  33533. */
  33534. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33535. /**
  33536. * Extracts the vertexData from the geometry
  33537. * @param geometry the geometry from which to extract the VertexData
  33538. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  33539. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33540. * @returns the object VertexData associated to the passed mesh
  33541. */
  33542. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33543. private static _ExtractFrom;
  33544. /**
  33545. * Creates the VertexData for a Ribbon
  33546. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  33547. * * pathArray array of paths, each of which an array of successive Vector3
  33548. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  33549. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  33550. * * 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
  33551. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33552. * * 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)
  33553. * * 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)
  33554. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  33555. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  33556. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  33557. * @returns the VertexData of the ribbon
  33558. */
  33559. static CreateRibbon(options: {
  33560. pathArray: Vector3[][];
  33561. closeArray?: boolean;
  33562. closePath?: boolean;
  33563. offset?: number;
  33564. sideOrientation?: number;
  33565. frontUVs?: Vector4;
  33566. backUVs?: Vector4;
  33567. invertUV?: boolean;
  33568. uvs?: Vector2[];
  33569. colors?: Color4[];
  33570. }): VertexData;
  33571. /**
  33572. * Creates the VertexData for a box
  33573. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33574. * * size sets the width, height and depth of the box to the value of size, optional default 1
  33575. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  33576. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  33577. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  33578. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33579. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33581. * * 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)
  33582. * * 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)
  33583. * @returns the VertexData of the box
  33584. */
  33585. static CreateBox(options: {
  33586. size?: number;
  33587. width?: number;
  33588. height?: number;
  33589. depth?: number;
  33590. faceUV?: Vector4[];
  33591. faceColors?: Color4[];
  33592. sideOrientation?: number;
  33593. frontUVs?: Vector4;
  33594. backUVs?: Vector4;
  33595. }): VertexData;
  33596. /**
  33597. * Creates the VertexData for a tiled box
  33598. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33599. * * faceTiles sets the pattern, tile size and number of tiles for a face
  33600. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33601. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33602. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33603. * @returns the VertexData of the box
  33604. */
  33605. static CreateTiledBox(options: {
  33606. pattern?: number;
  33607. width?: number;
  33608. height?: number;
  33609. depth?: number;
  33610. tileSize?: number;
  33611. tileWidth?: number;
  33612. tileHeight?: number;
  33613. alignHorizontal?: number;
  33614. alignVertical?: number;
  33615. faceUV?: Vector4[];
  33616. faceColors?: Color4[];
  33617. sideOrientation?: number;
  33618. }): VertexData;
  33619. /**
  33620. * Creates the VertexData for a tiled plane
  33621. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33622. * * pattern a limited pattern arrangement depending on the number
  33623. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  33624. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  33625. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  33626. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33627. * * 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)
  33628. * * 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)
  33629. * @returns the VertexData of the tiled plane
  33630. */
  33631. static CreateTiledPlane(options: {
  33632. pattern?: number;
  33633. tileSize?: number;
  33634. tileWidth?: number;
  33635. tileHeight?: number;
  33636. size?: number;
  33637. width?: number;
  33638. height?: number;
  33639. alignHorizontal?: number;
  33640. alignVertical?: number;
  33641. sideOrientation?: number;
  33642. frontUVs?: Vector4;
  33643. backUVs?: Vector4;
  33644. }): VertexData;
  33645. /**
  33646. * Creates the VertexData for an ellipsoid, defaults to a sphere
  33647. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33648. * * segments sets the number of horizontal strips optional, default 32
  33649. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  33650. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  33651. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  33652. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  33653. * * 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
  33654. * * 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
  33655. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33656. * * 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)
  33657. * * 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)
  33658. * @returns the VertexData of the ellipsoid
  33659. */
  33660. static CreateSphere(options: {
  33661. segments?: number;
  33662. diameter?: number;
  33663. diameterX?: number;
  33664. diameterY?: number;
  33665. diameterZ?: number;
  33666. arc?: number;
  33667. slice?: number;
  33668. sideOrientation?: number;
  33669. frontUVs?: Vector4;
  33670. backUVs?: Vector4;
  33671. }): VertexData;
  33672. /**
  33673. * Creates the VertexData for a cylinder, cone or prism
  33674. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33675. * * height sets the height (y direction) of the cylinder, optional, default 2
  33676. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  33677. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  33678. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  33679. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33680. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  33681. * * 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
  33682. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33683. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33684. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  33685. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  33686. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33687. * * 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)
  33688. * * 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)
  33689. * @returns the VertexData of the cylinder, cone or prism
  33690. */
  33691. static CreateCylinder(options: {
  33692. height?: number;
  33693. diameterTop?: number;
  33694. diameterBottom?: number;
  33695. diameter?: number;
  33696. tessellation?: number;
  33697. subdivisions?: number;
  33698. arc?: number;
  33699. faceColors?: Color4[];
  33700. faceUV?: Vector4[];
  33701. hasRings?: boolean;
  33702. enclose?: boolean;
  33703. sideOrientation?: number;
  33704. frontUVs?: Vector4;
  33705. backUVs?: Vector4;
  33706. }): VertexData;
  33707. /**
  33708. * Creates the VertexData for a torus
  33709. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33710. * * diameter the diameter of the torus, optional default 1
  33711. * * thickness the diameter of the tube forming the torus, optional default 0.5
  33712. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33713. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33714. * * 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)
  33715. * * 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)
  33716. * @returns the VertexData of the torus
  33717. */
  33718. static CreateTorus(options: {
  33719. diameter?: number;
  33720. thickness?: number;
  33721. tessellation?: number;
  33722. sideOrientation?: number;
  33723. frontUVs?: Vector4;
  33724. backUVs?: Vector4;
  33725. }): VertexData;
  33726. /**
  33727. * Creates the VertexData of the LineSystem
  33728. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  33729. * - lines an array of lines, each line being an array of successive Vector3
  33730. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  33731. * @returns the VertexData of the LineSystem
  33732. */
  33733. static CreateLineSystem(options: {
  33734. lines: Vector3[][];
  33735. colors?: Nullable<Color4[][]>;
  33736. }): VertexData;
  33737. /**
  33738. * Create the VertexData for a DashedLines
  33739. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  33740. * - points an array successive Vector3
  33741. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  33742. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  33743. * - dashNb the intended total number of dashes, optional, default 200
  33744. * @returns the VertexData for the DashedLines
  33745. */
  33746. static CreateDashedLines(options: {
  33747. points: Vector3[];
  33748. dashSize?: number;
  33749. gapSize?: number;
  33750. dashNb?: number;
  33751. }): VertexData;
  33752. /**
  33753. * Creates the VertexData for a Ground
  33754. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33755. * - width the width (x direction) of the ground, optional, default 1
  33756. * - height the height (z direction) of the ground, optional, default 1
  33757. * - subdivisions the number of subdivisions per side, optional, default 1
  33758. * @returns the VertexData of the Ground
  33759. */
  33760. static CreateGround(options: {
  33761. width?: number;
  33762. height?: number;
  33763. subdivisions?: number;
  33764. subdivisionsX?: number;
  33765. subdivisionsY?: number;
  33766. }): VertexData;
  33767. /**
  33768. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  33769. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33770. * * xmin the ground minimum X coordinate, optional, default -1
  33771. * * zmin the ground minimum Z coordinate, optional, default -1
  33772. * * xmax the ground maximum X coordinate, optional, default 1
  33773. * * zmax the ground maximum Z coordinate, optional, default 1
  33774. * * 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}
  33775. * * 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}
  33776. * @returns the VertexData of the TiledGround
  33777. */
  33778. static CreateTiledGround(options: {
  33779. xmin: number;
  33780. zmin: number;
  33781. xmax: number;
  33782. zmax: number;
  33783. subdivisions?: {
  33784. w: number;
  33785. h: number;
  33786. };
  33787. precision?: {
  33788. w: number;
  33789. h: number;
  33790. };
  33791. }): VertexData;
  33792. /**
  33793. * Creates the VertexData of the Ground designed from a heightmap
  33794. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  33795. * * width the width (x direction) of the ground
  33796. * * height the height (z direction) of the ground
  33797. * * subdivisions the number of subdivisions per side
  33798. * * minHeight the minimum altitude on the ground, optional, default 0
  33799. * * maxHeight the maximum altitude on the ground, optional default 1
  33800. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  33801. * * buffer the array holding the image color data
  33802. * * bufferWidth the width of image
  33803. * * bufferHeight the height of image
  33804. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  33805. * @returns the VertexData of the Ground designed from a heightmap
  33806. */
  33807. static CreateGroundFromHeightMap(options: {
  33808. width: number;
  33809. height: number;
  33810. subdivisions: number;
  33811. minHeight: number;
  33812. maxHeight: number;
  33813. colorFilter: Color3;
  33814. buffer: Uint8Array;
  33815. bufferWidth: number;
  33816. bufferHeight: number;
  33817. alphaFilter: number;
  33818. }): VertexData;
  33819. /**
  33820. * Creates the VertexData for a Plane
  33821. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  33822. * * size sets the width and height of the plane to the value of size, optional default 1
  33823. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  33824. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  33825. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33826. * * 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)
  33827. * * 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)
  33828. * @returns the VertexData of the box
  33829. */
  33830. static CreatePlane(options: {
  33831. size?: number;
  33832. width?: number;
  33833. height?: number;
  33834. sideOrientation?: number;
  33835. frontUVs?: Vector4;
  33836. backUVs?: Vector4;
  33837. }): VertexData;
  33838. /**
  33839. * Creates the VertexData of the Disc or regular Polygon
  33840. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  33841. * * radius the radius of the disc, optional default 0.5
  33842. * * tessellation the number of polygon sides, optional, default 64
  33843. * * 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
  33844. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33845. * * 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)
  33846. * * 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)
  33847. * @returns the VertexData of the box
  33848. */
  33849. static CreateDisc(options: {
  33850. radius?: number;
  33851. tessellation?: number;
  33852. arc?: number;
  33853. sideOrientation?: number;
  33854. frontUVs?: Vector4;
  33855. backUVs?: Vector4;
  33856. }): VertexData;
  33857. /**
  33858. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  33859. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  33860. * @param polygon a mesh built from polygonTriangulation.build()
  33861. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33862. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33863. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33864. * @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)
  33865. * @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)
  33866. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  33867. * @returns the VertexData of the Polygon
  33868. */
  33869. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  33870. /**
  33871. * Creates the VertexData of the IcoSphere
  33872. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  33873. * * radius the radius of the IcoSphere, optional default 1
  33874. * * radiusX allows stretching in the x direction, optional, default radius
  33875. * * radiusY allows stretching in the y direction, optional, default radius
  33876. * * radiusZ allows stretching in the z direction, optional, default radius
  33877. * * flat when true creates a flat shaded mesh, optional, default true
  33878. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  33879. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33880. * * 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)
  33881. * * 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)
  33882. * @returns the VertexData of the IcoSphere
  33883. */
  33884. static CreateIcoSphere(options: {
  33885. radius?: number;
  33886. radiusX?: number;
  33887. radiusY?: number;
  33888. radiusZ?: number;
  33889. flat?: boolean;
  33890. subdivisions?: number;
  33891. sideOrientation?: number;
  33892. frontUVs?: Vector4;
  33893. backUVs?: Vector4;
  33894. }): VertexData;
  33895. /**
  33896. * Creates the VertexData for a Polyhedron
  33897. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  33898. * * type provided types are:
  33899. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  33900. * * 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)
  33901. * * size the size of the IcoSphere, optional default 1
  33902. * * sizeX allows stretching in the x direction, optional, default size
  33903. * * sizeY allows stretching in the y direction, optional, default size
  33904. * * sizeZ allows stretching in the z direction, optional, default size
  33905. * * 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
  33906. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33907. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33908. * * flat when true creates a flat shaded mesh, optional, default true
  33909. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  33910. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33911. * * 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)
  33912. * * 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)
  33913. * @returns the VertexData of the Polyhedron
  33914. */
  33915. static CreatePolyhedron(options: {
  33916. type?: number;
  33917. size?: number;
  33918. sizeX?: number;
  33919. sizeY?: number;
  33920. sizeZ?: number;
  33921. custom?: any;
  33922. faceUV?: Vector4[];
  33923. faceColors?: Color4[];
  33924. flat?: boolean;
  33925. sideOrientation?: number;
  33926. frontUVs?: Vector4;
  33927. backUVs?: Vector4;
  33928. }): VertexData;
  33929. /**
  33930. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  33931. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  33932. * @returns the VertexData of the Capsule
  33933. */
  33934. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  33935. /**
  33936. * Creates the VertexData for a TorusKnot
  33937. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  33938. * * radius the radius of the torus knot, optional, default 2
  33939. * * tube the thickness of the tube, optional, default 0.5
  33940. * * radialSegments the number of sides on each tube segments, optional, default 32
  33941. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  33942. * * p the number of windings around the z axis, optional, default 2
  33943. * * q the number of windings around the x axis, optional, default 3
  33944. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33945. * * 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)
  33946. * * 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)
  33947. * @returns the VertexData of the Torus Knot
  33948. */
  33949. static CreateTorusKnot(options: {
  33950. radius?: number;
  33951. tube?: number;
  33952. radialSegments?: number;
  33953. tubularSegments?: number;
  33954. p?: number;
  33955. q?: number;
  33956. sideOrientation?: number;
  33957. frontUVs?: Vector4;
  33958. backUVs?: Vector4;
  33959. }): VertexData;
  33960. /**
  33961. * Compute normals for given positions and indices
  33962. * @param positions an array of vertex positions, [...., x, y, z, ......]
  33963. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  33964. * @param normals an array of vertex normals, [...., x, y, z, ......]
  33965. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  33966. * * facetNormals : optional array of facet normals (vector3)
  33967. * * facetPositions : optional array of facet positions (vector3)
  33968. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  33969. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  33970. * * bInfo : optional bounding info, required for facetPartitioning computation
  33971. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  33972. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  33973. * * useRightHandedSystem: optional boolean to for right handed system computation
  33974. * * depthSort : optional boolean to enable the facet depth sort computation
  33975. * * distanceTo : optional Vector3 to compute the facet depth from this location
  33976. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  33977. */
  33978. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  33979. facetNormals?: any;
  33980. facetPositions?: any;
  33981. facetPartitioning?: any;
  33982. ratio?: number;
  33983. bInfo?: any;
  33984. bbSize?: Vector3;
  33985. subDiv?: any;
  33986. useRightHandedSystem?: boolean;
  33987. depthSort?: boolean;
  33988. distanceTo?: Vector3;
  33989. depthSortedFacets?: any;
  33990. }): void;
  33991. /** @hidden */
  33992. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  33993. /**
  33994. * Applies VertexData created from the imported parameters to the geometry
  33995. * @param parsedVertexData the parsed data from an imported file
  33996. * @param geometry the geometry to apply the VertexData to
  33997. */
  33998. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  33999. }
  34000. }
  34001. declare module BABYLON {
  34002. /**
  34003. * Class containing static functions to help procedurally build meshes
  34004. */
  34005. export class DiscBuilder {
  34006. /**
  34007. * Creates a plane polygonal mesh. By default, this is a disc
  34008. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34009. * * 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
  34010. * * 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
  34011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34012. * * 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
  34013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34014. * @param name defines the name of the mesh
  34015. * @param options defines the options used to create the mesh
  34016. * @param scene defines the hosting scene
  34017. * @returns the plane polygonal mesh
  34018. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34019. */
  34020. static CreateDisc(name: string, options: {
  34021. radius?: number;
  34022. tessellation?: number;
  34023. arc?: number;
  34024. updatable?: boolean;
  34025. sideOrientation?: number;
  34026. frontUVs?: Vector4;
  34027. backUVs?: Vector4;
  34028. }, scene?: Nullable<Scene>): Mesh;
  34029. }
  34030. }
  34031. declare module BABYLON {
  34032. /**
  34033. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34034. *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.
  34035. * The SPS is also a particle system. It provides some methods to manage the particles.
  34036. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34037. *
  34038. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34039. */
  34040. export class SolidParticleSystem implements IDisposable {
  34041. /**
  34042. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34043. * Example : var p = SPS.particles[i];
  34044. */
  34045. particles: SolidParticle[];
  34046. /**
  34047. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34048. */
  34049. nbParticles: number;
  34050. /**
  34051. * If the particles must ever face the camera (default false). Useful for planar particles.
  34052. */
  34053. billboard: boolean;
  34054. /**
  34055. * Recompute normals when adding a shape
  34056. */
  34057. recomputeNormals: boolean;
  34058. /**
  34059. * This a counter ofr your own usage. It's not set by any SPS functions.
  34060. */
  34061. counter: number;
  34062. /**
  34063. * The SPS name. This name is also given to the underlying mesh.
  34064. */
  34065. name: string;
  34066. /**
  34067. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34068. */
  34069. mesh: Mesh;
  34070. /**
  34071. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34072. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34073. */
  34074. vars: any;
  34075. /**
  34076. * This array is populated when the SPS is set as 'pickable'.
  34077. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34078. * Each element of this array is an object `{idx: int, faceId: int}`.
  34079. * `idx` is the picked particle index in the `SPS.particles` array
  34080. * `faceId` is the picked face index counted within this particle.
  34081. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34082. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34083. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34084. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34085. */
  34086. pickedParticles: {
  34087. idx: number;
  34088. faceId: number;
  34089. }[];
  34090. /**
  34091. * This array is populated when the SPS is set as 'pickable'
  34092. * Each key of this array is a submesh index.
  34093. * Each element of this array is a second array defined like this :
  34094. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34095. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34096. * `idx` is the picked particle index in the `SPS.particles` array
  34097. * `faceId` is the picked face index counted within this particle.
  34098. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34099. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34100. */
  34101. pickedBySubMesh: {
  34102. idx: number;
  34103. faceId: number;
  34104. }[][];
  34105. /**
  34106. * This array is populated when `enableDepthSort` is set to true.
  34107. * Each element of this array is an instance of the class DepthSortedParticle.
  34108. */
  34109. depthSortedParticles: DepthSortedParticle[];
  34110. /**
  34111. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34112. * @hidden
  34113. */
  34114. _bSphereOnly: boolean;
  34115. /**
  34116. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34117. * @hidden
  34118. */
  34119. _bSphereRadiusFactor: number;
  34120. private _scene;
  34121. private _positions;
  34122. private _indices;
  34123. private _normals;
  34124. private _colors;
  34125. private _uvs;
  34126. private _indices32;
  34127. private _positions32;
  34128. private _normals32;
  34129. private _fixedNormal32;
  34130. private _colors32;
  34131. private _uvs32;
  34132. private _index;
  34133. private _updatable;
  34134. private _pickable;
  34135. private _isVisibilityBoxLocked;
  34136. private _alwaysVisible;
  34137. private _depthSort;
  34138. private _expandable;
  34139. private _shapeCounter;
  34140. private _copy;
  34141. private _color;
  34142. private _computeParticleColor;
  34143. private _computeParticleTexture;
  34144. private _computeParticleRotation;
  34145. private _computeParticleVertex;
  34146. private _computeBoundingBox;
  34147. private _depthSortParticles;
  34148. private _camera;
  34149. private _mustUnrotateFixedNormals;
  34150. private _particlesIntersect;
  34151. private _needs32Bits;
  34152. private _isNotBuilt;
  34153. private _lastParticleId;
  34154. private _idxOfId;
  34155. private _multimaterialEnabled;
  34156. private _useModelMaterial;
  34157. private _indicesByMaterial;
  34158. private _materialIndexes;
  34159. private _depthSortFunction;
  34160. private _materialSortFunction;
  34161. private _materials;
  34162. private _multimaterial;
  34163. private _materialIndexesById;
  34164. private _defaultMaterial;
  34165. private _autoUpdateSubMeshes;
  34166. private _tmpVertex;
  34167. /**
  34168. * Creates a SPS (Solid Particle System) object.
  34169. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34170. * @param scene (Scene) is the scene in which the SPS is added.
  34171. * @param options defines the options of the sps e.g.
  34172. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34173. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34174. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34175. * * 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.
  34176. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34177. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34178. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34179. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34180. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34181. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34182. */
  34183. constructor(name: string, scene: Scene, options?: {
  34184. updatable?: boolean;
  34185. isPickable?: boolean;
  34186. enableDepthSort?: boolean;
  34187. particleIntersection?: boolean;
  34188. boundingSphereOnly?: boolean;
  34189. bSphereRadiusFactor?: number;
  34190. expandable?: boolean;
  34191. useModelMaterial?: boolean;
  34192. enableMultiMaterial?: boolean;
  34193. });
  34194. /**
  34195. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34196. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34197. * @returns the created mesh
  34198. */
  34199. buildMesh(): Mesh;
  34200. /**
  34201. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34202. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34203. * Thus the particles generated from `digest()` have their property `position` set yet.
  34204. * @param mesh ( Mesh ) is the mesh to be digested
  34205. * @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
  34206. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34207. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34208. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34209. * @returns the current SPS
  34210. */
  34211. digest(mesh: Mesh, options?: {
  34212. facetNb?: number;
  34213. number?: number;
  34214. delta?: number;
  34215. storage?: [];
  34216. }): SolidParticleSystem;
  34217. /**
  34218. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34219. * @hidden
  34220. */
  34221. private _unrotateFixedNormals;
  34222. /**
  34223. * Resets the temporary working copy particle
  34224. * @hidden
  34225. */
  34226. private _resetCopy;
  34227. /**
  34228. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34229. * @param p the current index in the positions array to be updated
  34230. * @param ind the current index in the indices array
  34231. * @param shape a Vector3 array, the shape geometry
  34232. * @param positions the positions array to be updated
  34233. * @param meshInd the shape indices array
  34234. * @param indices the indices array to be updated
  34235. * @param meshUV the shape uv array
  34236. * @param uvs the uv array to be updated
  34237. * @param meshCol the shape color array
  34238. * @param colors the color array to be updated
  34239. * @param meshNor the shape normals array
  34240. * @param normals the normals array to be updated
  34241. * @param idx the particle index
  34242. * @param idxInShape the particle index in its shape
  34243. * @param options the addShape() method passed options
  34244. * @model the particle model
  34245. * @hidden
  34246. */
  34247. private _meshBuilder;
  34248. /**
  34249. * Returns a shape Vector3 array from positions float array
  34250. * @param positions float array
  34251. * @returns a vector3 array
  34252. * @hidden
  34253. */
  34254. private _posToShape;
  34255. /**
  34256. * Returns a shapeUV array from a float uvs (array deep copy)
  34257. * @param uvs as a float array
  34258. * @returns a shapeUV array
  34259. * @hidden
  34260. */
  34261. private _uvsToShapeUV;
  34262. /**
  34263. * Adds a new particle object in the particles array
  34264. * @param idx particle index in particles array
  34265. * @param id particle id
  34266. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34267. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34268. * @param model particle ModelShape object
  34269. * @param shapeId model shape identifier
  34270. * @param idxInShape index of the particle in the current model
  34271. * @param bInfo model bounding info object
  34272. * @param storage target storage array, if any
  34273. * @hidden
  34274. */
  34275. private _addParticle;
  34276. /**
  34277. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34278. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34279. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34280. * @param nb (positive integer) the number of particles to be created from this model
  34281. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34282. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34283. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34284. * @returns the number of shapes in the system
  34285. */
  34286. addShape(mesh: Mesh, nb: number, options?: {
  34287. positionFunction?: any;
  34288. vertexFunction?: any;
  34289. storage?: [];
  34290. }): number;
  34291. /**
  34292. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34293. * @hidden
  34294. */
  34295. private _rebuildParticle;
  34296. /**
  34297. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34298. * @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.
  34299. * @returns the SPS.
  34300. */
  34301. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34302. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34303. * Returns an array with the removed particles.
  34304. * 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.
  34305. * The SPS can't be empty so at least one particle needs to remain in place.
  34306. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34307. * @param start index of the first particle to remove
  34308. * @param end index of the last particle to remove (included)
  34309. * @returns an array populated with the removed particles
  34310. */
  34311. removeParticles(start: number, end: number): SolidParticle[];
  34312. /**
  34313. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34314. * @param solidParticleArray an array populated with Solid Particles objects
  34315. * @returns the SPS
  34316. */
  34317. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34318. /**
  34319. * Creates a new particle and modifies the SPS mesh geometry :
  34320. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34321. * - calls _addParticle() to populate the particle array
  34322. * factorized code from addShape() and insertParticlesFromArray()
  34323. * @param idx particle index in the particles array
  34324. * @param i particle index in its shape
  34325. * @param modelShape particle ModelShape object
  34326. * @param shape shape vertex array
  34327. * @param meshInd shape indices array
  34328. * @param meshUV shape uv array
  34329. * @param meshCol shape color array
  34330. * @param meshNor shape normals array
  34331. * @param bbInfo shape bounding info
  34332. * @param storage target particle storage
  34333. * @options addShape() passed options
  34334. * @hidden
  34335. */
  34336. private _insertNewParticle;
  34337. /**
  34338. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34339. * This method calls `updateParticle()` for each particle of the SPS.
  34340. * For an animated SPS, it is usually called within the render loop.
  34341. * 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.
  34342. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34343. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34344. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34345. * @returns the SPS.
  34346. */
  34347. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34348. /**
  34349. * Disposes the SPS.
  34350. */
  34351. dispose(): void;
  34352. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34353. * idx is the particle index in the SPS
  34354. * faceId is the picked face index counted within this particle.
  34355. * Returns null if the pickInfo can't identify a picked particle.
  34356. * @param pickingInfo (PickingInfo object)
  34357. * @returns {idx: number, faceId: number} or null
  34358. */
  34359. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34360. idx: number;
  34361. faceId: number;
  34362. }>;
  34363. /**
  34364. * Returns a SolidParticle object from its identifier : particle.id
  34365. * @param id (integer) the particle Id
  34366. * @returns the searched particle or null if not found in the SPS.
  34367. */
  34368. getParticleById(id: number): Nullable<SolidParticle>;
  34369. /**
  34370. * Returns a new array populated with the particles having the passed shapeId.
  34371. * @param shapeId (integer) the shape identifier
  34372. * @returns a new solid particle array
  34373. */
  34374. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34375. /**
  34376. * Populates the passed array "ref" with the particles having the passed shapeId.
  34377. * @param shapeId the shape identifier
  34378. * @returns the SPS
  34379. * @param ref
  34380. */
  34381. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34382. /**
  34383. * Computes the required SubMeshes according the materials assigned to the particles.
  34384. * @returns the solid particle system.
  34385. * Does nothing if called before the SPS mesh is built.
  34386. */
  34387. computeSubMeshes(): SolidParticleSystem;
  34388. /**
  34389. * Sorts the solid particles by material when MultiMaterial is enabled.
  34390. * Updates the indices32 array.
  34391. * Updates the indicesByMaterial array.
  34392. * Updates the mesh indices array.
  34393. * @returns the SPS
  34394. * @hidden
  34395. */
  34396. private _sortParticlesByMaterial;
  34397. /**
  34398. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34399. * @hidden
  34400. */
  34401. private _setMaterialIndexesById;
  34402. /**
  34403. * Returns an array with unique values of Materials from the passed array
  34404. * @param array the material array to be checked and filtered
  34405. * @hidden
  34406. */
  34407. private _filterUniqueMaterialId;
  34408. /**
  34409. * Sets a new Standard Material as _defaultMaterial if not already set.
  34410. * @hidden
  34411. */
  34412. private _setDefaultMaterial;
  34413. /**
  34414. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34415. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34416. * @returns the SPS.
  34417. */
  34418. refreshVisibleSize(): SolidParticleSystem;
  34419. /**
  34420. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34421. * @param size the size (float) of the visibility box
  34422. * note : this doesn't lock the SPS mesh bounding box.
  34423. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34424. */
  34425. setVisibilityBox(size: number): void;
  34426. /**
  34427. * Gets whether the SPS as always visible or not
  34428. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34429. */
  34430. get isAlwaysVisible(): boolean;
  34431. /**
  34432. * Sets the SPS as always visible or not
  34433. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34434. */
  34435. set isAlwaysVisible(val: boolean);
  34436. /**
  34437. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34438. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34439. */
  34440. set isVisibilityBoxLocked(val: boolean);
  34441. /**
  34442. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34443. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34444. */
  34445. get isVisibilityBoxLocked(): boolean;
  34446. /**
  34447. * Tells to `setParticles()` to compute the particle rotations or not.
  34448. * Default value : true. The SPS is faster when it's set to false.
  34449. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34450. */
  34451. set computeParticleRotation(val: boolean);
  34452. /**
  34453. * Tells to `setParticles()` to compute the particle colors or not.
  34454. * Default value : true. The SPS is faster when it's set to false.
  34455. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34456. */
  34457. set computeParticleColor(val: boolean);
  34458. set computeParticleTexture(val: boolean);
  34459. /**
  34460. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34461. * Default value : false. The SPS is faster when it's set to false.
  34462. * Note : the particle custom vertex positions aren't stored values.
  34463. */
  34464. set computeParticleVertex(val: boolean);
  34465. /**
  34466. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34467. */
  34468. set computeBoundingBox(val: boolean);
  34469. /**
  34470. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34471. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34472. * Default : `true`
  34473. */
  34474. set depthSortParticles(val: boolean);
  34475. /**
  34476. * Gets if `setParticles()` computes the particle rotations or not.
  34477. * Default value : true. The SPS is faster when it's set to false.
  34478. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34479. */
  34480. get computeParticleRotation(): boolean;
  34481. /**
  34482. * Gets if `setParticles()` computes the particle colors or not.
  34483. * Default value : true. The SPS is faster when it's set to false.
  34484. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34485. */
  34486. get computeParticleColor(): boolean;
  34487. /**
  34488. * Gets if `setParticles()` computes the particle textures or not.
  34489. * Default value : true. The SPS is faster when it's set to false.
  34490. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34491. */
  34492. get computeParticleTexture(): boolean;
  34493. /**
  34494. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34495. * Default value : false. The SPS is faster when it's set to false.
  34496. * Note : the particle custom vertex positions aren't stored values.
  34497. */
  34498. get computeParticleVertex(): boolean;
  34499. /**
  34500. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34501. */
  34502. get computeBoundingBox(): boolean;
  34503. /**
  34504. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34505. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34506. * Default : `true`
  34507. */
  34508. get depthSortParticles(): boolean;
  34509. /**
  34510. * Gets if the SPS is created as expandable at construction time.
  34511. * Default : `false`
  34512. */
  34513. get expandable(): boolean;
  34514. /**
  34515. * Gets if the SPS supports the Multi Materials
  34516. */
  34517. get multimaterialEnabled(): boolean;
  34518. /**
  34519. * Gets if the SPS uses the model materials for its own multimaterial.
  34520. */
  34521. get useModelMaterial(): boolean;
  34522. /**
  34523. * The SPS used material array.
  34524. */
  34525. get materials(): Material[];
  34526. /**
  34527. * Sets the SPS MultiMaterial from the passed materials.
  34528. * Note : the passed array is internally copied and not used then by reference.
  34529. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34530. */
  34531. setMultiMaterial(materials: Material[]): void;
  34532. /**
  34533. * The SPS computed multimaterial object
  34534. */
  34535. get multimaterial(): MultiMaterial;
  34536. set multimaterial(mm: MultiMaterial);
  34537. /**
  34538. * If the subMeshes must be updated on the next call to setParticles()
  34539. */
  34540. get autoUpdateSubMeshes(): boolean;
  34541. set autoUpdateSubMeshes(val: boolean);
  34542. /**
  34543. * This function does nothing. It may be overwritten to set all the particle first values.
  34544. * The SPS doesn't call this function, you may have to call it by your own.
  34545. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34546. */
  34547. initParticles(): void;
  34548. /**
  34549. * This function does nothing. It may be overwritten to recycle a particle.
  34550. * The SPS doesn't call this function, you may have to call it by your own.
  34551. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34552. * @param particle The particle to recycle
  34553. * @returns the recycled particle
  34554. */
  34555. recycleParticle(particle: SolidParticle): SolidParticle;
  34556. /**
  34557. * Updates a particle : this function should be overwritten by the user.
  34558. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34559. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34560. * @example : just set a particle position or velocity and recycle conditions
  34561. * @param particle The particle to update
  34562. * @returns the updated particle
  34563. */
  34564. updateParticle(particle: SolidParticle): SolidParticle;
  34565. /**
  34566. * Updates a vertex of a particle : it can be overwritten by the user.
  34567. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34568. * @param particle the current particle
  34569. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34570. * @param pt the index of the current vertex in the particle shape
  34571. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34572. * @example : just set a vertex particle position or color
  34573. * @returns the sps
  34574. */
  34575. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34576. /**
  34577. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34578. * This does nothing and may be overwritten by the user.
  34579. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34580. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34581. * @param update the boolean update value actually passed to setParticles()
  34582. */
  34583. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34584. /**
  34585. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34586. * This will be passed three parameters.
  34587. * This does nothing and may be overwritten by the user.
  34588. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34589. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34590. * @param update the boolean update value actually passed to setParticles()
  34591. */
  34592. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34593. }
  34594. }
  34595. declare module BABYLON {
  34596. /**
  34597. * Represents one particle of a solid particle system.
  34598. */
  34599. export class SolidParticle {
  34600. /**
  34601. * particle global index
  34602. */
  34603. idx: number;
  34604. /**
  34605. * particle identifier
  34606. */
  34607. id: number;
  34608. /**
  34609. * The color of the particle
  34610. */
  34611. color: Nullable<Color4>;
  34612. /**
  34613. * The world space position of the particle.
  34614. */
  34615. position: Vector3;
  34616. /**
  34617. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34618. */
  34619. rotation: Vector3;
  34620. /**
  34621. * The world space rotation quaternion of the particle.
  34622. */
  34623. rotationQuaternion: Nullable<Quaternion>;
  34624. /**
  34625. * The scaling of the particle.
  34626. */
  34627. scaling: Vector3;
  34628. /**
  34629. * The uvs of the particle.
  34630. */
  34631. uvs: Vector4;
  34632. /**
  34633. * The current speed of the particle.
  34634. */
  34635. velocity: Vector3;
  34636. /**
  34637. * The pivot point in the particle local space.
  34638. */
  34639. pivot: Vector3;
  34640. /**
  34641. * Must the particle be translated from its pivot point in its local space ?
  34642. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34643. * Default : false
  34644. */
  34645. translateFromPivot: boolean;
  34646. /**
  34647. * Is the particle active or not ?
  34648. */
  34649. alive: boolean;
  34650. /**
  34651. * Is the particle visible or not ?
  34652. */
  34653. isVisible: boolean;
  34654. /**
  34655. * Index of this particle in the global "positions" array (Internal use)
  34656. * @hidden
  34657. */
  34658. _pos: number;
  34659. /**
  34660. * @hidden Index of this particle in the global "indices" array (Internal use)
  34661. */
  34662. _ind: number;
  34663. /**
  34664. * @hidden ModelShape of this particle (Internal use)
  34665. */
  34666. _model: ModelShape;
  34667. /**
  34668. * ModelShape id of this particle
  34669. */
  34670. shapeId: number;
  34671. /**
  34672. * Index of the particle in its shape id
  34673. */
  34674. idxInShape: number;
  34675. /**
  34676. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34677. */
  34678. _modelBoundingInfo: BoundingInfo;
  34679. /**
  34680. * @hidden Particle BoundingInfo object (Internal use)
  34681. */
  34682. _boundingInfo: BoundingInfo;
  34683. /**
  34684. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34685. */
  34686. _sps: SolidParticleSystem;
  34687. /**
  34688. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34689. */
  34690. _stillInvisible: boolean;
  34691. /**
  34692. * @hidden Last computed particle rotation matrix
  34693. */
  34694. _rotationMatrix: number[];
  34695. /**
  34696. * Parent particle Id, if any.
  34697. * Default null.
  34698. */
  34699. parentId: Nullable<number>;
  34700. /**
  34701. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34702. */
  34703. materialIndex: Nullable<number>;
  34704. /**
  34705. * Custom object or properties.
  34706. */
  34707. props: Nullable<any>;
  34708. /**
  34709. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34710. * The possible values are :
  34711. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34712. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34713. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34714. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34715. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34716. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34717. * */
  34718. cullingStrategy: number;
  34719. /**
  34720. * @hidden Internal global position in the SPS.
  34721. */
  34722. _globalPosition: Vector3;
  34723. /**
  34724. * Creates a Solid Particle object.
  34725. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34726. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34727. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34728. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34729. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34730. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34731. * @param shapeId (integer) is the model shape identifier in the SPS.
  34732. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34733. * @param sps defines the sps it is associated to
  34734. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34735. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34736. */
  34737. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34738. /**
  34739. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34740. * @param target the particle target
  34741. * @returns the current particle
  34742. */
  34743. copyToRef(target: SolidParticle): SolidParticle;
  34744. /**
  34745. * Legacy support, changed scale to scaling
  34746. */
  34747. get scale(): Vector3;
  34748. /**
  34749. * Legacy support, changed scale to scaling
  34750. */
  34751. set scale(scale: Vector3);
  34752. /**
  34753. * Legacy support, changed quaternion to rotationQuaternion
  34754. */
  34755. get quaternion(): Nullable<Quaternion>;
  34756. /**
  34757. * Legacy support, changed quaternion to rotationQuaternion
  34758. */
  34759. set quaternion(q: Nullable<Quaternion>);
  34760. /**
  34761. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34762. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34763. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34764. * @returns true if it intersects
  34765. */
  34766. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34767. /**
  34768. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34769. * A particle is in the frustum if its bounding box intersects the frustum
  34770. * @param frustumPlanes defines the frustum to test
  34771. * @returns true if the particle is in the frustum planes
  34772. */
  34773. isInFrustum(frustumPlanes: Plane[]): boolean;
  34774. /**
  34775. * get the rotation matrix of the particle
  34776. * @hidden
  34777. */
  34778. getRotationMatrix(m: Matrix): void;
  34779. }
  34780. /**
  34781. * Represents the shape of the model used by one particle of a solid particle system.
  34782. * SPS internal tool, don't use it manually.
  34783. */
  34784. export class ModelShape {
  34785. /**
  34786. * The shape id
  34787. * @hidden
  34788. */
  34789. shapeID: number;
  34790. /**
  34791. * flat array of model positions (internal use)
  34792. * @hidden
  34793. */
  34794. _shape: Vector3[];
  34795. /**
  34796. * flat array of model UVs (internal use)
  34797. * @hidden
  34798. */
  34799. _shapeUV: number[];
  34800. /**
  34801. * color array of the model
  34802. * @hidden
  34803. */
  34804. _shapeColors: number[];
  34805. /**
  34806. * indices array of the model
  34807. * @hidden
  34808. */
  34809. _indices: number[];
  34810. /**
  34811. * normals array of the model
  34812. * @hidden
  34813. */
  34814. _normals: number[];
  34815. /**
  34816. * length of the shape in the model indices array (internal use)
  34817. * @hidden
  34818. */
  34819. _indicesLength: number;
  34820. /**
  34821. * Custom position function (internal use)
  34822. * @hidden
  34823. */
  34824. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34825. /**
  34826. * Custom vertex function (internal use)
  34827. * @hidden
  34828. */
  34829. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  34830. /**
  34831. * Model material (internal use)
  34832. * @hidden
  34833. */
  34834. _material: Nullable<Material>;
  34835. /**
  34836. * 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.
  34837. * SPS internal tool, don't use it manually.
  34838. * @hidden
  34839. */
  34840. 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>);
  34841. }
  34842. /**
  34843. * Represents a Depth Sorted Particle in the solid particle system.
  34844. * @hidden
  34845. */
  34846. export class DepthSortedParticle {
  34847. /**
  34848. * Particle index
  34849. */
  34850. idx: number;
  34851. /**
  34852. * Index of the particle in the "indices" array
  34853. */
  34854. ind: number;
  34855. /**
  34856. * Length of the particle shape in the "indices" array
  34857. */
  34858. indicesLength: number;
  34859. /**
  34860. * Squared distance from the particle to the camera
  34861. */
  34862. sqDistance: number;
  34863. /**
  34864. * Material index when used with MultiMaterials
  34865. */
  34866. materialIndex: number;
  34867. /**
  34868. * Creates a new sorted particle
  34869. * @param materialIndex
  34870. */
  34871. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  34872. }
  34873. /**
  34874. * Represents a solid particle vertex
  34875. */
  34876. export class SolidParticleVertex {
  34877. /**
  34878. * Vertex position
  34879. */
  34880. position: Vector3;
  34881. /**
  34882. * Vertex color
  34883. */
  34884. color: Color4;
  34885. /**
  34886. * Vertex UV
  34887. */
  34888. uv: Vector2;
  34889. /**
  34890. * Creates a new solid particle vertex
  34891. */
  34892. constructor();
  34893. /** Vertex x coordinate */
  34894. get x(): number;
  34895. set x(val: number);
  34896. /** Vertex y coordinate */
  34897. get y(): number;
  34898. set y(val: number);
  34899. /** Vertex z coordinate */
  34900. get z(): number;
  34901. set z(val: number);
  34902. }
  34903. }
  34904. declare module BABYLON {
  34905. /**
  34906. * @hidden
  34907. */
  34908. export class _MeshCollisionData {
  34909. _checkCollisions: boolean;
  34910. _collisionMask: number;
  34911. _collisionGroup: number;
  34912. _surroundingMeshes: Nullable<AbstractMesh[]>;
  34913. _collider: Nullable<Collider>;
  34914. _oldPositionForCollisions: Vector3;
  34915. _diffPositionForCollisions: Vector3;
  34916. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  34917. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  34918. _collisionResponse: boolean;
  34919. }
  34920. }
  34921. declare module BABYLON {
  34922. /** @hidden */
  34923. class _FacetDataStorage {
  34924. facetPositions: Vector3[];
  34925. facetNormals: Vector3[];
  34926. facetPartitioning: number[][];
  34927. facetNb: number;
  34928. partitioningSubdivisions: number;
  34929. partitioningBBoxRatio: number;
  34930. facetDataEnabled: boolean;
  34931. facetParameters: any;
  34932. bbSize: Vector3;
  34933. subDiv: {
  34934. max: number;
  34935. X: number;
  34936. Y: number;
  34937. Z: number;
  34938. };
  34939. facetDepthSort: boolean;
  34940. facetDepthSortEnabled: boolean;
  34941. depthSortedIndices: IndicesArray;
  34942. depthSortedFacets: {
  34943. ind: number;
  34944. sqDistance: number;
  34945. }[];
  34946. facetDepthSortFunction: (f1: {
  34947. ind: number;
  34948. sqDistance: number;
  34949. }, f2: {
  34950. ind: number;
  34951. sqDistance: number;
  34952. }) => number;
  34953. facetDepthSortFrom: Vector3;
  34954. facetDepthSortOrigin: Vector3;
  34955. invertedMatrix: Matrix;
  34956. }
  34957. /**
  34958. * @hidden
  34959. **/
  34960. class _InternalAbstractMeshDataInfo {
  34961. _hasVertexAlpha: boolean;
  34962. _useVertexColors: boolean;
  34963. _numBoneInfluencers: number;
  34964. _applyFog: boolean;
  34965. _receiveShadows: boolean;
  34966. _facetData: _FacetDataStorage;
  34967. _visibility: number;
  34968. _skeleton: Nullable<Skeleton>;
  34969. _layerMask: number;
  34970. _computeBonesUsingShaders: boolean;
  34971. _isActive: boolean;
  34972. _onlyForInstances: boolean;
  34973. _isActiveIntermediate: boolean;
  34974. _onlyForInstancesIntermediate: boolean;
  34975. _actAsRegularMesh: boolean;
  34976. _currentLOD: Nullable<AbstractMesh>;
  34977. }
  34978. /**
  34979. * Class used to store all common mesh properties
  34980. */
  34981. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  34982. /** No occlusion */
  34983. static OCCLUSION_TYPE_NONE: number;
  34984. /** Occlusion set to optimisitic */
  34985. static OCCLUSION_TYPE_OPTIMISTIC: number;
  34986. /** Occlusion set to strict */
  34987. static OCCLUSION_TYPE_STRICT: number;
  34988. /** Use an accurante occlusion algorithm */
  34989. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  34990. /** Use a conservative occlusion algorithm */
  34991. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  34992. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  34993. * Test order :
  34994. * Is the bounding sphere outside the frustum ?
  34995. * If not, are the bounding box vertices outside the frustum ?
  34996. * It not, then the cullable object is in the frustum.
  34997. */
  34998. static readonly CULLINGSTRATEGY_STANDARD: number;
  34999. /** Culling strategy : Bounding Sphere Only.
  35000. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35001. * It's also less accurate than the standard because some not visible objects can still be selected.
  35002. * Test : is the bounding sphere outside the frustum ?
  35003. * If not, then the cullable object is in the frustum.
  35004. */
  35005. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35006. /** Culling strategy : Optimistic Inclusion.
  35007. * This in an inclusion test first, then the standard exclusion test.
  35008. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35009. * 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.
  35010. * Anyway, it's as accurate as the standard strategy.
  35011. * Test :
  35012. * Is the cullable object bounding sphere center in the frustum ?
  35013. * If not, apply the default culling strategy.
  35014. */
  35015. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35016. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35017. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35018. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35019. * 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.
  35020. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35021. * Test :
  35022. * Is the cullable object bounding sphere center in the frustum ?
  35023. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35024. */
  35025. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35026. /**
  35027. * No billboard
  35028. */
  35029. static get BILLBOARDMODE_NONE(): number;
  35030. /** Billboard on X axis */
  35031. static get BILLBOARDMODE_X(): number;
  35032. /** Billboard on Y axis */
  35033. static get BILLBOARDMODE_Y(): number;
  35034. /** Billboard on Z axis */
  35035. static get BILLBOARDMODE_Z(): number;
  35036. /** Billboard on all axes */
  35037. static get BILLBOARDMODE_ALL(): number;
  35038. /** Billboard on using position instead of orientation */
  35039. static get BILLBOARDMODE_USE_POSITION(): number;
  35040. /** @hidden */
  35041. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35042. /**
  35043. * The culling strategy to use to check whether the mesh must be rendered or not.
  35044. * This value can be changed at any time and will be used on the next render mesh selection.
  35045. * The possible values are :
  35046. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35047. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35048. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35049. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35050. * Please read each static variable documentation to get details about the culling process.
  35051. * */
  35052. cullingStrategy: number;
  35053. /**
  35054. * Gets the number of facets in the mesh
  35055. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35056. */
  35057. get facetNb(): number;
  35058. /**
  35059. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35060. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35061. */
  35062. get partitioningSubdivisions(): number;
  35063. set partitioningSubdivisions(nb: number);
  35064. /**
  35065. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35066. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35067. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35068. */
  35069. get partitioningBBoxRatio(): number;
  35070. set partitioningBBoxRatio(ratio: number);
  35071. /**
  35072. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35073. * Works only for updatable meshes.
  35074. * Doesn't work with multi-materials
  35075. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35076. */
  35077. get mustDepthSortFacets(): boolean;
  35078. set mustDepthSortFacets(sort: boolean);
  35079. /**
  35080. * The location (Vector3) where the facet depth sort must be computed from.
  35081. * By default, the active camera position.
  35082. * Used only when facet depth sort is enabled
  35083. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35084. */
  35085. get facetDepthSortFrom(): Vector3;
  35086. set facetDepthSortFrom(location: Vector3);
  35087. /**
  35088. * gets a boolean indicating if facetData is enabled
  35089. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35090. */
  35091. get isFacetDataEnabled(): boolean;
  35092. /** @hidden */
  35093. _updateNonUniformScalingState(value: boolean): boolean;
  35094. /**
  35095. * An event triggered when this mesh collides with another one
  35096. */
  35097. onCollideObservable: Observable<AbstractMesh>;
  35098. /** Set a function to call when this mesh collides with another one */
  35099. set onCollide(callback: () => void);
  35100. /**
  35101. * An event triggered when the collision's position changes
  35102. */
  35103. onCollisionPositionChangeObservable: Observable<Vector3>;
  35104. /** Set a function to call when the collision's position changes */
  35105. set onCollisionPositionChange(callback: () => void);
  35106. /**
  35107. * An event triggered when material is changed
  35108. */
  35109. onMaterialChangedObservable: Observable<AbstractMesh>;
  35110. /**
  35111. * Gets or sets the orientation for POV movement & rotation
  35112. */
  35113. definedFacingForward: boolean;
  35114. /** @hidden */
  35115. _occlusionQuery: Nullable<WebGLQuery>;
  35116. /** @hidden */
  35117. _renderingGroup: Nullable<RenderingGroup>;
  35118. /**
  35119. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35120. */
  35121. get visibility(): number;
  35122. /**
  35123. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35124. */
  35125. set visibility(value: number);
  35126. /** Gets or sets the alpha index used to sort transparent meshes
  35127. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35128. */
  35129. alphaIndex: number;
  35130. /**
  35131. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35132. */
  35133. isVisible: boolean;
  35134. /**
  35135. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35136. */
  35137. isPickable: boolean;
  35138. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35139. showSubMeshesBoundingBox: boolean;
  35140. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35141. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35142. */
  35143. isBlocker: boolean;
  35144. /**
  35145. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35146. */
  35147. enablePointerMoveEvents: boolean;
  35148. private _renderingGroupId;
  35149. /**
  35150. * Specifies the rendering group id for this mesh (0 by default)
  35151. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35152. */
  35153. get renderingGroupId(): number;
  35154. set renderingGroupId(value: number);
  35155. private _material;
  35156. /** Gets or sets current material */
  35157. get material(): Nullable<Material>;
  35158. set material(value: Nullable<Material>);
  35159. /**
  35160. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35161. * @see https://doc.babylonjs.com/babylon101/shadows
  35162. */
  35163. get receiveShadows(): boolean;
  35164. set receiveShadows(value: boolean);
  35165. /** Defines color to use when rendering outline */
  35166. outlineColor: Color3;
  35167. /** Define width to use when rendering outline */
  35168. outlineWidth: number;
  35169. /** Defines color to use when rendering overlay */
  35170. overlayColor: Color3;
  35171. /** Defines alpha to use when rendering overlay */
  35172. overlayAlpha: number;
  35173. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35174. get hasVertexAlpha(): boolean;
  35175. set hasVertexAlpha(value: boolean);
  35176. /** 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) */
  35177. get useVertexColors(): boolean;
  35178. set useVertexColors(value: boolean);
  35179. /**
  35180. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35181. */
  35182. get computeBonesUsingShaders(): boolean;
  35183. set computeBonesUsingShaders(value: boolean);
  35184. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35185. get numBoneInfluencers(): number;
  35186. set numBoneInfluencers(value: number);
  35187. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35188. get applyFog(): boolean;
  35189. set applyFog(value: boolean);
  35190. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35191. useOctreeForRenderingSelection: boolean;
  35192. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35193. useOctreeForPicking: boolean;
  35194. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35195. useOctreeForCollisions: boolean;
  35196. /**
  35197. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35198. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35199. */
  35200. get layerMask(): number;
  35201. set layerMask(value: number);
  35202. /**
  35203. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35204. */
  35205. alwaysSelectAsActiveMesh: boolean;
  35206. /**
  35207. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35208. */
  35209. doNotSyncBoundingInfo: boolean;
  35210. /**
  35211. * Gets or sets the current action manager
  35212. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35213. */
  35214. actionManager: Nullable<AbstractActionManager>;
  35215. private _meshCollisionData;
  35216. /**
  35217. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35218. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35219. */
  35220. ellipsoid: Vector3;
  35221. /**
  35222. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35223. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35224. */
  35225. ellipsoidOffset: Vector3;
  35226. /**
  35227. * Gets or sets a collision mask used to mask collisions (default is -1).
  35228. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35229. */
  35230. get collisionMask(): number;
  35231. set collisionMask(mask: number);
  35232. /**
  35233. * Gets or sets a collision response flag (default is true).
  35234. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35235. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35236. * to respond to the collision.
  35237. */
  35238. get collisionResponse(): boolean;
  35239. set collisionResponse(response: boolean);
  35240. /**
  35241. * Gets or sets the current collision group mask (-1 by default).
  35242. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35243. */
  35244. get collisionGroup(): number;
  35245. set collisionGroup(mask: number);
  35246. /**
  35247. * Gets or sets current surrounding meshes (null by default).
  35248. *
  35249. * By default collision detection is tested against every mesh in the scene.
  35250. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35251. * meshes will be tested for the collision.
  35252. *
  35253. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35254. */
  35255. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35256. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35257. /**
  35258. * Defines edge width used when edgesRenderer is enabled
  35259. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35260. */
  35261. edgesWidth: number;
  35262. /**
  35263. * Defines edge color used when edgesRenderer is enabled
  35264. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35265. */
  35266. edgesColor: Color4;
  35267. /** @hidden */
  35268. _edgesRenderer: Nullable<IEdgesRenderer>;
  35269. /** @hidden */
  35270. _masterMesh: Nullable<AbstractMesh>;
  35271. /** @hidden */
  35272. _boundingInfo: Nullable<BoundingInfo>;
  35273. /** @hidden */
  35274. _renderId: number;
  35275. /**
  35276. * Gets or sets the list of subMeshes
  35277. * @see https://doc.babylonjs.com/how_to/multi_materials
  35278. */
  35279. subMeshes: SubMesh[];
  35280. /** @hidden */
  35281. _intersectionsInProgress: AbstractMesh[];
  35282. /** @hidden */
  35283. _unIndexed: boolean;
  35284. /** @hidden */
  35285. _lightSources: Light[];
  35286. /** Gets the list of lights affecting that mesh */
  35287. get lightSources(): Light[];
  35288. /** @hidden */
  35289. get _positions(): Nullable<Vector3[]>;
  35290. /** @hidden */
  35291. _waitingData: {
  35292. lods: Nullable<any>;
  35293. actions: Nullable<any>;
  35294. freezeWorldMatrix: Nullable<boolean>;
  35295. };
  35296. /** @hidden */
  35297. _bonesTransformMatrices: Nullable<Float32Array>;
  35298. /** @hidden */
  35299. _transformMatrixTexture: Nullable<RawTexture>;
  35300. /**
  35301. * Gets or sets a skeleton to apply skining transformations
  35302. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35303. */
  35304. set skeleton(value: Nullable<Skeleton>);
  35305. get skeleton(): Nullable<Skeleton>;
  35306. /**
  35307. * An event triggered when the mesh is rebuilt.
  35308. */
  35309. onRebuildObservable: Observable<AbstractMesh>;
  35310. /**
  35311. * Creates a new AbstractMesh
  35312. * @param name defines the name of the mesh
  35313. * @param scene defines the hosting scene
  35314. */
  35315. constructor(name: string, scene?: Nullable<Scene>);
  35316. /**
  35317. * Returns the string "AbstractMesh"
  35318. * @returns "AbstractMesh"
  35319. */
  35320. getClassName(): string;
  35321. /**
  35322. * Gets a string representation of the current mesh
  35323. * @param fullDetails defines a boolean indicating if full details must be included
  35324. * @returns a string representation of the current mesh
  35325. */
  35326. toString(fullDetails?: boolean): string;
  35327. /**
  35328. * @hidden
  35329. */
  35330. protected _getEffectiveParent(): Nullable<Node>;
  35331. /** @hidden */
  35332. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35333. /** @hidden */
  35334. _rebuild(): void;
  35335. /** @hidden */
  35336. _resyncLightSources(): void;
  35337. /** @hidden */
  35338. _resyncLightSource(light: Light): void;
  35339. /** @hidden */
  35340. _unBindEffect(): void;
  35341. /** @hidden */
  35342. _removeLightSource(light: Light, dispose: boolean): void;
  35343. private _markSubMeshesAsDirty;
  35344. /** @hidden */
  35345. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35346. /** @hidden */
  35347. _markSubMeshesAsAttributesDirty(): void;
  35348. /** @hidden */
  35349. _markSubMeshesAsMiscDirty(): void;
  35350. /**
  35351. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35352. */
  35353. get scaling(): Vector3;
  35354. set scaling(newScaling: Vector3);
  35355. /**
  35356. * Returns true if the mesh is blocked. Implemented by child classes
  35357. */
  35358. get isBlocked(): boolean;
  35359. /**
  35360. * Returns the mesh itself by default. Implemented by child classes
  35361. * @param camera defines the camera to use to pick the right LOD level
  35362. * @returns the currentAbstractMesh
  35363. */
  35364. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35365. /**
  35366. * Returns 0 by default. Implemented by child classes
  35367. * @returns an integer
  35368. */
  35369. getTotalVertices(): number;
  35370. /**
  35371. * Returns a positive integer : the total number of indices in this mesh geometry.
  35372. * @returns the numner of indices or zero if the mesh has no geometry.
  35373. */
  35374. getTotalIndices(): number;
  35375. /**
  35376. * Returns null by default. Implemented by child classes
  35377. * @returns null
  35378. */
  35379. getIndices(): Nullable<IndicesArray>;
  35380. /**
  35381. * Returns the array of the requested vertex data kind. Implemented by child classes
  35382. * @param kind defines the vertex data kind to use
  35383. * @returns null
  35384. */
  35385. getVerticesData(kind: string): Nullable<FloatArray>;
  35386. /**
  35387. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35388. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35389. * Note that a new underlying VertexBuffer object is created each call.
  35390. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35391. * @param kind defines vertex data kind:
  35392. * * VertexBuffer.PositionKind
  35393. * * VertexBuffer.UVKind
  35394. * * VertexBuffer.UV2Kind
  35395. * * VertexBuffer.UV3Kind
  35396. * * VertexBuffer.UV4Kind
  35397. * * VertexBuffer.UV5Kind
  35398. * * VertexBuffer.UV6Kind
  35399. * * VertexBuffer.ColorKind
  35400. * * VertexBuffer.MatricesIndicesKind
  35401. * * VertexBuffer.MatricesIndicesExtraKind
  35402. * * VertexBuffer.MatricesWeightsKind
  35403. * * VertexBuffer.MatricesWeightsExtraKind
  35404. * @param data defines the data source
  35405. * @param updatable defines if the data must be flagged as updatable (or static)
  35406. * @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
  35407. * @returns the current mesh
  35408. */
  35409. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35410. /**
  35411. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35412. * If the mesh has no geometry, it is simply returned as it is.
  35413. * @param kind defines vertex data kind:
  35414. * * VertexBuffer.PositionKind
  35415. * * VertexBuffer.UVKind
  35416. * * VertexBuffer.UV2Kind
  35417. * * VertexBuffer.UV3Kind
  35418. * * VertexBuffer.UV4Kind
  35419. * * VertexBuffer.UV5Kind
  35420. * * VertexBuffer.UV6Kind
  35421. * * VertexBuffer.ColorKind
  35422. * * VertexBuffer.MatricesIndicesKind
  35423. * * VertexBuffer.MatricesIndicesExtraKind
  35424. * * VertexBuffer.MatricesWeightsKind
  35425. * * VertexBuffer.MatricesWeightsExtraKind
  35426. * @param data defines the data source
  35427. * @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
  35428. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35429. * @returns the current mesh
  35430. */
  35431. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35432. /**
  35433. * Sets the mesh indices,
  35434. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35435. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35436. * @param totalVertices Defines the total number of vertices
  35437. * @returns the current mesh
  35438. */
  35439. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35440. /**
  35441. * Gets a boolean indicating if specific vertex data is present
  35442. * @param kind defines the vertex data kind to use
  35443. * @returns true is data kind is present
  35444. */
  35445. isVerticesDataPresent(kind: string): boolean;
  35446. /**
  35447. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35448. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35449. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35450. * @returns a BoundingInfo
  35451. */
  35452. getBoundingInfo(): BoundingInfo;
  35453. /**
  35454. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35455. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35456. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35457. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35458. * @returns the current mesh
  35459. */
  35460. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35461. /**
  35462. * Overwrite the current bounding info
  35463. * @param boundingInfo defines the new bounding info
  35464. * @returns the current mesh
  35465. */
  35466. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35467. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35468. get useBones(): boolean;
  35469. /** @hidden */
  35470. _preActivate(): void;
  35471. /** @hidden */
  35472. _preActivateForIntermediateRendering(renderId: number): void;
  35473. /** @hidden */
  35474. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35475. /** @hidden */
  35476. _postActivate(): void;
  35477. /** @hidden */
  35478. _freeze(): void;
  35479. /** @hidden */
  35480. _unFreeze(): void;
  35481. /**
  35482. * Gets the current world matrix
  35483. * @returns a Matrix
  35484. */
  35485. getWorldMatrix(): Matrix;
  35486. /** @hidden */
  35487. _getWorldMatrixDeterminant(): number;
  35488. /**
  35489. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35490. */
  35491. get isAnInstance(): boolean;
  35492. /**
  35493. * Gets a boolean indicating if this mesh has instances
  35494. */
  35495. get hasInstances(): boolean;
  35496. /**
  35497. * Gets a boolean indicating if this mesh has thin instances
  35498. */
  35499. get hasThinInstances(): boolean;
  35500. /**
  35501. * Perform relative position change from the point of view of behind the front of the mesh.
  35502. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35503. * Supports definition of mesh facing forward or backward
  35504. * @param amountRight defines the distance on the right axis
  35505. * @param amountUp defines the distance on the up axis
  35506. * @param amountForward defines the distance on the forward axis
  35507. * @returns the current mesh
  35508. */
  35509. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35510. /**
  35511. * Calculate relative position change from the point of view of behind the front of the mesh.
  35512. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35513. * Supports definition of mesh facing forward or backward
  35514. * @param amountRight defines the distance on the right axis
  35515. * @param amountUp defines the distance on the up axis
  35516. * @param amountForward defines the distance on the forward axis
  35517. * @returns the new displacement vector
  35518. */
  35519. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35520. /**
  35521. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35522. * Supports definition of mesh facing forward or backward
  35523. * @param flipBack defines the flip
  35524. * @param twirlClockwise defines the twirl
  35525. * @param tiltRight defines the tilt
  35526. * @returns the current mesh
  35527. */
  35528. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35529. /**
  35530. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35531. * Supports definition of mesh facing forward or backward.
  35532. * @param flipBack defines the flip
  35533. * @param twirlClockwise defines the twirl
  35534. * @param tiltRight defines the tilt
  35535. * @returns the new rotation vector
  35536. */
  35537. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35538. /**
  35539. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35540. * This means the mesh underlying bounding box and sphere are recomputed.
  35541. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35542. * @returns the current mesh
  35543. */
  35544. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35545. /** @hidden */
  35546. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35547. /** @hidden */
  35548. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35549. /** @hidden */
  35550. _updateBoundingInfo(): AbstractMesh;
  35551. /** @hidden */
  35552. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35553. /** @hidden */
  35554. protected _afterComputeWorldMatrix(): void;
  35555. /** @hidden */
  35556. get _effectiveMesh(): AbstractMesh;
  35557. /**
  35558. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35559. * A mesh is in the frustum if its bounding box intersects the frustum
  35560. * @param frustumPlanes defines the frustum to test
  35561. * @returns true if the mesh is in the frustum planes
  35562. */
  35563. isInFrustum(frustumPlanes: Plane[]): boolean;
  35564. /**
  35565. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35566. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35567. * @param frustumPlanes defines the frustum to test
  35568. * @returns true if the mesh is completely in the frustum planes
  35569. */
  35570. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35571. /**
  35572. * True if the mesh intersects another mesh or a SolidParticle object
  35573. * @param mesh defines a target mesh or SolidParticle to test
  35574. * @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)
  35575. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35576. * @returns true if there is an intersection
  35577. */
  35578. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35579. /**
  35580. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35581. * @param point defines the point to test
  35582. * @returns true if there is an intersection
  35583. */
  35584. intersectsPoint(point: Vector3): boolean;
  35585. /**
  35586. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35587. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35588. */
  35589. get checkCollisions(): boolean;
  35590. set checkCollisions(collisionEnabled: boolean);
  35591. /**
  35592. * Gets Collider object used to compute collisions (not physics)
  35593. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35594. */
  35595. get collider(): Nullable<Collider>;
  35596. /**
  35597. * Move the mesh using collision engine
  35598. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35599. * @param displacement defines the requested displacement vector
  35600. * @returns the current mesh
  35601. */
  35602. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35603. private _onCollisionPositionChange;
  35604. /** @hidden */
  35605. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35606. /** @hidden */
  35607. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35608. /** @hidden */
  35609. _checkCollision(collider: Collider): AbstractMesh;
  35610. /** @hidden */
  35611. _generatePointsArray(): boolean;
  35612. /**
  35613. * Checks if the passed Ray intersects with the mesh
  35614. * @param ray defines the ray to use
  35615. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35616. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35617. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35618. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35619. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  35620. * @returns the picking info
  35621. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35622. */
  35623. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  35624. /**
  35625. * Clones the current mesh
  35626. * @param name defines the mesh name
  35627. * @param newParent defines the new mesh parent
  35628. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35629. * @returns the new mesh
  35630. */
  35631. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35632. /**
  35633. * Disposes all the submeshes of the current meshnp
  35634. * @returns the current mesh
  35635. */
  35636. releaseSubMeshes(): AbstractMesh;
  35637. /**
  35638. * Releases resources associated with this abstract mesh.
  35639. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35640. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35641. */
  35642. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35643. /**
  35644. * Adds the passed mesh as a child to the current mesh
  35645. * @param mesh defines the child mesh
  35646. * @returns the current mesh
  35647. */
  35648. addChild(mesh: AbstractMesh): AbstractMesh;
  35649. /**
  35650. * Removes the passed mesh from the current mesh children list
  35651. * @param mesh defines the child mesh
  35652. * @returns the current mesh
  35653. */
  35654. removeChild(mesh: AbstractMesh): AbstractMesh;
  35655. /** @hidden */
  35656. private _initFacetData;
  35657. /**
  35658. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35659. * This method can be called within the render loop.
  35660. * 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
  35661. * @returns the current mesh
  35662. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35663. */
  35664. updateFacetData(): AbstractMesh;
  35665. /**
  35666. * Returns the facetLocalNormals array.
  35667. * The normals are expressed in the mesh local spac
  35668. * @returns an array of Vector3
  35669. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35670. */
  35671. getFacetLocalNormals(): Vector3[];
  35672. /**
  35673. * Returns the facetLocalPositions array.
  35674. * The facet positions are expressed in the mesh local space
  35675. * @returns an array of Vector3
  35676. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35677. */
  35678. getFacetLocalPositions(): Vector3[];
  35679. /**
  35680. * Returns the facetLocalPartioning array
  35681. * @returns an array of array of numbers
  35682. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35683. */
  35684. getFacetLocalPartitioning(): number[][];
  35685. /**
  35686. * Returns the i-th facet position in the world system.
  35687. * This method allocates a new Vector3 per call
  35688. * @param i defines the facet index
  35689. * @returns a new Vector3
  35690. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35691. */
  35692. getFacetPosition(i: number): Vector3;
  35693. /**
  35694. * Sets the reference Vector3 with the i-th facet position in the world system
  35695. * @param i defines the facet index
  35696. * @param ref defines the target vector
  35697. * @returns the current mesh
  35698. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35699. */
  35700. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35701. /**
  35702. * Returns the i-th facet normal in the world system.
  35703. * This method allocates a new Vector3 per call
  35704. * @param i defines the facet index
  35705. * @returns a new Vector3
  35706. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35707. */
  35708. getFacetNormal(i: number): Vector3;
  35709. /**
  35710. * Sets the reference Vector3 with the i-th facet normal in the world system
  35711. * @param i defines the facet index
  35712. * @param ref defines the target vector
  35713. * @returns the current mesh
  35714. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35715. */
  35716. getFacetNormalToRef(i: number, ref: Vector3): this;
  35717. /**
  35718. * 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)
  35719. * @param x defines x coordinate
  35720. * @param y defines y coordinate
  35721. * @param z defines z coordinate
  35722. * @returns the array of facet indexes
  35723. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35724. */
  35725. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35726. /**
  35727. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35728. * @param projected sets as the (x,y,z) world projection on the facet
  35729. * @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
  35730. * @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
  35731. * @param x defines x coordinate
  35732. * @param y defines y coordinate
  35733. * @param z defines z coordinate
  35734. * @returns the face index if found (or null instead)
  35735. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35736. */
  35737. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35738. /**
  35739. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35740. * @param projected sets as the (x,y,z) local projection on the facet
  35741. * @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
  35742. * @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
  35743. * @param x defines x coordinate
  35744. * @param y defines y coordinate
  35745. * @param z defines z coordinate
  35746. * @returns the face index if found (or null instead)
  35747. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35748. */
  35749. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35750. /**
  35751. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35752. * @returns the parameters
  35753. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35754. */
  35755. getFacetDataParameters(): any;
  35756. /**
  35757. * Disables the feature FacetData and frees the related memory
  35758. * @returns the current mesh
  35759. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35760. */
  35761. disableFacetData(): AbstractMesh;
  35762. /**
  35763. * Updates the AbstractMesh indices array
  35764. * @param indices defines the data source
  35765. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35766. * @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)
  35767. * @returns the current mesh
  35768. */
  35769. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35770. /**
  35771. * Creates new normals data for the mesh
  35772. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35773. * @returns the current mesh
  35774. */
  35775. createNormals(updatable: boolean): AbstractMesh;
  35776. /**
  35777. * Align the mesh with a normal
  35778. * @param normal defines the normal to use
  35779. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35780. * @returns the current mesh
  35781. */
  35782. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35783. /** @hidden */
  35784. _checkOcclusionQuery(): boolean;
  35785. /**
  35786. * Disables the mesh edge rendering mode
  35787. * @returns the currentAbstractMesh
  35788. */
  35789. disableEdgesRendering(): AbstractMesh;
  35790. /**
  35791. * Enables the edge rendering mode on the mesh.
  35792. * This mode makes the mesh edges visible
  35793. * @param epsilon defines the maximal distance between two angles to detect a face
  35794. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35795. * @param options options to the edge renderer
  35796. * @returns the currentAbstractMesh
  35797. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35798. */
  35799. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  35800. /**
  35801. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35802. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35803. */
  35804. getConnectedParticleSystems(): IParticleSystem[];
  35805. }
  35806. }
  35807. declare module BABYLON {
  35808. /**
  35809. * Interface used to define ActionEvent
  35810. */
  35811. export interface IActionEvent {
  35812. /** The mesh or sprite that triggered the action */
  35813. source: any;
  35814. /** The X mouse cursor position at the time of the event */
  35815. pointerX: number;
  35816. /** The Y mouse cursor position at the time of the event */
  35817. pointerY: number;
  35818. /** The mesh that is currently pointed at (can be null) */
  35819. meshUnderPointer: Nullable<AbstractMesh>;
  35820. /** the original (browser) event that triggered the ActionEvent */
  35821. sourceEvent?: any;
  35822. /** additional data for the event */
  35823. additionalData?: any;
  35824. }
  35825. /**
  35826. * ActionEvent is the event being sent when an action is triggered.
  35827. */
  35828. export class ActionEvent implements IActionEvent {
  35829. /** The mesh or sprite that triggered the action */
  35830. source: any;
  35831. /** The X mouse cursor position at the time of the event */
  35832. pointerX: number;
  35833. /** The Y mouse cursor position at the time of the event */
  35834. pointerY: number;
  35835. /** The mesh that is currently pointed at (can be null) */
  35836. meshUnderPointer: Nullable<AbstractMesh>;
  35837. /** the original (browser) event that triggered the ActionEvent */
  35838. sourceEvent?: any;
  35839. /** additional data for the event */
  35840. additionalData?: any;
  35841. /**
  35842. * Creates a new ActionEvent
  35843. * @param source The mesh or sprite that triggered the action
  35844. * @param pointerX The X mouse cursor position at the time of the event
  35845. * @param pointerY The Y mouse cursor position at the time of the event
  35846. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  35847. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  35848. * @param additionalData additional data for the event
  35849. */
  35850. constructor(
  35851. /** The mesh or sprite that triggered the action */
  35852. source: any,
  35853. /** The X mouse cursor position at the time of the event */
  35854. pointerX: number,
  35855. /** The Y mouse cursor position at the time of the event */
  35856. pointerY: number,
  35857. /** The mesh that is currently pointed at (can be null) */
  35858. meshUnderPointer: Nullable<AbstractMesh>,
  35859. /** the original (browser) event that triggered the ActionEvent */
  35860. sourceEvent?: any,
  35861. /** additional data for the event */
  35862. additionalData?: any);
  35863. /**
  35864. * Helper function to auto-create an ActionEvent from a source mesh.
  35865. * @param source The source mesh that triggered the event
  35866. * @param evt The original (browser) event
  35867. * @param additionalData additional data for the event
  35868. * @returns the new ActionEvent
  35869. */
  35870. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  35871. /**
  35872. * Helper function to auto-create an ActionEvent from a source sprite
  35873. * @param source The source sprite that triggered the event
  35874. * @param scene Scene associated with the sprite
  35875. * @param evt The original (browser) event
  35876. * @param additionalData additional data for the event
  35877. * @returns the new ActionEvent
  35878. */
  35879. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  35880. /**
  35881. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  35882. * @param scene the scene where the event occurred
  35883. * @param evt The original (browser) event
  35884. * @returns the new ActionEvent
  35885. */
  35886. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  35887. /**
  35888. * Helper function to auto-create an ActionEvent from a primitive
  35889. * @param prim defines the target primitive
  35890. * @param pointerPos defines the pointer position
  35891. * @param evt The original (browser) event
  35892. * @param additionalData additional data for the event
  35893. * @returns the new ActionEvent
  35894. */
  35895. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  35896. }
  35897. }
  35898. declare module BABYLON {
  35899. /**
  35900. * Abstract class used to decouple action Manager from scene and meshes.
  35901. * Do not instantiate.
  35902. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35903. */
  35904. export abstract class AbstractActionManager implements IDisposable {
  35905. /** Gets the list of active triggers */
  35906. static Triggers: {
  35907. [key: string]: number;
  35908. };
  35909. /** Gets the cursor to use when hovering items */
  35910. hoverCursor: string;
  35911. /** Gets the list of actions */
  35912. actions: IAction[];
  35913. /**
  35914. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  35915. */
  35916. isRecursive: boolean;
  35917. /**
  35918. * Releases all associated resources
  35919. */
  35920. abstract dispose(): void;
  35921. /**
  35922. * Does this action manager has pointer triggers
  35923. */
  35924. abstract get hasPointerTriggers(): boolean;
  35925. /**
  35926. * Does this action manager has pick triggers
  35927. */
  35928. abstract get hasPickTriggers(): boolean;
  35929. /**
  35930. * Process a specific trigger
  35931. * @param trigger defines the trigger to process
  35932. * @param evt defines the event details to be processed
  35933. */
  35934. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  35935. /**
  35936. * Does this action manager handles actions of any of the given triggers
  35937. * @param triggers defines the triggers to be tested
  35938. * @return a boolean indicating whether one (or more) of the triggers is handled
  35939. */
  35940. abstract hasSpecificTriggers(triggers: number[]): boolean;
  35941. /**
  35942. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  35943. * speed.
  35944. * @param triggerA defines the trigger to be tested
  35945. * @param triggerB defines the trigger to be tested
  35946. * @return a boolean indicating whether one (or more) of the triggers is handled
  35947. */
  35948. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  35949. /**
  35950. * Does this action manager handles actions of a given trigger
  35951. * @param trigger defines the trigger to be tested
  35952. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  35953. * @return whether the trigger is handled
  35954. */
  35955. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  35956. /**
  35957. * Serialize this manager to a JSON object
  35958. * @param name defines the property name to store this manager
  35959. * @returns a JSON representation of this manager
  35960. */
  35961. abstract serialize(name: string): any;
  35962. /**
  35963. * Registers an action to this action manager
  35964. * @param action defines the action to be registered
  35965. * @return the action amended (prepared) after registration
  35966. */
  35967. abstract registerAction(action: IAction): Nullable<IAction>;
  35968. /**
  35969. * Unregisters an action to this action manager
  35970. * @param action defines the action to be unregistered
  35971. * @return a boolean indicating whether the action has been unregistered
  35972. */
  35973. abstract unregisterAction(action: IAction): Boolean;
  35974. /**
  35975. * Does exist one action manager with at least one trigger
  35976. **/
  35977. static get HasTriggers(): boolean;
  35978. /**
  35979. * Does exist one action manager with at least one pick trigger
  35980. **/
  35981. static get HasPickTriggers(): boolean;
  35982. /**
  35983. * Does exist one action manager that handles actions of a given trigger
  35984. * @param trigger defines the trigger to be tested
  35985. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  35986. **/
  35987. static HasSpecificTrigger(trigger: number): boolean;
  35988. }
  35989. }
  35990. declare module BABYLON {
  35991. /**
  35992. * Defines how a node can be built from a string name.
  35993. */
  35994. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  35995. /**
  35996. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  35997. */
  35998. export class Node implements IBehaviorAware<Node> {
  35999. /** @hidden */
  36000. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36001. private static _NodeConstructors;
  36002. /**
  36003. * Add a new node constructor
  36004. * @param type defines the type name of the node to construct
  36005. * @param constructorFunc defines the constructor function
  36006. */
  36007. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36008. /**
  36009. * Returns a node constructor based on type name
  36010. * @param type defines the type name
  36011. * @param name defines the new node name
  36012. * @param scene defines the hosting scene
  36013. * @param options defines optional options to transmit to constructors
  36014. * @returns the new constructor or null
  36015. */
  36016. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36017. /**
  36018. * Gets or sets the name of the node
  36019. */
  36020. name: string;
  36021. /**
  36022. * Gets or sets the id of the node
  36023. */
  36024. id: string;
  36025. /**
  36026. * Gets or sets the unique id of the node
  36027. */
  36028. uniqueId: number;
  36029. /**
  36030. * Gets or sets a string used to store user defined state for the node
  36031. */
  36032. state: string;
  36033. /**
  36034. * Gets or sets an object used to store user defined information for the node
  36035. */
  36036. metadata: any;
  36037. /**
  36038. * For internal use only. Please do not use.
  36039. */
  36040. reservedDataStore: any;
  36041. /**
  36042. * List of inspectable custom properties (used by the Inspector)
  36043. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36044. */
  36045. inspectableCustomProperties: IInspectable[];
  36046. private _doNotSerialize;
  36047. /**
  36048. * Gets or sets a boolean used to define if the node must be serialized
  36049. */
  36050. get doNotSerialize(): boolean;
  36051. set doNotSerialize(value: boolean);
  36052. /** @hidden */
  36053. _isDisposed: boolean;
  36054. /**
  36055. * Gets a list of Animations associated with the node
  36056. */
  36057. animations: Animation[];
  36058. protected _ranges: {
  36059. [name: string]: Nullable<AnimationRange>;
  36060. };
  36061. /**
  36062. * Callback raised when the node is ready to be used
  36063. */
  36064. onReady: Nullable<(node: Node) => void>;
  36065. private _isEnabled;
  36066. private _isParentEnabled;
  36067. private _isReady;
  36068. /** @hidden */
  36069. _currentRenderId: number;
  36070. private _parentUpdateId;
  36071. /** @hidden */
  36072. _childUpdateId: number;
  36073. /** @hidden */
  36074. _waitingParentId: Nullable<string>;
  36075. /** @hidden */
  36076. _scene: Scene;
  36077. /** @hidden */
  36078. _cache: any;
  36079. private _parentNode;
  36080. private _children;
  36081. /** @hidden */
  36082. _worldMatrix: Matrix;
  36083. /** @hidden */
  36084. _worldMatrixDeterminant: number;
  36085. /** @hidden */
  36086. _worldMatrixDeterminantIsDirty: boolean;
  36087. /** @hidden */
  36088. private _sceneRootNodesIndex;
  36089. /**
  36090. * Gets a boolean indicating if the node has been disposed
  36091. * @returns true if the node was disposed
  36092. */
  36093. isDisposed(): boolean;
  36094. /**
  36095. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36096. * @see https://doc.babylonjs.com/how_to/parenting
  36097. */
  36098. set parent(parent: Nullable<Node>);
  36099. get parent(): Nullable<Node>;
  36100. /** @hidden */
  36101. _addToSceneRootNodes(): void;
  36102. /** @hidden */
  36103. _removeFromSceneRootNodes(): void;
  36104. private _animationPropertiesOverride;
  36105. /**
  36106. * Gets or sets the animation properties override
  36107. */
  36108. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36109. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36110. /**
  36111. * Gets a string identifying the name of the class
  36112. * @returns "Node" string
  36113. */
  36114. getClassName(): string;
  36115. /** @hidden */
  36116. readonly _isNode: boolean;
  36117. /**
  36118. * An event triggered when the mesh is disposed
  36119. */
  36120. onDisposeObservable: Observable<Node>;
  36121. private _onDisposeObserver;
  36122. /**
  36123. * Sets a callback that will be raised when the node will be disposed
  36124. */
  36125. set onDispose(callback: () => void);
  36126. /**
  36127. * Creates a new Node
  36128. * @param name the name and id to be given to this node
  36129. * @param scene the scene this node will be added to
  36130. */
  36131. constructor(name: string, scene?: Nullable<Scene>);
  36132. /**
  36133. * Gets the scene of the node
  36134. * @returns a scene
  36135. */
  36136. getScene(): Scene;
  36137. /**
  36138. * Gets the engine of the node
  36139. * @returns a Engine
  36140. */
  36141. getEngine(): Engine;
  36142. private _behaviors;
  36143. /**
  36144. * Attach a behavior to the node
  36145. * @see https://doc.babylonjs.com/features/behaviour
  36146. * @param behavior defines the behavior to attach
  36147. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36148. * @returns the current Node
  36149. */
  36150. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36151. /**
  36152. * Remove an attached behavior
  36153. * @see https://doc.babylonjs.com/features/behaviour
  36154. * @param behavior defines the behavior to attach
  36155. * @returns the current Node
  36156. */
  36157. removeBehavior(behavior: Behavior<Node>): Node;
  36158. /**
  36159. * Gets the list of attached behaviors
  36160. * @see https://doc.babylonjs.com/features/behaviour
  36161. */
  36162. get behaviors(): Behavior<Node>[];
  36163. /**
  36164. * Gets an attached behavior by name
  36165. * @param name defines the name of the behavior to look for
  36166. * @see https://doc.babylonjs.com/features/behaviour
  36167. * @returns null if behavior was not found else the requested behavior
  36168. */
  36169. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36170. /**
  36171. * Returns the latest update of the World matrix
  36172. * @returns a Matrix
  36173. */
  36174. getWorldMatrix(): Matrix;
  36175. /** @hidden */
  36176. _getWorldMatrixDeterminant(): number;
  36177. /**
  36178. * Returns directly the latest state of the mesh World matrix.
  36179. * A Matrix is returned.
  36180. */
  36181. get worldMatrixFromCache(): Matrix;
  36182. /** @hidden */
  36183. _initCache(): void;
  36184. /** @hidden */
  36185. updateCache(force?: boolean): void;
  36186. /** @hidden */
  36187. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36188. /** @hidden */
  36189. _updateCache(ignoreParentClass?: boolean): void;
  36190. /** @hidden */
  36191. _isSynchronized(): boolean;
  36192. /** @hidden */
  36193. _markSyncedWithParent(): void;
  36194. /** @hidden */
  36195. isSynchronizedWithParent(): boolean;
  36196. /** @hidden */
  36197. isSynchronized(): boolean;
  36198. /**
  36199. * Is this node ready to be used/rendered
  36200. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36201. * @return true if the node is ready
  36202. */
  36203. isReady(completeCheck?: boolean): boolean;
  36204. /**
  36205. * Is this node enabled?
  36206. * 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
  36207. * @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
  36208. * @return whether this node (and its parent) is enabled
  36209. */
  36210. isEnabled(checkAncestors?: boolean): boolean;
  36211. /** @hidden */
  36212. protected _syncParentEnabledState(): void;
  36213. /**
  36214. * Set the enabled state of this node
  36215. * @param value defines the new enabled state
  36216. */
  36217. setEnabled(value: boolean): void;
  36218. /**
  36219. * Is this node a descendant of the given node?
  36220. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36221. * @param ancestor defines the parent node to inspect
  36222. * @returns a boolean indicating if this node is a descendant of the given node
  36223. */
  36224. isDescendantOf(ancestor: Node): boolean;
  36225. /** @hidden */
  36226. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36227. /**
  36228. * Will return all nodes that have this node as ascendant
  36229. * @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
  36230. * @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
  36231. * @return all children nodes of all types
  36232. */
  36233. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36234. /**
  36235. * Get all child-meshes of this node
  36236. * @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)
  36237. * @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
  36238. * @returns an array of AbstractMesh
  36239. */
  36240. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36241. /**
  36242. * Get all direct children of this node
  36243. * @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
  36244. * @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)
  36245. * @returns an array of Node
  36246. */
  36247. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36248. /** @hidden */
  36249. _setReady(state: boolean): void;
  36250. /**
  36251. * Get an animation by name
  36252. * @param name defines the name of the animation to look for
  36253. * @returns null if not found else the requested animation
  36254. */
  36255. getAnimationByName(name: string): Nullable<Animation>;
  36256. /**
  36257. * Creates an animation range for this node
  36258. * @param name defines the name of the range
  36259. * @param from defines the starting key
  36260. * @param to defines the end key
  36261. */
  36262. createAnimationRange(name: string, from: number, to: number): void;
  36263. /**
  36264. * Delete a specific animation range
  36265. * @param name defines the name of the range to delete
  36266. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36267. */
  36268. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36269. /**
  36270. * Get an animation range by name
  36271. * @param name defines the name of the animation range to look for
  36272. * @returns null if not found else the requested animation range
  36273. */
  36274. getAnimationRange(name: string): Nullable<AnimationRange>;
  36275. /**
  36276. * Gets the list of all animation ranges defined on this node
  36277. * @returns an array
  36278. */
  36279. getAnimationRanges(): Nullable<AnimationRange>[];
  36280. /**
  36281. * Will start the animation sequence
  36282. * @param name defines the range frames for animation sequence
  36283. * @param loop defines if the animation should loop (false by default)
  36284. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36285. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36286. * @returns the object created for this animation. If range does not exist, it will return null
  36287. */
  36288. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36289. /**
  36290. * Serialize animation ranges into a JSON compatible object
  36291. * @returns serialization object
  36292. */
  36293. serializeAnimationRanges(): any;
  36294. /**
  36295. * Computes the world matrix of the node
  36296. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36297. * @returns the world matrix
  36298. */
  36299. computeWorldMatrix(force?: boolean): Matrix;
  36300. /**
  36301. * Releases resources associated with this node.
  36302. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36303. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36304. */
  36305. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36306. /**
  36307. * Parse animation range data from a serialization object and store them into a given node
  36308. * @param node defines where to store the animation ranges
  36309. * @param parsedNode defines the serialization object to read data from
  36310. * @param scene defines the hosting scene
  36311. */
  36312. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36313. /**
  36314. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36315. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36316. * @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
  36317. * @returns the new bounding vectors
  36318. */
  36319. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36320. min: Vector3;
  36321. max: Vector3;
  36322. };
  36323. }
  36324. }
  36325. declare module BABYLON {
  36326. /**
  36327. * @hidden
  36328. */
  36329. export class _IAnimationState {
  36330. key: number;
  36331. repeatCount: number;
  36332. workValue?: any;
  36333. loopMode?: number;
  36334. offsetValue?: any;
  36335. highLimitValue?: any;
  36336. }
  36337. /**
  36338. * Class used to store any kind of animation
  36339. */
  36340. export class Animation {
  36341. /**Name of the animation */
  36342. name: string;
  36343. /**Property to animate */
  36344. targetProperty: string;
  36345. /**The frames per second of the animation */
  36346. framePerSecond: number;
  36347. /**The data type of the animation */
  36348. dataType: number;
  36349. /**The loop mode of the animation */
  36350. loopMode?: number | undefined;
  36351. /**Specifies if blending should be enabled */
  36352. enableBlending?: boolean | undefined;
  36353. /**
  36354. * Use matrix interpolation instead of using direct key value when animating matrices
  36355. */
  36356. static AllowMatricesInterpolation: boolean;
  36357. /**
  36358. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36359. */
  36360. static AllowMatrixDecomposeForInterpolation: boolean;
  36361. /** Define the Url to load snippets */
  36362. static SnippetUrl: string;
  36363. /** Snippet ID if the animation was created from the snippet server */
  36364. snippetId: string;
  36365. /**
  36366. * Stores the key frames of the animation
  36367. */
  36368. private _keys;
  36369. /**
  36370. * Stores the easing function of the animation
  36371. */
  36372. private _easingFunction;
  36373. /**
  36374. * @hidden Internal use only
  36375. */
  36376. _runtimeAnimations: RuntimeAnimation[];
  36377. /**
  36378. * The set of event that will be linked to this animation
  36379. */
  36380. private _events;
  36381. /**
  36382. * Stores an array of target property paths
  36383. */
  36384. targetPropertyPath: string[];
  36385. /**
  36386. * Stores the blending speed of the animation
  36387. */
  36388. blendingSpeed: number;
  36389. /**
  36390. * Stores the animation ranges for the animation
  36391. */
  36392. private _ranges;
  36393. /**
  36394. * @hidden Internal use
  36395. */
  36396. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36397. /**
  36398. * Sets up an animation
  36399. * @param property The property to animate
  36400. * @param animationType The animation type to apply
  36401. * @param framePerSecond The frames per second of the animation
  36402. * @param easingFunction The easing function used in the animation
  36403. * @returns The created animation
  36404. */
  36405. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36406. /**
  36407. * Create and start an animation on a node
  36408. * @param name defines the name of the global animation that will be run on all nodes
  36409. * @param node defines the root node where the animation will take place
  36410. * @param targetProperty defines property to animate
  36411. * @param framePerSecond defines the number of frame per second yo use
  36412. * @param totalFrame defines the number of frames in total
  36413. * @param from defines the initial value
  36414. * @param to defines the final value
  36415. * @param loopMode defines which loop mode you want to use (off by default)
  36416. * @param easingFunction defines the easing function to use (linear by default)
  36417. * @param onAnimationEnd defines the callback to call when animation end
  36418. * @returns the animatable created for this animation
  36419. */
  36420. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36421. /**
  36422. * Create and start an animation on a node and its descendants
  36423. * @param name defines the name of the global animation that will be run on all nodes
  36424. * @param node defines the root node where the animation will take place
  36425. * @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
  36426. * @param targetProperty defines property to animate
  36427. * @param framePerSecond defines the number of frame per second to use
  36428. * @param totalFrame defines the number of frames in total
  36429. * @param from defines the initial value
  36430. * @param to defines the final value
  36431. * @param loopMode defines which loop mode you want to use (off by default)
  36432. * @param easingFunction defines the easing function to use (linear by default)
  36433. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36434. * @returns the list of animatables created for all nodes
  36435. * @example https://www.babylonjs-playground.com/#MH0VLI
  36436. */
  36437. 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[]>;
  36438. /**
  36439. * Creates a new animation, merges it with the existing animations and starts it
  36440. * @param name Name of the animation
  36441. * @param node Node which contains the scene that begins the animations
  36442. * @param targetProperty Specifies which property to animate
  36443. * @param framePerSecond The frames per second of the animation
  36444. * @param totalFrame The total number of frames
  36445. * @param from The frame at the beginning of the animation
  36446. * @param to The frame at the end of the animation
  36447. * @param loopMode Specifies the loop mode of the animation
  36448. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36449. * @param onAnimationEnd Callback to run once the animation is complete
  36450. * @returns Nullable animation
  36451. */
  36452. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36453. /**
  36454. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36455. * @param sourceAnimation defines the Animation containing keyframes to convert
  36456. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36457. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36458. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36459. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36460. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36461. */
  36462. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36463. /**
  36464. * Transition property of an host to the target Value
  36465. * @param property The property to transition
  36466. * @param targetValue The target Value of the property
  36467. * @param host The object where the property to animate belongs
  36468. * @param scene Scene used to run the animation
  36469. * @param frameRate Framerate (in frame/s) to use
  36470. * @param transition The transition type we want to use
  36471. * @param duration The duration of the animation, in milliseconds
  36472. * @param onAnimationEnd Callback trigger at the end of the animation
  36473. * @returns Nullable animation
  36474. */
  36475. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36476. /**
  36477. * Return the array of runtime animations currently using this animation
  36478. */
  36479. get runtimeAnimations(): RuntimeAnimation[];
  36480. /**
  36481. * Specifies if any of the runtime animations are currently running
  36482. */
  36483. get hasRunningRuntimeAnimations(): boolean;
  36484. /**
  36485. * Initializes the animation
  36486. * @param name Name of the animation
  36487. * @param targetProperty Property to animate
  36488. * @param framePerSecond The frames per second of the animation
  36489. * @param dataType The data type of the animation
  36490. * @param loopMode The loop mode of the animation
  36491. * @param enableBlending Specifies if blending should be enabled
  36492. */
  36493. constructor(
  36494. /**Name of the animation */
  36495. name: string,
  36496. /**Property to animate */
  36497. targetProperty: string,
  36498. /**The frames per second of the animation */
  36499. framePerSecond: number,
  36500. /**The data type of the animation */
  36501. dataType: number,
  36502. /**The loop mode of the animation */
  36503. loopMode?: number | undefined,
  36504. /**Specifies if blending should be enabled */
  36505. enableBlending?: boolean | undefined);
  36506. /**
  36507. * Converts the animation to a string
  36508. * @param fullDetails support for multiple levels of logging within scene loading
  36509. * @returns String form of the animation
  36510. */
  36511. toString(fullDetails?: boolean): string;
  36512. /**
  36513. * Add an event to this animation
  36514. * @param event Event to add
  36515. */
  36516. addEvent(event: AnimationEvent): void;
  36517. /**
  36518. * Remove all events found at the given frame
  36519. * @param frame The frame to remove events from
  36520. */
  36521. removeEvents(frame: number): void;
  36522. /**
  36523. * Retrieves all the events from the animation
  36524. * @returns Events from the animation
  36525. */
  36526. getEvents(): AnimationEvent[];
  36527. /**
  36528. * Creates an animation range
  36529. * @param name Name of the animation range
  36530. * @param from Starting frame of the animation range
  36531. * @param to Ending frame of the animation
  36532. */
  36533. createRange(name: string, from: number, to: number): void;
  36534. /**
  36535. * Deletes an animation range by name
  36536. * @param name Name of the animation range to delete
  36537. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36538. */
  36539. deleteRange(name: string, deleteFrames?: boolean): void;
  36540. /**
  36541. * Gets the animation range by name, or null if not defined
  36542. * @param name Name of the animation range
  36543. * @returns Nullable animation range
  36544. */
  36545. getRange(name: string): Nullable<AnimationRange>;
  36546. /**
  36547. * Gets the key frames from the animation
  36548. * @returns The key frames of the animation
  36549. */
  36550. getKeys(): Array<IAnimationKey>;
  36551. /**
  36552. * Gets the highest frame rate of the animation
  36553. * @returns Highest frame rate of the animation
  36554. */
  36555. getHighestFrame(): number;
  36556. /**
  36557. * Gets the easing function of the animation
  36558. * @returns Easing function of the animation
  36559. */
  36560. getEasingFunction(): IEasingFunction;
  36561. /**
  36562. * Sets the easing function of the animation
  36563. * @param easingFunction A custom mathematical formula for animation
  36564. */
  36565. setEasingFunction(easingFunction: EasingFunction): void;
  36566. /**
  36567. * Interpolates a scalar linearly
  36568. * @param startValue Start value of the animation curve
  36569. * @param endValue End value of the animation curve
  36570. * @param gradient Scalar amount to interpolate
  36571. * @returns Interpolated scalar value
  36572. */
  36573. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36574. /**
  36575. * Interpolates a scalar cubically
  36576. * @param startValue Start value of the animation curve
  36577. * @param outTangent End tangent of the animation
  36578. * @param endValue End value of the animation curve
  36579. * @param inTangent Start tangent of the animation curve
  36580. * @param gradient Scalar amount to interpolate
  36581. * @returns Interpolated scalar value
  36582. */
  36583. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36584. /**
  36585. * Interpolates a quaternion using a spherical linear interpolation
  36586. * @param startValue Start value of the animation curve
  36587. * @param endValue End value of the animation curve
  36588. * @param gradient Scalar amount to interpolate
  36589. * @returns Interpolated quaternion value
  36590. */
  36591. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36592. /**
  36593. * Interpolates a quaternion cubically
  36594. * @param startValue Start value of the animation curve
  36595. * @param outTangent End tangent of the animation curve
  36596. * @param endValue End value of the animation curve
  36597. * @param inTangent Start tangent of the animation curve
  36598. * @param gradient Scalar amount to interpolate
  36599. * @returns Interpolated quaternion value
  36600. */
  36601. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36602. /**
  36603. * Interpolates a Vector3 linearl
  36604. * @param startValue Start value of the animation curve
  36605. * @param endValue End value of the animation curve
  36606. * @param gradient Scalar amount to interpolate
  36607. * @returns Interpolated scalar value
  36608. */
  36609. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36610. /**
  36611. * Interpolates a Vector3 cubically
  36612. * @param startValue Start value of the animation curve
  36613. * @param outTangent End tangent of the animation
  36614. * @param endValue End value of the animation curve
  36615. * @param inTangent Start tangent of the animation curve
  36616. * @param gradient Scalar amount to interpolate
  36617. * @returns InterpolatedVector3 value
  36618. */
  36619. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36620. /**
  36621. * Interpolates a Vector2 linearly
  36622. * @param startValue Start value of the animation curve
  36623. * @param endValue End value of the animation curve
  36624. * @param gradient Scalar amount to interpolate
  36625. * @returns Interpolated Vector2 value
  36626. */
  36627. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36628. /**
  36629. * Interpolates a Vector2 cubically
  36630. * @param startValue Start value of the animation curve
  36631. * @param outTangent End tangent of the animation
  36632. * @param endValue End value of the animation curve
  36633. * @param inTangent Start tangent of the animation curve
  36634. * @param gradient Scalar amount to interpolate
  36635. * @returns Interpolated Vector2 value
  36636. */
  36637. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36638. /**
  36639. * Interpolates a size linearly
  36640. * @param startValue Start value of the animation curve
  36641. * @param endValue End value of the animation curve
  36642. * @param gradient Scalar amount to interpolate
  36643. * @returns Interpolated Size value
  36644. */
  36645. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36646. /**
  36647. * Interpolates a Color3 linearly
  36648. * @param startValue Start value of the animation curve
  36649. * @param endValue End value of the animation curve
  36650. * @param gradient Scalar amount to interpolate
  36651. * @returns Interpolated Color3 value
  36652. */
  36653. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36654. /**
  36655. * Interpolates a Color4 linearly
  36656. * @param startValue Start value of the animation curve
  36657. * @param endValue End value of the animation curve
  36658. * @param gradient Scalar amount to interpolate
  36659. * @returns Interpolated Color3 value
  36660. */
  36661. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36662. /**
  36663. * @hidden Internal use only
  36664. */
  36665. _getKeyValue(value: any): any;
  36666. /**
  36667. * @hidden Internal use only
  36668. */
  36669. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36670. /**
  36671. * Defines the function to use to interpolate matrices
  36672. * @param startValue defines the start matrix
  36673. * @param endValue defines the end matrix
  36674. * @param gradient defines the gradient between both matrices
  36675. * @param result defines an optional target matrix where to store the interpolation
  36676. * @returns the interpolated matrix
  36677. */
  36678. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36679. /**
  36680. * Makes a copy of the animation
  36681. * @returns Cloned animation
  36682. */
  36683. clone(): Animation;
  36684. /**
  36685. * Sets the key frames of the animation
  36686. * @param values The animation key frames to set
  36687. */
  36688. setKeys(values: Array<IAnimationKey>): void;
  36689. /**
  36690. * Serializes the animation to an object
  36691. * @returns Serialized object
  36692. */
  36693. serialize(): any;
  36694. /**
  36695. * Float animation type
  36696. */
  36697. static readonly ANIMATIONTYPE_FLOAT: number;
  36698. /**
  36699. * Vector3 animation type
  36700. */
  36701. static readonly ANIMATIONTYPE_VECTOR3: number;
  36702. /**
  36703. * Quaternion animation type
  36704. */
  36705. static readonly ANIMATIONTYPE_QUATERNION: number;
  36706. /**
  36707. * Matrix animation type
  36708. */
  36709. static readonly ANIMATIONTYPE_MATRIX: number;
  36710. /**
  36711. * Color3 animation type
  36712. */
  36713. static readonly ANIMATIONTYPE_COLOR3: number;
  36714. /**
  36715. * Color3 animation type
  36716. */
  36717. static readonly ANIMATIONTYPE_COLOR4: number;
  36718. /**
  36719. * Vector2 animation type
  36720. */
  36721. static readonly ANIMATIONTYPE_VECTOR2: number;
  36722. /**
  36723. * Size animation type
  36724. */
  36725. static readonly ANIMATIONTYPE_SIZE: number;
  36726. /**
  36727. * Relative Loop Mode
  36728. */
  36729. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36730. /**
  36731. * Cycle Loop Mode
  36732. */
  36733. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36734. /**
  36735. * Constant Loop Mode
  36736. */
  36737. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36738. /** @hidden */
  36739. static _UniversalLerp(left: any, right: any, amount: number): any;
  36740. /**
  36741. * Parses an animation object and creates an animation
  36742. * @param parsedAnimation Parsed animation object
  36743. * @returns Animation object
  36744. */
  36745. static Parse(parsedAnimation: any): Animation;
  36746. /**
  36747. * Appends the serialized animations from the source animations
  36748. * @param source Source containing the animations
  36749. * @param destination Target to store the animations
  36750. */
  36751. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36752. /**
  36753. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36754. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36755. * @param url defines the url to load from
  36756. * @returns a promise that will resolve to the new animation or an array of animations
  36757. */
  36758. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36759. /**
  36760. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36761. * @param snippetId defines the snippet to load
  36762. * @returns a promise that will resolve to the new animation or a new array of animations
  36763. */
  36764. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36765. }
  36766. }
  36767. declare module BABYLON {
  36768. /**
  36769. * Interface containing an array of animations
  36770. */
  36771. export interface IAnimatable {
  36772. /**
  36773. * Array of animations
  36774. */
  36775. animations: Nullable<Array<Animation>>;
  36776. }
  36777. }
  36778. declare module BABYLON {
  36779. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36780. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36781. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36782. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36783. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36784. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36785. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36786. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36787. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36788. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36789. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36790. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36791. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36792. /**
  36793. * Decorator used to define property that can be serialized as reference to a camera
  36794. * @param sourceName defines the name of the property to decorate
  36795. */
  36796. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36797. /**
  36798. * Class used to help serialization objects
  36799. */
  36800. export class SerializationHelper {
  36801. /** @hidden */
  36802. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36803. /** @hidden */
  36804. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36805. /** @hidden */
  36806. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36807. /** @hidden */
  36808. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36809. /**
  36810. * Appends the serialized animations from the source animations
  36811. * @param source Source containing the animations
  36812. * @param destination Target to store the animations
  36813. */
  36814. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36815. /**
  36816. * Static function used to serialized a specific entity
  36817. * @param entity defines the entity to serialize
  36818. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36819. * @returns a JSON compatible object representing the serialization of the entity
  36820. */
  36821. static Serialize<T>(entity: T, serializationObject?: any): any;
  36822. /**
  36823. * Creates a new entity from a serialization data object
  36824. * @param creationFunction defines a function used to instanciated the new entity
  36825. * @param source defines the source serialization data
  36826. * @param scene defines the hosting scene
  36827. * @param rootUrl defines the root url for resources
  36828. * @returns a new entity
  36829. */
  36830. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  36831. /**
  36832. * Clones an object
  36833. * @param creationFunction defines the function used to instanciate the new object
  36834. * @param source defines the source object
  36835. * @returns the cloned object
  36836. */
  36837. static Clone<T>(creationFunction: () => T, source: T): T;
  36838. /**
  36839. * Instanciates a new object based on a source one (some data will be shared between both object)
  36840. * @param creationFunction defines the function used to instanciate the new object
  36841. * @param source defines the source object
  36842. * @returns the new object
  36843. */
  36844. static Instanciate<T>(creationFunction: () => T, source: T): T;
  36845. }
  36846. }
  36847. declare module BABYLON {
  36848. /**
  36849. * This is the base class of all the camera used in the application.
  36850. * @see https://doc.babylonjs.com/features/cameras
  36851. */
  36852. export class Camera extends Node {
  36853. /** @hidden */
  36854. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  36855. /**
  36856. * This is the default projection mode used by the cameras.
  36857. * It helps recreating a feeling of perspective and better appreciate depth.
  36858. * This is the best way to simulate real life cameras.
  36859. */
  36860. static readonly PERSPECTIVE_CAMERA: number;
  36861. /**
  36862. * This helps creating camera with an orthographic mode.
  36863. * 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.
  36864. */
  36865. static readonly ORTHOGRAPHIC_CAMERA: number;
  36866. /**
  36867. * This is the default FOV mode for perspective cameras.
  36868. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  36869. */
  36870. static readonly FOVMODE_VERTICAL_FIXED: number;
  36871. /**
  36872. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  36873. */
  36874. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  36875. /**
  36876. * This specifies ther is no need for a camera rig.
  36877. * Basically only one eye is rendered corresponding to the camera.
  36878. */
  36879. static readonly RIG_MODE_NONE: number;
  36880. /**
  36881. * Simulates a camera Rig with one blue eye and one red eye.
  36882. * This can be use with 3d blue and red glasses.
  36883. */
  36884. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  36885. /**
  36886. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  36887. */
  36888. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  36889. /**
  36890. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  36891. */
  36892. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  36893. /**
  36894. * Defines that both eyes of the camera will be rendered over under each other.
  36895. */
  36896. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  36897. /**
  36898. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  36899. */
  36900. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  36901. /**
  36902. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  36903. */
  36904. static readonly RIG_MODE_VR: number;
  36905. /**
  36906. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  36907. */
  36908. static readonly RIG_MODE_WEBVR: number;
  36909. /**
  36910. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  36911. */
  36912. static readonly RIG_MODE_CUSTOM: number;
  36913. /**
  36914. * Defines if by default attaching controls should prevent the default javascript event to continue.
  36915. */
  36916. static ForceAttachControlToAlwaysPreventDefault: boolean;
  36917. /**
  36918. * Define the input manager associated with the camera.
  36919. */
  36920. inputs: CameraInputsManager<Camera>;
  36921. /** @hidden */
  36922. _position: Vector3;
  36923. /**
  36924. * Define the current local position of the camera in the scene
  36925. */
  36926. get position(): Vector3;
  36927. set position(newPosition: Vector3);
  36928. protected _upVector: Vector3;
  36929. /**
  36930. * The vector the camera should consider as up.
  36931. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  36932. */
  36933. set upVector(vec: Vector3);
  36934. get upVector(): Vector3;
  36935. /**
  36936. * Define the current limit on the left side for an orthographic camera
  36937. * In scene unit
  36938. */
  36939. orthoLeft: Nullable<number>;
  36940. /**
  36941. * Define the current limit on the right side for an orthographic camera
  36942. * In scene unit
  36943. */
  36944. orthoRight: Nullable<number>;
  36945. /**
  36946. * Define the current limit on the bottom side for an orthographic camera
  36947. * In scene unit
  36948. */
  36949. orthoBottom: Nullable<number>;
  36950. /**
  36951. * Define the current limit on the top side for an orthographic camera
  36952. * In scene unit
  36953. */
  36954. orthoTop: Nullable<number>;
  36955. /**
  36956. * Field Of View is set in Radians. (default is 0.8)
  36957. */
  36958. fov: number;
  36959. /**
  36960. * Define the minimum distance the camera can see from.
  36961. * This is important to note that the depth buffer are not infinite and the closer it starts
  36962. * the more your scene might encounter depth fighting issue.
  36963. */
  36964. minZ: number;
  36965. /**
  36966. * Define the maximum distance the camera can see to.
  36967. * This is important to note that the depth buffer are not infinite and the further it end
  36968. * the more your scene might encounter depth fighting issue.
  36969. */
  36970. maxZ: number;
  36971. /**
  36972. * Define the default inertia of the camera.
  36973. * This helps giving a smooth feeling to the camera movement.
  36974. */
  36975. inertia: number;
  36976. /**
  36977. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  36978. */
  36979. mode: number;
  36980. /**
  36981. * Define whether the camera is intermediate.
  36982. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  36983. */
  36984. isIntermediate: boolean;
  36985. /**
  36986. * Define the viewport of the camera.
  36987. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  36988. */
  36989. viewport: Viewport;
  36990. /**
  36991. * Restricts the camera to viewing objects with the same layerMask.
  36992. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  36993. */
  36994. layerMask: number;
  36995. /**
  36996. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  36997. */
  36998. fovMode: number;
  36999. /**
  37000. * Rig mode of the camera.
  37001. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37002. * This is normally controlled byt the camera themselves as internal use.
  37003. */
  37004. cameraRigMode: number;
  37005. /**
  37006. * Defines the distance between both "eyes" in case of a RIG
  37007. */
  37008. interaxialDistance: number;
  37009. /**
  37010. * Defines if stereoscopic rendering is done side by side or over under.
  37011. */
  37012. isStereoscopicSideBySide: boolean;
  37013. /**
  37014. * 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
  37015. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37016. * else in the scene. (Eg. security camera)
  37017. *
  37018. * 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)
  37019. */
  37020. customRenderTargets: RenderTargetTexture[];
  37021. /**
  37022. * When set, the camera will render to this render target instead of the default canvas
  37023. *
  37024. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37025. */
  37026. outputRenderTarget: Nullable<RenderTargetTexture>;
  37027. /**
  37028. * Observable triggered when the camera view matrix has changed.
  37029. */
  37030. onViewMatrixChangedObservable: Observable<Camera>;
  37031. /**
  37032. * Observable triggered when the camera Projection matrix has changed.
  37033. */
  37034. onProjectionMatrixChangedObservable: Observable<Camera>;
  37035. /**
  37036. * Observable triggered when the inputs have been processed.
  37037. */
  37038. onAfterCheckInputsObservable: Observable<Camera>;
  37039. /**
  37040. * Observable triggered when reset has been called and applied to the camera.
  37041. */
  37042. onRestoreStateObservable: Observable<Camera>;
  37043. /**
  37044. * Is this camera a part of a rig system?
  37045. */
  37046. isRigCamera: boolean;
  37047. /**
  37048. * If isRigCamera set to true this will be set with the parent camera.
  37049. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37050. */
  37051. rigParent?: Camera;
  37052. /** @hidden */
  37053. _cameraRigParams: any;
  37054. /** @hidden */
  37055. _rigCameras: Camera[];
  37056. /** @hidden */
  37057. _rigPostProcess: Nullable<PostProcess>;
  37058. protected _webvrViewMatrix: Matrix;
  37059. /** @hidden */
  37060. _skipRendering: boolean;
  37061. /** @hidden */
  37062. _projectionMatrix: Matrix;
  37063. /** @hidden */
  37064. _postProcesses: Nullable<PostProcess>[];
  37065. /** @hidden */
  37066. _activeMeshes: SmartArray<AbstractMesh>;
  37067. protected _globalPosition: Vector3;
  37068. /** @hidden */
  37069. _computedViewMatrix: Matrix;
  37070. private _doNotComputeProjectionMatrix;
  37071. private _transformMatrix;
  37072. private _frustumPlanes;
  37073. private _refreshFrustumPlanes;
  37074. private _storedFov;
  37075. private _stateStored;
  37076. /**
  37077. * Instantiates a new camera object.
  37078. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37079. * @see https://doc.babylonjs.com/features/cameras
  37080. * @param name Defines the name of the camera in the scene
  37081. * @param position Defines the position of the camera
  37082. * @param scene Defines the scene the camera belongs too
  37083. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37084. */
  37085. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37086. /**
  37087. * Store current camera state (fov, position, etc..)
  37088. * @returns the camera
  37089. */
  37090. storeState(): Camera;
  37091. /**
  37092. * Restores the camera state values if it has been stored. You must call storeState() first
  37093. */
  37094. protected _restoreStateValues(): boolean;
  37095. /**
  37096. * Restored camera state. You must call storeState() first.
  37097. * @returns true if restored and false otherwise
  37098. */
  37099. restoreState(): boolean;
  37100. /**
  37101. * Gets the class name of the camera.
  37102. * @returns the class name
  37103. */
  37104. getClassName(): string;
  37105. /** @hidden */
  37106. readonly _isCamera: boolean;
  37107. /**
  37108. * Gets a string representation of the camera useful for debug purpose.
  37109. * @param fullDetails Defines that a more verboe level of logging is required
  37110. * @returns the string representation
  37111. */
  37112. toString(fullDetails?: boolean): string;
  37113. /**
  37114. * Gets the current world space position of the camera.
  37115. */
  37116. get globalPosition(): Vector3;
  37117. /**
  37118. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  37119. * @returns the active meshe list
  37120. */
  37121. getActiveMeshes(): SmartArray<AbstractMesh>;
  37122. /**
  37123. * Check whether a mesh is part of the current active mesh list of the camera
  37124. * @param mesh Defines the mesh to check
  37125. * @returns true if active, false otherwise
  37126. */
  37127. isActiveMesh(mesh: Mesh): boolean;
  37128. /**
  37129. * Is this camera ready to be used/rendered
  37130. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  37131. * @return true if the camera is ready
  37132. */
  37133. isReady(completeCheck?: boolean): boolean;
  37134. /** @hidden */
  37135. _initCache(): void;
  37136. /** @hidden */
  37137. _updateCache(ignoreParentClass?: boolean): void;
  37138. /** @hidden */
  37139. _isSynchronized(): boolean;
  37140. /** @hidden */
  37141. _isSynchronizedViewMatrix(): boolean;
  37142. /** @hidden */
  37143. _isSynchronizedProjectionMatrix(): boolean;
  37144. /**
  37145. * Attach the input controls to a specific dom element to get the input from.
  37146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37147. */
  37148. attachControl(noPreventDefault?: boolean): void;
  37149. /**
  37150. * Attach the input controls to a specific dom element to get the input from.
  37151. * @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
  37152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37153. * BACK COMPAT SIGNATURE ONLY.
  37154. */
  37155. attachControl(ignored: any, noPreventDefault?: boolean): void;
  37156. /**
  37157. * Detach the current controls from the specified dom element.
  37158. */
  37159. detachControl(): void;
  37160. /**
  37161. * Detach the current controls from the specified dom element.
  37162. * @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
  37163. */
  37164. detachControl(ignored: any): void;
  37165. /**
  37166. * Update the camera state according to the different inputs gathered during the frame.
  37167. */
  37168. update(): void;
  37169. /** @hidden */
  37170. _checkInputs(): void;
  37171. /** @hidden */
  37172. get rigCameras(): Camera[];
  37173. /**
  37174. * Gets the post process used by the rig cameras
  37175. */
  37176. get rigPostProcess(): Nullable<PostProcess>;
  37177. /**
  37178. * Internal, gets the first post proces.
  37179. * @returns the first post process to be run on this camera.
  37180. */
  37181. _getFirstPostProcess(): Nullable<PostProcess>;
  37182. private _cascadePostProcessesToRigCams;
  37183. /**
  37184. * Attach a post process to the camera.
  37185. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37186. * @param postProcess The post process to attach to the camera
  37187. * @param insertAt The position of the post process in case several of them are in use in the scene
  37188. * @returns the position the post process has been inserted at
  37189. */
  37190. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  37191. /**
  37192. * Detach a post process to the camera.
  37193. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37194. * @param postProcess The post process to detach from the camera
  37195. */
  37196. detachPostProcess(postProcess: PostProcess): void;
  37197. /**
  37198. * Gets the current world matrix of the camera
  37199. */
  37200. getWorldMatrix(): Matrix;
  37201. /** @hidden */
  37202. _getViewMatrix(): Matrix;
  37203. /**
  37204. * Gets the current view matrix of the camera.
  37205. * @param force forces the camera to recompute the matrix without looking at the cached state
  37206. * @returns the view matrix
  37207. */
  37208. getViewMatrix(force?: boolean): Matrix;
  37209. /**
  37210. * Freeze the projection matrix.
  37211. * It will prevent the cache check of the camera projection compute and can speed up perf
  37212. * if no parameter of the camera are meant to change
  37213. * @param projection Defines manually a projection if necessary
  37214. */
  37215. freezeProjectionMatrix(projection?: Matrix): void;
  37216. /**
  37217. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  37218. */
  37219. unfreezeProjectionMatrix(): void;
  37220. /**
  37221. * Gets the current projection matrix of the camera.
  37222. * @param force forces the camera to recompute the matrix without looking at the cached state
  37223. * @returns the projection matrix
  37224. */
  37225. getProjectionMatrix(force?: boolean): Matrix;
  37226. /**
  37227. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  37228. * @returns a Matrix
  37229. */
  37230. getTransformationMatrix(): Matrix;
  37231. private _updateFrustumPlanes;
  37232. /**
  37233. * Checks if a cullable object (mesh...) is in the camera frustum
  37234. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  37235. * @param target The object to check
  37236. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  37237. * @returns true if the object is in frustum otherwise false
  37238. */
  37239. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  37240. /**
  37241. * Checks if a cullable object (mesh...) is in the camera frustum
  37242. * Unlike isInFrustum this cheks the full bounding box
  37243. * @param target The object to check
  37244. * @returns true if the object is in frustum otherwise false
  37245. */
  37246. isCompletelyInFrustum(target: ICullable): boolean;
  37247. /**
  37248. * Gets a ray in the forward direction from the camera.
  37249. * @param length Defines the length of the ray to create
  37250. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37251. * @param origin Defines the start point of the ray which defaults to the camera position
  37252. * @returns the forward ray
  37253. */
  37254. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37255. /**
  37256. * Gets a ray in the forward direction from the camera.
  37257. * @param refRay the ray to (re)use when setting the values
  37258. * @param length Defines the length of the ray to create
  37259. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37260. * @param origin Defines the start point of the ray which defaults to the camera position
  37261. * @returns the forward ray
  37262. */
  37263. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37264. /**
  37265. * Releases resources associated with this node.
  37266. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37267. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37268. */
  37269. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37270. /** @hidden */
  37271. _isLeftCamera: boolean;
  37272. /**
  37273. * Gets the left camera of a rig setup in case of Rigged Camera
  37274. */
  37275. get isLeftCamera(): boolean;
  37276. /** @hidden */
  37277. _isRightCamera: boolean;
  37278. /**
  37279. * Gets the right camera of a rig setup in case of Rigged Camera
  37280. */
  37281. get isRightCamera(): boolean;
  37282. /**
  37283. * Gets the left camera of a rig setup in case of Rigged Camera
  37284. */
  37285. get leftCamera(): Nullable<FreeCamera>;
  37286. /**
  37287. * Gets the right camera of a rig setup in case of Rigged Camera
  37288. */
  37289. get rightCamera(): Nullable<FreeCamera>;
  37290. /**
  37291. * Gets the left camera target of a rig setup in case of Rigged Camera
  37292. * @returns the target position
  37293. */
  37294. getLeftTarget(): Nullable<Vector3>;
  37295. /**
  37296. * Gets the right camera target of a rig setup in case of Rigged Camera
  37297. * @returns the target position
  37298. */
  37299. getRightTarget(): Nullable<Vector3>;
  37300. /**
  37301. * @hidden
  37302. */
  37303. setCameraRigMode(mode: number, rigParams: any): void;
  37304. /** @hidden */
  37305. static _setStereoscopicRigMode(camera: Camera): void;
  37306. /** @hidden */
  37307. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  37308. /** @hidden */
  37309. static _setVRRigMode(camera: Camera, rigParams: any): void;
  37310. /** @hidden */
  37311. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  37312. /** @hidden */
  37313. _getVRProjectionMatrix(): Matrix;
  37314. protected _updateCameraRotationMatrix(): void;
  37315. protected _updateWebVRCameraRotationMatrix(): void;
  37316. /**
  37317. * This function MUST be overwritten by the different WebVR cameras available.
  37318. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37319. * @hidden
  37320. */
  37321. _getWebVRProjectionMatrix(): Matrix;
  37322. /**
  37323. * This function MUST be overwritten by the different WebVR cameras available.
  37324. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37325. * @hidden
  37326. */
  37327. _getWebVRViewMatrix(): Matrix;
  37328. /** @hidden */
  37329. setCameraRigParameter(name: string, value: any): void;
  37330. /**
  37331. * needs to be overridden by children so sub has required properties to be copied
  37332. * @hidden
  37333. */
  37334. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  37335. /**
  37336. * May need to be overridden by children
  37337. * @hidden
  37338. */
  37339. _updateRigCameras(): void;
  37340. /** @hidden */
  37341. _setupInputs(): void;
  37342. /**
  37343. * Serialiaze the camera setup to a json represention
  37344. * @returns the JSON representation
  37345. */
  37346. serialize(): any;
  37347. /**
  37348. * Clones the current camera.
  37349. * @param name The cloned camera name
  37350. * @returns the cloned camera
  37351. */
  37352. clone(name: string): Camera;
  37353. /**
  37354. * Gets the direction of the camera relative to a given local axis.
  37355. * @param localAxis Defines the reference axis to provide a relative direction.
  37356. * @return the direction
  37357. */
  37358. getDirection(localAxis: Vector3): Vector3;
  37359. /**
  37360. * Returns the current camera absolute rotation
  37361. */
  37362. get absoluteRotation(): Quaternion;
  37363. /**
  37364. * Gets the direction of the camera relative to a given local axis into a passed vector.
  37365. * @param localAxis Defines the reference axis to provide a relative direction.
  37366. * @param result Defines the vector to store the result in
  37367. */
  37368. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  37369. /**
  37370. * Gets a camera constructor for a given camera type
  37371. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  37372. * @param name The name of the camera the result will be able to instantiate
  37373. * @param scene The scene the result will construct the camera in
  37374. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  37375. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  37376. * @returns a factory method to construc the camera
  37377. */
  37378. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  37379. /**
  37380. * Compute the world matrix of the camera.
  37381. * @returns the camera world matrix
  37382. */
  37383. computeWorldMatrix(): Matrix;
  37384. /**
  37385. * Parse a JSON and creates the camera from the parsed information
  37386. * @param parsedCamera The JSON to parse
  37387. * @param scene The scene to instantiate the camera in
  37388. * @returns the newly constructed camera
  37389. */
  37390. static Parse(parsedCamera: any, scene: Scene): Camera;
  37391. }
  37392. }
  37393. declare module BABYLON {
  37394. /**
  37395. * PostProcessManager is used to manage one or more post processes or post process pipelines
  37396. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  37397. */
  37398. export class PostProcessManager {
  37399. private _scene;
  37400. private _indexBuffer;
  37401. private _vertexBuffers;
  37402. /**
  37403. * Creates a new instance PostProcess
  37404. * @param scene The scene that the post process is associated with.
  37405. */
  37406. constructor(scene: Scene);
  37407. private _prepareBuffers;
  37408. private _buildIndexBuffer;
  37409. /**
  37410. * Rebuilds the vertex buffers of the manager.
  37411. * @hidden
  37412. */
  37413. _rebuild(): void;
  37414. /**
  37415. * Prepares a frame to be run through a post process.
  37416. * @param sourceTexture The input texture to the post procesess. (default: null)
  37417. * @param postProcesses An array of post processes to be run. (default: null)
  37418. * @returns True if the post processes were able to be run.
  37419. * @hidden
  37420. */
  37421. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  37422. /**
  37423. * Manually render a set of post processes to a texture.
  37424. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  37425. * @param postProcesses An array of post processes to be run.
  37426. * @param targetTexture The target texture to render to.
  37427. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  37428. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  37429. * @param lodLevel defines which lod of the texture to render to
  37430. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  37431. */
  37432. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  37433. /**
  37434. * Finalize the result of the output of the postprocesses.
  37435. * @param doNotPresent If true the result will not be displayed to the screen.
  37436. * @param targetTexture The target texture to render to.
  37437. * @param faceIndex The index of the face to bind the target texture to.
  37438. * @param postProcesses The array of post processes to render.
  37439. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  37440. * @hidden
  37441. */
  37442. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  37443. /**
  37444. * Disposes of the post process manager.
  37445. */
  37446. dispose(): void;
  37447. }
  37448. }
  37449. declare module BABYLON {
  37450. /**
  37451. * This Helps creating a texture that will be created from a camera in your scene.
  37452. * It is basically a dynamic texture that could be used to create special effects for instance.
  37453. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  37454. */
  37455. export class RenderTargetTexture extends Texture {
  37456. /**
  37457. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  37458. */
  37459. static readonly REFRESHRATE_RENDER_ONCE: number;
  37460. /**
  37461. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  37462. */
  37463. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37464. /**
  37465. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  37466. * the central point of your effect and can save a lot of performances.
  37467. */
  37468. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37469. /**
  37470. * Use this predicate to dynamically define the list of mesh you want to render.
  37471. * If set, the renderList property will be overwritten.
  37472. */
  37473. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37474. private _renderList;
  37475. /**
  37476. * Use this list to define the list of mesh you want to render.
  37477. */
  37478. get renderList(): Nullable<Array<AbstractMesh>>;
  37479. set renderList(value: Nullable<Array<AbstractMesh>>);
  37480. /**
  37481. * Use this function to overload the renderList array at rendering time.
  37482. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  37483. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  37484. * the cube (if the RTT is a cube, else layerOrFace=0).
  37485. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  37486. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  37487. * hold dummy elements!
  37488. */
  37489. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  37490. private _hookArray;
  37491. /**
  37492. * Define if particles should be rendered in your texture.
  37493. */
  37494. renderParticles: boolean;
  37495. /**
  37496. * Define if sprites should be rendered in your texture.
  37497. */
  37498. renderSprites: boolean;
  37499. /**
  37500. * Define the camera used to render the texture.
  37501. */
  37502. activeCamera: Nullable<Camera>;
  37503. /**
  37504. * Override the mesh isReady function with your own one.
  37505. */
  37506. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  37507. /**
  37508. * Override the render function of the texture with your own one.
  37509. */
  37510. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37511. /**
  37512. * Define if camera post processes should be use while rendering the texture.
  37513. */
  37514. useCameraPostProcesses: boolean;
  37515. /**
  37516. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  37517. */
  37518. ignoreCameraViewport: boolean;
  37519. private _postProcessManager;
  37520. private _postProcesses;
  37521. private _resizeObserver;
  37522. /**
  37523. * An event triggered when the texture is unbind.
  37524. */
  37525. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37526. /**
  37527. * An event triggered when the texture is unbind.
  37528. */
  37529. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37530. private _onAfterUnbindObserver;
  37531. /**
  37532. * Set a after unbind callback in the texture.
  37533. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  37534. */
  37535. set onAfterUnbind(callback: () => void);
  37536. /**
  37537. * An event triggered before rendering the texture
  37538. */
  37539. onBeforeRenderObservable: Observable<number>;
  37540. private _onBeforeRenderObserver;
  37541. /**
  37542. * Set a before render callback in the texture.
  37543. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  37544. */
  37545. set onBeforeRender(callback: (faceIndex: number) => void);
  37546. /**
  37547. * An event triggered after rendering the texture
  37548. */
  37549. onAfterRenderObservable: Observable<number>;
  37550. private _onAfterRenderObserver;
  37551. /**
  37552. * Set a after render callback in the texture.
  37553. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  37554. */
  37555. set onAfterRender(callback: (faceIndex: number) => void);
  37556. /**
  37557. * An event triggered after the texture clear
  37558. */
  37559. onClearObservable: Observable<Engine>;
  37560. private _onClearObserver;
  37561. /**
  37562. * Set a clear callback in the texture.
  37563. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  37564. */
  37565. set onClear(callback: (Engine: Engine) => void);
  37566. /**
  37567. * An event triggered when the texture is resized.
  37568. */
  37569. onResizeObservable: Observable<RenderTargetTexture>;
  37570. /**
  37571. * Define the clear color of the Render Target if it should be different from the scene.
  37572. */
  37573. clearColor: Color4;
  37574. protected _size: number | {
  37575. width: number;
  37576. height: number;
  37577. layers?: number;
  37578. };
  37579. protected _initialSizeParameter: number | {
  37580. width: number;
  37581. height: number;
  37582. } | {
  37583. ratio: number;
  37584. };
  37585. protected _sizeRatio: Nullable<number>;
  37586. /** @hidden */
  37587. _generateMipMaps: boolean;
  37588. protected _renderingManager: RenderingManager;
  37589. /** @hidden */
  37590. _waitingRenderList?: string[];
  37591. protected _doNotChangeAspectRatio: boolean;
  37592. protected _currentRefreshId: number;
  37593. protected _refreshRate: number;
  37594. protected _textureMatrix: Matrix;
  37595. protected _samples: number;
  37596. protected _renderTargetOptions: RenderTargetCreationOptions;
  37597. /**
  37598. * Gets render target creation options that were used.
  37599. */
  37600. get renderTargetOptions(): RenderTargetCreationOptions;
  37601. protected _onRatioRescale(): void;
  37602. /**
  37603. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37604. * It must define where the camera used to render the texture is set
  37605. */
  37606. boundingBoxPosition: Vector3;
  37607. private _boundingBoxSize;
  37608. /**
  37609. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37610. * When defined, the cubemap will switch to local mode
  37611. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37612. * @example https://www.babylonjs-playground.com/#RNASML
  37613. */
  37614. set boundingBoxSize(value: Vector3);
  37615. get boundingBoxSize(): Vector3;
  37616. /**
  37617. * In case the RTT has been created with a depth texture, get the associated
  37618. * depth texture.
  37619. * Otherwise, return null.
  37620. */
  37621. get depthStencilTexture(): Nullable<InternalTexture>;
  37622. /**
  37623. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  37624. * or used a shadow, depth texture...
  37625. * @param name The friendly name of the texture
  37626. * @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)
  37627. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37628. * @param generateMipMaps True if mip maps need to be generated after render.
  37629. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37630. * @param type The type of the buffer in the RTT (int, half float, float...)
  37631. * @param isCube True if a cube texture needs to be created
  37632. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37633. * @param generateDepthBuffer True to generate a depth buffer
  37634. * @param generateStencilBuffer True to generate a stencil buffer
  37635. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37636. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37637. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37638. */
  37639. constructor(name: string, size: number | {
  37640. width: number;
  37641. height: number;
  37642. layers?: number;
  37643. } | {
  37644. ratio: number;
  37645. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  37646. /**
  37647. * Creates a depth stencil texture.
  37648. * This is only available in WebGL 2 or with the depth texture extension available.
  37649. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37650. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37651. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37652. */
  37653. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37654. private _processSizeParameter;
  37655. /**
  37656. * Define the number of samples to use in case of MSAA.
  37657. * It defaults to one meaning no MSAA has been enabled.
  37658. */
  37659. get samples(): number;
  37660. set samples(value: number);
  37661. /**
  37662. * Resets the refresh counter of the texture and start bak from scratch.
  37663. * Could be useful to regenerate the texture if it is setup to render only once.
  37664. */
  37665. resetRefreshCounter(): void;
  37666. /**
  37667. * Define the refresh rate of the texture or the rendering frequency.
  37668. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  37669. */
  37670. get refreshRate(): number;
  37671. set refreshRate(value: number);
  37672. /**
  37673. * Adds a post process to the render target rendering passes.
  37674. * @param postProcess define the post process to add
  37675. */
  37676. addPostProcess(postProcess: PostProcess): void;
  37677. /**
  37678. * Clear all the post processes attached to the render target
  37679. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  37680. */
  37681. clearPostProcesses(dispose?: boolean): void;
  37682. /**
  37683. * Remove one of the post process from the list of attached post processes to the texture
  37684. * @param postProcess define the post process to remove from the list
  37685. */
  37686. removePostProcess(postProcess: PostProcess): void;
  37687. /** @hidden */
  37688. _shouldRender(): boolean;
  37689. /**
  37690. * Gets the actual render size of the texture.
  37691. * @returns the width of the render size
  37692. */
  37693. getRenderSize(): number;
  37694. /**
  37695. * Gets the actual render width of the texture.
  37696. * @returns the width of the render size
  37697. */
  37698. getRenderWidth(): number;
  37699. /**
  37700. * Gets the actual render height of the texture.
  37701. * @returns the height of the render size
  37702. */
  37703. getRenderHeight(): number;
  37704. /**
  37705. * Gets the actual number of layers of the texture.
  37706. * @returns the number of layers
  37707. */
  37708. getRenderLayers(): number;
  37709. /**
  37710. * Get if the texture can be rescaled or not.
  37711. */
  37712. get canRescale(): boolean;
  37713. /**
  37714. * Resize the texture using a ratio.
  37715. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  37716. */
  37717. scale(ratio: number): void;
  37718. /**
  37719. * Get the texture reflection matrix used to rotate/transform the reflection.
  37720. * @returns the reflection matrix
  37721. */
  37722. getReflectionTextureMatrix(): Matrix;
  37723. /**
  37724. * Resize the texture to a new desired size.
  37725. * Be carrefull as it will recreate all the data in the new texture.
  37726. * @param size Define the new size. It can be:
  37727. * - a number for squared texture,
  37728. * - an object containing { width: number, height: number }
  37729. * - or an object containing a ratio { ratio: number }
  37730. */
  37731. resize(size: number | {
  37732. width: number;
  37733. height: number;
  37734. } | {
  37735. ratio: number;
  37736. }): void;
  37737. private _defaultRenderListPrepared;
  37738. /**
  37739. * Renders all the objects from the render list into the texture.
  37740. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  37741. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  37742. */
  37743. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37744. private _bestReflectionRenderTargetDimension;
  37745. private _prepareRenderingManager;
  37746. /**
  37747. * @hidden
  37748. * @param faceIndex face index to bind to if this is a cubetexture
  37749. * @param layer defines the index of the texture to bind in the array
  37750. */
  37751. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  37752. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37753. private renderToTarget;
  37754. /**
  37755. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37756. * This allowed control for front to back rendering or reversly depending of the special needs.
  37757. *
  37758. * @param renderingGroupId The rendering group id corresponding to its index
  37759. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37760. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37761. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37762. */
  37763. 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;
  37764. /**
  37765. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37766. *
  37767. * @param renderingGroupId The rendering group id corresponding to its index
  37768. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37769. */
  37770. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37771. /**
  37772. * Clones the texture.
  37773. * @returns the cloned texture
  37774. */
  37775. clone(): RenderTargetTexture;
  37776. /**
  37777. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  37778. * @returns The JSON representation of the texture
  37779. */
  37780. serialize(): any;
  37781. /**
  37782. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  37783. */
  37784. disposeFramebufferObjects(): void;
  37785. /**
  37786. * Dispose the texture and release its associated resources.
  37787. */
  37788. dispose(): void;
  37789. /** @hidden */
  37790. _rebuild(): void;
  37791. /**
  37792. * Clear the info related to rendering groups preventing retention point in material dispose.
  37793. */
  37794. freeRenderingGroups(): void;
  37795. /**
  37796. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  37797. * @returns the view count
  37798. */
  37799. getViewCount(): number;
  37800. }
  37801. }
  37802. declare module BABYLON {
  37803. /**
  37804. * Options to be used when creating an effect.
  37805. */
  37806. export interface IEffectCreationOptions {
  37807. /**
  37808. * Atrributes that will be used in the shader.
  37809. */
  37810. attributes: string[];
  37811. /**
  37812. * Uniform varible names that will be set in the shader.
  37813. */
  37814. uniformsNames: string[];
  37815. /**
  37816. * Uniform buffer variable names that will be set in the shader.
  37817. */
  37818. uniformBuffersNames: string[];
  37819. /**
  37820. * Sampler texture variable names that will be set in the shader.
  37821. */
  37822. samplers: string[];
  37823. /**
  37824. * Define statements that will be set in the shader.
  37825. */
  37826. defines: any;
  37827. /**
  37828. * Possible fallbacks for this effect to improve performance when needed.
  37829. */
  37830. fallbacks: Nullable<IEffectFallbacks>;
  37831. /**
  37832. * Callback that will be called when the shader is compiled.
  37833. */
  37834. onCompiled: Nullable<(effect: Effect) => void>;
  37835. /**
  37836. * Callback that will be called if an error occurs during shader compilation.
  37837. */
  37838. onError: Nullable<(effect: Effect, errors: string) => void>;
  37839. /**
  37840. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37841. */
  37842. indexParameters?: any;
  37843. /**
  37844. * Max number of lights that can be used in the shader.
  37845. */
  37846. maxSimultaneousLights?: number;
  37847. /**
  37848. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37849. */
  37850. transformFeedbackVaryings?: Nullable<string[]>;
  37851. /**
  37852. * 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
  37853. */
  37854. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37855. /**
  37856. * Is this effect rendering to several color attachments ?
  37857. */
  37858. multiTarget?: boolean;
  37859. }
  37860. /**
  37861. * Effect containing vertex and fragment shader that can be executed on an object.
  37862. */
  37863. export class Effect implements IDisposable {
  37864. /**
  37865. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37866. */
  37867. static ShadersRepository: string;
  37868. /**
  37869. * Enable logging of the shader code when a compilation error occurs
  37870. */
  37871. static LogShaderCodeOnCompilationError: boolean;
  37872. /**
  37873. * Name of the effect.
  37874. */
  37875. name: any;
  37876. /**
  37877. * String container all the define statements that should be set on the shader.
  37878. */
  37879. defines: string;
  37880. /**
  37881. * Callback that will be called when the shader is compiled.
  37882. */
  37883. onCompiled: Nullable<(effect: Effect) => void>;
  37884. /**
  37885. * Callback that will be called if an error occurs during shader compilation.
  37886. */
  37887. onError: Nullable<(effect: Effect, errors: string) => void>;
  37888. /**
  37889. * Callback that will be called when effect is bound.
  37890. */
  37891. onBind: Nullable<(effect: Effect) => void>;
  37892. /**
  37893. * Unique ID of the effect.
  37894. */
  37895. uniqueId: number;
  37896. /**
  37897. * Observable that will be called when the shader is compiled.
  37898. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37899. */
  37900. onCompileObservable: Observable<Effect>;
  37901. /**
  37902. * Observable that will be called if an error occurs during shader compilation.
  37903. */
  37904. onErrorObservable: Observable<Effect>;
  37905. /** @hidden */
  37906. _onBindObservable: Nullable<Observable<Effect>>;
  37907. /**
  37908. * @hidden
  37909. * Specifies if the effect was previously ready
  37910. */
  37911. _wasPreviouslyReady: boolean;
  37912. /**
  37913. * Observable that will be called when effect is bound.
  37914. */
  37915. get onBindObservable(): Observable<Effect>;
  37916. /** @hidden */
  37917. _bonesComputationForcedToCPU: boolean;
  37918. /** @hidden */
  37919. _multiTarget: boolean;
  37920. private static _uniqueIdSeed;
  37921. private _engine;
  37922. private _uniformBuffersNames;
  37923. private _uniformBuffersNamesList;
  37924. private _uniformsNames;
  37925. private _samplerList;
  37926. private _samplers;
  37927. private _isReady;
  37928. private _compilationError;
  37929. private _allFallbacksProcessed;
  37930. private _attributesNames;
  37931. private _attributes;
  37932. private _attributeLocationByName;
  37933. private _uniforms;
  37934. /**
  37935. * Key for the effect.
  37936. * @hidden
  37937. */
  37938. _key: string;
  37939. private _indexParameters;
  37940. private _fallbacks;
  37941. private _vertexSourceCode;
  37942. private _fragmentSourceCode;
  37943. private _vertexSourceCodeOverride;
  37944. private _fragmentSourceCodeOverride;
  37945. private _transformFeedbackVaryings;
  37946. private _rawVertexSourceCode;
  37947. private _rawFragmentSourceCode;
  37948. /**
  37949. * Compiled shader to webGL program.
  37950. * @hidden
  37951. */
  37952. _pipelineContext: Nullable<IPipelineContext>;
  37953. private _valueCache;
  37954. private static _baseCache;
  37955. /**
  37956. * Instantiates an effect.
  37957. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37958. * @param baseName Name of the effect.
  37959. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37960. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37961. * @param samplers List of sampler variables that will be passed to the shader.
  37962. * @param engine Engine to be used to render the effect
  37963. * @param defines Define statements to be added to the shader.
  37964. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37965. * @param onCompiled Callback that will be called when the shader is compiled.
  37966. * @param onError Callback that will be called if an error occurs during shader compilation.
  37967. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37968. */
  37969. 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);
  37970. private _useFinalCode;
  37971. /**
  37972. * Unique key for this effect
  37973. */
  37974. get key(): string;
  37975. /**
  37976. * If the effect has been compiled and prepared.
  37977. * @returns if the effect is compiled and prepared.
  37978. */
  37979. isReady(): boolean;
  37980. private _isReadyInternal;
  37981. /**
  37982. * The engine the effect was initialized with.
  37983. * @returns the engine.
  37984. */
  37985. getEngine(): Engine;
  37986. /**
  37987. * The pipeline context for this effect
  37988. * @returns the associated pipeline context
  37989. */
  37990. getPipelineContext(): Nullable<IPipelineContext>;
  37991. /**
  37992. * The set of names of attribute variables for the shader.
  37993. * @returns An array of attribute names.
  37994. */
  37995. getAttributesNames(): string[];
  37996. /**
  37997. * Returns the attribute at the given index.
  37998. * @param index The index of the attribute.
  37999. * @returns The location of the attribute.
  38000. */
  38001. getAttributeLocation(index: number): number;
  38002. /**
  38003. * Returns the attribute based on the name of the variable.
  38004. * @param name of the attribute to look up.
  38005. * @returns the attribute location.
  38006. */
  38007. getAttributeLocationByName(name: string): number;
  38008. /**
  38009. * The number of attributes.
  38010. * @returns the numnber of attributes.
  38011. */
  38012. getAttributesCount(): number;
  38013. /**
  38014. * Gets the index of a uniform variable.
  38015. * @param uniformName of the uniform to look up.
  38016. * @returns the index.
  38017. */
  38018. getUniformIndex(uniformName: string): number;
  38019. /**
  38020. * Returns the attribute based on the name of the variable.
  38021. * @param uniformName of the uniform to look up.
  38022. * @returns the location of the uniform.
  38023. */
  38024. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38025. /**
  38026. * Returns an array of sampler variable names
  38027. * @returns The array of sampler variable names.
  38028. */
  38029. getSamplers(): string[];
  38030. /**
  38031. * Returns an array of uniform variable names
  38032. * @returns The array of uniform variable names.
  38033. */
  38034. getUniformNames(): string[];
  38035. /**
  38036. * Returns an array of uniform buffer variable names
  38037. * @returns The array of uniform buffer variable names.
  38038. */
  38039. getUniformBuffersNames(): string[];
  38040. /**
  38041. * Returns the index parameters used to create the effect
  38042. * @returns The index parameters object
  38043. */
  38044. getIndexParameters(): any;
  38045. /**
  38046. * The error from the last compilation.
  38047. * @returns the error string.
  38048. */
  38049. getCompilationError(): string;
  38050. /**
  38051. * Gets a boolean indicating that all fallbacks were used during compilation
  38052. * @returns true if all fallbacks were used
  38053. */
  38054. allFallbacksProcessed(): boolean;
  38055. /**
  38056. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38057. * @param func The callback to be used.
  38058. */
  38059. executeWhenCompiled(func: (effect: Effect) => void): void;
  38060. private _checkIsReady;
  38061. private _loadShader;
  38062. /**
  38063. * Gets the vertex shader source code of this effect
  38064. */
  38065. get vertexSourceCode(): string;
  38066. /**
  38067. * Gets the fragment shader source code of this effect
  38068. */
  38069. get fragmentSourceCode(): string;
  38070. /**
  38071. * Gets the vertex shader source code before it has been processed by the preprocessor
  38072. */
  38073. get rawVertexSourceCode(): string;
  38074. /**
  38075. * Gets the fragment shader source code before it has been processed by the preprocessor
  38076. */
  38077. get rawFragmentSourceCode(): string;
  38078. /**
  38079. * Recompiles the webGL program
  38080. * @param vertexSourceCode The source code for the vertex shader.
  38081. * @param fragmentSourceCode The source code for the fragment shader.
  38082. * @param onCompiled Callback called when completed.
  38083. * @param onError Callback called on error.
  38084. * @hidden
  38085. */
  38086. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38087. /**
  38088. * Prepares the effect
  38089. * @hidden
  38090. */
  38091. _prepareEffect(): void;
  38092. private _getShaderCodeAndErrorLine;
  38093. private _processCompilationErrors;
  38094. /**
  38095. * Checks if the effect is supported. (Must be called after compilation)
  38096. */
  38097. get isSupported(): boolean;
  38098. /**
  38099. * Binds a texture to the engine to be used as output of the shader.
  38100. * @param channel Name of the output variable.
  38101. * @param texture Texture to bind.
  38102. * @hidden
  38103. */
  38104. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  38105. /**
  38106. * Sets a texture on the engine to be used in the shader.
  38107. * @param channel Name of the sampler variable.
  38108. * @param texture Texture to set.
  38109. */
  38110. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  38111. /**
  38112. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  38113. * @param channel Name of the sampler variable.
  38114. * @param texture Texture to set.
  38115. */
  38116. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  38117. /**
  38118. * Sets an array of textures on the engine to be used in the shader.
  38119. * @param channel Name of the variable.
  38120. * @param textures Textures to set.
  38121. */
  38122. setTextureArray(channel: string, textures: ThinTexture[]): void;
  38123. /**
  38124. * 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)
  38125. * @param channel Name of the sampler variable.
  38126. * @param postProcess Post process to get the input texture from.
  38127. */
  38128. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  38129. /**
  38130. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  38131. * 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)
  38132. * @param channel Name of the sampler variable.
  38133. * @param postProcess Post process to get the output texture from.
  38134. */
  38135. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38136. /** @hidden */
  38137. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38138. /** @hidden */
  38139. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38140. /** @hidden */
  38141. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38142. /** @hidden */
  38143. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38144. /**
  38145. * Binds a buffer to a uniform.
  38146. * @param buffer Buffer to bind.
  38147. * @param name Name of the uniform variable to bind to.
  38148. */
  38149. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38150. /**
  38151. * Binds block to a uniform.
  38152. * @param blockName Name of the block to bind.
  38153. * @param index Index to bind.
  38154. */
  38155. bindUniformBlock(blockName: string, index: number): void;
  38156. /**
  38157. * Sets an interger value on a uniform variable.
  38158. * @param uniformName Name of the variable.
  38159. * @param value Value to be set.
  38160. * @returns this effect.
  38161. */
  38162. setInt(uniformName: string, value: number): Effect;
  38163. /**
  38164. * Sets an int array on a uniform variable.
  38165. * @param uniformName Name of the variable.
  38166. * @param array array to be set.
  38167. * @returns this effect.
  38168. */
  38169. setIntArray(uniformName: string, array: Int32Array): Effect;
  38170. /**
  38171. * 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)
  38172. * @param uniformName Name of the variable.
  38173. * @param array array to be set.
  38174. * @returns this effect.
  38175. */
  38176. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38177. /**
  38178. * 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)
  38179. * @param uniformName Name of the variable.
  38180. * @param array array to be set.
  38181. * @returns this effect.
  38182. */
  38183. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38184. /**
  38185. * 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)
  38186. * @param uniformName Name of the variable.
  38187. * @param array array to be set.
  38188. * @returns this effect.
  38189. */
  38190. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38191. /**
  38192. * Sets an float array on a uniform variable.
  38193. * @param uniformName Name of the variable.
  38194. * @param array array to be set.
  38195. * @returns this effect.
  38196. */
  38197. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38198. /**
  38199. * 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)
  38200. * @param uniformName Name of the variable.
  38201. * @param array array to be set.
  38202. * @returns this effect.
  38203. */
  38204. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38205. /**
  38206. * 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)
  38207. * @param uniformName Name of the variable.
  38208. * @param array array to be set.
  38209. * @returns this effect.
  38210. */
  38211. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38212. /**
  38213. * 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)
  38214. * @param uniformName Name of the variable.
  38215. * @param array array to be set.
  38216. * @returns this effect.
  38217. */
  38218. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38219. /**
  38220. * Sets an array on a uniform variable.
  38221. * @param uniformName Name of the variable.
  38222. * @param array array to be set.
  38223. * @returns this effect.
  38224. */
  38225. setArray(uniformName: string, array: number[]): Effect;
  38226. /**
  38227. * 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)
  38228. * @param uniformName Name of the variable.
  38229. * @param array array to be set.
  38230. * @returns this effect.
  38231. */
  38232. setArray2(uniformName: string, array: number[]): Effect;
  38233. /**
  38234. * 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)
  38235. * @param uniformName Name of the variable.
  38236. * @param array array to be set.
  38237. * @returns this effect.
  38238. */
  38239. setArray3(uniformName: string, array: number[]): Effect;
  38240. /**
  38241. * 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)
  38242. * @param uniformName Name of the variable.
  38243. * @param array array to be set.
  38244. * @returns this effect.
  38245. */
  38246. setArray4(uniformName: string, array: number[]): Effect;
  38247. /**
  38248. * Sets matrices on a uniform variable.
  38249. * @param uniformName Name of the variable.
  38250. * @param matrices matrices to be set.
  38251. * @returns this effect.
  38252. */
  38253. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38254. /**
  38255. * Sets matrix on a uniform variable.
  38256. * @param uniformName Name of the variable.
  38257. * @param matrix matrix to be set.
  38258. * @returns this effect.
  38259. */
  38260. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38261. /**
  38262. * 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)
  38263. * @param uniformName Name of the variable.
  38264. * @param matrix matrix to be set.
  38265. * @returns this effect.
  38266. */
  38267. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38268. /**
  38269. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38270. * @param uniformName Name of the variable.
  38271. * @param matrix matrix to be set.
  38272. * @returns this effect.
  38273. */
  38274. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38275. /**
  38276. * Sets a float on a uniform variable.
  38277. * @param uniformName Name of the variable.
  38278. * @param value value to be set.
  38279. * @returns this effect.
  38280. */
  38281. setFloat(uniformName: string, value: number): Effect;
  38282. /**
  38283. * Sets a boolean on a uniform variable.
  38284. * @param uniformName Name of the variable.
  38285. * @param bool value to be set.
  38286. * @returns this effect.
  38287. */
  38288. setBool(uniformName: string, bool: boolean): Effect;
  38289. /**
  38290. * Sets a Vector2 on a uniform variable.
  38291. * @param uniformName Name of the variable.
  38292. * @param vector2 vector2 to be set.
  38293. * @returns this effect.
  38294. */
  38295. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38296. /**
  38297. * Sets a float2 on a uniform variable.
  38298. * @param uniformName Name of the variable.
  38299. * @param x First float in float2.
  38300. * @param y Second float in float2.
  38301. * @returns this effect.
  38302. */
  38303. setFloat2(uniformName: string, x: number, y: number): Effect;
  38304. /**
  38305. * Sets a Vector3 on a uniform variable.
  38306. * @param uniformName Name of the variable.
  38307. * @param vector3 Value to be set.
  38308. * @returns this effect.
  38309. */
  38310. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38311. /**
  38312. * Sets a float3 on a uniform variable.
  38313. * @param uniformName Name of the variable.
  38314. * @param x First float in float3.
  38315. * @param y Second float in float3.
  38316. * @param z Third float in float3.
  38317. * @returns this effect.
  38318. */
  38319. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38320. /**
  38321. * Sets a Vector4 on a uniform variable.
  38322. * @param uniformName Name of the variable.
  38323. * @param vector4 Value to be set.
  38324. * @returns this effect.
  38325. */
  38326. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38327. /**
  38328. * Sets a float4 on a uniform variable.
  38329. * @param uniformName Name of the variable.
  38330. * @param x First float in float4.
  38331. * @param y Second float in float4.
  38332. * @param z Third float in float4.
  38333. * @param w Fourth float in float4.
  38334. * @returns this effect.
  38335. */
  38336. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38337. /**
  38338. * Sets a Color3 on a uniform variable.
  38339. * @param uniformName Name of the variable.
  38340. * @param color3 Value to be set.
  38341. * @returns this effect.
  38342. */
  38343. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38344. /**
  38345. * Sets a Color4 on a uniform variable.
  38346. * @param uniformName Name of the variable.
  38347. * @param color3 Value to be set.
  38348. * @param alpha Alpha value to be set.
  38349. * @returns this effect.
  38350. */
  38351. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38352. /**
  38353. * Sets a Color4 on a uniform variable
  38354. * @param uniformName defines the name of the variable
  38355. * @param color4 defines the value to be set
  38356. * @returns this effect.
  38357. */
  38358. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38359. /** Release all associated resources */
  38360. dispose(): void;
  38361. /**
  38362. * This function will add a new shader to the shader store
  38363. * @param name the name of the shader
  38364. * @param pixelShader optional pixel shader content
  38365. * @param vertexShader optional vertex shader content
  38366. */
  38367. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38368. /**
  38369. * Store of each shader (The can be looked up using effect.key)
  38370. */
  38371. static ShadersStore: {
  38372. [key: string]: string;
  38373. };
  38374. /**
  38375. * Store of each included file for a shader (The can be looked up using effect.key)
  38376. */
  38377. static IncludesShadersStore: {
  38378. [key: string]: string;
  38379. };
  38380. /**
  38381. * Resets the cache of effects.
  38382. */
  38383. static ResetCache(): void;
  38384. }
  38385. }
  38386. declare module BABYLON {
  38387. /**
  38388. * Interface used to describe the capabilities of the engine relatively to the current browser
  38389. */
  38390. export interface EngineCapabilities {
  38391. /** Maximum textures units per fragment shader */
  38392. maxTexturesImageUnits: number;
  38393. /** Maximum texture units per vertex shader */
  38394. maxVertexTextureImageUnits: number;
  38395. /** Maximum textures units in the entire pipeline */
  38396. maxCombinedTexturesImageUnits: number;
  38397. /** Maximum texture size */
  38398. maxTextureSize: number;
  38399. /** Maximum texture samples */
  38400. maxSamples?: number;
  38401. /** Maximum cube texture size */
  38402. maxCubemapTextureSize: number;
  38403. /** Maximum render texture size */
  38404. maxRenderTextureSize: number;
  38405. /** Maximum number of vertex attributes */
  38406. maxVertexAttribs: number;
  38407. /** Maximum number of varyings */
  38408. maxVaryingVectors: number;
  38409. /** Maximum number of uniforms per vertex shader */
  38410. maxVertexUniformVectors: number;
  38411. /** Maximum number of uniforms per fragment shader */
  38412. maxFragmentUniformVectors: number;
  38413. /** Defines if standard derivates (dx/dy) are supported */
  38414. standardDerivatives: boolean;
  38415. /** Defines if s3tc texture compression is supported */
  38416. s3tc?: WEBGL_compressed_texture_s3tc;
  38417. /** Defines if pvrtc texture compression is supported */
  38418. pvrtc: any;
  38419. /** Defines if etc1 texture compression is supported */
  38420. etc1: any;
  38421. /** Defines if etc2 texture compression is supported */
  38422. etc2: any;
  38423. /** Defines if astc texture compression is supported */
  38424. astc: any;
  38425. /** Defines if bptc texture compression is supported */
  38426. bptc: any;
  38427. /** Defines if float textures are supported */
  38428. textureFloat: boolean;
  38429. /** Defines if vertex array objects are supported */
  38430. vertexArrayObject: boolean;
  38431. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38432. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38433. /** Gets the maximum level of anisotropy supported */
  38434. maxAnisotropy: number;
  38435. /** Defines if instancing is supported */
  38436. instancedArrays: boolean;
  38437. /** Defines if 32 bits indices are supported */
  38438. uintIndices: boolean;
  38439. /** Defines if high precision shaders are supported */
  38440. highPrecisionShaderSupported: boolean;
  38441. /** Defines if depth reading in the fragment shader is supported */
  38442. fragmentDepthSupported: boolean;
  38443. /** Defines if float texture linear filtering is supported*/
  38444. textureFloatLinearFiltering: boolean;
  38445. /** Defines if rendering to float textures is supported */
  38446. textureFloatRender: boolean;
  38447. /** Defines if half float textures are supported*/
  38448. textureHalfFloat: boolean;
  38449. /** Defines if half float texture linear filtering is supported*/
  38450. textureHalfFloatLinearFiltering: boolean;
  38451. /** Defines if rendering to half float textures is supported */
  38452. textureHalfFloatRender: boolean;
  38453. /** Defines if textureLOD shader command is supported */
  38454. textureLOD: boolean;
  38455. /** Defines if draw buffers extension is supported */
  38456. drawBuffersExtension: boolean;
  38457. /** Defines if depth textures are supported */
  38458. depthTextureExtension: boolean;
  38459. /** Defines if float color buffer are supported */
  38460. colorBufferFloat: boolean;
  38461. /** Gets disjoint timer query extension (null if not supported) */
  38462. timerQuery?: EXT_disjoint_timer_query;
  38463. /** Defines if timestamp can be used with timer query */
  38464. canUseTimestampForTimerQuery: boolean;
  38465. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38466. multiview?: any;
  38467. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38468. oculusMultiview?: any;
  38469. /** Function used to let the system compiles shaders in background */
  38470. parallelShaderCompile?: {
  38471. COMPLETION_STATUS_KHR: number;
  38472. };
  38473. /** Max number of texture samples for MSAA */
  38474. maxMSAASamples: number;
  38475. /** Defines if the blend min max extension is supported */
  38476. blendMinMax: boolean;
  38477. }
  38478. }
  38479. declare module BABYLON {
  38480. /**
  38481. * @hidden
  38482. **/
  38483. export class DepthCullingState {
  38484. private _isDepthTestDirty;
  38485. private _isDepthMaskDirty;
  38486. private _isDepthFuncDirty;
  38487. private _isCullFaceDirty;
  38488. private _isCullDirty;
  38489. private _isZOffsetDirty;
  38490. private _isFrontFaceDirty;
  38491. private _depthTest;
  38492. private _depthMask;
  38493. private _depthFunc;
  38494. private _cull;
  38495. private _cullFace;
  38496. private _zOffset;
  38497. private _frontFace;
  38498. /**
  38499. * Initializes the state.
  38500. */
  38501. constructor();
  38502. get isDirty(): boolean;
  38503. get zOffset(): number;
  38504. set zOffset(value: number);
  38505. get cullFace(): Nullable<number>;
  38506. set cullFace(value: Nullable<number>);
  38507. get cull(): Nullable<boolean>;
  38508. set cull(value: Nullable<boolean>);
  38509. get depthFunc(): Nullable<number>;
  38510. set depthFunc(value: Nullable<number>);
  38511. get depthMask(): boolean;
  38512. set depthMask(value: boolean);
  38513. get depthTest(): boolean;
  38514. set depthTest(value: boolean);
  38515. get frontFace(): Nullable<number>;
  38516. set frontFace(value: Nullable<number>);
  38517. reset(): void;
  38518. apply(gl: WebGLRenderingContext): void;
  38519. }
  38520. }
  38521. declare module BABYLON {
  38522. /**
  38523. * @hidden
  38524. **/
  38525. export class StencilState {
  38526. /** 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 */
  38527. static readonly ALWAYS: number;
  38528. /** Passed to stencilOperation to specify that stencil value must be kept */
  38529. static readonly KEEP: number;
  38530. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38531. static readonly REPLACE: number;
  38532. private _isStencilTestDirty;
  38533. private _isStencilMaskDirty;
  38534. private _isStencilFuncDirty;
  38535. private _isStencilOpDirty;
  38536. private _stencilTest;
  38537. private _stencilMask;
  38538. private _stencilFunc;
  38539. private _stencilFuncRef;
  38540. private _stencilFuncMask;
  38541. private _stencilOpStencilFail;
  38542. private _stencilOpDepthFail;
  38543. private _stencilOpStencilDepthPass;
  38544. get isDirty(): boolean;
  38545. get stencilFunc(): number;
  38546. set stencilFunc(value: number);
  38547. get stencilFuncRef(): number;
  38548. set stencilFuncRef(value: number);
  38549. get stencilFuncMask(): number;
  38550. set stencilFuncMask(value: number);
  38551. get stencilOpStencilFail(): number;
  38552. set stencilOpStencilFail(value: number);
  38553. get stencilOpDepthFail(): number;
  38554. set stencilOpDepthFail(value: number);
  38555. get stencilOpStencilDepthPass(): number;
  38556. set stencilOpStencilDepthPass(value: number);
  38557. get stencilMask(): number;
  38558. set stencilMask(value: number);
  38559. get stencilTest(): boolean;
  38560. set stencilTest(value: boolean);
  38561. constructor();
  38562. reset(): void;
  38563. apply(gl: WebGLRenderingContext): void;
  38564. }
  38565. }
  38566. declare module BABYLON {
  38567. /**
  38568. * @hidden
  38569. **/
  38570. export class AlphaState {
  38571. private _isAlphaBlendDirty;
  38572. private _isBlendFunctionParametersDirty;
  38573. private _isBlendEquationParametersDirty;
  38574. private _isBlendConstantsDirty;
  38575. private _alphaBlend;
  38576. private _blendFunctionParameters;
  38577. private _blendEquationParameters;
  38578. private _blendConstants;
  38579. /**
  38580. * Initializes the state.
  38581. */
  38582. constructor();
  38583. get isDirty(): boolean;
  38584. get alphaBlend(): boolean;
  38585. set alphaBlend(value: boolean);
  38586. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38587. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38588. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38589. reset(): void;
  38590. apply(gl: WebGLRenderingContext): void;
  38591. }
  38592. }
  38593. declare module BABYLON {
  38594. /** @hidden */
  38595. export class WebGLShaderProcessor implements IShaderProcessor {
  38596. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38597. }
  38598. }
  38599. declare module BABYLON {
  38600. /** @hidden */
  38601. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38602. attributeProcessor(attribute: string): string;
  38603. varyingProcessor(varying: string, isFragment: boolean): string;
  38604. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38605. }
  38606. }
  38607. declare module BABYLON {
  38608. /**
  38609. * Interface for attribute information associated with buffer instanciation
  38610. */
  38611. export interface InstancingAttributeInfo {
  38612. /**
  38613. * Name of the GLSL attribute
  38614. * if attribute index is not specified, this is used to retrieve the index from the effect
  38615. */
  38616. attributeName: string;
  38617. /**
  38618. * Index/offset of the attribute in the vertex shader
  38619. * if not specified, this will be computes from the name.
  38620. */
  38621. index?: number;
  38622. /**
  38623. * size of the attribute, 1, 2, 3 or 4
  38624. */
  38625. attributeSize: number;
  38626. /**
  38627. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38628. */
  38629. offset: number;
  38630. /**
  38631. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38632. * default to 1
  38633. */
  38634. divisor?: number;
  38635. /**
  38636. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38637. * default is FLOAT
  38638. */
  38639. attributeType?: number;
  38640. /**
  38641. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38642. */
  38643. normalized?: boolean;
  38644. }
  38645. }
  38646. declare module BABYLON {
  38647. interface ThinEngine {
  38648. /**
  38649. * Update a video texture
  38650. * @param texture defines the texture to update
  38651. * @param video defines the video element to use
  38652. * @param invertY defines if data must be stored with Y axis inverted
  38653. */
  38654. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38655. }
  38656. }
  38657. declare module BABYLON {
  38658. interface ThinEngine {
  38659. /**
  38660. * Creates a dynamic texture
  38661. * @param width defines the width of the texture
  38662. * @param height defines the height of the texture
  38663. * @param generateMipMaps defines if the engine should generate the mip levels
  38664. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38665. * @returns the dynamic texture inside an InternalTexture
  38666. */
  38667. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38668. /**
  38669. * Update the content of a dynamic texture
  38670. * @param texture defines the texture to update
  38671. * @param source defines the source containing the data
  38672. * @param invertY defines if data must be stored with Y axis inverted
  38673. * @param premulAlpha defines if alpha is stored as premultiplied
  38674. * @param format defines the format of the data
  38675. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38676. */
  38677. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38678. }
  38679. }
  38680. declare module BABYLON {
  38681. /**
  38682. * Settings for finer control over video usage
  38683. */
  38684. export interface VideoTextureSettings {
  38685. /**
  38686. * Applies `autoplay` to video, if specified
  38687. */
  38688. autoPlay?: boolean;
  38689. /**
  38690. * Applies `muted` to video, if specified
  38691. */
  38692. muted?: boolean;
  38693. /**
  38694. * Applies `loop` to video, if specified
  38695. */
  38696. loop?: boolean;
  38697. /**
  38698. * Automatically updates internal texture from video at every frame in the render loop
  38699. */
  38700. autoUpdateTexture: boolean;
  38701. /**
  38702. * Image src displayed during the video loading or until the user interacts with the video.
  38703. */
  38704. poster?: string;
  38705. }
  38706. /**
  38707. * If you want to display a video in your scene, this is the special texture for that.
  38708. * This special texture works similar to other textures, with the exception of a few parameters.
  38709. * @see https://doc.babylonjs.com/how_to/video_texture
  38710. */
  38711. export class VideoTexture extends Texture {
  38712. /**
  38713. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38714. */
  38715. readonly autoUpdateTexture: boolean;
  38716. /**
  38717. * The video instance used by the texture internally
  38718. */
  38719. readonly video: HTMLVideoElement;
  38720. private _onUserActionRequestedObservable;
  38721. /**
  38722. * Event triggerd when a dom action is required by the user to play the video.
  38723. * This happens due to recent changes in browser policies preventing video to auto start.
  38724. */
  38725. get onUserActionRequestedObservable(): Observable<Texture>;
  38726. private _generateMipMaps;
  38727. private _stillImageCaptured;
  38728. private _displayingPosterTexture;
  38729. private _settings;
  38730. private _createInternalTextureOnEvent;
  38731. private _frameId;
  38732. private _currentSrc;
  38733. /**
  38734. * Creates a video texture.
  38735. * If you want to display a video in your scene, this is the special texture for that.
  38736. * This special texture works similar to other textures, with the exception of a few parameters.
  38737. * @see https://doc.babylonjs.com/how_to/video_texture
  38738. * @param name optional name, will detect from video source, if not defined
  38739. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38740. * @param scene is obviously the current scene.
  38741. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38742. * @param invertY is false by default but can be used to invert video on Y axis
  38743. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38744. * @param settings allows finer control over video usage
  38745. */
  38746. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38747. private _getName;
  38748. private _getVideo;
  38749. private _createInternalTexture;
  38750. private reset;
  38751. /**
  38752. * @hidden Internal method to initiate `update`.
  38753. */
  38754. _rebuild(): void;
  38755. /**
  38756. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38757. */
  38758. update(): void;
  38759. /**
  38760. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38761. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38762. */
  38763. updateTexture(isVisible: boolean): void;
  38764. protected _updateInternalTexture: () => void;
  38765. /**
  38766. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38767. * @param url New url.
  38768. */
  38769. updateURL(url: string): void;
  38770. /**
  38771. * Clones the texture.
  38772. * @returns the cloned texture
  38773. */
  38774. clone(): VideoTexture;
  38775. /**
  38776. * Dispose the texture and release its associated resources.
  38777. */
  38778. dispose(): void;
  38779. /**
  38780. * Creates a video texture straight from a stream.
  38781. * @param scene Define the scene the texture should be created in
  38782. * @param stream Define the stream the texture should be created from
  38783. * @returns The created video texture as a promise
  38784. */
  38785. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38786. /**
  38787. * Creates a video texture straight from your WebCam video feed.
  38788. * @param scene Define the scene the texture should be created in
  38789. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38790. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38791. * @returns The created video texture as a promise
  38792. */
  38793. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38794. minWidth: number;
  38795. maxWidth: number;
  38796. minHeight: number;
  38797. maxHeight: number;
  38798. deviceId: string;
  38799. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38800. /**
  38801. * Creates a video texture straight from your WebCam video feed.
  38802. * @param scene Define the scene the texture should be created in
  38803. * @param onReady Define a callback to triggered once the texture will be ready
  38804. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38805. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38806. */
  38807. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38808. minWidth: number;
  38809. maxWidth: number;
  38810. minHeight: number;
  38811. maxHeight: number;
  38812. deviceId: string;
  38813. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38814. }
  38815. }
  38816. declare module BABYLON {
  38817. /**
  38818. * Defines the interface used by objects working like Scene
  38819. * @hidden
  38820. */
  38821. export interface ISceneLike {
  38822. _addPendingData(data: any): void;
  38823. _removePendingData(data: any): void;
  38824. offlineProvider: IOfflineProvider;
  38825. }
  38826. /**
  38827. * Information about the current host
  38828. */
  38829. export interface HostInformation {
  38830. /**
  38831. * Defines if the current host is a mobile
  38832. */
  38833. isMobile: boolean;
  38834. }
  38835. /** Interface defining initialization parameters for Engine class */
  38836. export interface EngineOptions extends WebGLContextAttributes {
  38837. /**
  38838. * Defines if the engine should no exceed a specified device ratio
  38839. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38840. */
  38841. limitDeviceRatio?: number;
  38842. /**
  38843. * Defines if webvr should be enabled automatically
  38844. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38845. */
  38846. autoEnableWebVR?: boolean;
  38847. /**
  38848. * Defines if webgl2 should be turned off even if supported
  38849. * @see https://doc.babylonjs.com/features/webgl2
  38850. */
  38851. disableWebGL2Support?: boolean;
  38852. /**
  38853. * Defines if webaudio should be initialized as well
  38854. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38855. */
  38856. audioEngine?: boolean;
  38857. /**
  38858. * Defines if animations should run using a deterministic lock step
  38859. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38860. */
  38861. deterministicLockstep?: boolean;
  38862. /** Defines the maximum steps to use with deterministic lock step mode */
  38863. lockstepMaxSteps?: number;
  38864. /** Defines the seconds between each deterministic lock step */
  38865. timeStep?: number;
  38866. /**
  38867. * Defines that engine should ignore context lost events
  38868. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38869. */
  38870. doNotHandleContextLost?: boolean;
  38871. /**
  38872. * Defines that engine should ignore modifying touch action attribute and style
  38873. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38874. */
  38875. doNotHandleTouchAction?: boolean;
  38876. /**
  38877. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38878. */
  38879. useHighPrecisionFloats?: boolean;
  38880. /**
  38881. * Make the canvas XR Compatible for XR sessions
  38882. */
  38883. xrCompatible?: boolean;
  38884. /**
  38885. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38886. */
  38887. useHighPrecisionMatrix?: boolean;
  38888. /**
  38889. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38890. */
  38891. failIfMajorPerformanceCaveat?: boolean;
  38892. }
  38893. /**
  38894. * The base engine class (root of all engines)
  38895. */
  38896. export class ThinEngine {
  38897. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38898. static ExceptionList: ({
  38899. key: string;
  38900. capture: string;
  38901. captureConstraint: number;
  38902. targets: string[];
  38903. } | {
  38904. key: string;
  38905. capture: null;
  38906. captureConstraint: null;
  38907. targets: string[];
  38908. })[];
  38909. /** @hidden */
  38910. static _TextureLoaders: IInternalTextureLoader[];
  38911. /**
  38912. * Returns the current npm package of the sdk
  38913. */
  38914. static get NpmPackage(): string;
  38915. /**
  38916. * Returns the current version of the framework
  38917. */
  38918. static get Version(): string;
  38919. /**
  38920. * Returns a string describing the current engine
  38921. */
  38922. get description(): string;
  38923. /**
  38924. * Gets or sets the epsilon value used by collision engine
  38925. */
  38926. static CollisionsEpsilon: number;
  38927. /**
  38928. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38929. */
  38930. static get ShadersRepository(): string;
  38931. static set ShadersRepository(value: string);
  38932. /** @hidden */
  38933. _shaderProcessor: IShaderProcessor;
  38934. /**
  38935. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38936. */
  38937. forcePOTTextures: boolean;
  38938. /**
  38939. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38940. */
  38941. isFullscreen: boolean;
  38942. /**
  38943. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38944. */
  38945. cullBackFaces: boolean;
  38946. /**
  38947. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38948. */
  38949. renderEvenInBackground: boolean;
  38950. /**
  38951. * Gets or sets a boolean indicating that cache can be kept between frames
  38952. */
  38953. preventCacheWipeBetweenFrames: boolean;
  38954. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38955. validateShaderPrograms: boolean;
  38956. /**
  38957. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38958. * This can provide greater z depth for distant objects.
  38959. */
  38960. useReverseDepthBuffer: boolean;
  38961. /**
  38962. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38963. */
  38964. disableUniformBuffers: boolean;
  38965. /** @hidden */
  38966. _uniformBuffers: UniformBuffer[];
  38967. /**
  38968. * Gets a boolean indicating that the engine supports uniform buffers
  38969. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38970. */
  38971. get supportsUniformBuffers(): boolean;
  38972. /** @hidden */
  38973. _gl: WebGLRenderingContext;
  38974. /** @hidden */
  38975. _webGLVersion: number;
  38976. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38977. protected _windowIsBackground: boolean;
  38978. protected _creationOptions: EngineOptions;
  38979. protected _highPrecisionShadersAllowed: boolean;
  38980. /** @hidden */
  38981. get _shouldUseHighPrecisionShader(): boolean;
  38982. /**
  38983. * Gets a boolean indicating that only power of 2 textures are supported
  38984. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38985. */
  38986. get needPOTTextures(): boolean;
  38987. /** @hidden */
  38988. _badOS: boolean;
  38989. /** @hidden */
  38990. _badDesktopOS: boolean;
  38991. private _hardwareScalingLevel;
  38992. /** @hidden */
  38993. _caps: EngineCapabilities;
  38994. private _isStencilEnable;
  38995. private _glVersion;
  38996. private _glRenderer;
  38997. private _glVendor;
  38998. /** @hidden */
  38999. _videoTextureSupported: boolean;
  39000. protected _renderingQueueLaunched: boolean;
  39001. protected _activeRenderLoops: (() => void)[];
  39002. /**
  39003. * Observable signaled when a context lost event is raised
  39004. */
  39005. onContextLostObservable: Observable<ThinEngine>;
  39006. /**
  39007. * Observable signaled when a context restored event is raised
  39008. */
  39009. onContextRestoredObservable: Observable<ThinEngine>;
  39010. private _onContextLost;
  39011. private _onContextRestored;
  39012. protected _contextWasLost: boolean;
  39013. /** @hidden */
  39014. _doNotHandleContextLost: boolean;
  39015. /**
  39016. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39017. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39018. */
  39019. get doNotHandleContextLost(): boolean;
  39020. set doNotHandleContextLost(value: boolean);
  39021. /**
  39022. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39023. */
  39024. disableVertexArrayObjects: boolean;
  39025. /** @hidden */
  39026. protected _colorWrite: boolean;
  39027. /** @hidden */
  39028. protected _colorWriteChanged: boolean;
  39029. /** @hidden */
  39030. protected _depthCullingState: DepthCullingState;
  39031. /** @hidden */
  39032. protected _stencilState: StencilState;
  39033. /** @hidden */
  39034. _alphaState: AlphaState;
  39035. /** @hidden */
  39036. _alphaMode: number;
  39037. /** @hidden */
  39038. _alphaEquation: number;
  39039. /** @hidden */
  39040. _internalTexturesCache: InternalTexture[];
  39041. /** @hidden */
  39042. protected _activeChannel: number;
  39043. private _currentTextureChannel;
  39044. /** @hidden */
  39045. protected _boundTexturesCache: {
  39046. [key: string]: Nullable<InternalTexture>;
  39047. };
  39048. /** @hidden */
  39049. protected _currentEffect: Nullable<Effect>;
  39050. /** @hidden */
  39051. protected _currentProgram: Nullable<WebGLProgram>;
  39052. private _compiledEffects;
  39053. private _vertexAttribArraysEnabled;
  39054. /** @hidden */
  39055. protected _cachedViewport: Nullable<IViewportLike>;
  39056. private _cachedVertexArrayObject;
  39057. /** @hidden */
  39058. protected _cachedVertexBuffers: any;
  39059. /** @hidden */
  39060. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  39061. /** @hidden */
  39062. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  39063. /** @hidden */
  39064. _currentRenderTarget: Nullable<InternalTexture>;
  39065. private _uintIndicesCurrentlySet;
  39066. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  39067. /** @hidden */
  39068. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  39069. /** @hidden */
  39070. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  39071. private _currentBufferPointers;
  39072. private _currentInstanceLocations;
  39073. private _currentInstanceBuffers;
  39074. private _textureUnits;
  39075. /** @hidden */
  39076. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39077. /** @hidden */
  39078. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39079. /** @hidden */
  39080. _boundRenderFunction: any;
  39081. private _vaoRecordInProgress;
  39082. private _mustWipeVertexAttributes;
  39083. private _emptyTexture;
  39084. private _emptyCubeTexture;
  39085. private _emptyTexture3D;
  39086. private _emptyTexture2DArray;
  39087. /** @hidden */
  39088. _frameHandler: number;
  39089. private _nextFreeTextureSlots;
  39090. private _maxSimultaneousTextures;
  39091. private _activeRequests;
  39092. /** @hidden */
  39093. _transformTextureUrl: Nullable<(url: string) => string>;
  39094. /**
  39095. * Gets information about the current host
  39096. */
  39097. hostInformation: HostInformation;
  39098. protected get _supportsHardwareTextureRescaling(): boolean;
  39099. private _framebufferDimensionsObject;
  39100. /**
  39101. * sets the object from which width and height will be taken from when getting render width and height
  39102. * Will fallback to the gl object
  39103. * @param dimensions the framebuffer width and height that will be used.
  39104. */
  39105. set framebufferDimensionsObject(dimensions: Nullable<{
  39106. framebufferWidth: number;
  39107. framebufferHeight: number;
  39108. }>);
  39109. /**
  39110. * Gets the current viewport
  39111. */
  39112. get currentViewport(): Nullable<IViewportLike>;
  39113. /**
  39114. * Gets the default empty texture
  39115. */
  39116. get emptyTexture(): InternalTexture;
  39117. /**
  39118. * Gets the default empty 3D texture
  39119. */
  39120. get emptyTexture3D(): InternalTexture;
  39121. /**
  39122. * Gets the default empty 2D array texture
  39123. */
  39124. get emptyTexture2DArray(): InternalTexture;
  39125. /**
  39126. * Gets the default empty cube texture
  39127. */
  39128. get emptyCubeTexture(): InternalTexture;
  39129. /**
  39130. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  39131. */
  39132. readonly premultipliedAlpha: boolean;
  39133. /**
  39134. * Observable event triggered before each texture is initialized
  39135. */
  39136. onBeforeTextureInitObservable: Observable<Texture>;
  39137. /**
  39138. * Creates a new engine
  39139. * @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
  39140. * @param antialias defines enable antialiasing (default: false)
  39141. * @param options defines further options to be sent to the getContext() function
  39142. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39143. */
  39144. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39145. private _rebuildInternalTextures;
  39146. private _rebuildEffects;
  39147. /**
  39148. * Gets a boolean indicating if all created effects are ready
  39149. * @returns true if all effects are ready
  39150. */
  39151. areAllEffectsReady(): boolean;
  39152. protected _rebuildBuffers(): void;
  39153. protected _initGLContext(): void;
  39154. /**
  39155. * Gets version of the current webGL context
  39156. */
  39157. get webGLVersion(): number;
  39158. /**
  39159. * Gets a string identifying the name of the class
  39160. * @returns "Engine" string
  39161. */
  39162. getClassName(): string;
  39163. /**
  39164. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39165. */
  39166. get isStencilEnable(): boolean;
  39167. /** @hidden */
  39168. _prepareWorkingCanvas(): void;
  39169. /**
  39170. * Reset the texture cache to empty state
  39171. */
  39172. resetTextureCache(): void;
  39173. /**
  39174. * Gets an object containing information about the current webGL context
  39175. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39176. */
  39177. getGlInfo(): {
  39178. vendor: string;
  39179. renderer: string;
  39180. version: string;
  39181. };
  39182. /**
  39183. * Defines the hardware scaling level.
  39184. * By default the hardware scaling level is computed from the window device ratio.
  39185. * 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.
  39186. * @param level defines the level to use
  39187. */
  39188. setHardwareScalingLevel(level: number): void;
  39189. /**
  39190. * Gets the current hardware scaling level.
  39191. * By default the hardware scaling level is computed from the window device ratio.
  39192. * 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.
  39193. * @returns a number indicating the current hardware scaling level
  39194. */
  39195. getHardwareScalingLevel(): number;
  39196. /**
  39197. * Gets the list of loaded textures
  39198. * @returns an array containing all loaded textures
  39199. */
  39200. getLoadedTexturesCache(): InternalTexture[];
  39201. /**
  39202. * Gets the object containing all engine capabilities
  39203. * @returns the EngineCapabilities object
  39204. */
  39205. getCaps(): EngineCapabilities;
  39206. /**
  39207. * stop executing a render loop function and remove it from the execution array
  39208. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39209. */
  39210. stopRenderLoop(renderFunction?: () => void): void;
  39211. /** @hidden */
  39212. _renderLoop(): void;
  39213. /**
  39214. * Gets the HTML canvas attached with the current webGL context
  39215. * @returns a HTML canvas
  39216. */
  39217. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39218. /**
  39219. * Gets host window
  39220. * @returns the host window object
  39221. */
  39222. getHostWindow(): Nullable<Window>;
  39223. /**
  39224. * Gets the current render width
  39225. * @param useScreen defines if screen size must be used (or the current render target if any)
  39226. * @returns a number defining the current render width
  39227. */
  39228. getRenderWidth(useScreen?: boolean): number;
  39229. /**
  39230. * Gets the current render height
  39231. * @param useScreen defines if screen size must be used (or the current render target if any)
  39232. * @returns a number defining the current render height
  39233. */
  39234. getRenderHeight(useScreen?: boolean): number;
  39235. /**
  39236. * Can be used to override the current requestAnimationFrame requester.
  39237. * @hidden
  39238. */
  39239. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39240. /**
  39241. * Register and execute a render loop. The engine can have more than one render function
  39242. * @param renderFunction defines the function to continuously execute
  39243. */
  39244. runRenderLoop(renderFunction: () => void): void;
  39245. /**
  39246. * Clear the current render buffer or the current render target (if any is set up)
  39247. * @param color defines the color to use
  39248. * @param backBuffer defines if the back buffer must be cleared
  39249. * @param depth defines if the depth buffer must be cleared
  39250. * @param stencil defines if the stencil buffer must be cleared
  39251. */
  39252. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39253. private _viewportCached;
  39254. /** @hidden */
  39255. _viewport(x: number, y: number, width: number, height: number): void;
  39256. /**
  39257. * Set the WebGL's viewport
  39258. * @param viewport defines the viewport element to be used
  39259. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39260. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39261. */
  39262. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39263. /**
  39264. * Begin a new frame
  39265. */
  39266. beginFrame(): void;
  39267. /**
  39268. * Enf the current frame
  39269. */
  39270. endFrame(): void;
  39271. /**
  39272. * Resize the view according to the canvas' size
  39273. */
  39274. resize(): void;
  39275. /**
  39276. * Force a specific size of the canvas
  39277. * @param width defines the new canvas' width
  39278. * @param height defines the new canvas' height
  39279. * @returns true if the size was changed
  39280. */
  39281. setSize(width: number, height: number): boolean;
  39282. /**
  39283. * Binds the frame buffer to the specified texture.
  39284. * @param texture The texture to render to or null for the default canvas
  39285. * @param faceIndex The face of the texture to render to in case of cube texture
  39286. * @param requiredWidth The width of the target to render to
  39287. * @param requiredHeight The height of the target to render to
  39288. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39289. * @param lodLevel defines the lod level to bind to the frame buffer
  39290. * @param layer defines the 2d array index to bind to frame buffer to
  39291. */
  39292. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39293. /** @hidden */
  39294. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39295. /**
  39296. * Unbind the current render target texture from the webGL context
  39297. * @param texture defines the render target texture to unbind
  39298. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39299. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39300. */
  39301. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39302. /**
  39303. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39304. */
  39305. flushFramebuffer(): void;
  39306. /**
  39307. * Unbind the current render target and bind the default framebuffer
  39308. */
  39309. restoreDefaultFramebuffer(): void;
  39310. /** @hidden */
  39311. protected _resetVertexBufferBinding(): void;
  39312. /**
  39313. * Creates a vertex buffer
  39314. * @param data the data for the vertex buffer
  39315. * @returns the new WebGL static buffer
  39316. */
  39317. createVertexBuffer(data: DataArray): DataBuffer;
  39318. private _createVertexBuffer;
  39319. /**
  39320. * Creates a dynamic vertex buffer
  39321. * @param data the data for the dynamic vertex buffer
  39322. * @returns the new WebGL dynamic buffer
  39323. */
  39324. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39325. protected _resetIndexBufferBinding(): void;
  39326. /**
  39327. * Creates a new index buffer
  39328. * @param indices defines the content of the index buffer
  39329. * @param updatable defines if the index buffer must be updatable
  39330. * @returns a new webGL buffer
  39331. */
  39332. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39333. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39334. /**
  39335. * Bind a webGL buffer to the webGL context
  39336. * @param buffer defines the buffer to bind
  39337. */
  39338. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39339. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39340. private bindBuffer;
  39341. /**
  39342. * update the bound buffer with the given data
  39343. * @param data defines the data to update
  39344. */
  39345. updateArrayBuffer(data: Float32Array): void;
  39346. private _vertexAttribPointer;
  39347. /** @hidden */
  39348. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39349. private _bindVertexBuffersAttributes;
  39350. /**
  39351. * Records a vertex array object
  39352. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39353. * @param vertexBuffers defines the list of vertex buffers to store
  39354. * @param indexBuffer defines the index buffer to store
  39355. * @param effect defines the effect to store
  39356. * @returns the new vertex array object
  39357. */
  39358. recordVertexArrayObject(vertexBuffers: {
  39359. [key: string]: VertexBuffer;
  39360. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39361. /**
  39362. * Bind a specific vertex array object
  39363. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39364. * @param vertexArrayObject defines the vertex array object to bind
  39365. * @param indexBuffer defines the index buffer to bind
  39366. */
  39367. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39368. /**
  39369. * Bind webGl buffers directly to the webGL context
  39370. * @param vertexBuffer defines the vertex buffer to bind
  39371. * @param indexBuffer defines the index buffer to bind
  39372. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39373. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39374. * @param effect defines the effect associated with the vertex buffer
  39375. */
  39376. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39377. private _unbindVertexArrayObject;
  39378. /**
  39379. * Bind a list of vertex buffers to the webGL context
  39380. * @param vertexBuffers defines the list of vertex buffers to bind
  39381. * @param indexBuffer defines the index buffer to bind
  39382. * @param effect defines the effect associated with the vertex buffers
  39383. */
  39384. bindBuffers(vertexBuffers: {
  39385. [key: string]: Nullable<VertexBuffer>;
  39386. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39387. /**
  39388. * Unbind all instance attributes
  39389. */
  39390. unbindInstanceAttributes(): void;
  39391. /**
  39392. * Release and free the memory of a vertex array object
  39393. * @param vao defines the vertex array object to delete
  39394. */
  39395. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39396. /** @hidden */
  39397. _releaseBuffer(buffer: DataBuffer): boolean;
  39398. protected _deleteBuffer(buffer: DataBuffer): void;
  39399. /**
  39400. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39401. * @param instancesBuffer defines the webGL buffer to update and bind
  39402. * @param data defines the data to store in the buffer
  39403. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39404. */
  39405. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39406. /**
  39407. * Bind the content of a webGL buffer used with instantiation
  39408. * @param instancesBuffer defines the webGL buffer to bind
  39409. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39410. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39411. */
  39412. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39413. /**
  39414. * Disable the instance attribute corresponding to the name in parameter
  39415. * @param name defines the name of the attribute to disable
  39416. */
  39417. disableInstanceAttributeByName(name: string): void;
  39418. /**
  39419. * Disable the instance attribute corresponding to the location in parameter
  39420. * @param attributeLocation defines the attribute location of the attribute to disable
  39421. */
  39422. disableInstanceAttribute(attributeLocation: number): void;
  39423. /**
  39424. * Disable the attribute corresponding to the location in parameter
  39425. * @param attributeLocation defines the attribute location of the attribute to disable
  39426. */
  39427. disableAttributeByIndex(attributeLocation: number): void;
  39428. /**
  39429. * Send a draw order
  39430. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39431. * @param indexStart defines the starting index
  39432. * @param indexCount defines the number of index to draw
  39433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39434. */
  39435. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39436. /**
  39437. * Draw a list of points
  39438. * @param verticesStart defines the index of first vertex to draw
  39439. * @param verticesCount defines the count of vertices to draw
  39440. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39441. */
  39442. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39443. /**
  39444. * Draw a list of unindexed primitives
  39445. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39446. * @param verticesStart defines the index of first vertex to draw
  39447. * @param verticesCount defines the count of vertices to draw
  39448. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39449. */
  39450. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39451. /**
  39452. * Draw a list of indexed primitives
  39453. * @param fillMode defines the primitive to use
  39454. * @param indexStart defines the starting index
  39455. * @param indexCount defines the number of index to draw
  39456. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39457. */
  39458. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39459. /**
  39460. * Draw a list of unindexed primitives
  39461. * @param fillMode defines the primitive to use
  39462. * @param verticesStart defines the index of first vertex to draw
  39463. * @param verticesCount defines the count of vertices to draw
  39464. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39465. */
  39466. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39467. private _drawMode;
  39468. /** @hidden */
  39469. protected _reportDrawCall(): void;
  39470. /** @hidden */
  39471. _releaseEffect(effect: Effect): void;
  39472. /** @hidden */
  39473. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39474. /**
  39475. * Create a new effect (used to store vertex/fragment shaders)
  39476. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39477. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39478. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39479. * @param samplers defines an array of string used to represent textures
  39480. * @param defines defines the string containing the defines to use to compile the shaders
  39481. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39482. * @param onCompiled defines a function to call when the effect creation is successful
  39483. * @param onError defines a function to call when the effect creation has failed
  39484. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39485. * @returns the new Effect
  39486. */
  39487. 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;
  39488. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39489. private _compileShader;
  39490. private _compileRawShader;
  39491. /** @hidden */
  39492. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39493. /**
  39494. * Directly creates a webGL program
  39495. * @param pipelineContext defines the pipeline context to attach to
  39496. * @param vertexCode defines the vertex shader code to use
  39497. * @param fragmentCode defines the fragment shader code to use
  39498. * @param context defines the webGL context to use (if not set, the current one will be used)
  39499. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39500. * @returns the new webGL program
  39501. */
  39502. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39503. /**
  39504. * Creates a webGL program
  39505. * @param pipelineContext defines the pipeline context to attach to
  39506. * @param vertexCode defines the vertex shader code to use
  39507. * @param fragmentCode defines the fragment shader code to use
  39508. * @param defines defines the string containing the defines to use to compile the shaders
  39509. * @param context defines the webGL context to use (if not set, the current one will be used)
  39510. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39511. * @returns the new webGL program
  39512. */
  39513. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39514. /**
  39515. * Creates a new pipeline context
  39516. * @returns the new pipeline
  39517. */
  39518. createPipelineContext(): IPipelineContext;
  39519. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39520. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39521. /** @hidden */
  39522. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39523. /** @hidden */
  39524. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39525. /** @hidden */
  39526. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39527. /**
  39528. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39529. * @param pipelineContext defines the pipeline context to use
  39530. * @param uniformsNames defines the list of uniform names
  39531. * @returns an array of webGL uniform locations
  39532. */
  39533. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39534. /**
  39535. * Gets the lsit of active attributes for a given webGL program
  39536. * @param pipelineContext defines the pipeline context to use
  39537. * @param attributesNames defines the list of attribute names to get
  39538. * @returns an array of indices indicating the offset of each attribute
  39539. */
  39540. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39541. /**
  39542. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39543. * @param effect defines the effect to activate
  39544. */
  39545. enableEffect(effect: Nullable<Effect>): void;
  39546. /**
  39547. * Set the value of an uniform to a number (int)
  39548. * @param uniform defines the webGL uniform location where to store the value
  39549. * @param value defines the int number to store
  39550. * @returns true if the value was set
  39551. */
  39552. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39553. /**
  39554. * Set the value of an uniform to an array of int32
  39555. * @param uniform defines the webGL uniform location where to store the value
  39556. * @param array defines the array of int32 to store
  39557. * @returns true if the value was set
  39558. */
  39559. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39560. /**
  39561. * Set the value of an uniform to an array of int32 (stored as vec2)
  39562. * @param uniform defines the webGL uniform location where to store the value
  39563. * @param array defines the array of int32 to store
  39564. * @returns true if the value was set
  39565. */
  39566. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39567. /**
  39568. * Set the value of an uniform to an array of int32 (stored as vec3)
  39569. * @param uniform defines the webGL uniform location where to store the value
  39570. * @param array defines the array of int32 to store
  39571. * @returns true if the value was set
  39572. */
  39573. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39574. /**
  39575. * Set the value of an uniform to an array of int32 (stored as vec4)
  39576. * @param uniform defines the webGL uniform location where to store the value
  39577. * @param array defines the array of int32 to store
  39578. * @returns true if the value was set
  39579. */
  39580. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39581. /**
  39582. * Set the value of an uniform to an array of number
  39583. * @param uniform defines the webGL uniform location where to store the value
  39584. * @param array defines the array of number to store
  39585. * @returns true if the value was set
  39586. */
  39587. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39588. /**
  39589. * Set the value of an uniform to an array of number (stored as vec2)
  39590. * @param uniform defines the webGL uniform location where to store the value
  39591. * @param array defines the array of number to store
  39592. * @returns true if the value was set
  39593. */
  39594. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39595. /**
  39596. * Set the value of an uniform to an array of number (stored as vec3)
  39597. * @param uniform defines the webGL uniform location where to store the value
  39598. * @param array defines the array of number to store
  39599. * @returns true if the value was set
  39600. */
  39601. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39602. /**
  39603. * Set the value of an uniform to an array of number (stored as vec4)
  39604. * @param uniform defines the webGL uniform location where to store the value
  39605. * @param array defines the array of number to store
  39606. * @returns true if the value was set
  39607. */
  39608. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39609. /**
  39610. * Set the value of an uniform to an array of float32 (stored as matrices)
  39611. * @param uniform defines the webGL uniform location where to store the value
  39612. * @param matrices defines the array of float32 to store
  39613. * @returns true if the value was set
  39614. */
  39615. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39616. /**
  39617. * Set the value of an uniform to a matrix (3x3)
  39618. * @param uniform defines the webGL uniform location where to store the value
  39619. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39620. * @returns true if the value was set
  39621. */
  39622. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39623. /**
  39624. * Set the value of an uniform to a matrix (2x2)
  39625. * @param uniform defines the webGL uniform location where to store the value
  39626. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39627. * @returns true if the value was set
  39628. */
  39629. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39630. /**
  39631. * Set the value of an uniform to a number (float)
  39632. * @param uniform defines the webGL uniform location where to store the value
  39633. * @param value defines the float number to store
  39634. * @returns true if the value was transfered
  39635. */
  39636. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39637. /**
  39638. * Set the value of an uniform to a vec2
  39639. * @param uniform defines the webGL uniform location where to store the value
  39640. * @param x defines the 1st component of the value
  39641. * @param y defines the 2nd component of the value
  39642. * @returns true if the value was set
  39643. */
  39644. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39645. /**
  39646. * Set the value of an uniform to a vec3
  39647. * @param uniform defines the webGL uniform location where to store the value
  39648. * @param x defines the 1st component of the value
  39649. * @param y defines the 2nd component of the value
  39650. * @param z defines the 3rd component of the value
  39651. * @returns true if the value was set
  39652. */
  39653. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39654. /**
  39655. * Set the value of an uniform to a vec4
  39656. * @param uniform defines the webGL uniform location where to store the value
  39657. * @param x defines the 1st component of the value
  39658. * @param y defines the 2nd component of the value
  39659. * @param z defines the 3rd component of the value
  39660. * @param w defines the 4th component of the value
  39661. * @returns true if the value was set
  39662. */
  39663. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39664. /**
  39665. * Apply all cached states (depth, culling, stencil and alpha)
  39666. */
  39667. applyStates(): void;
  39668. /**
  39669. * Enable or disable color writing
  39670. * @param enable defines the state to set
  39671. */
  39672. setColorWrite(enable: boolean): void;
  39673. /**
  39674. * Gets a boolean indicating if color writing is enabled
  39675. * @returns the current color writing state
  39676. */
  39677. getColorWrite(): boolean;
  39678. /**
  39679. * Gets the depth culling state manager
  39680. */
  39681. get depthCullingState(): DepthCullingState;
  39682. /**
  39683. * Gets the alpha state manager
  39684. */
  39685. get alphaState(): AlphaState;
  39686. /**
  39687. * Gets the stencil state manager
  39688. */
  39689. get stencilState(): StencilState;
  39690. /**
  39691. * Clears the list of texture accessible through engine.
  39692. * This can help preventing texture load conflict due to name collision.
  39693. */
  39694. clearInternalTexturesCache(): void;
  39695. /**
  39696. * Force the entire cache to be cleared
  39697. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39698. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39699. */
  39700. wipeCaches(bruteForce?: boolean): void;
  39701. /** @hidden */
  39702. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39703. min: number;
  39704. mag: number;
  39705. };
  39706. /** @hidden */
  39707. _createTexture(): WebGLTexture;
  39708. /**
  39709. * Usually called from Texture.ts.
  39710. * Passed information to create a WebGLTexture
  39711. * @param url defines a value which contains one of the following:
  39712. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39713. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39714. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39715. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39716. * @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)
  39717. * @param scene needed for loading to the correct scene
  39718. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39719. * @param onLoad optional callback to be called upon successful completion
  39720. * @param onError optional callback to be called upon failure
  39721. * @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
  39722. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39723. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39724. * @param forcedExtension defines the extension to use to pick the right loader
  39725. * @param mimeType defines an optional mime type
  39726. * @param loaderOptions options to be passed to the loader
  39727. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39728. */
  39729. 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;
  39730. /**
  39731. * Loads an image as an HTMLImageElement.
  39732. * @param input url string, ArrayBuffer, or Blob to load
  39733. * @param onLoad callback called when the image successfully loads
  39734. * @param onError callback called when the image fails to load
  39735. * @param offlineProvider offline provider for caching
  39736. * @param mimeType optional mime type
  39737. * @returns the HTMLImageElement of the loaded image
  39738. * @hidden
  39739. */
  39740. 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>;
  39741. /**
  39742. * @hidden
  39743. */
  39744. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39745. private _unpackFlipYCached;
  39746. /**
  39747. * In case you are sharing the context with other applications, it might
  39748. * be interested to not cache the unpack flip y state to ensure a consistent
  39749. * value would be set.
  39750. */
  39751. enableUnpackFlipYCached: boolean;
  39752. /** @hidden */
  39753. _unpackFlipY(value: boolean): void;
  39754. /** @hidden */
  39755. _getUnpackAlignement(): number;
  39756. private _getTextureTarget;
  39757. /**
  39758. * Update the sampling mode of a given texture
  39759. * @param samplingMode defines the required sampling mode
  39760. * @param texture defines the texture to update
  39761. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39762. */
  39763. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39764. /**
  39765. * Update the sampling mode of a given texture
  39766. * @param texture defines the texture to update
  39767. * @param wrapU defines the texture wrap mode of the u coordinates
  39768. * @param wrapV defines the texture wrap mode of the v coordinates
  39769. * @param wrapR defines the texture wrap mode of the r coordinates
  39770. */
  39771. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39772. /** @hidden */
  39773. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39774. width: number;
  39775. height: number;
  39776. layers?: number;
  39777. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39778. /** @hidden */
  39779. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39780. /** @hidden */
  39781. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39782. /**
  39783. * Update a portion of an internal texture
  39784. * @param texture defines the texture to update
  39785. * @param imageData defines the data to store into the texture
  39786. * @param xOffset defines the x coordinates of the update rectangle
  39787. * @param yOffset defines the y coordinates of the update rectangle
  39788. * @param width defines the width of the update rectangle
  39789. * @param height defines the height of the update rectangle
  39790. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39791. * @param lod defines the lod level to update (0 by default)
  39792. */
  39793. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39794. /** @hidden */
  39795. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39796. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39797. private _prepareWebGLTexture;
  39798. /** @hidden */
  39799. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39800. private _getDepthStencilBuffer;
  39801. /** @hidden */
  39802. _releaseFramebufferObjects(texture: InternalTexture): void;
  39803. /** @hidden */
  39804. _releaseTexture(texture: InternalTexture): void;
  39805. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39806. protected _setProgram(program: WebGLProgram): void;
  39807. protected _boundUniforms: {
  39808. [key: number]: WebGLUniformLocation;
  39809. };
  39810. /**
  39811. * Binds an effect to the webGL context
  39812. * @param effect defines the effect to bind
  39813. */
  39814. bindSamplers(effect: Effect): void;
  39815. private _activateCurrentTexture;
  39816. /** @hidden */
  39817. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39818. /** @hidden */
  39819. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39820. /**
  39821. * Unbind all textures from the webGL context
  39822. */
  39823. unbindAllTextures(): void;
  39824. /**
  39825. * Sets a texture to the according uniform.
  39826. * @param channel The texture channel
  39827. * @param uniform The uniform to set
  39828. * @param texture The texture to apply
  39829. */
  39830. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  39831. private _bindSamplerUniformToChannel;
  39832. private _getTextureWrapMode;
  39833. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39834. /**
  39835. * Sets an array of texture to the webGL context
  39836. * @param channel defines the channel where the texture array must be set
  39837. * @param uniform defines the associated uniform location
  39838. * @param textures defines the array of textures to bind
  39839. */
  39840. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  39841. /** @hidden */
  39842. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39843. private _setTextureParameterFloat;
  39844. private _setTextureParameterInteger;
  39845. /**
  39846. * Unbind all vertex attributes from the webGL context
  39847. */
  39848. unbindAllAttributes(): void;
  39849. /**
  39850. * 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
  39851. */
  39852. releaseEffects(): void;
  39853. /**
  39854. * Dispose and release all associated resources
  39855. */
  39856. dispose(): void;
  39857. /**
  39858. * Attach a new callback raised when context lost event is fired
  39859. * @param callback defines the callback to call
  39860. */
  39861. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39862. /**
  39863. * Attach a new callback raised when context restored event is fired
  39864. * @param callback defines the callback to call
  39865. */
  39866. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39867. /**
  39868. * Get the current error code of the webGL context
  39869. * @returns the error code
  39870. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39871. */
  39872. getError(): number;
  39873. private _canRenderToFloatFramebuffer;
  39874. private _canRenderToHalfFloatFramebuffer;
  39875. private _canRenderToFramebuffer;
  39876. /** @hidden */
  39877. _getWebGLTextureType(type: number): number;
  39878. /** @hidden */
  39879. _getInternalFormat(format: number): number;
  39880. /** @hidden */
  39881. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39882. /** @hidden */
  39883. _getRGBAMultiSampleBufferFormat(type: number): number;
  39884. /** @hidden */
  39885. _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;
  39886. /**
  39887. * Loads a file from a url
  39888. * @param url url to load
  39889. * @param onSuccess callback called when the file successfully loads
  39890. * @param onProgress callback called while file is loading (if the server supports this mode)
  39891. * @param offlineProvider defines the offline provider for caching
  39892. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39893. * @param onError callback called when the file fails to load
  39894. * @returns a file request object
  39895. * @hidden
  39896. */
  39897. 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;
  39898. /**
  39899. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39900. * @param x defines the x coordinate of the rectangle where pixels must be read
  39901. * @param y defines the y coordinate of the rectangle where pixels must be read
  39902. * @param width defines the width of the rectangle where pixels must be read
  39903. * @param height defines the height of the rectangle where pixels must be read
  39904. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39905. * @returns a Uint8Array containing RGBA colors
  39906. */
  39907. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39908. private static _IsSupported;
  39909. private static _HasMajorPerformanceCaveat;
  39910. /**
  39911. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39912. */
  39913. static get IsSupported(): boolean;
  39914. /**
  39915. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39916. * @returns true if the engine can be created
  39917. * @ignorenaming
  39918. */
  39919. static isSupported(): boolean;
  39920. /**
  39921. * 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)
  39922. */
  39923. static get HasMajorPerformanceCaveat(): boolean;
  39924. /**
  39925. * Find the next highest power of two.
  39926. * @param x Number to start search from.
  39927. * @return Next highest power of two.
  39928. */
  39929. static CeilingPOT(x: number): number;
  39930. /**
  39931. * Find the next lowest power of two.
  39932. * @param x Number to start search from.
  39933. * @return Next lowest power of two.
  39934. */
  39935. static FloorPOT(x: number): number;
  39936. /**
  39937. * Find the nearest power of two.
  39938. * @param x Number to start search from.
  39939. * @return Next nearest power of two.
  39940. */
  39941. static NearestPOT(x: number): number;
  39942. /**
  39943. * Get the closest exponent of two
  39944. * @param value defines the value to approximate
  39945. * @param max defines the maximum value to return
  39946. * @param mode defines how to define the closest value
  39947. * @returns closest exponent of two of the given value
  39948. */
  39949. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39950. /**
  39951. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39952. * @param func - the function to be called
  39953. * @param requester - the object that will request the next frame. Falls back to window.
  39954. * @returns frame number
  39955. */
  39956. static QueueNewFrame(func: () => void, requester?: any): number;
  39957. /**
  39958. * Gets host document
  39959. * @returns the host document object
  39960. */
  39961. getHostDocument(): Nullable<Document>;
  39962. }
  39963. }
  39964. declare module BABYLON {
  39965. /**
  39966. * Defines the source of the internal texture
  39967. */
  39968. export enum InternalTextureSource {
  39969. /**
  39970. * The source of the texture data is unknown
  39971. */
  39972. Unknown = 0,
  39973. /**
  39974. * Texture data comes from an URL
  39975. */
  39976. Url = 1,
  39977. /**
  39978. * Texture data is only used for temporary storage
  39979. */
  39980. Temp = 2,
  39981. /**
  39982. * Texture data comes from raw data (ArrayBuffer)
  39983. */
  39984. Raw = 3,
  39985. /**
  39986. * Texture content is dynamic (video or dynamic texture)
  39987. */
  39988. Dynamic = 4,
  39989. /**
  39990. * Texture content is generated by rendering to it
  39991. */
  39992. RenderTarget = 5,
  39993. /**
  39994. * Texture content is part of a multi render target process
  39995. */
  39996. MultiRenderTarget = 6,
  39997. /**
  39998. * Texture data comes from a cube data file
  39999. */
  40000. Cube = 7,
  40001. /**
  40002. * Texture data comes from a raw cube data
  40003. */
  40004. CubeRaw = 8,
  40005. /**
  40006. * Texture data come from a prefiltered cube data file
  40007. */
  40008. CubePrefiltered = 9,
  40009. /**
  40010. * Texture content is raw 3D data
  40011. */
  40012. Raw3D = 10,
  40013. /**
  40014. * Texture content is raw 2D array data
  40015. */
  40016. Raw2DArray = 11,
  40017. /**
  40018. * Texture content is a depth texture
  40019. */
  40020. Depth = 12,
  40021. /**
  40022. * Texture data comes from a raw cube data encoded with RGBD
  40023. */
  40024. CubeRawRGBD = 13
  40025. }
  40026. /**
  40027. * Class used to store data associated with WebGL texture data for the engine
  40028. * This class should not be used directly
  40029. */
  40030. export class InternalTexture {
  40031. /** @hidden */
  40032. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40033. /**
  40034. * Defines if the texture is ready
  40035. */
  40036. isReady: boolean;
  40037. /**
  40038. * Defines if the texture is a cube texture
  40039. */
  40040. isCube: boolean;
  40041. /**
  40042. * Defines if the texture contains 3D data
  40043. */
  40044. is3D: boolean;
  40045. /**
  40046. * Defines if the texture contains 2D array data
  40047. */
  40048. is2DArray: boolean;
  40049. /**
  40050. * Defines if the texture contains multiview data
  40051. */
  40052. isMultiview: boolean;
  40053. /**
  40054. * Gets the URL used to load this texture
  40055. */
  40056. url: string;
  40057. /** @hidden */
  40058. _originalUrl: string;
  40059. /**
  40060. * Gets the sampling mode of the texture
  40061. */
  40062. samplingMode: number;
  40063. /**
  40064. * Gets a boolean indicating if the texture needs mipmaps generation
  40065. */
  40066. generateMipMaps: boolean;
  40067. /**
  40068. * Gets the number of samples used by the texture (WebGL2+ only)
  40069. */
  40070. samples: number;
  40071. /**
  40072. * Gets the type of the texture (int, float...)
  40073. */
  40074. type: number;
  40075. /**
  40076. * Gets the format of the texture (RGB, RGBA...)
  40077. */
  40078. format: number;
  40079. /**
  40080. * Observable called when the texture is loaded
  40081. */
  40082. onLoadedObservable: Observable<InternalTexture>;
  40083. /**
  40084. * Gets the width of the texture
  40085. */
  40086. width: number;
  40087. /**
  40088. * Gets the height of the texture
  40089. */
  40090. height: number;
  40091. /**
  40092. * Gets the depth of the texture
  40093. */
  40094. depth: number;
  40095. /**
  40096. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  40097. */
  40098. baseWidth: number;
  40099. /**
  40100. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  40101. */
  40102. baseHeight: number;
  40103. /**
  40104. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  40105. */
  40106. baseDepth: number;
  40107. /**
  40108. * Gets a boolean indicating if the texture is inverted on Y axis
  40109. */
  40110. invertY: boolean;
  40111. /** @hidden */
  40112. _invertVScale: boolean;
  40113. /** @hidden */
  40114. _associatedChannel: number;
  40115. /** @hidden */
  40116. _source: InternalTextureSource;
  40117. /** @hidden */
  40118. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  40119. /** @hidden */
  40120. _bufferView: Nullable<ArrayBufferView>;
  40121. /** @hidden */
  40122. _bufferViewArray: Nullable<ArrayBufferView[]>;
  40123. /** @hidden */
  40124. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  40125. /** @hidden */
  40126. _size: number;
  40127. /** @hidden */
  40128. _extension: string;
  40129. /** @hidden */
  40130. _files: Nullable<string[]>;
  40131. /** @hidden */
  40132. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40133. /** @hidden */
  40134. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40135. /** @hidden */
  40136. _framebuffer: Nullable<WebGLFramebuffer>;
  40137. /** @hidden */
  40138. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40139. /** @hidden */
  40140. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40141. /** @hidden */
  40142. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40143. /** @hidden */
  40144. _attachments: Nullable<number[]>;
  40145. /** @hidden */
  40146. _textureArray: Nullable<InternalTexture[]>;
  40147. /** @hidden */
  40148. _cachedCoordinatesMode: Nullable<number>;
  40149. /** @hidden */
  40150. _cachedWrapU: Nullable<number>;
  40151. /** @hidden */
  40152. _cachedWrapV: Nullable<number>;
  40153. /** @hidden */
  40154. _cachedWrapR: Nullable<number>;
  40155. /** @hidden */
  40156. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40157. /** @hidden */
  40158. _isDisabled: boolean;
  40159. /** @hidden */
  40160. _compression: Nullable<string>;
  40161. /** @hidden */
  40162. _generateStencilBuffer: boolean;
  40163. /** @hidden */
  40164. _generateDepthBuffer: boolean;
  40165. /** @hidden */
  40166. _comparisonFunction: number;
  40167. /** @hidden */
  40168. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40169. /** @hidden */
  40170. _lodGenerationScale: number;
  40171. /** @hidden */
  40172. _lodGenerationOffset: number;
  40173. /** @hidden */
  40174. _depthStencilTexture: Nullable<InternalTexture>;
  40175. /** @hidden */
  40176. _colorTextureArray: Nullable<WebGLTexture>;
  40177. /** @hidden */
  40178. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40179. /** @hidden */
  40180. _lodTextureHigh: Nullable<BaseTexture>;
  40181. /** @hidden */
  40182. _lodTextureMid: Nullable<BaseTexture>;
  40183. /** @hidden */
  40184. _lodTextureLow: Nullable<BaseTexture>;
  40185. /** @hidden */
  40186. _isRGBD: boolean;
  40187. /** @hidden */
  40188. _linearSpecularLOD: boolean;
  40189. /** @hidden */
  40190. _irradianceTexture: Nullable<BaseTexture>;
  40191. /** @hidden */
  40192. _webGLTexture: Nullable<WebGLTexture>;
  40193. /** @hidden */
  40194. _references: number;
  40195. /** @hidden */
  40196. _gammaSpace: Nullable<boolean>;
  40197. private _engine;
  40198. /**
  40199. * Gets the Engine the texture belongs to.
  40200. * @returns The babylon engine
  40201. */
  40202. getEngine(): ThinEngine;
  40203. /**
  40204. * Gets the data source type of the texture
  40205. */
  40206. get source(): InternalTextureSource;
  40207. /**
  40208. * Creates a new InternalTexture
  40209. * @param engine defines the engine to use
  40210. * @param source defines the type of data that will be used
  40211. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40212. */
  40213. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40214. /**
  40215. * Increments the number of references (ie. the number of Texture that point to it)
  40216. */
  40217. incrementReferences(): void;
  40218. /**
  40219. * Change the size of the texture (not the size of the content)
  40220. * @param width defines the new width
  40221. * @param height defines the new height
  40222. * @param depth defines the new depth (1 by default)
  40223. */
  40224. updateSize(width: int, height: int, depth?: int): void;
  40225. /** @hidden */
  40226. _rebuild(): void;
  40227. /** @hidden */
  40228. _swapAndDie(target: InternalTexture): void;
  40229. /**
  40230. * Dispose the current allocated resources
  40231. */
  40232. dispose(): void;
  40233. }
  40234. }
  40235. declare module BABYLON {
  40236. /**
  40237. * Interface used to present a loading screen while loading a scene
  40238. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40239. */
  40240. export interface ILoadingScreen {
  40241. /**
  40242. * Function called to display the loading screen
  40243. */
  40244. displayLoadingUI: () => void;
  40245. /**
  40246. * Function called to hide the loading screen
  40247. */
  40248. hideLoadingUI: () => void;
  40249. /**
  40250. * Gets or sets the color to use for the background
  40251. */
  40252. loadingUIBackgroundColor: string;
  40253. /**
  40254. * Gets or sets the text to display while loading
  40255. */
  40256. loadingUIText: string;
  40257. }
  40258. /**
  40259. * Class used for the default loading screen
  40260. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40261. */
  40262. export class DefaultLoadingScreen implements ILoadingScreen {
  40263. private _renderingCanvas;
  40264. private _loadingText;
  40265. private _loadingDivBackgroundColor;
  40266. private _loadingDiv;
  40267. private _loadingTextDiv;
  40268. /** Gets or sets the logo url to use for the default loading screen */
  40269. static DefaultLogoUrl: string;
  40270. /** Gets or sets the spinner url to use for the default loading screen */
  40271. static DefaultSpinnerUrl: string;
  40272. /**
  40273. * Creates a new default loading screen
  40274. * @param _renderingCanvas defines the canvas used to render the scene
  40275. * @param _loadingText defines the default text to display
  40276. * @param _loadingDivBackgroundColor defines the default background color
  40277. */
  40278. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40279. /**
  40280. * Function called to display the loading screen
  40281. */
  40282. displayLoadingUI(): void;
  40283. /**
  40284. * Function called to hide the loading screen
  40285. */
  40286. hideLoadingUI(): void;
  40287. /**
  40288. * Gets or sets the text to display while loading
  40289. */
  40290. set loadingUIText(text: string);
  40291. get loadingUIText(): string;
  40292. /**
  40293. * Gets or sets the color to use for the background
  40294. */
  40295. get loadingUIBackgroundColor(): string;
  40296. set loadingUIBackgroundColor(color: string);
  40297. private _resizeLoadingUI;
  40298. }
  40299. }
  40300. declare module BABYLON {
  40301. /**
  40302. * Interface for any object that can request an animation frame
  40303. */
  40304. export interface ICustomAnimationFrameRequester {
  40305. /**
  40306. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40307. */
  40308. renderFunction?: Function;
  40309. /**
  40310. * Called to request the next frame to render to
  40311. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40312. */
  40313. requestAnimationFrame: Function;
  40314. /**
  40315. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40316. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40317. */
  40318. requestID?: number;
  40319. }
  40320. }
  40321. declare module BABYLON {
  40322. /**
  40323. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40324. */
  40325. export class PerformanceMonitor {
  40326. private _enabled;
  40327. private _rollingFrameTime;
  40328. private _lastFrameTimeMs;
  40329. /**
  40330. * constructor
  40331. * @param frameSampleSize The number of samples required to saturate the sliding window
  40332. */
  40333. constructor(frameSampleSize?: number);
  40334. /**
  40335. * Samples current frame
  40336. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40337. */
  40338. sampleFrame(timeMs?: number): void;
  40339. /**
  40340. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40341. */
  40342. get averageFrameTime(): number;
  40343. /**
  40344. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40345. */
  40346. get averageFrameTimeVariance(): number;
  40347. /**
  40348. * Returns the frame time of the most recent frame
  40349. */
  40350. get instantaneousFrameTime(): number;
  40351. /**
  40352. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40353. */
  40354. get averageFPS(): number;
  40355. /**
  40356. * Returns the average framerate in frames per second using the most recent frame time
  40357. */
  40358. get instantaneousFPS(): number;
  40359. /**
  40360. * Returns true if enough samples have been taken to completely fill the sliding window
  40361. */
  40362. get isSaturated(): boolean;
  40363. /**
  40364. * Enables contributions to the sliding window sample set
  40365. */
  40366. enable(): void;
  40367. /**
  40368. * Disables contributions to the sliding window sample set
  40369. * Samples will not be interpolated over the disabled period
  40370. */
  40371. disable(): void;
  40372. /**
  40373. * Returns true if sampling is enabled
  40374. */
  40375. get isEnabled(): boolean;
  40376. /**
  40377. * Resets performance monitor
  40378. */
  40379. reset(): void;
  40380. }
  40381. /**
  40382. * RollingAverage
  40383. *
  40384. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40385. */
  40386. export class RollingAverage {
  40387. /**
  40388. * Current average
  40389. */
  40390. average: number;
  40391. /**
  40392. * Current variance
  40393. */
  40394. variance: number;
  40395. protected _samples: Array<number>;
  40396. protected _sampleCount: number;
  40397. protected _pos: number;
  40398. protected _m2: number;
  40399. /**
  40400. * constructor
  40401. * @param length The number of samples required to saturate the sliding window
  40402. */
  40403. constructor(length: number);
  40404. /**
  40405. * Adds a sample to the sample set
  40406. * @param v The sample value
  40407. */
  40408. add(v: number): void;
  40409. /**
  40410. * Returns previously added values or null if outside of history or outside the sliding window domain
  40411. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40412. * @return Value previously recorded with add() or null if outside of range
  40413. */
  40414. history(i: number): number;
  40415. /**
  40416. * Returns true if enough samples have been taken to completely fill the sliding window
  40417. * @return true if sample-set saturated
  40418. */
  40419. isSaturated(): boolean;
  40420. /**
  40421. * Resets the rolling average (equivalent to 0 samples taken so far)
  40422. */
  40423. reset(): void;
  40424. /**
  40425. * Wraps a value around the sample range boundaries
  40426. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40427. * @return Wrapped position in sample range
  40428. */
  40429. protected _wrapPosition(i: number): number;
  40430. }
  40431. }
  40432. declare module BABYLON {
  40433. /**
  40434. * This class is used to track a performance counter which is number based.
  40435. * The user has access to many properties which give statistics of different nature.
  40436. *
  40437. * The implementer can track two kinds of Performance Counter: time and count.
  40438. * 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.
  40439. * 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.
  40440. */
  40441. export class PerfCounter {
  40442. /**
  40443. * Gets or sets a global boolean to turn on and off all the counters
  40444. */
  40445. static Enabled: boolean;
  40446. /**
  40447. * Returns the smallest value ever
  40448. */
  40449. get min(): number;
  40450. /**
  40451. * Returns the biggest value ever
  40452. */
  40453. get max(): number;
  40454. /**
  40455. * Returns the average value since the performance counter is running
  40456. */
  40457. get average(): number;
  40458. /**
  40459. * Returns the average value of the last second the counter was monitored
  40460. */
  40461. get lastSecAverage(): number;
  40462. /**
  40463. * Returns the current value
  40464. */
  40465. get current(): number;
  40466. /**
  40467. * Gets the accumulated total
  40468. */
  40469. get total(): number;
  40470. /**
  40471. * Gets the total value count
  40472. */
  40473. get count(): number;
  40474. /**
  40475. * Creates a new counter
  40476. */
  40477. constructor();
  40478. /**
  40479. * Call this method to start monitoring a new frame.
  40480. * 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.
  40481. */
  40482. fetchNewFrame(): void;
  40483. /**
  40484. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40485. * @param newCount the count value to add to the monitored count
  40486. * @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.
  40487. */
  40488. addCount(newCount: number, fetchResult: boolean): void;
  40489. /**
  40490. * Start monitoring this performance counter
  40491. */
  40492. beginMonitoring(): void;
  40493. /**
  40494. * Compute the time lapsed since the previous beginMonitoring() call.
  40495. * @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
  40496. */
  40497. endMonitoring(newFrame?: boolean): void;
  40498. private _fetchResult;
  40499. private _startMonitoringTime;
  40500. private _min;
  40501. private _max;
  40502. private _average;
  40503. private _current;
  40504. private _totalValueCount;
  40505. private _totalAccumulated;
  40506. private _lastSecAverage;
  40507. private _lastSecAccumulated;
  40508. private _lastSecTime;
  40509. private _lastSecValueCount;
  40510. }
  40511. }
  40512. declare module BABYLON {
  40513. interface ThinEngine {
  40514. /** @hidden */
  40515. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40516. }
  40517. }
  40518. declare module BABYLON {
  40519. /**
  40520. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40521. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40522. */
  40523. export class Analyser {
  40524. /**
  40525. * Gets or sets the smoothing
  40526. * @ignorenaming
  40527. */
  40528. SMOOTHING: number;
  40529. /**
  40530. * Gets or sets the FFT table size
  40531. * @ignorenaming
  40532. */
  40533. FFT_SIZE: number;
  40534. /**
  40535. * Gets or sets the bar graph amplitude
  40536. * @ignorenaming
  40537. */
  40538. BARGRAPHAMPLITUDE: number;
  40539. /**
  40540. * Gets or sets the position of the debug canvas
  40541. * @ignorenaming
  40542. */
  40543. DEBUGCANVASPOS: {
  40544. x: number;
  40545. y: number;
  40546. };
  40547. /**
  40548. * Gets or sets the debug canvas size
  40549. * @ignorenaming
  40550. */
  40551. DEBUGCANVASSIZE: {
  40552. width: number;
  40553. height: number;
  40554. };
  40555. private _byteFreqs;
  40556. private _byteTime;
  40557. private _floatFreqs;
  40558. private _webAudioAnalyser;
  40559. private _debugCanvas;
  40560. private _debugCanvasContext;
  40561. private _scene;
  40562. private _registerFunc;
  40563. private _audioEngine;
  40564. /**
  40565. * Creates a new analyser
  40566. * @param scene defines hosting scene
  40567. */
  40568. constructor(scene: Scene);
  40569. /**
  40570. * Get the number of data values you will have to play with for the visualization
  40571. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40572. * @returns a number
  40573. */
  40574. getFrequencyBinCount(): number;
  40575. /**
  40576. * Gets the current frequency data as a byte array
  40577. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40578. * @returns a Uint8Array
  40579. */
  40580. getByteFrequencyData(): Uint8Array;
  40581. /**
  40582. * Gets the current waveform as a byte array
  40583. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40584. * @returns a Uint8Array
  40585. */
  40586. getByteTimeDomainData(): Uint8Array;
  40587. /**
  40588. * Gets the current frequency data as a float array
  40589. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40590. * @returns a Float32Array
  40591. */
  40592. getFloatFrequencyData(): Float32Array;
  40593. /**
  40594. * Renders the debug canvas
  40595. */
  40596. drawDebugCanvas(): void;
  40597. /**
  40598. * Stops rendering the debug canvas and removes it
  40599. */
  40600. stopDebugCanvas(): void;
  40601. /**
  40602. * Connects two audio nodes
  40603. * @param inputAudioNode defines first node to connect
  40604. * @param outputAudioNode defines second node to connect
  40605. */
  40606. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40607. /**
  40608. * Releases all associated resources
  40609. */
  40610. dispose(): void;
  40611. }
  40612. }
  40613. declare module BABYLON {
  40614. /**
  40615. * This represents an audio engine and it is responsible
  40616. * to play, synchronize and analyse sounds throughout the application.
  40617. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40618. */
  40619. export interface IAudioEngine extends IDisposable {
  40620. /**
  40621. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40622. */
  40623. readonly canUseWebAudio: boolean;
  40624. /**
  40625. * Gets the current AudioContext if available.
  40626. */
  40627. readonly audioContext: Nullable<AudioContext>;
  40628. /**
  40629. * The master gain node defines the global audio volume of your audio engine.
  40630. */
  40631. readonly masterGain: GainNode;
  40632. /**
  40633. * Gets whether or not mp3 are supported by your browser.
  40634. */
  40635. readonly isMP3supported: boolean;
  40636. /**
  40637. * Gets whether or not ogg are supported by your browser.
  40638. */
  40639. readonly isOGGsupported: boolean;
  40640. /**
  40641. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40642. * @ignoreNaming
  40643. */
  40644. WarnedWebAudioUnsupported: boolean;
  40645. /**
  40646. * Defines if the audio engine relies on a custom unlocked button.
  40647. * In this case, the embedded button will not be displayed.
  40648. */
  40649. useCustomUnlockedButton: boolean;
  40650. /**
  40651. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40652. */
  40653. readonly unlocked: boolean;
  40654. /**
  40655. * Event raised when audio has been unlocked on the browser.
  40656. */
  40657. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40658. /**
  40659. * Event raised when audio has been locked on the browser.
  40660. */
  40661. onAudioLockedObservable: Observable<IAudioEngine>;
  40662. /**
  40663. * Flags the audio engine in Locked state.
  40664. * This happens due to new browser policies preventing audio to autoplay.
  40665. */
  40666. lock(): void;
  40667. /**
  40668. * Unlocks the audio engine once a user action has been done on the dom.
  40669. * This is helpful to resume play once browser policies have been satisfied.
  40670. */
  40671. unlock(): void;
  40672. /**
  40673. * Gets the global volume sets on the master gain.
  40674. * @returns the global volume if set or -1 otherwise
  40675. */
  40676. getGlobalVolume(): number;
  40677. /**
  40678. * Sets the global volume of your experience (sets on the master gain).
  40679. * @param newVolume Defines the new global volume of the application
  40680. */
  40681. setGlobalVolume(newVolume: number): void;
  40682. /**
  40683. * Connect the audio engine to an audio analyser allowing some amazing
  40684. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40685. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40686. * @param analyser The analyser to connect to the engine
  40687. */
  40688. connectToAnalyser(analyser: Analyser): void;
  40689. }
  40690. }
  40691. declare module BABYLON {
  40692. /**
  40693. * Defines the interface used by display changed events
  40694. */
  40695. export interface IDisplayChangedEventArgs {
  40696. /** Gets the vrDisplay object (if any) */
  40697. vrDisplay: Nullable<any>;
  40698. /** Gets a boolean indicating if webVR is supported */
  40699. vrSupported: boolean;
  40700. }
  40701. /**
  40702. * Defines the interface used by objects containing a viewport (like a camera)
  40703. */
  40704. interface IViewportOwnerLike {
  40705. /**
  40706. * Gets or sets the viewport
  40707. */
  40708. viewport: IViewportLike;
  40709. }
  40710. /**
  40711. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40712. */
  40713. export class Engine extends ThinEngine {
  40714. /** Defines that alpha blending is disabled */
  40715. static readonly ALPHA_DISABLE: number;
  40716. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40717. static readonly ALPHA_ADD: number;
  40718. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40719. static readonly ALPHA_COMBINE: number;
  40720. /** Defines that alpha blending to DEST - SRC * DEST */
  40721. static readonly ALPHA_SUBTRACT: number;
  40722. /** Defines that alpha blending to SRC * DEST */
  40723. static readonly ALPHA_MULTIPLY: number;
  40724. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40725. static readonly ALPHA_MAXIMIZED: number;
  40726. /** Defines that alpha blending to SRC + DEST */
  40727. static readonly ALPHA_ONEONE: number;
  40728. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40729. static readonly ALPHA_PREMULTIPLIED: number;
  40730. /**
  40731. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40732. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40733. */
  40734. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40735. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40736. static readonly ALPHA_INTERPOLATE: number;
  40737. /**
  40738. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40739. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40740. */
  40741. static readonly ALPHA_SCREENMODE: number;
  40742. /** Defines that the ressource is not delayed*/
  40743. static readonly DELAYLOADSTATE_NONE: number;
  40744. /** Defines that the ressource was successfully delay loaded */
  40745. static readonly DELAYLOADSTATE_LOADED: number;
  40746. /** Defines that the ressource is currently delay loading */
  40747. static readonly DELAYLOADSTATE_LOADING: number;
  40748. /** Defines that the ressource is delayed and has not started loading */
  40749. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40750. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40751. static readonly NEVER: number;
  40752. /** 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 */
  40753. static readonly ALWAYS: number;
  40754. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40755. static readonly LESS: number;
  40756. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40757. static readonly EQUAL: number;
  40758. /** 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 */
  40759. static readonly LEQUAL: number;
  40760. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40761. static readonly GREATER: number;
  40762. /** 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 */
  40763. static readonly GEQUAL: number;
  40764. /** 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 */
  40765. static readonly NOTEQUAL: number;
  40766. /** Passed to stencilOperation to specify that stencil value must be kept */
  40767. static readonly KEEP: number;
  40768. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40769. static readonly REPLACE: number;
  40770. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40771. static readonly INCR: number;
  40772. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40773. static readonly DECR: number;
  40774. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40775. static readonly INVERT: number;
  40776. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40777. static readonly INCR_WRAP: number;
  40778. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40779. static readonly DECR_WRAP: number;
  40780. /** Texture is not repeating outside of 0..1 UVs */
  40781. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40782. /** Texture is repeating outside of 0..1 UVs */
  40783. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40784. /** Texture is repeating and mirrored */
  40785. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40786. /** ALPHA */
  40787. static readonly TEXTUREFORMAT_ALPHA: number;
  40788. /** LUMINANCE */
  40789. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40790. /** LUMINANCE_ALPHA */
  40791. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40792. /** RGB */
  40793. static readonly TEXTUREFORMAT_RGB: number;
  40794. /** RGBA */
  40795. static readonly TEXTUREFORMAT_RGBA: number;
  40796. /** RED */
  40797. static readonly TEXTUREFORMAT_RED: number;
  40798. /** RED (2nd reference) */
  40799. static readonly TEXTUREFORMAT_R: number;
  40800. /** RG */
  40801. static readonly TEXTUREFORMAT_RG: number;
  40802. /** RED_INTEGER */
  40803. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40804. /** RED_INTEGER (2nd reference) */
  40805. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40806. /** RG_INTEGER */
  40807. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40808. /** RGB_INTEGER */
  40809. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40810. /** RGBA_INTEGER */
  40811. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40812. /** UNSIGNED_BYTE */
  40813. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40814. /** UNSIGNED_BYTE (2nd reference) */
  40815. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40816. /** FLOAT */
  40817. static readonly TEXTURETYPE_FLOAT: number;
  40818. /** HALF_FLOAT */
  40819. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40820. /** BYTE */
  40821. static readonly TEXTURETYPE_BYTE: number;
  40822. /** SHORT */
  40823. static readonly TEXTURETYPE_SHORT: number;
  40824. /** UNSIGNED_SHORT */
  40825. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40826. /** INT */
  40827. static readonly TEXTURETYPE_INT: number;
  40828. /** UNSIGNED_INT */
  40829. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40830. /** UNSIGNED_SHORT_4_4_4_4 */
  40831. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40832. /** UNSIGNED_SHORT_5_5_5_1 */
  40833. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40834. /** UNSIGNED_SHORT_5_6_5 */
  40835. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40836. /** UNSIGNED_INT_2_10_10_10_REV */
  40837. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40838. /** UNSIGNED_INT_24_8 */
  40839. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40840. /** UNSIGNED_INT_10F_11F_11F_REV */
  40841. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40842. /** UNSIGNED_INT_5_9_9_9_REV */
  40843. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40844. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40845. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40846. /** nearest is mag = nearest and min = nearest and mip = linear */
  40847. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40848. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40849. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40850. /** Trilinear is mag = linear and min = linear and mip = linear */
  40851. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40852. /** nearest is mag = nearest and min = nearest and mip = linear */
  40853. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40854. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40855. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40856. /** Trilinear is mag = linear and min = linear and mip = linear */
  40857. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40858. /** mag = nearest and min = nearest and mip = nearest */
  40859. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40860. /** mag = nearest and min = linear and mip = nearest */
  40861. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40862. /** mag = nearest and min = linear and mip = linear */
  40863. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40864. /** mag = nearest and min = linear and mip = none */
  40865. static readonly TEXTURE_NEAREST_LINEAR: number;
  40866. /** mag = nearest and min = nearest and mip = none */
  40867. static readonly TEXTURE_NEAREST_NEAREST: number;
  40868. /** mag = linear and min = nearest and mip = nearest */
  40869. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40870. /** mag = linear and min = nearest and mip = linear */
  40871. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40872. /** mag = linear and min = linear and mip = none */
  40873. static readonly TEXTURE_LINEAR_LINEAR: number;
  40874. /** mag = linear and min = nearest and mip = none */
  40875. static readonly TEXTURE_LINEAR_NEAREST: number;
  40876. /** Explicit coordinates mode */
  40877. static readonly TEXTURE_EXPLICIT_MODE: number;
  40878. /** Spherical coordinates mode */
  40879. static readonly TEXTURE_SPHERICAL_MODE: number;
  40880. /** Planar coordinates mode */
  40881. static readonly TEXTURE_PLANAR_MODE: number;
  40882. /** Cubic coordinates mode */
  40883. static readonly TEXTURE_CUBIC_MODE: number;
  40884. /** Projection coordinates mode */
  40885. static readonly TEXTURE_PROJECTION_MODE: number;
  40886. /** Skybox coordinates mode */
  40887. static readonly TEXTURE_SKYBOX_MODE: number;
  40888. /** Inverse Cubic coordinates mode */
  40889. static readonly TEXTURE_INVCUBIC_MODE: number;
  40890. /** Equirectangular coordinates mode */
  40891. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40892. /** Equirectangular Fixed coordinates mode */
  40893. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40894. /** Equirectangular Fixed Mirrored coordinates mode */
  40895. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40896. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40897. static readonly SCALEMODE_FLOOR: number;
  40898. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40899. static readonly SCALEMODE_NEAREST: number;
  40900. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40901. static readonly SCALEMODE_CEILING: number;
  40902. /**
  40903. * Returns the current npm package of the sdk
  40904. */
  40905. static get NpmPackage(): string;
  40906. /**
  40907. * Returns the current version of the framework
  40908. */
  40909. static get Version(): string;
  40910. /** Gets the list of created engines */
  40911. static get Instances(): Engine[];
  40912. /**
  40913. * Gets the latest created engine
  40914. */
  40915. static get LastCreatedEngine(): Nullable<Engine>;
  40916. /**
  40917. * Gets the latest created scene
  40918. */
  40919. static get LastCreatedScene(): Nullable<Scene>;
  40920. /**
  40921. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40922. * @param flag defines which part of the materials must be marked as dirty
  40923. * @param predicate defines a predicate used to filter which materials should be affected
  40924. */
  40925. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40926. /**
  40927. * Method called to create the default loading screen.
  40928. * This can be overriden in your own app.
  40929. * @param canvas The rendering canvas element
  40930. * @returns The loading screen
  40931. */
  40932. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40933. /**
  40934. * Method called to create the default rescale post process on each engine.
  40935. */
  40936. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40937. /**
  40938. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40939. **/
  40940. enableOfflineSupport: boolean;
  40941. /**
  40942. * 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)
  40943. **/
  40944. disableManifestCheck: boolean;
  40945. /**
  40946. * Gets the list of created scenes
  40947. */
  40948. scenes: Scene[];
  40949. /**
  40950. * Event raised when a new scene is created
  40951. */
  40952. onNewSceneAddedObservable: Observable<Scene>;
  40953. /**
  40954. * Gets the list of created postprocesses
  40955. */
  40956. postProcesses: PostProcess[];
  40957. /**
  40958. * Gets a boolean indicating if the pointer is currently locked
  40959. */
  40960. isPointerLock: boolean;
  40961. /**
  40962. * Observable event triggered each time the rendering canvas is resized
  40963. */
  40964. onResizeObservable: Observable<Engine>;
  40965. /**
  40966. * Observable event triggered each time the canvas loses focus
  40967. */
  40968. onCanvasBlurObservable: Observable<Engine>;
  40969. /**
  40970. * Observable event triggered each time the canvas gains focus
  40971. */
  40972. onCanvasFocusObservable: Observable<Engine>;
  40973. /**
  40974. * Observable event triggered each time the canvas receives pointerout event
  40975. */
  40976. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40977. /**
  40978. * Observable raised when the engine begins a new frame
  40979. */
  40980. onBeginFrameObservable: Observable<Engine>;
  40981. /**
  40982. * If set, will be used to request the next animation frame for the render loop
  40983. */
  40984. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40985. /**
  40986. * Observable raised when the engine ends the current frame
  40987. */
  40988. onEndFrameObservable: Observable<Engine>;
  40989. /**
  40990. * Observable raised when the engine is about to compile a shader
  40991. */
  40992. onBeforeShaderCompilationObservable: Observable<Engine>;
  40993. /**
  40994. * Observable raised when the engine has jsut compiled a shader
  40995. */
  40996. onAfterShaderCompilationObservable: Observable<Engine>;
  40997. /**
  40998. * Gets the audio engine
  40999. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41000. * @ignorenaming
  41001. */
  41002. static audioEngine: IAudioEngine;
  41003. /**
  41004. * Default AudioEngine factory responsible of creating the Audio Engine.
  41005. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  41006. */
  41007. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  41008. /**
  41009. * Default offline support factory responsible of creating a tool used to store data locally.
  41010. * By default, this will create a Database object if the workload has been embedded.
  41011. */
  41012. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  41013. private _loadingScreen;
  41014. private _pointerLockRequested;
  41015. private _rescalePostProcess;
  41016. private _deterministicLockstep;
  41017. private _lockstepMaxSteps;
  41018. private _timeStep;
  41019. protected get _supportsHardwareTextureRescaling(): boolean;
  41020. private _fps;
  41021. private _deltaTime;
  41022. /** @hidden */
  41023. _drawCalls: PerfCounter;
  41024. /** 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 */
  41025. canvasTabIndex: number;
  41026. /**
  41027. * Turn this value on if you want to pause FPS computation when in background
  41028. */
  41029. disablePerformanceMonitorInBackground: boolean;
  41030. private _performanceMonitor;
  41031. /**
  41032. * Gets the performance monitor attached to this engine
  41033. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41034. */
  41035. get performanceMonitor(): PerformanceMonitor;
  41036. private _onFocus;
  41037. private _onBlur;
  41038. private _onCanvasPointerOut;
  41039. private _onCanvasBlur;
  41040. private _onCanvasFocus;
  41041. private _onFullscreenChange;
  41042. private _onPointerLockChange;
  41043. /**
  41044. * Gets the HTML element used to attach event listeners
  41045. * @returns a HTML element
  41046. */
  41047. getInputElement(): Nullable<HTMLElement>;
  41048. /**
  41049. * Creates a new engine
  41050. * @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
  41051. * @param antialias defines enable antialiasing (default: false)
  41052. * @param options defines further options to be sent to the getContext() function
  41053. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41054. */
  41055. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41056. /**
  41057. * Gets current aspect ratio
  41058. * @param viewportOwner defines the camera to use to get the aspect ratio
  41059. * @param useScreen defines if screen size must be used (or the current render target if any)
  41060. * @returns a number defining the aspect ratio
  41061. */
  41062. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  41063. /**
  41064. * Gets current screen aspect ratio
  41065. * @returns a number defining the aspect ratio
  41066. */
  41067. getScreenAspectRatio(): number;
  41068. /**
  41069. * Gets the client rect of the HTML canvas attached with the current webGL context
  41070. * @returns a client rectanglee
  41071. */
  41072. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  41073. /**
  41074. * Gets the client rect of the HTML element used for events
  41075. * @returns a client rectanglee
  41076. */
  41077. getInputElementClientRect(): Nullable<ClientRect>;
  41078. /**
  41079. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  41080. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41081. * @returns true if engine is in deterministic lock step mode
  41082. */
  41083. isDeterministicLockStep(): boolean;
  41084. /**
  41085. * Gets the max steps when engine is running in deterministic lock step
  41086. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41087. * @returns the max steps
  41088. */
  41089. getLockstepMaxSteps(): number;
  41090. /**
  41091. * Returns the time in ms between steps when using deterministic lock step.
  41092. * @returns time step in (ms)
  41093. */
  41094. getTimeStep(): number;
  41095. /**
  41096. * Force the mipmap generation for the given render target texture
  41097. * @param texture defines the render target texture to use
  41098. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  41099. */
  41100. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  41101. /** States */
  41102. /**
  41103. * Set various states to the webGL context
  41104. * @param culling defines backface culling state
  41105. * @param zOffset defines the value to apply to zOffset (0 by default)
  41106. * @param force defines if states must be applied even if cache is up to date
  41107. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  41108. */
  41109. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41110. /**
  41111. * Set the z offset to apply to current rendering
  41112. * @param value defines the offset to apply
  41113. */
  41114. setZOffset(value: number): void;
  41115. /**
  41116. * Gets the current value of the zOffset
  41117. * @returns the current zOffset state
  41118. */
  41119. getZOffset(): number;
  41120. /**
  41121. * Enable or disable depth buffering
  41122. * @param enable defines the state to set
  41123. */
  41124. setDepthBuffer(enable: boolean): void;
  41125. /**
  41126. * Gets a boolean indicating if depth writing is enabled
  41127. * @returns the current depth writing state
  41128. */
  41129. getDepthWrite(): boolean;
  41130. /**
  41131. * Enable or disable depth writing
  41132. * @param enable defines the state to set
  41133. */
  41134. setDepthWrite(enable: boolean): void;
  41135. /**
  41136. * Gets a boolean indicating if stencil buffer is enabled
  41137. * @returns the current stencil buffer state
  41138. */
  41139. getStencilBuffer(): boolean;
  41140. /**
  41141. * Enable or disable the stencil buffer
  41142. * @param enable defines if the stencil buffer must be enabled or disabled
  41143. */
  41144. setStencilBuffer(enable: boolean): void;
  41145. /**
  41146. * Gets the current stencil mask
  41147. * @returns a number defining the new stencil mask to use
  41148. */
  41149. getStencilMask(): number;
  41150. /**
  41151. * Sets the current stencil mask
  41152. * @param mask defines the new stencil mask to use
  41153. */
  41154. setStencilMask(mask: number): void;
  41155. /**
  41156. * Gets the current stencil function
  41157. * @returns a number defining the stencil function to use
  41158. */
  41159. getStencilFunction(): number;
  41160. /**
  41161. * Gets the current stencil reference value
  41162. * @returns a number defining the stencil reference value to use
  41163. */
  41164. getStencilFunctionReference(): number;
  41165. /**
  41166. * Gets the current stencil mask
  41167. * @returns a number defining the stencil mask to use
  41168. */
  41169. getStencilFunctionMask(): number;
  41170. /**
  41171. * Sets the current stencil function
  41172. * @param stencilFunc defines the new stencil function to use
  41173. */
  41174. setStencilFunction(stencilFunc: number): void;
  41175. /**
  41176. * Sets the current stencil reference
  41177. * @param reference defines the new stencil reference to use
  41178. */
  41179. setStencilFunctionReference(reference: number): void;
  41180. /**
  41181. * Sets the current stencil mask
  41182. * @param mask defines the new stencil mask to use
  41183. */
  41184. setStencilFunctionMask(mask: number): void;
  41185. /**
  41186. * Gets the current stencil operation when stencil fails
  41187. * @returns a number defining stencil operation to use when stencil fails
  41188. */
  41189. getStencilOperationFail(): number;
  41190. /**
  41191. * Gets the current stencil operation when depth fails
  41192. * @returns a number defining stencil operation to use when depth fails
  41193. */
  41194. getStencilOperationDepthFail(): number;
  41195. /**
  41196. * Gets the current stencil operation when stencil passes
  41197. * @returns a number defining stencil operation to use when stencil passes
  41198. */
  41199. getStencilOperationPass(): number;
  41200. /**
  41201. * Sets the stencil operation to use when stencil fails
  41202. * @param operation defines the stencil operation to use when stencil fails
  41203. */
  41204. setStencilOperationFail(operation: number): void;
  41205. /**
  41206. * Sets the stencil operation to use when depth fails
  41207. * @param operation defines the stencil operation to use when depth fails
  41208. */
  41209. setStencilOperationDepthFail(operation: number): void;
  41210. /**
  41211. * Sets the stencil operation to use when stencil passes
  41212. * @param operation defines the stencil operation to use when stencil passes
  41213. */
  41214. setStencilOperationPass(operation: number): void;
  41215. /**
  41216. * Sets a boolean indicating if the dithering state is enabled or disabled
  41217. * @param value defines the dithering state
  41218. */
  41219. setDitheringState(value: boolean): void;
  41220. /**
  41221. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41222. * @param value defines the rasterizer state
  41223. */
  41224. setRasterizerState(value: boolean): void;
  41225. /**
  41226. * Gets the current depth function
  41227. * @returns a number defining the depth function
  41228. */
  41229. getDepthFunction(): Nullable<number>;
  41230. /**
  41231. * Sets the current depth function
  41232. * @param depthFunc defines the function to use
  41233. */
  41234. setDepthFunction(depthFunc: number): void;
  41235. /**
  41236. * Sets the current depth function to GREATER
  41237. */
  41238. setDepthFunctionToGreater(): void;
  41239. /**
  41240. * Sets the current depth function to GEQUAL
  41241. */
  41242. setDepthFunctionToGreaterOrEqual(): void;
  41243. /**
  41244. * Sets the current depth function to LESS
  41245. */
  41246. setDepthFunctionToLess(): void;
  41247. /**
  41248. * Sets the current depth function to LEQUAL
  41249. */
  41250. setDepthFunctionToLessOrEqual(): void;
  41251. private _cachedStencilBuffer;
  41252. private _cachedStencilFunction;
  41253. private _cachedStencilMask;
  41254. private _cachedStencilOperationPass;
  41255. private _cachedStencilOperationFail;
  41256. private _cachedStencilOperationDepthFail;
  41257. private _cachedStencilReference;
  41258. /**
  41259. * Caches the the state of the stencil buffer
  41260. */
  41261. cacheStencilState(): void;
  41262. /**
  41263. * Restores the state of the stencil buffer
  41264. */
  41265. restoreStencilState(): void;
  41266. /**
  41267. * Directly set the WebGL Viewport
  41268. * @param x defines the x coordinate of the viewport (in screen space)
  41269. * @param y defines the y coordinate of the viewport (in screen space)
  41270. * @param width defines the width of the viewport (in screen space)
  41271. * @param height defines the height of the viewport (in screen space)
  41272. * @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
  41273. */
  41274. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41275. /**
  41276. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41277. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41278. * @param y defines the y-coordinate of the corner of the clear rectangle
  41279. * @param width defines the width of the clear rectangle
  41280. * @param height defines the height of the clear rectangle
  41281. * @param clearColor defines the clear color
  41282. */
  41283. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41284. /**
  41285. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41286. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41287. * @param y defines the y-coordinate of the corner of the clear rectangle
  41288. * @param width defines the width of the clear rectangle
  41289. * @param height defines the height of the clear rectangle
  41290. */
  41291. enableScissor(x: number, y: number, width: number, height: number): void;
  41292. /**
  41293. * Disable previously set scissor test rectangle
  41294. */
  41295. disableScissor(): void;
  41296. protected _reportDrawCall(): void;
  41297. /**
  41298. * Initializes a webVR display and starts listening to display change events
  41299. * The onVRDisplayChangedObservable will be notified upon these changes
  41300. * @returns The onVRDisplayChangedObservable
  41301. */
  41302. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41303. /** @hidden */
  41304. _prepareVRComponent(): void;
  41305. /** @hidden */
  41306. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41307. /** @hidden */
  41308. _submitVRFrame(): void;
  41309. /**
  41310. * Call this function to leave webVR mode
  41311. * Will do nothing if webVR is not supported or if there is no webVR device
  41312. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41313. */
  41314. disableVR(): void;
  41315. /**
  41316. * Gets a boolean indicating that the system is in VR mode and is presenting
  41317. * @returns true if VR mode is engaged
  41318. */
  41319. isVRPresenting(): boolean;
  41320. /** @hidden */
  41321. _requestVRFrame(): void;
  41322. /** @hidden */
  41323. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41324. /**
  41325. * Gets the source code of the vertex shader associated with a specific webGL program
  41326. * @param program defines the program to use
  41327. * @returns a string containing the source code of the vertex shader associated with the program
  41328. */
  41329. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41330. /**
  41331. * Gets the source code of the fragment shader associated with a specific webGL program
  41332. * @param program defines the program to use
  41333. * @returns a string containing the source code of the fragment shader associated with the program
  41334. */
  41335. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41336. /**
  41337. * Sets a depth stencil texture from a render target to the according uniform.
  41338. * @param channel The texture channel
  41339. * @param uniform The uniform to set
  41340. * @param texture The render target texture containing the depth stencil texture to apply
  41341. */
  41342. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41343. /**
  41344. * Sets a texture to the webGL context from a postprocess
  41345. * @param channel defines the channel to use
  41346. * @param postProcess defines the source postprocess
  41347. */
  41348. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41349. /**
  41350. * Binds the output of the passed in post process to the texture channel specified
  41351. * @param channel The channel the texture should be bound to
  41352. * @param postProcess The post process which's output should be bound
  41353. */
  41354. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41355. protected _rebuildBuffers(): void;
  41356. /** @hidden */
  41357. _renderFrame(): void;
  41358. _renderLoop(): void;
  41359. /** @hidden */
  41360. _renderViews(): boolean;
  41361. /**
  41362. * Toggle full screen mode
  41363. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41364. */
  41365. switchFullscreen(requestPointerLock: boolean): void;
  41366. /**
  41367. * Enters full screen mode
  41368. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41369. */
  41370. enterFullscreen(requestPointerLock: boolean): void;
  41371. /**
  41372. * Exits full screen mode
  41373. */
  41374. exitFullscreen(): void;
  41375. /**
  41376. * Enters Pointerlock mode
  41377. */
  41378. enterPointerlock(): void;
  41379. /**
  41380. * Exits Pointerlock mode
  41381. */
  41382. exitPointerlock(): void;
  41383. /**
  41384. * Begin a new frame
  41385. */
  41386. beginFrame(): void;
  41387. /**
  41388. * Enf the current frame
  41389. */
  41390. endFrame(): void;
  41391. resize(): void;
  41392. /**
  41393. * Force a specific size of the canvas
  41394. * @param width defines the new canvas' width
  41395. * @param height defines the new canvas' height
  41396. * @returns true if the size was changed
  41397. */
  41398. setSize(width: number, height: number): boolean;
  41399. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41400. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41401. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41402. _releaseTexture(texture: InternalTexture): void;
  41403. /**
  41404. * @hidden
  41405. * Rescales a texture
  41406. * @param source input texutre
  41407. * @param destination destination texture
  41408. * @param scene scene to use to render the resize
  41409. * @param internalFormat format to use when resizing
  41410. * @param onComplete callback to be called when resize has completed
  41411. */
  41412. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41413. /**
  41414. * Gets the current framerate
  41415. * @returns a number representing the framerate
  41416. */
  41417. getFps(): number;
  41418. /**
  41419. * Gets the time spent between current and previous frame
  41420. * @returns a number representing the delta time in ms
  41421. */
  41422. getDeltaTime(): number;
  41423. private _measureFps;
  41424. /** @hidden */
  41425. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41426. /**
  41427. * Updates the sample count of a render target texture
  41428. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41429. * @param texture defines the texture to update
  41430. * @param samples defines the sample count to set
  41431. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41432. */
  41433. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41434. /**
  41435. * Updates a depth texture Comparison Mode and Function.
  41436. * If the comparison Function is equal to 0, the mode will be set to none.
  41437. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41438. * @param texture The texture to set the comparison function for
  41439. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41440. */
  41441. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41442. /**
  41443. * Creates a webGL buffer to use with instanciation
  41444. * @param capacity defines the size of the buffer
  41445. * @returns the webGL buffer
  41446. */
  41447. createInstancesBuffer(capacity: number): DataBuffer;
  41448. /**
  41449. * Delete a webGL buffer used with instanciation
  41450. * @param buffer defines the webGL buffer to delete
  41451. */
  41452. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41453. private _clientWaitAsync;
  41454. /** @hidden */
  41455. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41456. dispose(): void;
  41457. private _disableTouchAction;
  41458. /**
  41459. * Display the loading screen
  41460. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41461. */
  41462. displayLoadingUI(): void;
  41463. /**
  41464. * Hide the loading screen
  41465. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41466. */
  41467. hideLoadingUI(): void;
  41468. /**
  41469. * Gets the current loading screen object
  41470. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41471. */
  41472. get loadingScreen(): ILoadingScreen;
  41473. /**
  41474. * Sets the current loading screen object
  41475. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41476. */
  41477. set loadingScreen(loadingScreen: ILoadingScreen);
  41478. /**
  41479. * Sets the current loading screen text
  41480. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41481. */
  41482. set loadingUIText(text: string);
  41483. /**
  41484. * Sets the current loading screen background color
  41485. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41486. */
  41487. set loadingUIBackgroundColor(color: string);
  41488. /** Pointerlock and fullscreen */
  41489. /**
  41490. * Ask the browser to promote the current element to pointerlock mode
  41491. * @param element defines the DOM element to promote
  41492. */
  41493. static _RequestPointerlock(element: HTMLElement): void;
  41494. /**
  41495. * Asks the browser to exit pointerlock mode
  41496. */
  41497. static _ExitPointerlock(): void;
  41498. /**
  41499. * Ask the browser to promote the current element to fullscreen rendering mode
  41500. * @param element defines the DOM element to promote
  41501. */
  41502. static _RequestFullscreen(element: HTMLElement): void;
  41503. /**
  41504. * Asks the browser to exit fullscreen mode
  41505. */
  41506. static _ExitFullscreen(): void;
  41507. }
  41508. }
  41509. declare module BABYLON {
  41510. /**
  41511. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41512. * during the life time of the application.
  41513. */
  41514. export class EngineStore {
  41515. /** Gets the list of created engines */
  41516. static Instances: Engine[];
  41517. /** @hidden */
  41518. static _LastCreatedScene: Nullable<Scene>;
  41519. /**
  41520. * Gets the latest created engine
  41521. */
  41522. static get LastCreatedEngine(): Nullable<Engine>;
  41523. /**
  41524. * Gets the latest created scene
  41525. */
  41526. static get LastCreatedScene(): Nullable<Scene>;
  41527. /**
  41528. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41529. * @ignorenaming
  41530. */
  41531. static UseFallbackTexture: boolean;
  41532. /**
  41533. * Texture content used if a texture cannot loaded
  41534. * @ignorenaming
  41535. */
  41536. static FallbackTexture: string;
  41537. }
  41538. }
  41539. declare module BABYLON {
  41540. /**
  41541. * Helper class that provides a small promise polyfill
  41542. */
  41543. export class PromisePolyfill {
  41544. /**
  41545. * Static function used to check if the polyfill is required
  41546. * If this is the case then the function will inject the polyfill to window.Promise
  41547. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41548. */
  41549. static Apply(force?: boolean): void;
  41550. }
  41551. }
  41552. declare module BABYLON {
  41553. /**
  41554. * Interface for screenshot methods with describe argument called `size` as object with options
  41555. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41556. */
  41557. export interface IScreenshotSize {
  41558. /**
  41559. * number in pixels for canvas height
  41560. */
  41561. height?: number;
  41562. /**
  41563. * multiplier allowing render at a higher or lower resolution
  41564. * If value is defined then height and width will be ignored and taken from camera
  41565. */
  41566. precision?: number;
  41567. /**
  41568. * number in pixels for canvas width
  41569. */
  41570. width?: number;
  41571. }
  41572. }
  41573. declare module BABYLON {
  41574. interface IColor4Like {
  41575. r: float;
  41576. g: float;
  41577. b: float;
  41578. a: float;
  41579. }
  41580. /**
  41581. * Class containing a set of static utilities functions
  41582. */
  41583. export class Tools {
  41584. /**
  41585. * Gets or sets the base URL to use to load assets
  41586. */
  41587. static get BaseUrl(): string;
  41588. static set BaseUrl(value: string);
  41589. /**
  41590. * Enable/Disable Custom HTTP Request Headers globally.
  41591. * default = false
  41592. * @see CustomRequestHeaders
  41593. */
  41594. static UseCustomRequestHeaders: boolean;
  41595. /**
  41596. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41597. * i.e. when loading files, where the server/service expects an Authorization header
  41598. */
  41599. static CustomRequestHeaders: {
  41600. [key: string]: string;
  41601. };
  41602. /**
  41603. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41604. */
  41605. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41606. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41607. /**
  41608. * Default behaviour for cors in the application.
  41609. * It can be a string if the expected behavior is identical in the entire app.
  41610. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41611. */
  41612. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41613. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41614. /**
  41615. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41616. * @ignorenaming
  41617. */
  41618. static get UseFallbackTexture(): boolean;
  41619. static set UseFallbackTexture(value: boolean);
  41620. /**
  41621. * Use this object to register external classes like custom textures or material
  41622. * to allow the laoders to instantiate them
  41623. */
  41624. static get RegisteredExternalClasses(): {
  41625. [key: string]: Object;
  41626. };
  41627. static set RegisteredExternalClasses(classes: {
  41628. [key: string]: Object;
  41629. });
  41630. /**
  41631. * Texture content used if a texture cannot loaded
  41632. * @ignorenaming
  41633. */
  41634. static get fallbackTexture(): string;
  41635. static set fallbackTexture(value: string);
  41636. /**
  41637. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41638. * @param u defines the coordinate on X axis
  41639. * @param v defines the coordinate on Y axis
  41640. * @param width defines the width of the source data
  41641. * @param height defines the height of the source data
  41642. * @param pixels defines the source byte array
  41643. * @param color defines the output color
  41644. */
  41645. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41646. /**
  41647. * Interpolates between a and b via alpha
  41648. * @param a The lower value (returned when alpha = 0)
  41649. * @param b The upper value (returned when alpha = 1)
  41650. * @param alpha The interpolation-factor
  41651. * @return The mixed value
  41652. */
  41653. static Mix(a: number, b: number, alpha: number): number;
  41654. /**
  41655. * Tries to instantiate a new object from a given class name
  41656. * @param className defines the class name to instantiate
  41657. * @returns the new object or null if the system was not able to do the instantiation
  41658. */
  41659. static Instantiate(className: string): any;
  41660. /**
  41661. * Provides a slice function that will work even on IE
  41662. * @param data defines the array to slice
  41663. * @param start defines the start of the data (optional)
  41664. * @param end defines the end of the data (optional)
  41665. * @returns the new sliced array
  41666. */
  41667. static Slice<T>(data: T, start?: number, end?: number): T;
  41668. /**
  41669. * Provides a slice function that will work even on IE
  41670. * The difference between this and Slice is that this will force-convert to array
  41671. * @param data defines the array to slice
  41672. * @param start defines the start of the data (optional)
  41673. * @param end defines the end of the data (optional)
  41674. * @returns the new sliced array
  41675. */
  41676. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41677. /**
  41678. * Polyfill for setImmediate
  41679. * @param action defines the action to execute after the current execution block
  41680. */
  41681. static SetImmediate(action: () => void): void;
  41682. /**
  41683. * Function indicating if a number is an exponent of 2
  41684. * @param value defines the value to test
  41685. * @returns true if the value is an exponent of 2
  41686. */
  41687. static IsExponentOfTwo(value: number): boolean;
  41688. private static _tmpFloatArray;
  41689. /**
  41690. * Returns the nearest 32-bit single precision float representation of a Number
  41691. * @param value A Number. If the parameter is of a different type, it will get converted
  41692. * to a number or to NaN if it cannot be converted
  41693. * @returns number
  41694. */
  41695. static FloatRound(value: number): number;
  41696. /**
  41697. * Extracts the filename from a path
  41698. * @param path defines the path to use
  41699. * @returns the filename
  41700. */
  41701. static GetFilename(path: string): string;
  41702. /**
  41703. * Extracts the "folder" part of a path (everything before the filename).
  41704. * @param uri The URI to extract the info from
  41705. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41706. * @returns The "folder" part of the path
  41707. */
  41708. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41709. /**
  41710. * Extracts text content from a DOM element hierarchy
  41711. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41712. */
  41713. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41714. /**
  41715. * Convert an angle in radians to degrees
  41716. * @param angle defines the angle to convert
  41717. * @returns the angle in degrees
  41718. */
  41719. static ToDegrees(angle: number): number;
  41720. /**
  41721. * Convert an angle in degrees to radians
  41722. * @param angle defines the angle to convert
  41723. * @returns the angle in radians
  41724. */
  41725. static ToRadians(angle: number): number;
  41726. /**
  41727. * Returns an array if obj is not an array
  41728. * @param obj defines the object to evaluate as an array
  41729. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41730. * @returns either obj directly if obj is an array or a new array containing obj
  41731. */
  41732. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41733. /**
  41734. * Gets the pointer prefix to use
  41735. * @param engine defines the engine we are finding the prefix for
  41736. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41737. */
  41738. static GetPointerPrefix(engine: Engine): string;
  41739. /**
  41740. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41741. * @param url define the url we are trying
  41742. * @param element define the dom element where to configure the cors policy
  41743. */
  41744. static SetCorsBehavior(url: string | string[], element: {
  41745. crossOrigin: string | null;
  41746. }): void;
  41747. /**
  41748. * Removes unwanted characters from an url
  41749. * @param url defines the url to clean
  41750. * @returns the cleaned url
  41751. */
  41752. static CleanUrl(url: string): string;
  41753. /**
  41754. * Gets or sets a function used to pre-process url before using them to load assets
  41755. */
  41756. static get PreprocessUrl(): (url: string) => string;
  41757. static set PreprocessUrl(processor: (url: string) => string);
  41758. /**
  41759. * Loads an image as an HTMLImageElement.
  41760. * @param input url string, ArrayBuffer, or Blob to load
  41761. * @param onLoad callback called when the image successfully loads
  41762. * @param onError callback called when the image fails to load
  41763. * @param offlineProvider offline provider for caching
  41764. * @param mimeType optional mime type
  41765. * @returns the HTMLImageElement of the loaded image
  41766. */
  41767. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41768. /**
  41769. * Loads a file from a url
  41770. * @param url url string, ArrayBuffer, or Blob to load
  41771. * @param onSuccess callback called when the file successfully loads
  41772. * @param onProgress callback called while file is loading (if the server supports this mode)
  41773. * @param offlineProvider defines the offline provider for caching
  41774. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41775. * @param onError callback called when the file fails to load
  41776. * @returns a file request object
  41777. */
  41778. 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;
  41779. /**
  41780. * Loads a file from a url
  41781. * @param url the file url to load
  41782. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41783. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41784. */
  41785. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41786. /**
  41787. * Load a script (identified by an url). When the url returns, the
  41788. * content of this file is added into a new script element, attached to the DOM (body element)
  41789. * @param scriptUrl defines the url of the script to laod
  41790. * @param onSuccess defines the callback called when the script is loaded
  41791. * @param onError defines the callback to call if an error occurs
  41792. * @param scriptId defines the id of the script element
  41793. */
  41794. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41795. /**
  41796. * Load an asynchronous script (identified by an url). When the url returns, the
  41797. * content of this file is added into a new script element, attached to the DOM (body element)
  41798. * @param scriptUrl defines the url of the script to laod
  41799. * @param scriptId defines the id of the script element
  41800. * @returns a promise request object
  41801. */
  41802. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41803. /**
  41804. * Loads a file from a blob
  41805. * @param fileToLoad defines the blob to use
  41806. * @param callback defines the callback to call when data is loaded
  41807. * @param progressCallback defines the callback to call during loading process
  41808. * @returns a file request object
  41809. */
  41810. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41811. /**
  41812. * Reads a file from a File object
  41813. * @param file defines the file to load
  41814. * @param onSuccess defines the callback to call when data is loaded
  41815. * @param onProgress defines the callback to call during loading process
  41816. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41817. * @param onError defines the callback to call when an error occurs
  41818. * @returns a file request object
  41819. */
  41820. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41821. /**
  41822. * Creates a data url from a given string content
  41823. * @param content defines the content to convert
  41824. * @returns the new data url link
  41825. */
  41826. static FileAsURL(content: string): string;
  41827. /**
  41828. * Format the given number to a specific decimal format
  41829. * @param value defines the number to format
  41830. * @param decimals defines the number of decimals to use
  41831. * @returns the formatted string
  41832. */
  41833. static Format(value: number, decimals?: number): string;
  41834. /**
  41835. * Tries to copy an object by duplicating every property
  41836. * @param source defines the source object
  41837. * @param destination defines the target object
  41838. * @param doNotCopyList defines a list of properties to avoid
  41839. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41840. */
  41841. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41842. /**
  41843. * Gets a boolean indicating if the given object has no own property
  41844. * @param obj defines the object to test
  41845. * @returns true if object has no own property
  41846. */
  41847. static IsEmpty(obj: any): boolean;
  41848. /**
  41849. * Function used to register events at window level
  41850. * @param windowElement defines the Window object to use
  41851. * @param events defines the events to register
  41852. */
  41853. static RegisterTopRootEvents(windowElement: Window, events: {
  41854. name: string;
  41855. handler: Nullable<(e: FocusEvent) => any>;
  41856. }[]): void;
  41857. /**
  41858. * Function used to unregister events from window level
  41859. * @param windowElement defines the Window object to use
  41860. * @param events defines the events to unregister
  41861. */
  41862. static UnregisterTopRootEvents(windowElement: Window, events: {
  41863. name: string;
  41864. handler: Nullable<(e: FocusEvent) => any>;
  41865. }[]): void;
  41866. /**
  41867. * @ignore
  41868. */
  41869. static _ScreenshotCanvas: HTMLCanvasElement;
  41870. /**
  41871. * Dumps the current bound framebuffer
  41872. * @param width defines the rendering width
  41873. * @param height defines the rendering height
  41874. * @param engine defines the hosting engine
  41875. * @param successCallback defines the callback triggered once the data are available
  41876. * @param mimeType defines the mime type of the result
  41877. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41878. */
  41879. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41880. /**
  41881. * Converts the canvas data to blob.
  41882. * This acts as a polyfill for browsers not supporting the to blob function.
  41883. * @param canvas Defines the canvas to extract the data from
  41884. * @param successCallback Defines the callback triggered once the data are available
  41885. * @param mimeType Defines the mime type of the result
  41886. */
  41887. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41888. /**
  41889. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41890. * @param successCallback defines the callback triggered once the data are available
  41891. * @param mimeType defines the mime type of the result
  41892. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41893. */
  41894. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41895. /**
  41896. * Downloads a blob in the browser
  41897. * @param blob defines the blob to download
  41898. * @param fileName defines the name of the downloaded file
  41899. */
  41900. static Download(blob: Blob, fileName: string): void;
  41901. /**
  41902. * Will return the right value of the noPreventDefault variable
  41903. * Needed to keep backwards compatibility to the old API.
  41904. *
  41905. * @param args arguments passed to the attachControl function
  41906. * @returns the correct value for noPreventDefault
  41907. */
  41908. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  41909. /**
  41910. * Captures a screenshot of the current rendering
  41911. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41912. * @param engine defines the rendering engine
  41913. * @param camera defines the source camera
  41914. * @param size This parameter can be set to a single number or to an object with the
  41915. * following (optional) properties: precision, width, height. If a single number is passed,
  41916. * it will be used for both width and height. If an object is passed, the screenshot size
  41917. * will be derived from the parameters. The precision property is a multiplier allowing
  41918. * rendering at a higher or lower resolution
  41919. * @param successCallback defines the callback receives a single parameter which contains the
  41920. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41921. * src parameter of an <img> to display it
  41922. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41923. * Check your browser for supported MIME types
  41924. */
  41925. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41926. /**
  41927. * Captures a screenshot of the current rendering
  41928. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41929. * @param engine defines the rendering engine
  41930. * @param camera defines the source camera
  41931. * @param size This parameter can be set to a single number or to an object with the
  41932. * following (optional) properties: precision, width, height. If a single number is passed,
  41933. * it will be used for both width and height. If an object is passed, the screenshot size
  41934. * will be derived from the parameters. The precision property is a multiplier allowing
  41935. * rendering at a higher or lower resolution
  41936. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41937. * Check your browser for supported MIME types
  41938. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41939. * to the src parameter of an <img> to display it
  41940. */
  41941. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41942. /**
  41943. * Generates an image screenshot from the specified camera.
  41944. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41945. * @param engine The engine to use for rendering
  41946. * @param camera The camera to use for rendering
  41947. * @param size This parameter can be set to a single number or to an object with the
  41948. * following (optional) properties: precision, width, height. If a single number is passed,
  41949. * it will be used for both width and height. If an object is passed, the screenshot size
  41950. * will be derived from the parameters. The precision property is a multiplier allowing
  41951. * rendering at a higher or lower resolution
  41952. * @param successCallback The callback receives a single parameter which contains the
  41953. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41954. * src parameter of an <img> to display it
  41955. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41956. * Check your browser for supported MIME types
  41957. * @param samples Texture samples (default: 1)
  41958. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41959. * @param fileName A name for for the downloaded file.
  41960. */
  41961. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41962. /**
  41963. * Generates an image screenshot from the specified camera.
  41964. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41965. * @param engine The engine to use for rendering
  41966. * @param camera The camera to use for rendering
  41967. * @param size This parameter can be set to a single number or to an object with the
  41968. * following (optional) properties: precision, width, height. If a single number is passed,
  41969. * it will be used for both width and height. If an object is passed, the screenshot size
  41970. * will be derived from the parameters. The precision property is a multiplier allowing
  41971. * rendering at a higher or lower resolution
  41972. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41973. * Check your browser for supported MIME types
  41974. * @param samples Texture samples (default: 1)
  41975. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41976. * @param fileName A name for for the downloaded file.
  41977. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41978. * to the src parameter of an <img> to display it
  41979. */
  41980. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41981. /**
  41982. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41983. * Be aware Math.random() could cause collisions, but:
  41984. * "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"
  41985. * @returns a pseudo random id
  41986. */
  41987. static RandomId(): string;
  41988. /**
  41989. * Test if the given uri is a base64 string
  41990. * @param uri The uri to test
  41991. * @return True if the uri is a base64 string or false otherwise
  41992. */
  41993. static IsBase64(uri: string): boolean;
  41994. /**
  41995. * Decode the given base64 uri.
  41996. * @param uri The uri to decode
  41997. * @return The decoded base64 data.
  41998. */
  41999. static DecodeBase64(uri: string): ArrayBuffer;
  42000. /**
  42001. * Gets the absolute url.
  42002. * @param url the input url
  42003. * @return the absolute url
  42004. */
  42005. static GetAbsoluteUrl(url: string): string;
  42006. /**
  42007. * No log
  42008. */
  42009. static readonly NoneLogLevel: number;
  42010. /**
  42011. * Only message logs
  42012. */
  42013. static readonly MessageLogLevel: number;
  42014. /**
  42015. * Only warning logs
  42016. */
  42017. static readonly WarningLogLevel: number;
  42018. /**
  42019. * Only error logs
  42020. */
  42021. static readonly ErrorLogLevel: number;
  42022. /**
  42023. * All logs
  42024. */
  42025. static readonly AllLogLevel: number;
  42026. /**
  42027. * Gets a value indicating the number of loading errors
  42028. * @ignorenaming
  42029. */
  42030. static get errorsCount(): number;
  42031. /**
  42032. * Callback called when a new log is added
  42033. */
  42034. static OnNewCacheEntry: (entry: string) => void;
  42035. /**
  42036. * Log a message to the console
  42037. * @param message defines the message to log
  42038. */
  42039. static Log(message: string): void;
  42040. /**
  42041. * Write a warning message to the console
  42042. * @param message defines the message to log
  42043. */
  42044. static Warn(message: string): void;
  42045. /**
  42046. * Write an error message to the console
  42047. * @param message defines the message to log
  42048. */
  42049. static Error(message: string): void;
  42050. /**
  42051. * Gets current log cache (list of logs)
  42052. */
  42053. static get LogCache(): string;
  42054. /**
  42055. * Clears the log cache
  42056. */
  42057. static ClearLogCache(): void;
  42058. /**
  42059. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  42060. */
  42061. static set LogLevels(level: number);
  42062. /**
  42063. * Checks if the window object exists
  42064. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  42065. */
  42066. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  42067. /**
  42068. * No performance log
  42069. */
  42070. static readonly PerformanceNoneLogLevel: number;
  42071. /**
  42072. * Use user marks to log performance
  42073. */
  42074. static readonly PerformanceUserMarkLogLevel: number;
  42075. /**
  42076. * Log performance to the console
  42077. */
  42078. static readonly PerformanceConsoleLogLevel: number;
  42079. private static _performance;
  42080. /**
  42081. * Sets the current performance log level
  42082. */
  42083. static set PerformanceLogLevel(level: number);
  42084. private static _StartPerformanceCounterDisabled;
  42085. private static _EndPerformanceCounterDisabled;
  42086. private static _StartUserMark;
  42087. private static _EndUserMark;
  42088. private static _StartPerformanceConsole;
  42089. private static _EndPerformanceConsole;
  42090. /**
  42091. * Starts a performance counter
  42092. */
  42093. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42094. /**
  42095. * Ends a specific performance coutner
  42096. */
  42097. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42098. /**
  42099. * Gets either window.performance.now() if supported or Date.now() else
  42100. */
  42101. static get Now(): number;
  42102. /**
  42103. * This method will return the name of the class used to create the instance of the given object.
  42104. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  42105. * @param object the object to get the class name from
  42106. * @param isType defines if the object is actually a type
  42107. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  42108. */
  42109. static GetClassName(object: any, isType?: boolean): string;
  42110. /**
  42111. * Gets the first element of an array satisfying a given predicate
  42112. * @param array defines the array to browse
  42113. * @param predicate defines the predicate to use
  42114. * @returns null if not found or the element
  42115. */
  42116. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  42117. /**
  42118. * This method will return the name of the full name of the class, including its owning module (if any).
  42119. * 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).
  42120. * @param object the object to get the class name from
  42121. * @param isType defines if the object is actually a type
  42122. * @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.
  42123. * @ignorenaming
  42124. */
  42125. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  42126. /**
  42127. * Returns a promise that resolves after the given amount of time.
  42128. * @param delay Number of milliseconds to delay
  42129. * @returns Promise that resolves after the given amount of time
  42130. */
  42131. static DelayAsync(delay: number): Promise<void>;
  42132. /**
  42133. * Utility function to detect if the current user agent is Safari
  42134. * @returns whether or not the current user agent is safari
  42135. */
  42136. static IsSafari(): boolean;
  42137. }
  42138. /**
  42139. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42140. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42141. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42142. * @param name The name of the class, case should be preserved
  42143. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42144. */
  42145. export function className(name: string, module?: string): (target: Object) => void;
  42146. /**
  42147. * An implementation of a loop for asynchronous functions.
  42148. */
  42149. export class AsyncLoop {
  42150. /**
  42151. * Defines the number of iterations for the loop
  42152. */
  42153. iterations: number;
  42154. /**
  42155. * Defines the current index of the loop.
  42156. */
  42157. index: number;
  42158. private _done;
  42159. private _fn;
  42160. private _successCallback;
  42161. /**
  42162. * Constructor.
  42163. * @param iterations the number of iterations.
  42164. * @param func the function to run each iteration
  42165. * @param successCallback the callback that will be called upon succesful execution
  42166. * @param offset starting offset.
  42167. */
  42168. constructor(
  42169. /**
  42170. * Defines the number of iterations for the loop
  42171. */
  42172. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42173. /**
  42174. * Execute the next iteration. Must be called after the last iteration was finished.
  42175. */
  42176. executeNext(): void;
  42177. /**
  42178. * Break the loop and run the success callback.
  42179. */
  42180. breakLoop(): void;
  42181. /**
  42182. * Create and run an async loop.
  42183. * @param iterations the number of iterations.
  42184. * @param fn the function to run each iteration
  42185. * @param successCallback the callback that will be called upon succesful execution
  42186. * @param offset starting offset.
  42187. * @returns the created async loop object
  42188. */
  42189. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42190. /**
  42191. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42192. * @param iterations total number of iterations
  42193. * @param syncedIterations number of synchronous iterations in each async iteration.
  42194. * @param fn the function to call each iteration.
  42195. * @param callback a success call back that will be called when iterating stops.
  42196. * @param breakFunction a break condition (optional)
  42197. * @param timeout timeout settings for the setTimeout function. default - 0.
  42198. * @returns the created async loop object
  42199. */
  42200. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42201. }
  42202. }
  42203. declare module BABYLON {
  42204. /**
  42205. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42206. * The underlying implementation relies on an associative array to ensure the best performances.
  42207. * The value can be anything including 'null' but except 'undefined'
  42208. */
  42209. export class StringDictionary<T> {
  42210. /**
  42211. * This will clear this dictionary and copy the content from the 'source' one.
  42212. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42213. * @param source the dictionary to take the content from and copy to this dictionary
  42214. */
  42215. copyFrom(source: StringDictionary<T>): void;
  42216. /**
  42217. * Get a value based from its key
  42218. * @param key the given key to get the matching value from
  42219. * @return the value if found, otherwise undefined is returned
  42220. */
  42221. get(key: string): T | undefined;
  42222. /**
  42223. * Get a value from its key or add it if it doesn't exist.
  42224. * This method will ensure you that a given key/data will be present in the dictionary.
  42225. * @param key the given key to get the matching value from
  42226. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42227. * The factory will only be invoked if there's no data for the given key.
  42228. * @return the value corresponding to the key.
  42229. */
  42230. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42231. /**
  42232. * Get a value from its key if present in the dictionary otherwise add it
  42233. * @param key the key to get the value from
  42234. * @param val if there's no such key/value pair in the dictionary add it with this value
  42235. * @return the value corresponding to the key
  42236. */
  42237. getOrAdd(key: string, val: T): T;
  42238. /**
  42239. * Check if there's a given key in the dictionary
  42240. * @param key the key to check for
  42241. * @return true if the key is present, false otherwise
  42242. */
  42243. contains(key: string): boolean;
  42244. /**
  42245. * Add a new key and its corresponding value
  42246. * @param key the key to add
  42247. * @param value the value corresponding to the key
  42248. * @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
  42249. */
  42250. add(key: string, value: T): boolean;
  42251. /**
  42252. * Update a specific value associated to a key
  42253. * @param key defines the key to use
  42254. * @param value defines the value to store
  42255. * @returns true if the value was updated (or false if the key was not found)
  42256. */
  42257. set(key: string, value: T): boolean;
  42258. /**
  42259. * Get the element of the given key and remove it from the dictionary
  42260. * @param key defines the key to search
  42261. * @returns the value associated with the key or null if not found
  42262. */
  42263. getAndRemove(key: string): Nullable<T>;
  42264. /**
  42265. * Remove a key/value from the dictionary.
  42266. * @param key the key to remove
  42267. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42268. */
  42269. remove(key: string): boolean;
  42270. /**
  42271. * Clear the whole content of the dictionary
  42272. */
  42273. clear(): void;
  42274. /**
  42275. * Gets the current count
  42276. */
  42277. get count(): number;
  42278. /**
  42279. * Execute a callback on each key/val of the dictionary.
  42280. * Note that you can remove any element in this dictionary in the callback implementation
  42281. * @param callback the callback to execute on a given key/value pair
  42282. */
  42283. forEach(callback: (key: string, val: T) => void): void;
  42284. /**
  42285. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42286. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42287. * Note that you can remove any element in this dictionary in the callback implementation
  42288. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42289. * @returns the first item
  42290. */
  42291. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42292. private _count;
  42293. private _data;
  42294. }
  42295. }
  42296. declare module BABYLON {
  42297. /** @hidden */
  42298. export interface ICollisionCoordinator {
  42299. createCollider(): Collider;
  42300. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42301. init(scene: Scene): void;
  42302. }
  42303. /** @hidden */
  42304. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42305. private _scene;
  42306. private _scaledPosition;
  42307. private _scaledVelocity;
  42308. private _finalPosition;
  42309. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42310. createCollider(): Collider;
  42311. init(scene: Scene): void;
  42312. private _collideWithWorld;
  42313. }
  42314. }
  42315. declare module BABYLON {
  42316. /**
  42317. * Class used to manage all inputs for the scene.
  42318. */
  42319. export class InputManager {
  42320. /** The distance in pixel that you have to move to prevent some events */
  42321. static DragMovementThreshold: number;
  42322. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42323. static LongPressDelay: number;
  42324. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42325. static DoubleClickDelay: number;
  42326. /** If you need to check double click without raising a single click at first click, enable this flag */
  42327. static ExclusiveDoubleClickMode: boolean;
  42328. /** 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. */
  42329. private _alreadyAttached;
  42330. private _alreadyAttachedTo;
  42331. private _wheelEventName;
  42332. private _onPointerMove;
  42333. private _onPointerDown;
  42334. private _onPointerUp;
  42335. private _initClickEvent;
  42336. private _initActionManager;
  42337. private _delayedSimpleClick;
  42338. private _delayedSimpleClickTimeout;
  42339. private _previousDelayedSimpleClickTimeout;
  42340. private _meshPickProceed;
  42341. private _previousButtonPressed;
  42342. private _currentPickResult;
  42343. private _previousPickResult;
  42344. private _totalPointersPressed;
  42345. private _doubleClickOccured;
  42346. private _pointerOverMesh;
  42347. private _pickedDownMesh;
  42348. private _pickedUpMesh;
  42349. private _pointerX;
  42350. private _pointerY;
  42351. private _unTranslatedPointerX;
  42352. private _unTranslatedPointerY;
  42353. private _startingPointerPosition;
  42354. private _previousStartingPointerPosition;
  42355. private _startingPointerTime;
  42356. private _previousStartingPointerTime;
  42357. private _pointerCaptures;
  42358. private _meshUnderPointerId;
  42359. private _onKeyDown;
  42360. private _onKeyUp;
  42361. private _keyboardIsAttached;
  42362. private _onCanvasFocusObserver;
  42363. private _onCanvasBlurObserver;
  42364. private _scene;
  42365. /**
  42366. * Creates a new InputManager
  42367. * @param scene defines the hosting scene
  42368. */
  42369. constructor(scene: Scene);
  42370. /**
  42371. * Gets the mesh that is currently under the pointer
  42372. */
  42373. get meshUnderPointer(): Nullable<AbstractMesh>;
  42374. /**
  42375. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42376. * @param pointerId the pointer id to use
  42377. * @returns The mesh under this pointer id or null if not found
  42378. */
  42379. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42380. /**
  42381. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42382. */
  42383. get unTranslatedPointer(): Vector2;
  42384. /**
  42385. * Gets or sets the current on-screen X position of the pointer
  42386. */
  42387. get pointerX(): number;
  42388. set pointerX(value: number);
  42389. /**
  42390. * Gets or sets the current on-screen Y position of the pointer
  42391. */
  42392. get pointerY(): number;
  42393. set pointerY(value: number);
  42394. private _updatePointerPosition;
  42395. private _processPointerMove;
  42396. private _setRayOnPointerInfo;
  42397. private _checkPrePointerObservable;
  42398. /**
  42399. * Use this method to simulate a pointer move on a mesh
  42400. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42401. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42402. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42403. */
  42404. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42405. /**
  42406. * Use this method to simulate a pointer down on a mesh
  42407. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42408. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42409. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42410. */
  42411. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42412. private _processPointerDown;
  42413. /** @hidden */
  42414. _isPointerSwiping(): boolean;
  42415. /**
  42416. * Use this method to simulate a pointer up on a mesh
  42417. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42418. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42419. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42420. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42421. */
  42422. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42423. private _processPointerUp;
  42424. /**
  42425. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42426. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42427. * @returns true if the pointer was captured
  42428. */
  42429. isPointerCaptured(pointerId?: number): boolean;
  42430. /**
  42431. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42432. * @param attachUp defines if you want to attach events to pointerup
  42433. * @param attachDown defines if you want to attach events to pointerdown
  42434. * @param attachMove defines if you want to attach events to pointermove
  42435. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42436. */
  42437. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42438. /**
  42439. * Detaches all event handlers
  42440. */
  42441. detachControl(): void;
  42442. /**
  42443. * Force the value of meshUnderPointer
  42444. * @param mesh defines the mesh to use
  42445. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42446. */
  42447. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42448. /**
  42449. * Gets the mesh under the pointer
  42450. * @returns a Mesh or null if no mesh is under the pointer
  42451. */
  42452. getPointerOverMesh(): Nullable<AbstractMesh>;
  42453. }
  42454. }
  42455. declare module BABYLON {
  42456. /**
  42457. * This class defines the direct association between an animation and a target
  42458. */
  42459. export class TargetedAnimation {
  42460. /**
  42461. * Animation to perform
  42462. */
  42463. animation: Animation;
  42464. /**
  42465. * Target to animate
  42466. */
  42467. target: any;
  42468. /**
  42469. * Returns the string "TargetedAnimation"
  42470. * @returns "TargetedAnimation"
  42471. */
  42472. getClassName(): string;
  42473. /**
  42474. * Serialize the object
  42475. * @returns the JSON object representing the current entity
  42476. */
  42477. serialize(): any;
  42478. }
  42479. /**
  42480. * Use this class to create coordinated animations on multiple targets
  42481. */
  42482. export class AnimationGroup implements IDisposable {
  42483. /** The name of the animation group */
  42484. name: string;
  42485. private _scene;
  42486. private _targetedAnimations;
  42487. private _animatables;
  42488. private _from;
  42489. private _to;
  42490. private _isStarted;
  42491. private _isPaused;
  42492. private _speedRatio;
  42493. private _loopAnimation;
  42494. private _isAdditive;
  42495. /**
  42496. * Gets or sets the unique id of the node
  42497. */
  42498. uniqueId: number;
  42499. /**
  42500. * This observable will notify when one animation have ended
  42501. */
  42502. onAnimationEndObservable: Observable<TargetedAnimation>;
  42503. /**
  42504. * Observer raised when one animation loops
  42505. */
  42506. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42507. /**
  42508. * Observer raised when all animations have looped
  42509. */
  42510. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42511. /**
  42512. * This observable will notify when all animations have ended.
  42513. */
  42514. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42515. /**
  42516. * This observable will notify when all animations have paused.
  42517. */
  42518. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42519. /**
  42520. * This observable will notify when all animations are playing.
  42521. */
  42522. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42523. /**
  42524. * Gets the first frame
  42525. */
  42526. get from(): number;
  42527. /**
  42528. * Gets the last frame
  42529. */
  42530. get to(): number;
  42531. /**
  42532. * Define if the animations are started
  42533. */
  42534. get isStarted(): boolean;
  42535. /**
  42536. * Gets a value indicating that the current group is playing
  42537. */
  42538. get isPlaying(): boolean;
  42539. /**
  42540. * Gets or sets the speed ratio to use for all animations
  42541. */
  42542. get speedRatio(): number;
  42543. /**
  42544. * Gets or sets the speed ratio to use for all animations
  42545. */
  42546. set speedRatio(value: number);
  42547. /**
  42548. * Gets or sets if all animations should loop or not
  42549. */
  42550. get loopAnimation(): boolean;
  42551. set loopAnimation(value: boolean);
  42552. /**
  42553. * Gets or sets if all animations should be evaluated additively
  42554. */
  42555. get isAdditive(): boolean;
  42556. set isAdditive(value: boolean);
  42557. /**
  42558. * Gets the targeted animations for this animation group
  42559. */
  42560. get targetedAnimations(): Array<TargetedAnimation>;
  42561. /**
  42562. * returning the list of animatables controlled by this animation group.
  42563. */
  42564. get animatables(): Array<Animatable>;
  42565. /**
  42566. * Gets the list of target animations
  42567. */
  42568. get children(): TargetedAnimation[];
  42569. /**
  42570. * Instantiates a new Animation Group.
  42571. * This helps managing several animations at once.
  42572. * @see https://doc.babylonjs.com/how_to/group
  42573. * @param name Defines the name of the group
  42574. * @param scene Defines the scene the group belongs to
  42575. */
  42576. constructor(
  42577. /** The name of the animation group */
  42578. name: string, scene?: Nullable<Scene>);
  42579. /**
  42580. * Add an animation (with its target) in the group
  42581. * @param animation defines the animation we want to add
  42582. * @param target defines the target of the animation
  42583. * @returns the TargetedAnimation object
  42584. */
  42585. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42586. /**
  42587. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42588. * It can add constant keys at begin or end
  42589. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42590. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42591. * @returns the animation group
  42592. */
  42593. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42594. private _animationLoopCount;
  42595. private _animationLoopFlags;
  42596. private _processLoop;
  42597. /**
  42598. * Start all animations on given targets
  42599. * @param loop defines if animations must loop
  42600. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42601. * @param from defines the from key (optional)
  42602. * @param to defines the to key (optional)
  42603. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42604. * @returns the current animation group
  42605. */
  42606. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42607. /**
  42608. * Pause all animations
  42609. * @returns the animation group
  42610. */
  42611. pause(): AnimationGroup;
  42612. /**
  42613. * Play all animations to initial state
  42614. * This function will start() the animations if they were not started or will restart() them if they were paused
  42615. * @param loop defines if animations must loop
  42616. * @returns the animation group
  42617. */
  42618. play(loop?: boolean): AnimationGroup;
  42619. /**
  42620. * Reset all animations to initial state
  42621. * @returns the animation group
  42622. */
  42623. reset(): AnimationGroup;
  42624. /**
  42625. * Restart animations from key 0
  42626. * @returns the animation group
  42627. */
  42628. restart(): AnimationGroup;
  42629. /**
  42630. * Stop all animations
  42631. * @returns the animation group
  42632. */
  42633. stop(): AnimationGroup;
  42634. /**
  42635. * Set animation weight for all animatables
  42636. * @param weight defines the weight to use
  42637. * @return the animationGroup
  42638. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42639. */
  42640. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42641. /**
  42642. * Synchronize and normalize all animatables with a source animatable
  42643. * @param root defines the root animatable to synchronize with
  42644. * @return the animationGroup
  42645. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42646. */
  42647. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42648. /**
  42649. * Goes to a specific frame in this animation group
  42650. * @param frame the frame number to go to
  42651. * @return the animationGroup
  42652. */
  42653. goToFrame(frame: number): AnimationGroup;
  42654. /**
  42655. * Dispose all associated resources
  42656. */
  42657. dispose(): void;
  42658. private _checkAnimationGroupEnded;
  42659. /**
  42660. * Clone the current animation group and returns a copy
  42661. * @param newName defines the name of the new group
  42662. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42663. * @returns the new aniamtion group
  42664. */
  42665. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42666. /**
  42667. * Serializes the animationGroup to an object
  42668. * @returns Serialized object
  42669. */
  42670. serialize(): any;
  42671. /**
  42672. * Returns a new AnimationGroup object parsed from the source provided.
  42673. * @param parsedAnimationGroup defines the source
  42674. * @param scene defines the scene that will receive the animationGroup
  42675. * @returns a new AnimationGroup
  42676. */
  42677. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42678. /**
  42679. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42680. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42681. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42682. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42683. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42684. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42685. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42686. */
  42687. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42688. /**
  42689. * Returns the string "AnimationGroup"
  42690. * @returns "AnimationGroup"
  42691. */
  42692. getClassName(): string;
  42693. /**
  42694. * Creates a detailled string about the object
  42695. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42696. * @returns a string representing the object
  42697. */
  42698. toString(fullDetails?: boolean): string;
  42699. }
  42700. }
  42701. declare module BABYLON {
  42702. /**
  42703. * Define an interface for all classes that will hold resources
  42704. */
  42705. export interface IDisposable {
  42706. /**
  42707. * Releases all held resources
  42708. */
  42709. dispose(): void;
  42710. }
  42711. /** Interface defining initialization parameters for Scene class */
  42712. export interface SceneOptions {
  42713. /**
  42714. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42715. * It will improve performance when the number of geometries becomes important.
  42716. */
  42717. useGeometryUniqueIdsMap?: boolean;
  42718. /**
  42719. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42720. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42721. */
  42722. useMaterialMeshMap?: boolean;
  42723. /**
  42724. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42725. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42726. */
  42727. useClonedMeshMap?: boolean;
  42728. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42729. virtual?: boolean;
  42730. }
  42731. /**
  42732. * Represents a scene to be rendered by the engine.
  42733. * @see https://doc.babylonjs.com/features/scene
  42734. */
  42735. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42736. /** The fog is deactivated */
  42737. static readonly FOGMODE_NONE: number;
  42738. /** The fog density is following an exponential function */
  42739. static readonly FOGMODE_EXP: number;
  42740. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42741. static readonly FOGMODE_EXP2: number;
  42742. /** The fog density is following a linear function. */
  42743. static readonly FOGMODE_LINEAR: number;
  42744. /**
  42745. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42746. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42747. */
  42748. static MinDeltaTime: number;
  42749. /**
  42750. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42751. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42752. */
  42753. static MaxDeltaTime: number;
  42754. /**
  42755. * Factory used to create the default material.
  42756. * @param name The name of the material to create
  42757. * @param scene The scene to create the material for
  42758. * @returns The default material
  42759. */
  42760. static DefaultMaterialFactory(scene: Scene): Material;
  42761. /**
  42762. * Factory used to create the a collision coordinator.
  42763. * @returns The collision coordinator
  42764. */
  42765. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42766. /** @hidden */
  42767. _inputManager: InputManager;
  42768. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42769. cameraToUseForPointers: Nullable<Camera>;
  42770. /** @hidden */
  42771. readonly _isScene: boolean;
  42772. /** @hidden */
  42773. _blockEntityCollection: boolean;
  42774. /**
  42775. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42776. */
  42777. autoClear: boolean;
  42778. /**
  42779. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42780. */
  42781. autoClearDepthAndStencil: boolean;
  42782. /**
  42783. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42784. */
  42785. clearColor: Color4;
  42786. /**
  42787. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42788. */
  42789. ambientColor: Color3;
  42790. /**
  42791. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42792. * It should only be one of the following (if not the default embedded one):
  42793. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42794. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42795. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42796. * The material properties need to be setup according to the type of texture in use.
  42797. */
  42798. environmentBRDFTexture: BaseTexture;
  42799. /**
  42800. * Texture used in all pbr material as the reflection texture.
  42801. * As in the majority of the scene they are the same (exception for multi room and so on),
  42802. * this is easier to reference from here than from all the materials.
  42803. */
  42804. get environmentTexture(): Nullable<BaseTexture>;
  42805. /**
  42806. * Texture used in all pbr material as the reflection texture.
  42807. * As in the majority of the scene they are the same (exception for multi room and so on),
  42808. * this is easier to set here than in all the materials.
  42809. */
  42810. set environmentTexture(value: Nullable<BaseTexture>);
  42811. /** @hidden */
  42812. protected _environmentIntensity: number;
  42813. /**
  42814. * Intensity of the environment in all pbr material.
  42815. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42816. * As in the majority of the scene they are the same (exception for multi room and so on),
  42817. * this is easier to reference from here than from all the materials.
  42818. */
  42819. get environmentIntensity(): number;
  42820. /**
  42821. * Intensity of the environment in all pbr material.
  42822. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42823. * As in the majority of the scene they are the same (exception for multi room and so on),
  42824. * this is easier to set here than in all the materials.
  42825. */
  42826. set environmentIntensity(value: number);
  42827. /** @hidden */
  42828. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42829. /**
  42830. * Default image processing configuration used either in the rendering
  42831. * Forward main pass or through the imageProcessingPostProcess if present.
  42832. * As in the majority of the scene they are the same (exception for multi camera),
  42833. * this is easier to reference from here than from all the materials and post process.
  42834. *
  42835. * No setter as we it is a shared configuration, you can set the values instead.
  42836. */
  42837. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42838. private _forceWireframe;
  42839. /**
  42840. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42841. */
  42842. set forceWireframe(value: boolean);
  42843. get forceWireframe(): boolean;
  42844. private _skipFrustumClipping;
  42845. /**
  42846. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42847. */
  42848. set skipFrustumClipping(value: boolean);
  42849. get skipFrustumClipping(): boolean;
  42850. private _forcePointsCloud;
  42851. /**
  42852. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42853. */
  42854. set forcePointsCloud(value: boolean);
  42855. get forcePointsCloud(): boolean;
  42856. /**
  42857. * Gets or sets the active clipplane 1
  42858. */
  42859. clipPlane: Nullable<Plane>;
  42860. /**
  42861. * Gets or sets the active clipplane 2
  42862. */
  42863. clipPlane2: Nullable<Plane>;
  42864. /**
  42865. * Gets or sets the active clipplane 3
  42866. */
  42867. clipPlane3: Nullable<Plane>;
  42868. /**
  42869. * Gets or sets the active clipplane 4
  42870. */
  42871. clipPlane4: Nullable<Plane>;
  42872. /**
  42873. * Gets or sets the active clipplane 5
  42874. */
  42875. clipPlane5: Nullable<Plane>;
  42876. /**
  42877. * Gets or sets the active clipplane 6
  42878. */
  42879. clipPlane6: Nullable<Plane>;
  42880. /**
  42881. * Gets or sets a boolean indicating if animations are enabled
  42882. */
  42883. animationsEnabled: boolean;
  42884. private _animationPropertiesOverride;
  42885. /**
  42886. * Gets or sets the animation properties override
  42887. */
  42888. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42889. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42890. /**
  42891. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42892. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42893. */
  42894. useConstantAnimationDeltaTime: boolean;
  42895. /**
  42896. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42897. * Please note that it requires to run a ray cast through the scene on every frame
  42898. */
  42899. constantlyUpdateMeshUnderPointer: boolean;
  42900. /**
  42901. * Defines the HTML cursor to use when hovering over interactive elements
  42902. */
  42903. hoverCursor: string;
  42904. /**
  42905. * Defines the HTML default cursor to use (empty by default)
  42906. */
  42907. defaultCursor: string;
  42908. /**
  42909. * Defines whether cursors are handled by the scene.
  42910. */
  42911. doNotHandleCursors: boolean;
  42912. /**
  42913. * This is used to call preventDefault() on pointer down
  42914. * in order to block unwanted artifacts like system double clicks
  42915. */
  42916. preventDefaultOnPointerDown: boolean;
  42917. /**
  42918. * This is used to call preventDefault() on pointer up
  42919. * in order to block unwanted artifacts like system double clicks
  42920. */
  42921. preventDefaultOnPointerUp: boolean;
  42922. /**
  42923. * Gets or sets user defined metadata
  42924. */
  42925. metadata: any;
  42926. /**
  42927. * For internal use only. Please do not use.
  42928. */
  42929. reservedDataStore: any;
  42930. /**
  42931. * Gets the name of the plugin used to load this scene (null by default)
  42932. */
  42933. loadingPluginName: string;
  42934. /**
  42935. * Use this array to add regular expressions used to disable offline support for specific urls
  42936. */
  42937. disableOfflineSupportExceptionRules: RegExp[];
  42938. /**
  42939. * An event triggered when the scene is disposed.
  42940. */
  42941. onDisposeObservable: Observable<Scene>;
  42942. private _onDisposeObserver;
  42943. /** Sets a function to be executed when this scene is disposed. */
  42944. set onDispose(callback: () => void);
  42945. /**
  42946. * An event triggered before rendering the scene (right after animations and physics)
  42947. */
  42948. onBeforeRenderObservable: Observable<Scene>;
  42949. private _onBeforeRenderObserver;
  42950. /** Sets a function to be executed before rendering this scene */
  42951. set beforeRender(callback: Nullable<() => void>);
  42952. /**
  42953. * An event triggered after rendering the scene
  42954. */
  42955. onAfterRenderObservable: Observable<Scene>;
  42956. /**
  42957. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42958. */
  42959. onAfterRenderCameraObservable: Observable<Camera>;
  42960. private _onAfterRenderObserver;
  42961. /** Sets a function to be executed after rendering this scene */
  42962. set afterRender(callback: Nullable<() => void>);
  42963. /**
  42964. * An event triggered before animating the scene
  42965. */
  42966. onBeforeAnimationsObservable: Observable<Scene>;
  42967. /**
  42968. * An event triggered after animations processing
  42969. */
  42970. onAfterAnimationsObservable: Observable<Scene>;
  42971. /**
  42972. * An event triggered before draw calls are ready to be sent
  42973. */
  42974. onBeforeDrawPhaseObservable: Observable<Scene>;
  42975. /**
  42976. * An event triggered after draw calls have been sent
  42977. */
  42978. onAfterDrawPhaseObservable: Observable<Scene>;
  42979. /**
  42980. * An event triggered when the scene is ready
  42981. */
  42982. onReadyObservable: Observable<Scene>;
  42983. /**
  42984. * An event triggered before rendering a camera
  42985. */
  42986. onBeforeCameraRenderObservable: Observable<Camera>;
  42987. private _onBeforeCameraRenderObserver;
  42988. /** Sets a function to be executed before rendering a camera*/
  42989. set beforeCameraRender(callback: () => void);
  42990. /**
  42991. * An event triggered after rendering a camera
  42992. */
  42993. onAfterCameraRenderObservable: Observable<Camera>;
  42994. private _onAfterCameraRenderObserver;
  42995. /** Sets a function to be executed after rendering a camera*/
  42996. set afterCameraRender(callback: () => void);
  42997. /**
  42998. * An event triggered when active meshes evaluation is about to start
  42999. */
  43000. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  43001. /**
  43002. * An event triggered when active meshes evaluation is done
  43003. */
  43004. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  43005. /**
  43006. * An event triggered when particles rendering is about to start
  43007. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43008. */
  43009. onBeforeParticlesRenderingObservable: Observable<Scene>;
  43010. /**
  43011. * An event triggered when particles rendering is done
  43012. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43013. */
  43014. onAfterParticlesRenderingObservable: Observable<Scene>;
  43015. /**
  43016. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  43017. */
  43018. onDataLoadedObservable: Observable<Scene>;
  43019. /**
  43020. * An event triggered when a camera is created
  43021. */
  43022. onNewCameraAddedObservable: Observable<Camera>;
  43023. /**
  43024. * An event triggered when a camera is removed
  43025. */
  43026. onCameraRemovedObservable: Observable<Camera>;
  43027. /**
  43028. * An event triggered when a light is created
  43029. */
  43030. onNewLightAddedObservable: Observable<Light>;
  43031. /**
  43032. * An event triggered when a light is removed
  43033. */
  43034. onLightRemovedObservable: Observable<Light>;
  43035. /**
  43036. * An event triggered when a geometry is created
  43037. */
  43038. onNewGeometryAddedObservable: Observable<Geometry>;
  43039. /**
  43040. * An event triggered when a geometry is removed
  43041. */
  43042. onGeometryRemovedObservable: Observable<Geometry>;
  43043. /**
  43044. * An event triggered when a transform node is created
  43045. */
  43046. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  43047. /**
  43048. * An event triggered when a transform node is removed
  43049. */
  43050. onTransformNodeRemovedObservable: Observable<TransformNode>;
  43051. /**
  43052. * An event triggered when a mesh is created
  43053. */
  43054. onNewMeshAddedObservable: Observable<AbstractMesh>;
  43055. /**
  43056. * An event triggered when a mesh is removed
  43057. */
  43058. onMeshRemovedObservable: Observable<AbstractMesh>;
  43059. /**
  43060. * An event triggered when a skeleton is created
  43061. */
  43062. onNewSkeletonAddedObservable: Observable<Skeleton>;
  43063. /**
  43064. * An event triggered when a skeleton is removed
  43065. */
  43066. onSkeletonRemovedObservable: Observable<Skeleton>;
  43067. /**
  43068. * An event triggered when a material is created
  43069. */
  43070. onNewMaterialAddedObservable: Observable<Material>;
  43071. /**
  43072. * An event triggered when a multi material is created
  43073. */
  43074. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  43075. /**
  43076. * An event triggered when a material is removed
  43077. */
  43078. onMaterialRemovedObservable: Observable<Material>;
  43079. /**
  43080. * An event triggered when a multi material is removed
  43081. */
  43082. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  43083. /**
  43084. * An event triggered when a texture is created
  43085. */
  43086. onNewTextureAddedObservable: Observable<BaseTexture>;
  43087. /**
  43088. * An event triggered when a texture is removed
  43089. */
  43090. onTextureRemovedObservable: Observable<BaseTexture>;
  43091. /**
  43092. * An event triggered when render targets are about to be rendered
  43093. * Can happen multiple times per frame.
  43094. */
  43095. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  43096. /**
  43097. * An event triggered when render targets were rendered.
  43098. * Can happen multiple times per frame.
  43099. */
  43100. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  43101. /**
  43102. * An event triggered before calculating deterministic simulation step
  43103. */
  43104. onBeforeStepObservable: Observable<Scene>;
  43105. /**
  43106. * An event triggered after calculating deterministic simulation step
  43107. */
  43108. onAfterStepObservable: Observable<Scene>;
  43109. /**
  43110. * An event triggered when the activeCamera property is updated
  43111. */
  43112. onActiveCameraChanged: Observable<Scene>;
  43113. /**
  43114. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  43115. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43116. * 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)
  43117. */
  43118. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43119. /**
  43120. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  43121. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43122. * 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)
  43123. */
  43124. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43125. /**
  43126. * This Observable will when a mesh has been imported into the scene.
  43127. */
  43128. onMeshImportedObservable: Observable<AbstractMesh>;
  43129. /**
  43130. * This Observable will when an animation file has been imported into the scene.
  43131. */
  43132. onAnimationFileImportedObservable: Observable<Scene>;
  43133. /**
  43134. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43135. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43136. */
  43137. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43138. /** @hidden */
  43139. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43140. /**
  43141. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43142. */
  43143. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43144. /**
  43145. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43146. */
  43147. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43148. /**
  43149. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43150. */
  43151. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43152. /** Callback called when a pointer move is detected */
  43153. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43154. /** Callback called when a pointer down is detected */
  43155. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43156. /** Callback called when a pointer up is detected */
  43157. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43158. /** Callback called when a pointer pick is detected */
  43159. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43160. /**
  43161. * 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).
  43162. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43163. */
  43164. onPrePointerObservable: Observable<PointerInfoPre>;
  43165. /**
  43166. * Observable event triggered each time an input event is received from the rendering canvas
  43167. */
  43168. onPointerObservable: Observable<PointerInfo>;
  43169. /**
  43170. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43171. */
  43172. get unTranslatedPointer(): Vector2;
  43173. /**
  43174. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43175. */
  43176. static get DragMovementThreshold(): number;
  43177. static set DragMovementThreshold(value: number);
  43178. /**
  43179. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43180. */
  43181. static get LongPressDelay(): number;
  43182. static set LongPressDelay(value: number);
  43183. /**
  43184. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43185. */
  43186. static get DoubleClickDelay(): number;
  43187. static set DoubleClickDelay(value: number);
  43188. /** If you need to check double click without raising a single click at first click, enable this flag */
  43189. static get ExclusiveDoubleClickMode(): boolean;
  43190. static set ExclusiveDoubleClickMode(value: boolean);
  43191. /** @hidden */
  43192. _mirroredCameraPosition: Nullable<Vector3>;
  43193. /**
  43194. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43195. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43196. */
  43197. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43198. /**
  43199. * Observable event triggered each time an keyboard event is received from the hosting window
  43200. */
  43201. onKeyboardObservable: Observable<KeyboardInfo>;
  43202. private _useRightHandedSystem;
  43203. /**
  43204. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43205. */
  43206. set useRightHandedSystem(value: boolean);
  43207. get useRightHandedSystem(): boolean;
  43208. private _timeAccumulator;
  43209. private _currentStepId;
  43210. private _currentInternalStep;
  43211. /**
  43212. * Sets the step Id used by deterministic lock step
  43213. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43214. * @param newStepId defines the step Id
  43215. */
  43216. setStepId(newStepId: number): void;
  43217. /**
  43218. * Gets the step Id used by deterministic lock step
  43219. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43220. * @returns the step Id
  43221. */
  43222. getStepId(): number;
  43223. /**
  43224. * Gets the internal step used by deterministic lock step
  43225. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43226. * @returns the internal step
  43227. */
  43228. getInternalStep(): number;
  43229. private _fogEnabled;
  43230. /**
  43231. * Gets or sets a boolean indicating if fog is enabled on this scene
  43232. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43233. * (Default is true)
  43234. */
  43235. set fogEnabled(value: boolean);
  43236. get fogEnabled(): boolean;
  43237. private _fogMode;
  43238. /**
  43239. * Gets or sets the fog mode to use
  43240. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43241. * | mode | value |
  43242. * | --- | --- |
  43243. * | FOGMODE_NONE | 0 |
  43244. * | FOGMODE_EXP | 1 |
  43245. * | FOGMODE_EXP2 | 2 |
  43246. * | FOGMODE_LINEAR | 3 |
  43247. */
  43248. set fogMode(value: number);
  43249. get fogMode(): number;
  43250. /**
  43251. * Gets or sets the fog color to use
  43252. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43253. * (Default is Color3(0.2, 0.2, 0.3))
  43254. */
  43255. fogColor: Color3;
  43256. /**
  43257. * Gets or sets the fog density to use
  43258. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43259. * (Default is 0.1)
  43260. */
  43261. fogDensity: number;
  43262. /**
  43263. * Gets or sets the fog start distance to use
  43264. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43265. * (Default is 0)
  43266. */
  43267. fogStart: number;
  43268. /**
  43269. * Gets or sets the fog end distance to use
  43270. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43271. * (Default is 1000)
  43272. */
  43273. fogEnd: number;
  43274. /**
  43275. * Flag indicating that the frame buffer binding is handled by another component
  43276. */
  43277. prePass: boolean;
  43278. private _shadowsEnabled;
  43279. /**
  43280. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43281. */
  43282. set shadowsEnabled(value: boolean);
  43283. get shadowsEnabled(): boolean;
  43284. private _lightsEnabled;
  43285. /**
  43286. * Gets or sets a boolean indicating if lights are enabled on this scene
  43287. */
  43288. set lightsEnabled(value: boolean);
  43289. get lightsEnabled(): boolean;
  43290. /** All of the active cameras added to this scene. */
  43291. activeCameras: Camera[];
  43292. /** @hidden */
  43293. _activeCamera: Nullable<Camera>;
  43294. /** Gets or sets the current active camera */
  43295. get activeCamera(): Nullable<Camera>;
  43296. set activeCamera(value: Nullable<Camera>);
  43297. private _defaultMaterial;
  43298. /** The default material used on meshes when no material is affected */
  43299. get defaultMaterial(): Material;
  43300. /** The default material used on meshes when no material is affected */
  43301. set defaultMaterial(value: Material);
  43302. private _texturesEnabled;
  43303. /**
  43304. * Gets or sets a boolean indicating if textures are enabled on this scene
  43305. */
  43306. set texturesEnabled(value: boolean);
  43307. get texturesEnabled(): boolean;
  43308. /**
  43309. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43310. */
  43311. physicsEnabled: boolean;
  43312. /**
  43313. * Gets or sets a boolean indicating if particles are enabled on this scene
  43314. */
  43315. particlesEnabled: boolean;
  43316. /**
  43317. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43318. */
  43319. spritesEnabled: boolean;
  43320. private _skeletonsEnabled;
  43321. /**
  43322. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43323. */
  43324. set skeletonsEnabled(value: boolean);
  43325. get skeletonsEnabled(): boolean;
  43326. /**
  43327. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43328. */
  43329. lensFlaresEnabled: boolean;
  43330. /**
  43331. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43332. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43333. */
  43334. collisionsEnabled: boolean;
  43335. private _collisionCoordinator;
  43336. /** @hidden */
  43337. get collisionCoordinator(): ICollisionCoordinator;
  43338. /**
  43339. * Defines the gravity applied to this scene (used only for collisions)
  43340. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43341. */
  43342. gravity: Vector3;
  43343. /**
  43344. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43345. */
  43346. postProcessesEnabled: boolean;
  43347. /**
  43348. * Gets the current postprocess manager
  43349. */
  43350. postProcessManager: PostProcessManager;
  43351. /**
  43352. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43353. */
  43354. renderTargetsEnabled: boolean;
  43355. /**
  43356. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43357. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43358. */
  43359. dumpNextRenderTargets: boolean;
  43360. /**
  43361. * The list of user defined render targets added to the scene
  43362. */
  43363. customRenderTargets: RenderTargetTexture[];
  43364. /**
  43365. * Defines if texture loading must be delayed
  43366. * If true, textures will only be loaded when they need to be rendered
  43367. */
  43368. useDelayedTextureLoading: boolean;
  43369. /**
  43370. * Gets the list of meshes imported to the scene through SceneLoader
  43371. */
  43372. importedMeshesFiles: String[];
  43373. /**
  43374. * Gets or sets a boolean indicating if probes are enabled on this scene
  43375. */
  43376. probesEnabled: boolean;
  43377. /**
  43378. * Gets or sets the current offline provider to use to store scene data
  43379. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43380. */
  43381. offlineProvider: IOfflineProvider;
  43382. /**
  43383. * Gets or sets the action manager associated with the scene
  43384. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43385. */
  43386. actionManager: AbstractActionManager;
  43387. private _meshesForIntersections;
  43388. /**
  43389. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43390. */
  43391. proceduralTexturesEnabled: boolean;
  43392. private _engine;
  43393. private _totalVertices;
  43394. /** @hidden */
  43395. _activeIndices: PerfCounter;
  43396. /** @hidden */
  43397. _activeParticles: PerfCounter;
  43398. /** @hidden */
  43399. _activeBones: PerfCounter;
  43400. private _animationRatio;
  43401. /** @hidden */
  43402. _animationTimeLast: number;
  43403. /** @hidden */
  43404. _animationTime: number;
  43405. /**
  43406. * Gets or sets a general scale for animation speed
  43407. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43408. */
  43409. animationTimeScale: number;
  43410. /** @hidden */
  43411. _cachedMaterial: Nullable<Material>;
  43412. /** @hidden */
  43413. _cachedEffect: Nullable<Effect>;
  43414. /** @hidden */
  43415. _cachedVisibility: Nullable<number>;
  43416. private _renderId;
  43417. private _frameId;
  43418. private _executeWhenReadyTimeoutId;
  43419. private _intermediateRendering;
  43420. private _viewUpdateFlag;
  43421. private _projectionUpdateFlag;
  43422. /** @hidden */
  43423. _toBeDisposed: Nullable<IDisposable>[];
  43424. private _activeRequests;
  43425. /** @hidden */
  43426. _pendingData: any[];
  43427. private _isDisposed;
  43428. /**
  43429. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43430. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43431. */
  43432. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43433. private _activeMeshes;
  43434. private _processedMaterials;
  43435. private _renderTargets;
  43436. /** @hidden */
  43437. _activeParticleSystems: SmartArray<IParticleSystem>;
  43438. private _activeSkeletons;
  43439. private _softwareSkinnedMeshes;
  43440. private _renderingManager;
  43441. /** @hidden */
  43442. _activeAnimatables: Animatable[];
  43443. private _transformMatrix;
  43444. private _sceneUbo;
  43445. /** @hidden */
  43446. _viewMatrix: Matrix;
  43447. private _projectionMatrix;
  43448. /** @hidden */
  43449. _forcedViewPosition: Nullable<Vector3>;
  43450. /** @hidden */
  43451. _frustumPlanes: Plane[];
  43452. /**
  43453. * Gets the list of frustum planes (built from the active camera)
  43454. */
  43455. get frustumPlanes(): Plane[];
  43456. /**
  43457. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43458. * This is useful if there are more lights that the maximum simulteanous authorized
  43459. */
  43460. requireLightSorting: boolean;
  43461. /** @hidden */
  43462. readonly useMaterialMeshMap: boolean;
  43463. /** @hidden */
  43464. readonly useClonedMeshMap: boolean;
  43465. private _externalData;
  43466. private _uid;
  43467. /**
  43468. * @hidden
  43469. * Backing store of defined scene components.
  43470. */
  43471. _components: ISceneComponent[];
  43472. /**
  43473. * @hidden
  43474. * Backing store of defined scene components.
  43475. */
  43476. _serializableComponents: ISceneSerializableComponent[];
  43477. /**
  43478. * List of components to register on the next registration step.
  43479. */
  43480. private _transientComponents;
  43481. /**
  43482. * Registers the transient components if needed.
  43483. */
  43484. private _registerTransientComponents;
  43485. /**
  43486. * @hidden
  43487. * Add a component to the scene.
  43488. * Note that the ccomponent could be registered on th next frame if this is called after
  43489. * the register component stage.
  43490. * @param component Defines the component to add to the scene
  43491. */
  43492. _addComponent(component: ISceneComponent): void;
  43493. /**
  43494. * @hidden
  43495. * Gets a component from the scene.
  43496. * @param name defines the name of the component to retrieve
  43497. * @returns the component or null if not present
  43498. */
  43499. _getComponent(name: string): Nullable<ISceneComponent>;
  43500. /**
  43501. * @hidden
  43502. * Defines the actions happening before camera updates.
  43503. */
  43504. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43505. /**
  43506. * @hidden
  43507. * Defines the actions happening before clear the canvas.
  43508. */
  43509. _beforeClearStage: Stage<SimpleStageAction>;
  43510. /**
  43511. * @hidden
  43512. * Defines the actions when collecting render targets for the frame.
  43513. */
  43514. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43515. /**
  43516. * @hidden
  43517. * Defines the actions happening for one camera in the frame.
  43518. */
  43519. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43520. /**
  43521. * @hidden
  43522. * Defines the actions happening during the per mesh ready checks.
  43523. */
  43524. _isReadyForMeshStage: Stage<MeshStageAction>;
  43525. /**
  43526. * @hidden
  43527. * Defines the actions happening before evaluate active mesh checks.
  43528. */
  43529. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43530. /**
  43531. * @hidden
  43532. * Defines the actions happening during the evaluate sub mesh checks.
  43533. */
  43534. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43535. /**
  43536. * @hidden
  43537. * Defines the actions happening during the active mesh stage.
  43538. */
  43539. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43540. /**
  43541. * @hidden
  43542. * Defines the actions happening during the per camera render target step.
  43543. */
  43544. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43545. /**
  43546. * @hidden
  43547. * Defines the actions happening just before the active camera is drawing.
  43548. */
  43549. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43550. /**
  43551. * @hidden
  43552. * Defines the actions happening just before a render target is drawing.
  43553. */
  43554. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43555. /**
  43556. * @hidden
  43557. * Defines the actions happening just before a rendering group is drawing.
  43558. */
  43559. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43560. /**
  43561. * @hidden
  43562. * Defines the actions happening just before a mesh is drawing.
  43563. */
  43564. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43565. /**
  43566. * @hidden
  43567. * Defines the actions happening just after a mesh has been drawn.
  43568. */
  43569. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43570. /**
  43571. * @hidden
  43572. * Defines the actions happening just after a rendering group has been drawn.
  43573. */
  43574. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43575. /**
  43576. * @hidden
  43577. * Defines the actions happening just after the active camera has been drawn.
  43578. */
  43579. _afterCameraDrawStage: Stage<CameraStageAction>;
  43580. /**
  43581. * @hidden
  43582. * Defines the actions happening just after a render target has been drawn.
  43583. */
  43584. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43585. /**
  43586. * @hidden
  43587. * Defines the actions happening just after rendering all cameras and computing intersections.
  43588. */
  43589. _afterRenderStage: Stage<SimpleStageAction>;
  43590. /**
  43591. * @hidden
  43592. * Defines the actions happening when a pointer move event happens.
  43593. */
  43594. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43595. /**
  43596. * @hidden
  43597. * Defines the actions happening when a pointer down event happens.
  43598. */
  43599. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43600. /**
  43601. * @hidden
  43602. * Defines the actions happening when a pointer up event happens.
  43603. */
  43604. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43605. /**
  43606. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43607. */
  43608. private geometriesByUniqueId;
  43609. /**
  43610. * Creates a new Scene
  43611. * @param engine defines the engine to use to render this scene
  43612. * @param options defines the scene options
  43613. */
  43614. constructor(engine: Engine, options?: SceneOptions);
  43615. /**
  43616. * Gets a string identifying the name of the class
  43617. * @returns "Scene" string
  43618. */
  43619. getClassName(): string;
  43620. private _defaultMeshCandidates;
  43621. /**
  43622. * @hidden
  43623. */
  43624. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43625. private _defaultSubMeshCandidates;
  43626. /**
  43627. * @hidden
  43628. */
  43629. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43630. /**
  43631. * Sets the default candidate providers for the scene.
  43632. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43633. * and getCollidingSubMeshCandidates to their default function
  43634. */
  43635. setDefaultCandidateProviders(): void;
  43636. /**
  43637. * Gets the mesh that is currently under the pointer
  43638. */
  43639. get meshUnderPointer(): Nullable<AbstractMesh>;
  43640. /**
  43641. * Gets or sets the current on-screen X position of the pointer
  43642. */
  43643. get pointerX(): number;
  43644. set pointerX(value: number);
  43645. /**
  43646. * Gets or sets the current on-screen Y position of the pointer
  43647. */
  43648. get pointerY(): number;
  43649. set pointerY(value: number);
  43650. /**
  43651. * Gets the cached material (ie. the latest rendered one)
  43652. * @returns the cached material
  43653. */
  43654. getCachedMaterial(): Nullable<Material>;
  43655. /**
  43656. * Gets the cached effect (ie. the latest rendered one)
  43657. * @returns the cached effect
  43658. */
  43659. getCachedEffect(): Nullable<Effect>;
  43660. /**
  43661. * Gets the cached visibility state (ie. the latest rendered one)
  43662. * @returns the cached visibility state
  43663. */
  43664. getCachedVisibility(): Nullable<number>;
  43665. /**
  43666. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43667. * @param material defines the current material
  43668. * @param effect defines the current effect
  43669. * @param visibility defines the current visibility state
  43670. * @returns true if one parameter is not cached
  43671. */
  43672. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43673. /**
  43674. * Gets the engine associated with the scene
  43675. * @returns an Engine
  43676. */
  43677. getEngine(): Engine;
  43678. /**
  43679. * Gets the total number of vertices rendered per frame
  43680. * @returns the total number of vertices rendered per frame
  43681. */
  43682. getTotalVertices(): number;
  43683. /**
  43684. * Gets the performance counter for total vertices
  43685. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43686. */
  43687. get totalVerticesPerfCounter(): PerfCounter;
  43688. /**
  43689. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43690. * @returns the total number of active indices rendered per frame
  43691. */
  43692. getActiveIndices(): number;
  43693. /**
  43694. * Gets the performance counter for active indices
  43695. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43696. */
  43697. get totalActiveIndicesPerfCounter(): PerfCounter;
  43698. /**
  43699. * Gets the total number of active particles rendered per frame
  43700. * @returns the total number of active particles rendered per frame
  43701. */
  43702. getActiveParticles(): number;
  43703. /**
  43704. * Gets the performance counter for active particles
  43705. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43706. */
  43707. get activeParticlesPerfCounter(): PerfCounter;
  43708. /**
  43709. * Gets the total number of active bones rendered per frame
  43710. * @returns the total number of active bones rendered per frame
  43711. */
  43712. getActiveBones(): number;
  43713. /**
  43714. * Gets the performance counter for active bones
  43715. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43716. */
  43717. get activeBonesPerfCounter(): PerfCounter;
  43718. /**
  43719. * Gets the array of active meshes
  43720. * @returns an array of AbstractMesh
  43721. */
  43722. getActiveMeshes(): SmartArray<AbstractMesh>;
  43723. /**
  43724. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43725. * @returns a number
  43726. */
  43727. getAnimationRatio(): number;
  43728. /**
  43729. * Gets an unique Id for the current render phase
  43730. * @returns a number
  43731. */
  43732. getRenderId(): number;
  43733. /**
  43734. * Gets an unique Id for the current frame
  43735. * @returns a number
  43736. */
  43737. getFrameId(): number;
  43738. /** Call this function if you want to manually increment the render Id*/
  43739. incrementRenderId(): void;
  43740. private _createUbo;
  43741. /**
  43742. * Use this method to simulate a pointer move on a mesh
  43743. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43744. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43745. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43746. * @returns the current scene
  43747. */
  43748. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43749. /**
  43750. * Use this method to simulate a pointer down on a mesh
  43751. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43752. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43753. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43754. * @returns the current scene
  43755. */
  43756. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43757. /**
  43758. * Use this method to simulate a pointer up on a mesh
  43759. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43760. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43761. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43762. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43763. * @returns the current scene
  43764. */
  43765. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43766. /**
  43767. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43768. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43769. * @returns true if the pointer was captured
  43770. */
  43771. isPointerCaptured(pointerId?: number): boolean;
  43772. /**
  43773. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43774. * @param attachUp defines if you want to attach events to pointerup
  43775. * @param attachDown defines if you want to attach events to pointerdown
  43776. * @param attachMove defines if you want to attach events to pointermove
  43777. */
  43778. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43779. /** Detaches all event handlers*/
  43780. detachControl(): void;
  43781. /**
  43782. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43783. * Delay loaded resources are not taking in account
  43784. * @return true if all required resources are ready
  43785. */
  43786. isReady(): boolean;
  43787. /** Resets all cached information relative to material (including effect and visibility) */
  43788. resetCachedMaterial(): void;
  43789. /**
  43790. * Registers a function to be called before every frame render
  43791. * @param func defines the function to register
  43792. */
  43793. registerBeforeRender(func: () => void): void;
  43794. /**
  43795. * Unregisters a function called before every frame render
  43796. * @param func defines the function to unregister
  43797. */
  43798. unregisterBeforeRender(func: () => void): void;
  43799. /**
  43800. * Registers a function to be called after every frame render
  43801. * @param func defines the function to register
  43802. */
  43803. registerAfterRender(func: () => void): void;
  43804. /**
  43805. * Unregisters a function called after every frame render
  43806. * @param func defines the function to unregister
  43807. */
  43808. unregisterAfterRender(func: () => void): void;
  43809. private _executeOnceBeforeRender;
  43810. /**
  43811. * The provided function will run before render once and will be disposed afterwards.
  43812. * A timeout delay can be provided so that the function will be executed in N ms.
  43813. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43814. * @param func The function to be executed.
  43815. * @param timeout optional delay in ms
  43816. */
  43817. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43818. /** @hidden */
  43819. _addPendingData(data: any): void;
  43820. /** @hidden */
  43821. _removePendingData(data: any): void;
  43822. /**
  43823. * Returns the number of items waiting to be loaded
  43824. * @returns the number of items waiting to be loaded
  43825. */
  43826. getWaitingItemsCount(): number;
  43827. /**
  43828. * Returns a boolean indicating if the scene is still loading data
  43829. */
  43830. get isLoading(): boolean;
  43831. /**
  43832. * Registers a function to be executed when the scene is ready
  43833. * @param {Function} func - the function to be executed
  43834. */
  43835. executeWhenReady(func: () => void): void;
  43836. /**
  43837. * Returns a promise that resolves when the scene is ready
  43838. * @returns A promise that resolves when the scene is ready
  43839. */
  43840. whenReadyAsync(): Promise<void>;
  43841. /** @hidden */
  43842. _checkIsReady(): void;
  43843. /**
  43844. * Gets all animatable attached to the scene
  43845. */
  43846. get animatables(): Animatable[];
  43847. /**
  43848. * Resets the last animation time frame.
  43849. * Useful to override when animations start running when loading a scene for the first time.
  43850. */
  43851. resetLastAnimationTimeFrame(): void;
  43852. /**
  43853. * Gets the current view matrix
  43854. * @returns a Matrix
  43855. */
  43856. getViewMatrix(): Matrix;
  43857. /**
  43858. * Gets the current projection matrix
  43859. * @returns a Matrix
  43860. */
  43861. getProjectionMatrix(): Matrix;
  43862. /**
  43863. * Gets the current transform matrix
  43864. * @returns a Matrix made of View * Projection
  43865. */
  43866. getTransformMatrix(): Matrix;
  43867. /**
  43868. * Sets the current transform matrix
  43869. * @param viewL defines the View matrix to use
  43870. * @param projectionL defines the Projection matrix to use
  43871. * @param viewR defines the right View matrix to use (if provided)
  43872. * @param projectionR defines the right Projection matrix to use (if provided)
  43873. */
  43874. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43875. /**
  43876. * Gets the uniform buffer used to store scene data
  43877. * @returns a UniformBuffer
  43878. */
  43879. getSceneUniformBuffer(): UniformBuffer;
  43880. /**
  43881. * Gets an unique (relatively to the current scene) Id
  43882. * @returns an unique number for the scene
  43883. */
  43884. getUniqueId(): number;
  43885. /**
  43886. * Add a mesh to the list of scene's meshes
  43887. * @param newMesh defines the mesh to add
  43888. * @param recursive if all child meshes should also be added to the scene
  43889. */
  43890. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43891. /**
  43892. * Remove a mesh for the list of scene's meshes
  43893. * @param toRemove defines the mesh to remove
  43894. * @param recursive if all child meshes should also be removed from the scene
  43895. * @returns the index where the mesh was in the mesh list
  43896. */
  43897. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43898. /**
  43899. * Add a transform node to the list of scene's transform nodes
  43900. * @param newTransformNode defines the transform node to add
  43901. */
  43902. addTransformNode(newTransformNode: TransformNode): void;
  43903. /**
  43904. * Remove a transform node for the list of scene's transform nodes
  43905. * @param toRemove defines the transform node to remove
  43906. * @returns the index where the transform node was in the transform node list
  43907. */
  43908. removeTransformNode(toRemove: TransformNode): number;
  43909. /**
  43910. * Remove a skeleton for the list of scene's skeletons
  43911. * @param toRemove defines the skeleton to remove
  43912. * @returns the index where the skeleton was in the skeleton list
  43913. */
  43914. removeSkeleton(toRemove: Skeleton): number;
  43915. /**
  43916. * Remove a morph target for the list of scene's morph targets
  43917. * @param toRemove defines the morph target to remove
  43918. * @returns the index where the morph target was in the morph target list
  43919. */
  43920. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43921. /**
  43922. * Remove a light for the list of scene's lights
  43923. * @param toRemove defines the light to remove
  43924. * @returns the index where the light was in the light list
  43925. */
  43926. removeLight(toRemove: Light): number;
  43927. /**
  43928. * Remove a camera for the list of scene's cameras
  43929. * @param toRemove defines the camera to remove
  43930. * @returns the index where the camera was in the camera list
  43931. */
  43932. removeCamera(toRemove: Camera): number;
  43933. /**
  43934. * Remove a particle system for the list of scene's particle systems
  43935. * @param toRemove defines the particle system to remove
  43936. * @returns the index where the particle system was in the particle system list
  43937. */
  43938. removeParticleSystem(toRemove: IParticleSystem): number;
  43939. /**
  43940. * Remove a animation for the list of scene's animations
  43941. * @param toRemove defines the animation to remove
  43942. * @returns the index where the animation was in the animation list
  43943. */
  43944. removeAnimation(toRemove: Animation): number;
  43945. /**
  43946. * Will stop the animation of the given target
  43947. * @param target - the target
  43948. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43949. * @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)
  43950. */
  43951. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43952. /**
  43953. * Removes the given animation group from this scene.
  43954. * @param toRemove The animation group to remove
  43955. * @returns The index of the removed animation group
  43956. */
  43957. removeAnimationGroup(toRemove: AnimationGroup): number;
  43958. /**
  43959. * Removes the given multi-material from this scene.
  43960. * @param toRemove The multi-material to remove
  43961. * @returns The index of the removed multi-material
  43962. */
  43963. removeMultiMaterial(toRemove: MultiMaterial): number;
  43964. /**
  43965. * Removes the given material from this scene.
  43966. * @param toRemove The material to remove
  43967. * @returns The index of the removed material
  43968. */
  43969. removeMaterial(toRemove: Material): number;
  43970. /**
  43971. * Removes the given action manager from this scene.
  43972. * @param toRemove The action manager to remove
  43973. * @returns The index of the removed action manager
  43974. */
  43975. removeActionManager(toRemove: AbstractActionManager): number;
  43976. /**
  43977. * Removes the given texture from this scene.
  43978. * @param toRemove The texture to remove
  43979. * @returns The index of the removed texture
  43980. */
  43981. removeTexture(toRemove: BaseTexture): number;
  43982. /**
  43983. * Adds the given light to this scene
  43984. * @param newLight The light to add
  43985. */
  43986. addLight(newLight: Light): void;
  43987. /**
  43988. * Sorts the list list based on light priorities
  43989. */
  43990. sortLightsByPriority(): void;
  43991. /**
  43992. * Adds the given camera to this scene
  43993. * @param newCamera The camera to add
  43994. */
  43995. addCamera(newCamera: Camera): void;
  43996. /**
  43997. * Adds the given skeleton to this scene
  43998. * @param newSkeleton The skeleton to add
  43999. */
  44000. addSkeleton(newSkeleton: Skeleton): void;
  44001. /**
  44002. * Adds the given particle system to this scene
  44003. * @param newParticleSystem The particle system to add
  44004. */
  44005. addParticleSystem(newParticleSystem: IParticleSystem): void;
  44006. /**
  44007. * Adds the given animation to this scene
  44008. * @param newAnimation The animation to add
  44009. */
  44010. addAnimation(newAnimation: Animation): void;
  44011. /**
  44012. * Adds the given animation group to this scene.
  44013. * @param newAnimationGroup The animation group to add
  44014. */
  44015. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  44016. /**
  44017. * Adds the given multi-material to this scene
  44018. * @param newMultiMaterial The multi-material to add
  44019. */
  44020. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  44021. /**
  44022. * Adds the given material to this scene
  44023. * @param newMaterial The material to add
  44024. */
  44025. addMaterial(newMaterial: Material): void;
  44026. /**
  44027. * Adds the given morph target to this scene
  44028. * @param newMorphTargetManager The morph target to add
  44029. */
  44030. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  44031. /**
  44032. * Adds the given geometry to this scene
  44033. * @param newGeometry The geometry to add
  44034. */
  44035. addGeometry(newGeometry: Geometry): void;
  44036. /**
  44037. * Adds the given action manager to this scene
  44038. * @param newActionManager The action manager to add
  44039. */
  44040. addActionManager(newActionManager: AbstractActionManager): void;
  44041. /**
  44042. * Adds the given texture to this scene.
  44043. * @param newTexture The texture to add
  44044. */
  44045. addTexture(newTexture: BaseTexture): void;
  44046. /**
  44047. * Switch active camera
  44048. * @param newCamera defines the new active camera
  44049. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  44050. */
  44051. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  44052. /**
  44053. * sets the active camera of the scene using its ID
  44054. * @param id defines the camera's ID
  44055. * @return the new active camera or null if none found.
  44056. */
  44057. setActiveCameraByID(id: string): Nullable<Camera>;
  44058. /**
  44059. * sets the active camera of the scene using its name
  44060. * @param name defines the camera's name
  44061. * @returns the new active camera or null if none found.
  44062. */
  44063. setActiveCameraByName(name: string): Nullable<Camera>;
  44064. /**
  44065. * get an animation group using its name
  44066. * @param name defines the material's name
  44067. * @return the animation group or null if none found.
  44068. */
  44069. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  44070. /**
  44071. * Get a material using its unique id
  44072. * @param uniqueId defines the material's unique id
  44073. * @return the material or null if none found.
  44074. */
  44075. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  44076. /**
  44077. * get a material using its id
  44078. * @param id defines the material's ID
  44079. * @return the material or null if none found.
  44080. */
  44081. getMaterialByID(id: string): Nullable<Material>;
  44082. /**
  44083. * Gets a the last added material using a given id
  44084. * @param id defines the material's ID
  44085. * @return the last material with the given id or null if none found.
  44086. */
  44087. getLastMaterialByID(id: string): Nullable<Material>;
  44088. /**
  44089. * Gets a material using its name
  44090. * @param name defines the material's name
  44091. * @return the material or null if none found.
  44092. */
  44093. getMaterialByName(name: string): Nullable<Material>;
  44094. /**
  44095. * Get a texture using its unique id
  44096. * @param uniqueId defines the texture's unique id
  44097. * @return the texture or null if none found.
  44098. */
  44099. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  44100. /**
  44101. * Gets a camera using its id
  44102. * @param id defines the id to look for
  44103. * @returns the camera or null if not found
  44104. */
  44105. getCameraByID(id: string): Nullable<Camera>;
  44106. /**
  44107. * Gets a camera using its unique id
  44108. * @param uniqueId defines the unique id to look for
  44109. * @returns the camera or null if not found
  44110. */
  44111. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  44112. /**
  44113. * Gets a camera using its name
  44114. * @param name defines the camera's name
  44115. * @return the camera or null if none found.
  44116. */
  44117. getCameraByName(name: string): Nullable<Camera>;
  44118. /**
  44119. * Gets a bone using its id
  44120. * @param id defines the bone's id
  44121. * @return the bone or null if not found
  44122. */
  44123. getBoneByID(id: string): Nullable<Bone>;
  44124. /**
  44125. * Gets a bone using its id
  44126. * @param name defines the bone's name
  44127. * @return the bone or null if not found
  44128. */
  44129. getBoneByName(name: string): Nullable<Bone>;
  44130. /**
  44131. * Gets a light node using its name
  44132. * @param name defines the the light's name
  44133. * @return the light or null if none found.
  44134. */
  44135. getLightByName(name: string): Nullable<Light>;
  44136. /**
  44137. * Gets a light node using its id
  44138. * @param id defines the light's id
  44139. * @return the light or null if none found.
  44140. */
  44141. getLightByID(id: string): Nullable<Light>;
  44142. /**
  44143. * Gets a light node using its scene-generated unique ID
  44144. * @param uniqueId defines the light's unique id
  44145. * @return the light or null if none found.
  44146. */
  44147. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44148. /**
  44149. * Gets a particle system by id
  44150. * @param id defines the particle system id
  44151. * @return the corresponding system or null if none found
  44152. */
  44153. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44154. /**
  44155. * Gets a geometry using its ID
  44156. * @param id defines the geometry's id
  44157. * @return the geometry or null if none found.
  44158. */
  44159. getGeometryByID(id: string): Nullable<Geometry>;
  44160. private _getGeometryByUniqueID;
  44161. /**
  44162. * Add a new geometry to this scene
  44163. * @param geometry defines the geometry to be added to the scene.
  44164. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44165. * @return a boolean defining if the geometry was added or not
  44166. */
  44167. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44168. /**
  44169. * Removes an existing geometry
  44170. * @param geometry defines the geometry to be removed from the scene
  44171. * @return a boolean defining if the geometry was removed or not
  44172. */
  44173. removeGeometry(geometry: Geometry): boolean;
  44174. /**
  44175. * Gets the list of geometries attached to the scene
  44176. * @returns an array of Geometry
  44177. */
  44178. getGeometries(): Geometry[];
  44179. /**
  44180. * Gets the first added mesh found of a given ID
  44181. * @param id defines the id to search for
  44182. * @return the mesh found or null if not found at all
  44183. */
  44184. getMeshByID(id: string): Nullable<AbstractMesh>;
  44185. /**
  44186. * Gets a list of meshes using their id
  44187. * @param id defines the id to search for
  44188. * @returns a list of meshes
  44189. */
  44190. getMeshesByID(id: string): Array<AbstractMesh>;
  44191. /**
  44192. * Gets the first added transform node found of a given ID
  44193. * @param id defines the id to search for
  44194. * @return the found transform node or null if not found at all.
  44195. */
  44196. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44197. /**
  44198. * Gets a transform node with its auto-generated unique id
  44199. * @param uniqueId efines the unique id to search for
  44200. * @return the found transform node or null if not found at all.
  44201. */
  44202. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44203. /**
  44204. * Gets a list of transform nodes using their id
  44205. * @param id defines the id to search for
  44206. * @returns a list of transform nodes
  44207. */
  44208. getTransformNodesByID(id: string): Array<TransformNode>;
  44209. /**
  44210. * Gets a mesh with its auto-generated unique id
  44211. * @param uniqueId defines the unique id to search for
  44212. * @return the found mesh or null if not found at all.
  44213. */
  44214. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44215. /**
  44216. * Gets a the last added mesh using a given id
  44217. * @param id defines the id to search for
  44218. * @return the found mesh or null if not found at all.
  44219. */
  44220. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44221. /**
  44222. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44223. * @param id defines the id to search for
  44224. * @return the found node or null if not found at all
  44225. */
  44226. getLastEntryByID(id: string): Nullable<Node>;
  44227. /**
  44228. * Gets a node (Mesh, Camera, Light) using a given id
  44229. * @param id defines the id to search for
  44230. * @return the found node or null if not found at all
  44231. */
  44232. getNodeByID(id: string): Nullable<Node>;
  44233. /**
  44234. * Gets a node (Mesh, Camera, Light) using a given name
  44235. * @param name defines the name to search for
  44236. * @return the found node or null if not found at all.
  44237. */
  44238. getNodeByName(name: string): Nullable<Node>;
  44239. /**
  44240. * Gets a mesh using a given name
  44241. * @param name defines the name to search for
  44242. * @return the found mesh or null if not found at all.
  44243. */
  44244. getMeshByName(name: string): Nullable<AbstractMesh>;
  44245. /**
  44246. * Gets a transform node using a given name
  44247. * @param name defines the name to search for
  44248. * @return the found transform node or null if not found at all.
  44249. */
  44250. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44251. /**
  44252. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44253. * @param id defines the id to search for
  44254. * @return the found skeleton or null if not found at all.
  44255. */
  44256. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44257. /**
  44258. * Gets a skeleton using a given auto generated unique id
  44259. * @param uniqueId defines the unique id to search for
  44260. * @return the found skeleton or null if not found at all.
  44261. */
  44262. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44263. /**
  44264. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44265. * @param id defines the id to search for
  44266. * @return the found skeleton or null if not found at all.
  44267. */
  44268. getSkeletonById(id: string): Nullable<Skeleton>;
  44269. /**
  44270. * Gets a skeleton using a given name
  44271. * @param name defines the name to search for
  44272. * @return the found skeleton or null if not found at all.
  44273. */
  44274. getSkeletonByName(name: string): Nullable<Skeleton>;
  44275. /**
  44276. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44277. * @param id defines the id to search for
  44278. * @return the found morph target manager or null if not found at all.
  44279. */
  44280. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44281. /**
  44282. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44283. * @param id defines the id to search for
  44284. * @return the found morph target or null if not found at all.
  44285. */
  44286. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44287. /**
  44288. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44289. * @param name defines the name to search for
  44290. * @return the found morph target or null if not found at all.
  44291. */
  44292. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44293. /**
  44294. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44295. * @param name defines the name to search for
  44296. * @return the found post process or null if not found at all.
  44297. */
  44298. getPostProcessByName(name: string): Nullable<PostProcess>;
  44299. /**
  44300. * Gets a boolean indicating if the given mesh is active
  44301. * @param mesh defines the mesh to look for
  44302. * @returns true if the mesh is in the active list
  44303. */
  44304. isActiveMesh(mesh: AbstractMesh): boolean;
  44305. /**
  44306. * Return a unique id as a string which can serve as an identifier for the scene
  44307. */
  44308. get uid(): string;
  44309. /**
  44310. * Add an externaly attached data from its key.
  44311. * This method call will fail and return false, if such key already exists.
  44312. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44313. * @param key the unique key that identifies the data
  44314. * @param data the data object to associate to the key for this Engine instance
  44315. * @return true if no such key were already present and the data was added successfully, false otherwise
  44316. */
  44317. addExternalData<T>(key: string, data: T): boolean;
  44318. /**
  44319. * Get an externaly attached data from its key
  44320. * @param key the unique key that identifies the data
  44321. * @return the associated data, if present (can be null), or undefined if not present
  44322. */
  44323. getExternalData<T>(key: string): Nullable<T>;
  44324. /**
  44325. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44326. * @param key the unique key that identifies the data
  44327. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44328. * @return the associated data, can be null if the factory returned null.
  44329. */
  44330. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44331. /**
  44332. * Remove an externaly attached data from the Engine instance
  44333. * @param key the unique key that identifies the data
  44334. * @return true if the data was successfully removed, false if it doesn't exist
  44335. */
  44336. removeExternalData(key: string): boolean;
  44337. private _evaluateSubMesh;
  44338. /**
  44339. * Clear the processed materials smart array preventing retention point in material dispose.
  44340. */
  44341. freeProcessedMaterials(): void;
  44342. private _preventFreeActiveMeshesAndRenderingGroups;
  44343. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44344. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44345. * when disposing several meshes in a row or a hierarchy of meshes.
  44346. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44347. */
  44348. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44349. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44350. /**
  44351. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44352. */
  44353. freeActiveMeshes(): void;
  44354. /**
  44355. * Clear the info related to rendering groups preventing retention points during dispose.
  44356. */
  44357. freeRenderingGroups(): void;
  44358. /** @hidden */
  44359. _isInIntermediateRendering(): boolean;
  44360. /**
  44361. * Lambda returning the list of potentially active meshes.
  44362. */
  44363. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44364. /**
  44365. * Lambda returning the list of potentially active sub meshes.
  44366. */
  44367. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44368. /**
  44369. * Lambda returning the list of potentially intersecting sub meshes.
  44370. */
  44371. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44372. /**
  44373. * Lambda returning the list of potentially colliding sub meshes.
  44374. */
  44375. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44376. private _activeMeshesFrozen;
  44377. private _skipEvaluateActiveMeshesCompletely;
  44378. /**
  44379. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44380. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44381. * @param onSuccess optional success callback
  44382. * @param onError optional error callback
  44383. * @returns the current scene
  44384. */
  44385. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44386. /**
  44387. * Use this function to restart evaluating active meshes on every frame
  44388. * @returns the current scene
  44389. */
  44390. unfreezeActiveMeshes(): Scene;
  44391. private _evaluateActiveMeshes;
  44392. private _activeMesh;
  44393. /**
  44394. * Update the transform matrix to update from the current active camera
  44395. * @param force defines a boolean used to force the update even if cache is up to date
  44396. */
  44397. updateTransformMatrix(force?: boolean): void;
  44398. private _bindFrameBuffer;
  44399. /** @hidden */
  44400. _allowPostProcessClearColor: boolean;
  44401. /** @hidden */
  44402. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44403. private _processSubCameras;
  44404. private _checkIntersections;
  44405. /** @hidden */
  44406. _advancePhysicsEngineStep(step: number): void;
  44407. /**
  44408. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44409. */
  44410. getDeterministicFrameTime: () => number;
  44411. /** @hidden */
  44412. _animate(): void;
  44413. /** Execute all animations (for a frame) */
  44414. animate(): void;
  44415. /**
  44416. * Render the scene
  44417. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44418. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44419. */
  44420. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44421. /**
  44422. * Freeze all materials
  44423. * A frozen material will not be updatable but should be faster to render
  44424. */
  44425. freezeMaterials(): void;
  44426. /**
  44427. * Unfreeze all materials
  44428. * A frozen material will not be updatable but should be faster to render
  44429. */
  44430. unfreezeMaterials(): void;
  44431. /**
  44432. * Releases all held ressources
  44433. */
  44434. dispose(): void;
  44435. /**
  44436. * Gets if the scene is already disposed
  44437. */
  44438. get isDisposed(): boolean;
  44439. /**
  44440. * Call this function to reduce memory footprint of the scene.
  44441. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44442. */
  44443. clearCachedVertexData(): void;
  44444. /**
  44445. * This function will remove the local cached buffer data from texture.
  44446. * It will save memory but will prevent the texture from being rebuilt
  44447. */
  44448. cleanCachedTextureBuffer(): void;
  44449. /**
  44450. * Get the world extend vectors with an optional filter
  44451. *
  44452. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44453. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44454. */
  44455. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44456. min: Vector3;
  44457. max: Vector3;
  44458. };
  44459. /**
  44460. * Creates a ray that can be used to pick in the scene
  44461. * @param x defines the x coordinate of the origin (on-screen)
  44462. * @param y defines the y coordinate of the origin (on-screen)
  44463. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44464. * @param camera defines the camera to use for the picking
  44465. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44466. * @returns a Ray
  44467. */
  44468. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44469. /**
  44470. * Creates a ray that can be used to pick in the scene
  44471. * @param x defines the x coordinate of the origin (on-screen)
  44472. * @param y defines the y coordinate of the origin (on-screen)
  44473. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44474. * @param result defines the ray where to store the picking ray
  44475. * @param camera defines the camera to use for the picking
  44476. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44477. * @returns the current scene
  44478. */
  44479. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44480. /**
  44481. * Creates a ray that can be used to pick in the scene
  44482. * @param x defines the x coordinate of the origin (on-screen)
  44483. * @param y defines the y coordinate of the origin (on-screen)
  44484. * @param camera defines the camera to use for the picking
  44485. * @returns a Ray
  44486. */
  44487. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44488. /**
  44489. * Creates a ray that can be used to pick in the scene
  44490. * @param x defines the x coordinate of the origin (on-screen)
  44491. * @param y defines the y coordinate of the origin (on-screen)
  44492. * @param result defines the ray where to store the picking ray
  44493. * @param camera defines the camera to use for the picking
  44494. * @returns the current scene
  44495. */
  44496. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44497. /** Launch a ray to try to pick a mesh in the scene
  44498. * @param x position on screen
  44499. * @param y position on screen
  44500. * @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
  44501. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44502. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44503. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44504. * @returns a PickingInfo
  44505. */
  44506. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44507. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44508. * @param x position on screen
  44509. * @param y position on screen
  44510. * @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
  44511. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44512. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44513. * @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)
  44514. */
  44515. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44516. /** Use the given ray to pick a mesh in the scene
  44517. * @param ray The ray to use to pick meshes
  44518. * @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
  44519. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44520. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44521. * @returns a PickingInfo
  44522. */
  44523. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44524. /**
  44525. * Launch a ray to try to pick a mesh in the scene
  44526. * @param x X position on screen
  44527. * @param y Y position on screen
  44528. * @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
  44529. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44530. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44531. * @returns an array of PickingInfo
  44532. */
  44533. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44534. /**
  44535. * Launch a ray to try to pick a mesh in the scene
  44536. * @param ray Ray to use
  44537. * @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
  44538. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44539. * @returns an array of PickingInfo
  44540. */
  44541. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44542. /**
  44543. * Force the value of meshUnderPointer
  44544. * @param mesh defines the mesh to use
  44545. * @param pointerId optional pointer id when using more than one pointer
  44546. */
  44547. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44548. /**
  44549. * Gets the mesh under the pointer
  44550. * @returns a Mesh or null if no mesh is under the pointer
  44551. */
  44552. getPointerOverMesh(): Nullable<AbstractMesh>;
  44553. /** @hidden */
  44554. _rebuildGeometries(): void;
  44555. /** @hidden */
  44556. _rebuildTextures(): void;
  44557. private _getByTags;
  44558. /**
  44559. * Get a list of meshes by tags
  44560. * @param tagsQuery defines the tags query to use
  44561. * @param forEach defines a predicate used to filter results
  44562. * @returns an array of Mesh
  44563. */
  44564. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44565. /**
  44566. * Get a list of cameras by tags
  44567. * @param tagsQuery defines the tags query to use
  44568. * @param forEach defines a predicate used to filter results
  44569. * @returns an array of Camera
  44570. */
  44571. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44572. /**
  44573. * Get a list of lights by tags
  44574. * @param tagsQuery defines the tags query to use
  44575. * @param forEach defines a predicate used to filter results
  44576. * @returns an array of Light
  44577. */
  44578. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44579. /**
  44580. * Get a list of materials by tags
  44581. * @param tagsQuery defines the tags query to use
  44582. * @param forEach defines a predicate used to filter results
  44583. * @returns an array of Material
  44584. */
  44585. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44586. /**
  44587. * Get a list of transform nodes by tags
  44588. * @param tagsQuery defines the tags query to use
  44589. * @param forEach defines a predicate used to filter results
  44590. * @returns an array of TransformNode
  44591. */
  44592. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44593. /**
  44594. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44595. * This allowed control for front to back rendering or reversly depending of the special needs.
  44596. *
  44597. * @param renderingGroupId The rendering group id corresponding to its index
  44598. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44599. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44600. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44601. */
  44602. 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;
  44603. /**
  44604. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44605. *
  44606. * @param renderingGroupId The rendering group id corresponding to its index
  44607. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44608. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44609. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44610. */
  44611. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44612. /**
  44613. * Gets the current auto clear configuration for one rendering group of the rendering
  44614. * manager.
  44615. * @param index the rendering group index to get the information for
  44616. * @returns The auto clear setup for the requested rendering group
  44617. */
  44618. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44619. private _blockMaterialDirtyMechanism;
  44620. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44621. get blockMaterialDirtyMechanism(): boolean;
  44622. set blockMaterialDirtyMechanism(value: boolean);
  44623. /**
  44624. * Will flag all materials as dirty to trigger new shader compilation
  44625. * @param flag defines the flag used to specify which material part must be marked as dirty
  44626. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44627. */
  44628. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44629. /** @hidden */
  44630. _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;
  44631. /** @hidden */
  44632. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44633. /** @hidden */
  44634. _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;
  44635. /** @hidden */
  44636. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44637. /** @hidden */
  44638. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44639. /** @hidden */
  44640. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44641. }
  44642. }
  44643. declare module BABYLON {
  44644. /**
  44645. * Set of assets to keep when moving a scene into an asset container.
  44646. */
  44647. export class KeepAssets extends AbstractScene {
  44648. }
  44649. /**
  44650. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44651. */
  44652. export class InstantiatedEntries {
  44653. /**
  44654. * List of new root nodes (eg. nodes with no parent)
  44655. */
  44656. rootNodes: TransformNode[];
  44657. /**
  44658. * List of new skeletons
  44659. */
  44660. skeletons: Skeleton[];
  44661. /**
  44662. * List of new animation groups
  44663. */
  44664. animationGroups: AnimationGroup[];
  44665. }
  44666. /**
  44667. * Container with a set of assets that can be added or removed from a scene.
  44668. */
  44669. export class AssetContainer extends AbstractScene {
  44670. private _wasAddedToScene;
  44671. /**
  44672. * The scene the AssetContainer belongs to.
  44673. */
  44674. scene: Scene;
  44675. /**
  44676. * Instantiates an AssetContainer.
  44677. * @param scene The scene the AssetContainer belongs to.
  44678. */
  44679. constructor(scene: Scene);
  44680. /**
  44681. * Instantiate or clone all meshes and add the new ones to the scene.
  44682. * Skeletons and animation groups will all be cloned
  44683. * @param nameFunction defines an optional function used to get new names for clones
  44684. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44685. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44686. */
  44687. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44688. /**
  44689. * Adds all the assets from the container to the scene.
  44690. */
  44691. addAllToScene(): void;
  44692. /**
  44693. * Removes all the assets in the container from the scene
  44694. */
  44695. removeAllFromScene(): void;
  44696. /**
  44697. * Disposes all the assets in the container
  44698. */
  44699. dispose(): void;
  44700. private _moveAssets;
  44701. /**
  44702. * Removes all the assets contained in the scene and adds them to the container.
  44703. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44704. */
  44705. moveAllFromScene(keepAssets?: KeepAssets): void;
  44706. /**
  44707. * 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.
  44708. * @returns the root mesh
  44709. */
  44710. createRootMesh(): Mesh;
  44711. /**
  44712. * Merge animations (direct and animation groups) from this asset container into a scene
  44713. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44714. * @param animatables set of animatables to retarget to a node from the scene
  44715. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44716. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44717. */
  44718. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44719. }
  44720. }
  44721. declare module BABYLON {
  44722. /**
  44723. * Defines how the parser contract is defined.
  44724. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44725. */
  44726. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44727. /**
  44728. * Defines how the individual parser contract is defined.
  44729. * These parser can parse an individual asset
  44730. */
  44731. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44732. /**
  44733. * Base class of the scene acting as a container for the different elements composing a scene.
  44734. * This class is dynamically extended by the different components of the scene increasing
  44735. * flexibility and reducing coupling
  44736. */
  44737. export abstract class AbstractScene {
  44738. /**
  44739. * Stores the list of available parsers in the application.
  44740. */
  44741. private static _BabylonFileParsers;
  44742. /**
  44743. * Stores the list of available individual parsers in the application.
  44744. */
  44745. private static _IndividualBabylonFileParsers;
  44746. /**
  44747. * Adds a parser in the list of available ones
  44748. * @param name Defines the name of the parser
  44749. * @param parser Defines the parser to add
  44750. */
  44751. static AddParser(name: string, parser: BabylonFileParser): void;
  44752. /**
  44753. * Gets a general parser from the list of avaialble ones
  44754. * @param name Defines the name of the parser
  44755. * @returns the requested parser or null
  44756. */
  44757. static GetParser(name: string): Nullable<BabylonFileParser>;
  44758. /**
  44759. * Adds n individual parser in the list of available ones
  44760. * @param name Defines the name of the parser
  44761. * @param parser Defines the parser to add
  44762. */
  44763. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44764. /**
  44765. * Gets an individual parser from the list of avaialble ones
  44766. * @param name Defines the name of the parser
  44767. * @returns the requested parser or null
  44768. */
  44769. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44770. /**
  44771. * Parser json data and populate both a scene and its associated container object
  44772. * @param jsonData Defines the data to parse
  44773. * @param scene Defines the scene to parse the data for
  44774. * @param container Defines the container attached to the parsing sequence
  44775. * @param rootUrl Defines the root url of the data
  44776. */
  44777. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44778. /**
  44779. * Gets the list of root nodes (ie. nodes with no parent)
  44780. */
  44781. rootNodes: Node[];
  44782. /** All of the cameras added to this scene
  44783. * @see https://doc.babylonjs.com/babylon101/cameras
  44784. */
  44785. cameras: Camera[];
  44786. /**
  44787. * All of the lights added to this scene
  44788. * @see https://doc.babylonjs.com/babylon101/lights
  44789. */
  44790. lights: Light[];
  44791. /**
  44792. * All of the (abstract) meshes added to this scene
  44793. */
  44794. meshes: AbstractMesh[];
  44795. /**
  44796. * The list of skeletons added to the scene
  44797. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44798. */
  44799. skeletons: Skeleton[];
  44800. /**
  44801. * All of the particle systems added to this scene
  44802. * @see https://doc.babylonjs.com/babylon101/particles
  44803. */
  44804. particleSystems: IParticleSystem[];
  44805. /**
  44806. * Gets a list of Animations associated with the scene
  44807. */
  44808. animations: Animation[];
  44809. /**
  44810. * All of the animation groups added to this scene
  44811. * @see https://doc.babylonjs.com/how_to/group
  44812. */
  44813. animationGroups: AnimationGroup[];
  44814. /**
  44815. * All of the multi-materials added to this scene
  44816. * @see https://doc.babylonjs.com/how_to/multi_materials
  44817. */
  44818. multiMaterials: MultiMaterial[];
  44819. /**
  44820. * All of the materials added to this scene
  44821. * In the context of a Scene, it is not supposed to be modified manually.
  44822. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44823. * Note also that the order of the Material within the array is not significant and might change.
  44824. * @see https://doc.babylonjs.com/babylon101/materials
  44825. */
  44826. materials: Material[];
  44827. /**
  44828. * The list of morph target managers added to the scene
  44829. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44830. */
  44831. morphTargetManagers: MorphTargetManager[];
  44832. /**
  44833. * The list of geometries used in the scene.
  44834. */
  44835. geometries: Geometry[];
  44836. /**
  44837. * All of the tranform nodes added to this scene
  44838. * In the context of a Scene, it is not supposed to be modified manually.
  44839. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44840. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44841. * @see https://doc.babylonjs.com/how_to/transformnode
  44842. */
  44843. transformNodes: TransformNode[];
  44844. /**
  44845. * ActionManagers available on the scene.
  44846. */
  44847. actionManagers: AbstractActionManager[];
  44848. /**
  44849. * Textures to keep.
  44850. */
  44851. textures: BaseTexture[];
  44852. /** @hidden */
  44853. protected _environmentTexture: Nullable<BaseTexture>;
  44854. /**
  44855. * Texture used in all pbr material as the reflection texture.
  44856. * As in the majority of the scene they are the same (exception for multi room and so on),
  44857. * this is easier to reference from here than from all the materials.
  44858. */
  44859. get environmentTexture(): Nullable<BaseTexture>;
  44860. set environmentTexture(value: Nullable<BaseTexture>);
  44861. /**
  44862. * The list of postprocesses added to the scene
  44863. */
  44864. postProcesses: PostProcess[];
  44865. /**
  44866. * @returns all meshes, lights, cameras, transformNodes and bones
  44867. */
  44868. getNodes(): Array<Node>;
  44869. }
  44870. }
  44871. declare module BABYLON {
  44872. /**
  44873. * Interface used to define options for Sound class
  44874. */
  44875. export interface ISoundOptions {
  44876. /**
  44877. * Does the sound autoplay once loaded.
  44878. */
  44879. autoplay?: boolean;
  44880. /**
  44881. * Does the sound loop after it finishes playing once.
  44882. */
  44883. loop?: boolean;
  44884. /**
  44885. * Sound's volume
  44886. */
  44887. volume?: number;
  44888. /**
  44889. * Is it a spatial sound?
  44890. */
  44891. spatialSound?: boolean;
  44892. /**
  44893. * Maximum distance to hear that sound
  44894. */
  44895. maxDistance?: number;
  44896. /**
  44897. * Uses user defined attenuation function
  44898. */
  44899. useCustomAttenuation?: boolean;
  44900. /**
  44901. * Define the roll off factor of spatial sounds.
  44902. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44903. */
  44904. rolloffFactor?: number;
  44905. /**
  44906. * Define the reference distance the sound should be heard perfectly.
  44907. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44908. */
  44909. refDistance?: number;
  44910. /**
  44911. * Define the distance attenuation model the sound will follow.
  44912. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44913. */
  44914. distanceModel?: string;
  44915. /**
  44916. * Defines the playback speed (1 by default)
  44917. */
  44918. playbackRate?: number;
  44919. /**
  44920. * Defines if the sound is from a streaming source
  44921. */
  44922. streaming?: boolean;
  44923. /**
  44924. * Defines an optional length (in seconds) inside the sound file
  44925. */
  44926. length?: number;
  44927. /**
  44928. * Defines an optional offset (in seconds) inside the sound file
  44929. */
  44930. offset?: number;
  44931. /**
  44932. * If true, URLs will not be required to state the audio file codec to use.
  44933. */
  44934. skipCodecCheck?: boolean;
  44935. }
  44936. }
  44937. declare module BABYLON {
  44938. /**
  44939. * Defines a sound that can be played in the application.
  44940. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44941. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44942. */
  44943. export class Sound {
  44944. /**
  44945. * The name of the sound in the scene.
  44946. */
  44947. name: string;
  44948. /**
  44949. * Does the sound autoplay once loaded.
  44950. */
  44951. autoplay: boolean;
  44952. /**
  44953. * Does the sound loop after it finishes playing once.
  44954. */
  44955. loop: boolean;
  44956. /**
  44957. * Does the sound use a custom attenuation curve to simulate the falloff
  44958. * happening when the source gets further away from the camera.
  44959. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44960. */
  44961. useCustomAttenuation: boolean;
  44962. /**
  44963. * The sound track id this sound belongs to.
  44964. */
  44965. soundTrackId: number;
  44966. /**
  44967. * Is this sound currently played.
  44968. */
  44969. isPlaying: boolean;
  44970. /**
  44971. * Is this sound currently paused.
  44972. */
  44973. isPaused: boolean;
  44974. /**
  44975. * Does this sound enables spatial sound.
  44976. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44977. */
  44978. spatialSound: boolean;
  44979. /**
  44980. * Define the reference distance the sound should be heard perfectly.
  44981. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44982. */
  44983. refDistance: number;
  44984. /**
  44985. * Define the roll off factor of spatial sounds.
  44986. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44987. */
  44988. rolloffFactor: number;
  44989. /**
  44990. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44991. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44992. */
  44993. maxDistance: number;
  44994. /**
  44995. * Define the distance attenuation model the sound will follow.
  44996. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44997. */
  44998. distanceModel: string;
  44999. /**
  45000. * @hidden
  45001. * Back Compat
  45002. **/
  45003. onended: () => any;
  45004. /**
  45005. * Gets or sets an object used to store user defined information for the sound.
  45006. */
  45007. metadata: any;
  45008. /**
  45009. * Observable event when the current playing sound finishes.
  45010. */
  45011. onEndedObservable: Observable<Sound>;
  45012. /**
  45013. * Gets the current time for the sound.
  45014. */
  45015. get currentTime(): number;
  45016. private _panningModel;
  45017. private _playbackRate;
  45018. private _streaming;
  45019. private _startTime;
  45020. private _startOffset;
  45021. private _position;
  45022. /** @hidden */
  45023. _positionInEmitterSpace: boolean;
  45024. private _localDirection;
  45025. private _volume;
  45026. private _isReadyToPlay;
  45027. private _isDirectional;
  45028. private _readyToPlayCallback;
  45029. private _audioBuffer;
  45030. private _soundSource;
  45031. private _streamingSource;
  45032. private _soundPanner;
  45033. private _soundGain;
  45034. private _inputAudioNode;
  45035. private _outputAudioNode;
  45036. private _coneInnerAngle;
  45037. private _coneOuterAngle;
  45038. private _coneOuterGain;
  45039. private _scene;
  45040. private _connectedTransformNode;
  45041. private _customAttenuationFunction;
  45042. private _registerFunc;
  45043. private _isOutputConnected;
  45044. private _htmlAudioElement;
  45045. private _urlType;
  45046. private _length?;
  45047. private _offset?;
  45048. /** @hidden */
  45049. static _SceneComponentInitialization: (scene: Scene) => void;
  45050. /**
  45051. * Create a sound and attach it to a scene
  45052. * @param name Name of your sound
  45053. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  45054. * @param scene defines the scene the sound belongs to
  45055. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  45056. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  45057. */
  45058. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  45059. /**
  45060. * Release the sound and its associated resources
  45061. */
  45062. dispose(): void;
  45063. /**
  45064. * Gets if the sounds is ready to be played or not.
  45065. * @returns true if ready, otherwise false
  45066. */
  45067. isReady(): boolean;
  45068. private _soundLoaded;
  45069. /**
  45070. * Sets the data of the sound from an audiobuffer
  45071. * @param audioBuffer The audioBuffer containing the data
  45072. */
  45073. setAudioBuffer(audioBuffer: AudioBuffer): void;
  45074. /**
  45075. * Updates the current sounds options such as maxdistance, loop...
  45076. * @param options A JSON object containing values named as the object properties
  45077. */
  45078. updateOptions(options: ISoundOptions): void;
  45079. private _createSpatialParameters;
  45080. private _updateSpatialParameters;
  45081. /**
  45082. * Switch the panning model to HRTF:
  45083. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45084. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45085. */
  45086. switchPanningModelToHRTF(): void;
  45087. /**
  45088. * Switch the panning model to Equal Power:
  45089. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45090. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45091. */
  45092. switchPanningModelToEqualPower(): void;
  45093. private _switchPanningModel;
  45094. /**
  45095. * Connect this sound to a sound track audio node like gain...
  45096. * @param soundTrackAudioNode the sound track audio node to connect to
  45097. */
  45098. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  45099. /**
  45100. * Transform this sound into a directional source
  45101. * @param coneInnerAngle Size of the inner cone in degree
  45102. * @param coneOuterAngle Size of the outer cone in degree
  45103. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  45104. */
  45105. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  45106. /**
  45107. * Gets or sets the inner angle for the directional cone.
  45108. */
  45109. get directionalConeInnerAngle(): number;
  45110. /**
  45111. * Gets or sets the inner angle for the directional cone.
  45112. */
  45113. set directionalConeInnerAngle(value: number);
  45114. /**
  45115. * Gets or sets the outer angle for the directional cone.
  45116. */
  45117. get directionalConeOuterAngle(): number;
  45118. /**
  45119. * Gets or sets the outer angle for the directional cone.
  45120. */
  45121. set directionalConeOuterAngle(value: number);
  45122. /**
  45123. * Sets the position of the emitter if spatial sound is enabled
  45124. * @param newPosition Defines the new posisiton
  45125. */
  45126. setPosition(newPosition: Vector3): void;
  45127. /**
  45128. * Sets the local direction of the emitter if spatial sound is enabled
  45129. * @param newLocalDirection Defines the new local direction
  45130. */
  45131. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45132. private _updateDirection;
  45133. /** @hidden */
  45134. updateDistanceFromListener(): void;
  45135. /**
  45136. * Sets a new custom attenuation function for the sound.
  45137. * @param callback Defines the function used for the attenuation
  45138. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45139. */
  45140. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45141. /**
  45142. * Play the sound
  45143. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45144. * @param offset (optional) Start the sound at a specific time in seconds
  45145. * @param length (optional) Sound duration (in seconds)
  45146. */
  45147. play(time?: number, offset?: number, length?: number): void;
  45148. private _onended;
  45149. /**
  45150. * Stop the sound
  45151. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45152. */
  45153. stop(time?: number): void;
  45154. /**
  45155. * Put the sound in pause
  45156. */
  45157. pause(): void;
  45158. /**
  45159. * Sets a dedicated volume for this sounds
  45160. * @param newVolume Define the new volume of the sound
  45161. * @param time Define time for gradual change to new volume
  45162. */
  45163. setVolume(newVolume: number, time?: number): void;
  45164. /**
  45165. * Set the sound play back rate
  45166. * @param newPlaybackRate Define the playback rate the sound should be played at
  45167. */
  45168. setPlaybackRate(newPlaybackRate: number): void;
  45169. /**
  45170. * Gets the volume of the sound.
  45171. * @returns the volume of the sound
  45172. */
  45173. getVolume(): number;
  45174. /**
  45175. * Attach the sound to a dedicated mesh
  45176. * @param transformNode The transform node to connect the sound with
  45177. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45178. */
  45179. attachToMesh(transformNode: TransformNode): void;
  45180. /**
  45181. * Detach the sound from the previously attached mesh
  45182. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45183. */
  45184. detachFromMesh(): void;
  45185. private _onRegisterAfterWorldMatrixUpdate;
  45186. /**
  45187. * Clone the current sound in the scene.
  45188. * @returns the new sound clone
  45189. */
  45190. clone(): Nullable<Sound>;
  45191. /**
  45192. * Gets the current underlying audio buffer containing the data
  45193. * @returns the audio buffer
  45194. */
  45195. getAudioBuffer(): Nullable<AudioBuffer>;
  45196. /**
  45197. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45198. * @returns the source node
  45199. */
  45200. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45201. /**
  45202. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45203. * @returns the gain node
  45204. */
  45205. getSoundGain(): Nullable<GainNode>;
  45206. /**
  45207. * Serializes the Sound in a JSON representation
  45208. * @returns the JSON representation of the sound
  45209. */
  45210. serialize(): any;
  45211. /**
  45212. * Parse a JSON representation of a sound to innstantiate in a given scene
  45213. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45214. * @param scene Define the scene the new parsed sound should be created in
  45215. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45216. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45217. * @returns the newly parsed sound
  45218. */
  45219. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45220. }
  45221. }
  45222. declare module BABYLON {
  45223. /**
  45224. * This defines an action helpful to play a defined sound on a triggered action.
  45225. */
  45226. export class PlaySoundAction extends Action {
  45227. private _sound;
  45228. /**
  45229. * Instantiate the action
  45230. * @param triggerOptions defines the trigger options
  45231. * @param sound defines the sound to play
  45232. * @param condition defines the trigger related conditions
  45233. */
  45234. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45235. /** @hidden */
  45236. _prepare(): void;
  45237. /**
  45238. * Execute the action and play the sound.
  45239. */
  45240. execute(): void;
  45241. /**
  45242. * Serializes the actions and its related information.
  45243. * @param parent defines the object to serialize in
  45244. * @returns the serialized object
  45245. */
  45246. serialize(parent: any): any;
  45247. }
  45248. /**
  45249. * This defines an action helpful to stop a defined sound on a triggered action.
  45250. */
  45251. export class StopSoundAction extends Action {
  45252. private _sound;
  45253. /**
  45254. * Instantiate the action
  45255. * @param triggerOptions defines the trigger options
  45256. * @param sound defines the sound to stop
  45257. * @param condition defines the trigger related conditions
  45258. */
  45259. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45260. /** @hidden */
  45261. _prepare(): void;
  45262. /**
  45263. * Execute the action and stop the sound.
  45264. */
  45265. execute(): void;
  45266. /**
  45267. * Serializes the actions and its related information.
  45268. * @param parent defines the object to serialize in
  45269. * @returns the serialized object
  45270. */
  45271. serialize(parent: any): any;
  45272. }
  45273. }
  45274. declare module BABYLON {
  45275. /**
  45276. * This defines an action responsible to change the value of a property
  45277. * by interpolating between its current value and the newly set one once triggered.
  45278. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45279. */
  45280. export class InterpolateValueAction extends Action {
  45281. /**
  45282. * Defines the path of the property where the value should be interpolated
  45283. */
  45284. propertyPath: string;
  45285. /**
  45286. * Defines the target value at the end of the interpolation.
  45287. */
  45288. value: any;
  45289. /**
  45290. * Defines the time it will take for the property to interpolate to the value.
  45291. */
  45292. duration: number;
  45293. /**
  45294. * Defines if the other scene animations should be stopped when the action has been triggered
  45295. */
  45296. stopOtherAnimations?: boolean;
  45297. /**
  45298. * Defines a callback raised once the interpolation animation has been done.
  45299. */
  45300. onInterpolationDone?: () => void;
  45301. /**
  45302. * Observable triggered once the interpolation animation has been done.
  45303. */
  45304. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45305. private _target;
  45306. private _effectiveTarget;
  45307. private _property;
  45308. /**
  45309. * Instantiate the action
  45310. * @param triggerOptions defines the trigger options
  45311. * @param target defines the object containing the value to interpolate
  45312. * @param propertyPath defines the path to the property in the target object
  45313. * @param value defines the target value at the end of the interpolation
  45314. * @param duration deines the time it will take for the property to interpolate to the value.
  45315. * @param condition defines the trigger related conditions
  45316. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45317. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45318. */
  45319. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45320. /** @hidden */
  45321. _prepare(): void;
  45322. /**
  45323. * Execute the action starts the value interpolation.
  45324. */
  45325. execute(): void;
  45326. /**
  45327. * Serializes the actions and its related information.
  45328. * @param parent defines the object to serialize in
  45329. * @returns the serialized object
  45330. */
  45331. serialize(parent: any): any;
  45332. }
  45333. }
  45334. declare module BABYLON {
  45335. /**
  45336. * This represents the default audio engine used in babylon.
  45337. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45338. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45339. */
  45340. export class AudioEngine implements IAudioEngine {
  45341. private _audioContext;
  45342. private _audioContextInitialized;
  45343. private _muteButton;
  45344. private _hostElement;
  45345. /**
  45346. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45347. */
  45348. canUseWebAudio: boolean;
  45349. /**
  45350. * The master gain node defines the global audio volume of your audio engine.
  45351. */
  45352. masterGain: GainNode;
  45353. /**
  45354. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45355. * @ignoreNaming
  45356. */
  45357. WarnedWebAudioUnsupported: boolean;
  45358. /**
  45359. * Gets whether or not mp3 are supported by your browser.
  45360. */
  45361. isMP3supported: boolean;
  45362. /**
  45363. * Gets whether or not ogg are supported by your browser.
  45364. */
  45365. isOGGsupported: boolean;
  45366. /**
  45367. * Gets whether audio has been unlocked on the device.
  45368. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45369. * a user interaction has happened.
  45370. */
  45371. unlocked: boolean;
  45372. /**
  45373. * Defines if the audio engine relies on a custom unlocked button.
  45374. * In this case, the embedded button will not be displayed.
  45375. */
  45376. useCustomUnlockedButton: boolean;
  45377. /**
  45378. * Event raised when audio has been unlocked on the browser.
  45379. */
  45380. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45381. /**
  45382. * Event raised when audio has been locked on the browser.
  45383. */
  45384. onAudioLockedObservable: Observable<IAudioEngine>;
  45385. /**
  45386. * Gets the current AudioContext if available.
  45387. */
  45388. get audioContext(): Nullable<AudioContext>;
  45389. private _connectedAnalyser;
  45390. /**
  45391. * Instantiates a new audio engine.
  45392. *
  45393. * There should be only one per page as some browsers restrict the number
  45394. * of audio contexts you can create.
  45395. * @param hostElement defines the host element where to display the mute icon if necessary
  45396. */
  45397. constructor(hostElement?: Nullable<HTMLElement>);
  45398. /**
  45399. * Flags the audio engine in Locked state.
  45400. * This happens due to new browser policies preventing audio to autoplay.
  45401. */
  45402. lock(): void;
  45403. /**
  45404. * Unlocks the audio engine once a user action has been done on the dom.
  45405. * This is helpful to resume play once browser policies have been satisfied.
  45406. */
  45407. unlock(): void;
  45408. private _resumeAudioContext;
  45409. private _initializeAudioContext;
  45410. private _tryToRun;
  45411. private _triggerRunningState;
  45412. private _triggerSuspendedState;
  45413. private _displayMuteButton;
  45414. private _moveButtonToTopLeft;
  45415. private _onResize;
  45416. private _hideMuteButton;
  45417. /**
  45418. * Destroy and release the resources associated with the audio ccontext.
  45419. */
  45420. dispose(): void;
  45421. /**
  45422. * Gets the global volume sets on the master gain.
  45423. * @returns the global volume if set or -1 otherwise
  45424. */
  45425. getGlobalVolume(): number;
  45426. /**
  45427. * Sets the global volume of your experience (sets on the master gain).
  45428. * @param newVolume Defines the new global volume of the application
  45429. */
  45430. setGlobalVolume(newVolume: number): void;
  45431. /**
  45432. * Connect the audio engine to an audio analyser allowing some amazing
  45433. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45434. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45435. * @param analyser The analyser to connect to the engine
  45436. */
  45437. connectToAnalyser(analyser: Analyser): void;
  45438. }
  45439. }
  45440. declare module BABYLON {
  45441. /**
  45442. * Options allowed during the creation of a sound track.
  45443. */
  45444. export interface ISoundTrackOptions {
  45445. /**
  45446. * The volume the sound track should take during creation
  45447. */
  45448. volume?: number;
  45449. /**
  45450. * Define if the sound track is the main sound track of the scene
  45451. */
  45452. mainTrack?: boolean;
  45453. }
  45454. /**
  45455. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45456. * It will be also used in a future release to apply effects on a specific track.
  45457. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45458. */
  45459. export class SoundTrack {
  45460. /**
  45461. * The unique identifier of the sound track in the scene.
  45462. */
  45463. id: number;
  45464. /**
  45465. * The list of sounds included in the sound track.
  45466. */
  45467. soundCollection: Array<Sound>;
  45468. private _outputAudioNode;
  45469. private _scene;
  45470. private _connectedAnalyser;
  45471. private _options;
  45472. private _isInitialized;
  45473. /**
  45474. * Creates a new sound track.
  45475. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45476. * @param scene Define the scene the sound track belongs to
  45477. * @param options
  45478. */
  45479. constructor(scene: Scene, options?: ISoundTrackOptions);
  45480. private _initializeSoundTrackAudioGraph;
  45481. /**
  45482. * Release the sound track and its associated resources
  45483. */
  45484. dispose(): void;
  45485. /**
  45486. * Adds a sound to this sound track
  45487. * @param sound define the cound to add
  45488. * @ignoreNaming
  45489. */
  45490. addSound(sound: Sound): void;
  45491. /**
  45492. * Removes a sound to this sound track
  45493. * @param sound define the cound to remove
  45494. * @ignoreNaming
  45495. */
  45496. removeSound(sound: Sound): void;
  45497. /**
  45498. * Set a global volume for the full sound track.
  45499. * @param newVolume Define the new volume of the sound track
  45500. */
  45501. setVolume(newVolume: number): void;
  45502. /**
  45503. * Switch the panning model to HRTF:
  45504. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45505. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45506. */
  45507. switchPanningModelToHRTF(): void;
  45508. /**
  45509. * Switch the panning model to Equal Power:
  45510. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45511. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45512. */
  45513. switchPanningModelToEqualPower(): void;
  45514. /**
  45515. * Connect the sound track to an audio analyser allowing some amazing
  45516. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45517. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45518. * @param analyser The analyser to connect to the engine
  45519. */
  45520. connectToAnalyser(analyser: Analyser): void;
  45521. }
  45522. }
  45523. declare module BABYLON {
  45524. interface AbstractScene {
  45525. /**
  45526. * The list of sounds used in the scene.
  45527. */
  45528. sounds: Nullable<Array<Sound>>;
  45529. }
  45530. interface Scene {
  45531. /**
  45532. * @hidden
  45533. * Backing field
  45534. */
  45535. _mainSoundTrack: SoundTrack;
  45536. /**
  45537. * The main sound track played by the scene.
  45538. * It cotains your primary collection of sounds.
  45539. */
  45540. mainSoundTrack: SoundTrack;
  45541. /**
  45542. * The list of sound tracks added to the scene
  45543. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45544. */
  45545. soundTracks: Nullable<Array<SoundTrack>>;
  45546. /**
  45547. * Gets a sound using a given name
  45548. * @param name defines the name to search for
  45549. * @return the found sound or null if not found at all.
  45550. */
  45551. getSoundByName(name: string): Nullable<Sound>;
  45552. /**
  45553. * Gets or sets if audio support is enabled
  45554. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45555. */
  45556. audioEnabled: boolean;
  45557. /**
  45558. * Gets or sets if audio will be output to headphones
  45559. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45560. */
  45561. headphone: boolean;
  45562. /**
  45563. * Gets or sets custom audio listener position provider
  45564. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45565. */
  45566. audioListenerPositionProvider: Nullable<() => Vector3>;
  45567. /**
  45568. * Gets or sets a refresh rate when using 3D audio positioning
  45569. */
  45570. audioPositioningRefreshRate: number;
  45571. }
  45572. /**
  45573. * Defines the sound scene component responsible to manage any sounds
  45574. * in a given scene.
  45575. */
  45576. export class AudioSceneComponent implements ISceneSerializableComponent {
  45577. private static _CameraDirectionLH;
  45578. private static _CameraDirectionRH;
  45579. /**
  45580. * The component name helpfull to identify the component in the list of scene components.
  45581. */
  45582. readonly name: string;
  45583. /**
  45584. * The scene the component belongs to.
  45585. */
  45586. scene: Scene;
  45587. private _audioEnabled;
  45588. /**
  45589. * Gets whether audio is enabled or not.
  45590. * Please use related enable/disable method to switch state.
  45591. */
  45592. get audioEnabled(): boolean;
  45593. private _headphone;
  45594. /**
  45595. * Gets whether audio is outputing to headphone or not.
  45596. * Please use the according Switch methods to change output.
  45597. */
  45598. get headphone(): boolean;
  45599. /**
  45600. * Gets or sets a refresh rate when using 3D audio positioning
  45601. */
  45602. audioPositioningRefreshRate: number;
  45603. private _audioListenerPositionProvider;
  45604. /**
  45605. * Gets the current audio listener position provider
  45606. */
  45607. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45608. /**
  45609. * Sets a custom listener position for all sounds in the scene
  45610. * By default, this is the position of the first active camera
  45611. */
  45612. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45613. /**
  45614. * Creates a new instance of the component for the given scene
  45615. * @param scene Defines the scene to register the component in
  45616. */
  45617. constructor(scene: Scene);
  45618. /**
  45619. * Registers the component in a given scene
  45620. */
  45621. register(): void;
  45622. /**
  45623. * Rebuilds the elements related to this component in case of
  45624. * context lost for instance.
  45625. */
  45626. rebuild(): void;
  45627. /**
  45628. * Serializes the component data to the specified json object
  45629. * @param serializationObject The object to serialize to
  45630. */
  45631. serialize(serializationObject: any): void;
  45632. /**
  45633. * Adds all the elements from the container to the scene
  45634. * @param container the container holding the elements
  45635. */
  45636. addFromContainer(container: AbstractScene): void;
  45637. /**
  45638. * Removes all the elements in the container from the scene
  45639. * @param container contains the elements to remove
  45640. * @param dispose if the removed element should be disposed (default: false)
  45641. */
  45642. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45643. /**
  45644. * Disposes the component and the associated ressources.
  45645. */
  45646. dispose(): void;
  45647. /**
  45648. * Disables audio in the associated scene.
  45649. */
  45650. disableAudio(): void;
  45651. /**
  45652. * Enables audio in the associated scene.
  45653. */
  45654. enableAudio(): void;
  45655. /**
  45656. * Switch audio to headphone output.
  45657. */
  45658. switchAudioModeForHeadphones(): void;
  45659. /**
  45660. * Switch audio to normal speakers.
  45661. */
  45662. switchAudioModeForNormalSpeakers(): void;
  45663. private _cachedCameraDirection;
  45664. private _cachedCameraPosition;
  45665. private _lastCheck;
  45666. private _afterRender;
  45667. }
  45668. }
  45669. declare module BABYLON {
  45670. /**
  45671. * Wraps one or more Sound objects and selects one with random weight for playback.
  45672. */
  45673. export class WeightedSound {
  45674. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45675. loop: boolean;
  45676. private _coneInnerAngle;
  45677. private _coneOuterAngle;
  45678. private _volume;
  45679. /** A Sound is currently playing. */
  45680. isPlaying: boolean;
  45681. /** A Sound is currently paused. */
  45682. isPaused: boolean;
  45683. private _sounds;
  45684. private _weights;
  45685. private _currentIndex?;
  45686. /**
  45687. * Creates a new WeightedSound from the list of sounds given.
  45688. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45689. * @param sounds Array of Sounds that will be selected from.
  45690. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45691. */
  45692. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45693. /**
  45694. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45695. */
  45696. get directionalConeInnerAngle(): number;
  45697. /**
  45698. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45699. */
  45700. set directionalConeInnerAngle(value: number);
  45701. /**
  45702. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45703. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45704. */
  45705. get directionalConeOuterAngle(): number;
  45706. /**
  45707. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45708. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45709. */
  45710. set directionalConeOuterAngle(value: number);
  45711. /**
  45712. * Playback volume.
  45713. */
  45714. get volume(): number;
  45715. /**
  45716. * Playback volume.
  45717. */
  45718. set volume(value: number);
  45719. private _onended;
  45720. /**
  45721. * Suspend playback
  45722. */
  45723. pause(): void;
  45724. /**
  45725. * Stop playback
  45726. */
  45727. stop(): void;
  45728. /**
  45729. * Start playback.
  45730. * @param startOffset Position the clip head at a specific time in seconds.
  45731. */
  45732. play(startOffset?: number): void;
  45733. }
  45734. }
  45735. declare module BABYLON {
  45736. /**
  45737. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45738. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45739. */
  45740. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45741. /**
  45742. * Gets the name of the behavior.
  45743. */
  45744. get name(): string;
  45745. /**
  45746. * The easing function used by animations
  45747. */
  45748. static EasingFunction: BackEase;
  45749. /**
  45750. * The easing mode used by animations
  45751. */
  45752. static EasingMode: number;
  45753. /**
  45754. * The duration of the animation, in milliseconds
  45755. */
  45756. transitionDuration: number;
  45757. /**
  45758. * Length of the distance animated by the transition when lower radius is reached
  45759. */
  45760. lowerRadiusTransitionRange: number;
  45761. /**
  45762. * Length of the distance animated by the transition when upper radius is reached
  45763. */
  45764. upperRadiusTransitionRange: number;
  45765. private _autoTransitionRange;
  45766. /**
  45767. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45768. */
  45769. get autoTransitionRange(): boolean;
  45770. /**
  45771. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45772. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45773. */
  45774. set autoTransitionRange(value: boolean);
  45775. private _attachedCamera;
  45776. private _onAfterCheckInputsObserver;
  45777. private _onMeshTargetChangedObserver;
  45778. /**
  45779. * Initializes the behavior.
  45780. */
  45781. init(): void;
  45782. /**
  45783. * Attaches the behavior to its arc rotate camera.
  45784. * @param camera Defines the camera to attach the behavior to
  45785. */
  45786. attach(camera: ArcRotateCamera): void;
  45787. /**
  45788. * Detaches the behavior from its current arc rotate camera.
  45789. */
  45790. detach(): void;
  45791. private _radiusIsAnimating;
  45792. private _radiusBounceTransition;
  45793. private _animatables;
  45794. private _cachedWheelPrecision;
  45795. /**
  45796. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45797. * @param radiusLimit The limit to check against.
  45798. * @return Bool to indicate if at limit.
  45799. */
  45800. private _isRadiusAtLimit;
  45801. /**
  45802. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45803. * @param radiusDelta The delta by which to animate to. Can be negative.
  45804. */
  45805. private _applyBoundRadiusAnimation;
  45806. /**
  45807. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45808. */
  45809. protected _clearAnimationLocks(): void;
  45810. /**
  45811. * Stops and removes all animations that have been applied to the camera
  45812. */
  45813. stopAllAnimations(): void;
  45814. }
  45815. }
  45816. declare module BABYLON {
  45817. /**
  45818. * 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.
  45819. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45820. */
  45821. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45822. /**
  45823. * Gets the name of the behavior.
  45824. */
  45825. get name(): string;
  45826. private _mode;
  45827. private _radiusScale;
  45828. private _positionScale;
  45829. private _defaultElevation;
  45830. private _elevationReturnTime;
  45831. private _elevationReturnWaitTime;
  45832. private _zoomStopsAnimation;
  45833. private _framingTime;
  45834. /**
  45835. * The easing function used by animations
  45836. */
  45837. static EasingFunction: ExponentialEase;
  45838. /**
  45839. * The easing mode used by animations
  45840. */
  45841. static EasingMode: number;
  45842. /**
  45843. * Sets the current mode used by the behavior
  45844. */
  45845. set mode(mode: number);
  45846. /**
  45847. * Gets current mode used by the behavior.
  45848. */
  45849. get mode(): number;
  45850. /**
  45851. * Sets the scale applied to the radius (1 by default)
  45852. */
  45853. set radiusScale(radius: number);
  45854. /**
  45855. * Gets the scale applied to the radius
  45856. */
  45857. get radiusScale(): number;
  45858. /**
  45859. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45860. */
  45861. set positionScale(scale: number);
  45862. /**
  45863. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45864. */
  45865. get positionScale(): number;
  45866. /**
  45867. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45868. * behaviour is triggered, in radians.
  45869. */
  45870. set defaultElevation(elevation: number);
  45871. /**
  45872. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45873. * behaviour is triggered, in radians.
  45874. */
  45875. get defaultElevation(): number;
  45876. /**
  45877. * Sets the time (in milliseconds) taken to return to the default beta position.
  45878. * Negative value indicates camera should not return to default.
  45879. */
  45880. set elevationReturnTime(speed: number);
  45881. /**
  45882. * Gets the time (in milliseconds) taken to return to the default beta position.
  45883. * Negative value indicates camera should not return to default.
  45884. */
  45885. get elevationReturnTime(): number;
  45886. /**
  45887. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45888. */
  45889. set elevationReturnWaitTime(time: number);
  45890. /**
  45891. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45892. */
  45893. get elevationReturnWaitTime(): number;
  45894. /**
  45895. * Sets the flag that indicates if user zooming should stop animation.
  45896. */
  45897. set zoomStopsAnimation(flag: boolean);
  45898. /**
  45899. * Gets the flag that indicates if user zooming should stop animation.
  45900. */
  45901. get zoomStopsAnimation(): boolean;
  45902. /**
  45903. * Sets the transition time when framing the mesh, in milliseconds
  45904. */
  45905. set framingTime(time: number);
  45906. /**
  45907. * Gets the transition time when framing the mesh, in milliseconds
  45908. */
  45909. get framingTime(): number;
  45910. /**
  45911. * Define if the behavior should automatically change the configured
  45912. * camera limits and sensibilities.
  45913. */
  45914. autoCorrectCameraLimitsAndSensibility: boolean;
  45915. private _onPrePointerObservableObserver;
  45916. private _onAfterCheckInputsObserver;
  45917. private _onMeshTargetChangedObserver;
  45918. private _attachedCamera;
  45919. private _isPointerDown;
  45920. private _lastInteractionTime;
  45921. /**
  45922. * Initializes the behavior.
  45923. */
  45924. init(): void;
  45925. /**
  45926. * Attaches the behavior to its arc rotate camera.
  45927. * @param camera Defines the camera to attach the behavior to
  45928. */
  45929. attach(camera: ArcRotateCamera): void;
  45930. /**
  45931. * Detaches the behavior from its current arc rotate camera.
  45932. */
  45933. detach(): void;
  45934. private _animatables;
  45935. private _betaIsAnimating;
  45936. private _betaTransition;
  45937. private _radiusTransition;
  45938. private _vectorTransition;
  45939. /**
  45940. * Targets the given mesh and updates zoom level accordingly.
  45941. * @param mesh The mesh to target.
  45942. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45943. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45944. */
  45945. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45946. /**
  45947. * Targets the given mesh with its children and updates zoom level accordingly.
  45948. * @param mesh The mesh to target.
  45949. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45950. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45951. */
  45952. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45953. /**
  45954. * Targets the given meshes with their children and updates zoom level accordingly.
  45955. * @param meshes The mesh to target.
  45956. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45957. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45958. */
  45959. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45960. /**
  45961. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45962. * @param minimumWorld Determines the smaller position of the bounding box extend
  45963. * @param maximumWorld Determines the bigger position of the bounding box extend
  45964. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45965. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45966. */
  45967. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45968. /**
  45969. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45970. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45971. * frustum width.
  45972. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45973. * to fully enclose the mesh in the viewing frustum.
  45974. */
  45975. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45976. /**
  45977. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45978. * is automatically returned to its default position (expected to be above ground plane).
  45979. */
  45980. private _maintainCameraAboveGround;
  45981. /**
  45982. * Returns the frustum slope based on the canvas ratio and camera FOV
  45983. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45984. */
  45985. private _getFrustumSlope;
  45986. /**
  45987. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45988. */
  45989. private _clearAnimationLocks;
  45990. /**
  45991. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45992. */
  45993. private _applyUserInteraction;
  45994. /**
  45995. * Stops and removes all animations that have been applied to the camera
  45996. */
  45997. stopAllAnimations(): void;
  45998. /**
  45999. * Gets a value indicating if the user is moving the camera
  46000. */
  46001. get isUserIsMoving(): boolean;
  46002. /**
  46003. * The camera can move all the way towards the mesh.
  46004. */
  46005. static IgnoreBoundsSizeMode: number;
  46006. /**
  46007. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  46008. */
  46009. static FitFrustumSidesMode: number;
  46010. }
  46011. }
  46012. declare module BABYLON {
  46013. /**
  46014. * Base class for Camera Pointer Inputs.
  46015. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  46016. * for example usage.
  46017. */
  46018. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  46019. /**
  46020. * Defines the camera the input is attached to.
  46021. */
  46022. abstract camera: Camera;
  46023. /**
  46024. * Whether keyboard modifier keys are pressed at time of last mouse event.
  46025. */
  46026. protected _altKey: boolean;
  46027. protected _ctrlKey: boolean;
  46028. protected _metaKey: boolean;
  46029. protected _shiftKey: boolean;
  46030. /**
  46031. * Which mouse buttons were pressed at time of last mouse event.
  46032. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  46033. */
  46034. protected _buttonsPressed: number;
  46035. /**
  46036. * Defines the buttons associated with the input to handle camera move.
  46037. */
  46038. buttons: number[];
  46039. /**
  46040. * Attach the input controls to a specific dom element to get the input from.
  46041. * @param element Defines the element the controls should be listened from
  46042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46043. */
  46044. attachControl(noPreventDefault?: boolean): void;
  46045. /**
  46046. * Detach the current controls from the specified dom element.
  46047. */
  46048. detachControl(): void;
  46049. /**
  46050. * Gets the class name of the current input.
  46051. * @returns the class name
  46052. */
  46053. getClassName(): string;
  46054. /**
  46055. * Get the friendly name associated with the input class.
  46056. * @returns the input friendly name
  46057. */
  46058. getSimpleName(): string;
  46059. /**
  46060. * Called on pointer POINTERDOUBLETAP event.
  46061. * Override this method to provide functionality on POINTERDOUBLETAP event.
  46062. */
  46063. protected onDoubleTap(type: string): void;
  46064. /**
  46065. * Called on pointer POINTERMOVE event if only a single touch is active.
  46066. * Override this method to provide functionality.
  46067. */
  46068. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46069. /**
  46070. * Called on pointer POINTERMOVE event if multiple touches are active.
  46071. * Override this method to provide functionality.
  46072. */
  46073. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46074. /**
  46075. * Called on JS contextmenu event.
  46076. * Override this method to provide functionality.
  46077. */
  46078. protected onContextMenu(evt: PointerEvent): void;
  46079. /**
  46080. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46081. * press.
  46082. * Override this method to provide functionality.
  46083. */
  46084. protected onButtonDown(evt: PointerEvent): void;
  46085. /**
  46086. * Called each time a new POINTERUP event occurs. Ie, for each button
  46087. * release.
  46088. * Override this method to provide functionality.
  46089. */
  46090. protected onButtonUp(evt: PointerEvent): void;
  46091. /**
  46092. * Called when window becomes inactive.
  46093. * Override this method to provide functionality.
  46094. */
  46095. protected onLostFocus(): void;
  46096. private _pointerInput;
  46097. private _observer;
  46098. private _onLostFocus;
  46099. private pointA;
  46100. private pointB;
  46101. }
  46102. }
  46103. declare module BABYLON {
  46104. /**
  46105. * Manage the pointers inputs to control an arc rotate camera.
  46106. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46107. */
  46108. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  46109. /**
  46110. * Defines the camera the input is attached to.
  46111. */
  46112. camera: ArcRotateCamera;
  46113. /**
  46114. * Gets the class name of the current input.
  46115. * @returns the class name
  46116. */
  46117. getClassName(): string;
  46118. /**
  46119. * Defines the buttons associated with the input to handle camera move.
  46120. */
  46121. buttons: number[];
  46122. /**
  46123. * Defines the pointer angular sensibility along the X axis or how fast is
  46124. * the camera rotating.
  46125. */
  46126. angularSensibilityX: number;
  46127. /**
  46128. * Defines the pointer angular sensibility along the Y axis or how fast is
  46129. * the camera rotating.
  46130. */
  46131. angularSensibilityY: number;
  46132. /**
  46133. * Defines the pointer pinch precision or how fast is the camera zooming.
  46134. */
  46135. pinchPrecision: number;
  46136. /**
  46137. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46138. * from 0.
  46139. * It defines the percentage of current camera.radius to use as delta when
  46140. * pinch zoom is used.
  46141. */
  46142. pinchDeltaPercentage: number;
  46143. /**
  46144. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46145. * that any object in the plane at the camera's target point will scale
  46146. * perfectly with finger motion.
  46147. * Overrides pinchDeltaPercentage and pinchPrecision.
  46148. */
  46149. useNaturalPinchZoom: boolean;
  46150. /**
  46151. * Defines the pointer panning sensibility or how fast is the camera moving.
  46152. */
  46153. panningSensibility: number;
  46154. /**
  46155. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46156. */
  46157. multiTouchPanning: boolean;
  46158. /**
  46159. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46160. * zoom (pinch) through multitouch.
  46161. */
  46162. multiTouchPanAndZoom: boolean;
  46163. /**
  46164. * Revers pinch action direction.
  46165. */
  46166. pinchInwards: boolean;
  46167. private _isPanClick;
  46168. private _twoFingerActivityCount;
  46169. private _isPinching;
  46170. /**
  46171. * Called on pointer POINTERMOVE event if only a single touch is active.
  46172. */
  46173. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46174. /**
  46175. * Called on pointer POINTERDOUBLETAP event.
  46176. */
  46177. protected onDoubleTap(type: string): void;
  46178. /**
  46179. * Called on pointer POINTERMOVE event if multiple touches are active.
  46180. */
  46181. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46182. /**
  46183. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46184. * press.
  46185. */
  46186. protected onButtonDown(evt: PointerEvent): void;
  46187. /**
  46188. * Called each time a new POINTERUP event occurs. Ie, for each button
  46189. * release.
  46190. */
  46191. protected onButtonUp(evt: PointerEvent): void;
  46192. /**
  46193. * Called when window becomes inactive.
  46194. */
  46195. protected onLostFocus(): void;
  46196. }
  46197. }
  46198. declare module BABYLON {
  46199. /**
  46200. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46201. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46202. */
  46203. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46204. /**
  46205. * Defines the camera the input is attached to.
  46206. */
  46207. camera: ArcRotateCamera;
  46208. /**
  46209. * Defines the list of key codes associated with the up action (increase alpha)
  46210. */
  46211. keysUp: number[];
  46212. /**
  46213. * Defines the list of key codes associated with the down action (decrease alpha)
  46214. */
  46215. keysDown: number[];
  46216. /**
  46217. * Defines the list of key codes associated with the left action (increase beta)
  46218. */
  46219. keysLeft: number[];
  46220. /**
  46221. * Defines the list of key codes associated with the right action (decrease beta)
  46222. */
  46223. keysRight: number[];
  46224. /**
  46225. * Defines the list of key codes associated with the reset action.
  46226. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46227. */
  46228. keysReset: number[];
  46229. /**
  46230. * Defines the panning sensibility of the inputs.
  46231. * (How fast is the camera panning)
  46232. */
  46233. panningSensibility: number;
  46234. /**
  46235. * Defines the zooming sensibility of the inputs.
  46236. * (How fast is the camera zooming)
  46237. */
  46238. zoomingSensibility: number;
  46239. /**
  46240. * Defines whether maintaining the alt key down switch the movement mode from
  46241. * orientation to zoom.
  46242. */
  46243. useAltToZoom: boolean;
  46244. /**
  46245. * Rotation speed of the camera
  46246. */
  46247. angularSpeed: number;
  46248. private _keys;
  46249. private _ctrlPressed;
  46250. private _altPressed;
  46251. private _onCanvasBlurObserver;
  46252. private _onKeyboardObserver;
  46253. private _engine;
  46254. private _scene;
  46255. /**
  46256. * Attach the input controls to a specific dom element to get the input from.
  46257. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46258. */
  46259. attachControl(noPreventDefault?: boolean): void;
  46260. /**
  46261. * Detach the current controls from the specified dom element.
  46262. */
  46263. detachControl(): void;
  46264. /**
  46265. * Update the current camera state depending on the inputs that have been used this frame.
  46266. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46267. */
  46268. checkInputs(): void;
  46269. /**
  46270. * Gets the class name of the current intput.
  46271. * @returns the class name
  46272. */
  46273. getClassName(): string;
  46274. /**
  46275. * Get the friendly name associated with the input class.
  46276. * @returns the input friendly name
  46277. */
  46278. getSimpleName(): string;
  46279. }
  46280. }
  46281. declare module BABYLON {
  46282. /**
  46283. * Manage the mouse wheel inputs to control an arc rotate camera.
  46284. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46285. */
  46286. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46287. /**
  46288. * Defines the camera the input is attached to.
  46289. */
  46290. camera: ArcRotateCamera;
  46291. /**
  46292. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46293. */
  46294. wheelPrecision: number;
  46295. /**
  46296. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46297. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46298. */
  46299. wheelDeltaPercentage: number;
  46300. private _wheel;
  46301. private _observer;
  46302. private computeDeltaFromMouseWheelLegacyEvent;
  46303. /**
  46304. * Attach the input controls to a specific dom element to get the input from.
  46305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46306. */
  46307. attachControl(noPreventDefault?: boolean): void;
  46308. /**
  46309. * Detach the current controls from the specified dom element.
  46310. */
  46311. detachControl(): void;
  46312. /**
  46313. * Gets the class name of the current intput.
  46314. * @returns the class name
  46315. */
  46316. getClassName(): string;
  46317. /**
  46318. * Get the friendly name associated with the input class.
  46319. * @returns the input friendly name
  46320. */
  46321. getSimpleName(): string;
  46322. }
  46323. }
  46324. declare module BABYLON {
  46325. /**
  46326. * Default Inputs manager for the ArcRotateCamera.
  46327. * It groups all the default supported inputs for ease of use.
  46328. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46329. */
  46330. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46331. /**
  46332. * Instantiates a new ArcRotateCameraInputsManager.
  46333. * @param camera Defines the camera the inputs belong to
  46334. */
  46335. constructor(camera: ArcRotateCamera);
  46336. /**
  46337. * Add mouse wheel input support to the input manager.
  46338. * @returns the current input manager
  46339. */
  46340. addMouseWheel(): ArcRotateCameraInputsManager;
  46341. /**
  46342. * Add pointers input support to the input manager.
  46343. * @returns the current input manager
  46344. */
  46345. addPointers(): ArcRotateCameraInputsManager;
  46346. /**
  46347. * Add keyboard input support to the input manager.
  46348. * @returns the current input manager
  46349. */
  46350. addKeyboard(): ArcRotateCameraInputsManager;
  46351. }
  46352. }
  46353. declare module BABYLON {
  46354. /**
  46355. * This represents an orbital type of camera.
  46356. *
  46357. * 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.
  46358. * 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.
  46359. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46360. */
  46361. export class ArcRotateCamera extends TargetCamera {
  46362. /**
  46363. * Defines the rotation angle of the camera along the longitudinal axis.
  46364. */
  46365. alpha: number;
  46366. /**
  46367. * Defines the rotation angle of the camera along the latitudinal axis.
  46368. */
  46369. beta: number;
  46370. /**
  46371. * Defines the radius of the camera from it s target point.
  46372. */
  46373. radius: number;
  46374. protected _target: Vector3;
  46375. protected _targetHost: Nullable<AbstractMesh>;
  46376. /**
  46377. * Defines the target point of the camera.
  46378. * The camera looks towards it form the radius distance.
  46379. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46380. */
  46381. get target(): Vector3;
  46382. set target(value: Vector3);
  46383. /**
  46384. * Define the current local position of the camera in the scene
  46385. */
  46386. get position(): Vector3;
  46387. set position(newPosition: Vector3);
  46388. protected _upToYMatrix: Matrix;
  46389. protected _YToUpMatrix: Matrix;
  46390. /**
  46391. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46392. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46393. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46394. */
  46395. set upVector(vec: Vector3);
  46396. get upVector(): Vector3;
  46397. /**
  46398. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46399. */
  46400. setMatUp(): void;
  46401. /**
  46402. * Current inertia value on the longitudinal axis.
  46403. * The bigger this number the longer it will take for the camera to stop.
  46404. */
  46405. inertialAlphaOffset: number;
  46406. /**
  46407. * Current inertia value on the latitudinal axis.
  46408. * The bigger this number the longer it will take for the camera to stop.
  46409. */
  46410. inertialBetaOffset: number;
  46411. /**
  46412. * Current inertia value on the radius axis.
  46413. * The bigger this number the longer it will take for the camera to stop.
  46414. */
  46415. inertialRadiusOffset: number;
  46416. /**
  46417. * Minimum allowed angle on the longitudinal axis.
  46418. * This can help limiting how the Camera is able to move in the scene.
  46419. */
  46420. lowerAlphaLimit: Nullable<number>;
  46421. /**
  46422. * Maximum allowed angle on the longitudinal axis.
  46423. * This can help limiting how the Camera is able to move in the scene.
  46424. */
  46425. upperAlphaLimit: Nullable<number>;
  46426. /**
  46427. * Minimum allowed angle on the latitudinal axis.
  46428. * This can help limiting how the Camera is able to move in the scene.
  46429. */
  46430. lowerBetaLimit: number;
  46431. /**
  46432. * Maximum allowed angle on the latitudinal axis.
  46433. * This can help limiting how the Camera is able to move in the scene.
  46434. */
  46435. upperBetaLimit: number;
  46436. /**
  46437. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46438. * This can help limiting how the Camera is able to move in the scene.
  46439. */
  46440. lowerRadiusLimit: Nullable<number>;
  46441. /**
  46442. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46443. * This can help limiting how the Camera is able to move in the scene.
  46444. */
  46445. upperRadiusLimit: Nullable<number>;
  46446. /**
  46447. * Defines the current inertia value used during panning of the camera along the X axis.
  46448. */
  46449. inertialPanningX: number;
  46450. /**
  46451. * Defines the current inertia value used during panning of the camera along the Y axis.
  46452. */
  46453. inertialPanningY: number;
  46454. /**
  46455. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46456. * Basically if your fingers moves away from more than this distance you will be considered
  46457. * in pinch mode.
  46458. */
  46459. pinchToPanMaxDistance: number;
  46460. /**
  46461. * Defines the maximum distance the camera can pan.
  46462. * This could help keeping the cammera always in your scene.
  46463. */
  46464. panningDistanceLimit: Nullable<number>;
  46465. /**
  46466. * Defines the target of the camera before paning.
  46467. */
  46468. panningOriginTarget: Vector3;
  46469. /**
  46470. * Defines the value of the inertia used during panning.
  46471. * 0 would mean stop inertia and one would mean no decelleration at all.
  46472. */
  46473. panningInertia: number;
  46474. /**
  46475. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46476. */
  46477. get angularSensibilityX(): number;
  46478. set angularSensibilityX(value: number);
  46479. /**
  46480. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46481. */
  46482. get angularSensibilityY(): number;
  46483. set angularSensibilityY(value: number);
  46484. /**
  46485. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46486. */
  46487. get pinchPrecision(): number;
  46488. set pinchPrecision(value: number);
  46489. /**
  46490. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46491. * It will be used instead of pinchDeltaPrecision if different from 0.
  46492. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46493. */
  46494. get pinchDeltaPercentage(): number;
  46495. set pinchDeltaPercentage(value: number);
  46496. /**
  46497. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46498. * and pinch delta percentage.
  46499. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46500. * that any object in the plane at the camera's target point will scale
  46501. * perfectly with finger motion.
  46502. */
  46503. get useNaturalPinchZoom(): boolean;
  46504. set useNaturalPinchZoom(value: boolean);
  46505. /**
  46506. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46507. */
  46508. get panningSensibility(): number;
  46509. set panningSensibility(value: number);
  46510. /**
  46511. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46512. */
  46513. get keysUp(): number[];
  46514. set keysUp(value: number[]);
  46515. /**
  46516. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46517. */
  46518. get keysDown(): number[];
  46519. set keysDown(value: number[]);
  46520. /**
  46521. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46522. */
  46523. get keysLeft(): number[];
  46524. set keysLeft(value: number[]);
  46525. /**
  46526. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46527. */
  46528. get keysRight(): number[];
  46529. set keysRight(value: number[]);
  46530. /**
  46531. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46532. */
  46533. get wheelPrecision(): number;
  46534. set wheelPrecision(value: number);
  46535. /**
  46536. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46537. * It will be used instead of pinchDeltaPrecision if different from 0.
  46538. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46539. */
  46540. get wheelDeltaPercentage(): number;
  46541. set wheelDeltaPercentage(value: number);
  46542. /**
  46543. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46544. */
  46545. zoomOnFactor: number;
  46546. /**
  46547. * Defines a screen offset for the camera position.
  46548. */
  46549. targetScreenOffset: Vector2;
  46550. /**
  46551. * Allows the camera to be completely reversed.
  46552. * If false the camera can not arrive upside down.
  46553. */
  46554. allowUpsideDown: boolean;
  46555. /**
  46556. * Define if double tap/click is used to restore the previously saved state of the camera.
  46557. */
  46558. useInputToRestoreState: boolean;
  46559. /** @hidden */
  46560. _viewMatrix: Matrix;
  46561. /** @hidden */
  46562. _useCtrlForPanning: boolean;
  46563. /** @hidden */
  46564. _panningMouseButton: number;
  46565. /**
  46566. * Defines the input associated to the camera.
  46567. */
  46568. inputs: ArcRotateCameraInputsManager;
  46569. /** @hidden */
  46570. _reset: () => void;
  46571. /**
  46572. * Defines the allowed panning axis.
  46573. */
  46574. panningAxis: Vector3;
  46575. protected _localDirection: Vector3;
  46576. protected _transformedDirection: Vector3;
  46577. private _bouncingBehavior;
  46578. /**
  46579. * Gets the bouncing behavior of the camera if it has been enabled.
  46580. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46581. */
  46582. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46583. /**
  46584. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46585. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46586. */
  46587. get useBouncingBehavior(): boolean;
  46588. set useBouncingBehavior(value: boolean);
  46589. private _framingBehavior;
  46590. /**
  46591. * Gets the framing behavior of the camera if it has been enabled.
  46592. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46593. */
  46594. get framingBehavior(): Nullable<FramingBehavior>;
  46595. /**
  46596. * Defines if the framing behavior of the camera is enabled on the camera.
  46597. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46598. */
  46599. get useFramingBehavior(): boolean;
  46600. set useFramingBehavior(value: boolean);
  46601. private _autoRotationBehavior;
  46602. /**
  46603. * Gets the auto rotation behavior of the camera if it has been enabled.
  46604. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46605. */
  46606. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46607. /**
  46608. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46609. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46610. */
  46611. get useAutoRotationBehavior(): boolean;
  46612. set useAutoRotationBehavior(value: boolean);
  46613. /**
  46614. * Observable triggered when the mesh target has been changed on the camera.
  46615. */
  46616. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46617. /**
  46618. * Event raised when the camera is colliding with a mesh.
  46619. */
  46620. onCollide: (collidedMesh: AbstractMesh) => void;
  46621. /**
  46622. * Defines whether the camera should check collision with the objects oh the scene.
  46623. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46624. */
  46625. checkCollisions: boolean;
  46626. /**
  46627. * Defines the collision radius of the camera.
  46628. * This simulates a sphere around the camera.
  46629. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46630. */
  46631. collisionRadius: Vector3;
  46632. protected _collider: Collider;
  46633. protected _previousPosition: Vector3;
  46634. protected _collisionVelocity: Vector3;
  46635. protected _newPosition: Vector3;
  46636. protected _previousAlpha: number;
  46637. protected _previousBeta: number;
  46638. protected _previousRadius: number;
  46639. protected _collisionTriggered: boolean;
  46640. protected _targetBoundingCenter: Nullable<Vector3>;
  46641. private _computationVector;
  46642. /**
  46643. * Instantiates a new ArcRotateCamera in a given scene
  46644. * @param name Defines the name of the camera
  46645. * @param alpha Defines the camera rotation along the logitudinal axis
  46646. * @param beta Defines the camera rotation along the latitudinal axis
  46647. * @param radius Defines the camera distance from its target
  46648. * @param target Defines the camera target
  46649. * @param scene Defines the scene the camera belongs to
  46650. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46651. */
  46652. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46653. /** @hidden */
  46654. _initCache(): void;
  46655. /** @hidden */
  46656. _updateCache(ignoreParentClass?: boolean): void;
  46657. protected _getTargetPosition(): Vector3;
  46658. private _storedAlpha;
  46659. private _storedBeta;
  46660. private _storedRadius;
  46661. private _storedTarget;
  46662. private _storedTargetScreenOffset;
  46663. /**
  46664. * Stores the current state of the camera (alpha, beta, radius and target)
  46665. * @returns the camera itself
  46666. */
  46667. storeState(): Camera;
  46668. /**
  46669. * @hidden
  46670. * Restored camera state. You must call storeState() first
  46671. */
  46672. _restoreStateValues(): boolean;
  46673. /** @hidden */
  46674. _isSynchronizedViewMatrix(): boolean;
  46675. /**
  46676. * Attach the input controls to a specific dom element to get the input from.
  46677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46678. */
  46679. attachControl(noPreventDefault?: boolean): void;
  46680. /**
  46681. * Attach the input controls to a specific dom element to get the input from.
  46682. * @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
  46683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46684. */
  46685. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46686. /**
  46687. * Attached controls to the current camera.
  46688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46689. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46690. */
  46691. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46692. /**
  46693. * Attached controls to the current camera.
  46694. * @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
  46695. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46696. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46697. */
  46698. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46699. /**
  46700. * Attached controls to the current camera.
  46701. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46702. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46703. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46704. */
  46705. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46706. /**
  46707. * Detach the current controls from the specified dom element.
  46708. */
  46709. detachControl(): void;
  46710. /**
  46711. * Detach the current controls from the specified dom element.
  46712. * @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
  46713. */
  46714. detachControl(ignored: any): void;
  46715. /** @hidden */
  46716. _checkInputs(): void;
  46717. protected _checkLimits(): void;
  46718. /**
  46719. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46720. */
  46721. rebuildAnglesAndRadius(): void;
  46722. /**
  46723. * Use a position to define the current camera related information like alpha, beta and radius
  46724. * @param position Defines the position to set the camera at
  46725. */
  46726. setPosition(position: Vector3): void;
  46727. /**
  46728. * Defines the target the camera should look at.
  46729. * This will automatically adapt alpha beta and radius to fit within the new target.
  46730. * @param target Defines the new target as a Vector or a mesh
  46731. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46732. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46733. */
  46734. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46735. /** @hidden */
  46736. _getViewMatrix(): Matrix;
  46737. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46738. /**
  46739. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46740. * @param meshes Defines the mesh to zoom on
  46741. * @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)
  46742. */
  46743. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46744. /**
  46745. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46746. * The target will be changed but the radius
  46747. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46748. * @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)
  46749. */
  46750. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46751. min: Vector3;
  46752. max: Vector3;
  46753. distance: number;
  46754. }, doNotUpdateMaxZ?: boolean): void;
  46755. /**
  46756. * @override
  46757. * Override Camera.createRigCamera
  46758. */
  46759. createRigCamera(name: string, cameraIndex: number): Camera;
  46760. /**
  46761. * @hidden
  46762. * @override
  46763. * Override Camera._updateRigCameras
  46764. */
  46765. _updateRigCameras(): void;
  46766. /**
  46767. * Destroy the camera and release the current resources hold by it.
  46768. */
  46769. dispose(): void;
  46770. /**
  46771. * Gets the current object class name.
  46772. * @return the class name
  46773. */
  46774. getClassName(): string;
  46775. }
  46776. }
  46777. declare module BABYLON {
  46778. /**
  46779. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46780. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46781. */
  46782. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46783. /**
  46784. * Gets the name of the behavior.
  46785. */
  46786. get name(): string;
  46787. private _zoomStopsAnimation;
  46788. private _idleRotationSpeed;
  46789. private _idleRotationWaitTime;
  46790. private _idleRotationSpinupTime;
  46791. /**
  46792. * Sets the flag that indicates if user zooming should stop animation.
  46793. */
  46794. set zoomStopsAnimation(flag: boolean);
  46795. /**
  46796. * Gets the flag that indicates if user zooming should stop animation.
  46797. */
  46798. get zoomStopsAnimation(): boolean;
  46799. /**
  46800. * Sets the default speed at which the camera rotates around the model.
  46801. */
  46802. set idleRotationSpeed(speed: number);
  46803. /**
  46804. * Gets the default speed at which the camera rotates around the model.
  46805. */
  46806. get idleRotationSpeed(): number;
  46807. /**
  46808. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46809. */
  46810. set idleRotationWaitTime(time: number);
  46811. /**
  46812. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46813. */
  46814. get idleRotationWaitTime(): number;
  46815. /**
  46816. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46817. */
  46818. set idleRotationSpinupTime(time: number);
  46819. /**
  46820. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46821. */
  46822. get idleRotationSpinupTime(): number;
  46823. /**
  46824. * Gets a value indicating if the camera is currently rotating because of this behavior
  46825. */
  46826. get rotationInProgress(): boolean;
  46827. private _onPrePointerObservableObserver;
  46828. private _onAfterCheckInputsObserver;
  46829. private _attachedCamera;
  46830. private _isPointerDown;
  46831. private _lastFrameTime;
  46832. private _lastInteractionTime;
  46833. private _cameraRotationSpeed;
  46834. /**
  46835. * Initializes the behavior.
  46836. */
  46837. init(): void;
  46838. /**
  46839. * Attaches the behavior to its arc rotate camera.
  46840. * @param camera Defines the camera to attach the behavior to
  46841. */
  46842. attach(camera: ArcRotateCamera): void;
  46843. /**
  46844. * Detaches the behavior from its current arc rotate camera.
  46845. */
  46846. detach(): void;
  46847. /**
  46848. * Returns true if user is scrolling.
  46849. * @return true if user is scrolling.
  46850. */
  46851. private _userIsZooming;
  46852. private _lastFrameRadius;
  46853. private _shouldAnimationStopForInteraction;
  46854. /**
  46855. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46856. */
  46857. private _applyUserInteraction;
  46858. private _userIsMoving;
  46859. }
  46860. }
  46861. declare module BABYLON {
  46862. /**
  46863. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46864. */
  46865. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46866. private ui;
  46867. /**
  46868. * The name of the behavior
  46869. */
  46870. name: string;
  46871. /**
  46872. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46873. */
  46874. distanceAwayFromFace: number;
  46875. /**
  46876. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46877. */
  46878. distanceAwayFromBottomOfFace: number;
  46879. private _faceVectors;
  46880. private _target;
  46881. private _scene;
  46882. private _onRenderObserver;
  46883. private _tmpMatrix;
  46884. private _tmpVector;
  46885. /**
  46886. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46887. * @param ui The transform node that should be attched to the mesh
  46888. */
  46889. constructor(ui: TransformNode);
  46890. /**
  46891. * Initializes the behavior
  46892. */
  46893. init(): void;
  46894. private _closestFace;
  46895. private _zeroVector;
  46896. private _lookAtTmpMatrix;
  46897. private _lookAtToRef;
  46898. /**
  46899. * Attaches the AttachToBoxBehavior to the passed in mesh
  46900. * @param target The mesh that the specified node will be attached to
  46901. */
  46902. attach(target: Mesh): void;
  46903. /**
  46904. * Detaches the behavior from the mesh
  46905. */
  46906. detach(): void;
  46907. }
  46908. }
  46909. declare module BABYLON {
  46910. /**
  46911. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46912. */
  46913. export class FadeInOutBehavior implements Behavior<Mesh> {
  46914. /**
  46915. * Time in milliseconds to delay before fading in (Default: 0)
  46916. */
  46917. delay: number;
  46918. /**
  46919. * Time in milliseconds for the mesh to fade in (Default: 300)
  46920. */
  46921. fadeInTime: number;
  46922. private _millisecondsPerFrame;
  46923. private _hovered;
  46924. private _hoverValue;
  46925. private _ownerNode;
  46926. /**
  46927. * Instatiates the FadeInOutBehavior
  46928. */
  46929. constructor();
  46930. /**
  46931. * The name of the behavior
  46932. */
  46933. get name(): string;
  46934. /**
  46935. * Initializes the behavior
  46936. */
  46937. init(): void;
  46938. /**
  46939. * Attaches the fade behavior on the passed in mesh
  46940. * @param ownerNode The mesh that will be faded in/out once attached
  46941. */
  46942. attach(ownerNode: Mesh): void;
  46943. /**
  46944. * Detaches the behavior from the mesh
  46945. */
  46946. detach(): void;
  46947. /**
  46948. * Triggers the mesh to begin fading in or out
  46949. * @param value if the object should fade in or out (true to fade in)
  46950. */
  46951. fadeIn(value: boolean): void;
  46952. private _update;
  46953. private _setAllVisibility;
  46954. }
  46955. }
  46956. declare module BABYLON {
  46957. /**
  46958. * Class containing a set of static utilities functions for managing Pivots
  46959. * @hidden
  46960. */
  46961. export class PivotTools {
  46962. private static _PivotCached;
  46963. private static _OldPivotPoint;
  46964. private static _PivotTranslation;
  46965. private static _PivotTmpVector;
  46966. private static _PivotPostMultiplyPivotMatrix;
  46967. /** @hidden */
  46968. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46969. /** @hidden */
  46970. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46971. }
  46972. }
  46973. declare module BABYLON {
  46974. /**
  46975. * Class containing static functions to help procedurally build meshes
  46976. */
  46977. export class PlaneBuilder {
  46978. /**
  46979. * Creates a plane mesh
  46980. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46981. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46982. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46984. * * 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
  46985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46986. * @param name defines the name of the mesh
  46987. * @param options defines the options used to create the mesh
  46988. * @param scene defines the hosting scene
  46989. * @returns the plane mesh
  46990. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46991. */
  46992. static CreatePlane(name: string, options: {
  46993. size?: number;
  46994. width?: number;
  46995. height?: number;
  46996. sideOrientation?: number;
  46997. frontUVs?: Vector4;
  46998. backUVs?: Vector4;
  46999. updatable?: boolean;
  47000. sourcePlane?: Plane;
  47001. }, scene?: Nullable<Scene>): Mesh;
  47002. }
  47003. }
  47004. declare module BABYLON {
  47005. /**
  47006. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  47007. */
  47008. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  47009. private static _AnyMouseID;
  47010. /**
  47011. * Abstract mesh the behavior is set on
  47012. */
  47013. attachedNode: AbstractMesh;
  47014. private _dragPlane;
  47015. private _scene;
  47016. private _pointerObserver;
  47017. private _beforeRenderObserver;
  47018. private static _planeScene;
  47019. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  47020. /**
  47021. * 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)
  47022. */
  47023. maxDragAngle: number;
  47024. /**
  47025. * @hidden
  47026. */
  47027. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  47028. /**
  47029. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47030. */
  47031. currentDraggingPointerID: number;
  47032. /**
  47033. * The last position where the pointer hit the drag plane in world space
  47034. */
  47035. lastDragPosition: Vector3;
  47036. /**
  47037. * If the behavior is currently in a dragging state
  47038. */
  47039. dragging: boolean;
  47040. /**
  47041. * 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)
  47042. */
  47043. dragDeltaRatio: number;
  47044. /**
  47045. * If the drag plane orientation should be updated during the dragging (Default: true)
  47046. */
  47047. updateDragPlane: boolean;
  47048. private _debugMode;
  47049. private _moving;
  47050. /**
  47051. * Fires each time the attached mesh is dragged with the pointer
  47052. * * delta between last drag position and current drag position in world space
  47053. * * dragDistance along the drag axis
  47054. * * dragPlaneNormal normal of the current drag plane used during the drag
  47055. * * dragPlanePoint in world space where the drag intersects the drag plane
  47056. */
  47057. onDragObservable: Observable<{
  47058. delta: Vector3;
  47059. dragPlanePoint: Vector3;
  47060. dragPlaneNormal: Vector3;
  47061. dragDistance: number;
  47062. pointerId: number;
  47063. }>;
  47064. /**
  47065. * Fires each time a drag begins (eg. mouse down on mesh)
  47066. */
  47067. onDragStartObservable: Observable<{
  47068. dragPlanePoint: Vector3;
  47069. pointerId: number;
  47070. }>;
  47071. /**
  47072. * Fires each time a drag ends (eg. mouse release after drag)
  47073. */
  47074. onDragEndObservable: Observable<{
  47075. dragPlanePoint: Vector3;
  47076. pointerId: number;
  47077. }>;
  47078. /**
  47079. * If the attached mesh should be moved when dragged
  47080. */
  47081. moveAttached: boolean;
  47082. /**
  47083. * If the drag behavior will react to drag events (Default: true)
  47084. */
  47085. enabled: boolean;
  47086. /**
  47087. * If pointer events should start and release the drag (Default: true)
  47088. */
  47089. startAndReleaseDragOnPointerEvents: boolean;
  47090. /**
  47091. * If camera controls should be detached during the drag
  47092. */
  47093. detachCameraControls: boolean;
  47094. /**
  47095. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  47096. */
  47097. useObjectOrientationForDragging: boolean;
  47098. private _options;
  47099. /**
  47100. * Gets the options used by the behavior
  47101. */
  47102. get options(): {
  47103. dragAxis?: Vector3;
  47104. dragPlaneNormal?: Vector3;
  47105. };
  47106. /**
  47107. * Sets the options used by the behavior
  47108. */
  47109. set options(options: {
  47110. dragAxis?: Vector3;
  47111. dragPlaneNormal?: Vector3;
  47112. });
  47113. /**
  47114. * Creates a pointer drag behavior that can be attached to a mesh
  47115. * @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)
  47116. */
  47117. constructor(options?: {
  47118. dragAxis?: Vector3;
  47119. dragPlaneNormal?: Vector3;
  47120. });
  47121. /**
  47122. * Predicate to determine if it is valid to move the object to a new position when it is moved
  47123. */
  47124. validateDrag: (targetPosition: Vector3) => boolean;
  47125. /**
  47126. * The name of the behavior
  47127. */
  47128. get name(): string;
  47129. /**
  47130. * Initializes the behavior
  47131. */
  47132. init(): void;
  47133. private _tmpVector;
  47134. private _alternatePickedPoint;
  47135. private _worldDragAxis;
  47136. private _targetPosition;
  47137. private _attachedToElement;
  47138. /**
  47139. * Attaches the drag behavior the passed in mesh
  47140. * @param ownerNode The mesh that will be dragged around once attached
  47141. * @param predicate Predicate to use for pick filtering
  47142. */
  47143. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  47144. /**
  47145. * Force relase the drag action by code.
  47146. */
  47147. releaseDrag(): void;
  47148. private _startDragRay;
  47149. private _lastPointerRay;
  47150. /**
  47151. * Simulates the start of a pointer drag event on the behavior
  47152. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47153. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47154. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47155. */
  47156. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47157. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47158. private _dragDelta;
  47159. protected _moveDrag(ray: Ray): void;
  47160. private _pickWithRayOnDragPlane;
  47161. private _pointA;
  47162. private _pointC;
  47163. private _localAxis;
  47164. private _lookAt;
  47165. private _updateDragPlanePosition;
  47166. /**
  47167. * Detaches the behavior from the mesh
  47168. */
  47169. detach(): void;
  47170. }
  47171. }
  47172. declare module BABYLON {
  47173. /**
  47174. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47175. */
  47176. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47177. private _dragBehaviorA;
  47178. private _dragBehaviorB;
  47179. private _startDistance;
  47180. private _initialScale;
  47181. private _targetScale;
  47182. private _ownerNode;
  47183. private _sceneRenderObserver;
  47184. /**
  47185. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47186. */
  47187. constructor();
  47188. /**
  47189. * The name of the behavior
  47190. */
  47191. get name(): string;
  47192. /**
  47193. * Initializes the behavior
  47194. */
  47195. init(): void;
  47196. private _getCurrentDistance;
  47197. /**
  47198. * Attaches the scale behavior the passed in mesh
  47199. * @param ownerNode The mesh that will be scaled around once attached
  47200. */
  47201. attach(ownerNode: Mesh): void;
  47202. /**
  47203. * Detaches the behavior from the mesh
  47204. */
  47205. detach(): void;
  47206. }
  47207. }
  47208. declare module BABYLON {
  47209. /**
  47210. * 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
  47211. */
  47212. export class SixDofDragBehavior implements Behavior<Mesh> {
  47213. private static _virtualScene;
  47214. private _ownerNode;
  47215. private _sceneRenderObserver;
  47216. private _scene;
  47217. private _targetPosition;
  47218. private _virtualOriginMesh;
  47219. private _virtualDragMesh;
  47220. private _pointerObserver;
  47221. private _moving;
  47222. private _startingOrientation;
  47223. private _attachedToElement;
  47224. /**
  47225. * 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)
  47226. */
  47227. private zDragFactor;
  47228. /**
  47229. * If the object should rotate to face the drag origin
  47230. */
  47231. rotateDraggedObject: boolean;
  47232. /**
  47233. * If the behavior is currently in a dragging state
  47234. */
  47235. dragging: boolean;
  47236. /**
  47237. * 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)
  47238. */
  47239. dragDeltaRatio: number;
  47240. /**
  47241. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47242. */
  47243. currentDraggingPointerID: number;
  47244. /**
  47245. * If camera controls should be detached during the drag
  47246. */
  47247. detachCameraControls: boolean;
  47248. /**
  47249. * Fires each time a drag starts
  47250. */
  47251. onDragStartObservable: Observable<{}>;
  47252. /**
  47253. * Fires each time a drag happens
  47254. */
  47255. onDragObservable: Observable<void>;
  47256. /**
  47257. * Fires each time a drag ends (eg. mouse release after drag)
  47258. */
  47259. onDragEndObservable: Observable<{}>;
  47260. /**
  47261. * 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
  47262. */
  47263. constructor();
  47264. /**
  47265. * The name of the behavior
  47266. */
  47267. get name(): string;
  47268. /**
  47269. * Initializes the behavior
  47270. */
  47271. init(): void;
  47272. /**
  47273. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47274. */
  47275. private get _pointerCamera();
  47276. /**
  47277. * Attaches the scale behavior the passed in mesh
  47278. * @param ownerNode The mesh that will be scaled around once attached
  47279. */
  47280. attach(ownerNode: Mesh): void;
  47281. /**
  47282. * Detaches the behavior from the mesh
  47283. */
  47284. detach(): void;
  47285. }
  47286. }
  47287. declare module BABYLON {
  47288. /**
  47289. * Class used to apply inverse kinematics to bones
  47290. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47291. */
  47292. export class BoneIKController {
  47293. private static _tmpVecs;
  47294. private static _tmpQuat;
  47295. private static _tmpMats;
  47296. /**
  47297. * Gets or sets the target mesh
  47298. */
  47299. targetMesh: AbstractMesh;
  47300. /** Gets or sets the mesh used as pole */
  47301. poleTargetMesh: AbstractMesh;
  47302. /**
  47303. * Gets or sets the bone used as pole
  47304. */
  47305. poleTargetBone: Nullable<Bone>;
  47306. /**
  47307. * Gets or sets the target position
  47308. */
  47309. targetPosition: Vector3;
  47310. /**
  47311. * Gets or sets the pole target position
  47312. */
  47313. poleTargetPosition: Vector3;
  47314. /**
  47315. * Gets or sets the pole target local offset
  47316. */
  47317. poleTargetLocalOffset: Vector3;
  47318. /**
  47319. * Gets or sets the pole angle
  47320. */
  47321. poleAngle: number;
  47322. /**
  47323. * Gets or sets the mesh associated with the controller
  47324. */
  47325. mesh: AbstractMesh;
  47326. /**
  47327. * 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)
  47328. */
  47329. slerpAmount: number;
  47330. private _bone1Quat;
  47331. private _bone1Mat;
  47332. private _bone2Ang;
  47333. private _bone1;
  47334. private _bone2;
  47335. private _bone1Length;
  47336. private _bone2Length;
  47337. private _maxAngle;
  47338. private _maxReach;
  47339. private _rightHandedSystem;
  47340. private _bendAxis;
  47341. private _slerping;
  47342. private _adjustRoll;
  47343. /**
  47344. * Gets or sets maximum allowed angle
  47345. */
  47346. get maxAngle(): number;
  47347. set maxAngle(value: number);
  47348. /**
  47349. * Creates a new BoneIKController
  47350. * @param mesh defines the mesh to control
  47351. * @param bone defines the bone to control
  47352. * @param options defines options to set up the controller
  47353. */
  47354. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47355. targetMesh?: AbstractMesh;
  47356. poleTargetMesh?: AbstractMesh;
  47357. poleTargetBone?: Bone;
  47358. poleTargetLocalOffset?: Vector3;
  47359. poleAngle?: number;
  47360. bendAxis?: Vector3;
  47361. maxAngle?: number;
  47362. slerpAmount?: number;
  47363. });
  47364. private _setMaxAngle;
  47365. /**
  47366. * Force the controller to update the bones
  47367. */
  47368. update(): void;
  47369. }
  47370. }
  47371. declare module BABYLON {
  47372. /**
  47373. * Class used to make a bone look toward a point in space
  47374. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47375. */
  47376. export class BoneLookController {
  47377. private static _tmpVecs;
  47378. private static _tmpQuat;
  47379. private static _tmpMats;
  47380. /**
  47381. * The target Vector3 that the bone will look at
  47382. */
  47383. target: Vector3;
  47384. /**
  47385. * The mesh that the bone is attached to
  47386. */
  47387. mesh: AbstractMesh;
  47388. /**
  47389. * The bone that will be looking to the target
  47390. */
  47391. bone: Bone;
  47392. /**
  47393. * The up axis of the coordinate system that is used when the bone is rotated
  47394. */
  47395. upAxis: Vector3;
  47396. /**
  47397. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47398. */
  47399. upAxisSpace: Space;
  47400. /**
  47401. * Used to make an adjustment to the yaw of the bone
  47402. */
  47403. adjustYaw: number;
  47404. /**
  47405. * Used to make an adjustment to the pitch of the bone
  47406. */
  47407. adjustPitch: number;
  47408. /**
  47409. * Used to make an adjustment to the roll of the bone
  47410. */
  47411. adjustRoll: number;
  47412. /**
  47413. * 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)
  47414. */
  47415. slerpAmount: number;
  47416. private _minYaw;
  47417. private _maxYaw;
  47418. private _minPitch;
  47419. private _maxPitch;
  47420. private _minYawSin;
  47421. private _minYawCos;
  47422. private _maxYawSin;
  47423. private _maxYawCos;
  47424. private _midYawConstraint;
  47425. private _minPitchTan;
  47426. private _maxPitchTan;
  47427. private _boneQuat;
  47428. private _slerping;
  47429. private _transformYawPitch;
  47430. private _transformYawPitchInv;
  47431. private _firstFrameSkipped;
  47432. private _yawRange;
  47433. private _fowardAxis;
  47434. /**
  47435. * Gets or sets the minimum yaw angle that the bone can look to
  47436. */
  47437. get minYaw(): number;
  47438. set minYaw(value: number);
  47439. /**
  47440. * Gets or sets the maximum yaw angle that the bone can look to
  47441. */
  47442. get maxYaw(): number;
  47443. set maxYaw(value: number);
  47444. /**
  47445. * Gets or sets the minimum pitch angle that the bone can look to
  47446. */
  47447. get minPitch(): number;
  47448. set minPitch(value: number);
  47449. /**
  47450. * Gets or sets the maximum pitch angle that the bone can look to
  47451. */
  47452. get maxPitch(): number;
  47453. set maxPitch(value: number);
  47454. /**
  47455. * Create a BoneLookController
  47456. * @param mesh the mesh that the bone belongs to
  47457. * @param bone the bone that will be looking to the target
  47458. * @param target the target Vector3 to look at
  47459. * @param options optional settings:
  47460. * * maxYaw: the maximum angle the bone will yaw to
  47461. * * minYaw: the minimum angle the bone will yaw to
  47462. * * maxPitch: the maximum angle the bone will pitch to
  47463. * * minPitch: the minimum angle the bone will yaw to
  47464. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47465. * * upAxis: the up axis of the coordinate system
  47466. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47467. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47468. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47469. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47470. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47471. * * adjustRoll: used to make an adjustment to the roll of the bone
  47472. **/
  47473. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47474. maxYaw?: number;
  47475. minYaw?: number;
  47476. maxPitch?: number;
  47477. minPitch?: number;
  47478. slerpAmount?: number;
  47479. upAxis?: Vector3;
  47480. upAxisSpace?: Space;
  47481. yawAxis?: Vector3;
  47482. pitchAxis?: Vector3;
  47483. adjustYaw?: number;
  47484. adjustPitch?: number;
  47485. adjustRoll?: number;
  47486. });
  47487. /**
  47488. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47489. */
  47490. update(): void;
  47491. private _getAngleDiff;
  47492. private _getAngleBetween;
  47493. private _isAngleBetween;
  47494. }
  47495. }
  47496. declare module BABYLON {
  47497. /**
  47498. * Manage the gamepad inputs to control an arc rotate camera.
  47499. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47500. */
  47501. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47502. /**
  47503. * Defines the camera the input is attached to.
  47504. */
  47505. camera: ArcRotateCamera;
  47506. /**
  47507. * Defines the gamepad the input is gathering event from.
  47508. */
  47509. gamepad: Nullable<Gamepad>;
  47510. /**
  47511. * Defines the gamepad rotation sensiblity.
  47512. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47513. */
  47514. gamepadRotationSensibility: number;
  47515. /**
  47516. * Defines the gamepad move sensiblity.
  47517. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47518. */
  47519. gamepadMoveSensibility: number;
  47520. private _yAxisScale;
  47521. /**
  47522. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47523. */
  47524. get invertYAxis(): boolean;
  47525. set invertYAxis(value: boolean);
  47526. private _onGamepadConnectedObserver;
  47527. private _onGamepadDisconnectedObserver;
  47528. /**
  47529. * Attach the input controls to a specific dom element to get the input from.
  47530. */
  47531. attachControl(): void;
  47532. /**
  47533. * Detach the current controls from the specified dom element.
  47534. */
  47535. detachControl(): void;
  47536. /**
  47537. * Update the current camera state depending on the inputs that have been used this frame.
  47538. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47539. */
  47540. checkInputs(): void;
  47541. /**
  47542. * Gets the class name of the current intput.
  47543. * @returns the class name
  47544. */
  47545. getClassName(): string;
  47546. /**
  47547. * Get the friendly name associated with the input class.
  47548. * @returns the input friendly name
  47549. */
  47550. getSimpleName(): string;
  47551. }
  47552. }
  47553. declare module BABYLON {
  47554. interface ArcRotateCameraInputsManager {
  47555. /**
  47556. * Add orientation input support to the input manager.
  47557. * @returns the current input manager
  47558. */
  47559. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47560. }
  47561. /**
  47562. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47563. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47564. */
  47565. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47566. /**
  47567. * Defines the camera the input is attached to.
  47568. */
  47569. camera: ArcRotateCamera;
  47570. /**
  47571. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47572. */
  47573. alphaCorrection: number;
  47574. /**
  47575. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47576. */
  47577. gammaCorrection: number;
  47578. private _alpha;
  47579. private _gamma;
  47580. private _dirty;
  47581. private _deviceOrientationHandler;
  47582. /**
  47583. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47584. */
  47585. constructor();
  47586. /**
  47587. * Attach the input controls to a specific dom element to get the input from.
  47588. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47589. */
  47590. attachControl(noPreventDefault?: boolean): void;
  47591. /** @hidden */
  47592. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47593. /**
  47594. * Update the current camera state depending on the inputs that have been used this frame.
  47595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47596. */
  47597. checkInputs(): void;
  47598. /**
  47599. * Detach the current controls from the specified dom element.
  47600. */
  47601. detachControl(): void;
  47602. /**
  47603. * Gets the class name of the current intput.
  47604. * @returns the class name
  47605. */
  47606. getClassName(): string;
  47607. /**
  47608. * Get the friendly name associated with the input class.
  47609. * @returns the input friendly name
  47610. */
  47611. getSimpleName(): string;
  47612. }
  47613. }
  47614. declare module BABYLON {
  47615. /**
  47616. * Listen to mouse events to control the camera.
  47617. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47618. */
  47619. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47620. /**
  47621. * Defines the camera the input is attached to.
  47622. */
  47623. camera: FlyCamera;
  47624. /**
  47625. * Defines if touch is enabled. (Default is true.)
  47626. */
  47627. touchEnabled: boolean;
  47628. /**
  47629. * Defines the buttons associated with the input to handle camera rotation.
  47630. */
  47631. buttons: number[];
  47632. /**
  47633. * Assign buttons for Yaw control.
  47634. */
  47635. buttonsYaw: number[];
  47636. /**
  47637. * Assign buttons for Pitch control.
  47638. */
  47639. buttonsPitch: number[];
  47640. /**
  47641. * Assign buttons for Roll control.
  47642. */
  47643. buttonsRoll: number[];
  47644. /**
  47645. * Detect if any button is being pressed while mouse is moved.
  47646. * -1 = Mouse locked.
  47647. * 0 = Left button.
  47648. * 1 = Middle Button.
  47649. * 2 = Right Button.
  47650. */
  47651. activeButton: number;
  47652. /**
  47653. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47654. * Higher values reduce its sensitivity.
  47655. */
  47656. angularSensibility: number;
  47657. private _observer;
  47658. private _rollObserver;
  47659. private previousPosition;
  47660. private noPreventDefault;
  47661. private element;
  47662. /**
  47663. * Listen to mouse events to control the camera.
  47664. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47665. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47666. */
  47667. constructor(touchEnabled?: boolean);
  47668. /**
  47669. * Attach the mouse control to the HTML DOM element.
  47670. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47671. */
  47672. attachControl(noPreventDefault?: boolean): void;
  47673. /**
  47674. * Detach the current controls from the specified dom element.
  47675. */
  47676. detachControl(): void;
  47677. /**
  47678. * Gets the class name of the current input.
  47679. * @returns the class name.
  47680. */
  47681. getClassName(): string;
  47682. /**
  47683. * Get the friendly name associated with the input class.
  47684. * @returns the input's friendly name.
  47685. */
  47686. getSimpleName(): string;
  47687. private _pointerInput;
  47688. private _onMouseMove;
  47689. /**
  47690. * Rotate camera by mouse offset.
  47691. */
  47692. private rotateCamera;
  47693. }
  47694. }
  47695. declare module BABYLON {
  47696. /**
  47697. * Default Inputs manager for the FlyCamera.
  47698. * It groups all the default supported inputs for ease of use.
  47699. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47700. */
  47701. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47702. /**
  47703. * Instantiates a new FlyCameraInputsManager.
  47704. * @param camera Defines the camera the inputs belong to.
  47705. */
  47706. constructor(camera: FlyCamera);
  47707. /**
  47708. * Add keyboard input support to the input manager.
  47709. * @returns the new FlyCameraKeyboardMoveInput().
  47710. */
  47711. addKeyboard(): FlyCameraInputsManager;
  47712. /**
  47713. * Add mouse input support to the input manager.
  47714. * @param touchEnabled Enable touch screen support.
  47715. * @returns the new FlyCameraMouseInput().
  47716. */
  47717. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47718. }
  47719. }
  47720. declare module BABYLON {
  47721. /**
  47722. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47723. * such as in a 3D Space Shooter or a Flight Simulator.
  47724. */
  47725. export class FlyCamera extends TargetCamera {
  47726. /**
  47727. * Define the collision ellipsoid of the camera.
  47728. * This is helpful for simulating a camera body, like a player's body.
  47729. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47730. */
  47731. ellipsoid: Vector3;
  47732. /**
  47733. * Define an offset for the position of the ellipsoid around the camera.
  47734. * This can be helpful if the camera is attached away from the player's body center,
  47735. * such as at its head.
  47736. */
  47737. ellipsoidOffset: Vector3;
  47738. /**
  47739. * Enable or disable collisions of the camera with the rest of the scene objects.
  47740. */
  47741. checkCollisions: boolean;
  47742. /**
  47743. * Enable or disable gravity on the camera.
  47744. */
  47745. applyGravity: boolean;
  47746. /**
  47747. * Define the current direction the camera is moving to.
  47748. */
  47749. cameraDirection: Vector3;
  47750. /**
  47751. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47752. * This overrides and empties cameraRotation.
  47753. */
  47754. rotationQuaternion: Quaternion;
  47755. /**
  47756. * Track Roll to maintain the wanted Rolling when looking around.
  47757. */
  47758. _trackRoll: number;
  47759. /**
  47760. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47761. */
  47762. rollCorrect: number;
  47763. /**
  47764. * Mimic a banked turn, Rolling the camera when Yawing.
  47765. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47766. */
  47767. bankedTurn: boolean;
  47768. /**
  47769. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47770. */
  47771. bankedTurnLimit: number;
  47772. /**
  47773. * Value of 0 disables the banked Roll.
  47774. * Value of 1 is equal to the Yaw angle in radians.
  47775. */
  47776. bankedTurnMultiplier: number;
  47777. /**
  47778. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47779. */
  47780. inputs: FlyCameraInputsManager;
  47781. /**
  47782. * Gets the input sensibility for mouse input.
  47783. * Higher values reduce sensitivity.
  47784. */
  47785. get angularSensibility(): number;
  47786. /**
  47787. * Sets the input sensibility for a mouse input.
  47788. * Higher values reduce sensitivity.
  47789. */
  47790. set angularSensibility(value: number);
  47791. /**
  47792. * Get the keys for camera movement forward.
  47793. */
  47794. get keysForward(): number[];
  47795. /**
  47796. * Set the keys for camera movement forward.
  47797. */
  47798. set keysForward(value: number[]);
  47799. /**
  47800. * Get the keys for camera movement backward.
  47801. */
  47802. get keysBackward(): number[];
  47803. set keysBackward(value: number[]);
  47804. /**
  47805. * Get the keys for camera movement up.
  47806. */
  47807. get keysUp(): number[];
  47808. /**
  47809. * Set the keys for camera movement up.
  47810. */
  47811. set keysUp(value: number[]);
  47812. /**
  47813. * Get the keys for camera movement down.
  47814. */
  47815. get keysDown(): number[];
  47816. /**
  47817. * Set the keys for camera movement down.
  47818. */
  47819. set keysDown(value: number[]);
  47820. /**
  47821. * Get the keys for camera movement left.
  47822. */
  47823. get keysLeft(): number[];
  47824. /**
  47825. * Set the keys for camera movement left.
  47826. */
  47827. set keysLeft(value: number[]);
  47828. /**
  47829. * Set the keys for camera movement right.
  47830. */
  47831. get keysRight(): number[];
  47832. /**
  47833. * Set the keys for camera movement right.
  47834. */
  47835. set keysRight(value: number[]);
  47836. /**
  47837. * Event raised when the camera collides with a mesh in the scene.
  47838. */
  47839. onCollide: (collidedMesh: AbstractMesh) => void;
  47840. private _collider;
  47841. private _needMoveForGravity;
  47842. private _oldPosition;
  47843. private _diffPosition;
  47844. private _newPosition;
  47845. /** @hidden */
  47846. _localDirection: Vector3;
  47847. /** @hidden */
  47848. _transformedDirection: Vector3;
  47849. /**
  47850. * Instantiates a FlyCamera.
  47851. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47852. * such as in a 3D Space Shooter or a Flight Simulator.
  47853. * @param name Define the name of the camera in the scene.
  47854. * @param position Define the starting position of the camera in the scene.
  47855. * @param scene Define the scene the camera belongs to.
  47856. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47857. */
  47858. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47859. /**
  47860. * Attach the input controls to a specific dom element to get the input from.
  47861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47862. */
  47863. attachControl(noPreventDefault?: boolean): void;
  47864. /**
  47865. * Detach a control from the HTML DOM element.
  47866. * The camera will stop reacting to that input.
  47867. */
  47868. detachControl(): void;
  47869. private _collisionMask;
  47870. /**
  47871. * Get the mask that the camera ignores in collision events.
  47872. */
  47873. get collisionMask(): number;
  47874. /**
  47875. * Set the mask that the camera ignores in collision events.
  47876. */
  47877. set collisionMask(mask: number);
  47878. /** @hidden */
  47879. _collideWithWorld(displacement: Vector3): void;
  47880. /** @hidden */
  47881. private _onCollisionPositionChange;
  47882. /** @hidden */
  47883. _checkInputs(): void;
  47884. /** @hidden */
  47885. _decideIfNeedsToMove(): boolean;
  47886. /** @hidden */
  47887. _updatePosition(): void;
  47888. /**
  47889. * Restore the Roll to its target value at the rate specified.
  47890. * @param rate - Higher means slower restoring.
  47891. * @hidden
  47892. */
  47893. restoreRoll(rate: number): void;
  47894. /**
  47895. * Destroy the camera and release the current resources held by it.
  47896. */
  47897. dispose(): void;
  47898. /**
  47899. * Get the current object class name.
  47900. * @returns the class name.
  47901. */
  47902. getClassName(): string;
  47903. }
  47904. }
  47905. declare module BABYLON {
  47906. /**
  47907. * Listen to keyboard events to control the camera.
  47908. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47909. */
  47910. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47911. /**
  47912. * Defines the camera the input is attached to.
  47913. */
  47914. camera: FlyCamera;
  47915. /**
  47916. * The list of keyboard keys used to control the forward move of the camera.
  47917. */
  47918. keysForward: number[];
  47919. /**
  47920. * The list of keyboard keys used to control the backward move of the camera.
  47921. */
  47922. keysBackward: number[];
  47923. /**
  47924. * The list of keyboard keys used to control the forward move of the camera.
  47925. */
  47926. keysUp: number[];
  47927. /**
  47928. * The list of keyboard keys used to control the backward move of the camera.
  47929. */
  47930. keysDown: number[];
  47931. /**
  47932. * The list of keyboard keys used to control the right strafe move of the camera.
  47933. */
  47934. keysRight: number[];
  47935. /**
  47936. * The list of keyboard keys used to control the left strafe move of the camera.
  47937. */
  47938. keysLeft: number[];
  47939. private _keys;
  47940. private _onCanvasBlurObserver;
  47941. private _onKeyboardObserver;
  47942. private _engine;
  47943. private _scene;
  47944. /**
  47945. * Attach the input controls to a specific dom element to get the input from.
  47946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47947. */
  47948. attachControl(noPreventDefault?: boolean): void;
  47949. /**
  47950. * Detach the current controls from the specified dom element.
  47951. */
  47952. detachControl(): void;
  47953. /**
  47954. * Gets the class name of the current intput.
  47955. * @returns the class name
  47956. */
  47957. getClassName(): string;
  47958. /** @hidden */
  47959. _onLostFocus(e: FocusEvent): void;
  47960. /**
  47961. * Get the friendly name associated with the input class.
  47962. * @returns the input friendly name
  47963. */
  47964. getSimpleName(): string;
  47965. /**
  47966. * Update the current camera state depending on the inputs that have been used this frame.
  47967. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47968. */
  47969. checkInputs(): void;
  47970. }
  47971. }
  47972. declare module BABYLON {
  47973. /**
  47974. * Manage the mouse wheel inputs to control a follow camera.
  47975. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47976. */
  47977. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47978. /**
  47979. * Defines the camera the input is attached to.
  47980. */
  47981. camera: FollowCamera;
  47982. /**
  47983. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47984. */
  47985. axisControlRadius: boolean;
  47986. /**
  47987. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47988. */
  47989. axisControlHeight: boolean;
  47990. /**
  47991. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47992. */
  47993. axisControlRotation: boolean;
  47994. /**
  47995. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47996. * relation to mouseWheel events.
  47997. */
  47998. wheelPrecision: number;
  47999. /**
  48000. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48001. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48002. */
  48003. wheelDeltaPercentage: number;
  48004. private _wheel;
  48005. private _observer;
  48006. /**
  48007. * Attach the input controls to a specific dom element to get the input from.
  48008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48009. */
  48010. attachControl(noPreventDefault?: boolean): void;
  48011. /**
  48012. * Detach the current controls from the specified dom element.
  48013. */
  48014. detachControl(): void;
  48015. /**
  48016. * Gets the class name of the current intput.
  48017. * @returns the class name
  48018. */
  48019. getClassName(): string;
  48020. /**
  48021. * Get the friendly name associated with the input class.
  48022. * @returns the input friendly name
  48023. */
  48024. getSimpleName(): string;
  48025. }
  48026. }
  48027. declare module BABYLON {
  48028. /**
  48029. * Manage the pointers inputs to control an follow camera.
  48030. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48031. */
  48032. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  48033. /**
  48034. * Defines the camera the input is attached to.
  48035. */
  48036. camera: FollowCamera;
  48037. /**
  48038. * Gets the class name of the current input.
  48039. * @returns the class name
  48040. */
  48041. getClassName(): string;
  48042. /**
  48043. * Defines the pointer angular sensibility along the X axis or how fast is
  48044. * the camera rotating.
  48045. * A negative number will reverse the axis direction.
  48046. */
  48047. angularSensibilityX: number;
  48048. /**
  48049. * Defines the pointer angular sensibility along the Y axis or how fast is
  48050. * the camera rotating.
  48051. * A negative number will reverse the axis direction.
  48052. */
  48053. angularSensibilityY: number;
  48054. /**
  48055. * Defines the pointer pinch precision or how fast is the camera zooming.
  48056. * A negative number will reverse the axis direction.
  48057. */
  48058. pinchPrecision: number;
  48059. /**
  48060. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  48061. * from 0.
  48062. * It defines the percentage of current camera.radius to use as delta when
  48063. * pinch zoom is used.
  48064. */
  48065. pinchDeltaPercentage: number;
  48066. /**
  48067. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  48068. */
  48069. axisXControlRadius: boolean;
  48070. /**
  48071. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  48072. */
  48073. axisXControlHeight: boolean;
  48074. /**
  48075. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  48076. */
  48077. axisXControlRotation: boolean;
  48078. /**
  48079. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  48080. */
  48081. axisYControlRadius: boolean;
  48082. /**
  48083. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  48084. */
  48085. axisYControlHeight: boolean;
  48086. /**
  48087. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  48088. */
  48089. axisYControlRotation: boolean;
  48090. /**
  48091. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  48092. */
  48093. axisPinchControlRadius: boolean;
  48094. /**
  48095. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  48096. */
  48097. axisPinchControlHeight: boolean;
  48098. /**
  48099. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  48100. */
  48101. axisPinchControlRotation: boolean;
  48102. /**
  48103. * Log error messages if basic misconfiguration has occurred.
  48104. */
  48105. warningEnable: boolean;
  48106. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48107. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48108. private _warningCounter;
  48109. private _warning;
  48110. }
  48111. }
  48112. declare module BABYLON {
  48113. /**
  48114. * Default Inputs manager for the FollowCamera.
  48115. * It groups all the default supported inputs for ease of use.
  48116. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48117. */
  48118. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  48119. /**
  48120. * Instantiates a new FollowCameraInputsManager.
  48121. * @param camera Defines the camera the inputs belong to
  48122. */
  48123. constructor(camera: FollowCamera);
  48124. /**
  48125. * Add keyboard input support to the input manager.
  48126. * @returns the current input manager
  48127. */
  48128. addKeyboard(): FollowCameraInputsManager;
  48129. /**
  48130. * Add mouse wheel input support to the input manager.
  48131. * @returns the current input manager
  48132. */
  48133. addMouseWheel(): FollowCameraInputsManager;
  48134. /**
  48135. * Add pointers input support to the input manager.
  48136. * @returns the current input manager
  48137. */
  48138. addPointers(): FollowCameraInputsManager;
  48139. /**
  48140. * Add orientation input support to the input manager.
  48141. * @returns the current input manager
  48142. */
  48143. addVRDeviceOrientation(): FollowCameraInputsManager;
  48144. }
  48145. }
  48146. declare module BABYLON {
  48147. /**
  48148. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  48149. * an arc rotate version arcFollowCamera are available.
  48150. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48151. */
  48152. export class FollowCamera extends TargetCamera {
  48153. /**
  48154. * Distance the follow camera should follow an object at
  48155. */
  48156. radius: number;
  48157. /**
  48158. * Minimum allowed distance of the camera to the axis of rotation
  48159. * (The camera can not get closer).
  48160. * This can help limiting how the Camera is able to move in the scene.
  48161. */
  48162. lowerRadiusLimit: Nullable<number>;
  48163. /**
  48164. * Maximum allowed distance of the camera to the axis of rotation
  48165. * (The camera can not get further).
  48166. * This can help limiting how the Camera is able to move in the scene.
  48167. */
  48168. upperRadiusLimit: Nullable<number>;
  48169. /**
  48170. * Define a rotation offset between the camera and the object it follows
  48171. */
  48172. rotationOffset: number;
  48173. /**
  48174. * Minimum allowed angle to camera position relative to target object.
  48175. * This can help limiting how the Camera is able to move in the scene.
  48176. */
  48177. lowerRotationOffsetLimit: Nullable<number>;
  48178. /**
  48179. * Maximum allowed angle to camera position relative to target object.
  48180. * This can help limiting how the Camera is able to move in the scene.
  48181. */
  48182. upperRotationOffsetLimit: Nullable<number>;
  48183. /**
  48184. * Define a height offset between the camera and the object it follows.
  48185. * It can help following an object from the top (like a car chaing a plane)
  48186. */
  48187. heightOffset: number;
  48188. /**
  48189. * Minimum allowed height of camera position relative to target object.
  48190. * This can help limiting how the Camera is able to move in the scene.
  48191. */
  48192. lowerHeightOffsetLimit: Nullable<number>;
  48193. /**
  48194. * Maximum allowed height of camera position relative to target object.
  48195. * This can help limiting how the Camera is able to move in the scene.
  48196. */
  48197. upperHeightOffsetLimit: Nullable<number>;
  48198. /**
  48199. * Define how fast the camera can accelerate to follow it s target.
  48200. */
  48201. cameraAcceleration: number;
  48202. /**
  48203. * Define the speed limit of the camera following an object.
  48204. */
  48205. maxCameraSpeed: number;
  48206. /**
  48207. * Define the target of the camera.
  48208. */
  48209. lockedTarget: Nullable<AbstractMesh>;
  48210. /**
  48211. * Defines the input associated with the camera.
  48212. */
  48213. inputs: FollowCameraInputsManager;
  48214. /**
  48215. * Instantiates the follow camera.
  48216. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48217. * @param name Define the name of the camera in the scene
  48218. * @param position Define the position of the camera
  48219. * @param scene Define the scene the camera belong to
  48220. * @param lockedTarget Define the target of the camera
  48221. */
  48222. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48223. private _follow;
  48224. /**
  48225. * Attach the input controls to a specific dom element to get the input from.
  48226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48227. */
  48228. attachControl(noPreventDefault?: boolean): void;
  48229. /**
  48230. * Detach the current controls from the specified dom element.
  48231. */
  48232. detachControl(): void;
  48233. /** @hidden */
  48234. _checkInputs(): void;
  48235. private _checkLimits;
  48236. /**
  48237. * Gets the camera class name.
  48238. * @returns the class name
  48239. */
  48240. getClassName(): string;
  48241. }
  48242. /**
  48243. * Arc Rotate version of the follow camera.
  48244. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48245. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48246. */
  48247. export class ArcFollowCamera extends TargetCamera {
  48248. /** The longitudinal angle of the camera */
  48249. alpha: number;
  48250. /** The latitudinal angle of the camera */
  48251. beta: number;
  48252. /** The radius of the camera from its target */
  48253. radius: number;
  48254. private _cartesianCoordinates;
  48255. /** Define the camera target (the mesh it should follow) */
  48256. private _meshTarget;
  48257. /**
  48258. * Instantiates a new ArcFollowCamera
  48259. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48260. * @param name Define the name of the camera
  48261. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48262. * @param beta Define the rotation angle of the camera around the elevation axis
  48263. * @param radius Define the radius of the camera from its target point
  48264. * @param target Define the target of the camera
  48265. * @param scene Define the scene the camera belongs to
  48266. */
  48267. constructor(name: string,
  48268. /** The longitudinal angle of the camera */
  48269. alpha: number,
  48270. /** The latitudinal angle of the camera */
  48271. beta: number,
  48272. /** The radius of the camera from its target */
  48273. radius: number,
  48274. /** Define the camera target (the mesh it should follow) */
  48275. target: Nullable<AbstractMesh>, scene: Scene);
  48276. private _follow;
  48277. /** @hidden */
  48278. _checkInputs(): void;
  48279. /**
  48280. * Returns the class name of the object.
  48281. * It is mostly used internally for serialization purposes.
  48282. */
  48283. getClassName(): string;
  48284. }
  48285. }
  48286. declare module BABYLON {
  48287. /**
  48288. * Manage the keyboard inputs to control the movement of a follow camera.
  48289. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48290. */
  48291. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48292. /**
  48293. * Defines the camera the input is attached to.
  48294. */
  48295. camera: FollowCamera;
  48296. /**
  48297. * Defines the list of key codes associated with the up action (increase heightOffset)
  48298. */
  48299. keysHeightOffsetIncr: number[];
  48300. /**
  48301. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48302. */
  48303. keysHeightOffsetDecr: number[];
  48304. /**
  48305. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48306. */
  48307. keysHeightOffsetModifierAlt: boolean;
  48308. /**
  48309. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48310. */
  48311. keysHeightOffsetModifierCtrl: boolean;
  48312. /**
  48313. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48314. */
  48315. keysHeightOffsetModifierShift: boolean;
  48316. /**
  48317. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48318. */
  48319. keysRotationOffsetIncr: number[];
  48320. /**
  48321. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48322. */
  48323. keysRotationOffsetDecr: number[];
  48324. /**
  48325. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48326. */
  48327. keysRotationOffsetModifierAlt: boolean;
  48328. /**
  48329. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48330. */
  48331. keysRotationOffsetModifierCtrl: boolean;
  48332. /**
  48333. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48334. */
  48335. keysRotationOffsetModifierShift: boolean;
  48336. /**
  48337. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48338. */
  48339. keysRadiusIncr: number[];
  48340. /**
  48341. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48342. */
  48343. keysRadiusDecr: number[];
  48344. /**
  48345. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48346. */
  48347. keysRadiusModifierAlt: boolean;
  48348. /**
  48349. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48350. */
  48351. keysRadiusModifierCtrl: boolean;
  48352. /**
  48353. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48354. */
  48355. keysRadiusModifierShift: boolean;
  48356. /**
  48357. * Defines the rate of change of heightOffset.
  48358. */
  48359. heightSensibility: number;
  48360. /**
  48361. * Defines the rate of change of rotationOffset.
  48362. */
  48363. rotationSensibility: number;
  48364. /**
  48365. * Defines the rate of change of radius.
  48366. */
  48367. radiusSensibility: number;
  48368. private _keys;
  48369. private _ctrlPressed;
  48370. private _altPressed;
  48371. private _shiftPressed;
  48372. private _onCanvasBlurObserver;
  48373. private _onKeyboardObserver;
  48374. private _engine;
  48375. private _scene;
  48376. /**
  48377. * Attach the input controls to a specific dom element to get the input from.
  48378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48379. */
  48380. attachControl(noPreventDefault?: boolean): void;
  48381. /**
  48382. * Detach the current controls from the specified dom element.
  48383. */
  48384. detachControl(): void;
  48385. /**
  48386. * Update the current camera state depending on the inputs that have been used this frame.
  48387. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48388. */
  48389. checkInputs(): void;
  48390. /**
  48391. * Gets the class name of the current input.
  48392. * @returns the class name
  48393. */
  48394. getClassName(): string;
  48395. /**
  48396. * Get the friendly name associated with the input class.
  48397. * @returns the input friendly name
  48398. */
  48399. getSimpleName(): string;
  48400. /**
  48401. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48402. * allow modification of the heightOffset value.
  48403. */
  48404. private _modifierHeightOffset;
  48405. /**
  48406. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48407. * allow modification of the rotationOffset value.
  48408. */
  48409. private _modifierRotationOffset;
  48410. /**
  48411. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48412. * allow modification of the radius value.
  48413. */
  48414. private _modifierRadius;
  48415. }
  48416. }
  48417. declare module BABYLON {
  48418. interface FreeCameraInputsManager {
  48419. /**
  48420. * @hidden
  48421. */
  48422. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48423. /**
  48424. * Add orientation input support to the input manager.
  48425. * @returns the current input manager
  48426. */
  48427. addDeviceOrientation(): FreeCameraInputsManager;
  48428. }
  48429. /**
  48430. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48431. * Screen rotation is taken into account.
  48432. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48433. */
  48434. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48435. private _camera;
  48436. private _screenOrientationAngle;
  48437. private _constantTranform;
  48438. private _screenQuaternion;
  48439. private _alpha;
  48440. private _beta;
  48441. private _gamma;
  48442. /**
  48443. * Can be used to detect if a device orientation sensor is available on a device
  48444. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48445. * @returns a promise that will resolve on orientation change
  48446. */
  48447. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48448. /**
  48449. * @hidden
  48450. */
  48451. _onDeviceOrientationChangedObservable: Observable<void>;
  48452. /**
  48453. * Instantiates a new input
  48454. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48455. */
  48456. constructor();
  48457. /**
  48458. * Define the camera controlled by the input.
  48459. */
  48460. get camera(): FreeCamera;
  48461. set camera(camera: FreeCamera);
  48462. /**
  48463. * Attach the input controls to a specific dom element to get the input from.
  48464. */
  48465. attachControl(): void;
  48466. private _orientationChanged;
  48467. private _deviceOrientation;
  48468. /**
  48469. * Detach the current controls from the specified dom element.
  48470. */
  48471. detachControl(): void;
  48472. /**
  48473. * Update the current camera state depending on the inputs that have been used this frame.
  48474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48475. */
  48476. checkInputs(): void;
  48477. /**
  48478. * Gets the class name of the current intput.
  48479. * @returns the class name
  48480. */
  48481. getClassName(): string;
  48482. /**
  48483. * Get the friendly name associated with the input class.
  48484. * @returns the input friendly name
  48485. */
  48486. getSimpleName(): string;
  48487. }
  48488. }
  48489. declare module BABYLON {
  48490. /**
  48491. * Manage the gamepad inputs to control a free camera.
  48492. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48493. */
  48494. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48495. /**
  48496. * Define the camera the input is attached to.
  48497. */
  48498. camera: FreeCamera;
  48499. /**
  48500. * Define the Gamepad controlling the input
  48501. */
  48502. gamepad: Nullable<Gamepad>;
  48503. /**
  48504. * Defines the gamepad rotation sensiblity.
  48505. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48506. */
  48507. gamepadAngularSensibility: number;
  48508. /**
  48509. * Defines the gamepad move sensiblity.
  48510. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48511. */
  48512. gamepadMoveSensibility: number;
  48513. private _yAxisScale;
  48514. /**
  48515. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48516. */
  48517. get invertYAxis(): boolean;
  48518. set invertYAxis(value: boolean);
  48519. private _onGamepadConnectedObserver;
  48520. private _onGamepadDisconnectedObserver;
  48521. private _cameraTransform;
  48522. private _deltaTransform;
  48523. private _vector3;
  48524. private _vector2;
  48525. /**
  48526. * Attach the input controls to a specific dom element to get the input from.
  48527. */
  48528. attachControl(): void;
  48529. /**
  48530. * Detach the current controls from the specified dom element.
  48531. */
  48532. detachControl(): void;
  48533. /**
  48534. * Update the current camera state depending on the inputs that have been used this frame.
  48535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48536. */
  48537. checkInputs(): void;
  48538. /**
  48539. * Gets the class name of the current intput.
  48540. * @returns the class name
  48541. */
  48542. getClassName(): string;
  48543. /**
  48544. * Get the friendly name associated with the input class.
  48545. * @returns the input friendly name
  48546. */
  48547. getSimpleName(): string;
  48548. }
  48549. }
  48550. declare module BABYLON {
  48551. /**
  48552. * Defines the potential axis of a Joystick
  48553. */
  48554. export enum JoystickAxis {
  48555. /** X axis */
  48556. X = 0,
  48557. /** Y axis */
  48558. Y = 1,
  48559. /** Z axis */
  48560. Z = 2
  48561. }
  48562. /**
  48563. * Represents the different customization options available
  48564. * for VirtualJoystick
  48565. */
  48566. interface VirtualJoystickCustomizations {
  48567. /**
  48568. * Size of the joystick's puck
  48569. */
  48570. puckSize: number;
  48571. /**
  48572. * Size of the joystick's container
  48573. */
  48574. containerSize: number;
  48575. /**
  48576. * Color of the joystick && puck
  48577. */
  48578. color: string;
  48579. /**
  48580. * Image URL for the joystick's puck
  48581. */
  48582. puckImage?: string;
  48583. /**
  48584. * Image URL for the joystick's container
  48585. */
  48586. containerImage?: string;
  48587. /**
  48588. * Defines the unmoving position of the joystick container
  48589. */
  48590. position?: {
  48591. x: number;
  48592. y: number;
  48593. };
  48594. /**
  48595. * Defines whether or not the joystick container is always visible
  48596. */
  48597. alwaysVisible: boolean;
  48598. /**
  48599. * Defines whether or not to limit the movement of the puck to the joystick's container
  48600. */
  48601. limitToContainer: boolean;
  48602. }
  48603. /**
  48604. * Class used to define virtual joystick (used in touch mode)
  48605. */
  48606. export class VirtualJoystick {
  48607. /**
  48608. * Gets or sets a boolean indicating that left and right values must be inverted
  48609. */
  48610. reverseLeftRight: boolean;
  48611. /**
  48612. * Gets or sets a boolean indicating that up and down values must be inverted
  48613. */
  48614. reverseUpDown: boolean;
  48615. /**
  48616. * Gets the offset value for the position (ie. the change of the position value)
  48617. */
  48618. deltaPosition: Vector3;
  48619. /**
  48620. * Gets a boolean indicating if the virtual joystick was pressed
  48621. */
  48622. pressed: boolean;
  48623. /**
  48624. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48625. */
  48626. static Canvas: Nullable<HTMLCanvasElement>;
  48627. /**
  48628. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48629. */
  48630. limitToContainer: boolean;
  48631. private static _globalJoystickIndex;
  48632. private static _alwaysVisibleSticks;
  48633. private static vjCanvasContext;
  48634. private static vjCanvasWidth;
  48635. private static vjCanvasHeight;
  48636. private static halfWidth;
  48637. private static _GetDefaultOptions;
  48638. private _action;
  48639. private _axisTargetedByLeftAndRight;
  48640. private _axisTargetedByUpAndDown;
  48641. private _joystickSensibility;
  48642. private _inversedSensibility;
  48643. private _joystickPointerID;
  48644. private _joystickColor;
  48645. private _joystickPointerPos;
  48646. private _joystickPreviousPointerPos;
  48647. private _joystickPointerStartPos;
  48648. private _deltaJoystickVector;
  48649. private _leftJoystick;
  48650. private _touches;
  48651. private _joystickPosition;
  48652. private _alwaysVisible;
  48653. private _puckImage;
  48654. private _containerImage;
  48655. private _joystickPuckSize;
  48656. private _joystickContainerSize;
  48657. private _clearPuckSize;
  48658. private _clearContainerSize;
  48659. private _clearPuckSizeOffset;
  48660. private _clearContainerSizeOffset;
  48661. private _onPointerDownHandlerRef;
  48662. private _onPointerMoveHandlerRef;
  48663. private _onPointerUpHandlerRef;
  48664. private _onResize;
  48665. /**
  48666. * Creates a new virtual joystick
  48667. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48668. * @param customizations Defines the options we want to customize the VirtualJoystick
  48669. */
  48670. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48671. /**
  48672. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48673. * @param newJoystickSensibility defines the new sensibility
  48674. */
  48675. setJoystickSensibility(newJoystickSensibility: number): void;
  48676. private _onPointerDown;
  48677. private _onPointerMove;
  48678. private _onPointerUp;
  48679. /**
  48680. * Change the color of the virtual joystick
  48681. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48682. */
  48683. setJoystickColor(newColor: string): void;
  48684. /**
  48685. * Size of the joystick's container
  48686. */
  48687. set containerSize(newSize: number);
  48688. get containerSize(): number;
  48689. /**
  48690. * Size of the joystick's puck
  48691. */
  48692. set puckSize(newSize: number);
  48693. get puckSize(): number;
  48694. /**
  48695. * Clears the set position of the joystick
  48696. */
  48697. clearPosition(): void;
  48698. /**
  48699. * Defines whether or not the joystick container is always visible
  48700. */
  48701. set alwaysVisible(value: boolean);
  48702. get alwaysVisible(): boolean;
  48703. /**
  48704. * Sets the constant position of the Joystick container
  48705. * @param x X axis coordinate
  48706. * @param y Y axis coordinate
  48707. */
  48708. setPosition(x: number, y: number): void;
  48709. /**
  48710. * Defines a callback to call when the joystick is touched
  48711. * @param action defines the callback
  48712. */
  48713. setActionOnTouch(action: () => any): void;
  48714. /**
  48715. * Defines which axis you'd like to control for left & right
  48716. * @param axis defines the axis to use
  48717. */
  48718. setAxisForLeftRight(axis: JoystickAxis): void;
  48719. /**
  48720. * Defines which axis you'd like to control for up & down
  48721. * @param axis defines the axis to use
  48722. */
  48723. setAxisForUpDown(axis: JoystickAxis): void;
  48724. /**
  48725. * Clears the canvas from the previous puck / container draw
  48726. */
  48727. private _clearPreviousDraw;
  48728. /**
  48729. * Loads `urlPath` to be used for the container's image
  48730. * @param urlPath defines the urlPath of an image to use
  48731. */
  48732. setContainerImage(urlPath: string): void;
  48733. /**
  48734. * Loads `urlPath` to be used for the puck's image
  48735. * @param urlPath defines the urlPath of an image to use
  48736. */
  48737. setPuckImage(urlPath: string): void;
  48738. /**
  48739. * Draws the Virtual Joystick's container
  48740. */
  48741. private _drawContainer;
  48742. /**
  48743. * Draws the Virtual Joystick's puck
  48744. */
  48745. private _drawPuck;
  48746. private _drawVirtualJoystick;
  48747. /**
  48748. * Release internal HTML canvas
  48749. */
  48750. releaseCanvas(): void;
  48751. }
  48752. }
  48753. declare module BABYLON {
  48754. interface FreeCameraInputsManager {
  48755. /**
  48756. * Add virtual joystick input support to the input manager.
  48757. * @returns the current input manager
  48758. */
  48759. addVirtualJoystick(): FreeCameraInputsManager;
  48760. }
  48761. /**
  48762. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48763. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48764. */
  48765. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48766. /**
  48767. * Defines the camera the input is attached to.
  48768. */
  48769. camera: FreeCamera;
  48770. private _leftjoystick;
  48771. private _rightjoystick;
  48772. /**
  48773. * Gets the left stick of the virtual joystick.
  48774. * @returns The virtual Joystick
  48775. */
  48776. getLeftJoystick(): VirtualJoystick;
  48777. /**
  48778. * Gets the right stick of the virtual joystick.
  48779. * @returns The virtual Joystick
  48780. */
  48781. getRightJoystick(): VirtualJoystick;
  48782. /**
  48783. * Update the current camera state depending on the inputs that have been used this frame.
  48784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48785. */
  48786. checkInputs(): void;
  48787. /**
  48788. * Attach the input controls to a specific dom element to get the input from.
  48789. */
  48790. attachControl(): void;
  48791. /**
  48792. * Detach the current controls from the specified dom element.
  48793. */
  48794. detachControl(): void;
  48795. /**
  48796. * Gets the class name of the current intput.
  48797. * @returns the class name
  48798. */
  48799. getClassName(): string;
  48800. /**
  48801. * Get the friendly name associated with the input class.
  48802. * @returns the input friendly name
  48803. */
  48804. getSimpleName(): string;
  48805. }
  48806. }
  48807. declare module BABYLON {
  48808. /**
  48809. * This represents a FPS type of camera controlled by touch.
  48810. * This is like a universal camera minus the Gamepad controls.
  48811. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48812. */
  48813. export class TouchCamera extends FreeCamera {
  48814. /**
  48815. * Defines the touch sensibility for rotation.
  48816. * The higher the faster.
  48817. */
  48818. get touchAngularSensibility(): number;
  48819. set touchAngularSensibility(value: number);
  48820. /**
  48821. * Defines the touch sensibility for move.
  48822. * The higher the faster.
  48823. */
  48824. get touchMoveSensibility(): number;
  48825. set touchMoveSensibility(value: number);
  48826. /**
  48827. * Instantiates a new touch camera.
  48828. * This represents a FPS type of camera controlled by touch.
  48829. * This is like a universal camera minus the Gamepad controls.
  48830. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48831. * @param name Define the name of the camera in the scene
  48832. * @param position Define the start position of the camera in the scene
  48833. * @param scene Define the scene the camera belongs to
  48834. */
  48835. constructor(name: string, position: Vector3, scene: Scene);
  48836. /**
  48837. * Gets the current object class name.
  48838. * @return the class name
  48839. */
  48840. getClassName(): string;
  48841. /** @hidden */
  48842. _setupInputs(): void;
  48843. }
  48844. }
  48845. declare module BABYLON {
  48846. /**
  48847. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48848. * being tilted forward or back and left or right.
  48849. */
  48850. export class DeviceOrientationCamera extends FreeCamera {
  48851. private _initialQuaternion;
  48852. private _quaternionCache;
  48853. private _tmpDragQuaternion;
  48854. private _disablePointerInputWhenUsingDeviceOrientation;
  48855. /**
  48856. * Creates a new device orientation camera
  48857. * @param name The name of the camera
  48858. * @param position The start position camera
  48859. * @param scene The scene the camera belongs to
  48860. */
  48861. constructor(name: string, position: Vector3, scene: Scene);
  48862. /**
  48863. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48864. */
  48865. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48866. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48867. private _dragFactor;
  48868. /**
  48869. * Enabled turning on the y axis when the orientation sensor is active
  48870. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48871. */
  48872. enableHorizontalDragging(dragFactor?: number): void;
  48873. /**
  48874. * Gets the current instance class name ("DeviceOrientationCamera").
  48875. * This helps avoiding instanceof at run time.
  48876. * @returns the class name
  48877. */
  48878. getClassName(): string;
  48879. /**
  48880. * @hidden
  48881. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48882. */
  48883. _checkInputs(): void;
  48884. /**
  48885. * Reset the camera to its default orientation on the specified axis only.
  48886. * @param axis The axis to reset
  48887. */
  48888. resetToCurrentRotation(axis?: Axis): void;
  48889. }
  48890. }
  48891. declare module BABYLON {
  48892. /**
  48893. * Defines supported buttons for XBox360 compatible gamepads
  48894. */
  48895. export enum Xbox360Button {
  48896. /** A */
  48897. A = 0,
  48898. /** B */
  48899. B = 1,
  48900. /** X */
  48901. X = 2,
  48902. /** Y */
  48903. Y = 3,
  48904. /** Left button */
  48905. LB = 4,
  48906. /** Right button */
  48907. RB = 5,
  48908. /** Back */
  48909. Back = 8,
  48910. /** Start */
  48911. Start = 9,
  48912. /** Left stick */
  48913. LeftStick = 10,
  48914. /** Right stick */
  48915. RightStick = 11
  48916. }
  48917. /** Defines values for XBox360 DPad */
  48918. export enum Xbox360Dpad {
  48919. /** Up */
  48920. Up = 12,
  48921. /** Down */
  48922. Down = 13,
  48923. /** Left */
  48924. Left = 14,
  48925. /** Right */
  48926. Right = 15
  48927. }
  48928. /**
  48929. * Defines a XBox360 gamepad
  48930. */
  48931. export class Xbox360Pad extends Gamepad {
  48932. private _leftTrigger;
  48933. private _rightTrigger;
  48934. private _onlefttriggerchanged;
  48935. private _onrighttriggerchanged;
  48936. private _onbuttondown;
  48937. private _onbuttonup;
  48938. private _ondpaddown;
  48939. private _ondpadup;
  48940. /** Observable raised when a button is pressed */
  48941. onButtonDownObservable: Observable<Xbox360Button>;
  48942. /** Observable raised when a button is released */
  48943. onButtonUpObservable: Observable<Xbox360Button>;
  48944. /** Observable raised when a pad is pressed */
  48945. onPadDownObservable: Observable<Xbox360Dpad>;
  48946. /** Observable raised when a pad is released */
  48947. onPadUpObservable: Observable<Xbox360Dpad>;
  48948. private _buttonA;
  48949. private _buttonB;
  48950. private _buttonX;
  48951. private _buttonY;
  48952. private _buttonBack;
  48953. private _buttonStart;
  48954. private _buttonLB;
  48955. private _buttonRB;
  48956. private _buttonLeftStick;
  48957. private _buttonRightStick;
  48958. private _dPadUp;
  48959. private _dPadDown;
  48960. private _dPadLeft;
  48961. private _dPadRight;
  48962. private _isXboxOnePad;
  48963. /**
  48964. * Creates a new XBox360 gamepad object
  48965. * @param id defines the id of this gamepad
  48966. * @param index defines its index
  48967. * @param gamepad defines the internal HTML gamepad object
  48968. * @param xboxOne defines if it is a XBox One gamepad
  48969. */
  48970. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48971. /**
  48972. * Defines the callback to call when left trigger is pressed
  48973. * @param callback defines the callback to use
  48974. */
  48975. onlefttriggerchanged(callback: (value: number) => void): void;
  48976. /**
  48977. * Defines the callback to call when right trigger is pressed
  48978. * @param callback defines the callback to use
  48979. */
  48980. onrighttriggerchanged(callback: (value: number) => void): void;
  48981. /**
  48982. * Gets the left trigger value
  48983. */
  48984. get leftTrigger(): number;
  48985. /**
  48986. * Sets the left trigger value
  48987. */
  48988. set leftTrigger(newValue: number);
  48989. /**
  48990. * Gets the right trigger value
  48991. */
  48992. get rightTrigger(): number;
  48993. /**
  48994. * Sets the right trigger value
  48995. */
  48996. set rightTrigger(newValue: number);
  48997. /**
  48998. * Defines the callback to call when a button is pressed
  48999. * @param callback defines the callback to use
  49000. */
  49001. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  49002. /**
  49003. * Defines the callback to call when a button is released
  49004. * @param callback defines the callback to use
  49005. */
  49006. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  49007. /**
  49008. * Defines the callback to call when a pad is pressed
  49009. * @param callback defines the callback to use
  49010. */
  49011. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  49012. /**
  49013. * Defines the callback to call when a pad is released
  49014. * @param callback defines the callback to use
  49015. */
  49016. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  49017. private _setButtonValue;
  49018. private _setDPadValue;
  49019. /**
  49020. * Gets the value of the `A` button
  49021. */
  49022. get buttonA(): number;
  49023. /**
  49024. * Sets the value of the `A` button
  49025. */
  49026. set buttonA(value: number);
  49027. /**
  49028. * Gets the value of the `B` button
  49029. */
  49030. get buttonB(): number;
  49031. /**
  49032. * Sets the value of the `B` button
  49033. */
  49034. set buttonB(value: number);
  49035. /**
  49036. * Gets the value of the `X` button
  49037. */
  49038. get buttonX(): number;
  49039. /**
  49040. * Sets the value of the `X` button
  49041. */
  49042. set buttonX(value: number);
  49043. /**
  49044. * Gets the value of the `Y` button
  49045. */
  49046. get buttonY(): number;
  49047. /**
  49048. * Sets the value of the `Y` button
  49049. */
  49050. set buttonY(value: number);
  49051. /**
  49052. * Gets the value of the `Start` button
  49053. */
  49054. get buttonStart(): number;
  49055. /**
  49056. * Sets the value of the `Start` button
  49057. */
  49058. set buttonStart(value: number);
  49059. /**
  49060. * Gets the value of the `Back` button
  49061. */
  49062. get buttonBack(): number;
  49063. /**
  49064. * Sets the value of the `Back` button
  49065. */
  49066. set buttonBack(value: number);
  49067. /**
  49068. * Gets the value of the `Left` button
  49069. */
  49070. get buttonLB(): number;
  49071. /**
  49072. * Sets the value of the `Left` button
  49073. */
  49074. set buttonLB(value: number);
  49075. /**
  49076. * Gets the value of the `Right` button
  49077. */
  49078. get buttonRB(): number;
  49079. /**
  49080. * Sets the value of the `Right` button
  49081. */
  49082. set buttonRB(value: number);
  49083. /**
  49084. * Gets the value of the Left joystick
  49085. */
  49086. get buttonLeftStick(): number;
  49087. /**
  49088. * Sets the value of the Left joystick
  49089. */
  49090. set buttonLeftStick(value: number);
  49091. /**
  49092. * Gets the value of the Right joystick
  49093. */
  49094. get buttonRightStick(): number;
  49095. /**
  49096. * Sets the value of the Right joystick
  49097. */
  49098. set buttonRightStick(value: number);
  49099. /**
  49100. * Gets the value of D-pad up
  49101. */
  49102. get dPadUp(): number;
  49103. /**
  49104. * Sets the value of D-pad up
  49105. */
  49106. set dPadUp(value: number);
  49107. /**
  49108. * Gets the value of D-pad down
  49109. */
  49110. get dPadDown(): number;
  49111. /**
  49112. * Sets the value of D-pad down
  49113. */
  49114. set dPadDown(value: number);
  49115. /**
  49116. * Gets the value of D-pad left
  49117. */
  49118. get dPadLeft(): number;
  49119. /**
  49120. * Sets the value of D-pad left
  49121. */
  49122. set dPadLeft(value: number);
  49123. /**
  49124. * Gets the value of D-pad right
  49125. */
  49126. get dPadRight(): number;
  49127. /**
  49128. * Sets the value of D-pad right
  49129. */
  49130. set dPadRight(value: number);
  49131. /**
  49132. * Force the gamepad to synchronize with device values
  49133. */
  49134. update(): void;
  49135. /**
  49136. * Disposes the gamepad
  49137. */
  49138. dispose(): void;
  49139. }
  49140. }
  49141. declare module BABYLON {
  49142. /**
  49143. * Defines supported buttons for DualShock compatible gamepads
  49144. */
  49145. export enum DualShockButton {
  49146. /** Cross */
  49147. Cross = 0,
  49148. /** Circle */
  49149. Circle = 1,
  49150. /** Square */
  49151. Square = 2,
  49152. /** Triangle */
  49153. Triangle = 3,
  49154. /** L1 */
  49155. L1 = 4,
  49156. /** R1 */
  49157. R1 = 5,
  49158. /** Share */
  49159. Share = 8,
  49160. /** Options */
  49161. Options = 9,
  49162. /** Left stick */
  49163. LeftStick = 10,
  49164. /** Right stick */
  49165. RightStick = 11
  49166. }
  49167. /** Defines values for DualShock DPad */
  49168. export enum DualShockDpad {
  49169. /** Up */
  49170. Up = 12,
  49171. /** Down */
  49172. Down = 13,
  49173. /** Left */
  49174. Left = 14,
  49175. /** Right */
  49176. Right = 15
  49177. }
  49178. /**
  49179. * Defines a DualShock gamepad
  49180. */
  49181. export class DualShockPad extends Gamepad {
  49182. private _leftTrigger;
  49183. private _rightTrigger;
  49184. private _onlefttriggerchanged;
  49185. private _onrighttriggerchanged;
  49186. private _onbuttondown;
  49187. private _onbuttonup;
  49188. private _ondpaddown;
  49189. private _ondpadup;
  49190. /** Observable raised when a button is pressed */
  49191. onButtonDownObservable: Observable<DualShockButton>;
  49192. /** Observable raised when a button is released */
  49193. onButtonUpObservable: Observable<DualShockButton>;
  49194. /** Observable raised when a pad is pressed */
  49195. onPadDownObservable: Observable<DualShockDpad>;
  49196. /** Observable raised when a pad is released */
  49197. onPadUpObservable: Observable<DualShockDpad>;
  49198. private _buttonCross;
  49199. private _buttonCircle;
  49200. private _buttonSquare;
  49201. private _buttonTriangle;
  49202. private _buttonShare;
  49203. private _buttonOptions;
  49204. private _buttonL1;
  49205. private _buttonR1;
  49206. private _buttonLeftStick;
  49207. private _buttonRightStick;
  49208. private _dPadUp;
  49209. private _dPadDown;
  49210. private _dPadLeft;
  49211. private _dPadRight;
  49212. /**
  49213. * Creates a new DualShock gamepad object
  49214. * @param id defines the id of this gamepad
  49215. * @param index defines its index
  49216. * @param gamepad defines the internal HTML gamepad object
  49217. */
  49218. constructor(id: string, index: number, gamepad: any);
  49219. /**
  49220. * Defines the callback to call when left trigger is pressed
  49221. * @param callback defines the callback to use
  49222. */
  49223. onlefttriggerchanged(callback: (value: number) => void): void;
  49224. /**
  49225. * Defines the callback to call when right trigger is pressed
  49226. * @param callback defines the callback to use
  49227. */
  49228. onrighttriggerchanged(callback: (value: number) => void): void;
  49229. /**
  49230. * Gets the left trigger value
  49231. */
  49232. get leftTrigger(): number;
  49233. /**
  49234. * Sets the left trigger value
  49235. */
  49236. set leftTrigger(newValue: number);
  49237. /**
  49238. * Gets the right trigger value
  49239. */
  49240. get rightTrigger(): number;
  49241. /**
  49242. * Sets the right trigger value
  49243. */
  49244. set rightTrigger(newValue: number);
  49245. /**
  49246. * Defines the callback to call when a button is pressed
  49247. * @param callback defines the callback to use
  49248. */
  49249. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49250. /**
  49251. * Defines the callback to call when a button is released
  49252. * @param callback defines the callback to use
  49253. */
  49254. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49255. /**
  49256. * Defines the callback to call when a pad is pressed
  49257. * @param callback defines the callback to use
  49258. */
  49259. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49260. /**
  49261. * Defines the callback to call when a pad is released
  49262. * @param callback defines the callback to use
  49263. */
  49264. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49265. private _setButtonValue;
  49266. private _setDPadValue;
  49267. /**
  49268. * Gets the value of the `Cross` button
  49269. */
  49270. get buttonCross(): number;
  49271. /**
  49272. * Sets the value of the `Cross` button
  49273. */
  49274. set buttonCross(value: number);
  49275. /**
  49276. * Gets the value of the `Circle` button
  49277. */
  49278. get buttonCircle(): number;
  49279. /**
  49280. * Sets the value of the `Circle` button
  49281. */
  49282. set buttonCircle(value: number);
  49283. /**
  49284. * Gets the value of the `Square` button
  49285. */
  49286. get buttonSquare(): number;
  49287. /**
  49288. * Sets the value of the `Square` button
  49289. */
  49290. set buttonSquare(value: number);
  49291. /**
  49292. * Gets the value of the `Triangle` button
  49293. */
  49294. get buttonTriangle(): number;
  49295. /**
  49296. * Sets the value of the `Triangle` button
  49297. */
  49298. set buttonTriangle(value: number);
  49299. /**
  49300. * Gets the value of the `Options` button
  49301. */
  49302. get buttonOptions(): number;
  49303. /**
  49304. * Sets the value of the `Options` button
  49305. */
  49306. set buttonOptions(value: number);
  49307. /**
  49308. * Gets the value of the `Share` button
  49309. */
  49310. get buttonShare(): number;
  49311. /**
  49312. * Sets the value of the `Share` button
  49313. */
  49314. set buttonShare(value: number);
  49315. /**
  49316. * Gets the value of the `L1` button
  49317. */
  49318. get buttonL1(): number;
  49319. /**
  49320. * Sets the value of the `L1` button
  49321. */
  49322. set buttonL1(value: number);
  49323. /**
  49324. * Gets the value of the `R1` button
  49325. */
  49326. get buttonR1(): number;
  49327. /**
  49328. * Sets the value of the `R1` button
  49329. */
  49330. set buttonR1(value: number);
  49331. /**
  49332. * Gets the value of the Left joystick
  49333. */
  49334. get buttonLeftStick(): number;
  49335. /**
  49336. * Sets the value of the Left joystick
  49337. */
  49338. set buttonLeftStick(value: number);
  49339. /**
  49340. * Gets the value of the Right joystick
  49341. */
  49342. get buttonRightStick(): number;
  49343. /**
  49344. * Sets the value of the Right joystick
  49345. */
  49346. set buttonRightStick(value: number);
  49347. /**
  49348. * Gets the value of D-pad up
  49349. */
  49350. get dPadUp(): number;
  49351. /**
  49352. * Sets the value of D-pad up
  49353. */
  49354. set dPadUp(value: number);
  49355. /**
  49356. * Gets the value of D-pad down
  49357. */
  49358. get dPadDown(): number;
  49359. /**
  49360. * Sets the value of D-pad down
  49361. */
  49362. set dPadDown(value: number);
  49363. /**
  49364. * Gets the value of D-pad left
  49365. */
  49366. get dPadLeft(): number;
  49367. /**
  49368. * Sets the value of D-pad left
  49369. */
  49370. set dPadLeft(value: number);
  49371. /**
  49372. * Gets the value of D-pad right
  49373. */
  49374. get dPadRight(): number;
  49375. /**
  49376. * Sets the value of D-pad right
  49377. */
  49378. set dPadRight(value: number);
  49379. /**
  49380. * Force the gamepad to synchronize with device values
  49381. */
  49382. update(): void;
  49383. /**
  49384. * Disposes the gamepad
  49385. */
  49386. dispose(): void;
  49387. }
  49388. }
  49389. declare module BABYLON {
  49390. /**
  49391. * Manager for handling gamepads
  49392. */
  49393. export class GamepadManager {
  49394. private _scene?;
  49395. private _babylonGamepads;
  49396. private _oneGamepadConnected;
  49397. /** @hidden */
  49398. _isMonitoring: boolean;
  49399. private _gamepadEventSupported;
  49400. private _gamepadSupport?;
  49401. /**
  49402. * observable to be triggered when the gamepad controller has been connected
  49403. */
  49404. onGamepadConnectedObservable: Observable<Gamepad>;
  49405. /**
  49406. * observable to be triggered when the gamepad controller has been disconnected
  49407. */
  49408. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49409. private _onGamepadConnectedEvent;
  49410. private _onGamepadDisconnectedEvent;
  49411. /**
  49412. * Initializes the gamepad manager
  49413. * @param _scene BabylonJS scene
  49414. */
  49415. constructor(_scene?: Scene | undefined);
  49416. /**
  49417. * The gamepads in the game pad manager
  49418. */
  49419. get gamepads(): Gamepad[];
  49420. /**
  49421. * Get the gamepad controllers based on type
  49422. * @param type The type of gamepad controller
  49423. * @returns Nullable gamepad
  49424. */
  49425. getGamepadByType(type?: number): Nullable<Gamepad>;
  49426. /**
  49427. * Disposes the gamepad manager
  49428. */
  49429. dispose(): void;
  49430. private _addNewGamepad;
  49431. private _startMonitoringGamepads;
  49432. private _stopMonitoringGamepads;
  49433. /** @hidden */
  49434. _checkGamepadsStatus(): void;
  49435. private _updateGamepadObjects;
  49436. }
  49437. }
  49438. declare module BABYLON {
  49439. interface Scene {
  49440. /** @hidden */
  49441. _gamepadManager: Nullable<GamepadManager>;
  49442. /**
  49443. * Gets the gamepad manager associated with the scene
  49444. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49445. */
  49446. gamepadManager: GamepadManager;
  49447. }
  49448. /**
  49449. * Interface representing a free camera inputs manager
  49450. */
  49451. interface FreeCameraInputsManager {
  49452. /**
  49453. * Adds gamepad input support to the FreeCameraInputsManager.
  49454. * @returns the FreeCameraInputsManager
  49455. */
  49456. addGamepad(): FreeCameraInputsManager;
  49457. }
  49458. /**
  49459. * Interface representing an arc rotate camera inputs manager
  49460. */
  49461. interface ArcRotateCameraInputsManager {
  49462. /**
  49463. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49464. * @returns the camera inputs manager
  49465. */
  49466. addGamepad(): ArcRotateCameraInputsManager;
  49467. }
  49468. /**
  49469. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49470. */
  49471. export class GamepadSystemSceneComponent implements ISceneComponent {
  49472. /**
  49473. * The component name helpfull to identify the component in the list of scene components.
  49474. */
  49475. readonly name: string;
  49476. /**
  49477. * The scene the component belongs to.
  49478. */
  49479. scene: Scene;
  49480. /**
  49481. * Creates a new instance of the component for the given scene
  49482. * @param scene Defines the scene to register the component in
  49483. */
  49484. constructor(scene: Scene);
  49485. /**
  49486. * Registers the component in a given scene
  49487. */
  49488. register(): void;
  49489. /**
  49490. * Rebuilds the elements related to this component in case of
  49491. * context lost for instance.
  49492. */
  49493. rebuild(): void;
  49494. /**
  49495. * Disposes the component and the associated ressources
  49496. */
  49497. dispose(): void;
  49498. private _beforeCameraUpdate;
  49499. }
  49500. }
  49501. declare module BABYLON {
  49502. /**
  49503. * 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,
  49504. * which still works and will still be found in many Playgrounds.
  49505. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49506. */
  49507. export class UniversalCamera extends TouchCamera {
  49508. /**
  49509. * Defines the gamepad rotation sensiblity.
  49510. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49511. */
  49512. get gamepadAngularSensibility(): number;
  49513. set gamepadAngularSensibility(value: number);
  49514. /**
  49515. * Defines the gamepad move sensiblity.
  49516. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49517. */
  49518. get gamepadMoveSensibility(): number;
  49519. set gamepadMoveSensibility(value: number);
  49520. /**
  49521. * 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,
  49522. * which still works and will still be found in many Playgrounds.
  49523. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49524. * @param name Define the name of the camera in the scene
  49525. * @param position Define the start position of the camera in the scene
  49526. * @param scene Define the scene the camera belongs to
  49527. */
  49528. constructor(name: string, position: Vector3, scene: Scene);
  49529. /**
  49530. * Gets the current object class name.
  49531. * @return the class name
  49532. */
  49533. getClassName(): string;
  49534. }
  49535. }
  49536. declare module BABYLON {
  49537. /**
  49538. * This represents a FPS type of camera. This is only here for back compat purpose.
  49539. * Please use the UniversalCamera instead as both are identical.
  49540. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49541. */
  49542. export class GamepadCamera extends UniversalCamera {
  49543. /**
  49544. * Instantiates a new Gamepad Camera
  49545. * This represents a FPS type of camera. This is only here for back compat purpose.
  49546. * Please use the UniversalCamera instead as both are identical.
  49547. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49548. * @param name Define the name of the camera in the scene
  49549. * @param position Define the start position of the camera in the scene
  49550. * @param scene Define the scene the camera belongs to
  49551. */
  49552. constructor(name: string, position: Vector3, scene: Scene);
  49553. /**
  49554. * Gets the current object class name.
  49555. * @return the class name
  49556. */
  49557. getClassName(): string;
  49558. }
  49559. }
  49560. declare module BABYLON {
  49561. /** @hidden */
  49562. export var passPixelShader: {
  49563. name: string;
  49564. shader: string;
  49565. };
  49566. }
  49567. declare module BABYLON {
  49568. /** @hidden */
  49569. export var passCubePixelShader: {
  49570. name: string;
  49571. shader: string;
  49572. };
  49573. }
  49574. declare module BABYLON {
  49575. /**
  49576. * PassPostProcess which produces an output the same as it's input
  49577. */
  49578. export class PassPostProcess extends PostProcess {
  49579. /**
  49580. * Gets a string identifying the name of the class
  49581. * @returns "PassPostProcess" string
  49582. */
  49583. getClassName(): string;
  49584. /**
  49585. * Creates the PassPostProcess
  49586. * @param name The name of the effect.
  49587. * @param options The required width/height ratio to downsize to before computing the render pass.
  49588. * @param camera The camera to apply the render pass to.
  49589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49590. * @param engine The engine which the post process will be applied. (default: current engine)
  49591. * @param reusable If the post process can be reused on the same frame. (default: false)
  49592. * @param textureType The type of texture to be used when performing the post processing.
  49593. * @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)
  49594. */
  49595. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49596. /** @hidden */
  49597. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49598. }
  49599. /**
  49600. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49601. */
  49602. export class PassCubePostProcess extends PostProcess {
  49603. private _face;
  49604. /**
  49605. * Gets or sets the cube face to display.
  49606. * * 0 is +X
  49607. * * 1 is -X
  49608. * * 2 is +Y
  49609. * * 3 is -Y
  49610. * * 4 is +Z
  49611. * * 5 is -Z
  49612. */
  49613. get face(): number;
  49614. set face(value: number);
  49615. /**
  49616. * Gets a string identifying the name of the class
  49617. * @returns "PassCubePostProcess" string
  49618. */
  49619. getClassName(): string;
  49620. /**
  49621. * Creates the PassCubePostProcess
  49622. * @param name The name of the effect.
  49623. * @param options The required width/height ratio to downsize to before computing the render pass.
  49624. * @param camera The camera to apply the render pass to.
  49625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49626. * @param engine The engine which the post process will be applied. (default: current engine)
  49627. * @param reusable If the post process can be reused on the same frame. (default: false)
  49628. * @param textureType The type of texture to be used when performing the post processing.
  49629. * @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)
  49630. */
  49631. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49632. /** @hidden */
  49633. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49634. }
  49635. }
  49636. declare module BABYLON {
  49637. /** @hidden */
  49638. export var anaglyphPixelShader: {
  49639. name: string;
  49640. shader: string;
  49641. };
  49642. }
  49643. declare module BABYLON {
  49644. /**
  49645. * Postprocess used to generate anaglyphic rendering
  49646. */
  49647. export class AnaglyphPostProcess extends PostProcess {
  49648. private _passedProcess;
  49649. /**
  49650. * Gets a string identifying the name of the class
  49651. * @returns "AnaglyphPostProcess" string
  49652. */
  49653. getClassName(): string;
  49654. /**
  49655. * Creates a new AnaglyphPostProcess
  49656. * @param name defines postprocess name
  49657. * @param options defines creation options or target ratio scale
  49658. * @param rigCameras defines cameras using this postprocess
  49659. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49660. * @param engine defines hosting engine
  49661. * @param reusable defines if the postprocess will be reused multiple times per frame
  49662. */
  49663. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49664. }
  49665. }
  49666. declare module BABYLON {
  49667. /**
  49668. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49669. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49670. */
  49671. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49672. /**
  49673. * Creates a new AnaglyphArcRotateCamera
  49674. * @param name defines camera name
  49675. * @param alpha defines alpha angle (in radians)
  49676. * @param beta defines beta angle (in radians)
  49677. * @param radius defines radius
  49678. * @param target defines camera target
  49679. * @param interaxialDistance defines distance between each color axis
  49680. * @param scene defines the hosting scene
  49681. */
  49682. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49683. /**
  49684. * Gets camera class name
  49685. * @returns AnaglyphArcRotateCamera
  49686. */
  49687. getClassName(): string;
  49688. }
  49689. }
  49690. declare module BABYLON {
  49691. /**
  49692. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49693. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49694. */
  49695. export class AnaglyphFreeCamera extends FreeCamera {
  49696. /**
  49697. * Creates a new AnaglyphFreeCamera
  49698. * @param name defines camera name
  49699. * @param position defines initial position
  49700. * @param interaxialDistance defines distance between each color axis
  49701. * @param scene defines the hosting scene
  49702. */
  49703. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49704. /**
  49705. * Gets camera class name
  49706. * @returns AnaglyphFreeCamera
  49707. */
  49708. getClassName(): string;
  49709. }
  49710. }
  49711. declare module BABYLON {
  49712. /**
  49713. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49714. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49715. */
  49716. export class AnaglyphGamepadCamera extends GamepadCamera {
  49717. /**
  49718. * Creates a new AnaglyphGamepadCamera
  49719. * @param name defines camera name
  49720. * @param position defines initial position
  49721. * @param interaxialDistance defines distance between each color axis
  49722. * @param scene defines the hosting scene
  49723. */
  49724. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49725. /**
  49726. * Gets camera class name
  49727. * @returns AnaglyphGamepadCamera
  49728. */
  49729. getClassName(): string;
  49730. }
  49731. }
  49732. declare module BABYLON {
  49733. /**
  49734. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49735. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49736. */
  49737. export class AnaglyphUniversalCamera extends UniversalCamera {
  49738. /**
  49739. * Creates a new AnaglyphUniversalCamera
  49740. * @param name defines camera name
  49741. * @param position defines initial position
  49742. * @param interaxialDistance defines distance between each color axis
  49743. * @param scene defines the hosting scene
  49744. */
  49745. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49746. /**
  49747. * Gets camera class name
  49748. * @returns AnaglyphUniversalCamera
  49749. */
  49750. getClassName(): string;
  49751. }
  49752. }
  49753. declare module BABYLON {
  49754. /**
  49755. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49756. * @see https://doc.babylonjs.com/features/cameras
  49757. */
  49758. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49759. /**
  49760. * Creates a new StereoscopicArcRotateCamera
  49761. * @param name defines camera name
  49762. * @param alpha defines alpha angle (in radians)
  49763. * @param beta defines beta angle (in radians)
  49764. * @param radius defines radius
  49765. * @param target defines camera target
  49766. * @param interaxialDistance defines distance between each color axis
  49767. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49768. * @param scene defines the hosting scene
  49769. */
  49770. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49771. /**
  49772. * Gets camera class name
  49773. * @returns StereoscopicArcRotateCamera
  49774. */
  49775. getClassName(): string;
  49776. }
  49777. }
  49778. declare module BABYLON {
  49779. /**
  49780. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49781. * @see https://doc.babylonjs.com/features/cameras
  49782. */
  49783. export class StereoscopicFreeCamera extends FreeCamera {
  49784. /**
  49785. * Creates a new StereoscopicFreeCamera
  49786. * @param name defines camera name
  49787. * @param position defines initial position
  49788. * @param interaxialDistance defines distance between each color axis
  49789. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49790. * @param scene defines the hosting scene
  49791. */
  49792. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49793. /**
  49794. * Gets camera class name
  49795. * @returns StereoscopicFreeCamera
  49796. */
  49797. getClassName(): string;
  49798. }
  49799. }
  49800. declare module BABYLON {
  49801. /**
  49802. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49803. * @see https://doc.babylonjs.com/features/cameras
  49804. */
  49805. export class StereoscopicGamepadCamera extends GamepadCamera {
  49806. /**
  49807. * Creates a new StereoscopicGamepadCamera
  49808. * @param name defines camera name
  49809. * @param position defines initial position
  49810. * @param interaxialDistance defines distance between each color axis
  49811. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49812. * @param scene defines the hosting scene
  49813. */
  49814. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49815. /**
  49816. * Gets camera class name
  49817. * @returns StereoscopicGamepadCamera
  49818. */
  49819. getClassName(): string;
  49820. }
  49821. }
  49822. declare module BABYLON {
  49823. /**
  49824. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49825. * @see https://doc.babylonjs.com/features/cameras
  49826. */
  49827. export class StereoscopicUniversalCamera extends UniversalCamera {
  49828. /**
  49829. * Creates a new StereoscopicUniversalCamera
  49830. * @param name defines camera name
  49831. * @param position defines initial position
  49832. * @param interaxialDistance defines distance between each color axis
  49833. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49834. * @param scene defines the hosting scene
  49835. */
  49836. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49837. /**
  49838. * Gets camera class name
  49839. * @returns StereoscopicUniversalCamera
  49840. */
  49841. getClassName(): string;
  49842. }
  49843. }
  49844. declare module BABYLON {
  49845. /**
  49846. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49847. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49848. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49849. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49850. */
  49851. export class VirtualJoysticksCamera extends FreeCamera {
  49852. /**
  49853. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49854. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49855. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49856. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49857. * @param name Define the name of the camera in the scene
  49858. * @param position Define the start position of the camera in the scene
  49859. * @param scene Define the scene the camera belongs to
  49860. */
  49861. constructor(name: string, position: Vector3, scene: Scene);
  49862. /**
  49863. * Gets the current object class name.
  49864. * @return the class name
  49865. */
  49866. getClassName(): string;
  49867. }
  49868. }
  49869. declare module BABYLON {
  49870. /**
  49871. * This represents all the required metrics to create a VR camera.
  49872. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49873. */
  49874. export class VRCameraMetrics {
  49875. /**
  49876. * Define the horizontal resolution off the screen.
  49877. */
  49878. hResolution: number;
  49879. /**
  49880. * Define the vertical resolution off the screen.
  49881. */
  49882. vResolution: number;
  49883. /**
  49884. * Define the horizontal screen size.
  49885. */
  49886. hScreenSize: number;
  49887. /**
  49888. * Define the vertical screen size.
  49889. */
  49890. vScreenSize: number;
  49891. /**
  49892. * Define the vertical screen center position.
  49893. */
  49894. vScreenCenter: number;
  49895. /**
  49896. * Define the distance of the eyes to the screen.
  49897. */
  49898. eyeToScreenDistance: number;
  49899. /**
  49900. * Define the distance between both lenses
  49901. */
  49902. lensSeparationDistance: number;
  49903. /**
  49904. * Define the distance between both viewer's eyes.
  49905. */
  49906. interpupillaryDistance: number;
  49907. /**
  49908. * Define the distortion factor of the VR postprocess.
  49909. * Please, touch with care.
  49910. */
  49911. distortionK: number[];
  49912. /**
  49913. * Define the chromatic aberration correction factors for the VR post process.
  49914. */
  49915. chromaAbCorrection: number[];
  49916. /**
  49917. * Define the scale factor of the post process.
  49918. * The smaller the better but the slower.
  49919. */
  49920. postProcessScaleFactor: number;
  49921. /**
  49922. * Define an offset for the lens center.
  49923. */
  49924. lensCenterOffset: number;
  49925. /**
  49926. * Define if the current vr camera should compensate the distortion of the lense or not.
  49927. */
  49928. compensateDistortion: boolean;
  49929. /**
  49930. * Defines if multiview should be enabled when rendering (Default: false)
  49931. */
  49932. multiviewEnabled: boolean;
  49933. /**
  49934. * Gets the rendering aspect ratio based on the provided resolutions.
  49935. */
  49936. get aspectRatio(): number;
  49937. /**
  49938. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49939. */
  49940. get aspectRatioFov(): number;
  49941. /**
  49942. * @hidden
  49943. */
  49944. get leftHMatrix(): Matrix;
  49945. /**
  49946. * @hidden
  49947. */
  49948. get rightHMatrix(): Matrix;
  49949. /**
  49950. * @hidden
  49951. */
  49952. get leftPreViewMatrix(): Matrix;
  49953. /**
  49954. * @hidden
  49955. */
  49956. get rightPreViewMatrix(): Matrix;
  49957. /**
  49958. * Get the default VRMetrics based on the most generic setup.
  49959. * @returns the default vr metrics
  49960. */
  49961. static GetDefault(): VRCameraMetrics;
  49962. }
  49963. }
  49964. declare module BABYLON {
  49965. /** @hidden */
  49966. export var vrDistortionCorrectionPixelShader: {
  49967. name: string;
  49968. shader: string;
  49969. };
  49970. }
  49971. declare module BABYLON {
  49972. /**
  49973. * VRDistortionCorrectionPostProcess used for mobile VR
  49974. */
  49975. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49976. private _isRightEye;
  49977. private _distortionFactors;
  49978. private _postProcessScaleFactor;
  49979. private _lensCenterOffset;
  49980. private _scaleIn;
  49981. private _scaleFactor;
  49982. private _lensCenter;
  49983. /**
  49984. * Gets a string identifying the name of the class
  49985. * @returns "VRDistortionCorrectionPostProcess" string
  49986. */
  49987. getClassName(): string;
  49988. /**
  49989. * Initializes the VRDistortionCorrectionPostProcess
  49990. * @param name The name of the effect.
  49991. * @param camera The camera to apply the render pass to.
  49992. * @param isRightEye If this is for the right eye distortion
  49993. * @param vrMetrics All the required metrics for the VR camera
  49994. */
  49995. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49996. }
  49997. }
  49998. declare module BABYLON {
  49999. /**
  50000. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  50001. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50002. */
  50003. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  50004. /**
  50005. * Creates a new VRDeviceOrientationArcRotateCamera
  50006. * @param name defines camera name
  50007. * @param alpha defines the camera rotation along the logitudinal axis
  50008. * @param beta defines the camera rotation along the latitudinal axis
  50009. * @param radius defines the camera distance from its target
  50010. * @param target defines the camera target
  50011. * @param scene defines the scene the camera belongs to
  50012. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50013. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50014. */
  50015. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50016. /**
  50017. * Gets camera class name
  50018. * @returns VRDeviceOrientationArcRotateCamera
  50019. */
  50020. getClassName(): string;
  50021. }
  50022. }
  50023. declare module BABYLON {
  50024. /**
  50025. * Camera used to simulate VR rendering (based on FreeCamera)
  50026. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50027. */
  50028. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  50029. /**
  50030. * Creates a new VRDeviceOrientationFreeCamera
  50031. * @param name defines camera name
  50032. * @param position defines the start position of the camera
  50033. * @param scene defines the scene the camera belongs to
  50034. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50035. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50036. */
  50037. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50038. /**
  50039. * Gets camera class name
  50040. * @returns VRDeviceOrientationFreeCamera
  50041. */
  50042. getClassName(): string;
  50043. }
  50044. }
  50045. declare module BABYLON {
  50046. /**
  50047. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  50048. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50049. */
  50050. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  50051. /**
  50052. * Creates a new VRDeviceOrientationGamepadCamera
  50053. * @param name defines camera name
  50054. * @param position defines the start position of the camera
  50055. * @param scene defines the scene the camera belongs to
  50056. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50057. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50058. */
  50059. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50060. /**
  50061. * Gets camera class name
  50062. * @returns VRDeviceOrientationGamepadCamera
  50063. */
  50064. getClassName(): string;
  50065. }
  50066. }
  50067. declare module BABYLON {
  50068. /**
  50069. * A class extending Texture allowing drawing on a texture
  50070. * @see https://doc.babylonjs.com/how_to/dynamictexture
  50071. */
  50072. export class DynamicTexture extends Texture {
  50073. private _generateMipMaps;
  50074. private _canvas;
  50075. private _context;
  50076. /**
  50077. * Creates a DynamicTexture
  50078. * @param name defines the name of the texture
  50079. * @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
  50080. * @param scene defines the scene where you want the texture
  50081. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  50082. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  50083. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  50084. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  50085. */
  50086. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  50087. /**
  50088. * Get the current class name of the texture useful for serialization or dynamic coding.
  50089. * @returns "DynamicTexture"
  50090. */
  50091. getClassName(): string;
  50092. /**
  50093. * Gets the current state of canRescale
  50094. */
  50095. get canRescale(): boolean;
  50096. private _recreate;
  50097. /**
  50098. * Scales the texture
  50099. * @param ratio the scale factor to apply to both width and height
  50100. */
  50101. scale(ratio: number): void;
  50102. /**
  50103. * Resizes the texture
  50104. * @param width the new width
  50105. * @param height the new height
  50106. */
  50107. scaleTo(width: number, height: number): void;
  50108. /**
  50109. * Gets the context of the canvas used by the texture
  50110. * @returns the canvas context of the dynamic texture
  50111. */
  50112. getContext(): CanvasRenderingContext2D;
  50113. /**
  50114. * Clears the texture
  50115. */
  50116. clear(): void;
  50117. /**
  50118. * Updates the texture
  50119. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50120. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  50121. */
  50122. update(invertY?: boolean, premulAlpha?: boolean): void;
  50123. /**
  50124. * Draws text onto the texture
  50125. * @param text defines the text to be drawn
  50126. * @param x defines the placement of the text from the left
  50127. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  50128. * @param font defines the font to be used with font-style, font-size, font-name
  50129. * @param color defines the color used for the text
  50130. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  50131. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50132. * @param update defines whether texture is immediately update (default is true)
  50133. */
  50134. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  50135. /**
  50136. * Clones the texture
  50137. * @returns the clone of the texture.
  50138. */
  50139. clone(): DynamicTexture;
  50140. /**
  50141. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  50142. * @returns a serialized dynamic texture object
  50143. */
  50144. serialize(): any;
  50145. private _IsCanvasElement;
  50146. /** @hidden */
  50147. _rebuild(): void;
  50148. }
  50149. }
  50150. declare module BABYLON {
  50151. /**
  50152. * Class containing static functions to help procedurally build meshes
  50153. */
  50154. export class GroundBuilder {
  50155. /**
  50156. * Creates a ground mesh
  50157. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50158. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50160. * @param name defines the name of the mesh
  50161. * @param options defines the options used to create the mesh
  50162. * @param scene defines the hosting scene
  50163. * @returns the ground mesh
  50164. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50165. */
  50166. static CreateGround(name: string, options: {
  50167. width?: number;
  50168. height?: number;
  50169. subdivisions?: number;
  50170. subdivisionsX?: number;
  50171. subdivisionsY?: number;
  50172. updatable?: boolean;
  50173. }, scene: any): Mesh;
  50174. /**
  50175. * Creates a tiled ground mesh
  50176. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50177. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50178. * * 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
  50179. * * 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
  50180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50181. * @param name defines the name of the mesh
  50182. * @param options defines the options used to create the mesh
  50183. * @param scene defines the hosting scene
  50184. * @returns the tiled ground mesh
  50185. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50186. */
  50187. static CreateTiledGround(name: string, options: {
  50188. xmin: number;
  50189. zmin: number;
  50190. xmax: number;
  50191. zmax: number;
  50192. subdivisions?: {
  50193. w: number;
  50194. h: number;
  50195. };
  50196. precision?: {
  50197. w: number;
  50198. h: number;
  50199. };
  50200. updatable?: boolean;
  50201. }, scene?: Nullable<Scene>): Mesh;
  50202. /**
  50203. * Creates a ground mesh from a height map
  50204. * * The parameter `url` sets the URL of the height map image resource.
  50205. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50206. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50207. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50208. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50209. * * 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.
  50210. * * 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).
  50211. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50213. * @param name defines the name of the mesh
  50214. * @param url defines the url to the height map
  50215. * @param options defines the options used to create the mesh
  50216. * @param scene defines the hosting scene
  50217. * @returns the ground mesh
  50218. * @see https://doc.babylonjs.com/babylon101/height_map
  50219. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50220. */
  50221. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50222. width?: number;
  50223. height?: number;
  50224. subdivisions?: number;
  50225. minHeight?: number;
  50226. maxHeight?: number;
  50227. colorFilter?: Color3;
  50228. alphaFilter?: number;
  50229. updatable?: boolean;
  50230. onReady?: (mesh: GroundMesh) => void;
  50231. }, scene?: Nullable<Scene>): GroundMesh;
  50232. }
  50233. }
  50234. declare module BABYLON {
  50235. /**
  50236. * Class containing static functions to help procedurally build meshes
  50237. */
  50238. export class TorusBuilder {
  50239. /**
  50240. * Creates a torus mesh
  50241. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50242. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50243. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50245. * * 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
  50246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50247. * @param name defines the name of the mesh
  50248. * @param options defines the options used to create the mesh
  50249. * @param scene defines the hosting scene
  50250. * @returns the torus mesh
  50251. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50252. */
  50253. static CreateTorus(name: string, options: {
  50254. diameter?: number;
  50255. thickness?: number;
  50256. tessellation?: number;
  50257. updatable?: boolean;
  50258. sideOrientation?: number;
  50259. frontUVs?: Vector4;
  50260. backUVs?: Vector4;
  50261. }, scene: any): Mesh;
  50262. }
  50263. }
  50264. declare module BABYLON {
  50265. /**
  50266. * Class containing static functions to help procedurally build meshes
  50267. */
  50268. export class CylinderBuilder {
  50269. /**
  50270. * Creates a cylinder or a cone mesh
  50271. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50272. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50273. * * 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.
  50274. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50275. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50276. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50277. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50278. * * 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).
  50279. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50280. * * 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).
  50281. * * 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
  50282. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50283. * * 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
  50284. * * 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.
  50285. * * If `enclose` is false, a ring surface is one element.
  50286. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50287. * * 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
  50288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50289. * * 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
  50290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50291. * @param name defines the name of the mesh
  50292. * @param options defines the options used to create the mesh
  50293. * @param scene defines the hosting scene
  50294. * @returns the cylinder mesh
  50295. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50296. */
  50297. static CreateCylinder(name: string, options: {
  50298. height?: number;
  50299. diameterTop?: number;
  50300. diameterBottom?: number;
  50301. diameter?: number;
  50302. tessellation?: number;
  50303. subdivisions?: number;
  50304. arc?: number;
  50305. faceColors?: Color4[];
  50306. faceUV?: Vector4[];
  50307. updatable?: boolean;
  50308. hasRings?: boolean;
  50309. enclose?: boolean;
  50310. cap?: number;
  50311. sideOrientation?: number;
  50312. frontUVs?: Vector4;
  50313. backUVs?: Vector4;
  50314. }, scene: any): Mesh;
  50315. }
  50316. }
  50317. declare module BABYLON {
  50318. /**
  50319. * States of the webXR experience
  50320. */
  50321. export enum WebXRState {
  50322. /**
  50323. * Transitioning to being in XR mode
  50324. */
  50325. ENTERING_XR = 0,
  50326. /**
  50327. * Transitioning to non XR mode
  50328. */
  50329. EXITING_XR = 1,
  50330. /**
  50331. * In XR mode and presenting
  50332. */
  50333. IN_XR = 2,
  50334. /**
  50335. * Not entered XR mode
  50336. */
  50337. NOT_IN_XR = 3
  50338. }
  50339. /**
  50340. * The state of the XR camera's tracking
  50341. */
  50342. export enum WebXRTrackingState {
  50343. /**
  50344. * No transformation received, device is not being tracked
  50345. */
  50346. NOT_TRACKING = 0,
  50347. /**
  50348. * Tracking lost - using emulated position
  50349. */
  50350. TRACKING_LOST = 1,
  50351. /**
  50352. * Transformation tracking works normally
  50353. */
  50354. TRACKING = 2
  50355. }
  50356. /**
  50357. * Abstraction of the XR render target
  50358. */
  50359. export interface WebXRRenderTarget extends IDisposable {
  50360. /**
  50361. * xrpresent context of the canvas which can be used to display/mirror xr content
  50362. */
  50363. canvasContext: WebGLRenderingContext;
  50364. /**
  50365. * xr layer for the canvas
  50366. */
  50367. xrLayer: Nullable<XRWebGLLayer>;
  50368. /**
  50369. * Initializes the xr layer for the session
  50370. * @param xrSession xr session
  50371. * @returns a promise that will resolve once the XR Layer has been created
  50372. */
  50373. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50374. }
  50375. }
  50376. declare module BABYLON {
  50377. /**
  50378. * COnfiguration object for WebXR output canvas
  50379. */
  50380. export class WebXRManagedOutputCanvasOptions {
  50381. /**
  50382. * An optional canvas in case you wish to create it yourself and provide it here.
  50383. * If not provided, a new canvas will be created
  50384. */
  50385. canvasElement?: HTMLCanvasElement;
  50386. /**
  50387. * Options for this XR Layer output
  50388. */
  50389. canvasOptions?: XRWebGLLayerInit;
  50390. /**
  50391. * CSS styling for a newly created canvas (if not provided)
  50392. */
  50393. newCanvasCssStyle?: string;
  50394. /**
  50395. * Get the default values of the configuration object
  50396. * @param engine defines the engine to use (can be null)
  50397. * @returns default values of this configuration object
  50398. */
  50399. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50400. }
  50401. /**
  50402. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50403. */
  50404. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50405. private _options;
  50406. private _canvas;
  50407. private _engine;
  50408. private _originalCanvasSize;
  50409. /**
  50410. * Rendering context of the canvas which can be used to display/mirror xr content
  50411. */
  50412. canvasContext: WebGLRenderingContext;
  50413. /**
  50414. * xr layer for the canvas
  50415. */
  50416. xrLayer: Nullable<XRWebGLLayer>;
  50417. /**
  50418. * Obseervers registered here will be triggered when the xr layer was initialized
  50419. */
  50420. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50421. /**
  50422. * Initializes the canvas to be added/removed upon entering/exiting xr
  50423. * @param _xrSessionManager The XR Session manager
  50424. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50425. */
  50426. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50427. /**
  50428. * Disposes of the object
  50429. */
  50430. dispose(): void;
  50431. /**
  50432. * Initializes the xr layer for the session
  50433. * @param xrSession xr session
  50434. * @returns a promise that will resolve once the XR Layer has been created
  50435. */
  50436. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50437. private _addCanvas;
  50438. private _removeCanvas;
  50439. private _setCanvasSize;
  50440. private _setManagedOutputCanvas;
  50441. }
  50442. }
  50443. declare module BABYLON {
  50444. /**
  50445. * Manages an XRSession to work with Babylon's engine
  50446. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50447. */
  50448. export class WebXRSessionManager implements IDisposable {
  50449. /** The scene which the session should be created for */
  50450. scene: Scene;
  50451. private _referenceSpace;
  50452. private _rttProvider;
  50453. private _sessionEnded;
  50454. private _xrNavigator;
  50455. private baseLayer;
  50456. /**
  50457. * The base reference space from which the session started. good if you want to reset your
  50458. * reference space
  50459. */
  50460. baseReferenceSpace: XRReferenceSpace;
  50461. /**
  50462. * Current XR frame
  50463. */
  50464. currentFrame: Nullable<XRFrame>;
  50465. /** WebXR timestamp updated every frame */
  50466. currentTimestamp: number;
  50467. /**
  50468. * Used just in case of a failure to initialize an immersive session.
  50469. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50470. */
  50471. defaultHeightCompensation: number;
  50472. /**
  50473. * Fires every time a new xrFrame arrives which can be used to update the camera
  50474. */
  50475. onXRFrameObservable: Observable<XRFrame>;
  50476. /**
  50477. * Fires when the reference space changed
  50478. */
  50479. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50480. /**
  50481. * Fires when the xr session is ended either by the device or manually done
  50482. */
  50483. onXRSessionEnded: Observable<any>;
  50484. /**
  50485. * Fires when the xr session is ended either by the device or manually done
  50486. */
  50487. onXRSessionInit: Observable<XRSession>;
  50488. /**
  50489. * Underlying xr session
  50490. */
  50491. session: XRSession;
  50492. /**
  50493. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50494. * or get the offset the player is currently at.
  50495. */
  50496. viewerReferenceSpace: XRReferenceSpace;
  50497. /**
  50498. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50499. * @param scene The scene which the session should be created for
  50500. */
  50501. constructor(
  50502. /** The scene which the session should be created for */
  50503. scene: Scene);
  50504. /**
  50505. * The current reference space used in this session. This reference space can constantly change!
  50506. * It is mainly used to offset the camera's position.
  50507. */
  50508. get referenceSpace(): XRReferenceSpace;
  50509. /**
  50510. * Set a new reference space and triggers the observable
  50511. */
  50512. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50513. /**
  50514. * Disposes of the session manager
  50515. */
  50516. dispose(): void;
  50517. /**
  50518. * Stops the xrSession and restores the render loop
  50519. * @returns Promise which resolves after it exits XR
  50520. */
  50521. exitXRAsync(): Promise<void>;
  50522. /**
  50523. * Gets the correct render target texture to be rendered this frame for this eye
  50524. * @param eye the eye for which to get the render target
  50525. * @returns the render target for the specified eye
  50526. */
  50527. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50528. /**
  50529. * Creates a WebXRRenderTarget object for the XR session
  50530. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50531. * @param options optional options to provide when creating a new render target
  50532. * @returns a WebXR render target to which the session can render
  50533. */
  50534. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50535. /**
  50536. * Initializes the manager
  50537. * After initialization enterXR can be called to start an XR session
  50538. * @returns Promise which resolves after it is initialized
  50539. */
  50540. initializeAsync(): Promise<void>;
  50541. /**
  50542. * Initializes an xr session
  50543. * @param xrSessionMode mode to initialize
  50544. * @param xrSessionInit defines optional and required values to pass to the session builder
  50545. * @returns a promise which will resolve once the session has been initialized
  50546. */
  50547. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50548. /**
  50549. * Checks if a session would be supported for the creation options specified
  50550. * @param sessionMode session mode to check if supported eg. immersive-vr
  50551. * @returns A Promise that resolves to true if supported and false if not
  50552. */
  50553. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50554. /**
  50555. * Resets the reference space to the one started the session
  50556. */
  50557. resetReferenceSpace(): void;
  50558. /**
  50559. * Starts rendering to the xr layer
  50560. */
  50561. runXRRenderLoop(): void;
  50562. /**
  50563. * Sets the reference space on the xr session
  50564. * @param referenceSpaceType space to set
  50565. * @returns a promise that will resolve once the reference space has been set
  50566. */
  50567. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50568. /**
  50569. * Updates the render state of the session
  50570. * @param state state to set
  50571. * @returns a promise that resolves once the render state has been updated
  50572. */
  50573. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50574. /**
  50575. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50576. * @param sessionMode defines the session to test
  50577. * @returns a promise with boolean as final value
  50578. */
  50579. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50580. private _createRenderTargetTexture;
  50581. }
  50582. }
  50583. declare module BABYLON {
  50584. /**
  50585. * WebXR Camera which holds the views for the xrSession
  50586. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50587. */
  50588. export class WebXRCamera extends FreeCamera {
  50589. private _xrSessionManager;
  50590. private _firstFrame;
  50591. private _referenceQuaternion;
  50592. private _referencedPosition;
  50593. private _xrInvPositionCache;
  50594. private _xrInvQuaternionCache;
  50595. private _trackingState;
  50596. /**
  50597. * Observable raised before camera teleportation
  50598. */
  50599. onBeforeCameraTeleport: Observable<Vector3>;
  50600. /**
  50601. * Observable raised after camera teleportation
  50602. */
  50603. onAfterCameraTeleport: Observable<Vector3>;
  50604. /**
  50605. * Notifies when the camera's tracking state has changed.
  50606. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50607. */
  50608. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50609. /**
  50610. * Should position compensation execute on first frame.
  50611. * This is used when copying the position from a native (non XR) camera
  50612. */
  50613. compensateOnFirstFrame: boolean;
  50614. /**
  50615. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50616. * @param name the name of the camera
  50617. * @param scene the scene to add the camera to
  50618. * @param _xrSessionManager a constructed xr session manager
  50619. */
  50620. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50621. /**
  50622. * Get the current XR tracking state of the camera
  50623. */
  50624. get trackingState(): WebXRTrackingState;
  50625. private _setTrackingState;
  50626. /**
  50627. * Return the user's height, unrelated to the current ground.
  50628. * This will be the y position of this camera, when ground level is 0.
  50629. */
  50630. get realWorldHeight(): number;
  50631. /** @hidden */
  50632. _updateForDualEyeDebugging(): void;
  50633. /**
  50634. * Sets this camera's transformation based on a non-vr camera
  50635. * @param otherCamera the non-vr camera to copy the transformation from
  50636. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50637. */
  50638. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50639. /**
  50640. * Gets the current instance class name ("WebXRCamera").
  50641. * @returns the class name
  50642. */
  50643. getClassName(): string;
  50644. private _rotate180;
  50645. private _updateFromXRSession;
  50646. private _updateNumberOfRigCameras;
  50647. private _updateReferenceSpace;
  50648. private _updateReferenceSpaceOffset;
  50649. }
  50650. }
  50651. declare module BABYLON {
  50652. /**
  50653. * Defining the interface required for a (webxr) feature
  50654. */
  50655. export interface IWebXRFeature extends IDisposable {
  50656. /**
  50657. * Is this feature attached
  50658. */
  50659. attached: boolean;
  50660. /**
  50661. * Should auto-attach be disabled?
  50662. */
  50663. disableAutoAttach: boolean;
  50664. /**
  50665. * Attach the feature to the session
  50666. * Will usually be called by the features manager
  50667. *
  50668. * @param force should attachment be forced (even when already attached)
  50669. * @returns true if successful.
  50670. */
  50671. attach(force?: boolean): boolean;
  50672. /**
  50673. * Detach the feature from the session
  50674. * Will usually be called by the features manager
  50675. *
  50676. * @returns true if successful.
  50677. */
  50678. detach(): boolean;
  50679. /**
  50680. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50681. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50682. *
  50683. * @returns whether or not the feature is compatible in this environment
  50684. */
  50685. isCompatible(): boolean;
  50686. /**
  50687. * Was this feature disposed;
  50688. */
  50689. isDisposed: boolean;
  50690. /**
  50691. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50692. */
  50693. xrNativeFeatureName?: string;
  50694. /**
  50695. * A list of (Babylon WebXR) features this feature depends on
  50696. */
  50697. dependsOn?: string[];
  50698. }
  50699. /**
  50700. * A list of the currently available features without referencing them
  50701. */
  50702. export class WebXRFeatureName {
  50703. /**
  50704. * The name of the anchor system feature
  50705. */
  50706. static readonly ANCHOR_SYSTEM: string;
  50707. /**
  50708. * The name of the background remover feature
  50709. */
  50710. static readonly BACKGROUND_REMOVER: string;
  50711. /**
  50712. * The name of the hit test feature
  50713. */
  50714. static readonly HIT_TEST: string;
  50715. /**
  50716. * physics impostors for xr controllers feature
  50717. */
  50718. static readonly PHYSICS_CONTROLLERS: string;
  50719. /**
  50720. * The name of the plane detection feature
  50721. */
  50722. static readonly PLANE_DETECTION: string;
  50723. /**
  50724. * The name of the pointer selection feature
  50725. */
  50726. static readonly POINTER_SELECTION: string;
  50727. /**
  50728. * The name of the teleportation feature
  50729. */
  50730. static readonly TELEPORTATION: string;
  50731. /**
  50732. * The name of the feature points feature.
  50733. */
  50734. static readonly FEATURE_POINTS: string;
  50735. /**
  50736. * The name of the hand tracking feature.
  50737. */
  50738. static readonly HAND_TRACKING: string;
  50739. }
  50740. /**
  50741. * Defining the constructor of a feature. Used to register the modules.
  50742. */
  50743. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50744. /**
  50745. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50746. * It is mainly used in AR sessions.
  50747. *
  50748. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50749. */
  50750. export class WebXRFeaturesManager implements IDisposable {
  50751. private _xrSessionManager;
  50752. private static readonly _AvailableFeatures;
  50753. private _features;
  50754. /**
  50755. * constructs a new features manages.
  50756. *
  50757. * @param _xrSessionManager an instance of WebXRSessionManager
  50758. */
  50759. constructor(_xrSessionManager: WebXRSessionManager);
  50760. /**
  50761. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50762. * Mainly used internally.
  50763. *
  50764. * @param featureName the name of the feature to register
  50765. * @param constructorFunction the function used to construct the module
  50766. * @param version the (babylon) version of the module
  50767. * @param stable is that a stable version of this module
  50768. */
  50769. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50770. /**
  50771. * Returns a constructor of a specific feature.
  50772. *
  50773. * @param featureName the name of the feature to construct
  50774. * @param version the version of the feature to load
  50775. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50776. * @param options optional options provided to the module.
  50777. * @returns a function that, when called, will return a new instance of this feature
  50778. */
  50779. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50780. /**
  50781. * Can be used to return the list of features currently registered
  50782. *
  50783. * @returns an Array of available features
  50784. */
  50785. static GetAvailableFeatures(): string[];
  50786. /**
  50787. * Gets the versions available for a specific feature
  50788. * @param featureName the name of the feature
  50789. * @returns an array with the available versions
  50790. */
  50791. static GetAvailableVersions(featureName: string): string[];
  50792. /**
  50793. * Return the latest unstable version of this feature
  50794. * @param featureName the name of the feature to search
  50795. * @returns the version number. if not found will return -1
  50796. */
  50797. static GetLatestVersionOfFeature(featureName: string): number;
  50798. /**
  50799. * Return the latest stable version of this feature
  50800. * @param featureName the name of the feature to search
  50801. * @returns the version number. if not found will return -1
  50802. */
  50803. static GetStableVersionOfFeature(featureName: string): number;
  50804. /**
  50805. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50806. * Can be used during a session to start a feature
  50807. * @param featureName the name of feature to attach
  50808. */
  50809. attachFeature(featureName: string): void;
  50810. /**
  50811. * Can be used inside a session or when the session ends to detach a specific feature
  50812. * @param featureName the name of the feature to detach
  50813. */
  50814. detachFeature(featureName: string): void;
  50815. /**
  50816. * Used to disable an already-enabled feature
  50817. * The feature will be disposed and will be recreated once enabled.
  50818. * @param featureName the feature to disable
  50819. * @returns true if disable was successful
  50820. */
  50821. disableFeature(featureName: string | {
  50822. Name: string;
  50823. }): boolean;
  50824. /**
  50825. * dispose this features manager
  50826. */
  50827. dispose(): void;
  50828. /**
  50829. * 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.
  50830. * 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.
  50831. *
  50832. * @param featureName the name of the feature to load or the class of the feature
  50833. * @param version optional version to load. if not provided the latest version will be enabled
  50834. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50835. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50836. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50837. * @returns a new constructed feature or throws an error if feature not found.
  50838. */
  50839. enableFeature(featureName: string | {
  50840. Name: string;
  50841. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50842. /**
  50843. * get the implementation of an enabled feature.
  50844. * @param featureName the name of the feature to load
  50845. * @returns the feature class, if found
  50846. */
  50847. getEnabledFeature(featureName: string): IWebXRFeature;
  50848. /**
  50849. * Get the list of enabled features
  50850. * @returns an array of enabled features
  50851. */
  50852. getEnabledFeatures(): string[];
  50853. /**
  50854. * This function will exten the session creation configuration object with enabled features.
  50855. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50856. * according to the defined "required" variable, provided during enableFeature call
  50857. * @param xrSessionInit the xr Session init object to extend
  50858. *
  50859. * @returns an extended XRSessionInit object
  50860. */
  50861. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50862. }
  50863. }
  50864. declare module BABYLON {
  50865. /**
  50866. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50867. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50868. */
  50869. export class WebXRExperienceHelper implements IDisposable {
  50870. private scene;
  50871. private _nonVRCamera;
  50872. private _originalSceneAutoClear;
  50873. private _supported;
  50874. /**
  50875. * Camera used to render xr content
  50876. */
  50877. camera: WebXRCamera;
  50878. /** A features manager for this xr session */
  50879. featuresManager: WebXRFeaturesManager;
  50880. /**
  50881. * Observers registered here will be triggered after the camera's initial transformation is set
  50882. * This can be used to set a different ground level or an extra rotation.
  50883. *
  50884. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50885. * to the position set after this observable is done executing.
  50886. */
  50887. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50888. /**
  50889. * Fires when the state of the experience helper has changed
  50890. */
  50891. onStateChangedObservable: Observable<WebXRState>;
  50892. /** Session manager used to keep track of xr session */
  50893. sessionManager: WebXRSessionManager;
  50894. /**
  50895. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50896. */
  50897. state: WebXRState;
  50898. /**
  50899. * Creates a WebXRExperienceHelper
  50900. * @param scene The scene the helper should be created in
  50901. */
  50902. private constructor();
  50903. /**
  50904. * Creates the experience helper
  50905. * @param scene the scene to attach the experience helper to
  50906. * @returns a promise for the experience helper
  50907. */
  50908. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50909. /**
  50910. * Disposes of the experience helper
  50911. */
  50912. dispose(): void;
  50913. /**
  50914. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50915. * @param sessionMode options for the XR session
  50916. * @param referenceSpaceType frame of reference of the XR session
  50917. * @param renderTarget the output canvas that will be used to enter XR mode
  50918. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50919. * @returns promise that resolves after xr mode has entered
  50920. */
  50921. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50922. /**
  50923. * Exits XR mode and returns the scene to its original state
  50924. * @returns promise that resolves after xr mode has exited
  50925. */
  50926. exitXRAsync(): Promise<void>;
  50927. private _nonXRToXRCamera;
  50928. private _setState;
  50929. }
  50930. }
  50931. declare module BABYLON {
  50932. /**
  50933. * X-Y values for axes in WebXR
  50934. */
  50935. export interface IWebXRMotionControllerAxesValue {
  50936. /**
  50937. * The value of the x axis
  50938. */
  50939. x: number;
  50940. /**
  50941. * The value of the y-axis
  50942. */
  50943. y: number;
  50944. }
  50945. /**
  50946. * changed / previous values for the values of this component
  50947. */
  50948. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50949. /**
  50950. * current (this frame) value
  50951. */
  50952. current: T;
  50953. /**
  50954. * previous (last change) value
  50955. */
  50956. previous: T;
  50957. }
  50958. /**
  50959. * Represents changes in the component between current frame and last values recorded
  50960. */
  50961. export interface IWebXRMotionControllerComponentChanges {
  50962. /**
  50963. * will be populated with previous and current values if axes changed
  50964. */
  50965. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50966. /**
  50967. * will be populated with previous and current values if pressed changed
  50968. */
  50969. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50970. /**
  50971. * will be populated with previous and current values if touched changed
  50972. */
  50973. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50974. /**
  50975. * will be populated with previous and current values if value changed
  50976. */
  50977. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50978. }
  50979. /**
  50980. * This class represents a single component (for example button or thumbstick) of a motion controller
  50981. */
  50982. export class WebXRControllerComponent implements IDisposable {
  50983. /**
  50984. * the id of this component
  50985. */
  50986. id: string;
  50987. /**
  50988. * the type of the component
  50989. */
  50990. type: MotionControllerComponentType;
  50991. private _buttonIndex;
  50992. private _axesIndices;
  50993. private _axes;
  50994. private _changes;
  50995. private _currentValue;
  50996. private _hasChanges;
  50997. private _pressed;
  50998. private _touched;
  50999. /**
  51000. * button component type
  51001. */
  51002. static BUTTON_TYPE: MotionControllerComponentType;
  51003. /**
  51004. * squeeze component type
  51005. */
  51006. static SQUEEZE_TYPE: MotionControllerComponentType;
  51007. /**
  51008. * Thumbstick component type
  51009. */
  51010. static THUMBSTICK_TYPE: MotionControllerComponentType;
  51011. /**
  51012. * Touchpad component type
  51013. */
  51014. static TOUCHPAD_TYPE: MotionControllerComponentType;
  51015. /**
  51016. * trigger component type
  51017. */
  51018. static TRIGGER_TYPE: MotionControllerComponentType;
  51019. /**
  51020. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  51021. * the axes data changes
  51022. */
  51023. onAxisValueChangedObservable: Observable<{
  51024. x: number;
  51025. y: number;
  51026. }>;
  51027. /**
  51028. * Observers registered here will be triggered when the state of a button changes
  51029. * State change is either pressed / touched / value
  51030. */
  51031. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  51032. /**
  51033. * Creates a new component for a motion controller.
  51034. * It is created by the motion controller itself
  51035. *
  51036. * @param id the id of this component
  51037. * @param type the type of the component
  51038. * @param _buttonIndex index in the buttons array of the gamepad
  51039. * @param _axesIndices indices of the values in the axes array of the gamepad
  51040. */
  51041. constructor(
  51042. /**
  51043. * the id of this component
  51044. */
  51045. id: string,
  51046. /**
  51047. * the type of the component
  51048. */
  51049. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  51050. /**
  51051. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  51052. */
  51053. get axes(): IWebXRMotionControllerAxesValue;
  51054. /**
  51055. * Get the changes. Elements will be populated only if they changed with their previous and current value
  51056. */
  51057. get changes(): IWebXRMotionControllerComponentChanges;
  51058. /**
  51059. * Return whether or not the component changed the last frame
  51060. */
  51061. get hasChanges(): boolean;
  51062. /**
  51063. * is the button currently pressed
  51064. */
  51065. get pressed(): boolean;
  51066. /**
  51067. * is the button currently touched
  51068. */
  51069. get touched(): boolean;
  51070. /**
  51071. * Get the current value of this component
  51072. */
  51073. get value(): number;
  51074. /**
  51075. * Dispose this component
  51076. */
  51077. dispose(): void;
  51078. /**
  51079. * Are there axes correlating to this component
  51080. * @return true is axes data is available
  51081. */
  51082. isAxes(): boolean;
  51083. /**
  51084. * Is this component a button (hence - pressable)
  51085. * @returns true if can be pressed
  51086. */
  51087. isButton(): boolean;
  51088. /**
  51089. * update this component using the gamepad object it is in. Called on every frame
  51090. * @param nativeController the native gamepad controller object
  51091. */
  51092. update(nativeController: IMinimalMotionControllerObject): void;
  51093. }
  51094. }
  51095. declare module BABYLON {
  51096. /**
  51097. * Interface used to represent data loading progression
  51098. */
  51099. export interface ISceneLoaderProgressEvent {
  51100. /**
  51101. * Defines if data length to load can be evaluated
  51102. */
  51103. readonly lengthComputable: boolean;
  51104. /**
  51105. * Defines the loaded data length
  51106. */
  51107. readonly loaded: number;
  51108. /**
  51109. * Defines the data length to load
  51110. */
  51111. readonly total: number;
  51112. }
  51113. /**
  51114. * Interface used by SceneLoader plugins to define supported file extensions
  51115. */
  51116. export interface ISceneLoaderPluginExtensions {
  51117. /**
  51118. * Defines the list of supported extensions
  51119. */
  51120. [extension: string]: {
  51121. isBinary: boolean;
  51122. };
  51123. }
  51124. /**
  51125. * Interface used by SceneLoader plugin factory
  51126. */
  51127. export interface ISceneLoaderPluginFactory {
  51128. /**
  51129. * Defines the name of the factory
  51130. */
  51131. name: string;
  51132. /**
  51133. * Function called to create a new plugin
  51134. * @return the new plugin
  51135. */
  51136. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  51137. /**
  51138. * The callback that returns true if the data can be directly loaded.
  51139. * @param data string containing the file data
  51140. * @returns if the data can be loaded directly
  51141. */
  51142. canDirectLoad?(data: string): boolean;
  51143. }
  51144. /**
  51145. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  51146. */
  51147. export interface ISceneLoaderPluginBase {
  51148. /**
  51149. * The friendly name of this plugin.
  51150. */
  51151. name: string;
  51152. /**
  51153. * The file extensions supported by this plugin.
  51154. */
  51155. extensions: string | ISceneLoaderPluginExtensions;
  51156. /**
  51157. * The callback called when loading from a url.
  51158. * @param scene scene loading this url
  51159. * @param url url to load
  51160. * @param onSuccess callback called when the file successfully loads
  51161. * @param onProgress callback called while file is loading (if the server supports this mode)
  51162. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51163. * @param onError callback called when the file fails to load
  51164. * @returns a file request object
  51165. */
  51166. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51167. /**
  51168. * The callback called when loading from a file object.
  51169. * @param scene scene loading this file
  51170. * @param file defines the file to load
  51171. * @param onSuccess defines the callback to call when data is loaded
  51172. * @param onProgress defines the callback to call during loading process
  51173. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51174. * @param onError defines the callback to call when an error occurs
  51175. * @returns a file request object
  51176. */
  51177. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51178. /**
  51179. * The callback that returns true if the data can be directly loaded.
  51180. * @param data string containing the file data
  51181. * @returns if the data can be loaded directly
  51182. */
  51183. canDirectLoad?(data: string): boolean;
  51184. /**
  51185. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51186. * @param scene scene loading this data
  51187. * @param data string containing the data
  51188. * @returns data to pass to the plugin
  51189. */
  51190. directLoad?(scene: Scene, data: string): any;
  51191. /**
  51192. * The callback that allows custom handling of the root url based on the response url.
  51193. * @param rootUrl the original root url
  51194. * @param responseURL the response url if available
  51195. * @returns the new root url
  51196. */
  51197. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51198. }
  51199. /**
  51200. * Interface used to define a SceneLoader plugin
  51201. */
  51202. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51203. /**
  51204. * Import meshes into a scene.
  51205. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51206. * @param scene The scene to import into
  51207. * @param data The data to import
  51208. * @param rootUrl The root url for scene and resources
  51209. * @param meshes The meshes array to import into
  51210. * @param particleSystems The particle systems array to import into
  51211. * @param skeletons The skeletons array to import into
  51212. * @param onError The callback when import fails
  51213. * @returns True if successful or false otherwise
  51214. */
  51215. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51216. /**
  51217. * Load into a scene.
  51218. * @param scene The scene to load into
  51219. * @param data The data to import
  51220. * @param rootUrl The root url for scene and resources
  51221. * @param onError The callback when import fails
  51222. * @returns True if successful or false otherwise
  51223. */
  51224. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51225. /**
  51226. * Load into an asset container.
  51227. * @param scene The scene to load into
  51228. * @param data The data to import
  51229. * @param rootUrl The root url for scene and resources
  51230. * @param onError The callback when import fails
  51231. * @returns The loaded asset container
  51232. */
  51233. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51234. }
  51235. /**
  51236. * Interface used to define an async SceneLoader plugin
  51237. */
  51238. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51239. /**
  51240. * Import meshes into a scene.
  51241. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51242. * @param scene The scene to import into
  51243. * @param data The data to import
  51244. * @param rootUrl The root url for scene and resources
  51245. * @param onProgress The callback when the load progresses
  51246. * @param fileName Defines the name of the file to load
  51247. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  51248. */
  51249. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  51250. meshes: AbstractMesh[];
  51251. particleSystems: IParticleSystem[];
  51252. skeletons: Skeleton[];
  51253. animationGroups: AnimationGroup[];
  51254. }>;
  51255. /**
  51256. * Load into a scene.
  51257. * @param scene The scene to load into
  51258. * @param data The data to import
  51259. * @param rootUrl The root url for scene and resources
  51260. * @param onProgress The callback when the load progresses
  51261. * @param fileName Defines the name of the file to load
  51262. * @returns Nothing
  51263. */
  51264. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51265. /**
  51266. * Load into an asset container.
  51267. * @param scene The scene to load into
  51268. * @param data The data to import
  51269. * @param rootUrl The root url for scene and resources
  51270. * @param onProgress The callback when the load progresses
  51271. * @param fileName Defines the name of the file to load
  51272. * @returns The loaded asset container
  51273. */
  51274. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51275. }
  51276. /**
  51277. * Mode that determines how to handle old animation groups before loading new ones.
  51278. */
  51279. export enum SceneLoaderAnimationGroupLoadingMode {
  51280. /**
  51281. * Reset all old animations to initial state then dispose them.
  51282. */
  51283. Clean = 0,
  51284. /**
  51285. * Stop all old animations.
  51286. */
  51287. Stop = 1,
  51288. /**
  51289. * Restart old animations from first frame.
  51290. */
  51291. Sync = 2,
  51292. /**
  51293. * Old animations remains untouched.
  51294. */
  51295. NoSync = 3
  51296. }
  51297. /**
  51298. * Defines a plugin registered by the SceneLoader
  51299. */
  51300. interface IRegisteredPlugin {
  51301. /**
  51302. * Defines the plugin to use
  51303. */
  51304. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51305. /**
  51306. * Defines if the plugin supports binary data
  51307. */
  51308. isBinary: boolean;
  51309. }
  51310. /**
  51311. * Class used to load scene from various file formats using registered plugins
  51312. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51313. */
  51314. export class SceneLoader {
  51315. /**
  51316. * No logging while loading
  51317. */
  51318. static readonly NO_LOGGING: number;
  51319. /**
  51320. * Minimal logging while loading
  51321. */
  51322. static readonly MINIMAL_LOGGING: number;
  51323. /**
  51324. * Summary logging while loading
  51325. */
  51326. static readonly SUMMARY_LOGGING: number;
  51327. /**
  51328. * Detailled logging while loading
  51329. */
  51330. static readonly DETAILED_LOGGING: number;
  51331. /**
  51332. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51333. */
  51334. static get ForceFullSceneLoadingForIncremental(): boolean;
  51335. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51336. /**
  51337. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51338. */
  51339. static get ShowLoadingScreen(): boolean;
  51340. static set ShowLoadingScreen(value: boolean);
  51341. /**
  51342. * Defines the current logging level (while loading the scene)
  51343. * @ignorenaming
  51344. */
  51345. static get loggingLevel(): number;
  51346. static set loggingLevel(value: number);
  51347. /**
  51348. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51349. */
  51350. static get CleanBoneMatrixWeights(): boolean;
  51351. static set CleanBoneMatrixWeights(value: boolean);
  51352. /**
  51353. * Event raised when a plugin is used to load a scene
  51354. */
  51355. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51356. private static _registeredPlugins;
  51357. private static _showingLoadingScreen;
  51358. /**
  51359. * Gets the default plugin (used to load Babylon files)
  51360. * @returns the .babylon plugin
  51361. */
  51362. static GetDefaultPlugin(): IRegisteredPlugin;
  51363. private static _GetPluginForExtension;
  51364. private static _GetPluginForDirectLoad;
  51365. private static _GetPluginForFilename;
  51366. private static _GetDirectLoad;
  51367. private static _LoadData;
  51368. private static _GetFileInfo;
  51369. /**
  51370. * Gets a plugin that can load the given extension
  51371. * @param extension defines the extension to load
  51372. * @returns a plugin or null if none works
  51373. */
  51374. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51375. /**
  51376. * Gets a boolean indicating that the given extension can be loaded
  51377. * @param extension defines the extension to load
  51378. * @returns true if the extension is supported
  51379. */
  51380. static IsPluginForExtensionAvailable(extension: string): boolean;
  51381. /**
  51382. * Adds a new plugin to the list of registered plugins
  51383. * @param plugin defines the plugin to add
  51384. */
  51385. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51386. /**
  51387. * Import meshes into a scene
  51388. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51389. * @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)
  51390. * @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)
  51391. * @param scene the instance of BABYLON.Scene to append to
  51392. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51393. * @param onProgress a callback with a progress event for each file being loaded
  51394. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51395. * @param pluginExtension the extension used to determine the plugin
  51396. * @returns The loaded plugin
  51397. */
  51398. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51399. /**
  51400. * Import meshes into a scene
  51401. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51402. * @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)
  51403. * @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)
  51404. * @param scene the instance of BABYLON.Scene to append to
  51405. * @param onProgress a callback with a progress event for each file being loaded
  51406. * @param pluginExtension the extension used to determine the plugin
  51407. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51408. */
  51409. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  51410. meshes: AbstractMesh[];
  51411. particleSystems: IParticleSystem[];
  51412. skeletons: Skeleton[];
  51413. animationGroups: AnimationGroup[];
  51414. }>;
  51415. /**
  51416. * Load a scene
  51417. * @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)
  51418. * @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)
  51419. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51420. * @param onSuccess a callback with the scene when import succeeds
  51421. * @param onProgress a callback with a progress event for each file being loaded
  51422. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51423. * @param pluginExtension the extension used to determine the plugin
  51424. * @returns The loaded plugin
  51425. */
  51426. 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>;
  51427. /**
  51428. * Load a scene
  51429. * @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)
  51430. * @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)
  51431. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51432. * @param onProgress a callback with a progress event for each file being loaded
  51433. * @param pluginExtension the extension used to determine the plugin
  51434. * @returns The loaded scene
  51435. */
  51436. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51437. /**
  51438. * Append a scene
  51439. * @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)
  51440. * @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)
  51441. * @param scene is the instance of BABYLON.Scene to append to
  51442. * @param onSuccess a callback with the scene when import succeeds
  51443. * @param onProgress a callback with a progress event for each file being loaded
  51444. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51445. * @param pluginExtension the extension used to determine the plugin
  51446. * @returns The loaded plugin
  51447. */
  51448. 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>;
  51449. /**
  51450. * Append a scene
  51451. * @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)
  51452. * @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)
  51453. * @param scene is the instance of BABYLON.Scene to append to
  51454. * @param onProgress a callback with a progress event for each file being loaded
  51455. * @param pluginExtension the extension used to determine the plugin
  51456. * @returns The given scene
  51457. */
  51458. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51459. /**
  51460. * Load a scene into an asset container
  51461. * @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)
  51462. * @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)
  51463. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51464. * @param onSuccess a callback with the scene when import succeeds
  51465. * @param onProgress a callback with a progress event for each file being loaded
  51466. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51467. * @param pluginExtension the extension used to determine the plugin
  51468. * @returns The loaded plugin
  51469. */
  51470. 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>;
  51471. /**
  51472. * Load a scene into an asset container
  51473. * @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)
  51474. * @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)
  51475. * @param scene is the instance of Scene to append to
  51476. * @param onProgress a callback with a progress event for each file being loaded
  51477. * @param pluginExtension the extension used to determine the plugin
  51478. * @returns The loaded asset container
  51479. */
  51480. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51481. /**
  51482. * Import animations from a file into a scene
  51483. * @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)
  51484. * @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)
  51485. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51486. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51487. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51488. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51489. * @param onSuccess a callback with the scene when import succeeds
  51490. * @param onProgress a callback with a progress event for each file being loaded
  51491. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51492. * @param pluginExtension the extension used to determine the plugin
  51493. */
  51494. 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;
  51495. /**
  51496. * Import animations from a file into a scene
  51497. * @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)
  51498. * @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)
  51499. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51500. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51501. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51502. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51503. * @param onSuccess a callback with the scene when import succeeds
  51504. * @param onProgress a callback with a progress event for each file being loaded
  51505. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51506. * @param pluginExtension the extension used to determine the plugin
  51507. * @returns the updated scene with imported animations
  51508. */
  51509. 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>;
  51510. }
  51511. }
  51512. declare module BABYLON {
  51513. /**
  51514. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51515. */
  51516. export type MotionControllerHandedness = "none" | "left" | "right";
  51517. /**
  51518. * The type of components available in motion controllers.
  51519. * This is not the name of the component.
  51520. */
  51521. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51522. /**
  51523. * The state of a controller component
  51524. */
  51525. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51526. /**
  51527. * The schema of motion controller layout.
  51528. * No object will be initialized using this interface
  51529. * This is used just to define the profile.
  51530. */
  51531. export interface IMotionControllerLayout {
  51532. /**
  51533. * Path to load the assets. Usually relative to the base path
  51534. */
  51535. assetPath: string;
  51536. /**
  51537. * Available components (unsorted)
  51538. */
  51539. components: {
  51540. /**
  51541. * A map of component Ids
  51542. */
  51543. [componentId: string]: {
  51544. /**
  51545. * The type of input the component outputs
  51546. */
  51547. type: MotionControllerComponentType;
  51548. /**
  51549. * The indices of this component in the gamepad object
  51550. */
  51551. gamepadIndices: {
  51552. /**
  51553. * Index of button
  51554. */
  51555. button?: number;
  51556. /**
  51557. * If available, index of x-axis
  51558. */
  51559. xAxis?: number;
  51560. /**
  51561. * If available, index of y-axis
  51562. */
  51563. yAxis?: number;
  51564. };
  51565. /**
  51566. * The mesh's root node name
  51567. */
  51568. rootNodeName: string;
  51569. /**
  51570. * Animation definitions for this model
  51571. */
  51572. visualResponses: {
  51573. [stateKey: string]: {
  51574. /**
  51575. * What property will be animated
  51576. */
  51577. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51578. /**
  51579. * What states influence this visual response
  51580. */
  51581. states: MotionControllerComponentStateType[];
  51582. /**
  51583. * Type of animation - movement or visibility
  51584. */
  51585. valueNodeProperty: "transform" | "visibility";
  51586. /**
  51587. * Base node name to move. Its position will be calculated according to the min and max nodes
  51588. */
  51589. valueNodeName?: string;
  51590. /**
  51591. * Minimum movement node
  51592. */
  51593. minNodeName?: string;
  51594. /**
  51595. * Max movement node
  51596. */
  51597. maxNodeName?: string;
  51598. };
  51599. };
  51600. /**
  51601. * If touch enabled, what is the name of node to display user feedback
  51602. */
  51603. touchPointNodeName?: string;
  51604. };
  51605. };
  51606. /**
  51607. * Is it xr standard mapping or not
  51608. */
  51609. gamepadMapping: "" | "xr-standard";
  51610. /**
  51611. * Base root node of this entire model
  51612. */
  51613. rootNodeName: string;
  51614. /**
  51615. * Defines the main button component id
  51616. */
  51617. selectComponentId: string;
  51618. }
  51619. /**
  51620. * A definition for the layout map in the input profile
  51621. */
  51622. export interface IMotionControllerLayoutMap {
  51623. /**
  51624. * Layouts with handedness type as a key
  51625. */
  51626. [handedness: string]: IMotionControllerLayout;
  51627. }
  51628. /**
  51629. * The XR Input profile schema
  51630. * Profiles can be found here:
  51631. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51632. */
  51633. export interface IMotionControllerProfile {
  51634. /**
  51635. * fallback profiles for this profileId
  51636. */
  51637. fallbackProfileIds: string[];
  51638. /**
  51639. * The layout map, with handedness as key
  51640. */
  51641. layouts: IMotionControllerLayoutMap;
  51642. /**
  51643. * The id of this profile
  51644. * correlates to the profile(s) in the xrInput.profiles array
  51645. */
  51646. profileId: string;
  51647. }
  51648. /**
  51649. * A helper-interface for the 3 meshes needed for controller button animation
  51650. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51651. */
  51652. export interface IMotionControllerButtonMeshMap {
  51653. /**
  51654. * the mesh that defines the pressed value mesh position.
  51655. * This is used to find the max-position of this button
  51656. */
  51657. pressedMesh: AbstractMesh;
  51658. /**
  51659. * the mesh that defines the unpressed value mesh position.
  51660. * This is used to find the min (or initial) position of this button
  51661. */
  51662. unpressedMesh: AbstractMesh;
  51663. /**
  51664. * The mesh that will be changed when value changes
  51665. */
  51666. valueMesh: AbstractMesh;
  51667. }
  51668. /**
  51669. * A helper-interface for the 3 meshes needed for controller axis animation.
  51670. * This will be expanded when touchpad animations are fully supported
  51671. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51672. */
  51673. export interface IMotionControllerMeshMap {
  51674. /**
  51675. * the mesh that defines the maximum value mesh position.
  51676. */
  51677. maxMesh?: AbstractMesh;
  51678. /**
  51679. * the mesh that defines the minimum value mesh position.
  51680. */
  51681. minMesh?: AbstractMesh;
  51682. /**
  51683. * The mesh that will be changed when axis value changes
  51684. */
  51685. valueMesh?: AbstractMesh;
  51686. }
  51687. /**
  51688. * The elements needed for change-detection of the gamepad objects in motion controllers
  51689. */
  51690. export interface IMinimalMotionControllerObject {
  51691. /**
  51692. * Available axes of this controller
  51693. */
  51694. axes: number[];
  51695. /**
  51696. * An array of available buttons
  51697. */
  51698. buttons: Array<{
  51699. /**
  51700. * Value of the button/trigger
  51701. */
  51702. value: number;
  51703. /**
  51704. * If the button/trigger is currently touched
  51705. */
  51706. touched: boolean;
  51707. /**
  51708. * If the button/trigger is currently pressed
  51709. */
  51710. pressed: boolean;
  51711. }>;
  51712. /**
  51713. * EXPERIMENTAL haptic support.
  51714. */
  51715. hapticActuators?: Array<{
  51716. pulse: (value: number, duration: number) => Promise<boolean>;
  51717. }>;
  51718. }
  51719. /**
  51720. * An Abstract Motion controller
  51721. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51722. * Each component has an observable to check for changes in value and state
  51723. */
  51724. export abstract class WebXRAbstractMotionController implements IDisposable {
  51725. protected scene: Scene;
  51726. protected layout: IMotionControllerLayout;
  51727. /**
  51728. * The gamepad object correlating to this controller
  51729. */
  51730. gamepadObject: IMinimalMotionControllerObject;
  51731. /**
  51732. * handedness (left/right/none) of this controller
  51733. */
  51734. handedness: MotionControllerHandedness;
  51735. private _initComponent;
  51736. private _modelReady;
  51737. /**
  51738. * A map of components (WebXRControllerComponent) in this motion controller
  51739. * Components have a ComponentType and can also have both button and axis definitions
  51740. */
  51741. readonly components: {
  51742. [id: string]: WebXRControllerComponent;
  51743. };
  51744. /**
  51745. * Disable the model's animation. Can be set at any time.
  51746. */
  51747. disableAnimation: boolean;
  51748. /**
  51749. * Observers registered here will be triggered when the model of this controller is done loading
  51750. */
  51751. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51752. /**
  51753. * The profile id of this motion controller
  51754. */
  51755. abstract profileId: string;
  51756. /**
  51757. * The root mesh of the model. It is null if the model was not yet initialized
  51758. */
  51759. rootMesh: Nullable<AbstractMesh>;
  51760. /**
  51761. * constructs a new abstract motion controller
  51762. * @param scene the scene to which the model of the controller will be added
  51763. * @param layout The profile layout to load
  51764. * @param gamepadObject The gamepad object correlating to this controller
  51765. * @param handedness handedness (left/right/none) of this controller
  51766. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51767. */
  51768. constructor(scene: Scene, layout: IMotionControllerLayout,
  51769. /**
  51770. * The gamepad object correlating to this controller
  51771. */
  51772. gamepadObject: IMinimalMotionControllerObject,
  51773. /**
  51774. * handedness (left/right/none) of this controller
  51775. */
  51776. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51777. /**
  51778. * Dispose this controller, the model mesh and all its components
  51779. */
  51780. dispose(): void;
  51781. /**
  51782. * Returns all components of specific type
  51783. * @param type the type to search for
  51784. * @return an array of components with this type
  51785. */
  51786. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51787. /**
  51788. * get a component based an its component id as defined in layout.components
  51789. * @param id the id of the component
  51790. * @returns the component correlates to the id or undefined if not found
  51791. */
  51792. getComponent(id: string): WebXRControllerComponent;
  51793. /**
  51794. * Get the list of components available in this motion controller
  51795. * @returns an array of strings correlating to available components
  51796. */
  51797. getComponentIds(): string[];
  51798. /**
  51799. * Get the first component of specific type
  51800. * @param type type of component to find
  51801. * @return a controller component or null if not found
  51802. */
  51803. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51804. /**
  51805. * Get the main (Select) component of this controller as defined in the layout
  51806. * @returns the main component of this controller
  51807. */
  51808. getMainComponent(): WebXRControllerComponent;
  51809. /**
  51810. * Loads the model correlating to this controller
  51811. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51812. * @returns A promise fulfilled with the result of the model loading
  51813. */
  51814. loadModel(): Promise<boolean>;
  51815. /**
  51816. * Update this model using the current XRFrame
  51817. * @param xrFrame the current xr frame to use and update the model
  51818. */
  51819. updateFromXRFrame(xrFrame: XRFrame): void;
  51820. /**
  51821. * Backwards compatibility due to a deeply-integrated typo
  51822. */
  51823. get handness(): XREye;
  51824. /**
  51825. * Pulse (vibrate) this controller
  51826. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51827. * Consecutive calls to this function will cancel the last pulse call
  51828. *
  51829. * @param value the strength of the pulse in 0.0...1.0 range
  51830. * @param duration Duration of the pulse in milliseconds
  51831. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51832. * @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
  51833. */
  51834. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51835. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51836. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51837. /**
  51838. * Moves the axis on the controller mesh based on its current state
  51839. * @param axis the index of the axis
  51840. * @param axisValue the value of the axis which determines the meshes new position
  51841. * @hidden
  51842. */
  51843. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51844. /**
  51845. * Update the model itself with the current frame data
  51846. * @param xrFrame the frame to use for updating the model mesh
  51847. */
  51848. protected updateModel(xrFrame: XRFrame): void;
  51849. /**
  51850. * Get the filename and path for this controller's model
  51851. * @returns a map of filename and path
  51852. */
  51853. protected abstract _getFilenameAndPath(): {
  51854. filename: string;
  51855. path: string;
  51856. };
  51857. /**
  51858. * This function is called before the mesh is loaded. It checks for loading constraints.
  51859. * For example, this function can check if the GLB loader is available
  51860. * If this function returns false, the generic controller will be loaded instead
  51861. * @returns Is the client ready to load the mesh
  51862. */
  51863. protected abstract _getModelLoadingConstraints(): boolean;
  51864. /**
  51865. * This function will be called after the model was successfully loaded and can be used
  51866. * for mesh transformations before it is available for the user
  51867. * @param meshes the loaded meshes
  51868. */
  51869. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51870. /**
  51871. * Set the root mesh for this controller. Important for the WebXR controller class
  51872. * @param meshes the loaded meshes
  51873. */
  51874. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51875. /**
  51876. * A function executed each frame that updates the mesh (if needed)
  51877. * @param xrFrame the current xrFrame
  51878. */
  51879. protected abstract _updateModel(xrFrame: XRFrame): void;
  51880. private _getGenericFilenameAndPath;
  51881. private _getGenericParentMesh;
  51882. }
  51883. }
  51884. declare module BABYLON {
  51885. /**
  51886. * A generic trigger-only motion controller for WebXR
  51887. */
  51888. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51889. /**
  51890. * Static version of the profile id of this controller
  51891. */
  51892. static ProfileId: string;
  51893. profileId: string;
  51894. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51895. protected _getFilenameAndPath(): {
  51896. filename: string;
  51897. path: string;
  51898. };
  51899. protected _getModelLoadingConstraints(): boolean;
  51900. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51901. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51902. protected _updateModel(): void;
  51903. }
  51904. }
  51905. declare module BABYLON {
  51906. /**
  51907. * Class containing static functions to help procedurally build meshes
  51908. */
  51909. export class SphereBuilder {
  51910. /**
  51911. * Creates a sphere mesh
  51912. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51913. * * 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`)
  51914. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51915. * * 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
  51916. * * 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)
  51917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51918. * * 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
  51919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51920. * @param name defines the name of the mesh
  51921. * @param options defines the options used to create the mesh
  51922. * @param scene defines the hosting scene
  51923. * @returns the sphere mesh
  51924. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51925. */
  51926. static CreateSphere(name: string, options: {
  51927. segments?: number;
  51928. diameter?: number;
  51929. diameterX?: number;
  51930. diameterY?: number;
  51931. diameterZ?: number;
  51932. arc?: number;
  51933. slice?: number;
  51934. sideOrientation?: number;
  51935. frontUVs?: Vector4;
  51936. backUVs?: Vector4;
  51937. updatable?: boolean;
  51938. }, scene?: Nullable<Scene>): Mesh;
  51939. }
  51940. }
  51941. declare module BABYLON {
  51942. /**
  51943. * A profiled motion controller has its profile loaded from an online repository.
  51944. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51945. */
  51946. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51947. private _repositoryUrl;
  51948. private _buttonMeshMapping;
  51949. private _touchDots;
  51950. /**
  51951. * The profile ID of this controller. Will be populated when the controller initializes.
  51952. */
  51953. profileId: string;
  51954. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51955. dispose(): void;
  51956. protected _getFilenameAndPath(): {
  51957. filename: string;
  51958. path: string;
  51959. };
  51960. protected _getModelLoadingConstraints(): boolean;
  51961. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51962. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51963. protected _updateModel(_xrFrame: XRFrame): void;
  51964. }
  51965. }
  51966. declare module BABYLON {
  51967. /**
  51968. * A construction function type to create a new controller based on an xrInput object
  51969. */
  51970. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51971. /**
  51972. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51973. *
  51974. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51975. * it should be replaced with auto-loaded controllers.
  51976. *
  51977. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51978. */
  51979. export class WebXRMotionControllerManager {
  51980. private static _AvailableControllers;
  51981. private static _Fallbacks;
  51982. private static _ProfileLoadingPromises;
  51983. private static _ProfilesList;
  51984. /**
  51985. * The base URL of the online controller repository. Can be changed at any time.
  51986. */
  51987. static BaseRepositoryUrl: string;
  51988. /**
  51989. * Which repository gets priority - local or online
  51990. */
  51991. static PrioritizeOnlineRepository: boolean;
  51992. /**
  51993. * Use the online repository, or use only locally-defined controllers
  51994. */
  51995. static UseOnlineRepository: boolean;
  51996. /**
  51997. * Clear the cache used for profile loading and reload when requested again
  51998. */
  51999. static ClearProfilesCache(): void;
  52000. /**
  52001. * Register the default fallbacks.
  52002. * This function is called automatically when this file is imported.
  52003. */
  52004. static DefaultFallbacks(): void;
  52005. /**
  52006. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  52007. * @param profileId the profile to which a fallback needs to be found
  52008. * @return an array with corresponding fallback profiles
  52009. */
  52010. static FindFallbackWithProfileId(profileId: string): string[];
  52011. /**
  52012. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  52013. * The order of search:
  52014. *
  52015. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  52016. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  52017. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  52018. * 4) return the generic trigger controller if none were found
  52019. *
  52020. * @param xrInput the xrInput to which a new controller is initialized
  52021. * @param scene the scene to which the model will be added
  52022. * @param forceProfile force a certain profile for this controller
  52023. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  52024. */
  52025. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  52026. /**
  52027. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  52028. *
  52029. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  52030. *
  52031. * @param type the profile type to register
  52032. * @param constructFunction the function to be called when loading this profile
  52033. */
  52034. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  52035. /**
  52036. * Register a fallback to a specific profile.
  52037. * @param profileId the profileId that will receive the fallbacks
  52038. * @param fallbacks A list of fallback profiles
  52039. */
  52040. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  52041. /**
  52042. * Will update the list of profiles available in the repository
  52043. * @return a promise that resolves to a map of profiles available online
  52044. */
  52045. static UpdateProfilesList(): Promise<{
  52046. [profile: string]: string;
  52047. }>;
  52048. private static _LoadProfileFromRepository;
  52049. private static _LoadProfilesFromAvailableControllers;
  52050. }
  52051. }
  52052. declare module BABYLON {
  52053. /**
  52054. * Configuration options for the WebXR controller creation
  52055. */
  52056. export interface IWebXRControllerOptions {
  52057. /**
  52058. * Should the controller mesh be animated when a user interacts with it
  52059. * The pressed buttons / thumbstick and touchpad animations will be disabled
  52060. */
  52061. disableMotionControllerAnimation?: boolean;
  52062. /**
  52063. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  52064. */
  52065. doNotLoadControllerMesh?: boolean;
  52066. /**
  52067. * Force a specific controller type for this controller.
  52068. * This can be used when creating your own profile or when testing different controllers
  52069. */
  52070. forceControllerProfile?: string;
  52071. /**
  52072. * Defines a rendering group ID for meshes that will be loaded.
  52073. * This is for the default controllers only.
  52074. */
  52075. renderingGroupId?: number;
  52076. }
  52077. /**
  52078. * Represents an XR controller
  52079. */
  52080. export class WebXRInputSource {
  52081. private _scene;
  52082. /** The underlying input source for the controller */
  52083. inputSource: XRInputSource;
  52084. private _options;
  52085. private _tmpVector;
  52086. private _uniqueId;
  52087. private _disposed;
  52088. /**
  52089. * 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
  52090. */
  52091. grip?: AbstractMesh;
  52092. /**
  52093. * If available, this is the gamepad object related to this controller.
  52094. * Using this object it is possible to get click events and trackpad changes of the
  52095. * webxr controller that is currently being used.
  52096. */
  52097. motionController?: WebXRAbstractMotionController;
  52098. /**
  52099. * Event that fires when the controller is removed/disposed.
  52100. * The object provided as event data is this controller, after associated assets were disposed.
  52101. * uniqueId is still available.
  52102. */
  52103. onDisposeObservable: Observable<WebXRInputSource>;
  52104. /**
  52105. * Will be triggered when the mesh associated with the motion controller is done loading.
  52106. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  52107. * A shortened version of controller -> motion controller -> on mesh loaded.
  52108. */
  52109. onMeshLoadedObservable: Observable<AbstractMesh>;
  52110. /**
  52111. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  52112. */
  52113. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  52114. /**
  52115. * Pointer which can be used to select objects or attach a visible laser to
  52116. */
  52117. pointer: AbstractMesh;
  52118. /**
  52119. * Creates the input source object
  52120. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  52121. * @param _scene the scene which the controller should be associated to
  52122. * @param inputSource the underlying input source for the controller
  52123. * @param _options options for this controller creation
  52124. */
  52125. constructor(_scene: Scene,
  52126. /** The underlying input source for the controller */
  52127. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  52128. /**
  52129. * Get this controllers unique id
  52130. */
  52131. get uniqueId(): string;
  52132. /**
  52133. * Disposes of the object
  52134. */
  52135. dispose(): void;
  52136. /**
  52137. * Gets a world space ray coming from the pointer or grip
  52138. * @param result the resulting ray
  52139. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  52140. */
  52141. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  52142. /**
  52143. * Updates the controller pose based on the given XRFrame
  52144. * @param xrFrame xr frame to update the pose with
  52145. * @param referenceSpace reference space to use
  52146. */
  52147. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  52148. }
  52149. }
  52150. declare module BABYLON {
  52151. /**
  52152. * The schema for initialization options of the XR Input class
  52153. */
  52154. export interface IWebXRInputOptions {
  52155. /**
  52156. * If set to true no model will be automatically loaded
  52157. */
  52158. doNotLoadControllerMeshes?: boolean;
  52159. /**
  52160. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52161. * If not found, the xr input profile data will be used.
  52162. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52163. */
  52164. forceInputProfile?: string;
  52165. /**
  52166. * Do not send a request to the controller repository to load the profile.
  52167. *
  52168. * Instead, use the controllers available in babylon itself.
  52169. */
  52170. disableOnlineControllerRepository?: boolean;
  52171. /**
  52172. * A custom URL for the controllers repository
  52173. */
  52174. customControllersRepositoryURL?: string;
  52175. /**
  52176. * Should the controller model's components not move according to the user input
  52177. */
  52178. disableControllerAnimation?: boolean;
  52179. /**
  52180. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52181. */
  52182. controllerOptions?: IWebXRControllerOptions;
  52183. }
  52184. /**
  52185. * XR input used to track XR inputs such as controllers/rays
  52186. */
  52187. export class WebXRInput implements IDisposable {
  52188. /**
  52189. * the xr session manager for this session
  52190. */
  52191. xrSessionManager: WebXRSessionManager;
  52192. /**
  52193. * the WebXR camera for this session. Mainly used for teleportation
  52194. */
  52195. xrCamera: WebXRCamera;
  52196. private readonly options;
  52197. /**
  52198. * XR controllers being tracked
  52199. */
  52200. controllers: Array<WebXRInputSource>;
  52201. private _frameObserver;
  52202. private _sessionEndedObserver;
  52203. private _sessionInitObserver;
  52204. /**
  52205. * Event when a controller has been connected/added
  52206. */
  52207. onControllerAddedObservable: Observable<WebXRInputSource>;
  52208. /**
  52209. * Event when a controller has been removed/disconnected
  52210. */
  52211. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52212. /**
  52213. * Initializes the WebXRInput
  52214. * @param xrSessionManager the xr session manager for this session
  52215. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52216. * @param options = initialization options for this xr input
  52217. */
  52218. constructor(
  52219. /**
  52220. * the xr session manager for this session
  52221. */
  52222. xrSessionManager: WebXRSessionManager,
  52223. /**
  52224. * the WebXR camera for this session. Mainly used for teleportation
  52225. */
  52226. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52227. private _onInputSourcesChange;
  52228. private _addAndRemoveControllers;
  52229. /**
  52230. * Disposes of the object
  52231. */
  52232. dispose(): void;
  52233. }
  52234. }
  52235. declare module BABYLON {
  52236. /**
  52237. * This is the base class for all WebXR features.
  52238. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52239. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52240. */
  52241. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52242. protected _xrSessionManager: WebXRSessionManager;
  52243. private _attached;
  52244. private _removeOnDetach;
  52245. /**
  52246. * Is this feature disposed?
  52247. */
  52248. isDisposed: boolean;
  52249. /**
  52250. * Should auto-attach be disabled?
  52251. */
  52252. disableAutoAttach: boolean;
  52253. /**
  52254. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52255. */
  52256. xrNativeFeatureName: string;
  52257. /**
  52258. * Construct a new (abstract) WebXR feature
  52259. * @param _xrSessionManager the xr session manager for this feature
  52260. */
  52261. constructor(_xrSessionManager: WebXRSessionManager);
  52262. /**
  52263. * Is this feature attached
  52264. */
  52265. get attached(): boolean;
  52266. /**
  52267. * attach this feature
  52268. *
  52269. * @param force should attachment be forced (even when already attached)
  52270. * @returns true if successful, false is failed or already attached
  52271. */
  52272. attach(force?: boolean): boolean;
  52273. /**
  52274. * detach this feature.
  52275. *
  52276. * @returns true if successful, false if failed or already detached
  52277. */
  52278. detach(): boolean;
  52279. /**
  52280. * Dispose this feature and all of the resources attached
  52281. */
  52282. dispose(): void;
  52283. /**
  52284. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52285. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52286. *
  52287. * @returns whether or not the feature is compatible in this environment
  52288. */
  52289. isCompatible(): boolean;
  52290. /**
  52291. * This is used to register callbacks that will automatically be removed when detach is called.
  52292. * @param observable the observable to which the observer will be attached
  52293. * @param callback the callback to register
  52294. */
  52295. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52296. /**
  52297. * Code in this function will be executed on each xrFrame received from the browser.
  52298. * This function will not execute after the feature is detached.
  52299. * @param _xrFrame the current frame
  52300. */
  52301. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52302. }
  52303. }
  52304. declare module BABYLON {
  52305. /**
  52306. * Renders a layer on top of an existing scene
  52307. */
  52308. export class UtilityLayerRenderer implements IDisposable {
  52309. /** the original scene that will be rendered on top of */
  52310. originalScene: Scene;
  52311. private _pointerCaptures;
  52312. private _lastPointerEvents;
  52313. private static _DefaultUtilityLayer;
  52314. private static _DefaultKeepDepthUtilityLayer;
  52315. private _sharedGizmoLight;
  52316. private _renderCamera;
  52317. /**
  52318. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52319. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52320. * @returns the camera that is used when rendering the utility layer
  52321. */
  52322. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52323. /**
  52324. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52325. * @param cam the camera that should be used when rendering the utility layer
  52326. */
  52327. setRenderCamera(cam: Nullable<Camera>): void;
  52328. /**
  52329. * @hidden
  52330. * Light which used by gizmos to get light shading
  52331. */
  52332. _getSharedGizmoLight(): HemisphericLight;
  52333. /**
  52334. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52335. */
  52336. pickUtilitySceneFirst: boolean;
  52337. /**
  52338. * 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)
  52339. */
  52340. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52341. /**
  52342. * 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)
  52343. */
  52344. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52345. /**
  52346. * The scene that is rendered on top of the original scene
  52347. */
  52348. utilityLayerScene: Scene;
  52349. /**
  52350. * If the utility layer should automatically be rendered on top of existing scene
  52351. */
  52352. shouldRender: boolean;
  52353. /**
  52354. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52355. */
  52356. onlyCheckPointerDownEvents: boolean;
  52357. /**
  52358. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52359. */
  52360. processAllEvents: boolean;
  52361. /**
  52362. * Observable raised when the pointer move from the utility layer scene to the main scene
  52363. */
  52364. onPointerOutObservable: Observable<number>;
  52365. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52366. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52367. private _afterRenderObserver;
  52368. private _sceneDisposeObserver;
  52369. private _originalPointerObserver;
  52370. /**
  52371. * Instantiates a UtilityLayerRenderer
  52372. * @param originalScene the original scene that will be rendered on top of
  52373. * @param handleEvents boolean indicating if the utility layer should handle events
  52374. */
  52375. constructor(
  52376. /** the original scene that will be rendered on top of */
  52377. originalScene: Scene, handleEvents?: boolean);
  52378. private _notifyObservers;
  52379. /**
  52380. * Renders the utility layers scene on top of the original scene
  52381. */
  52382. render(): void;
  52383. /**
  52384. * Disposes of the renderer
  52385. */
  52386. dispose(): void;
  52387. private _updateCamera;
  52388. }
  52389. }
  52390. declare module BABYLON {
  52391. /**
  52392. * Options interface for the pointer selection module
  52393. */
  52394. export interface IWebXRControllerPointerSelectionOptions {
  52395. /**
  52396. * if provided, this scene will be used to render meshes.
  52397. */
  52398. customUtilityLayerScene?: Scene;
  52399. /**
  52400. * 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)
  52401. * If not disabled, the last picked point will be used to execute a pointer up event
  52402. * If disabled, pointer up event will be triggered right after the pointer down event.
  52403. * Used in screen and gaze target ray mode only
  52404. */
  52405. disablePointerUpOnTouchOut: boolean;
  52406. /**
  52407. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52408. */
  52409. forceGazeMode: boolean;
  52410. /**
  52411. * 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
  52412. * to start a new countdown to the pointer down event.
  52413. * Defaults to 1.
  52414. */
  52415. gazeModePointerMovedFactor?: number;
  52416. /**
  52417. * Different button type to use instead of the main component
  52418. */
  52419. overrideButtonId?: string;
  52420. /**
  52421. * use this rendering group id for the meshes (optional)
  52422. */
  52423. renderingGroupId?: number;
  52424. /**
  52425. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52426. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52427. * 3000 means 3 seconds between pointing at something and selecting it
  52428. */
  52429. timeToSelect?: number;
  52430. /**
  52431. * Should meshes created here be added to a utility layer or the main scene
  52432. */
  52433. useUtilityLayer?: boolean;
  52434. /**
  52435. * Optional WebXR camera to be used for gaze selection
  52436. */
  52437. gazeCamera?: WebXRCamera;
  52438. /**
  52439. * the xr input to use with this pointer selection
  52440. */
  52441. xrInput: WebXRInput;
  52442. /**
  52443. * Should the scene pointerX and pointerY update be disabled
  52444. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52445. * Disable in VR, if not needed.
  52446. * The first rig camera (left eye) will be used to calculate the projection
  52447. */
  52448. disableScenePointerVectorUpdate: boolean;
  52449. /**
  52450. * Enable pointer selection on all controllers instead of switching between them
  52451. */
  52452. enablePointerSelectionOnAllControllers?: boolean;
  52453. /**
  52454. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52455. * If switch is enabled, it will still allow the user to switch between the different controllers
  52456. */
  52457. preferredHandedness?: XRHandedness;
  52458. /**
  52459. * Disable switching the pointer selection from one controller to the other.
  52460. * 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
  52461. */
  52462. disableSwitchOnClick?: boolean;
  52463. /**
  52464. * The maximum distance of the pointer selection feature. Defaults to 100.
  52465. */
  52466. maxPointerDistance?: number;
  52467. }
  52468. /**
  52469. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52470. */
  52471. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52472. private readonly _options;
  52473. private static _idCounter;
  52474. private _attachController;
  52475. private _controllers;
  52476. private _scene;
  52477. private _tmpVectorForPickCompare;
  52478. private _attachedController;
  52479. /**
  52480. * The module's name
  52481. */
  52482. static readonly Name: string;
  52483. /**
  52484. * The (Babylon) version of this module.
  52485. * This is an integer representing the implementation version.
  52486. * This number does not correspond to the WebXR specs version
  52487. */
  52488. static readonly Version: number;
  52489. /**
  52490. * Disable lighting on the laser pointer (so it will always be visible)
  52491. */
  52492. disablePointerLighting: boolean;
  52493. /**
  52494. * Disable lighting on the selection mesh (so it will always be visible)
  52495. */
  52496. disableSelectionMeshLighting: boolean;
  52497. /**
  52498. * Should the laser pointer be displayed
  52499. */
  52500. displayLaserPointer: boolean;
  52501. /**
  52502. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52503. */
  52504. displaySelectionMesh: boolean;
  52505. /**
  52506. * This color will be set to the laser pointer when selection is triggered
  52507. */
  52508. laserPointerPickedColor: Color3;
  52509. /**
  52510. * Default color of the laser pointer
  52511. */
  52512. laserPointerDefaultColor: Color3;
  52513. /**
  52514. * default color of the selection ring
  52515. */
  52516. selectionMeshDefaultColor: Color3;
  52517. /**
  52518. * This color will be applied to the selection ring when selection is triggered
  52519. */
  52520. selectionMeshPickedColor: Color3;
  52521. /**
  52522. * Optional filter to be used for ray selection. This predicate shares behavior with
  52523. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52524. */
  52525. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52526. /**
  52527. * constructs a new background remover module
  52528. * @param _xrSessionManager the session manager for this module
  52529. * @param _options read-only options to be used in this module
  52530. */
  52531. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52532. /**
  52533. * attach this feature
  52534. * Will usually be called by the features manager
  52535. *
  52536. * @returns true if successful.
  52537. */
  52538. attach(): boolean;
  52539. /**
  52540. * detach this feature.
  52541. * Will usually be called by the features manager
  52542. *
  52543. * @returns true if successful.
  52544. */
  52545. detach(): boolean;
  52546. /**
  52547. * Will get the mesh under a specific pointer.
  52548. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52549. * @param controllerId the controllerId to check
  52550. * @returns The mesh under pointer or null if no mesh is under the pointer
  52551. */
  52552. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52553. /**
  52554. * Get the xr controller that correlates to the pointer id in the pointer event
  52555. *
  52556. * @param id the pointer id to search for
  52557. * @returns the controller that correlates to this id or null if not found
  52558. */
  52559. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52560. private _identityMatrix;
  52561. private _screenCoordinatesRef;
  52562. private _viewportRef;
  52563. protected _onXRFrame(_xrFrame: XRFrame): void;
  52564. private _attachGazeMode;
  52565. private _attachScreenRayMode;
  52566. private _attachTrackedPointerRayMode;
  52567. private _convertNormalToDirectionOfRay;
  52568. private _detachController;
  52569. private _generateNewMeshPair;
  52570. private _pickingMoved;
  52571. private _updatePointerDistance;
  52572. /** @hidden */
  52573. get lasterPointerDefaultColor(): Color3;
  52574. }
  52575. }
  52576. declare module BABYLON {
  52577. /**
  52578. * Button which can be used to enter a different mode of XR
  52579. */
  52580. export class WebXREnterExitUIButton {
  52581. /** button element */
  52582. element: HTMLElement;
  52583. /** XR initialization options for the button */
  52584. sessionMode: XRSessionMode;
  52585. /** Reference space type */
  52586. referenceSpaceType: XRReferenceSpaceType;
  52587. /**
  52588. * Creates a WebXREnterExitUIButton
  52589. * @param element button element
  52590. * @param sessionMode XR initialization session mode
  52591. * @param referenceSpaceType the type of reference space to be used
  52592. */
  52593. constructor(
  52594. /** button element */
  52595. element: HTMLElement,
  52596. /** XR initialization options for the button */
  52597. sessionMode: XRSessionMode,
  52598. /** Reference space type */
  52599. referenceSpaceType: XRReferenceSpaceType);
  52600. /**
  52601. * Extendable function which can be used to update the button's visuals when the state changes
  52602. * @param activeButton the current active button in the UI
  52603. */
  52604. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52605. }
  52606. /**
  52607. * Options to create the webXR UI
  52608. */
  52609. export class WebXREnterExitUIOptions {
  52610. /**
  52611. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52612. */
  52613. customButtons?: Array<WebXREnterExitUIButton>;
  52614. /**
  52615. * A reference space type to use when creating the default button.
  52616. * Default is local-floor
  52617. */
  52618. referenceSpaceType?: XRReferenceSpaceType;
  52619. /**
  52620. * Context to enter xr with
  52621. */
  52622. renderTarget?: Nullable<WebXRRenderTarget>;
  52623. /**
  52624. * A session mode to use when creating the default button.
  52625. * Default is immersive-vr
  52626. */
  52627. sessionMode?: XRSessionMode;
  52628. /**
  52629. * A list of optional features to init the session with
  52630. */
  52631. optionalFeatures?: string[];
  52632. /**
  52633. * A list of optional features to init the session with
  52634. */
  52635. requiredFeatures?: string[];
  52636. /**
  52637. * If defined, this function will be executed if the UI encounters an error when entering XR
  52638. */
  52639. onError?: (error: any) => void;
  52640. }
  52641. /**
  52642. * UI to allow the user to enter/exit XR mode
  52643. */
  52644. export class WebXREnterExitUI implements IDisposable {
  52645. private scene;
  52646. /** version of the options passed to this UI */
  52647. options: WebXREnterExitUIOptions;
  52648. private _activeButton;
  52649. private _buttons;
  52650. /**
  52651. * The HTML Div Element to which buttons are added.
  52652. */
  52653. readonly overlay: HTMLDivElement;
  52654. /**
  52655. * Fired every time the active button is changed.
  52656. *
  52657. * When xr is entered via a button that launches xr that button will be the callback parameter
  52658. *
  52659. * When exiting xr the callback parameter will be null)
  52660. */
  52661. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52662. /**
  52663. *
  52664. * @param scene babylon scene object to use
  52665. * @param options (read-only) version of the options passed to this UI
  52666. */
  52667. private constructor();
  52668. /**
  52669. * Creates UI to allow the user to enter/exit XR mode
  52670. * @param scene the scene to add the ui to
  52671. * @param helper the xr experience helper to enter/exit xr with
  52672. * @param options options to configure the UI
  52673. * @returns the created ui
  52674. */
  52675. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52676. /**
  52677. * Disposes of the XR UI component
  52678. */
  52679. dispose(): void;
  52680. private _updateButtons;
  52681. }
  52682. }
  52683. declare module BABYLON {
  52684. /**
  52685. * Class containing static functions to help procedurally build meshes
  52686. */
  52687. export class LinesBuilder {
  52688. /**
  52689. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52690. * * 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
  52691. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52692. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52693. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52694. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52695. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52696. * * 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
  52697. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52699. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52700. * @param name defines the name of the new line system
  52701. * @param options defines the options used to create the line system
  52702. * @param scene defines the hosting scene
  52703. * @returns a new line system mesh
  52704. */
  52705. static CreateLineSystem(name: string, options: {
  52706. lines: Vector3[][];
  52707. updatable?: boolean;
  52708. instance?: Nullable<LinesMesh>;
  52709. colors?: Nullable<Color4[][]>;
  52710. useVertexAlpha?: boolean;
  52711. }, scene: Nullable<Scene>): LinesMesh;
  52712. /**
  52713. * Creates a line mesh
  52714. * 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
  52715. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52716. * * The parameter `points` is an array successive Vector3
  52717. * * 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
  52718. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52719. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52720. * * When updating an instance, remember that only point positions can change, not the number of points
  52721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52722. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52723. * @param name defines the name of the new line system
  52724. * @param options defines the options used to create the line system
  52725. * @param scene defines the hosting scene
  52726. * @returns a new line mesh
  52727. */
  52728. static CreateLines(name: string, options: {
  52729. points: Vector3[];
  52730. updatable?: boolean;
  52731. instance?: Nullable<LinesMesh>;
  52732. colors?: Color4[];
  52733. useVertexAlpha?: boolean;
  52734. }, scene?: Nullable<Scene>): LinesMesh;
  52735. /**
  52736. * Creates a dashed line mesh
  52737. * * 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
  52738. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52739. * * The parameter `points` is an array successive Vector3
  52740. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52741. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52742. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52743. * * 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
  52744. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52745. * * When updating an instance, remember that only point positions can change, not the number of points
  52746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52747. * @param name defines the name of the mesh
  52748. * @param options defines the options used to create the mesh
  52749. * @param scene defines the hosting scene
  52750. * @returns the dashed line mesh
  52751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52752. */
  52753. static CreateDashedLines(name: string, options: {
  52754. points: Vector3[];
  52755. dashSize?: number;
  52756. gapSize?: number;
  52757. dashNb?: number;
  52758. updatable?: boolean;
  52759. instance?: LinesMesh;
  52760. useVertexAlpha?: boolean;
  52761. }, scene?: Nullable<Scene>): LinesMesh;
  52762. }
  52763. }
  52764. declare module BABYLON {
  52765. /**
  52766. * Construction options for a timer
  52767. */
  52768. export interface ITimerOptions<T> {
  52769. /**
  52770. * Time-to-end
  52771. */
  52772. timeout: number;
  52773. /**
  52774. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52775. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52776. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52777. */
  52778. contextObservable: Observable<T>;
  52779. /**
  52780. * Optional parameters when adding an observer to the observable
  52781. */
  52782. observableParameters?: {
  52783. mask?: number;
  52784. insertFirst?: boolean;
  52785. scope?: any;
  52786. };
  52787. /**
  52788. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52789. */
  52790. breakCondition?: (data?: ITimerData<T>) => boolean;
  52791. /**
  52792. * Will be triggered when the time condition has met
  52793. */
  52794. onEnded?: (data: ITimerData<any>) => void;
  52795. /**
  52796. * Will be triggered when the break condition has met (prematurely ended)
  52797. */
  52798. onAborted?: (data: ITimerData<any>) => void;
  52799. /**
  52800. * Optional function to execute on each tick (or count)
  52801. */
  52802. onTick?: (data: ITimerData<any>) => void;
  52803. }
  52804. /**
  52805. * An interface defining the data sent by the timer
  52806. */
  52807. export interface ITimerData<T> {
  52808. /**
  52809. * When did it start
  52810. */
  52811. startTime: number;
  52812. /**
  52813. * Time now
  52814. */
  52815. currentTime: number;
  52816. /**
  52817. * Time passed since started
  52818. */
  52819. deltaTime: number;
  52820. /**
  52821. * How much is completed, in [0.0...1.0].
  52822. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52823. */
  52824. completeRate: number;
  52825. /**
  52826. * What the registered observable sent in the last count
  52827. */
  52828. payload: T;
  52829. }
  52830. /**
  52831. * The current state of the timer
  52832. */
  52833. export enum TimerState {
  52834. /**
  52835. * Timer initialized, not yet started
  52836. */
  52837. INIT = 0,
  52838. /**
  52839. * Timer started and counting
  52840. */
  52841. STARTED = 1,
  52842. /**
  52843. * Timer ended (whether aborted or time reached)
  52844. */
  52845. ENDED = 2
  52846. }
  52847. /**
  52848. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52849. *
  52850. * @param options options with which to initialize this timer
  52851. */
  52852. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52853. /**
  52854. * An advanced implementation of a timer class
  52855. */
  52856. export class AdvancedTimer<T = any> implements IDisposable {
  52857. /**
  52858. * Will notify each time the timer calculates the remaining time
  52859. */
  52860. onEachCountObservable: Observable<ITimerData<T>>;
  52861. /**
  52862. * Will trigger when the timer was aborted due to the break condition
  52863. */
  52864. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52865. /**
  52866. * Will trigger when the timer ended successfully
  52867. */
  52868. onTimerEndedObservable: Observable<ITimerData<T>>;
  52869. /**
  52870. * Will trigger when the timer state has changed
  52871. */
  52872. onStateChangedObservable: Observable<TimerState>;
  52873. private _observer;
  52874. private _contextObservable;
  52875. private _observableParameters;
  52876. private _startTime;
  52877. private _timer;
  52878. private _state;
  52879. private _breakCondition;
  52880. private _timeToEnd;
  52881. private _breakOnNextTick;
  52882. /**
  52883. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52884. * @param options construction options for this advanced timer
  52885. */
  52886. constructor(options: ITimerOptions<T>);
  52887. /**
  52888. * set a breaking condition for this timer. Default is to never break during count
  52889. * @param predicate the new break condition. Returns true to break, false otherwise
  52890. */
  52891. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52892. /**
  52893. * Reset ALL associated observables in this advanced timer
  52894. */
  52895. clearObservables(): void;
  52896. /**
  52897. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52898. *
  52899. * @param timeToEnd how much time to measure until timer ended
  52900. */
  52901. start(timeToEnd?: number): void;
  52902. /**
  52903. * Will force a stop on the next tick.
  52904. */
  52905. stop(): void;
  52906. /**
  52907. * Dispose this timer, clearing all resources
  52908. */
  52909. dispose(): void;
  52910. private _setState;
  52911. private _tick;
  52912. private _stop;
  52913. }
  52914. }
  52915. declare module BABYLON {
  52916. /**
  52917. * The options container for the teleportation module
  52918. */
  52919. export interface IWebXRTeleportationOptions {
  52920. /**
  52921. * if provided, this scene will be used to render meshes.
  52922. */
  52923. customUtilityLayerScene?: Scene;
  52924. /**
  52925. * Values to configure the default target mesh
  52926. */
  52927. defaultTargetMeshOptions?: {
  52928. /**
  52929. * Fill color of the teleportation area
  52930. */
  52931. teleportationFillColor?: string;
  52932. /**
  52933. * Border color for the teleportation area
  52934. */
  52935. teleportationBorderColor?: string;
  52936. /**
  52937. * Disable the mesh's animation sequence
  52938. */
  52939. disableAnimation?: boolean;
  52940. /**
  52941. * Disable lighting on the material or the ring and arrow
  52942. */
  52943. disableLighting?: boolean;
  52944. /**
  52945. * Override the default material of the torus and arrow
  52946. */
  52947. torusArrowMaterial?: Material;
  52948. };
  52949. /**
  52950. * A list of meshes to use as floor meshes.
  52951. * Meshes can be added and removed after initializing the feature using the
  52952. * addFloorMesh and removeFloorMesh functions
  52953. * If empty, rotation will still work
  52954. */
  52955. floorMeshes?: AbstractMesh[];
  52956. /**
  52957. * use this rendering group id for the meshes (optional)
  52958. */
  52959. renderingGroupId?: number;
  52960. /**
  52961. * Should teleportation move only to snap points
  52962. */
  52963. snapPointsOnly?: boolean;
  52964. /**
  52965. * An array of points to which the teleportation will snap to.
  52966. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52967. */
  52968. snapPositions?: Vector3[];
  52969. /**
  52970. * How close should the teleportation ray be in order to snap to position.
  52971. * Default to 0.8 units (meters)
  52972. */
  52973. snapToPositionRadius?: number;
  52974. /**
  52975. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52976. * If you want to support rotation, make sure your mesh has a direction indicator.
  52977. *
  52978. * When left untouched, the default mesh will be initialized.
  52979. */
  52980. teleportationTargetMesh?: AbstractMesh;
  52981. /**
  52982. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52983. */
  52984. timeToTeleport?: number;
  52985. /**
  52986. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52987. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52988. */
  52989. useMainComponentOnly?: boolean;
  52990. /**
  52991. * Should meshes created here be added to a utility layer or the main scene
  52992. */
  52993. useUtilityLayer?: boolean;
  52994. /**
  52995. * Babylon XR Input class for controller
  52996. */
  52997. xrInput: WebXRInput;
  52998. /**
  52999. * Meshes that the teleportation ray cannot go through
  53000. */
  53001. pickBlockerMeshes?: AbstractMesh[];
  53002. }
  53003. /**
  53004. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  53005. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  53006. * the input of the attached controllers.
  53007. */
  53008. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  53009. private _options;
  53010. private _controllers;
  53011. private _currentTeleportationControllerId;
  53012. private _floorMeshes;
  53013. private _quadraticBezierCurve;
  53014. private _selectionFeature;
  53015. private _snapToPositions;
  53016. private _snappedToPoint;
  53017. private _teleportationRingMaterial?;
  53018. private _tmpRay;
  53019. private _tmpVector;
  53020. private _tmpQuaternion;
  53021. /**
  53022. * The module's name
  53023. */
  53024. static readonly Name: string;
  53025. /**
  53026. * The (Babylon) version of this module.
  53027. * This is an integer representing the implementation version.
  53028. * This number does not correspond to the webxr specs version
  53029. */
  53030. static readonly Version: number;
  53031. /**
  53032. * Is movement backwards enabled
  53033. */
  53034. backwardsMovementEnabled: boolean;
  53035. /**
  53036. * Distance to travel when moving backwards
  53037. */
  53038. backwardsTeleportationDistance: number;
  53039. /**
  53040. * The distance from the user to the inspection point in the direction of the controller
  53041. * A higher number will allow the user to move further
  53042. * defaults to 5 (meters, in xr units)
  53043. */
  53044. parabolicCheckRadius: number;
  53045. /**
  53046. * Should the module support parabolic ray on top of direct ray
  53047. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  53048. * Very helpful when moving between floors / different heights
  53049. */
  53050. parabolicRayEnabled: boolean;
  53051. /**
  53052. * How much rotation should be applied when rotating right and left
  53053. */
  53054. rotationAngle: number;
  53055. /**
  53056. * Is rotation enabled when moving forward?
  53057. * Disabling this feature will prevent the user from deciding the direction when teleporting
  53058. */
  53059. rotationEnabled: boolean;
  53060. /**
  53061. * constructs a new anchor system
  53062. * @param _xrSessionManager an instance of WebXRSessionManager
  53063. * @param _options configuration object for this feature
  53064. */
  53065. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  53066. /**
  53067. * Get the snapPointsOnly flag
  53068. */
  53069. get snapPointsOnly(): boolean;
  53070. /**
  53071. * Sets the snapPointsOnly flag
  53072. * @param snapToPoints should teleportation be exclusively to snap points
  53073. */
  53074. set snapPointsOnly(snapToPoints: boolean);
  53075. /**
  53076. * Add a new mesh to the floor meshes array
  53077. * @param mesh the mesh to use as floor mesh
  53078. */
  53079. addFloorMesh(mesh: AbstractMesh): void;
  53080. /**
  53081. * Add a new snap-to point to fix teleportation to this position
  53082. * @param newSnapPoint The new Snap-To point
  53083. */
  53084. addSnapPoint(newSnapPoint: Vector3): void;
  53085. attach(): boolean;
  53086. detach(): boolean;
  53087. dispose(): void;
  53088. /**
  53089. * Remove a mesh from the floor meshes array
  53090. * @param mesh the mesh to remove
  53091. */
  53092. removeFloorMesh(mesh: AbstractMesh): void;
  53093. /**
  53094. * Remove a mesh from the floor meshes array using its name
  53095. * @param name the mesh name to remove
  53096. */
  53097. removeFloorMeshByName(name: string): void;
  53098. /**
  53099. * 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
  53100. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  53101. * @returns was the point found and removed or not
  53102. */
  53103. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  53104. /**
  53105. * This function sets a selection feature that will be disabled when
  53106. * the forward ray is shown and will be reattached when hidden.
  53107. * This is used to remove the selection rays when moving.
  53108. * @param selectionFeature the feature to disable when forward movement is enabled
  53109. */
  53110. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  53111. protected _onXRFrame(_xrFrame: XRFrame): void;
  53112. private _attachController;
  53113. private _createDefaultTargetMesh;
  53114. private _detachController;
  53115. private _findClosestSnapPointWithRadius;
  53116. private _setTargetMeshPosition;
  53117. private _setTargetMeshVisibility;
  53118. private _showParabolicPath;
  53119. private _teleportForward;
  53120. }
  53121. }
  53122. declare module BABYLON {
  53123. /**
  53124. * Options for the default xr helper
  53125. */
  53126. export class WebXRDefaultExperienceOptions {
  53127. /**
  53128. * Enable or disable default UI to enter XR
  53129. */
  53130. disableDefaultUI?: boolean;
  53131. /**
  53132. * Should teleportation not initialize. defaults to false.
  53133. */
  53134. disableTeleportation?: boolean;
  53135. /**
  53136. * Floor meshes that will be used for teleport
  53137. */
  53138. floorMeshes?: Array<AbstractMesh>;
  53139. /**
  53140. * If set to true, the first frame will not be used to reset position
  53141. * The first frame is mainly used when copying transformation from the old camera
  53142. * Mainly used in AR
  53143. */
  53144. ignoreNativeCameraTransformation?: boolean;
  53145. /**
  53146. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  53147. */
  53148. inputOptions?: IWebXRInputOptions;
  53149. /**
  53150. * optional configuration for the output canvas
  53151. */
  53152. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53153. /**
  53154. * optional UI options. This can be used among other to change session mode and reference space type
  53155. */
  53156. uiOptions?: WebXREnterExitUIOptions;
  53157. /**
  53158. * When loading teleportation and pointer select, use stable versions instead of latest.
  53159. */
  53160. useStablePlugins?: boolean;
  53161. /**
  53162. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53163. */
  53164. renderingGroupId?: number;
  53165. /**
  53166. * A list of optional features to init the session with
  53167. * If set to true, all features we support will be added
  53168. */
  53169. optionalFeatures?: boolean | string[];
  53170. }
  53171. /**
  53172. * Default experience which provides a similar setup to the previous webVRExperience
  53173. */
  53174. export class WebXRDefaultExperience {
  53175. /**
  53176. * Base experience
  53177. */
  53178. baseExperience: WebXRExperienceHelper;
  53179. /**
  53180. * Enables ui for entering/exiting xr
  53181. */
  53182. enterExitUI: WebXREnterExitUI;
  53183. /**
  53184. * Input experience extension
  53185. */
  53186. input: WebXRInput;
  53187. /**
  53188. * Enables laser pointer and selection
  53189. */
  53190. pointerSelection: WebXRControllerPointerSelection;
  53191. /**
  53192. * Default target xr should render to
  53193. */
  53194. renderTarget: WebXRRenderTarget;
  53195. /**
  53196. * Enables teleportation
  53197. */
  53198. teleportation: WebXRMotionControllerTeleportation;
  53199. private constructor();
  53200. /**
  53201. * Creates the default xr experience
  53202. * @param scene scene
  53203. * @param options options for basic configuration
  53204. * @returns resulting WebXRDefaultExperience
  53205. */
  53206. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53207. /**
  53208. * DIsposes of the experience helper
  53209. */
  53210. dispose(): void;
  53211. }
  53212. }
  53213. declare module BABYLON {
  53214. /**
  53215. * Options to modify the vr teleportation behavior.
  53216. */
  53217. export interface VRTeleportationOptions {
  53218. /**
  53219. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53220. */
  53221. floorMeshName?: string;
  53222. /**
  53223. * A list of meshes to be used as the teleportation floor. (default: empty)
  53224. */
  53225. floorMeshes?: Mesh[];
  53226. /**
  53227. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53228. */
  53229. teleportationMode?: number;
  53230. /**
  53231. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53232. */
  53233. teleportationTime?: number;
  53234. /**
  53235. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53236. */
  53237. teleportationSpeed?: number;
  53238. /**
  53239. * The easing function used in the animation or null for Linear. (default CircleEase)
  53240. */
  53241. easingFunction?: EasingFunction;
  53242. }
  53243. /**
  53244. * Options to modify the vr experience helper's behavior.
  53245. */
  53246. export interface VRExperienceHelperOptions extends WebVROptions {
  53247. /**
  53248. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53249. */
  53250. createDeviceOrientationCamera?: boolean;
  53251. /**
  53252. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53253. */
  53254. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53255. /**
  53256. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53257. */
  53258. laserToggle?: boolean;
  53259. /**
  53260. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53261. */
  53262. floorMeshes?: Mesh[];
  53263. /**
  53264. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53265. */
  53266. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53267. /**
  53268. * Defines if WebXR should be used instead of WebVR (if available)
  53269. */
  53270. useXR?: boolean;
  53271. }
  53272. /**
  53273. * Event containing information after VR has been entered
  53274. */
  53275. export class OnAfterEnteringVRObservableEvent {
  53276. /**
  53277. * If entering vr was successful
  53278. */
  53279. success: boolean;
  53280. }
  53281. /**
  53282. * Helps to quickly add VR support to an existing scene.
  53283. * See https://doc.babylonjs.com/how_to/webvr_helper
  53284. */
  53285. export class VRExperienceHelper {
  53286. /** Options to modify the vr experience helper's behavior. */
  53287. webVROptions: VRExperienceHelperOptions;
  53288. private _scene;
  53289. private _position;
  53290. private _btnVR;
  53291. private _btnVRDisplayed;
  53292. private _webVRsupported;
  53293. private _webVRready;
  53294. private _webVRrequesting;
  53295. private _webVRpresenting;
  53296. private _hasEnteredVR;
  53297. private _fullscreenVRpresenting;
  53298. private _inputElement;
  53299. private _webVRCamera;
  53300. private _vrDeviceOrientationCamera;
  53301. private _deviceOrientationCamera;
  53302. private _existingCamera;
  53303. private _onKeyDown;
  53304. private _onVrDisplayPresentChange;
  53305. private _onVRDisplayChanged;
  53306. private _onVRRequestPresentStart;
  53307. private _onVRRequestPresentComplete;
  53308. /**
  53309. * 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)
  53310. */
  53311. enableGazeEvenWhenNoPointerLock: boolean;
  53312. /**
  53313. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53314. */
  53315. exitVROnDoubleTap: boolean;
  53316. /**
  53317. * Observable raised right before entering VR.
  53318. */
  53319. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53320. /**
  53321. * Observable raised when entering VR has completed.
  53322. */
  53323. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53324. /**
  53325. * Observable raised when exiting VR.
  53326. */
  53327. onExitingVRObservable: Observable<VRExperienceHelper>;
  53328. /**
  53329. * Observable raised when controller mesh is loaded.
  53330. */
  53331. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53332. /** Return this.onEnteringVRObservable
  53333. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53334. */
  53335. get onEnteringVR(): Observable<VRExperienceHelper>;
  53336. /** Return this.onExitingVRObservable
  53337. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53338. */
  53339. get onExitingVR(): Observable<VRExperienceHelper>;
  53340. /** Return this.onControllerMeshLoadedObservable
  53341. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53342. */
  53343. get onControllerMeshLoaded(): Observable<WebVRController>;
  53344. private _rayLength;
  53345. private _useCustomVRButton;
  53346. private _teleportationRequested;
  53347. private _teleportActive;
  53348. private _floorMeshName;
  53349. private _floorMeshesCollection;
  53350. private _teleportationMode;
  53351. private _teleportationTime;
  53352. private _teleportationSpeed;
  53353. private _teleportationEasing;
  53354. private _rotationAllowed;
  53355. private _teleportBackwardsVector;
  53356. private _teleportationTarget;
  53357. private _isDefaultTeleportationTarget;
  53358. private _postProcessMove;
  53359. private _teleportationFillColor;
  53360. private _teleportationBorderColor;
  53361. private _rotationAngle;
  53362. private _haloCenter;
  53363. private _cameraGazer;
  53364. private _padSensibilityUp;
  53365. private _padSensibilityDown;
  53366. private _leftController;
  53367. private _rightController;
  53368. private _gazeColor;
  53369. private _laserColor;
  53370. private _pickedLaserColor;
  53371. private _pickedGazeColor;
  53372. /**
  53373. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53374. */
  53375. onNewMeshSelected: Observable<AbstractMesh>;
  53376. /**
  53377. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53378. * This observable will provide the mesh and the controller used to select the mesh
  53379. */
  53380. onMeshSelectedWithController: Observable<{
  53381. mesh: AbstractMesh;
  53382. controller: WebVRController;
  53383. }>;
  53384. /**
  53385. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53386. */
  53387. onNewMeshPicked: Observable<PickingInfo>;
  53388. private _circleEase;
  53389. /**
  53390. * Observable raised before camera teleportation
  53391. */
  53392. onBeforeCameraTeleport: Observable<Vector3>;
  53393. /**
  53394. * Observable raised after camera teleportation
  53395. */
  53396. onAfterCameraTeleport: Observable<Vector3>;
  53397. /**
  53398. * Observable raised when current selected mesh gets unselected
  53399. */
  53400. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53401. private _raySelectionPredicate;
  53402. /**
  53403. * To be optionaly changed by user to define custom ray selection
  53404. */
  53405. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53406. /**
  53407. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53408. */
  53409. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53410. /**
  53411. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53412. */
  53413. teleportationEnabled: boolean;
  53414. private _defaultHeight;
  53415. private _teleportationInitialized;
  53416. private _interactionsEnabled;
  53417. private _interactionsRequested;
  53418. private _displayGaze;
  53419. private _displayLaserPointer;
  53420. /**
  53421. * The mesh used to display where the user is going to teleport.
  53422. */
  53423. get teleportationTarget(): Mesh;
  53424. /**
  53425. * Sets the mesh to be used to display where the user is going to teleport.
  53426. */
  53427. set teleportationTarget(value: Mesh);
  53428. /**
  53429. * 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
  53430. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53431. * See https://doc.babylonjs.com/resources/baking_transformations
  53432. */
  53433. get gazeTrackerMesh(): Mesh;
  53434. set gazeTrackerMesh(value: Mesh);
  53435. /**
  53436. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53437. */
  53438. updateGazeTrackerScale: boolean;
  53439. /**
  53440. * If the gaze trackers color should be updated when selecting meshes
  53441. */
  53442. updateGazeTrackerColor: boolean;
  53443. /**
  53444. * If the controller laser color should be updated when selecting meshes
  53445. */
  53446. updateControllerLaserColor: boolean;
  53447. /**
  53448. * The gaze tracking mesh corresponding to the left controller
  53449. */
  53450. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53451. /**
  53452. * The gaze tracking mesh corresponding to the right controller
  53453. */
  53454. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53455. /**
  53456. * If the ray of the gaze should be displayed.
  53457. */
  53458. get displayGaze(): boolean;
  53459. /**
  53460. * Sets if the ray of the gaze should be displayed.
  53461. */
  53462. set displayGaze(value: boolean);
  53463. /**
  53464. * If the ray of the LaserPointer should be displayed.
  53465. */
  53466. get displayLaserPointer(): boolean;
  53467. /**
  53468. * Sets if the ray of the LaserPointer should be displayed.
  53469. */
  53470. set displayLaserPointer(value: boolean);
  53471. /**
  53472. * The deviceOrientationCamera used as the camera when not in VR.
  53473. */
  53474. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53475. /**
  53476. * Based on the current WebVR support, returns the current VR camera used.
  53477. */
  53478. get currentVRCamera(): Nullable<Camera>;
  53479. /**
  53480. * The webVRCamera which is used when in VR.
  53481. */
  53482. get webVRCamera(): WebVRFreeCamera;
  53483. /**
  53484. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53485. */
  53486. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53487. /**
  53488. * The html button that is used to trigger entering into VR.
  53489. */
  53490. get vrButton(): Nullable<HTMLButtonElement>;
  53491. private get _teleportationRequestInitiated();
  53492. /**
  53493. * Defines whether or not Pointer lock should be requested when switching to
  53494. * full screen.
  53495. */
  53496. requestPointerLockOnFullScreen: boolean;
  53497. /**
  53498. * If asking to force XR, this will be populated with the default xr experience
  53499. */
  53500. xr: WebXRDefaultExperience;
  53501. /**
  53502. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53503. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53504. */
  53505. xrTestDone: boolean;
  53506. /**
  53507. * Instantiates a VRExperienceHelper.
  53508. * Helps to quickly add VR support to an existing scene.
  53509. * @param scene The scene the VRExperienceHelper belongs to.
  53510. * @param webVROptions Options to modify the vr experience helper's behavior.
  53511. */
  53512. constructor(scene: Scene,
  53513. /** Options to modify the vr experience helper's behavior. */
  53514. webVROptions?: VRExperienceHelperOptions);
  53515. private completeVRInit;
  53516. private _onDefaultMeshLoaded;
  53517. private _onResize;
  53518. private _onFullscreenChange;
  53519. /**
  53520. * Gets a value indicating if we are currently in VR mode.
  53521. */
  53522. get isInVRMode(): boolean;
  53523. private onVrDisplayPresentChange;
  53524. private onVRDisplayChanged;
  53525. private moveButtonToBottomRight;
  53526. private displayVRButton;
  53527. private updateButtonVisibility;
  53528. private _cachedAngularSensibility;
  53529. /**
  53530. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53531. * Otherwise, will use the fullscreen API.
  53532. */
  53533. enterVR(): void;
  53534. /**
  53535. * Attempt to exit VR, or fullscreen.
  53536. */
  53537. exitVR(): void;
  53538. /**
  53539. * The position of the vr experience helper.
  53540. */
  53541. get position(): Vector3;
  53542. /**
  53543. * Sets the position of the vr experience helper.
  53544. */
  53545. set position(value: Vector3);
  53546. /**
  53547. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53548. */
  53549. enableInteractions(): void;
  53550. private get _noControllerIsActive();
  53551. private beforeRender;
  53552. private _isTeleportationFloor;
  53553. /**
  53554. * Adds a floor mesh to be used for teleportation.
  53555. * @param floorMesh the mesh to be used for teleportation.
  53556. */
  53557. addFloorMesh(floorMesh: Mesh): void;
  53558. /**
  53559. * Removes a floor mesh from being used for teleportation.
  53560. * @param floorMesh the mesh to be removed.
  53561. */
  53562. removeFloorMesh(floorMesh: Mesh): void;
  53563. /**
  53564. * Enables interactions and teleportation using the VR controllers and gaze.
  53565. * @param vrTeleportationOptions options to modify teleportation behavior.
  53566. */
  53567. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53568. private _onNewGamepadConnected;
  53569. private _tryEnableInteractionOnController;
  53570. private _onNewGamepadDisconnected;
  53571. private _enableInteractionOnController;
  53572. private _checkTeleportWithRay;
  53573. private _checkRotate;
  53574. private _checkTeleportBackwards;
  53575. private _enableTeleportationOnController;
  53576. private _createTeleportationCircles;
  53577. private _displayTeleportationTarget;
  53578. private _hideTeleportationTarget;
  53579. private _rotateCamera;
  53580. private _moveTeleportationSelectorTo;
  53581. private _workingVector;
  53582. private _workingQuaternion;
  53583. private _workingMatrix;
  53584. /**
  53585. * Time Constant Teleportation Mode
  53586. */
  53587. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53588. /**
  53589. * Speed Constant Teleportation Mode
  53590. */
  53591. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53592. /**
  53593. * Teleports the users feet to the desired location
  53594. * @param location The location where the user's feet should be placed
  53595. */
  53596. teleportCamera(location: Vector3): void;
  53597. private _convertNormalToDirectionOfRay;
  53598. private _castRayAndSelectObject;
  53599. private _notifySelectedMeshUnselected;
  53600. /**
  53601. * Permanently set new colors for the laser pointer
  53602. * @param color the new laser color
  53603. * @param pickedColor the new laser color when picked mesh detected
  53604. */
  53605. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53606. /**
  53607. * Set lighting enabled / disabled on the laser pointer of both controllers
  53608. * @param enabled should the lighting be enabled on the laser pointer
  53609. */
  53610. setLaserLightingState(enabled?: boolean): void;
  53611. /**
  53612. * Permanently set new colors for the gaze pointer
  53613. * @param color the new gaze color
  53614. * @param pickedColor the new gaze color when picked mesh detected
  53615. */
  53616. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53617. /**
  53618. * Sets the color of the laser ray from the vr controllers.
  53619. * @param color new color for the ray.
  53620. */
  53621. changeLaserColor(color: Color3): void;
  53622. /**
  53623. * Sets the color of the ray from the vr headsets gaze.
  53624. * @param color new color for the ray.
  53625. */
  53626. changeGazeColor(color: Color3): void;
  53627. /**
  53628. * Exits VR and disposes of the vr experience helper
  53629. */
  53630. dispose(): void;
  53631. /**
  53632. * Gets the name of the VRExperienceHelper class
  53633. * @returns "VRExperienceHelper"
  53634. */
  53635. getClassName(): string;
  53636. }
  53637. }
  53638. declare module BABYLON {
  53639. /**
  53640. * Contains an array of blocks representing the octree
  53641. */
  53642. export interface IOctreeContainer<T> {
  53643. /**
  53644. * Blocks within the octree
  53645. */
  53646. blocks: Array<OctreeBlock<T>>;
  53647. }
  53648. /**
  53649. * Class used to store a cell in an octree
  53650. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53651. */
  53652. export class OctreeBlock<T> {
  53653. /**
  53654. * Gets the content of the current block
  53655. */
  53656. entries: T[];
  53657. /**
  53658. * Gets the list of block children
  53659. */
  53660. blocks: Array<OctreeBlock<T>>;
  53661. private _depth;
  53662. private _maxDepth;
  53663. private _capacity;
  53664. private _minPoint;
  53665. private _maxPoint;
  53666. private _boundingVectors;
  53667. private _creationFunc;
  53668. /**
  53669. * Creates a new block
  53670. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53671. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53672. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53673. * @param depth defines the current depth of this block in the octree
  53674. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53675. * @param creationFunc defines a callback to call when an element is added to the block
  53676. */
  53677. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53678. /**
  53679. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53680. */
  53681. get capacity(): number;
  53682. /**
  53683. * Gets the minimum vector (in world space) of the block's bounding box
  53684. */
  53685. get minPoint(): Vector3;
  53686. /**
  53687. * Gets the maximum vector (in world space) of the block's bounding box
  53688. */
  53689. get maxPoint(): Vector3;
  53690. /**
  53691. * Add a new element to this block
  53692. * @param entry defines the element to add
  53693. */
  53694. addEntry(entry: T): void;
  53695. /**
  53696. * Remove an element from this block
  53697. * @param entry defines the element to remove
  53698. */
  53699. removeEntry(entry: T): void;
  53700. /**
  53701. * Add an array of elements to this block
  53702. * @param entries defines the array of elements to add
  53703. */
  53704. addEntries(entries: T[]): void;
  53705. /**
  53706. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53707. * @param frustumPlanes defines the frustum planes to test
  53708. * @param selection defines the array to store current content if selection is positive
  53709. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53710. */
  53711. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53712. /**
  53713. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53714. * @param sphereCenter defines the bounding sphere center
  53715. * @param sphereRadius defines the bounding sphere radius
  53716. * @param selection defines the array to store current content if selection is positive
  53717. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53718. */
  53719. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53720. /**
  53721. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53722. * @param ray defines the ray to test with
  53723. * @param selection defines the array to store current content if selection is positive
  53724. */
  53725. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53726. /**
  53727. * Subdivide the content into child blocks (this block will then be empty)
  53728. */
  53729. createInnerBlocks(): void;
  53730. /**
  53731. * @hidden
  53732. */
  53733. 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;
  53734. }
  53735. }
  53736. declare module BABYLON {
  53737. /**
  53738. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53739. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53740. */
  53741. export class Octree<T> {
  53742. /** 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.) */
  53743. maxDepth: number;
  53744. /**
  53745. * Blocks within the octree containing objects
  53746. */
  53747. blocks: Array<OctreeBlock<T>>;
  53748. /**
  53749. * Content stored in the octree
  53750. */
  53751. dynamicContent: T[];
  53752. private _maxBlockCapacity;
  53753. private _selectionContent;
  53754. private _creationFunc;
  53755. /**
  53756. * Creates a octree
  53757. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53758. * @param creationFunc function to be used to instatiate the octree
  53759. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53760. * @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.)
  53761. */
  53762. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53763. /** 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.) */
  53764. maxDepth?: number);
  53765. /**
  53766. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53767. * @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);
  53768. * @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);
  53769. * @param entries meshes to be added to the octree blocks
  53770. */
  53771. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53772. /**
  53773. * Adds a mesh to the octree
  53774. * @param entry Mesh to add to the octree
  53775. */
  53776. addMesh(entry: T): void;
  53777. /**
  53778. * Remove an element from the octree
  53779. * @param entry defines the element to remove
  53780. */
  53781. removeMesh(entry: T): void;
  53782. /**
  53783. * Selects an array of meshes within the frustum
  53784. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53785. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53786. * @returns array of meshes within the frustum
  53787. */
  53788. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53789. /**
  53790. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53791. * @param sphereCenter defines the bounding sphere center
  53792. * @param sphereRadius defines the bounding sphere radius
  53793. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53794. * @returns an array of objects that intersect the sphere
  53795. */
  53796. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53797. /**
  53798. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53799. * @param ray defines the ray to test with
  53800. * @returns array of intersected objects
  53801. */
  53802. intersectsRay(ray: Ray): SmartArray<T>;
  53803. /**
  53804. * Adds a mesh into the octree block if it intersects the block
  53805. */
  53806. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53807. /**
  53808. * Adds a submesh into the octree block if it intersects the block
  53809. */
  53810. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53811. }
  53812. }
  53813. declare module BABYLON {
  53814. interface Scene {
  53815. /**
  53816. * @hidden
  53817. * Backing Filed
  53818. */
  53819. _selectionOctree: Octree<AbstractMesh>;
  53820. /**
  53821. * Gets the octree used to boost mesh selection (picking)
  53822. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53823. */
  53824. selectionOctree: Octree<AbstractMesh>;
  53825. /**
  53826. * Creates or updates the octree used to boost selection (picking)
  53827. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53828. * @param maxCapacity defines the maximum capacity per leaf
  53829. * @param maxDepth defines the maximum depth of the octree
  53830. * @returns an octree of AbstractMesh
  53831. */
  53832. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53833. }
  53834. interface AbstractMesh {
  53835. /**
  53836. * @hidden
  53837. * Backing Field
  53838. */
  53839. _submeshesOctree: Octree<SubMesh>;
  53840. /**
  53841. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53842. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53843. * @param maxCapacity defines the maximum size of each block (64 by default)
  53844. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53845. * @returns the new octree
  53846. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53847. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53848. */
  53849. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53850. }
  53851. /**
  53852. * Defines the octree scene component responsible to manage any octrees
  53853. * in a given scene.
  53854. */
  53855. export class OctreeSceneComponent {
  53856. /**
  53857. * The component name help to identify the component in the list of scene components.
  53858. */
  53859. readonly name: string;
  53860. /**
  53861. * The scene the component belongs to.
  53862. */
  53863. scene: Scene;
  53864. /**
  53865. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53866. */
  53867. readonly checksIsEnabled: boolean;
  53868. /**
  53869. * Creates a new instance of the component for the given scene
  53870. * @param scene Defines the scene to register the component in
  53871. */
  53872. constructor(scene: Scene);
  53873. /**
  53874. * Registers the component in a given scene
  53875. */
  53876. register(): void;
  53877. /**
  53878. * Return the list of active meshes
  53879. * @returns the list of active meshes
  53880. */
  53881. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53882. /**
  53883. * Return the list of active sub meshes
  53884. * @param mesh The mesh to get the candidates sub meshes from
  53885. * @returns the list of active sub meshes
  53886. */
  53887. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53888. private _tempRay;
  53889. /**
  53890. * Return the list of sub meshes intersecting with a given local ray
  53891. * @param mesh defines the mesh to find the submesh for
  53892. * @param localRay defines the ray in local space
  53893. * @returns the list of intersecting sub meshes
  53894. */
  53895. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53896. /**
  53897. * Return the list of sub meshes colliding with a collider
  53898. * @param mesh defines the mesh to find the submesh for
  53899. * @param collider defines the collider to evaluate the collision against
  53900. * @returns the list of colliding sub meshes
  53901. */
  53902. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53903. /**
  53904. * Rebuilds the elements related to this component in case of
  53905. * context lost for instance.
  53906. */
  53907. rebuild(): void;
  53908. /**
  53909. * Disposes the component and the associated ressources.
  53910. */
  53911. dispose(): void;
  53912. }
  53913. }
  53914. declare module BABYLON {
  53915. /**
  53916. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  53917. */
  53918. export interface GizmoAxisCache {
  53919. /** Mesh used to runder the Gizmo */
  53920. gizmoMeshes: Mesh[];
  53921. /** Mesh used to detect user interaction with Gizmo */
  53922. colliderMeshes: Mesh[];
  53923. /** Material used to inicate color of gizmo mesh */
  53924. material: StandardMaterial;
  53925. /** Material used to inicate hover state of the Gizmo */
  53926. hoverMaterial: StandardMaterial;
  53927. /** Material used to inicate disabled state of the Gizmo */
  53928. disableMaterial: StandardMaterial;
  53929. /** Used to indicate Active state of the Gizmo */
  53930. active: boolean;
  53931. }
  53932. /**
  53933. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53934. */
  53935. export class Gizmo implements IDisposable {
  53936. /** The utility layer the gizmo will be added to */
  53937. gizmoLayer: UtilityLayerRenderer;
  53938. /**
  53939. * The root mesh of the gizmo
  53940. */
  53941. _rootMesh: Mesh;
  53942. private _attachedMesh;
  53943. private _attachedNode;
  53944. /**
  53945. * Ratio for the scale of the gizmo (Default: 1)
  53946. */
  53947. protected _scaleRatio: number;
  53948. /**
  53949. * boolean updated by pointermove when a gizmo mesh is hovered
  53950. */
  53951. protected _isHovered: boolean;
  53952. /**
  53953. * Ratio for the scale of the gizmo (Default: 1)
  53954. */
  53955. set scaleRatio(value: number);
  53956. get scaleRatio(): number;
  53957. /**
  53958. * True when the mouse pointer is hovered a gizmo mesh
  53959. */
  53960. get isHovered(): boolean;
  53961. /**
  53962. * If a custom mesh has been set (Default: false)
  53963. */
  53964. protected _customMeshSet: boolean;
  53965. /**
  53966. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53967. * * When set, interactions will be enabled
  53968. */
  53969. get attachedMesh(): Nullable<AbstractMesh>;
  53970. set attachedMesh(value: Nullable<AbstractMesh>);
  53971. /**
  53972. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53973. * * When set, interactions will be enabled
  53974. */
  53975. get attachedNode(): Nullable<Node>;
  53976. set attachedNode(value: Nullable<Node>);
  53977. /**
  53978. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53979. * @param mesh The mesh to replace the default mesh of the gizmo
  53980. */
  53981. setCustomMesh(mesh: Mesh): void;
  53982. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53983. /**
  53984. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53985. */
  53986. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53987. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53988. /**
  53989. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53990. */
  53991. updateGizmoPositionToMatchAttachedMesh: boolean;
  53992. /**
  53993. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53994. */
  53995. updateScale: boolean;
  53996. protected _interactionsEnabled: boolean;
  53997. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53998. private _beforeRenderObserver;
  53999. private _tempQuaternion;
  54000. private _tempVector;
  54001. private _tempVector2;
  54002. private _tempMatrix1;
  54003. private _tempMatrix2;
  54004. private _rightHandtoLeftHandMatrix;
  54005. /**
  54006. * Creates a gizmo
  54007. * @param gizmoLayer The utility layer the gizmo will be added to
  54008. */
  54009. constructor(
  54010. /** The utility layer the gizmo will be added to */
  54011. gizmoLayer?: UtilityLayerRenderer);
  54012. /**
  54013. * Updates the gizmo to match the attached mesh's position/rotation
  54014. */
  54015. protected _update(): void;
  54016. /**
  54017. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  54018. * @param value Node, TransformNode or mesh
  54019. */
  54020. protected _matrixChanged(): void;
  54021. /**
  54022. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  54023. * @param gizmoLayer The utility layer the gizmo will be added to
  54024. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54025. * @returns {Observer<PointerInfo>} pointerObserver
  54026. */
  54027. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  54028. /**
  54029. * Disposes of the gizmo
  54030. */
  54031. dispose(): void;
  54032. }
  54033. }
  54034. declare module BABYLON {
  54035. /**
  54036. * Single plane drag gizmo
  54037. */
  54038. export class PlaneDragGizmo extends Gizmo {
  54039. /**
  54040. * Drag behavior responsible for the gizmos dragging interactions
  54041. */
  54042. dragBehavior: PointerDragBehavior;
  54043. private _pointerObserver;
  54044. /**
  54045. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54046. */
  54047. snapDistance: number;
  54048. /**
  54049. * Event that fires each time the gizmo snaps to a new location.
  54050. * * snapDistance is the the change in distance
  54051. */
  54052. onSnapObservable: Observable<{
  54053. snapDistance: number;
  54054. }>;
  54055. private _gizmoMesh;
  54056. private _coloredMaterial;
  54057. private _hoverMaterial;
  54058. private _disableMaterial;
  54059. private _isEnabled;
  54060. private _parent;
  54061. private _dragging;
  54062. /** @hidden */
  54063. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  54064. /**
  54065. * Creates a PlaneDragGizmo
  54066. * @param gizmoLayer The utility layer the gizmo will be added to
  54067. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  54068. * @param color The color of the gizmo
  54069. */
  54070. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  54071. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54072. /**
  54073. * If the gizmo is enabled
  54074. */
  54075. set isEnabled(value: boolean);
  54076. get isEnabled(): boolean;
  54077. /**
  54078. * Disposes of the gizmo
  54079. */
  54080. dispose(): void;
  54081. }
  54082. }
  54083. declare module BABYLON {
  54084. /**
  54085. * Single plane rotation gizmo
  54086. */
  54087. export class PlaneRotationGizmo extends Gizmo {
  54088. /**
  54089. * Drag behavior responsible for the gizmos dragging interactions
  54090. */
  54091. dragBehavior: PointerDragBehavior;
  54092. private _pointerObserver;
  54093. /**
  54094. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54095. */
  54096. snapDistance: number;
  54097. /**
  54098. * Event that fires each time the gizmo snaps to a new location.
  54099. * * snapDistance is the the change in distance
  54100. */
  54101. onSnapObservable: Observable<{
  54102. snapDistance: number;
  54103. }>;
  54104. private _isEnabled;
  54105. private _parent;
  54106. private _coloredMaterial;
  54107. private _hoverMaterial;
  54108. private _disableMaterial;
  54109. private _gizmoMesh;
  54110. private _rotationCircle;
  54111. private _dragging;
  54112. private static _CircleConstants;
  54113. /**
  54114. * Creates a PlaneRotationGizmo
  54115. * @param gizmoLayer The utility layer the gizmo will be added to
  54116. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54117. * @param color The color of the gizmo
  54118. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54119. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54120. * @param thickness display gizmo axis thickness
  54121. */
  54122. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  54123. /** Create Geometry for Gizmo */
  54124. private _createGizmoMesh;
  54125. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54126. private setupRotationCircle;
  54127. private updateRotationPath;
  54128. private updateRotationCircle;
  54129. /**
  54130. * If the gizmo is enabled
  54131. */
  54132. set isEnabled(value: boolean);
  54133. get isEnabled(): boolean;
  54134. /**
  54135. * Disposes of the gizmo
  54136. */
  54137. dispose(): void;
  54138. }
  54139. }
  54140. declare module BABYLON {
  54141. /**
  54142. * Gizmo that enables rotating a mesh along 3 axis
  54143. */
  54144. export class RotationGizmo extends Gizmo {
  54145. /**
  54146. * Internal gizmo used for interactions on the x axis
  54147. */
  54148. xGizmo: PlaneRotationGizmo;
  54149. /**
  54150. * Internal gizmo used for interactions on the y axis
  54151. */
  54152. yGizmo: PlaneRotationGizmo;
  54153. /**
  54154. * Internal gizmo used for interactions on the z axis
  54155. */
  54156. zGizmo: PlaneRotationGizmo;
  54157. /** Fires an event when any of it's sub gizmos are dragged */
  54158. onDragStartObservable: Observable<unknown>;
  54159. /** Fires an event when any of it's sub gizmos are released from dragging */
  54160. onDragEndObservable: Observable<unknown>;
  54161. private _meshAttached;
  54162. private _nodeAttached;
  54163. private _observables;
  54164. /** Node Caching for quick lookup */
  54165. private _gizmoAxisCache;
  54166. get attachedMesh(): Nullable<AbstractMesh>;
  54167. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54168. get attachedNode(): Nullable<Node>;
  54169. set attachedNode(node: Nullable<Node>);
  54170. protected _checkBillboardTransform(): void;
  54171. /**
  54172. * True when the mouse pointer is hovering a gizmo mesh
  54173. */
  54174. get isHovered(): boolean;
  54175. /**
  54176. * Creates a RotationGizmo
  54177. * @param gizmoLayer The utility layer the gizmo will be added to
  54178. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54179. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54180. * @param thickness display gizmo axis thickness
  54181. */
  54182. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  54183. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54184. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54185. /**
  54186. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54187. */
  54188. set snapDistance(value: number);
  54189. get snapDistance(): number;
  54190. /**
  54191. * Ratio for the scale of the gizmo (Default: 1)
  54192. */
  54193. set scaleRatio(value: number);
  54194. get scaleRatio(): number;
  54195. /**
  54196. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54197. * @param mesh Axis gizmo mesh
  54198. * @param cache Gizmo axis definition used for reactive gizmo UI
  54199. */
  54200. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54201. /**
  54202. * Disposes of the gizmo
  54203. */
  54204. dispose(): void;
  54205. /**
  54206. * CustomMeshes are not supported by this gizmo
  54207. * @param mesh The mesh to replace the default mesh of the gizmo
  54208. */
  54209. setCustomMesh(mesh: Mesh): void;
  54210. }
  54211. }
  54212. declare module BABYLON {
  54213. /**
  54214. * Class containing static functions to help procedurally build meshes
  54215. */
  54216. export class PolyhedronBuilder {
  54217. /**
  54218. * Creates a polyhedron mesh
  54219. * * 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
  54220. * * The parameter `size` (positive float, default 1) sets the polygon size
  54221. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54222. * * 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`
  54223. * * 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
  54224. * * 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)`)
  54225. * * 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
  54226. * * 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
  54227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54228. * * 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
  54229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54230. * @param name defines the name of the mesh
  54231. * @param options defines the options used to create the mesh
  54232. * @param scene defines the hosting scene
  54233. * @returns the polyhedron mesh
  54234. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54235. */
  54236. static CreatePolyhedron(name: string, options: {
  54237. type?: number;
  54238. size?: number;
  54239. sizeX?: number;
  54240. sizeY?: number;
  54241. sizeZ?: number;
  54242. custom?: any;
  54243. faceUV?: Vector4[];
  54244. faceColors?: Color4[];
  54245. flat?: boolean;
  54246. updatable?: boolean;
  54247. sideOrientation?: number;
  54248. frontUVs?: Vector4;
  54249. backUVs?: Vector4;
  54250. }, scene?: Nullable<Scene>): Mesh;
  54251. }
  54252. }
  54253. declare module BABYLON {
  54254. /**
  54255. * Class containing static functions to help procedurally build meshes
  54256. */
  54257. export class BoxBuilder {
  54258. /**
  54259. * Creates a box mesh
  54260. * * The parameter `size` sets the size (float) of each box side (default 1)
  54261. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54262. * * 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)
  54263. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54265. * * 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
  54266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54267. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54268. * @param name defines the name of the mesh
  54269. * @param options defines the options used to create the mesh
  54270. * @param scene defines the hosting scene
  54271. * @returns the box mesh
  54272. */
  54273. static CreateBox(name: string, options: {
  54274. size?: number;
  54275. width?: number;
  54276. height?: number;
  54277. depth?: number;
  54278. faceUV?: Vector4[];
  54279. faceColors?: Color4[];
  54280. sideOrientation?: number;
  54281. frontUVs?: Vector4;
  54282. backUVs?: Vector4;
  54283. wrap?: boolean;
  54284. topBaseAt?: number;
  54285. bottomBaseAt?: number;
  54286. updatable?: boolean;
  54287. }, scene?: Nullable<Scene>): Mesh;
  54288. }
  54289. }
  54290. declare module BABYLON {
  54291. /**
  54292. * Single axis scale gizmo
  54293. */
  54294. export class AxisScaleGizmo extends Gizmo {
  54295. /**
  54296. * Drag behavior responsible for the gizmos dragging interactions
  54297. */
  54298. dragBehavior: PointerDragBehavior;
  54299. private _pointerObserver;
  54300. /**
  54301. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54302. */
  54303. snapDistance: number;
  54304. /**
  54305. * Event that fires each time the gizmo snaps to a new location.
  54306. * * snapDistance is the the change in distance
  54307. */
  54308. onSnapObservable: Observable<{
  54309. snapDistance: number;
  54310. }>;
  54311. /**
  54312. * If the scaling operation should be done on all axis (default: false)
  54313. */
  54314. uniformScaling: boolean;
  54315. /**
  54316. * Custom sensitivity value for the drag strength
  54317. */
  54318. sensitivity: number;
  54319. private _isEnabled;
  54320. private _parent;
  54321. private _gizmoMesh;
  54322. private _coloredMaterial;
  54323. private _hoverMaterial;
  54324. private _disableMaterial;
  54325. private _dragging;
  54326. /**
  54327. * Creates an AxisScaleGizmo
  54328. * @param gizmoLayer The utility layer the gizmo will be added to
  54329. * @param dragAxis The axis which the gizmo will be able to scale on
  54330. * @param color The color of the gizmo
  54331. * @param thickness display gizmo axis thickness
  54332. */
  54333. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  54334. /** Create Geometry for Gizmo */
  54335. private _createGizmoMesh;
  54336. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54337. /**
  54338. * If the gizmo is enabled
  54339. */
  54340. set isEnabled(value: boolean);
  54341. get isEnabled(): boolean;
  54342. /**
  54343. * Disposes of the gizmo
  54344. */
  54345. dispose(): void;
  54346. /**
  54347. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54348. * @param mesh The mesh to replace the default mesh of the gizmo
  54349. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54350. */
  54351. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54352. }
  54353. }
  54354. declare module BABYLON {
  54355. /**
  54356. * Gizmo that enables scaling a mesh along 3 axis
  54357. */
  54358. export class ScaleGizmo extends Gizmo {
  54359. /**
  54360. * Internal gizmo used for interactions on the x axis
  54361. */
  54362. xGizmo: AxisScaleGizmo;
  54363. /**
  54364. * Internal gizmo used for interactions on the y axis
  54365. */
  54366. yGizmo: AxisScaleGizmo;
  54367. /**
  54368. * Internal gizmo used for interactions on the z axis
  54369. */
  54370. zGizmo: AxisScaleGizmo;
  54371. /**
  54372. * Internal gizmo used to scale all axis equally
  54373. */
  54374. uniformScaleGizmo: AxisScaleGizmo;
  54375. private _meshAttached;
  54376. private _nodeAttached;
  54377. private _snapDistance;
  54378. private _uniformScalingMesh;
  54379. private _octahedron;
  54380. private _sensitivity;
  54381. private _coloredMaterial;
  54382. private _hoverMaterial;
  54383. private _disableMaterial;
  54384. private _observables;
  54385. /** Node Caching for quick lookup */
  54386. private _gizmoAxisCache;
  54387. /** Fires an event when any of it's sub gizmos are dragged */
  54388. onDragStartObservable: Observable<unknown>;
  54389. /** Fires an event when any of it's sub gizmos are released from dragging */
  54390. onDragEndObservable: Observable<unknown>;
  54391. get attachedMesh(): Nullable<AbstractMesh>;
  54392. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54393. get attachedNode(): Nullable<Node>;
  54394. set attachedNode(node: Nullable<Node>);
  54395. /**
  54396. * True when the mouse pointer is hovering a gizmo mesh
  54397. */
  54398. get isHovered(): boolean;
  54399. /**
  54400. * Creates a ScaleGizmo
  54401. * @param gizmoLayer The utility layer the gizmo will be added to
  54402. * @param thickness display gizmo axis thickness
  54403. */
  54404. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54405. /** Create Geometry for Gizmo */
  54406. private _createUniformScaleMesh;
  54407. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54408. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54409. /**
  54410. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54411. */
  54412. set snapDistance(value: number);
  54413. get snapDistance(): number;
  54414. /**
  54415. * Ratio for the scale of the gizmo (Default: 1)
  54416. */
  54417. set scaleRatio(value: number);
  54418. get scaleRatio(): number;
  54419. /**
  54420. * Sensitivity factor for dragging (Default: 1)
  54421. */
  54422. set sensitivity(value: number);
  54423. get sensitivity(): number;
  54424. /**
  54425. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54426. * @param mesh Axis gizmo mesh
  54427. * @param cache Gizmo axis definition used for reactive gizmo UI
  54428. */
  54429. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54430. /**
  54431. * Disposes of the gizmo
  54432. */
  54433. dispose(): void;
  54434. }
  54435. }
  54436. declare module BABYLON {
  54437. /**
  54438. * Bounding box gizmo
  54439. */
  54440. export class BoundingBoxGizmo extends Gizmo {
  54441. private _lineBoundingBox;
  54442. private _rotateSpheresParent;
  54443. private _scaleBoxesParent;
  54444. private _boundingDimensions;
  54445. private _renderObserver;
  54446. private _pointerObserver;
  54447. private _scaleDragSpeed;
  54448. private _tmpQuaternion;
  54449. private _tmpVector;
  54450. private _tmpRotationMatrix;
  54451. /**
  54452. * 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)
  54453. */
  54454. ignoreChildren: boolean;
  54455. /**
  54456. * 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)
  54457. */
  54458. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54459. /**
  54460. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54461. */
  54462. rotationSphereSize: number;
  54463. /**
  54464. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54465. */
  54466. scaleBoxSize: number;
  54467. /**
  54468. * 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)
  54469. */
  54470. fixedDragMeshScreenSize: boolean;
  54471. /**
  54472. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54473. */
  54474. fixedDragMeshScreenSizeDistanceFactor: number;
  54475. /**
  54476. * Fired when a rotation sphere or scale box is dragged
  54477. */
  54478. onDragStartObservable: Observable<{}>;
  54479. /**
  54480. * Fired when a scale box is dragged
  54481. */
  54482. onScaleBoxDragObservable: Observable<{}>;
  54483. /**
  54484. * Fired when a scale box drag is ended
  54485. */
  54486. onScaleBoxDragEndObservable: Observable<{}>;
  54487. /**
  54488. * Fired when a rotation sphere is dragged
  54489. */
  54490. onRotationSphereDragObservable: Observable<{}>;
  54491. /**
  54492. * Fired when a rotation sphere drag is ended
  54493. */
  54494. onRotationSphereDragEndObservable: Observable<{}>;
  54495. /**
  54496. * 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)
  54497. */
  54498. scalePivot: Nullable<Vector3>;
  54499. /**
  54500. * Mesh used as a pivot to rotate the attached node
  54501. */
  54502. private _anchorMesh;
  54503. private _existingMeshScale;
  54504. private _dragMesh;
  54505. private pointerDragBehavior;
  54506. private coloredMaterial;
  54507. private hoverColoredMaterial;
  54508. /**
  54509. * Sets the color of the bounding box gizmo
  54510. * @param color the color to set
  54511. */
  54512. setColor(color: Color3): void;
  54513. /**
  54514. * Creates an BoundingBoxGizmo
  54515. * @param gizmoLayer The utility layer the gizmo will be added to
  54516. * @param color The color of the gizmo
  54517. */
  54518. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54519. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  54520. private _selectNode;
  54521. /**
  54522. * Updates the bounding box information for the Gizmo
  54523. */
  54524. updateBoundingBox(): void;
  54525. private _updateRotationSpheres;
  54526. private _updateScaleBoxes;
  54527. /**
  54528. * Enables rotation on the specified axis and disables rotation on the others
  54529. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54530. */
  54531. setEnabledRotationAxis(axis: string): void;
  54532. /**
  54533. * Enables/disables scaling
  54534. * @param enable if scaling should be enabled
  54535. * @param homogeneousScaling defines if scaling should only be homogeneous
  54536. */
  54537. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54538. private _updateDummy;
  54539. /**
  54540. * Enables a pointer drag behavior on the bounding box of the gizmo
  54541. */
  54542. enableDragBehavior(): void;
  54543. /**
  54544. * Disposes of the gizmo
  54545. */
  54546. dispose(): void;
  54547. /**
  54548. * 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)
  54549. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54550. * @returns the bounding box mesh with the passed in mesh as a child
  54551. */
  54552. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54553. /**
  54554. * CustomMeshes are not supported by this gizmo
  54555. * @param mesh The mesh to replace the default mesh of the gizmo
  54556. */
  54557. setCustomMesh(mesh: Mesh): void;
  54558. }
  54559. }
  54560. declare module BABYLON {
  54561. /**
  54562. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54563. */
  54564. export class GizmoManager implements IDisposable {
  54565. private scene;
  54566. /**
  54567. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54568. */
  54569. gizmos: {
  54570. positionGizmo: Nullable<PositionGizmo>;
  54571. rotationGizmo: Nullable<RotationGizmo>;
  54572. scaleGizmo: Nullable<ScaleGizmo>;
  54573. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54574. };
  54575. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54576. clearGizmoOnEmptyPointerEvent: boolean;
  54577. /** Fires an event when the manager is attached to a mesh */
  54578. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54579. /** Fires an event when the manager is attached to a node */
  54580. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54581. private _gizmosEnabled;
  54582. private _pointerObservers;
  54583. private _attachedMesh;
  54584. private _attachedNode;
  54585. private _boundingBoxColor;
  54586. private _defaultUtilityLayer;
  54587. private _defaultKeepDepthUtilityLayer;
  54588. private _thickness;
  54589. /** Node Caching for quick lookup */
  54590. private _gizmoAxisCache;
  54591. /**
  54592. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54593. */
  54594. boundingBoxDragBehavior: SixDofDragBehavior;
  54595. /**
  54596. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54597. */
  54598. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54599. /**
  54600. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54601. */
  54602. attachableNodes: Nullable<Array<Node>>;
  54603. /**
  54604. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54605. */
  54606. usePointerToAttachGizmos: boolean;
  54607. /**
  54608. * Utility layer that the bounding box gizmo belongs to
  54609. */
  54610. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54611. /**
  54612. * Utility layer that all gizmos besides bounding box belong to
  54613. */
  54614. get utilityLayer(): UtilityLayerRenderer;
  54615. /**
  54616. * True when the mouse pointer is hovering a gizmo mesh
  54617. */
  54618. get isHovered(): boolean;
  54619. /**
  54620. * Instatiates a gizmo manager
  54621. * @param scene the scene to overlay the gizmos on top of
  54622. * @param thickness display gizmo axis thickness
  54623. * @param utilityLayer the layer where gizmos are rendered
  54624. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  54625. */
  54626. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  54627. /**
  54628. * Subscribes to pointer down events, for attaching and detaching mesh
  54629. * @param scene The sceme layer the observer will be added to
  54630. */
  54631. private _attachToMeshPointerObserver;
  54632. /**
  54633. * Attaches a set of gizmos to the specified mesh
  54634. * @param mesh The mesh the gizmo's should be attached to
  54635. */
  54636. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54637. /**
  54638. * Attaches a set of gizmos to the specified node
  54639. * @param node The node the gizmo's should be attached to
  54640. */
  54641. attachToNode(node: Nullable<Node>): void;
  54642. /**
  54643. * If the position gizmo is enabled
  54644. */
  54645. set positionGizmoEnabled(value: boolean);
  54646. get positionGizmoEnabled(): boolean;
  54647. /**
  54648. * If the rotation gizmo is enabled
  54649. */
  54650. set rotationGizmoEnabled(value: boolean);
  54651. get rotationGizmoEnabled(): boolean;
  54652. /**
  54653. * If the scale gizmo is enabled
  54654. */
  54655. set scaleGizmoEnabled(value: boolean);
  54656. get scaleGizmoEnabled(): boolean;
  54657. /**
  54658. * If the boundingBox gizmo is enabled
  54659. */
  54660. set boundingBoxGizmoEnabled(value: boolean);
  54661. get boundingBoxGizmoEnabled(): boolean;
  54662. /**
  54663. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54664. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54665. */
  54666. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  54667. /**
  54668. * Disposes of the gizmo manager
  54669. */
  54670. dispose(): void;
  54671. }
  54672. }
  54673. declare module BABYLON {
  54674. /**
  54675. * Gizmo that enables dragging a mesh along 3 axis
  54676. */
  54677. export class PositionGizmo extends Gizmo {
  54678. /**
  54679. * Internal gizmo used for interactions on the x axis
  54680. */
  54681. xGizmo: AxisDragGizmo;
  54682. /**
  54683. * Internal gizmo used for interactions on the y axis
  54684. */
  54685. yGizmo: AxisDragGizmo;
  54686. /**
  54687. * Internal gizmo used for interactions on the z axis
  54688. */
  54689. zGizmo: AxisDragGizmo;
  54690. /**
  54691. * Internal gizmo used for interactions on the yz plane
  54692. */
  54693. xPlaneGizmo: PlaneDragGizmo;
  54694. /**
  54695. * Internal gizmo used for interactions on the xz plane
  54696. */
  54697. yPlaneGizmo: PlaneDragGizmo;
  54698. /**
  54699. * Internal gizmo used for interactions on the xy plane
  54700. */
  54701. zPlaneGizmo: PlaneDragGizmo;
  54702. /**
  54703. * private variables
  54704. */
  54705. private _meshAttached;
  54706. private _nodeAttached;
  54707. private _snapDistance;
  54708. private _observables;
  54709. /** Node Caching for quick lookup */
  54710. private _gizmoAxisCache;
  54711. /** Fires an event when any of it's sub gizmos are dragged */
  54712. onDragStartObservable: Observable<unknown>;
  54713. /** Fires an event when any of it's sub gizmos are released from dragging */
  54714. onDragEndObservable: Observable<unknown>;
  54715. /**
  54716. * If set to true, planar drag is enabled
  54717. */
  54718. private _planarGizmoEnabled;
  54719. get attachedMesh(): Nullable<AbstractMesh>;
  54720. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54721. get attachedNode(): Nullable<Node>;
  54722. set attachedNode(node: Nullable<Node>);
  54723. /**
  54724. * True when the mouse pointer is hovering a gizmo mesh
  54725. */
  54726. get isHovered(): boolean;
  54727. /**
  54728. * Creates a PositionGizmo
  54729. * @param gizmoLayer The utility layer the gizmo will be added to
  54730. @param thickness display gizmo axis thickness
  54731. */
  54732. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54733. /**
  54734. * If the planar drag gizmo is enabled
  54735. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  54736. */
  54737. set planarGizmoEnabled(value: boolean);
  54738. get planarGizmoEnabled(): boolean;
  54739. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54740. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54741. /**
  54742. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54743. */
  54744. set snapDistance(value: number);
  54745. get snapDistance(): number;
  54746. /**
  54747. * Ratio for the scale of the gizmo (Default: 1)
  54748. */
  54749. set scaleRatio(value: number);
  54750. get scaleRatio(): number;
  54751. /**
  54752. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54753. * @param mesh Axis gizmo mesh
  54754. * @param cache Gizmo axis definition used for reactive gizmo UI
  54755. */
  54756. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54757. /**
  54758. * Disposes of the gizmo
  54759. */
  54760. dispose(): void;
  54761. /**
  54762. * CustomMeshes are not supported by this gizmo
  54763. * @param mesh The mesh to replace the default mesh of the gizmo
  54764. */
  54765. setCustomMesh(mesh: Mesh): void;
  54766. }
  54767. }
  54768. declare module BABYLON {
  54769. /**
  54770. * Single axis drag gizmo
  54771. */
  54772. export class AxisDragGizmo extends Gizmo {
  54773. /**
  54774. * Drag behavior responsible for the gizmos dragging interactions
  54775. */
  54776. dragBehavior: PointerDragBehavior;
  54777. private _pointerObserver;
  54778. /**
  54779. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54780. */
  54781. snapDistance: number;
  54782. /**
  54783. * Event that fires each time the gizmo snaps to a new location.
  54784. * * snapDistance is the the change in distance
  54785. */
  54786. onSnapObservable: Observable<{
  54787. snapDistance: number;
  54788. }>;
  54789. private _isEnabled;
  54790. private _parent;
  54791. private _gizmoMesh;
  54792. private _coloredMaterial;
  54793. private _hoverMaterial;
  54794. private _disableMaterial;
  54795. private _dragging;
  54796. /** @hidden */
  54797. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  54798. /** @hidden */
  54799. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  54800. /**
  54801. * Creates an AxisDragGizmo
  54802. * @param gizmoLayer The utility layer the gizmo will be added to
  54803. * @param dragAxis The axis which the gizmo will be able to drag on
  54804. * @param color The color of the gizmo
  54805. * @param thickness display gizmo axis thickness
  54806. */
  54807. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  54808. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54809. /**
  54810. * If the gizmo is enabled
  54811. */
  54812. set isEnabled(value: boolean);
  54813. get isEnabled(): boolean;
  54814. /**
  54815. * Disposes of the gizmo
  54816. */
  54817. dispose(): void;
  54818. }
  54819. }
  54820. declare module BABYLON.Debug {
  54821. /**
  54822. * The Axes viewer will show 3 axes in a specific point in space
  54823. */
  54824. export class AxesViewer {
  54825. private _xAxis;
  54826. private _yAxis;
  54827. private _zAxis;
  54828. private _scaleLinesFactor;
  54829. private _instanced;
  54830. /**
  54831. * Gets the hosting scene
  54832. */
  54833. scene: Nullable<Scene>;
  54834. /**
  54835. * Gets or sets a number used to scale line length
  54836. */
  54837. scaleLines: number;
  54838. /** Gets the node hierarchy used to render x-axis */
  54839. get xAxis(): TransformNode;
  54840. /** Gets the node hierarchy used to render y-axis */
  54841. get yAxis(): TransformNode;
  54842. /** Gets the node hierarchy used to render z-axis */
  54843. get zAxis(): TransformNode;
  54844. /**
  54845. * Creates a new AxesViewer
  54846. * @param scene defines the hosting scene
  54847. * @param scaleLines defines a number used to scale line length (1 by default)
  54848. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  54849. * @param xAxis defines the node hierarchy used to render the x-axis
  54850. * @param yAxis defines the node hierarchy used to render the y-axis
  54851. * @param zAxis defines the node hierarchy used to render the z-axis
  54852. */
  54853. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  54854. /**
  54855. * Force the viewer to update
  54856. * @param position defines the position of the viewer
  54857. * @param xaxis defines the x axis of the viewer
  54858. * @param yaxis defines the y axis of the viewer
  54859. * @param zaxis defines the z axis of the viewer
  54860. */
  54861. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  54862. /**
  54863. * Creates an instance of this axes viewer.
  54864. * @returns a new axes viewer with instanced meshes
  54865. */
  54866. createInstance(): AxesViewer;
  54867. /** Releases resources */
  54868. dispose(): void;
  54869. private static _SetRenderingGroupId;
  54870. }
  54871. }
  54872. declare module BABYLON.Debug {
  54873. /**
  54874. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  54875. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  54876. */
  54877. export class BoneAxesViewer extends AxesViewer {
  54878. /**
  54879. * Gets or sets the target mesh where to display the axes viewer
  54880. */
  54881. mesh: Nullable<Mesh>;
  54882. /**
  54883. * Gets or sets the target bone where to display the axes viewer
  54884. */
  54885. bone: Nullable<Bone>;
  54886. /** Gets current position */
  54887. pos: Vector3;
  54888. /** Gets direction of X axis */
  54889. xaxis: Vector3;
  54890. /** Gets direction of Y axis */
  54891. yaxis: Vector3;
  54892. /** Gets direction of Z axis */
  54893. zaxis: Vector3;
  54894. /**
  54895. * Creates a new BoneAxesViewer
  54896. * @param scene defines the hosting scene
  54897. * @param bone defines the target bone
  54898. * @param mesh defines the target mesh
  54899. * @param scaleLines defines a scaling factor for line length (1 by default)
  54900. */
  54901. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  54902. /**
  54903. * Force the viewer to update
  54904. */
  54905. update(): void;
  54906. /** Releases resources */
  54907. dispose(): void;
  54908. }
  54909. }
  54910. declare module BABYLON {
  54911. /**
  54912. * Interface used to define scene explorer extensibility option
  54913. */
  54914. export interface IExplorerExtensibilityOption {
  54915. /**
  54916. * Define the option label
  54917. */
  54918. label: string;
  54919. /**
  54920. * Defines the action to execute on click
  54921. */
  54922. action: (entity: any) => void;
  54923. }
  54924. /**
  54925. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  54926. */
  54927. export interface IExplorerExtensibilityGroup {
  54928. /**
  54929. * Defines a predicate to test if a given type mut be extended
  54930. */
  54931. predicate: (entity: any) => boolean;
  54932. /**
  54933. * Gets the list of options added to a type
  54934. */
  54935. entries: IExplorerExtensibilityOption[];
  54936. }
  54937. /**
  54938. * Interface used to define the options to use to create the Inspector
  54939. */
  54940. export interface IInspectorOptions {
  54941. /**
  54942. * Display in overlay mode (default: false)
  54943. */
  54944. overlay?: boolean;
  54945. /**
  54946. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  54947. */
  54948. globalRoot?: HTMLElement;
  54949. /**
  54950. * Display the Scene explorer
  54951. */
  54952. showExplorer?: boolean;
  54953. /**
  54954. * Display the property inspector
  54955. */
  54956. showInspector?: boolean;
  54957. /**
  54958. * Display in embed mode (both panes on the right)
  54959. */
  54960. embedMode?: boolean;
  54961. /**
  54962. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  54963. */
  54964. handleResize?: boolean;
  54965. /**
  54966. * Allow the panes to popup (default: true)
  54967. */
  54968. enablePopup?: boolean;
  54969. /**
  54970. * Allow the panes to be closed by users (default: true)
  54971. */
  54972. enableClose?: boolean;
  54973. /**
  54974. * Optional list of extensibility entries
  54975. */
  54976. explorerExtensibility?: IExplorerExtensibilityGroup[];
  54977. /**
  54978. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  54979. */
  54980. inspectorURL?: string;
  54981. /**
  54982. * Optional initial tab (default to DebugLayerTab.Properties)
  54983. */
  54984. initialTab?: DebugLayerTab;
  54985. }
  54986. interface Scene {
  54987. /**
  54988. * @hidden
  54989. * Backing field
  54990. */
  54991. _debugLayer: DebugLayer;
  54992. /**
  54993. * Gets the debug layer (aka Inspector) associated with the scene
  54994. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54995. */
  54996. debugLayer: DebugLayer;
  54997. }
  54998. /**
  54999. * Enum of inspector action tab
  55000. */
  55001. export enum DebugLayerTab {
  55002. /**
  55003. * Properties tag (default)
  55004. */
  55005. Properties = 0,
  55006. /**
  55007. * Debug tab
  55008. */
  55009. Debug = 1,
  55010. /**
  55011. * Statistics tab
  55012. */
  55013. Statistics = 2,
  55014. /**
  55015. * Tools tab
  55016. */
  55017. Tools = 3,
  55018. /**
  55019. * Settings tab
  55020. */
  55021. Settings = 4
  55022. }
  55023. /**
  55024. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55025. * what is happening in your scene
  55026. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55027. */
  55028. export class DebugLayer {
  55029. /**
  55030. * Define the url to get the inspector script from.
  55031. * By default it uses the babylonjs CDN.
  55032. * @ignoreNaming
  55033. */
  55034. static InspectorURL: string;
  55035. private _scene;
  55036. private BJSINSPECTOR;
  55037. private _onPropertyChangedObservable?;
  55038. /**
  55039. * Observable triggered when a property is changed through the inspector.
  55040. */
  55041. get onPropertyChangedObservable(): any;
  55042. /**
  55043. * Instantiates a new debug layer.
  55044. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55045. * what is happening in your scene
  55046. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55047. * @param scene Defines the scene to inspect
  55048. */
  55049. constructor(scene: Scene);
  55050. /** Creates the inspector window. */
  55051. private _createInspector;
  55052. /**
  55053. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  55054. * @param entity defines the entity to select
  55055. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  55056. */
  55057. select(entity: any, lineContainerTitles?: string | string[]): void;
  55058. /** Get the inspector from bundle or global */
  55059. private _getGlobalInspector;
  55060. /**
  55061. * Get if the inspector is visible or not.
  55062. * @returns true if visible otherwise, false
  55063. */
  55064. isVisible(): boolean;
  55065. /**
  55066. * Hide the inspector and close its window.
  55067. */
  55068. hide(): void;
  55069. /**
  55070. * Update the scene in the inspector
  55071. */
  55072. setAsActiveScene(): void;
  55073. /**
  55074. * Launch the debugLayer.
  55075. * @param config Define the configuration of the inspector
  55076. * @return a promise fulfilled when the debug layer is visible
  55077. */
  55078. show(config?: IInspectorOptions): Promise<DebugLayer>;
  55079. }
  55080. }
  55081. declare module BABYLON.Debug {
  55082. /**
  55083. * Used to show the physics impostor around the specific mesh
  55084. */
  55085. export class PhysicsViewer {
  55086. /** @hidden */
  55087. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  55088. /** @hidden */
  55089. protected _meshes: Array<Nullable<AbstractMesh>>;
  55090. /** @hidden */
  55091. protected _scene: Nullable<Scene>;
  55092. /** @hidden */
  55093. protected _numMeshes: number;
  55094. /** @hidden */
  55095. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  55096. private _renderFunction;
  55097. private _utilityLayer;
  55098. private _debugBoxMesh;
  55099. private _debugSphereMesh;
  55100. private _debugCylinderMesh;
  55101. private _debugMaterial;
  55102. private _debugMeshMeshes;
  55103. /**
  55104. * Creates a new PhysicsViewer
  55105. * @param scene defines the hosting scene
  55106. */
  55107. constructor(scene: Scene);
  55108. /** @hidden */
  55109. protected _updateDebugMeshes(): void;
  55110. /**
  55111. * Renders a specified physic impostor
  55112. * @param impostor defines the impostor to render
  55113. * @param targetMesh defines the mesh represented by the impostor
  55114. * @returns the new debug mesh used to render the impostor
  55115. */
  55116. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  55117. /**
  55118. * Hides a specified physic impostor
  55119. * @param impostor defines the impostor to hide
  55120. */
  55121. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  55122. private _getDebugMaterial;
  55123. private _getDebugBoxMesh;
  55124. private _getDebugSphereMesh;
  55125. private _getDebugCylinderMesh;
  55126. private _getDebugMeshMesh;
  55127. private _getDebugMesh;
  55128. /** Releases all resources */
  55129. dispose(): void;
  55130. }
  55131. }
  55132. declare module BABYLON {
  55133. /**
  55134. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55135. * in order to better appreciate the issue one might have.
  55136. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55137. */
  55138. export class RayHelper {
  55139. /**
  55140. * Defines the ray we are currently tryin to visualize.
  55141. */
  55142. ray: Nullable<Ray>;
  55143. private _renderPoints;
  55144. private _renderLine;
  55145. private _renderFunction;
  55146. private _scene;
  55147. private _onAfterRenderObserver;
  55148. private _onAfterStepObserver;
  55149. private _attachedToMesh;
  55150. private _meshSpaceDirection;
  55151. private _meshSpaceOrigin;
  55152. /**
  55153. * Helper function to create a colored helper in a scene in one line.
  55154. * @param ray Defines the ray we are currently tryin to visualize
  55155. * @param scene Defines the scene the ray is used in
  55156. * @param color Defines the color we want to see the ray in
  55157. * @returns The newly created ray helper.
  55158. */
  55159. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  55160. /**
  55161. * Instantiate a new ray helper.
  55162. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55163. * in order to better appreciate the issue one might have.
  55164. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55165. * @param ray Defines the ray we are currently tryin to visualize
  55166. */
  55167. constructor(ray: Ray);
  55168. /**
  55169. * Shows the ray we are willing to debug.
  55170. * @param scene Defines the scene the ray needs to be rendered in
  55171. * @param color Defines the color the ray needs to be rendered in
  55172. */
  55173. show(scene: Scene, color?: Color3): void;
  55174. /**
  55175. * Hides the ray we are debugging.
  55176. */
  55177. hide(): void;
  55178. private _render;
  55179. /**
  55180. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  55181. * @param mesh Defines the mesh we want the helper attached to
  55182. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  55183. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  55184. * @param length Defines the length of the ray
  55185. */
  55186. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  55187. /**
  55188. * Detach the ray helper from the mesh it has previously been attached to.
  55189. */
  55190. detachFromMesh(): void;
  55191. private _updateToMesh;
  55192. /**
  55193. * Dispose the helper and release its associated resources.
  55194. */
  55195. dispose(): void;
  55196. }
  55197. }
  55198. declare module BABYLON {
  55199. /**
  55200. * Defines the options associated with the creation of a SkeletonViewer.
  55201. */
  55202. export interface ISkeletonViewerOptions {
  55203. /** Should the system pause animations before building the Viewer? */
  55204. pauseAnimations: boolean;
  55205. /** Should the system return the skeleton to rest before building? */
  55206. returnToRest: boolean;
  55207. /** public Display Mode of the Viewer */
  55208. displayMode: number;
  55209. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55210. displayOptions: ISkeletonViewerDisplayOptions;
  55211. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55212. computeBonesUsingShaders: boolean;
  55213. /** Flag ignore non weighted bones */
  55214. useAllBones: boolean;
  55215. }
  55216. /**
  55217. * Defines how to display the various bone meshes for the viewer.
  55218. */
  55219. export interface ISkeletonViewerDisplayOptions {
  55220. /** How far down to start tapering the bone spurs */
  55221. midStep?: number;
  55222. /** How big is the midStep? */
  55223. midStepFactor?: number;
  55224. /** Base for the Sphere Size */
  55225. sphereBaseSize?: number;
  55226. /** The ratio of the sphere to the longest bone in units */
  55227. sphereScaleUnit?: number;
  55228. /** Ratio for the Sphere Size */
  55229. sphereFactor?: number;
  55230. /** Whether a spur should attach its far end to the child bone position */
  55231. spurFollowsChild?: boolean;
  55232. /** Whether to show local axes or not */
  55233. showLocalAxes?: boolean;
  55234. /** Length of each local axis */
  55235. localAxesSize?: number;
  55236. }
  55237. /**
  55238. * Defines the constructor options for the BoneWeight Shader.
  55239. */
  55240. export interface IBoneWeightShaderOptions {
  55241. /** Skeleton to Map */
  55242. skeleton: Skeleton;
  55243. /** Colors for Uninfluenced bones */
  55244. colorBase?: Color3;
  55245. /** Colors for 0.0-0.25 Weight bones */
  55246. colorZero?: Color3;
  55247. /** Color for 0.25-0.5 Weight Influence */
  55248. colorQuarter?: Color3;
  55249. /** Color for 0.5-0.75 Weight Influence */
  55250. colorHalf?: Color3;
  55251. /** Color for 0.75-1 Weight Influence */
  55252. colorFull?: Color3;
  55253. /** Color for Zero Weight Influence */
  55254. targetBoneIndex?: number;
  55255. }
  55256. /**
  55257. * Simple structure of the gradient steps for the Color Map.
  55258. */
  55259. export interface ISkeletonMapShaderColorMapKnot {
  55260. /** Color of the Knot */
  55261. color: Color3;
  55262. /** Location of the Knot */
  55263. location: number;
  55264. }
  55265. /**
  55266. * Defines the constructor options for the SkeletonMap Shader.
  55267. */
  55268. export interface ISkeletonMapShaderOptions {
  55269. /** Skeleton to Map */
  55270. skeleton: Skeleton;
  55271. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  55272. colorMap?: ISkeletonMapShaderColorMapKnot[];
  55273. }
  55274. }
  55275. declare module BABYLON {
  55276. /**
  55277. * Class containing static functions to help procedurally build meshes
  55278. */
  55279. export class RibbonBuilder {
  55280. /**
  55281. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55282. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55283. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55284. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55285. * * 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
  55286. * * 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
  55287. * * 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
  55288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55289. * * 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
  55290. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55291. * * 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
  55292. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55293. * * 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
  55294. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55296. * @param name defines the name of the mesh
  55297. * @param options defines the options used to create the mesh
  55298. * @param scene defines the hosting scene
  55299. * @returns the ribbon mesh
  55300. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55301. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55302. */
  55303. static CreateRibbon(name: string, options: {
  55304. pathArray: Vector3[][];
  55305. closeArray?: boolean;
  55306. closePath?: boolean;
  55307. offset?: number;
  55308. updatable?: boolean;
  55309. sideOrientation?: number;
  55310. frontUVs?: Vector4;
  55311. backUVs?: Vector4;
  55312. instance?: Mesh;
  55313. invertUV?: boolean;
  55314. uvs?: Vector2[];
  55315. colors?: Color4[];
  55316. }, scene?: Nullable<Scene>): Mesh;
  55317. }
  55318. }
  55319. declare module BABYLON {
  55320. /**
  55321. * Class containing static functions to help procedurally build meshes
  55322. */
  55323. export class ShapeBuilder {
  55324. /**
  55325. * 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.
  55326. * * 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.
  55327. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55328. * * 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.
  55329. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55330. * * 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
  55331. * * 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
  55332. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55334. * * 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
  55335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55337. * @param name defines the name of the mesh
  55338. * @param options defines the options used to create the mesh
  55339. * @param scene defines the hosting scene
  55340. * @returns the extruded shape mesh
  55341. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55342. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55343. */
  55344. static ExtrudeShape(name: string, options: {
  55345. shape: Vector3[];
  55346. path: Vector3[];
  55347. scale?: number;
  55348. rotation?: number;
  55349. cap?: number;
  55350. updatable?: boolean;
  55351. sideOrientation?: number;
  55352. frontUVs?: Vector4;
  55353. backUVs?: Vector4;
  55354. instance?: Mesh;
  55355. invertUV?: boolean;
  55356. }, scene?: Nullable<Scene>): Mesh;
  55357. /**
  55358. * Creates an custom extruded shape mesh.
  55359. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55360. * * 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.
  55361. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55362. * * 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
  55363. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55364. * * 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
  55365. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55366. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55367. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55368. * * 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
  55369. * * 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
  55370. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55372. * * 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
  55373. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55375. * @param name defines the name of the mesh
  55376. * @param options defines the options used to create the mesh
  55377. * @param scene defines the hosting scene
  55378. * @returns the custom extruded shape mesh
  55379. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55380. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55381. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55382. */
  55383. static ExtrudeShapeCustom(name: string, options: {
  55384. shape: Vector3[];
  55385. path: Vector3[];
  55386. scaleFunction?: any;
  55387. rotationFunction?: any;
  55388. ribbonCloseArray?: boolean;
  55389. ribbonClosePath?: boolean;
  55390. cap?: number;
  55391. updatable?: boolean;
  55392. sideOrientation?: number;
  55393. frontUVs?: Vector4;
  55394. backUVs?: Vector4;
  55395. instance?: Mesh;
  55396. invertUV?: boolean;
  55397. }, scene?: Nullable<Scene>): Mesh;
  55398. private static _ExtrudeShapeGeneric;
  55399. }
  55400. }
  55401. declare module BABYLON.Debug {
  55402. /**
  55403. * Class used to render a debug view of a given skeleton
  55404. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  55405. */
  55406. export class SkeletonViewer {
  55407. /** defines the skeleton to render */
  55408. skeleton: Skeleton;
  55409. /** defines the mesh attached to the skeleton */
  55410. mesh: AbstractMesh;
  55411. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55412. autoUpdateBonesMatrices: boolean;
  55413. /** defines the rendering group id to use with the viewer */
  55414. renderingGroupId: number;
  55415. /** is the options for the viewer */
  55416. options: Partial<ISkeletonViewerOptions>;
  55417. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  55418. static readonly DISPLAY_LINES: number;
  55419. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  55420. static readonly DISPLAY_SPHERES: number;
  55421. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  55422. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  55423. /** public static method to create a BoneWeight Shader
  55424. * @param options The constructor options
  55425. * @param scene The scene that the shader is scoped to
  55426. * @returns The created ShaderMaterial
  55427. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  55428. */
  55429. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  55430. /** public static method to create a BoneWeight Shader
  55431. * @param options The constructor options
  55432. * @param scene The scene that the shader is scoped to
  55433. * @returns The created ShaderMaterial
  55434. */
  55435. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  55436. /** private static method to create a BoneWeight Shader
  55437. * @param size The size of the buffer to create (usually the bone count)
  55438. * @param colorMap The gradient data to generate
  55439. * @param scene The scene that the shader is scoped to
  55440. * @returns an Array of floats from the color gradient values
  55441. */
  55442. private static _CreateBoneMapColorBuffer;
  55443. /** If SkeletonViewer scene scope. */
  55444. private _scene;
  55445. /** Gets or sets the color used to render the skeleton */
  55446. color: Color3;
  55447. /** Array of the points of the skeleton fo the line view. */
  55448. private _debugLines;
  55449. /** The SkeletonViewers Mesh. */
  55450. private _debugMesh;
  55451. /** The local axes Meshes. */
  55452. private _localAxes;
  55453. /** If SkeletonViewer is enabled. */
  55454. private _isEnabled;
  55455. /** If SkeletonViewer is ready. */
  55456. private _ready;
  55457. /** SkeletonViewer render observable. */
  55458. private _obs;
  55459. /** The Utility Layer to render the gizmos in. */
  55460. private _utilityLayer;
  55461. private _boneIndices;
  55462. /** Gets the Scene. */
  55463. get scene(): Scene;
  55464. /** Gets the utilityLayer. */
  55465. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  55466. /** Checks Ready Status. */
  55467. get isReady(): Boolean;
  55468. /** Sets Ready Status. */
  55469. set ready(value: boolean);
  55470. /** Gets the debugMesh */
  55471. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  55472. /** Sets the debugMesh */
  55473. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  55474. /** Gets the displayMode */
  55475. get displayMode(): number;
  55476. /** Sets the displayMode */
  55477. set displayMode(value: number);
  55478. /**
  55479. * Creates a new SkeletonViewer
  55480. * @param skeleton defines the skeleton to render
  55481. * @param mesh defines the mesh attached to the skeleton
  55482. * @param scene defines the hosting scene
  55483. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  55484. * @param renderingGroupId defines the rendering group id to use with the viewer
  55485. * @param options All of the extra constructor options for the SkeletonViewer
  55486. */
  55487. constructor(
  55488. /** defines the skeleton to render */
  55489. skeleton: Skeleton,
  55490. /** defines the mesh attached to the skeleton */
  55491. mesh: AbstractMesh,
  55492. /** The Scene scope*/
  55493. scene: Scene,
  55494. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55495. autoUpdateBonesMatrices?: boolean,
  55496. /** defines the rendering group id to use with the viewer */
  55497. renderingGroupId?: number,
  55498. /** is the options for the viewer */
  55499. options?: Partial<ISkeletonViewerOptions>);
  55500. /** The Dynamic bindings for the update functions */
  55501. private _bindObs;
  55502. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  55503. update(): void;
  55504. /** Gets or sets a boolean indicating if the viewer is enabled */
  55505. set isEnabled(value: boolean);
  55506. get isEnabled(): boolean;
  55507. private _getBonePosition;
  55508. private _getLinesForBonesWithLength;
  55509. private _getLinesForBonesNoLength;
  55510. /** function to revert the mesh and scene back to the initial state. */
  55511. private _revert;
  55512. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  55513. private _getAbsoluteBindPoseToRef;
  55514. /** function to build and bind sphere joint points and spur bone representations. */
  55515. private _buildSpheresAndSpurs;
  55516. private _buildLocalAxes;
  55517. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  55518. private _displayLinesUpdate;
  55519. /** Changes the displayMode of the skeleton viewer
  55520. * @param mode The displayMode numerical value
  55521. */
  55522. changeDisplayMode(mode: number): void;
  55523. /** Sets a display option of the skeleton viewer
  55524. *
  55525. * | Option | Type | Default | Description |
  55526. * | ---------------- | ------- | ------- | ----------- |
  55527. * | 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`. |
  55528. * | 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`. |
  55529. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55530. * | 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`. |
  55531. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  55532. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  55533. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  55534. *
  55535. * @param option String of the option name
  55536. * @param value The numerical option value
  55537. */
  55538. changeDisplayOptions(option: string, value: number): void;
  55539. /** Release associated resources */
  55540. dispose(): void;
  55541. }
  55542. }
  55543. declare module BABYLON {
  55544. /**
  55545. * Enum for Device Types
  55546. */
  55547. export enum DeviceType {
  55548. /** Generic */
  55549. Generic = 0,
  55550. /** Keyboard */
  55551. Keyboard = 1,
  55552. /** Mouse */
  55553. Mouse = 2,
  55554. /** Touch Pointers */
  55555. Touch = 3,
  55556. /** PS4 Dual Shock */
  55557. DualShock = 4,
  55558. /** Xbox */
  55559. Xbox = 5,
  55560. /** Switch Controller */
  55561. Switch = 6
  55562. }
  55563. /**
  55564. * Enum for All Pointers (Touch/Mouse)
  55565. */
  55566. export enum PointerInput {
  55567. /** Horizontal Axis */
  55568. Horizontal = 0,
  55569. /** Vertical Axis */
  55570. Vertical = 1,
  55571. /** Left Click or Touch */
  55572. LeftClick = 2,
  55573. /** Middle Click */
  55574. MiddleClick = 3,
  55575. /** Right Click */
  55576. RightClick = 4,
  55577. /** Browser Back */
  55578. BrowserBack = 5,
  55579. /** Browser Forward */
  55580. BrowserForward = 6
  55581. }
  55582. /**
  55583. * Enum for Dual Shock Gamepad
  55584. */
  55585. export enum DualShockInput {
  55586. /** Cross */
  55587. Cross = 0,
  55588. /** Circle */
  55589. Circle = 1,
  55590. /** Square */
  55591. Square = 2,
  55592. /** Triangle */
  55593. Triangle = 3,
  55594. /** L1 */
  55595. L1 = 4,
  55596. /** R1 */
  55597. R1 = 5,
  55598. /** L2 */
  55599. L2 = 6,
  55600. /** R2 */
  55601. R2 = 7,
  55602. /** Share */
  55603. Share = 8,
  55604. /** Options */
  55605. Options = 9,
  55606. /** L3 */
  55607. L3 = 10,
  55608. /** R3 */
  55609. R3 = 11,
  55610. /** DPadUp */
  55611. DPadUp = 12,
  55612. /** DPadDown */
  55613. DPadDown = 13,
  55614. /** DPadLeft */
  55615. DPadLeft = 14,
  55616. /** DRight */
  55617. DPadRight = 15,
  55618. /** Home */
  55619. Home = 16,
  55620. /** TouchPad */
  55621. TouchPad = 17,
  55622. /** LStickXAxis */
  55623. LStickXAxis = 18,
  55624. /** LStickYAxis */
  55625. LStickYAxis = 19,
  55626. /** RStickXAxis */
  55627. RStickXAxis = 20,
  55628. /** RStickYAxis */
  55629. RStickYAxis = 21
  55630. }
  55631. /**
  55632. * Enum for Xbox Gamepad
  55633. */
  55634. export enum XboxInput {
  55635. /** A */
  55636. A = 0,
  55637. /** B */
  55638. B = 1,
  55639. /** X */
  55640. X = 2,
  55641. /** Y */
  55642. Y = 3,
  55643. /** LB */
  55644. LB = 4,
  55645. /** RB */
  55646. RB = 5,
  55647. /** LT */
  55648. LT = 6,
  55649. /** RT */
  55650. RT = 7,
  55651. /** Back */
  55652. Back = 8,
  55653. /** Start */
  55654. Start = 9,
  55655. /** LS */
  55656. LS = 10,
  55657. /** RS */
  55658. RS = 11,
  55659. /** DPadUp */
  55660. DPadUp = 12,
  55661. /** DPadDown */
  55662. DPadDown = 13,
  55663. /** DPadLeft */
  55664. DPadLeft = 14,
  55665. /** DRight */
  55666. DPadRight = 15,
  55667. /** Home */
  55668. Home = 16,
  55669. /** LStickXAxis */
  55670. LStickXAxis = 17,
  55671. /** LStickYAxis */
  55672. LStickYAxis = 18,
  55673. /** RStickXAxis */
  55674. RStickXAxis = 19,
  55675. /** RStickYAxis */
  55676. RStickYAxis = 20
  55677. }
  55678. /**
  55679. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  55680. */
  55681. export enum SwitchInput {
  55682. /** B */
  55683. B = 0,
  55684. /** A */
  55685. A = 1,
  55686. /** Y */
  55687. Y = 2,
  55688. /** X */
  55689. X = 3,
  55690. /** L */
  55691. L = 4,
  55692. /** R */
  55693. R = 5,
  55694. /** ZL */
  55695. ZL = 6,
  55696. /** ZR */
  55697. ZR = 7,
  55698. /** Minus */
  55699. Minus = 8,
  55700. /** Plus */
  55701. Plus = 9,
  55702. /** LS */
  55703. LS = 10,
  55704. /** RS */
  55705. RS = 11,
  55706. /** DPadUp */
  55707. DPadUp = 12,
  55708. /** DPadDown */
  55709. DPadDown = 13,
  55710. /** DPadLeft */
  55711. DPadLeft = 14,
  55712. /** DRight */
  55713. DPadRight = 15,
  55714. /** Home */
  55715. Home = 16,
  55716. /** Capture */
  55717. Capture = 17,
  55718. /** LStickXAxis */
  55719. LStickXAxis = 18,
  55720. /** LStickYAxis */
  55721. LStickYAxis = 19,
  55722. /** RStickXAxis */
  55723. RStickXAxis = 20,
  55724. /** RStickYAxis */
  55725. RStickYAxis = 21
  55726. }
  55727. }
  55728. declare module BABYLON {
  55729. /**
  55730. * This class will take all inputs from Keyboard, Pointer, and
  55731. * any Gamepads and provide a polling system that all devices
  55732. * will use. This class assumes that there will only be one
  55733. * pointer device and one keyboard.
  55734. */
  55735. export class DeviceInputSystem implements IDisposable {
  55736. /**
  55737. * Returns onDeviceConnected callback property
  55738. * @returns Callback with function to execute when a device is connected
  55739. */
  55740. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55741. /**
  55742. * Sets callback function when a device is connected and executes against all connected devices
  55743. * @param callback Function to execute when a device is connected
  55744. */
  55745. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55746. /**
  55747. * Callback to be triggered when a device is disconnected
  55748. */
  55749. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55750. /**
  55751. * Callback to be triggered when event driven input is updated
  55752. */
  55753. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55754. private _inputs;
  55755. private _gamepads;
  55756. private _keyboardActive;
  55757. private _pointerActive;
  55758. private _elementToAttachTo;
  55759. private _keyboardDownEvent;
  55760. private _keyboardUpEvent;
  55761. private _pointerMoveEvent;
  55762. private _pointerDownEvent;
  55763. private _pointerUpEvent;
  55764. private _gamepadConnectedEvent;
  55765. private _gamepadDisconnectedEvent;
  55766. private _onDeviceConnected;
  55767. private static _MAX_KEYCODES;
  55768. private static _MAX_POINTER_INPUTS;
  55769. private constructor();
  55770. /**
  55771. * Creates a new DeviceInputSystem instance
  55772. * @param engine Engine to pull input element from
  55773. * @returns The new instance
  55774. */
  55775. static Create(engine: Engine): DeviceInputSystem;
  55776. /**
  55777. * Checks for current device input value, given an id and input index
  55778. * @param deviceName Id of connected device
  55779. * @param inputIndex Index of device input
  55780. * @returns Current value of input
  55781. */
  55782. /**
  55783. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  55784. * @param deviceType Enum specifiying device type
  55785. * @param deviceSlot "Slot" or index that device is referenced in
  55786. * @param inputIndex Id of input to be checked
  55787. * @returns Current value of input
  55788. */
  55789. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  55790. /**
  55791. * Dispose of all the eventlisteners
  55792. */
  55793. dispose(): void;
  55794. /**
  55795. * Checks for existing connections to devices and register them, if necessary
  55796. * Currently handles gamepads and mouse
  55797. */
  55798. private _checkForConnectedDevices;
  55799. /**
  55800. * Add a gamepad to the DeviceInputSystem
  55801. * @param gamepad A single DOM Gamepad object
  55802. */
  55803. private _addGamePad;
  55804. /**
  55805. * Add pointer device to DeviceInputSystem
  55806. * @param deviceType Type of Pointer to add
  55807. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  55808. * @param currentX Current X at point of adding
  55809. * @param currentY Current Y at point of adding
  55810. */
  55811. private _addPointerDevice;
  55812. /**
  55813. * Add device and inputs to device array
  55814. * @param deviceType Enum specifiying device type
  55815. * @param deviceSlot "Slot" or index that device is referenced in
  55816. * @param numberOfInputs Number of input entries to create for given device
  55817. */
  55818. private _registerDevice;
  55819. /**
  55820. * Given a specific device name, remove that device from the device map
  55821. * @param deviceType Enum specifiying device type
  55822. * @param deviceSlot "Slot" or index that device is referenced in
  55823. */
  55824. private _unregisterDevice;
  55825. /**
  55826. * Handle all actions that come from keyboard interaction
  55827. */
  55828. private _handleKeyActions;
  55829. /**
  55830. * Handle all actions that come from pointer interaction
  55831. */
  55832. private _handlePointerActions;
  55833. /**
  55834. * Handle all actions that come from gamepad interaction
  55835. */
  55836. private _handleGamepadActions;
  55837. /**
  55838. * Update all non-event based devices with each frame
  55839. * @param deviceType Enum specifiying device type
  55840. * @param deviceSlot "Slot" or index that device is referenced in
  55841. * @param inputIndex Id of input to be checked
  55842. */
  55843. private _updateDevice;
  55844. /**
  55845. * Gets DeviceType from the device name
  55846. * @param deviceName Name of Device from DeviceInputSystem
  55847. * @returns DeviceType enum value
  55848. */
  55849. private _getGamepadDeviceType;
  55850. }
  55851. }
  55852. declare module BABYLON {
  55853. /**
  55854. * Type to handle enforcement of inputs
  55855. */
  55856. 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;
  55857. }
  55858. declare module BABYLON {
  55859. /**
  55860. * Class that handles all input for a specific device
  55861. */
  55862. export class DeviceSource<T extends DeviceType> {
  55863. /** Type of device */
  55864. readonly deviceType: DeviceType;
  55865. /** "Slot" or index that device is referenced in */
  55866. readonly deviceSlot: number;
  55867. /**
  55868. * Observable to handle device input changes per device
  55869. */
  55870. readonly onInputChangedObservable: Observable<{
  55871. inputIndex: DeviceInput<T>;
  55872. previousState: Nullable<number>;
  55873. currentState: Nullable<number>;
  55874. }>;
  55875. private readonly _deviceInputSystem;
  55876. /**
  55877. * Default Constructor
  55878. * @param deviceInputSystem Reference to DeviceInputSystem
  55879. * @param deviceType Type of device
  55880. * @param deviceSlot "Slot" or index that device is referenced in
  55881. */
  55882. constructor(deviceInputSystem: DeviceInputSystem,
  55883. /** Type of device */
  55884. deviceType: DeviceType,
  55885. /** "Slot" or index that device is referenced in */
  55886. deviceSlot?: number);
  55887. /**
  55888. * Get input for specific input
  55889. * @param inputIndex index of specific input on device
  55890. * @returns Input value from DeviceInputSystem
  55891. */
  55892. getInput(inputIndex: DeviceInput<T>): number;
  55893. }
  55894. /**
  55895. * Class to keep track of devices
  55896. */
  55897. export class DeviceSourceManager implements IDisposable {
  55898. /**
  55899. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  55900. */
  55901. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  55902. /**
  55903. * Observable to be triggered when after a device is disconnected
  55904. */
  55905. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  55906. private readonly _devices;
  55907. private readonly _firstDevice;
  55908. private readonly _deviceInputSystem;
  55909. /**
  55910. * Default Constructor
  55911. * @param engine engine to pull input element from
  55912. */
  55913. constructor(engine: Engine);
  55914. /**
  55915. * Gets a DeviceSource, given a type and slot
  55916. * @param deviceType Enum specifying device type
  55917. * @param deviceSlot "Slot" or index that device is referenced in
  55918. * @returns DeviceSource object
  55919. */
  55920. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  55921. /**
  55922. * Gets an array of DeviceSource objects for a given device type
  55923. * @param deviceType Enum specifying device type
  55924. * @returns Array of DeviceSource objects
  55925. */
  55926. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  55927. /**
  55928. * Returns a read-only list of all available devices
  55929. * @returns Read-only array with active devices
  55930. */
  55931. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  55932. /**
  55933. * Dispose of DeviceInputSystem and other parts
  55934. */
  55935. dispose(): void;
  55936. /**
  55937. * Function to add device name to device list
  55938. * @param deviceType Enum specifying device type
  55939. * @param deviceSlot "Slot" or index that device is referenced in
  55940. */
  55941. private _addDevice;
  55942. /**
  55943. * Function to remove device name to device list
  55944. * @param deviceType Enum specifying device type
  55945. * @param deviceSlot "Slot" or index that device is referenced in
  55946. */
  55947. private _removeDevice;
  55948. /**
  55949. * Updates array storing first connected device of each type
  55950. * @param type Type of Device
  55951. */
  55952. private _updateFirstDevices;
  55953. }
  55954. }
  55955. declare module BABYLON {
  55956. /**
  55957. * Options to create the null engine
  55958. */
  55959. export class NullEngineOptions {
  55960. /**
  55961. * Render width (Default: 512)
  55962. */
  55963. renderWidth: number;
  55964. /**
  55965. * Render height (Default: 256)
  55966. */
  55967. renderHeight: number;
  55968. /**
  55969. * Texture size (Default: 512)
  55970. */
  55971. textureSize: number;
  55972. /**
  55973. * If delta time between frames should be constant
  55974. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55975. */
  55976. deterministicLockstep: boolean;
  55977. /**
  55978. * Maximum about of steps between frames (Default: 4)
  55979. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55980. */
  55981. lockstepMaxSteps: number;
  55982. /**
  55983. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  55984. */
  55985. useHighPrecisionMatrix?: boolean;
  55986. }
  55987. /**
  55988. * The null engine class provides support for headless version of babylon.js.
  55989. * This can be used in server side scenario or for testing purposes
  55990. */
  55991. export class NullEngine extends Engine {
  55992. private _options;
  55993. /**
  55994. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  55995. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55996. * @returns true if engine is in deterministic lock step mode
  55997. */
  55998. isDeterministicLockStep(): boolean;
  55999. /**
  56000. * Gets the max steps when engine is running in deterministic lock step
  56001. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56002. * @returns the max steps
  56003. */
  56004. getLockstepMaxSteps(): number;
  56005. /**
  56006. * Gets the current hardware scaling level.
  56007. * By default the hardware scaling level is computed from the window device ratio.
  56008. * 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.
  56009. * @returns a number indicating the current hardware scaling level
  56010. */
  56011. getHardwareScalingLevel(): number;
  56012. constructor(options?: NullEngineOptions);
  56013. /**
  56014. * Creates a vertex buffer
  56015. * @param vertices the data for the vertex buffer
  56016. * @returns the new WebGL static buffer
  56017. */
  56018. createVertexBuffer(vertices: FloatArray): DataBuffer;
  56019. /**
  56020. * Creates a new index buffer
  56021. * @param indices defines the content of the index buffer
  56022. * @param updatable defines if the index buffer must be updatable
  56023. * @returns a new webGL buffer
  56024. */
  56025. createIndexBuffer(indices: IndicesArray): DataBuffer;
  56026. /**
  56027. * Clear the current render buffer or the current render target (if any is set up)
  56028. * @param color defines the color to use
  56029. * @param backBuffer defines if the back buffer must be cleared
  56030. * @param depth defines if the depth buffer must be cleared
  56031. * @param stencil defines if the stencil buffer must be cleared
  56032. */
  56033. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56034. /**
  56035. * Gets the current render width
  56036. * @param useScreen defines if screen size must be used (or the current render target if any)
  56037. * @returns a number defining the current render width
  56038. */
  56039. getRenderWidth(useScreen?: boolean): number;
  56040. /**
  56041. * Gets the current render height
  56042. * @param useScreen defines if screen size must be used (or the current render target if any)
  56043. * @returns a number defining the current render height
  56044. */
  56045. getRenderHeight(useScreen?: boolean): number;
  56046. /**
  56047. * Set the WebGL's viewport
  56048. * @param viewport defines the viewport element to be used
  56049. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  56050. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  56051. */
  56052. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  56053. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  56054. /**
  56055. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  56056. * @param pipelineContext defines the pipeline context to use
  56057. * @param uniformsNames defines the list of uniform names
  56058. * @returns an array of webGL uniform locations
  56059. */
  56060. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  56061. /**
  56062. * Gets the lsit of active attributes for a given webGL program
  56063. * @param pipelineContext defines the pipeline context to use
  56064. * @param attributesNames defines the list of attribute names to get
  56065. * @returns an array of indices indicating the offset of each attribute
  56066. */
  56067. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56068. /**
  56069. * Binds an effect to the webGL context
  56070. * @param effect defines the effect to bind
  56071. */
  56072. bindSamplers(effect: Effect): void;
  56073. /**
  56074. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  56075. * @param effect defines the effect to activate
  56076. */
  56077. enableEffect(effect: Effect): void;
  56078. /**
  56079. * Set various states to the webGL context
  56080. * @param culling defines backface culling state
  56081. * @param zOffset defines the value to apply to zOffset (0 by default)
  56082. * @param force defines if states must be applied even if cache is up to date
  56083. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  56084. */
  56085. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56086. /**
  56087. * Set the value of an uniform to an array of int32
  56088. * @param uniform defines the webGL uniform location where to store the value
  56089. * @param array defines the array of int32 to store
  56090. * @returns true if value was set
  56091. */
  56092. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56093. /**
  56094. * Set the value of an uniform to an array of int32 (stored as vec2)
  56095. * @param uniform defines the webGL uniform location where to store the value
  56096. * @param array defines the array of int32 to store
  56097. * @returns true if value was set
  56098. */
  56099. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56100. /**
  56101. * Set the value of an uniform to an array of int32 (stored as vec3)
  56102. * @param uniform defines the webGL uniform location where to store the value
  56103. * @param array defines the array of int32 to store
  56104. * @returns true if value was set
  56105. */
  56106. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56107. /**
  56108. * Set the value of an uniform to an array of int32 (stored as vec4)
  56109. * @param uniform defines the webGL uniform location where to store the value
  56110. * @param array defines the array of int32 to store
  56111. * @returns true if value was set
  56112. */
  56113. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56114. /**
  56115. * Set the value of an uniform to an array of float32
  56116. * @param uniform defines the webGL uniform location where to store the value
  56117. * @param array defines the array of float32 to store
  56118. * @returns true if value was set
  56119. */
  56120. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56121. /**
  56122. * Set the value of an uniform to an array of float32 (stored as vec2)
  56123. * @param uniform defines the webGL uniform location where to store the value
  56124. * @param array defines the array of float32 to store
  56125. * @returns true if value was set
  56126. */
  56127. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56128. /**
  56129. * Set the value of an uniform to an array of float32 (stored as vec3)
  56130. * @param uniform defines the webGL uniform location where to store the value
  56131. * @param array defines the array of float32 to store
  56132. * @returns true if value was set
  56133. */
  56134. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56135. /**
  56136. * Set the value of an uniform to an array of float32 (stored as vec4)
  56137. * @param uniform defines the webGL uniform location where to store the value
  56138. * @param array defines the array of float32 to store
  56139. * @returns true if value was set
  56140. */
  56141. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56142. /**
  56143. * Set the value of an uniform to an array of number
  56144. * @param uniform defines the webGL uniform location where to store the value
  56145. * @param array defines the array of number to store
  56146. * @returns true if value was set
  56147. */
  56148. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56149. /**
  56150. * Set the value of an uniform to an array of number (stored as vec2)
  56151. * @param uniform defines the webGL uniform location where to store the value
  56152. * @param array defines the array of number to store
  56153. * @returns true if value was set
  56154. */
  56155. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56156. /**
  56157. * Set the value of an uniform to an array of number (stored as vec3)
  56158. * @param uniform defines the webGL uniform location where to store the value
  56159. * @param array defines the array of number to store
  56160. * @returns true if value was set
  56161. */
  56162. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56163. /**
  56164. * Set the value of an uniform to an array of number (stored as vec4)
  56165. * @param uniform defines the webGL uniform location where to store the value
  56166. * @param array defines the array of number to store
  56167. * @returns true if value was set
  56168. */
  56169. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56170. /**
  56171. * Set the value of an uniform to an array of float32 (stored as matrices)
  56172. * @param uniform defines the webGL uniform location where to store the value
  56173. * @param matrices defines the array of float32 to store
  56174. * @returns true if value was set
  56175. */
  56176. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56177. /**
  56178. * Set the value of an uniform to a matrix (3x3)
  56179. * @param uniform defines the webGL uniform location where to store the value
  56180. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  56181. * @returns true if value was set
  56182. */
  56183. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56184. /**
  56185. * Set the value of an uniform to a matrix (2x2)
  56186. * @param uniform defines the webGL uniform location where to store the value
  56187. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  56188. * @returns true if value was set
  56189. */
  56190. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56191. /**
  56192. * Set the value of an uniform to a number (float)
  56193. * @param uniform defines the webGL uniform location where to store the value
  56194. * @param value defines the float number to store
  56195. * @returns true if value was set
  56196. */
  56197. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56198. /**
  56199. * Set the value of an uniform to a vec2
  56200. * @param uniform defines the webGL uniform location where to store the value
  56201. * @param x defines the 1st component of the value
  56202. * @param y defines the 2nd component of the value
  56203. * @returns true if value was set
  56204. */
  56205. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56206. /**
  56207. * Set the value of an uniform to a vec3
  56208. * @param uniform defines the webGL uniform location where to store the value
  56209. * @param x defines the 1st component of the value
  56210. * @param y defines the 2nd component of the value
  56211. * @param z defines the 3rd component of the value
  56212. * @returns true if value was set
  56213. */
  56214. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56215. /**
  56216. * Set the value of an uniform to a boolean
  56217. * @param uniform defines the webGL uniform location where to store the value
  56218. * @param bool defines the boolean to store
  56219. * @returns true if value was set
  56220. */
  56221. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  56222. /**
  56223. * Set the value of an uniform to a vec4
  56224. * @param uniform defines the webGL uniform location where to store the value
  56225. * @param x defines the 1st component of the value
  56226. * @param y defines the 2nd component of the value
  56227. * @param z defines the 3rd component of the value
  56228. * @param w defines the 4th component of the value
  56229. * @returns true if value was set
  56230. */
  56231. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56232. /**
  56233. * Sets the current alpha mode
  56234. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  56235. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56236. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56237. */
  56238. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56239. /**
  56240. * Bind webGl buffers directly to the webGL context
  56241. * @param vertexBuffers defines the vertex buffer to bind
  56242. * @param indexBuffer defines the index buffer to bind
  56243. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  56244. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  56245. * @param effect defines the effect associated with the vertex buffer
  56246. */
  56247. bindBuffers(vertexBuffers: {
  56248. [key: string]: VertexBuffer;
  56249. }, indexBuffer: DataBuffer, effect: Effect): void;
  56250. /**
  56251. * Force the entire cache to be cleared
  56252. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  56253. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  56254. */
  56255. wipeCaches(bruteForce?: boolean): void;
  56256. /**
  56257. * Send a draw order
  56258. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  56259. * @param indexStart defines the starting index
  56260. * @param indexCount defines the number of index to draw
  56261. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56262. */
  56263. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  56264. /**
  56265. * Draw a list of indexed primitives
  56266. * @param fillMode defines the primitive to use
  56267. * @param indexStart defines the starting index
  56268. * @param indexCount defines the number of index to draw
  56269. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56270. */
  56271. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56272. /**
  56273. * Draw a list of unindexed primitives
  56274. * @param fillMode defines the primitive to use
  56275. * @param verticesStart defines the index of first vertex to draw
  56276. * @param verticesCount defines the count of vertices to draw
  56277. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56278. */
  56279. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56280. /** @hidden */
  56281. _createTexture(): WebGLTexture;
  56282. /** @hidden */
  56283. _releaseTexture(texture: InternalTexture): void;
  56284. /**
  56285. * Usually called from Texture.ts.
  56286. * Passed information to create a WebGLTexture
  56287. * @param urlArg defines a value which contains one of the following:
  56288. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56289. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56290. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56291. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56292. * @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)
  56293. * @param scene needed for loading to the correct scene
  56294. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56295. * @param onLoad optional callback to be called upon successful completion
  56296. * @param onError optional callback to be called upon failure
  56297. * @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
  56298. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56299. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56300. * @param forcedExtension defines the extension to use to pick the right loader
  56301. * @param mimeType defines an optional mime type
  56302. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56303. */
  56304. 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;
  56305. /**
  56306. * Creates a new render target texture
  56307. * @param size defines the size of the texture
  56308. * @param options defines the options used to create the texture
  56309. * @returns a new render target texture stored in an InternalTexture
  56310. */
  56311. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  56312. /**
  56313. * Update the sampling mode of a given texture
  56314. * @param samplingMode defines the required sampling mode
  56315. * @param texture defines the texture to update
  56316. */
  56317. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56318. /**
  56319. * Binds the frame buffer to the specified texture.
  56320. * @param texture The texture to render to or null for the default canvas
  56321. * @param faceIndex The face of the texture to render to in case of cube texture
  56322. * @param requiredWidth The width of the target to render to
  56323. * @param requiredHeight The height of the target to render to
  56324. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  56325. * @param lodLevel defines le lod level to bind to the frame buffer
  56326. */
  56327. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56328. /**
  56329. * Unbind the current render target texture from the webGL context
  56330. * @param texture defines the render target texture to unbind
  56331. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  56332. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  56333. */
  56334. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56335. /**
  56336. * Creates a dynamic vertex buffer
  56337. * @param vertices the data for the dynamic vertex buffer
  56338. * @returns the new WebGL dynamic buffer
  56339. */
  56340. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  56341. /**
  56342. * Update the content of a dynamic texture
  56343. * @param texture defines the texture to update
  56344. * @param canvas defines the canvas containing the source
  56345. * @param invertY defines if data must be stored with Y axis inverted
  56346. * @param premulAlpha defines if alpha is stored as premultiplied
  56347. * @param format defines the format of the data
  56348. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56349. */
  56350. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56351. /**
  56352. * Gets a boolean indicating if all created effects are ready
  56353. * @returns true if all effects are ready
  56354. */
  56355. areAllEffectsReady(): boolean;
  56356. /**
  56357. * @hidden
  56358. * Get the current error code of the webGL context
  56359. * @returns the error code
  56360. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  56361. */
  56362. getError(): number;
  56363. /** @hidden */
  56364. _getUnpackAlignement(): number;
  56365. /** @hidden */
  56366. _unpackFlipY(value: boolean): void;
  56367. /**
  56368. * Update a dynamic index buffer
  56369. * @param indexBuffer defines the target index buffer
  56370. * @param indices defines the data to update
  56371. * @param offset defines the offset in the target index buffer where update should start
  56372. */
  56373. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  56374. /**
  56375. * Updates a dynamic vertex buffer.
  56376. * @param vertexBuffer the vertex buffer to update
  56377. * @param vertices the data used to update the vertex buffer
  56378. * @param byteOffset the byte offset of the data (optional)
  56379. * @param byteLength the byte length of the data (optional)
  56380. */
  56381. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  56382. /** @hidden */
  56383. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  56384. /** @hidden */
  56385. _bindTexture(channel: number, texture: InternalTexture): void;
  56386. protected _deleteBuffer(buffer: WebGLBuffer): void;
  56387. /**
  56388. * 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
  56389. */
  56390. releaseEffects(): void;
  56391. displayLoadingUI(): void;
  56392. hideLoadingUI(): void;
  56393. /** @hidden */
  56394. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56395. /** @hidden */
  56396. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56397. /** @hidden */
  56398. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56399. /** @hidden */
  56400. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56401. }
  56402. }
  56403. declare module BABYLON {
  56404. /**
  56405. * @hidden
  56406. **/
  56407. export class _TimeToken {
  56408. _startTimeQuery: Nullable<WebGLQuery>;
  56409. _endTimeQuery: Nullable<WebGLQuery>;
  56410. _timeElapsedQuery: Nullable<WebGLQuery>;
  56411. _timeElapsedQueryEnded: boolean;
  56412. }
  56413. }
  56414. declare module BABYLON {
  56415. /** @hidden */
  56416. export class _OcclusionDataStorage {
  56417. /** @hidden */
  56418. occlusionInternalRetryCounter: number;
  56419. /** @hidden */
  56420. isOcclusionQueryInProgress: boolean;
  56421. /** @hidden */
  56422. isOccluded: boolean;
  56423. /** @hidden */
  56424. occlusionRetryCount: number;
  56425. /** @hidden */
  56426. occlusionType: number;
  56427. /** @hidden */
  56428. occlusionQueryAlgorithmType: number;
  56429. }
  56430. interface Engine {
  56431. /**
  56432. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  56433. * @return the new query
  56434. */
  56435. createQuery(): WebGLQuery;
  56436. /**
  56437. * Delete and release a webGL query
  56438. * @param query defines the query to delete
  56439. * @return the current engine
  56440. */
  56441. deleteQuery(query: WebGLQuery): Engine;
  56442. /**
  56443. * Check if a given query has resolved and got its value
  56444. * @param query defines the query to check
  56445. * @returns true if the query got its value
  56446. */
  56447. isQueryResultAvailable(query: WebGLQuery): boolean;
  56448. /**
  56449. * Gets the value of a given query
  56450. * @param query defines the query to check
  56451. * @returns the value of the query
  56452. */
  56453. getQueryResult(query: WebGLQuery): number;
  56454. /**
  56455. * Initiates an occlusion query
  56456. * @param algorithmType defines the algorithm to use
  56457. * @param query defines the query to use
  56458. * @returns the current engine
  56459. * @see https://doc.babylonjs.com/features/occlusionquery
  56460. */
  56461. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  56462. /**
  56463. * Ends an occlusion query
  56464. * @see https://doc.babylonjs.com/features/occlusionquery
  56465. * @param algorithmType defines the algorithm to use
  56466. * @returns the current engine
  56467. */
  56468. endOcclusionQuery(algorithmType: number): Engine;
  56469. /**
  56470. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  56471. * Please note that only one query can be issued at a time
  56472. * @returns a time token used to track the time span
  56473. */
  56474. startTimeQuery(): Nullable<_TimeToken>;
  56475. /**
  56476. * Ends a time query
  56477. * @param token defines the token used to measure the time span
  56478. * @returns the time spent (in ns)
  56479. */
  56480. endTimeQuery(token: _TimeToken): int;
  56481. /** @hidden */
  56482. _currentNonTimestampToken: Nullable<_TimeToken>;
  56483. /** @hidden */
  56484. _createTimeQuery(): WebGLQuery;
  56485. /** @hidden */
  56486. _deleteTimeQuery(query: WebGLQuery): void;
  56487. /** @hidden */
  56488. _getGlAlgorithmType(algorithmType: number): number;
  56489. /** @hidden */
  56490. _getTimeQueryResult(query: WebGLQuery): any;
  56491. /** @hidden */
  56492. _getTimeQueryAvailability(query: WebGLQuery): any;
  56493. }
  56494. interface AbstractMesh {
  56495. /**
  56496. * Backing filed
  56497. * @hidden
  56498. */
  56499. __occlusionDataStorage: _OcclusionDataStorage;
  56500. /**
  56501. * Access property
  56502. * @hidden
  56503. */
  56504. _occlusionDataStorage: _OcclusionDataStorage;
  56505. /**
  56506. * 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.
  56507. * The default value is -1 which means don't break the query and wait till the result
  56508. * @see https://doc.babylonjs.com/features/occlusionquery
  56509. */
  56510. occlusionRetryCount: number;
  56511. /**
  56512. * 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:
  56513. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  56514. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  56515. * * 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.
  56516. * @see https://doc.babylonjs.com/features/occlusionquery
  56517. */
  56518. occlusionType: number;
  56519. /**
  56520. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  56521. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  56522. * * 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.
  56523. * @see https://doc.babylonjs.com/features/occlusionquery
  56524. */
  56525. occlusionQueryAlgorithmType: number;
  56526. /**
  56527. * 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
  56528. * @see https://doc.babylonjs.com/features/occlusionquery
  56529. */
  56530. isOccluded: boolean;
  56531. /**
  56532. * Flag to check the progress status of the query
  56533. * @see https://doc.babylonjs.com/features/occlusionquery
  56534. */
  56535. isOcclusionQueryInProgress: boolean;
  56536. }
  56537. }
  56538. declare module BABYLON {
  56539. /** @hidden */
  56540. export var _forceTransformFeedbackToBundle: boolean;
  56541. interface Engine {
  56542. /**
  56543. * Creates a webGL transform feedback object
  56544. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  56545. * @returns the webGL transform feedback object
  56546. */
  56547. createTransformFeedback(): WebGLTransformFeedback;
  56548. /**
  56549. * Delete a webGL transform feedback object
  56550. * @param value defines the webGL transform feedback object to delete
  56551. */
  56552. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  56553. /**
  56554. * Bind a webGL transform feedback object to the webgl context
  56555. * @param value defines the webGL transform feedback object to bind
  56556. */
  56557. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  56558. /**
  56559. * Begins a transform feedback operation
  56560. * @param usePoints defines if points or triangles must be used
  56561. */
  56562. beginTransformFeedback(usePoints: boolean): void;
  56563. /**
  56564. * Ends a transform feedback operation
  56565. */
  56566. endTransformFeedback(): void;
  56567. /**
  56568. * Specify the varyings to use with transform feedback
  56569. * @param program defines the associated webGL program
  56570. * @param value defines the list of strings representing the varying names
  56571. */
  56572. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  56573. /**
  56574. * Bind a webGL buffer for a transform feedback operation
  56575. * @param value defines the webGL buffer to bind
  56576. */
  56577. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  56578. }
  56579. }
  56580. declare module BABYLON {
  56581. /**
  56582. * Class used to define an additional view for the engine
  56583. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56584. */
  56585. export class EngineView {
  56586. /** Defines the canvas where to render the view */
  56587. target: HTMLCanvasElement;
  56588. /** Defines an optional camera used to render the view (will use active camera else) */
  56589. camera?: Camera;
  56590. }
  56591. interface Engine {
  56592. /**
  56593. * Gets or sets the HTML element to use for attaching events
  56594. */
  56595. inputElement: Nullable<HTMLElement>;
  56596. /**
  56597. * Gets the current engine view
  56598. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56599. */
  56600. activeView: Nullable<EngineView>;
  56601. /** Gets or sets the list of views */
  56602. views: EngineView[];
  56603. /**
  56604. * Register a new child canvas
  56605. * @param canvas defines the canvas to register
  56606. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  56607. * @returns the associated view
  56608. */
  56609. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  56610. /**
  56611. * Remove a registered child canvas
  56612. * @param canvas defines the canvas to remove
  56613. * @returns the current engine
  56614. */
  56615. unRegisterView(canvas: HTMLCanvasElement): Engine;
  56616. }
  56617. }
  56618. declare module BABYLON {
  56619. interface Engine {
  56620. /** @hidden */
  56621. _excludedCompressedTextures: string[];
  56622. /** @hidden */
  56623. _textureFormatInUse: string;
  56624. /**
  56625. * Gets the list of texture formats supported
  56626. */
  56627. readonly texturesSupported: Array<string>;
  56628. /**
  56629. * Gets the texture format in use
  56630. */
  56631. readonly textureFormatInUse: Nullable<string>;
  56632. /**
  56633. * Set the compressed texture extensions or file names to skip.
  56634. *
  56635. * @param skippedFiles defines the list of those texture files you want to skip
  56636. * Example: [".dds", ".env", "myfile.png"]
  56637. */
  56638. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  56639. /**
  56640. * Set the compressed texture format to use, based on the formats you have, and the formats
  56641. * supported by the hardware / browser.
  56642. *
  56643. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  56644. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  56645. * to API arguments needed to compressed textures. This puts the burden on the container
  56646. * generator to house the arcane code for determining these for current & future formats.
  56647. *
  56648. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56649. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56650. *
  56651. * Note: The result of this call is not taken into account when a texture is base64.
  56652. *
  56653. * @param formatsAvailable defines the list of those format families you have created
  56654. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  56655. *
  56656. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  56657. * @returns The extension selected.
  56658. */
  56659. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  56660. }
  56661. }
  56662. declare module BABYLON {
  56663. /** @hidden */
  56664. export var rgbdEncodePixelShader: {
  56665. name: string;
  56666. shader: string;
  56667. };
  56668. }
  56669. declare module BABYLON {
  56670. /**
  56671. * Raw texture data and descriptor sufficient for WebGL texture upload
  56672. */
  56673. export interface EnvironmentTextureInfo {
  56674. /**
  56675. * Version of the environment map
  56676. */
  56677. version: number;
  56678. /**
  56679. * Width of image
  56680. */
  56681. width: number;
  56682. /**
  56683. * Irradiance information stored in the file.
  56684. */
  56685. irradiance: any;
  56686. /**
  56687. * Specular information stored in the file.
  56688. */
  56689. specular: any;
  56690. }
  56691. /**
  56692. * Defines One Image in the file. It requires only the position in the file
  56693. * as well as the length.
  56694. */
  56695. interface BufferImageData {
  56696. /**
  56697. * Length of the image data.
  56698. */
  56699. length: number;
  56700. /**
  56701. * Position of the data from the null terminator delimiting the end of the JSON.
  56702. */
  56703. position: number;
  56704. }
  56705. /**
  56706. * Defines the specular data enclosed in the file.
  56707. * This corresponds to the version 1 of the data.
  56708. */
  56709. export interface EnvironmentTextureSpecularInfoV1 {
  56710. /**
  56711. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  56712. */
  56713. specularDataPosition?: number;
  56714. /**
  56715. * This contains all the images data needed to reconstruct the cubemap.
  56716. */
  56717. mipmaps: Array<BufferImageData>;
  56718. /**
  56719. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  56720. */
  56721. lodGenerationScale: number;
  56722. }
  56723. /**
  56724. * Sets of helpers addressing the serialization and deserialization of environment texture
  56725. * stored in a BabylonJS env file.
  56726. * Those files are usually stored as .env files.
  56727. */
  56728. export class EnvironmentTextureTools {
  56729. /**
  56730. * Magic number identifying the env file.
  56731. */
  56732. private static _MagicBytes;
  56733. /**
  56734. * Gets the environment info from an env file.
  56735. * @param data The array buffer containing the .env bytes.
  56736. * @returns the environment file info (the json header) if successfully parsed.
  56737. */
  56738. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56739. /**
  56740. * Creates an environment texture from a loaded cube texture.
  56741. * @param texture defines the cube texture to convert in env file
  56742. * @return a promise containing the environment data if succesfull.
  56743. */
  56744. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56745. /**
  56746. * Creates a JSON representation of the spherical data.
  56747. * @param texture defines the texture containing the polynomials
  56748. * @return the JSON representation of the spherical info
  56749. */
  56750. private static _CreateEnvTextureIrradiance;
  56751. /**
  56752. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56753. * @param data the image data
  56754. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56755. * @return the views described by info providing access to the underlying buffer
  56756. */
  56757. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  56758. /**
  56759. * Uploads the texture info contained in the env file to the GPU.
  56760. * @param texture defines the internal texture to upload to
  56761. * @param data defines the data to load
  56762. * @param info defines the texture info retrieved through the GetEnvInfo method
  56763. * @returns a promise
  56764. */
  56765. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  56766. private static _OnImageReadyAsync;
  56767. /**
  56768. * Uploads the levels of image data to the GPU.
  56769. * @param texture defines the internal texture to upload to
  56770. * @param imageData defines the array buffer views of image data [mipmap][face]
  56771. * @returns a promise
  56772. */
  56773. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  56774. /**
  56775. * Uploads spherical polynomials information to the texture.
  56776. * @param texture defines the texture we are trying to upload the information to
  56777. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  56778. */
  56779. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  56780. /** @hidden */
  56781. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56782. }
  56783. }
  56784. declare module BABYLON {
  56785. /**
  56786. * Class used to inline functions in shader code
  56787. */
  56788. export class ShaderCodeInliner {
  56789. private static readonly _RegexpFindFunctionNameAndType;
  56790. private _sourceCode;
  56791. private _functionDescr;
  56792. private _numMaxIterations;
  56793. /** Gets or sets the token used to mark the functions to inline */
  56794. inlineToken: string;
  56795. /** Gets or sets the debug mode */
  56796. debug: boolean;
  56797. /** Gets the code after the inlining process */
  56798. get code(): string;
  56799. /**
  56800. * Initializes the inliner
  56801. * @param sourceCode shader code source to inline
  56802. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  56803. */
  56804. constructor(sourceCode: string, numMaxIterations?: number);
  56805. /**
  56806. * Start the processing of the shader code
  56807. */
  56808. processCode(): void;
  56809. private _collectFunctions;
  56810. private _processInlining;
  56811. private _extractBetweenMarkers;
  56812. private _skipWhitespaces;
  56813. private _removeComments;
  56814. private _replaceFunctionCallsByCode;
  56815. private _findBackward;
  56816. private _escapeRegExp;
  56817. private _replaceNames;
  56818. }
  56819. }
  56820. declare module BABYLON {
  56821. /**
  56822. * Container for accessors for natively-stored mesh data buffers.
  56823. */
  56824. class NativeDataBuffer extends DataBuffer {
  56825. /**
  56826. * Accessor value used to identify/retrieve a natively-stored index buffer.
  56827. */
  56828. nativeIndexBuffer?: any;
  56829. /**
  56830. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  56831. */
  56832. nativeVertexBuffer?: any;
  56833. }
  56834. /** @hidden */
  56835. class NativeTexture extends InternalTexture {
  56836. getInternalTexture(): InternalTexture;
  56837. getViewCount(): number;
  56838. }
  56839. /** @hidden */
  56840. export class NativeEngine extends Engine {
  56841. private readonly _native;
  56842. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  56843. private readonly INVALID_HANDLE;
  56844. private _boundBuffersVertexArray;
  56845. private _currentDepthTest;
  56846. getHardwareScalingLevel(): number;
  56847. constructor();
  56848. dispose(): void;
  56849. /**
  56850. * Can be used to override the current requestAnimationFrame requester.
  56851. * @hidden
  56852. */
  56853. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  56854. /**
  56855. * Override default engine behavior.
  56856. * @param color
  56857. * @param backBuffer
  56858. * @param depth
  56859. * @param stencil
  56860. */
  56861. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  56862. /**
  56863. * Gets host document
  56864. * @returns the host document object
  56865. */
  56866. getHostDocument(): Nullable<Document>;
  56867. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56868. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  56869. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  56870. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  56871. [key: string]: VertexBuffer;
  56872. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56873. bindBuffers(vertexBuffers: {
  56874. [key: string]: VertexBuffer;
  56875. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56876. recordVertexArrayObject(vertexBuffers: {
  56877. [key: string]: VertexBuffer;
  56878. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  56879. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56880. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56881. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56882. /**
  56883. * Draw a list of indexed primitives
  56884. * @param fillMode defines the primitive to use
  56885. * @param indexStart defines the starting index
  56886. * @param indexCount defines the number of index to draw
  56887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56888. */
  56889. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56890. /**
  56891. * Draw a list of unindexed primitives
  56892. * @param fillMode defines the primitive to use
  56893. * @param verticesStart defines the index of first vertex to draw
  56894. * @param verticesCount defines the count of vertices to draw
  56895. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56896. */
  56897. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56898. createPipelineContext(): IPipelineContext;
  56899. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  56900. /** @hidden */
  56901. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  56902. /** @hidden */
  56903. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  56904. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56905. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56906. protected _setProgram(program: WebGLProgram): void;
  56907. _releaseEffect(effect: Effect): void;
  56908. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  56909. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  56910. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  56911. bindSamplers(effect: Effect): void;
  56912. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  56913. getRenderWidth(useScreen?: boolean): number;
  56914. getRenderHeight(useScreen?: boolean): number;
  56915. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  56916. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56917. /**
  56918. * Set the z offset to apply to current rendering
  56919. * @param value defines the offset to apply
  56920. */
  56921. setZOffset(value: number): void;
  56922. /**
  56923. * Gets the current value of the zOffset
  56924. * @returns the current zOffset state
  56925. */
  56926. getZOffset(): number;
  56927. /**
  56928. * Enable or disable depth buffering
  56929. * @param enable defines the state to set
  56930. */
  56931. setDepthBuffer(enable: boolean): void;
  56932. /**
  56933. * Gets a boolean indicating if depth writing is enabled
  56934. * @returns the current depth writing state
  56935. */
  56936. getDepthWrite(): boolean;
  56937. setDepthFunctionToGreater(): void;
  56938. setDepthFunctionToGreaterOrEqual(): void;
  56939. setDepthFunctionToLess(): void;
  56940. setDepthFunctionToLessOrEqual(): void;
  56941. /**
  56942. * Enable or disable depth writing
  56943. * @param enable defines the state to set
  56944. */
  56945. setDepthWrite(enable: boolean): void;
  56946. /**
  56947. * Enable or disable color writing
  56948. * @param enable defines the state to set
  56949. */
  56950. setColorWrite(enable: boolean): void;
  56951. /**
  56952. * Gets a boolean indicating if color writing is enabled
  56953. * @returns the current color writing state
  56954. */
  56955. getColorWrite(): boolean;
  56956. /**
  56957. * Sets alpha constants used by some alpha blending modes
  56958. * @param r defines the red component
  56959. * @param g defines the green component
  56960. * @param b defines the blue component
  56961. * @param a defines the alpha component
  56962. */
  56963. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  56964. /**
  56965. * Sets the current alpha mode
  56966. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  56967. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56968. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56969. */
  56970. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56971. /**
  56972. * Gets the current alpha mode
  56973. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56974. * @returns the current alpha mode
  56975. */
  56976. getAlphaMode(): number;
  56977. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  56978. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56979. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56980. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56981. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56982. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56983. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56984. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56985. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56986. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56987. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56988. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56989. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56990. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56991. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56992. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56993. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56994. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56995. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56996. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56997. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  56998. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  56999. wipeCaches(bruteForce?: boolean): void;
  57000. _createTexture(): WebGLTexture;
  57001. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  57002. /**
  57003. * Update the content of a dynamic texture
  57004. * @param texture defines the texture to update
  57005. * @param canvas defines the canvas containing the source
  57006. * @param invertY defines if data must be stored with Y axis inverted
  57007. * @param premulAlpha defines if alpha is stored as premultiplied
  57008. * @param format defines the format of the data
  57009. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57010. */
  57011. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57012. /**
  57013. * Usually called from Texture.ts.
  57014. * Passed information to create a WebGLTexture
  57015. * @param url defines a value which contains one of the following:
  57016. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57017. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57018. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57019. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57020. * @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)
  57021. * @param scene needed for loading to the correct scene
  57022. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57023. * @param onLoad optional callback to be called upon successful completion
  57024. * @param onError optional callback to be called upon failure
  57025. * @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
  57026. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57027. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57028. * @param forcedExtension defines the extension to use to pick the right loader
  57029. * @param mimeType defines an optional mime type
  57030. * @param loaderOptions options to be passed to the loader
  57031. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57032. */
  57033. 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;
  57034. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  57035. _releaseFramebufferObjects(texture: InternalTexture): void;
  57036. /**
  57037. * Creates a cube texture
  57038. * @param rootUrl defines the url where the files to load is located
  57039. * @param scene defines the current scene
  57040. * @param files defines the list of files to load (1 per face)
  57041. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  57042. * @param onLoad defines an optional callback raised when the texture is loaded
  57043. * @param onError defines an optional callback raised if there is an issue to load the texture
  57044. * @param format defines the format of the data
  57045. * @param forcedExtension defines the extension to use to pick the right loader
  57046. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  57047. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57048. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57049. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  57050. * @returns the cube texture as an InternalTexture
  57051. */
  57052. 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;
  57053. createRenderTargetTexture(size: number | {
  57054. width: number;
  57055. height: number;
  57056. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  57057. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57058. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57059. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57060. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  57061. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  57062. /**
  57063. * Updates a dynamic vertex buffer.
  57064. * @param vertexBuffer the vertex buffer to update
  57065. * @param data the data used to update the vertex buffer
  57066. * @param byteOffset the byte offset of the data (optional)
  57067. * @param byteLength the byte length of the data (optional)
  57068. */
  57069. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  57070. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  57071. private _updateAnisotropicLevel;
  57072. private _getAddressMode;
  57073. /** @hidden */
  57074. _bindTexture(channel: number, texture: InternalTexture): void;
  57075. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  57076. releaseEffects(): void;
  57077. /** @hidden */
  57078. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57079. /** @hidden */
  57080. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57081. /** @hidden */
  57082. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57083. /** @hidden */
  57084. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57085. private _getNativeSamplingMode;
  57086. private _getNativeTextureFormat;
  57087. private _getNativeAlphaMode;
  57088. private _getNativeAttribType;
  57089. }
  57090. }
  57091. declare module BABYLON {
  57092. /**
  57093. * Gather the list of clipboard event types as constants.
  57094. */
  57095. export class ClipboardEventTypes {
  57096. /**
  57097. * The clipboard event is fired when a copy command is active (pressed).
  57098. */
  57099. static readonly COPY: number;
  57100. /**
  57101. * The clipboard event is fired when a cut command is active (pressed).
  57102. */
  57103. static readonly CUT: number;
  57104. /**
  57105. * The clipboard event is fired when a paste command is active (pressed).
  57106. */
  57107. static readonly PASTE: number;
  57108. }
  57109. /**
  57110. * This class is used to store clipboard related info for the onClipboardObservable event.
  57111. */
  57112. export class ClipboardInfo {
  57113. /**
  57114. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57115. */
  57116. type: number;
  57117. /**
  57118. * Defines the related dom event
  57119. */
  57120. event: ClipboardEvent;
  57121. /**
  57122. *Creates an instance of ClipboardInfo.
  57123. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  57124. * @param event Defines the related dom event
  57125. */
  57126. constructor(
  57127. /**
  57128. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57129. */
  57130. type: number,
  57131. /**
  57132. * Defines the related dom event
  57133. */
  57134. event: ClipboardEvent);
  57135. /**
  57136. * Get the clipboard event's type from the keycode.
  57137. * @param keyCode Defines the keyCode for the current keyboard event.
  57138. * @return {number}
  57139. */
  57140. static GetTypeFromCharacter(keyCode: number): number;
  57141. }
  57142. }
  57143. declare module BABYLON {
  57144. /**
  57145. * Google Daydream controller
  57146. */
  57147. export class DaydreamController extends WebVRController {
  57148. /**
  57149. * Base Url for the controller model.
  57150. */
  57151. static MODEL_BASE_URL: string;
  57152. /**
  57153. * File name for the controller model.
  57154. */
  57155. static MODEL_FILENAME: string;
  57156. /**
  57157. * Gamepad Id prefix used to identify Daydream Controller.
  57158. */
  57159. static readonly GAMEPAD_ID_PREFIX: string;
  57160. /**
  57161. * Creates a new DaydreamController from a gamepad
  57162. * @param vrGamepad the gamepad that the controller should be created from
  57163. */
  57164. constructor(vrGamepad: any);
  57165. /**
  57166. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57167. * @param scene scene in which to add meshes
  57168. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57169. */
  57170. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57171. /**
  57172. * Called once for each button that changed state since the last frame
  57173. * @param buttonIdx Which button index changed
  57174. * @param state New state of the button
  57175. * @param changes Which properties on the state changed since last frame
  57176. */
  57177. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57178. }
  57179. }
  57180. declare module BABYLON {
  57181. /**
  57182. * Gear VR Controller
  57183. */
  57184. export class GearVRController extends WebVRController {
  57185. /**
  57186. * Base Url for the controller model.
  57187. */
  57188. static MODEL_BASE_URL: string;
  57189. /**
  57190. * File name for the controller model.
  57191. */
  57192. static MODEL_FILENAME: string;
  57193. /**
  57194. * Gamepad Id prefix used to identify this controller.
  57195. */
  57196. static readonly GAMEPAD_ID_PREFIX: string;
  57197. private readonly _buttonIndexToObservableNameMap;
  57198. /**
  57199. * Creates a new GearVRController from a gamepad
  57200. * @param vrGamepad the gamepad that the controller should be created from
  57201. */
  57202. constructor(vrGamepad: any);
  57203. /**
  57204. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57205. * @param scene scene in which to add meshes
  57206. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57207. */
  57208. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57209. /**
  57210. * Called once for each button that changed state since the last frame
  57211. * @param buttonIdx Which button index changed
  57212. * @param state New state of the button
  57213. * @param changes Which properties on the state changed since last frame
  57214. */
  57215. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57216. }
  57217. }
  57218. declare module BABYLON {
  57219. /**
  57220. * Generic Controller
  57221. */
  57222. export class GenericController extends WebVRController {
  57223. /**
  57224. * Base Url for the controller model.
  57225. */
  57226. static readonly MODEL_BASE_URL: string;
  57227. /**
  57228. * File name for the controller model.
  57229. */
  57230. static readonly MODEL_FILENAME: string;
  57231. /**
  57232. * Creates a new GenericController from a gamepad
  57233. * @param vrGamepad the gamepad that the controller should be created from
  57234. */
  57235. constructor(vrGamepad: any);
  57236. /**
  57237. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57238. * @param scene scene in which to add meshes
  57239. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57240. */
  57241. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57242. /**
  57243. * Called once for each button that changed state since the last frame
  57244. * @param buttonIdx Which button index changed
  57245. * @param state New state of the button
  57246. * @param changes Which properties on the state changed since last frame
  57247. */
  57248. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57249. }
  57250. }
  57251. declare module BABYLON {
  57252. /**
  57253. * Oculus Touch Controller
  57254. */
  57255. export class OculusTouchController extends WebVRController {
  57256. /**
  57257. * Base Url for the controller model.
  57258. */
  57259. static MODEL_BASE_URL: string;
  57260. /**
  57261. * File name for the left controller model.
  57262. */
  57263. static MODEL_LEFT_FILENAME: string;
  57264. /**
  57265. * File name for the right controller model.
  57266. */
  57267. static MODEL_RIGHT_FILENAME: string;
  57268. /**
  57269. * Base Url for the Quest controller model.
  57270. */
  57271. static QUEST_MODEL_BASE_URL: string;
  57272. /**
  57273. * @hidden
  57274. * If the controllers are running on a device that needs the updated Quest controller models
  57275. */
  57276. static _IsQuest: boolean;
  57277. /**
  57278. * Fired when the secondary trigger on this controller is modified
  57279. */
  57280. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  57281. /**
  57282. * Fired when the thumb rest on this controller is modified
  57283. */
  57284. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  57285. /**
  57286. * Creates a new OculusTouchController from a gamepad
  57287. * @param vrGamepad the gamepad that the controller should be created from
  57288. */
  57289. constructor(vrGamepad: any);
  57290. /**
  57291. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57292. * @param scene scene in which to add meshes
  57293. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57294. */
  57295. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57296. /**
  57297. * Fired when the A button on this controller is modified
  57298. */
  57299. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57300. /**
  57301. * Fired when the B button on this controller is modified
  57302. */
  57303. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57304. /**
  57305. * Fired when the X button on this controller is modified
  57306. */
  57307. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57308. /**
  57309. * Fired when the Y button on this controller is modified
  57310. */
  57311. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57312. /**
  57313. * Called once for each button that changed state since the last frame
  57314. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  57315. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  57316. * 2) secondary trigger (same)
  57317. * 3) A (right) X (left), touch, pressed = value
  57318. * 4) B / Y
  57319. * 5) thumb rest
  57320. * @param buttonIdx Which button index changed
  57321. * @param state New state of the button
  57322. * @param changes Which properties on the state changed since last frame
  57323. */
  57324. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57325. }
  57326. }
  57327. declare module BABYLON {
  57328. /**
  57329. * Vive Controller
  57330. */
  57331. export class ViveController extends WebVRController {
  57332. /**
  57333. * Base Url for the controller model.
  57334. */
  57335. static MODEL_BASE_URL: string;
  57336. /**
  57337. * File name for the controller model.
  57338. */
  57339. static MODEL_FILENAME: string;
  57340. /**
  57341. * Creates a new ViveController from a gamepad
  57342. * @param vrGamepad the gamepad that the controller should be created from
  57343. */
  57344. constructor(vrGamepad: any);
  57345. /**
  57346. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57347. * @param scene scene in which to add meshes
  57348. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57349. */
  57350. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57351. /**
  57352. * Fired when the left button on this controller is modified
  57353. */
  57354. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57355. /**
  57356. * Fired when the right button on this controller is modified
  57357. */
  57358. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57359. /**
  57360. * Fired when the menu button on this controller is modified
  57361. */
  57362. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57363. /**
  57364. * Called once for each button that changed state since the last frame
  57365. * Vive mapping:
  57366. * 0: touchpad
  57367. * 1: trigger
  57368. * 2: left AND right buttons
  57369. * 3: menu button
  57370. * @param buttonIdx Which button index changed
  57371. * @param state New state of the button
  57372. * @param changes Which properties on the state changed since last frame
  57373. */
  57374. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57375. }
  57376. }
  57377. declare module BABYLON {
  57378. /**
  57379. * Defines the WindowsMotionController object that the state of the windows motion controller
  57380. */
  57381. export class WindowsMotionController extends WebVRController {
  57382. /**
  57383. * The base url used to load the left and right controller models
  57384. */
  57385. static MODEL_BASE_URL: string;
  57386. /**
  57387. * The name of the left controller model file
  57388. */
  57389. static MODEL_LEFT_FILENAME: string;
  57390. /**
  57391. * The name of the right controller model file
  57392. */
  57393. static MODEL_RIGHT_FILENAME: string;
  57394. /**
  57395. * The controller name prefix for this controller type
  57396. */
  57397. static readonly GAMEPAD_ID_PREFIX: string;
  57398. /**
  57399. * The controller id pattern for this controller type
  57400. */
  57401. private static readonly GAMEPAD_ID_PATTERN;
  57402. private _loadedMeshInfo;
  57403. protected readonly _mapping: {
  57404. buttons: string[];
  57405. buttonMeshNames: {
  57406. trigger: string;
  57407. menu: string;
  57408. grip: string;
  57409. thumbstick: string;
  57410. trackpad: string;
  57411. };
  57412. buttonObservableNames: {
  57413. trigger: string;
  57414. menu: string;
  57415. grip: string;
  57416. thumbstick: string;
  57417. trackpad: string;
  57418. };
  57419. axisMeshNames: string[];
  57420. pointingPoseMeshName: string;
  57421. };
  57422. /**
  57423. * Fired when the trackpad on this controller is clicked
  57424. */
  57425. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57426. /**
  57427. * Fired when the trackpad on this controller is modified
  57428. */
  57429. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57430. /**
  57431. * The current x and y values of this controller's trackpad
  57432. */
  57433. trackpad: StickValues;
  57434. /**
  57435. * Creates a new WindowsMotionController from a gamepad
  57436. * @param vrGamepad the gamepad that the controller should be created from
  57437. */
  57438. constructor(vrGamepad: any);
  57439. /**
  57440. * Fired when the trigger on this controller is modified
  57441. */
  57442. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57443. /**
  57444. * Fired when the menu button on this controller is modified
  57445. */
  57446. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57447. /**
  57448. * Fired when the grip button on this controller is modified
  57449. */
  57450. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57451. /**
  57452. * Fired when the thumbstick button on this controller is modified
  57453. */
  57454. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57455. /**
  57456. * Fired when the touchpad button on this controller is modified
  57457. */
  57458. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57459. /**
  57460. * Fired when the touchpad values on this controller are modified
  57461. */
  57462. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  57463. protected _updateTrackpad(): void;
  57464. /**
  57465. * Called once per frame by the engine.
  57466. */
  57467. update(): void;
  57468. /**
  57469. * Called once for each button that changed state since the last frame
  57470. * @param buttonIdx Which button index changed
  57471. * @param state New state of the button
  57472. * @param changes Which properties on the state changed since last frame
  57473. */
  57474. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57475. /**
  57476. * Moves the buttons on the controller mesh based on their current state
  57477. * @param buttonName the name of the button to move
  57478. * @param buttonValue the value of the button which determines the buttons new position
  57479. */
  57480. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  57481. /**
  57482. * Moves the axis on the controller mesh based on its current state
  57483. * @param axis the index of the axis
  57484. * @param axisValue the value of the axis which determines the meshes new position
  57485. * @hidden
  57486. */
  57487. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  57488. /**
  57489. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57490. * @param scene scene in which to add meshes
  57491. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57492. */
  57493. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  57494. /**
  57495. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  57496. * can be transformed by button presses and axes values, based on this._mapping.
  57497. *
  57498. * @param scene scene in which the meshes exist
  57499. * @param meshes list of meshes that make up the controller model to process
  57500. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  57501. */
  57502. private processModel;
  57503. private createMeshInfo;
  57504. /**
  57505. * Gets the ray of the controller in the direction the controller is pointing
  57506. * @param length the length the resulting ray should be
  57507. * @returns a ray in the direction the controller is pointing
  57508. */
  57509. getForwardRay(length?: number): Ray;
  57510. /**
  57511. * Disposes of the controller
  57512. */
  57513. dispose(): void;
  57514. }
  57515. /**
  57516. * This class represents a new windows motion controller in XR.
  57517. */
  57518. export class XRWindowsMotionController extends WindowsMotionController {
  57519. /**
  57520. * Changing the original WIndowsMotionController mapping to fir the new mapping
  57521. */
  57522. protected readonly _mapping: {
  57523. buttons: string[];
  57524. buttonMeshNames: {
  57525. trigger: string;
  57526. menu: string;
  57527. grip: string;
  57528. thumbstick: string;
  57529. trackpad: string;
  57530. };
  57531. buttonObservableNames: {
  57532. trigger: string;
  57533. menu: string;
  57534. grip: string;
  57535. thumbstick: string;
  57536. trackpad: string;
  57537. };
  57538. axisMeshNames: string[];
  57539. pointingPoseMeshName: string;
  57540. };
  57541. /**
  57542. * Construct a new XR-Based windows motion controller
  57543. *
  57544. * @param gamepadInfo the gamepad object from the browser
  57545. */
  57546. constructor(gamepadInfo: any);
  57547. /**
  57548. * holds the thumbstick values (X,Y)
  57549. */
  57550. thumbstickValues: StickValues;
  57551. /**
  57552. * Fired when the thumbstick on this controller is clicked
  57553. */
  57554. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  57555. /**
  57556. * Fired when the thumbstick on this controller is modified
  57557. */
  57558. onThumbstickValuesChangedObservable: Observable<StickValues>;
  57559. /**
  57560. * Fired when the touchpad button on this controller is modified
  57561. */
  57562. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57563. /**
  57564. * Fired when the touchpad values on this controller are modified
  57565. */
  57566. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57567. /**
  57568. * Fired when the thumbstick button on this controller is modified
  57569. * here to prevent breaking changes
  57570. */
  57571. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57572. /**
  57573. * updating the thumbstick(!) and not the trackpad.
  57574. * This is named this way due to the difference between WebVR and XR and to avoid
  57575. * changing the parent class.
  57576. */
  57577. protected _updateTrackpad(): void;
  57578. /**
  57579. * Disposes the class with joy
  57580. */
  57581. dispose(): void;
  57582. }
  57583. }
  57584. declare module BABYLON {
  57585. /**
  57586. * A directional light is defined by a direction (what a surprise!).
  57587. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57588. * 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.
  57589. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57590. */
  57591. export class DirectionalLight extends ShadowLight {
  57592. private _shadowFrustumSize;
  57593. /**
  57594. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57595. */
  57596. get shadowFrustumSize(): number;
  57597. /**
  57598. * Specifies a fix frustum size for the shadow generation.
  57599. */
  57600. set shadowFrustumSize(value: number);
  57601. private _shadowOrthoScale;
  57602. /**
  57603. * Gets the shadow projection scale against the optimal computed one.
  57604. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57605. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57606. */
  57607. get shadowOrthoScale(): number;
  57608. /**
  57609. * Sets the shadow projection scale against the optimal computed one.
  57610. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57611. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57612. */
  57613. set shadowOrthoScale(value: number);
  57614. /**
  57615. * Automatically compute the projection matrix to best fit (including all the casters)
  57616. * on each frame.
  57617. */
  57618. autoUpdateExtends: boolean;
  57619. /**
  57620. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57621. * on each frame. autoUpdateExtends must be set to true for this to work
  57622. */
  57623. autoCalcShadowZBounds: boolean;
  57624. private _orthoLeft;
  57625. private _orthoRight;
  57626. private _orthoTop;
  57627. private _orthoBottom;
  57628. /**
  57629. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57630. * The directional light is emitted from everywhere in the given direction.
  57631. * It can cast shadows.
  57632. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57633. * @param name The friendly name of the light
  57634. * @param direction The direction of the light
  57635. * @param scene The scene the light belongs to
  57636. */
  57637. constructor(name: string, direction: Vector3, scene: Scene);
  57638. /**
  57639. * Returns the string "DirectionalLight".
  57640. * @return The class name
  57641. */
  57642. getClassName(): string;
  57643. /**
  57644. * Returns the integer 1.
  57645. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57646. */
  57647. getTypeID(): number;
  57648. /**
  57649. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57650. * Returns the DirectionalLight Shadow projection matrix.
  57651. */
  57652. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57653. /**
  57654. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57655. * Returns the DirectionalLight Shadow projection matrix.
  57656. */
  57657. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57658. /**
  57659. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57660. * Returns the DirectionalLight Shadow projection matrix.
  57661. */
  57662. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57663. protected _buildUniformLayout(): void;
  57664. /**
  57665. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57666. * @param effect The effect to update
  57667. * @param lightIndex The index of the light in the effect to update
  57668. * @returns The directional light
  57669. */
  57670. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57671. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57672. /**
  57673. * Gets the minZ used for shadow according to both the scene and the light.
  57674. *
  57675. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57676. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57677. * @param activeCamera The camera we are returning the min for
  57678. * @returns the depth min z
  57679. */
  57680. getDepthMinZ(activeCamera: Camera): number;
  57681. /**
  57682. * Gets the maxZ used for shadow according to both the scene and the light.
  57683. *
  57684. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57685. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57686. * @param activeCamera The camera we are returning the max for
  57687. * @returns the depth max z
  57688. */
  57689. getDepthMaxZ(activeCamera: Camera): number;
  57690. /**
  57691. * Prepares the list of defines specific to the light type.
  57692. * @param defines the list of defines
  57693. * @param lightIndex defines the index of the light for the effect
  57694. */
  57695. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57696. }
  57697. }
  57698. declare module BABYLON {
  57699. /**
  57700. * Class containing static functions to help procedurally build meshes
  57701. */
  57702. export class HemisphereBuilder {
  57703. /**
  57704. * Creates a hemisphere mesh
  57705. * @param name defines the name of the mesh
  57706. * @param options defines the options used to create the mesh
  57707. * @param scene defines the hosting scene
  57708. * @returns the hemisphere mesh
  57709. */
  57710. static CreateHemisphere(name: string, options: {
  57711. segments?: number;
  57712. diameter?: number;
  57713. sideOrientation?: number;
  57714. }, scene: any): Mesh;
  57715. }
  57716. }
  57717. declare module BABYLON {
  57718. /**
  57719. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57720. * These values define a cone of light starting from the position, emitting toward the direction.
  57721. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57722. * and the exponent defines the speed of the decay of the light with distance (reach).
  57723. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57724. */
  57725. export class SpotLight extends ShadowLight {
  57726. private _angle;
  57727. private _innerAngle;
  57728. private _cosHalfAngle;
  57729. private _lightAngleScale;
  57730. private _lightAngleOffset;
  57731. /**
  57732. * Gets the cone angle of the spot light in Radians.
  57733. */
  57734. get angle(): number;
  57735. /**
  57736. * Sets the cone angle of the spot light in Radians.
  57737. */
  57738. set angle(value: number);
  57739. /**
  57740. * Only used in gltf falloff mode, this defines the angle where
  57741. * the directional falloff will start before cutting at angle which could be seen
  57742. * as outer angle.
  57743. */
  57744. get innerAngle(): number;
  57745. /**
  57746. * Only used in gltf falloff mode, this defines the angle where
  57747. * the directional falloff will start before cutting at angle which could be seen
  57748. * as outer angle.
  57749. */
  57750. set innerAngle(value: number);
  57751. private _shadowAngleScale;
  57752. /**
  57753. * Allows scaling the angle of the light for shadow generation only.
  57754. */
  57755. get shadowAngleScale(): number;
  57756. /**
  57757. * Allows scaling the angle of the light for shadow generation only.
  57758. */
  57759. set shadowAngleScale(value: number);
  57760. /**
  57761. * The light decay speed with the distance from the emission spot.
  57762. */
  57763. exponent: number;
  57764. private _projectionTextureMatrix;
  57765. /**
  57766. * Allows reading the projecton texture
  57767. */
  57768. get projectionTextureMatrix(): Matrix;
  57769. protected _projectionTextureLightNear: number;
  57770. /**
  57771. * Gets the near clip of the Spotlight for texture projection.
  57772. */
  57773. get projectionTextureLightNear(): number;
  57774. /**
  57775. * Sets the near clip of the Spotlight for texture projection.
  57776. */
  57777. set projectionTextureLightNear(value: number);
  57778. protected _projectionTextureLightFar: number;
  57779. /**
  57780. * Gets the far clip of the Spotlight for texture projection.
  57781. */
  57782. get projectionTextureLightFar(): number;
  57783. /**
  57784. * Sets the far clip of the Spotlight for texture projection.
  57785. */
  57786. set projectionTextureLightFar(value: number);
  57787. protected _projectionTextureUpDirection: Vector3;
  57788. /**
  57789. * Gets the Up vector of the Spotlight for texture projection.
  57790. */
  57791. get projectionTextureUpDirection(): Vector3;
  57792. /**
  57793. * Sets the Up vector of the Spotlight for texture projection.
  57794. */
  57795. set projectionTextureUpDirection(value: Vector3);
  57796. private _projectionTexture;
  57797. /**
  57798. * Gets the projection texture of the light.
  57799. */
  57800. get projectionTexture(): Nullable<BaseTexture>;
  57801. /**
  57802. * Sets the projection texture of the light.
  57803. */
  57804. set projectionTexture(value: Nullable<BaseTexture>);
  57805. private static _IsProceduralTexture;
  57806. private static _IsTexture;
  57807. private _projectionTextureViewLightDirty;
  57808. private _projectionTextureProjectionLightDirty;
  57809. private _projectionTextureDirty;
  57810. private _projectionTextureViewTargetVector;
  57811. private _projectionTextureViewLightMatrix;
  57812. private _projectionTextureProjectionLightMatrix;
  57813. private _projectionTextureScalingMatrix;
  57814. /**
  57815. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57816. * It can cast shadows.
  57817. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57818. * @param name The light friendly name
  57819. * @param position The position of the spot light in the scene
  57820. * @param direction The direction of the light in the scene
  57821. * @param angle The cone angle of the light in Radians
  57822. * @param exponent The light decay speed with the distance from the emission spot
  57823. * @param scene The scene the lights belongs to
  57824. */
  57825. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57826. /**
  57827. * Returns the string "SpotLight".
  57828. * @returns the class name
  57829. */
  57830. getClassName(): string;
  57831. /**
  57832. * Returns the integer 2.
  57833. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57834. */
  57835. getTypeID(): number;
  57836. /**
  57837. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57838. */
  57839. protected _setDirection(value: Vector3): void;
  57840. /**
  57841. * Overrides the position setter to recompute the projection texture view light Matrix.
  57842. */
  57843. protected _setPosition(value: Vector3): void;
  57844. /**
  57845. * 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.
  57846. * Returns the SpotLight.
  57847. */
  57848. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57849. protected _computeProjectionTextureViewLightMatrix(): void;
  57850. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57851. /**
  57852. * Main function for light texture projection matrix computing.
  57853. */
  57854. protected _computeProjectionTextureMatrix(): void;
  57855. protected _buildUniformLayout(): void;
  57856. private _computeAngleValues;
  57857. /**
  57858. * Sets the passed Effect "effect" with the Light textures.
  57859. * @param effect The effect to update
  57860. * @param lightIndex The index of the light in the effect to update
  57861. * @returns The light
  57862. */
  57863. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57864. /**
  57865. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57866. * @param effect The effect to update
  57867. * @param lightIndex The index of the light in the effect to update
  57868. * @returns The spot light
  57869. */
  57870. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57871. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57872. /**
  57873. * Disposes the light and the associated resources.
  57874. */
  57875. dispose(): void;
  57876. /**
  57877. * Prepares the list of defines specific to the light type.
  57878. * @param defines the list of defines
  57879. * @param lightIndex defines the index of the light for the effect
  57880. */
  57881. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57882. }
  57883. }
  57884. declare module BABYLON {
  57885. /**
  57886. * Gizmo that enables viewing a light
  57887. */
  57888. export class LightGizmo extends Gizmo {
  57889. private _lightMesh;
  57890. private _material;
  57891. private _cachedPosition;
  57892. private _cachedForward;
  57893. private _attachedMeshParent;
  57894. private _pointerObserver;
  57895. /**
  57896. * Event that fires each time the gizmo is clicked
  57897. */
  57898. onClickedObservable: Observable<Light>;
  57899. /**
  57900. * Creates a LightGizmo
  57901. * @param gizmoLayer The utility layer the gizmo will be added to
  57902. */
  57903. constructor(gizmoLayer?: UtilityLayerRenderer);
  57904. private _light;
  57905. /**
  57906. * The light that the gizmo is attached to
  57907. */
  57908. set light(light: Nullable<Light>);
  57909. get light(): Nullable<Light>;
  57910. /**
  57911. * Gets the material used to render the light gizmo
  57912. */
  57913. get material(): StandardMaterial;
  57914. /**
  57915. * @hidden
  57916. * Updates the gizmo to match the attached mesh's position/rotation
  57917. */
  57918. protected _update(): void;
  57919. private static _Scale;
  57920. /**
  57921. * Creates the lines for a light mesh
  57922. */
  57923. private static _CreateLightLines;
  57924. /**
  57925. * Disposes of the light gizmo
  57926. */
  57927. dispose(): void;
  57928. private static _CreateHemisphericLightMesh;
  57929. private static _CreatePointLightMesh;
  57930. private static _CreateSpotLightMesh;
  57931. private static _CreateDirectionalLightMesh;
  57932. }
  57933. }
  57934. declare module BABYLON {
  57935. /**
  57936. * Gizmo that enables viewing a camera
  57937. */
  57938. export class CameraGizmo extends Gizmo {
  57939. private _cameraMesh;
  57940. private _cameraLinesMesh;
  57941. private _material;
  57942. private _pointerObserver;
  57943. /**
  57944. * Event that fires each time the gizmo is clicked
  57945. */
  57946. onClickedObservable: Observable<Camera>;
  57947. /**
  57948. * Creates a CameraGizmo
  57949. * @param gizmoLayer The utility layer the gizmo will be added to
  57950. */
  57951. constructor(gizmoLayer?: UtilityLayerRenderer);
  57952. private _camera;
  57953. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57954. get displayFrustum(): boolean;
  57955. set displayFrustum(value: boolean);
  57956. /**
  57957. * The camera that the gizmo is attached to
  57958. */
  57959. set camera(camera: Nullable<Camera>);
  57960. get camera(): Nullable<Camera>;
  57961. /**
  57962. * Gets the material used to render the camera gizmo
  57963. */
  57964. get material(): StandardMaterial;
  57965. /**
  57966. * @hidden
  57967. * Updates the gizmo to match the attached mesh's position/rotation
  57968. */
  57969. protected _update(): void;
  57970. private static _Scale;
  57971. private _invProjection;
  57972. /**
  57973. * Disposes of the camera gizmo
  57974. */
  57975. dispose(): void;
  57976. private static _CreateCameraMesh;
  57977. private static _CreateCameraFrustum;
  57978. }
  57979. }
  57980. declare module BABYLON {
  57981. /** @hidden */
  57982. export var backgroundFragmentDeclaration: {
  57983. name: string;
  57984. shader: string;
  57985. };
  57986. }
  57987. declare module BABYLON {
  57988. /** @hidden */
  57989. export var backgroundUboDeclaration: {
  57990. name: string;
  57991. shader: string;
  57992. };
  57993. }
  57994. declare module BABYLON {
  57995. /** @hidden */
  57996. export var backgroundPixelShader: {
  57997. name: string;
  57998. shader: string;
  57999. };
  58000. }
  58001. declare module BABYLON {
  58002. /** @hidden */
  58003. export var backgroundVertexDeclaration: {
  58004. name: string;
  58005. shader: string;
  58006. };
  58007. }
  58008. declare module BABYLON {
  58009. /** @hidden */
  58010. export var backgroundVertexShader: {
  58011. name: string;
  58012. shader: string;
  58013. };
  58014. }
  58015. declare module BABYLON {
  58016. /**
  58017. * Background material used to create an efficient environement around your scene.
  58018. */
  58019. export class BackgroundMaterial extends PushMaterial {
  58020. /**
  58021. * Standard reflectance value at parallel view angle.
  58022. */
  58023. static StandardReflectance0: number;
  58024. /**
  58025. * Standard reflectance value at grazing angle.
  58026. */
  58027. static StandardReflectance90: number;
  58028. protected _primaryColor: Color3;
  58029. /**
  58030. * Key light Color (multiply against the environement texture)
  58031. */
  58032. primaryColor: Color3;
  58033. protected __perceptualColor: Nullable<Color3>;
  58034. /**
  58035. * Experimental Internal Use Only.
  58036. *
  58037. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  58038. * This acts as a helper to set the primary color to a more "human friendly" value.
  58039. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  58040. * output color as close as possible from the chosen value.
  58041. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  58042. * part of lighting setup.)
  58043. */
  58044. get _perceptualColor(): Nullable<Color3>;
  58045. set _perceptualColor(value: Nullable<Color3>);
  58046. protected _primaryColorShadowLevel: float;
  58047. /**
  58048. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  58049. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  58050. */
  58051. get primaryColorShadowLevel(): float;
  58052. set primaryColorShadowLevel(value: float);
  58053. protected _primaryColorHighlightLevel: float;
  58054. /**
  58055. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  58056. * The primary color is used at the level chosen to define what the white area would look.
  58057. */
  58058. get primaryColorHighlightLevel(): float;
  58059. set primaryColorHighlightLevel(value: float);
  58060. protected _reflectionTexture: Nullable<BaseTexture>;
  58061. /**
  58062. * Reflection Texture used in the material.
  58063. * Should be author in a specific way for the best result (refer to the documentation).
  58064. */
  58065. reflectionTexture: Nullable<BaseTexture>;
  58066. protected _reflectionBlur: float;
  58067. /**
  58068. * Reflection Texture level of blur.
  58069. *
  58070. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  58071. * texture twice.
  58072. */
  58073. reflectionBlur: float;
  58074. protected _diffuseTexture: Nullable<BaseTexture>;
  58075. /**
  58076. * Diffuse Texture used in the material.
  58077. * Should be author in a specific way for the best result (refer to the documentation).
  58078. */
  58079. diffuseTexture: Nullable<BaseTexture>;
  58080. protected _shadowLights: Nullable<IShadowLight[]>;
  58081. /**
  58082. * Specify the list of lights casting shadow on the material.
  58083. * All scene shadow lights will be included if null.
  58084. */
  58085. shadowLights: Nullable<IShadowLight[]>;
  58086. protected _shadowLevel: float;
  58087. /**
  58088. * Helps adjusting the shadow to a softer level if required.
  58089. * 0 means black shadows and 1 means no shadows.
  58090. */
  58091. shadowLevel: float;
  58092. protected _sceneCenter: Vector3;
  58093. /**
  58094. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  58095. * It is usually zero but might be interesting to modify according to your setup.
  58096. */
  58097. sceneCenter: Vector3;
  58098. protected _opacityFresnel: boolean;
  58099. /**
  58100. * This helps specifying that the material is falling off to the sky box at grazing angle.
  58101. * This helps ensuring a nice transition when the camera goes under the ground.
  58102. */
  58103. opacityFresnel: boolean;
  58104. protected _reflectionFresnel: boolean;
  58105. /**
  58106. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  58107. * This helps adding a mirror texture on the ground.
  58108. */
  58109. reflectionFresnel: boolean;
  58110. protected _reflectionFalloffDistance: number;
  58111. /**
  58112. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  58113. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  58114. */
  58115. reflectionFalloffDistance: number;
  58116. protected _reflectionAmount: number;
  58117. /**
  58118. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  58119. */
  58120. reflectionAmount: number;
  58121. protected _reflectionReflectance0: number;
  58122. /**
  58123. * This specifies the weight of the reflection at grazing angle.
  58124. */
  58125. reflectionReflectance0: number;
  58126. protected _reflectionReflectance90: number;
  58127. /**
  58128. * This specifies the weight of the reflection at a perpendicular point of view.
  58129. */
  58130. reflectionReflectance90: number;
  58131. /**
  58132. * Sets the reflection reflectance fresnel values according to the default standard
  58133. * empirically know to work well :-)
  58134. */
  58135. set reflectionStandardFresnelWeight(value: number);
  58136. protected _useRGBColor: boolean;
  58137. /**
  58138. * Helps to directly use the maps channels instead of their level.
  58139. */
  58140. useRGBColor: boolean;
  58141. protected _enableNoise: boolean;
  58142. /**
  58143. * This helps reducing the banding effect that could occur on the background.
  58144. */
  58145. enableNoise: boolean;
  58146. /**
  58147. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58148. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  58149. * Recommended to be keep at 1.0 except for special cases.
  58150. */
  58151. get fovMultiplier(): number;
  58152. set fovMultiplier(value: number);
  58153. private _fovMultiplier;
  58154. /**
  58155. * Enable the FOV adjustment feature controlled by fovMultiplier.
  58156. */
  58157. useEquirectangularFOV: boolean;
  58158. private _maxSimultaneousLights;
  58159. /**
  58160. * Number of Simultaneous lights allowed on the material.
  58161. */
  58162. maxSimultaneousLights: int;
  58163. private _shadowOnly;
  58164. /**
  58165. * Make the material only render shadows
  58166. */
  58167. shadowOnly: boolean;
  58168. /**
  58169. * Default configuration related to image processing available in the Background Material.
  58170. */
  58171. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58172. /**
  58173. * Keep track of the image processing observer to allow dispose and replace.
  58174. */
  58175. private _imageProcessingObserver;
  58176. /**
  58177. * Attaches a new image processing configuration to the PBR Material.
  58178. * @param configuration (if null the scene configuration will be use)
  58179. */
  58180. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58181. /**
  58182. * Gets the image processing configuration used either in this material.
  58183. */
  58184. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  58185. /**
  58186. * Sets the Default image processing configuration used either in the this material.
  58187. *
  58188. * If sets to null, the scene one is in use.
  58189. */
  58190. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  58191. /**
  58192. * Gets wether the color curves effect is enabled.
  58193. */
  58194. get cameraColorCurvesEnabled(): boolean;
  58195. /**
  58196. * Sets wether the color curves effect is enabled.
  58197. */
  58198. set cameraColorCurvesEnabled(value: boolean);
  58199. /**
  58200. * Gets wether the color grading effect is enabled.
  58201. */
  58202. get cameraColorGradingEnabled(): boolean;
  58203. /**
  58204. * Gets wether the color grading effect is enabled.
  58205. */
  58206. set cameraColorGradingEnabled(value: boolean);
  58207. /**
  58208. * Gets wether tonemapping is enabled or not.
  58209. */
  58210. get cameraToneMappingEnabled(): boolean;
  58211. /**
  58212. * Sets wether tonemapping is enabled or not
  58213. */
  58214. set cameraToneMappingEnabled(value: boolean);
  58215. /**
  58216. * The camera exposure used on this material.
  58217. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58218. * This corresponds to a photographic exposure.
  58219. */
  58220. get cameraExposure(): float;
  58221. /**
  58222. * The camera exposure used on this material.
  58223. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58224. * This corresponds to a photographic exposure.
  58225. */
  58226. set cameraExposure(value: float);
  58227. /**
  58228. * Gets The camera contrast used on this material.
  58229. */
  58230. get cameraContrast(): float;
  58231. /**
  58232. * Sets The camera contrast used on this material.
  58233. */
  58234. set cameraContrast(value: float);
  58235. /**
  58236. * Gets the Color Grading 2D Lookup Texture.
  58237. */
  58238. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58239. /**
  58240. * Sets the Color Grading 2D Lookup Texture.
  58241. */
  58242. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58243. /**
  58244. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58245. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58246. * 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;
  58247. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58248. */
  58249. get cameraColorCurves(): Nullable<ColorCurves>;
  58250. /**
  58251. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58252. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58253. * 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;
  58254. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58255. */
  58256. set cameraColorCurves(value: Nullable<ColorCurves>);
  58257. /**
  58258. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58259. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58260. */
  58261. switchToBGR: boolean;
  58262. private _renderTargets;
  58263. private _reflectionControls;
  58264. private _white;
  58265. private _primaryShadowColor;
  58266. private _primaryHighlightColor;
  58267. /**
  58268. * Instantiates a Background Material in the given scene
  58269. * @param name The friendly name of the material
  58270. * @param scene The scene to add the material to
  58271. */
  58272. constructor(name: string, scene: Scene);
  58273. /**
  58274. * Gets a boolean indicating that current material needs to register RTT
  58275. */
  58276. get hasRenderTargetTextures(): boolean;
  58277. /**
  58278. * The entire material has been created in order to prevent overdraw.
  58279. * @returns false
  58280. */
  58281. needAlphaTesting(): boolean;
  58282. /**
  58283. * The entire material has been created in order to prevent overdraw.
  58284. * @returns true if blending is enable
  58285. */
  58286. needAlphaBlending(): boolean;
  58287. /**
  58288. * Checks wether the material is ready to be rendered for a given mesh.
  58289. * @param mesh The mesh to render
  58290. * @param subMesh The submesh to check against
  58291. * @param useInstances Specify wether or not the material is used with instances
  58292. * @returns true if all the dependencies are ready (Textures, Effects...)
  58293. */
  58294. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58295. /**
  58296. * Compute the primary color according to the chosen perceptual color.
  58297. */
  58298. private _computePrimaryColorFromPerceptualColor;
  58299. /**
  58300. * Compute the highlights and shadow colors according to their chosen levels.
  58301. */
  58302. private _computePrimaryColors;
  58303. /**
  58304. * Build the uniform buffer used in the material.
  58305. */
  58306. buildUniformLayout(): void;
  58307. /**
  58308. * Unbind the material.
  58309. */
  58310. unbind(): void;
  58311. /**
  58312. * Bind only the world matrix to the material.
  58313. * @param world The world matrix to bind.
  58314. */
  58315. bindOnlyWorldMatrix(world: Matrix): void;
  58316. /**
  58317. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58318. * @param world The world matrix to bind.
  58319. * @param subMesh The submesh to bind for.
  58320. */
  58321. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58322. /**
  58323. * Checks to see if a texture is used in the material.
  58324. * @param texture - Base texture to use.
  58325. * @returns - Boolean specifying if a texture is used in the material.
  58326. */
  58327. hasTexture(texture: BaseTexture): boolean;
  58328. /**
  58329. * Dispose the material.
  58330. * @param forceDisposeEffect Force disposal of the associated effect.
  58331. * @param forceDisposeTextures Force disposal of the associated textures.
  58332. */
  58333. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58334. /**
  58335. * Clones the material.
  58336. * @param name The cloned name.
  58337. * @returns The cloned material.
  58338. */
  58339. clone(name: string): BackgroundMaterial;
  58340. /**
  58341. * Serializes the current material to its JSON representation.
  58342. * @returns The JSON representation.
  58343. */
  58344. serialize(): any;
  58345. /**
  58346. * Gets the class name of the material
  58347. * @returns "BackgroundMaterial"
  58348. */
  58349. getClassName(): string;
  58350. /**
  58351. * Parse a JSON input to create back a background material.
  58352. * @param source The JSON data to parse
  58353. * @param scene The scene to create the parsed material in
  58354. * @param rootUrl The root url of the assets the material depends upon
  58355. * @returns the instantiated BackgroundMaterial.
  58356. */
  58357. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58358. }
  58359. }
  58360. declare module BABYLON {
  58361. /**
  58362. * Represents the different options available during the creation of
  58363. * a Environment helper.
  58364. *
  58365. * This can control the default ground, skybox and image processing setup of your scene.
  58366. */
  58367. export interface IEnvironmentHelperOptions {
  58368. /**
  58369. * Specifies whether or not to create a ground.
  58370. * True by default.
  58371. */
  58372. createGround: boolean;
  58373. /**
  58374. * Specifies the ground size.
  58375. * 15 by default.
  58376. */
  58377. groundSize: number;
  58378. /**
  58379. * The texture used on the ground for the main color.
  58380. * Comes from the BabylonJS CDN by default.
  58381. *
  58382. * Remarks: Can be either a texture or a url.
  58383. */
  58384. groundTexture: string | BaseTexture;
  58385. /**
  58386. * The color mixed in the ground texture by default.
  58387. * BabylonJS clearColor by default.
  58388. */
  58389. groundColor: Color3;
  58390. /**
  58391. * Specifies the ground opacity.
  58392. * 1 by default.
  58393. */
  58394. groundOpacity: number;
  58395. /**
  58396. * Enables the ground to receive shadows.
  58397. * True by default.
  58398. */
  58399. enableGroundShadow: boolean;
  58400. /**
  58401. * Helps preventing the shadow to be fully black on the ground.
  58402. * 0.5 by default.
  58403. */
  58404. groundShadowLevel: number;
  58405. /**
  58406. * Creates a mirror texture attach to the ground.
  58407. * false by default.
  58408. */
  58409. enableGroundMirror: boolean;
  58410. /**
  58411. * Specifies the ground mirror size ratio.
  58412. * 0.3 by default as the default kernel is 64.
  58413. */
  58414. groundMirrorSizeRatio: number;
  58415. /**
  58416. * Specifies the ground mirror blur kernel size.
  58417. * 64 by default.
  58418. */
  58419. groundMirrorBlurKernel: number;
  58420. /**
  58421. * Specifies the ground mirror visibility amount.
  58422. * 1 by default
  58423. */
  58424. groundMirrorAmount: number;
  58425. /**
  58426. * Specifies the ground mirror reflectance weight.
  58427. * This uses the standard weight of the background material to setup the fresnel effect
  58428. * of the mirror.
  58429. * 1 by default.
  58430. */
  58431. groundMirrorFresnelWeight: number;
  58432. /**
  58433. * Specifies the ground mirror Falloff distance.
  58434. * This can helps reducing the size of the reflection.
  58435. * 0 by Default.
  58436. */
  58437. groundMirrorFallOffDistance: number;
  58438. /**
  58439. * Specifies the ground mirror texture type.
  58440. * Unsigned Int by Default.
  58441. */
  58442. groundMirrorTextureType: number;
  58443. /**
  58444. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58445. * the shown objects.
  58446. */
  58447. groundYBias: number;
  58448. /**
  58449. * Specifies whether or not to create a skybox.
  58450. * True by default.
  58451. */
  58452. createSkybox: boolean;
  58453. /**
  58454. * Specifies the skybox size.
  58455. * 20 by default.
  58456. */
  58457. skyboxSize: number;
  58458. /**
  58459. * The texture used on the skybox for the main color.
  58460. * Comes from the BabylonJS CDN by default.
  58461. *
  58462. * Remarks: Can be either a texture or a url.
  58463. */
  58464. skyboxTexture: string | BaseTexture;
  58465. /**
  58466. * The color mixed in the skybox texture by default.
  58467. * BabylonJS clearColor by default.
  58468. */
  58469. skyboxColor: Color3;
  58470. /**
  58471. * The background rotation around the Y axis of the scene.
  58472. * This helps aligning the key lights of your scene with the background.
  58473. * 0 by default.
  58474. */
  58475. backgroundYRotation: number;
  58476. /**
  58477. * Compute automatically the size of the elements to best fit with the scene.
  58478. */
  58479. sizeAuto: boolean;
  58480. /**
  58481. * Default position of the rootMesh if autoSize is not true.
  58482. */
  58483. rootPosition: Vector3;
  58484. /**
  58485. * Sets up the image processing in the scene.
  58486. * true by default.
  58487. */
  58488. setupImageProcessing: boolean;
  58489. /**
  58490. * The texture used as your environment texture in the scene.
  58491. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58492. *
  58493. * Remarks: Can be either a texture or a url.
  58494. */
  58495. environmentTexture: string | BaseTexture;
  58496. /**
  58497. * The value of the exposure to apply to the scene.
  58498. * 0.6 by default if setupImageProcessing is true.
  58499. */
  58500. cameraExposure: number;
  58501. /**
  58502. * The value of the contrast to apply to the scene.
  58503. * 1.6 by default if setupImageProcessing is true.
  58504. */
  58505. cameraContrast: number;
  58506. /**
  58507. * Specifies whether or not tonemapping should be enabled in the scene.
  58508. * true by default if setupImageProcessing is true.
  58509. */
  58510. toneMappingEnabled: boolean;
  58511. }
  58512. /**
  58513. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58514. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58515. * It also helps with the default setup of your imageProcessing configuration.
  58516. */
  58517. export class EnvironmentHelper {
  58518. /**
  58519. * Default ground texture URL.
  58520. */
  58521. private static _groundTextureCDNUrl;
  58522. /**
  58523. * Default skybox texture URL.
  58524. */
  58525. private static _skyboxTextureCDNUrl;
  58526. /**
  58527. * Default environment texture URL.
  58528. */
  58529. private static _environmentTextureCDNUrl;
  58530. /**
  58531. * Creates the default options for the helper.
  58532. */
  58533. private static _getDefaultOptions;
  58534. private _rootMesh;
  58535. /**
  58536. * Gets the root mesh created by the helper.
  58537. */
  58538. get rootMesh(): Mesh;
  58539. private _skybox;
  58540. /**
  58541. * Gets the skybox created by the helper.
  58542. */
  58543. get skybox(): Nullable<Mesh>;
  58544. private _skyboxTexture;
  58545. /**
  58546. * Gets the skybox texture created by the helper.
  58547. */
  58548. get skyboxTexture(): Nullable<BaseTexture>;
  58549. private _skyboxMaterial;
  58550. /**
  58551. * Gets the skybox material created by the helper.
  58552. */
  58553. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58554. private _ground;
  58555. /**
  58556. * Gets the ground mesh created by the helper.
  58557. */
  58558. get ground(): Nullable<Mesh>;
  58559. private _groundTexture;
  58560. /**
  58561. * Gets the ground texture created by the helper.
  58562. */
  58563. get groundTexture(): Nullable<BaseTexture>;
  58564. private _groundMirror;
  58565. /**
  58566. * Gets the ground mirror created by the helper.
  58567. */
  58568. get groundMirror(): Nullable<MirrorTexture>;
  58569. /**
  58570. * Gets the ground mirror render list to helps pushing the meshes
  58571. * you wish in the ground reflection.
  58572. */
  58573. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58574. private _groundMaterial;
  58575. /**
  58576. * Gets the ground material created by the helper.
  58577. */
  58578. get groundMaterial(): Nullable<BackgroundMaterial>;
  58579. /**
  58580. * Stores the creation options.
  58581. */
  58582. private readonly _scene;
  58583. private _options;
  58584. /**
  58585. * This observable will be notified with any error during the creation of the environment,
  58586. * mainly texture creation errors.
  58587. */
  58588. onErrorObservable: Observable<{
  58589. message?: string;
  58590. exception?: any;
  58591. }>;
  58592. /**
  58593. * constructor
  58594. * @param options Defines the options we want to customize the helper
  58595. * @param scene The scene to add the material to
  58596. */
  58597. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58598. /**
  58599. * Updates the background according to the new options
  58600. * @param options
  58601. */
  58602. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58603. /**
  58604. * Sets the primary color of all the available elements.
  58605. * @param color the main color to affect to the ground and the background
  58606. */
  58607. setMainColor(color: Color3): void;
  58608. /**
  58609. * Setup the image processing according to the specified options.
  58610. */
  58611. private _setupImageProcessing;
  58612. /**
  58613. * Setup the environment texture according to the specified options.
  58614. */
  58615. private _setupEnvironmentTexture;
  58616. /**
  58617. * Setup the background according to the specified options.
  58618. */
  58619. private _setupBackground;
  58620. /**
  58621. * Get the scene sizes according to the setup.
  58622. */
  58623. private _getSceneSize;
  58624. /**
  58625. * Setup the ground according to the specified options.
  58626. */
  58627. private _setupGround;
  58628. /**
  58629. * Setup the ground material according to the specified options.
  58630. */
  58631. private _setupGroundMaterial;
  58632. /**
  58633. * Setup the ground diffuse texture according to the specified options.
  58634. */
  58635. private _setupGroundDiffuseTexture;
  58636. /**
  58637. * Setup the ground mirror texture according to the specified options.
  58638. */
  58639. private _setupGroundMirrorTexture;
  58640. /**
  58641. * Setup the ground to receive the mirror texture.
  58642. */
  58643. private _setupMirrorInGroundMaterial;
  58644. /**
  58645. * Setup the skybox according to the specified options.
  58646. */
  58647. private _setupSkybox;
  58648. /**
  58649. * Setup the skybox material according to the specified options.
  58650. */
  58651. private _setupSkyboxMaterial;
  58652. /**
  58653. * Setup the skybox reflection texture according to the specified options.
  58654. */
  58655. private _setupSkyboxReflectionTexture;
  58656. private _errorHandler;
  58657. /**
  58658. * Dispose all the elements created by the Helper.
  58659. */
  58660. dispose(): void;
  58661. }
  58662. }
  58663. declare module BABYLON {
  58664. /**
  58665. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58666. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58667. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58668. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58669. */
  58670. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58671. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58672. /**
  58673. * Define the source as a Monoscopic panoramic 360/180.
  58674. */
  58675. static readonly MODE_MONOSCOPIC: number;
  58676. /**
  58677. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58678. */
  58679. static readonly MODE_TOPBOTTOM: number;
  58680. /**
  58681. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58682. */
  58683. static readonly MODE_SIDEBYSIDE: number;
  58684. private _halfDome;
  58685. private _crossEye;
  58686. protected _useDirectMapping: boolean;
  58687. /**
  58688. * The texture being displayed on the sphere
  58689. */
  58690. protected _texture: T;
  58691. /**
  58692. * Gets the texture being displayed on the sphere
  58693. */
  58694. get texture(): T;
  58695. /**
  58696. * Sets the texture being displayed on the sphere
  58697. */
  58698. set texture(newTexture: T);
  58699. /**
  58700. * The skybox material
  58701. */
  58702. protected _material: BackgroundMaterial;
  58703. /**
  58704. * The surface used for the dome
  58705. */
  58706. protected _mesh: Mesh;
  58707. /**
  58708. * Gets the mesh used for the dome.
  58709. */
  58710. get mesh(): Mesh;
  58711. /**
  58712. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58713. */
  58714. private _halfDomeMask;
  58715. /**
  58716. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58717. * Also see the options.resolution property.
  58718. */
  58719. get fovMultiplier(): number;
  58720. set fovMultiplier(value: number);
  58721. protected _textureMode: number;
  58722. /**
  58723. * Gets or set the current texture mode for the texture. It can be:
  58724. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58725. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58726. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58727. */
  58728. get textureMode(): number;
  58729. /**
  58730. * Sets the current texture mode for the texture. It can be:
  58731. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58732. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58733. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58734. */
  58735. set textureMode(value: number);
  58736. /**
  58737. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58738. */
  58739. get halfDome(): boolean;
  58740. /**
  58741. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58742. */
  58743. set halfDome(enabled: boolean);
  58744. /**
  58745. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58746. */
  58747. set crossEye(enabled: boolean);
  58748. /**
  58749. * Is it a cross-eye texture?
  58750. */
  58751. get crossEye(): boolean;
  58752. /**
  58753. * The background material of this dome.
  58754. */
  58755. get material(): BackgroundMaterial;
  58756. /**
  58757. * Oberserver used in Stereoscopic VR Mode.
  58758. */
  58759. private _onBeforeCameraRenderObserver;
  58760. /**
  58761. * Observable raised when an error occured while loading the 360 image
  58762. */
  58763. onLoadErrorObservable: Observable<string>;
  58764. /**
  58765. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58766. * @param name Element's name, child elements will append suffixes for their own names.
  58767. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58768. * @param options An object containing optional or exposed sub element properties
  58769. */
  58770. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58771. resolution?: number;
  58772. clickToPlay?: boolean;
  58773. autoPlay?: boolean;
  58774. loop?: boolean;
  58775. size?: number;
  58776. poster?: string;
  58777. faceForward?: boolean;
  58778. useDirectMapping?: boolean;
  58779. halfDomeMode?: boolean;
  58780. crossEyeMode?: boolean;
  58781. generateMipMaps?: boolean;
  58782. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58783. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58784. protected _changeTextureMode(value: number): void;
  58785. /**
  58786. * Releases resources associated with this node.
  58787. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58788. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58789. */
  58790. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58791. }
  58792. }
  58793. declare module BABYLON {
  58794. /**
  58795. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58796. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58797. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58798. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58799. */
  58800. export class PhotoDome extends TextureDome<Texture> {
  58801. /**
  58802. * Define the image as a Monoscopic panoramic 360 image.
  58803. */
  58804. static readonly MODE_MONOSCOPIC: number;
  58805. /**
  58806. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58807. */
  58808. static readonly MODE_TOPBOTTOM: number;
  58809. /**
  58810. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58811. */
  58812. static readonly MODE_SIDEBYSIDE: number;
  58813. /**
  58814. * Gets or sets the texture being displayed on the sphere
  58815. */
  58816. get photoTexture(): Texture;
  58817. /**
  58818. * sets the texture being displayed on the sphere
  58819. */
  58820. set photoTexture(value: Texture);
  58821. /**
  58822. * Gets the current video mode for the video. It can be:
  58823. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58824. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58825. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58826. */
  58827. get imageMode(): number;
  58828. /**
  58829. * Sets the current video mode for the video. It can be:
  58830. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58831. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58832. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58833. */
  58834. set imageMode(value: number);
  58835. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58836. }
  58837. }
  58838. declare module BABYLON {
  58839. /**
  58840. * Direct draw surface info
  58841. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58842. */
  58843. export interface DDSInfo {
  58844. /**
  58845. * Width of the texture
  58846. */
  58847. width: number;
  58848. /**
  58849. * Width of the texture
  58850. */
  58851. height: number;
  58852. /**
  58853. * Number of Mipmaps for the texture
  58854. * @see https://en.wikipedia.org/wiki/Mipmap
  58855. */
  58856. mipmapCount: number;
  58857. /**
  58858. * If the textures format is a known fourCC format
  58859. * @see https://www.fourcc.org/
  58860. */
  58861. isFourCC: boolean;
  58862. /**
  58863. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58864. */
  58865. isRGB: boolean;
  58866. /**
  58867. * If the texture is a lumincance format
  58868. */
  58869. isLuminance: boolean;
  58870. /**
  58871. * If this is a cube texture
  58872. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58873. */
  58874. isCube: boolean;
  58875. /**
  58876. * If the texture is a compressed format eg. FOURCC_DXT1
  58877. */
  58878. isCompressed: boolean;
  58879. /**
  58880. * The dxgiFormat of the texture
  58881. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58882. */
  58883. dxgiFormat: number;
  58884. /**
  58885. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58886. */
  58887. textureType: number;
  58888. /**
  58889. * Sphericle polynomial created for the dds texture
  58890. */
  58891. sphericalPolynomial?: SphericalPolynomial;
  58892. }
  58893. /**
  58894. * Class used to provide DDS decompression tools
  58895. */
  58896. export class DDSTools {
  58897. /**
  58898. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58899. */
  58900. static StoreLODInAlphaChannel: boolean;
  58901. /**
  58902. * Gets DDS information from an array buffer
  58903. * @param data defines the array buffer view to read data from
  58904. * @returns the DDS information
  58905. */
  58906. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58907. private static _FloatView;
  58908. private static _Int32View;
  58909. private static _ToHalfFloat;
  58910. private static _FromHalfFloat;
  58911. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58912. private static _GetHalfFloatRGBAArrayBuffer;
  58913. private static _GetFloatRGBAArrayBuffer;
  58914. private static _GetFloatAsUIntRGBAArrayBuffer;
  58915. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58916. private static _GetRGBAArrayBuffer;
  58917. private static _ExtractLongWordOrder;
  58918. private static _GetRGBArrayBuffer;
  58919. private static _GetLuminanceArrayBuffer;
  58920. /**
  58921. * Uploads DDS Levels to a Babylon Texture
  58922. * @hidden
  58923. */
  58924. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58925. }
  58926. interface ThinEngine {
  58927. /**
  58928. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58929. * @param rootUrl defines the url where the file to load is located
  58930. * @param scene defines the current scene
  58931. * @param lodScale defines scale to apply to the mip map selection
  58932. * @param lodOffset defines offset to apply to the mip map selection
  58933. * @param onLoad defines an optional callback raised when the texture is loaded
  58934. * @param onError defines an optional callback raised if there is an issue to load the texture
  58935. * @param format defines the format of the data
  58936. * @param forcedExtension defines the extension to use to pick the right loader
  58937. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58938. * @returns the cube texture as an InternalTexture
  58939. */
  58940. 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;
  58941. }
  58942. }
  58943. declare module BABYLON {
  58944. /**
  58945. * Implementation of the DDS Texture Loader.
  58946. * @hidden
  58947. */
  58948. export class _DDSTextureLoader implements IInternalTextureLoader {
  58949. /**
  58950. * Defines wether the loader supports cascade loading the different faces.
  58951. */
  58952. readonly supportCascades: boolean;
  58953. /**
  58954. * This returns if the loader support the current file information.
  58955. * @param extension defines the file extension of the file being loaded
  58956. * @returns true if the loader can load the specified file
  58957. */
  58958. canLoad(extension: string): boolean;
  58959. /**
  58960. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58961. * @param data contains the texture data
  58962. * @param texture defines the BabylonJS internal texture
  58963. * @param createPolynomials will be true if polynomials have been requested
  58964. * @param onLoad defines the callback to trigger once the texture is ready
  58965. * @param onError defines the callback to trigger in case of error
  58966. */
  58967. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58968. /**
  58969. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58970. * @param data contains the texture data
  58971. * @param texture defines the BabylonJS internal texture
  58972. * @param callback defines the method to call once ready to upload
  58973. */
  58974. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58975. }
  58976. }
  58977. declare module BABYLON {
  58978. /**
  58979. * Implementation of the ENV Texture Loader.
  58980. * @hidden
  58981. */
  58982. export class _ENVTextureLoader implements IInternalTextureLoader {
  58983. /**
  58984. * Defines wether the loader supports cascade loading the different faces.
  58985. */
  58986. readonly supportCascades: boolean;
  58987. /**
  58988. * This returns if the loader support the current file information.
  58989. * @param extension defines the file extension of the file being loaded
  58990. * @returns true if the loader can load the specified file
  58991. */
  58992. canLoad(extension: string): boolean;
  58993. /**
  58994. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58995. * @param data contains the texture data
  58996. * @param texture defines the BabylonJS internal texture
  58997. * @param createPolynomials will be true if polynomials have been requested
  58998. * @param onLoad defines the callback to trigger once the texture is ready
  58999. * @param onError defines the callback to trigger in case of error
  59000. */
  59001. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59002. /**
  59003. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59004. * @param data contains the texture data
  59005. * @param texture defines the BabylonJS internal texture
  59006. * @param callback defines the method to call once ready to upload
  59007. */
  59008. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59009. }
  59010. }
  59011. declare module BABYLON {
  59012. /**
  59013. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59014. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59015. */
  59016. export class KhronosTextureContainer {
  59017. /** contents of the KTX container file */
  59018. data: ArrayBufferView;
  59019. private static HEADER_LEN;
  59020. private static COMPRESSED_2D;
  59021. private static COMPRESSED_3D;
  59022. private static TEX_2D;
  59023. private static TEX_3D;
  59024. /**
  59025. * Gets the openGL type
  59026. */
  59027. glType: number;
  59028. /**
  59029. * Gets the openGL type size
  59030. */
  59031. glTypeSize: number;
  59032. /**
  59033. * Gets the openGL format
  59034. */
  59035. glFormat: number;
  59036. /**
  59037. * Gets the openGL internal format
  59038. */
  59039. glInternalFormat: number;
  59040. /**
  59041. * Gets the base internal format
  59042. */
  59043. glBaseInternalFormat: number;
  59044. /**
  59045. * Gets image width in pixel
  59046. */
  59047. pixelWidth: number;
  59048. /**
  59049. * Gets image height in pixel
  59050. */
  59051. pixelHeight: number;
  59052. /**
  59053. * Gets image depth in pixels
  59054. */
  59055. pixelDepth: number;
  59056. /**
  59057. * Gets the number of array elements
  59058. */
  59059. numberOfArrayElements: number;
  59060. /**
  59061. * Gets the number of faces
  59062. */
  59063. numberOfFaces: number;
  59064. /**
  59065. * Gets the number of mipmap levels
  59066. */
  59067. numberOfMipmapLevels: number;
  59068. /**
  59069. * Gets the bytes of key value data
  59070. */
  59071. bytesOfKeyValueData: number;
  59072. /**
  59073. * Gets the load type
  59074. */
  59075. loadType: number;
  59076. /**
  59077. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59078. */
  59079. isInvalid: boolean;
  59080. /**
  59081. * Creates a new KhronosTextureContainer
  59082. * @param data contents of the KTX container file
  59083. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59084. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59085. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59086. */
  59087. constructor(
  59088. /** contents of the KTX container file */
  59089. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59090. /**
  59091. * Uploads KTX content to a Babylon Texture.
  59092. * It is assumed that the texture has already been created & is currently bound
  59093. * @hidden
  59094. */
  59095. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59096. private _upload2DCompressedLevels;
  59097. /**
  59098. * Checks if the given data starts with a KTX file identifier.
  59099. * @param data the data to check
  59100. * @returns true if the data is a KTX file or false otherwise
  59101. */
  59102. static IsValid(data: ArrayBufferView): boolean;
  59103. }
  59104. }
  59105. declare module BABYLON {
  59106. /**
  59107. * Helper class to push actions to a pool of workers.
  59108. */
  59109. export class WorkerPool implements IDisposable {
  59110. private _workerInfos;
  59111. private _pendingActions;
  59112. /**
  59113. * Constructor
  59114. * @param workers Array of workers to use for actions
  59115. */
  59116. constructor(workers: Array<Worker>);
  59117. /**
  59118. * Terminates all workers and clears any pending actions.
  59119. */
  59120. dispose(): void;
  59121. /**
  59122. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59123. * pended until a worker has completed its action.
  59124. * @param action The action to perform. Call onComplete when the action is complete.
  59125. */
  59126. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59127. private _execute;
  59128. }
  59129. }
  59130. declare module BABYLON {
  59131. /**
  59132. * Class for loading KTX2 files
  59133. */
  59134. export class KhronosTextureContainer2 {
  59135. private static _WorkerPoolPromise?;
  59136. private static _Initialized;
  59137. private static _Ktx2Decoder;
  59138. /**
  59139. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  59140. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  59141. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  59142. * Urls you can change:
  59143. * URLConfig.jsDecoderModule
  59144. * URLConfig.wasmUASTCToASTC
  59145. * URLConfig.wasmUASTCToBC7
  59146. * URLConfig.wasmUASTCToRGBA_UNORM
  59147. * URLConfig.wasmUASTCToRGBA_SRGB
  59148. * URLConfig.jsMSCTranscoder
  59149. * URLConfig.wasmMSCTranscoder
  59150. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  59151. */
  59152. static URLConfig: {
  59153. jsDecoderModule: string;
  59154. wasmUASTCToASTC: null;
  59155. wasmUASTCToBC7: null;
  59156. wasmUASTCToRGBA_UNORM: null;
  59157. wasmUASTCToRGBA_SRGB: null;
  59158. jsMSCTranscoder: null;
  59159. wasmMSCTranscoder: null;
  59160. };
  59161. /**
  59162. * Default number of workers used to handle data decoding
  59163. */
  59164. static DefaultNumWorkers: number;
  59165. private static GetDefaultNumWorkers;
  59166. private _engine;
  59167. private static _CreateWorkerPool;
  59168. /**
  59169. * Constructor
  59170. * @param engine The engine to use
  59171. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59172. */
  59173. constructor(engine: ThinEngine, numWorkers?: number);
  59174. /** @hidden */
  59175. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  59176. /**
  59177. * Stop all async operations and release resources.
  59178. */
  59179. dispose(): void;
  59180. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  59181. /**
  59182. * Checks if the given data starts with a KTX2 file identifier.
  59183. * @param data the data to check
  59184. * @returns true if the data is a KTX2 file or false otherwise
  59185. */
  59186. static IsValid(data: ArrayBufferView): boolean;
  59187. }
  59188. }
  59189. declare module BABYLON {
  59190. /**
  59191. * Implementation of the KTX Texture Loader.
  59192. * @hidden
  59193. */
  59194. export class _KTXTextureLoader implements IInternalTextureLoader {
  59195. /**
  59196. * Defines wether the loader supports cascade loading the different faces.
  59197. */
  59198. readonly supportCascades: boolean;
  59199. /**
  59200. * This returns if the loader support the current file information.
  59201. * @param extension defines the file extension of the file being loaded
  59202. * @param mimeType defines the optional mime type of the file being loaded
  59203. * @returns true if the loader can load the specified file
  59204. */
  59205. canLoad(extension: string, mimeType?: string): boolean;
  59206. /**
  59207. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59208. * @param data contains the texture data
  59209. * @param texture defines the BabylonJS internal texture
  59210. * @param createPolynomials will be true if polynomials have been requested
  59211. * @param onLoad defines the callback to trigger once the texture is ready
  59212. * @param onError defines the callback to trigger in case of error
  59213. */
  59214. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59215. /**
  59216. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59217. * @param data contains the texture data
  59218. * @param texture defines the BabylonJS internal texture
  59219. * @param callback defines the method to call once ready to upload
  59220. */
  59221. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  59222. }
  59223. }
  59224. declare module BABYLON {
  59225. /** @hidden */
  59226. export var _forceSceneHelpersToBundle: boolean;
  59227. interface Scene {
  59228. /**
  59229. * Creates a default light for the scene.
  59230. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59231. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59232. */
  59233. createDefaultLight(replace?: boolean): void;
  59234. /**
  59235. * Creates a default camera for the scene.
  59236. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59237. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59238. * @param replace has default false, when true replaces the active camera in the scene
  59239. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59240. */
  59241. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59242. /**
  59243. * Creates a default camera and a default light.
  59244. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59245. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59246. * @param replace has the default false, when true replaces the active camera/light in the scene
  59247. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59248. */
  59249. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59250. /**
  59251. * Creates a new sky box
  59252. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59253. * @param environmentTexture defines the texture to use as environment texture
  59254. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59255. * @param scale defines the overall scale of the skybox
  59256. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59257. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59258. * @returns a new mesh holding the sky box
  59259. */
  59260. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59261. /**
  59262. * Creates a new environment
  59263. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59264. * @param options defines the options you can use to configure the environment
  59265. * @returns the new EnvironmentHelper
  59266. */
  59267. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59268. /**
  59269. * Creates a new VREXperienceHelper
  59270. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59271. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59272. * @returns a new VREXperienceHelper
  59273. */
  59274. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59275. /**
  59276. * Creates a new WebXRDefaultExperience
  59277. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59278. * @param options experience options
  59279. * @returns a promise for a new WebXRDefaultExperience
  59280. */
  59281. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59282. }
  59283. }
  59284. declare module BABYLON {
  59285. /**
  59286. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59287. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59288. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59289. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59290. */
  59291. export class VideoDome extends TextureDome<VideoTexture> {
  59292. /**
  59293. * Define the video source as a Monoscopic panoramic 360 video.
  59294. */
  59295. static readonly MODE_MONOSCOPIC: number;
  59296. /**
  59297. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59298. */
  59299. static readonly MODE_TOPBOTTOM: number;
  59300. /**
  59301. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59302. */
  59303. static readonly MODE_SIDEBYSIDE: number;
  59304. /**
  59305. * Get the video texture associated with this video dome
  59306. */
  59307. get videoTexture(): VideoTexture;
  59308. /**
  59309. * Get the video mode of this dome
  59310. */
  59311. get videoMode(): number;
  59312. /**
  59313. * Set the video mode of this dome.
  59314. * @see textureMode
  59315. */
  59316. set videoMode(value: number);
  59317. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59318. }
  59319. }
  59320. declare module BABYLON {
  59321. /**
  59322. * This class can be used to get instrumentation data from a Babylon engine
  59323. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59324. */
  59325. export class EngineInstrumentation implements IDisposable {
  59326. /**
  59327. * Define the instrumented engine.
  59328. */
  59329. engine: Engine;
  59330. private _captureGPUFrameTime;
  59331. private _gpuFrameTimeToken;
  59332. private _gpuFrameTime;
  59333. private _captureShaderCompilationTime;
  59334. private _shaderCompilationTime;
  59335. private _onBeginFrameObserver;
  59336. private _onEndFrameObserver;
  59337. private _onBeforeShaderCompilationObserver;
  59338. private _onAfterShaderCompilationObserver;
  59339. /**
  59340. * Gets the perf counter used for GPU frame time
  59341. */
  59342. get gpuFrameTimeCounter(): PerfCounter;
  59343. /**
  59344. * Gets the GPU frame time capture status
  59345. */
  59346. get captureGPUFrameTime(): boolean;
  59347. /**
  59348. * Enable or disable the GPU frame time capture
  59349. */
  59350. set captureGPUFrameTime(value: boolean);
  59351. /**
  59352. * Gets the perf counter used for shader compilation time
  59353. */
  59354. get shaderCompilationTimeCounter(): PerfCounter;
  59355. /**
  59356. * Gets the shader compilation time capture status
  59357. */
  59358. get captureShaderCompilationTime(): boolean;
  59359. /**
  59360. * Enable or disable the shader compilation time capture
  59361. */
  59362. set captureShaderCompilationTime(value: boolean);
  59363. /**
  59364. * Instantiates a new engine instrumentation.
  59365. * This class can be used to get instrumentation data from a Babylon engine
  59366. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59367. * @param engine Defines the engine to instrument
  59368. */
  59369. constructor(
  59370. /**
  59371. * Define the instrumented engine.
  59372. */
  59373. engine: Engine);
  59374. /**
  59375. * Dispose and release associated resources.
  59376. */
  59377. dispose(): void;
  59378. }
  59379. }
  59380. declare module BABYLON {
  59381. /**
  59382. * This class can be used to get instrumentation data from a Babylon engine
  59383. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59384. */
  59385. export class SceneInstrumentation implements IDisposable {
  59386. /**
  59387. * Defines the scene to instrument
  59388. */
  59389. scene: Scene;
  59390. private _captureActiveMeshesEvaluationTime;
  59391. private _activeMeshesEvaluationTime;
  59392. private _captureRenderTargetsRenderTime;
  59393. private _renderTargetsRenderTime;
  59394. private _captureFrameTime;
  59395. private _frameTime;
  59396. private _captureRenderTime;
  59397. private _renderTime;
  59398. private _captureInterFrameTime;
  59399. private _interFrameTime;
  59400. private _captureParticlesRenderTime;
  59401. private _particlesRenderTime;
  59402. private _captureSpritesRenderTime;
  59403. private _spritesRenderTime;
  59404. private _capturePhysicsTime;
  59405. private _physicsTime;
  59406. private _captureAnimationsTime;
  59407. private _animationsTime;
  59408. private _captureCameraRenderTime;
  59409. private _cameraRenderTime;
  59410. private _onBeforeActiveMeshesEvaluationObserver;
  59411. private _onAfterActiveMeshesEvaluationObserver;
  59412. private _onBeforeRenderTargetsRenderObserver;
  59413. private _onAfterRenderTargetsRenderObserver;
  59414. private _onAfterRenderObserver;
  59415. private _onBeforeDrawPhaseObserver;
  59416. private _onAfterDrawPhaseObserver;
  59417. private _onBeforeAnimationsObserver;
  59418. private _onBeforeParticlesRenderingObserver;
  59419. private _onAfterParticlesRenderingObserver;
  59420. private _onBeforeSpritesRenderingObserver;
  59421. private _onAfterSpritesRenderingObserver;
  59422. private _onBeforePhysicsObserver;
  59423. private _onAfterPhysicsObserver;
  59424. private _onAfterAnimationsObserver;
  59425. private _onBeforeCameraRenderObserver;
  59426. private _onAfterCameraRenderObserver;
  59427. /**
  59428. * Gets the perf counter used for active meshes evaluation time
  59429. */
  59430. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59431. /**
  59432. * Gets the active meshes evaluation time capture status
  59433. */
  59434. get captureActiveMeshesEvaluationTime(): boolean;
  59435. /**
  59436. * Enable or disable the active meshes evaluation time capture
  59437. */
  59438. set captureActiveMeshesEvaluationTime(value: boolean);
  59439. /**
  59440. * Gets the perf counter used for render targets render time
  59441. */
  59442. get renderTargetsRenderTimeCounter(): PerfCounter;
  59443. /**
  59444. * Gets the render targets render time capture status
  59445. */
  59446. get captureRenderTargetsRenderTime(): boolean;
  59447. /**
  59448. * Enable or disable the render targets render time capture
  59449. */
  59450. set captureRenderTargetsRenderTime(value: boolean);
  59451. /**
  59452. * Gets the perf counter used for particles render time
  59453. */
  59454. get particlesRenderTimeCounter(): PerfCounter;
  59455. /**
  59456. * Gets the particles render time capture status
  59457. */
  59458. get captureParticlesRenderTime(): boolean;
  59459. /**
  59460. * Enable or disable the particles render time capture
  59461. */
  59462. set captureParticlesRenderTime(value: boolean);
  59463. /**
  59464. * Gets the perf counter used for sprites render time
  59465. */
  59466. get spritesRenderTimeCounter(): PerfCounter;
  59467. /**
  59468. * Gets the sprites render time capture status
  59469. */
  59470. get captureSpritesRenderTime(): boolean;
  59471. /**
  59472. * Enable or disable the sprites render time capture
  59473. */
  59474. set captureSpritesRenderTime(value: boolean);
  59475. /**
  59476. * Gets the perf counter used for physics time
  59477. */
  59478. get physicsTimeCounter(): PerfCounter;
  59479. /**
  59480. * Gets the physics time capture status
  59481. */
  59482. get capturePhysicsTime(): boolean;
  59483. /**
  59484. * Enable or disable the physics time capture
  59485. */
  59486. set capturePhysicsTime(value: boolean);
  59487. /**
  59488. * Gets the perf counter used for animations time
  59489. */
  59490. get animationsTimeCounter(): PerfCounter;
  59491. /**
  59492. * Gets the animations time capture status
  59493. */
  59494. get captureAnimationsTime(): boolean;
  59495. /**
  59496. * Enable or disable the animations time capture
  59497. */
  59498. set captureAnimationsTime(value: boolean);
  59499. /**
  59500. * Gets the perf counter used for frame time capture
  59501. */
  59502. get frameTimeCounter(): PerfCounter;
  59503. /**
  59504. * Gets the frame time capture status
  59505. */
  59506. get captureFrameTime(): boolean;
  59507. /**
  59508. * Enable or disable the frame time capture
  59509. */
  59510. set captureFrameTime(value: boolean);
  59511. /**
  59512. * Gets the perf counter used for inter-frames time capture
  59513. */
  59514. get interFrameTimeCounter(): PerfCounter;
  59515. /**
  59516. * Gets the inter-frames time capture status
  59517. */
  59518. get captureInterFrameTime(): boolean;
  59519. /**
  59520. * Enable or disable the inter-frames time capture
  59521. */
  59522. set captureInterFrameTime(value: boolean);
  59523. /**
  59524. * Gets the perf counter used for render time capture
  59525. */
  59526. get renderTimeCounter(): PerfCounter;
  59527. /**
  59528. * Gets the render time capture status
  59529. */
  59530. get captureRenderTime(): boolean;
  59531. /**
  59532. * Enable or disable the render time capture
  59533. */
  59534. set captureRenderTime(value: boolean);
  59535. /**
  59536. * Gets the perf counter used for camera render time capture
  59537. */
  59538. get cameraRenderTimeCounter(): PerfCounter;
  59539. /**
  59540. * Gets the camera render time capture status
  59541. */
  59542. get captureCameraRenderTime(): boolean;
  59543. /**
  59544. * Enable or disable the camera render time capture
  59545. */
  59546. set captureCameraRenderTime(value: boolean);
  59547. /**
  59548. * Gets the perf counter used for draw calls
  59549. */
  59550. get drawCallsCounter(): PerfCounter;
  59551. /**
  59552. * Instantiates a new scene instrumentation.
  59553. * This class can be used to get instrumentation data from a Babylon engine
  59554. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59555. * @param scene Defines the scene to instrument
  59556. */
  59557. constructor(
  59558. /**
  59559. * Defines the scene to instrument
  59560. */
  59561. scene: Scene);
  59562. /**
  59563. * Dispose and release associated resources.
  59564. */
  59565. dispose(): void;
  59566. }
  59567. }
  59568. declare module BABYLON {
  59569. /** @hidden */
  59570. export var glowMapGenerationPixelShader: {
  59571. name: string;
  59572. shader: string;
  59573. };
  59574. }
  59575. declare module BABYLON {
  59576. /** @hidden */
  59577. export var glowMapGenerationVertexShader: {
  59578. name: string;
  59579. shader: string;
  59580. };
  59581. }
  59582. declare module BABYLON {
  59583. /**
  59584. * Effect layer options. This helps customizing the behaviour
  59585. * of the effect layer.
  59586. */
  59587. export interface IEffectLayerOptions {
  59588. /**
  59589. * Multiplication factor apply to the canvas size to compute the render target size
  59590. * used to generated the objects (the smaller the faster).
  59591. */
  59592. mainTextureRatio: number;
  59593. /**
  59594. * Enforces a fixed size texture to ensure effect stability across devices.
  59595. */
  59596. mainTextureFixedSize?: number;
  59597. /**
  59598. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59599. */
  59600. alphaBlendingMode: number;
  59601. /**
  59602. * The camera attached to the layer.
  59603. */
  59604. camera: Nullable<Camera>;
  59605. /**
  59606. * The rendering group to draw the layer in.
  59607. */
  59608. renderingGroupId: number;
  59609. }
  59610. /**
  59611. * The effect layer Helps adding post process effect blended with the main pass.
  59612. *
  59613. * This can be for instance use to generate glow or higlight effects on the scene.
  59614. *
  59615. * The effect layer class can not be used directly and is intented to inherited from to be
  59616. * customized per effects.
  59617. */
  59618. export abstract class EffectLayer {
  59619. private _vertexBuffers;
  59620. private _indexBuffer;
  59621. private _cachedDefines;
  59622. private _effectLayerMapGenerationEffect;
  59623. private _effectLayerOptions;
  59624. private _mergeEffect;
  59625. protected _scene: Scene;
  59626. protected _engine: Engine;
  59627. protected _maxSize: number;
  59628. protected _mainTextureDesiredSize: ISize;
  59629. protected _mainTexture: RenderTargetTexture;
  59630. protected _shouldRender: boolean;
  59631. protected _postProcesses: PostProcess[];
  59632. protected _textures: BaseTexture[];
  59633. protected _emissiveTextureAndColor: {
  59634. texture: Nullable<BaseTexture>;
  59635. color: Color4;
  59636. };
  59637. /**
  59638. * The name of the layer
  59639. */
  59640. name: string;
  59641. /**
  59642. * The clear color of the texture used to generate the glow map.
  59643. */
  59644. neutralColor: Color4;
  59645. /**
  59646. * Specifies whether the highlight layer is enabled or not.
  59647. */
  59648. isEnabled: boolean;
  59649. /**
  59650. * Gets the camera attached to the layer.
  59651. */
  59652. get camera(): Nullable<Camera>;
  59653. /**
  59654. * Gets the rendering group id the layer should render in.
  59655. */
  59656. get renderingGroupId(): number;
  59657. set renderingGroupId(renderingGroupId: number);
  59658. /**
  59659. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59660. */
  59661. disableBoundingBoxesFromEffectLayer: boolean;
  59662. /**
  59663. * An event triggered when the effect layer has been disposed.
  59664. */
  59665. onDisposeObservable: Observable<EffectLayer>;
  59666. /**
  59667. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59668. */
  59669. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59670. /**
  59671. * An event triggered when the generated texture is being merged in the scene.
  59672. */
  59673. onBeforeComposeObservable: Observable<EffectLayer>;
  59674. /**
  59675. * An event triggered when the mesh is rendered into the effect render target.
  59676. */
  59677. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59678. /**
  59679. * An event triggered after the mesh has been rendered into the effect render target.
  59680. */
  59681. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59682. /**
  59683. * An event triggered when the generated texture has been merged in the scene.
  59684. */
  59685. onAfterComposeObservable: Observable<EffectLayer>;
  59686. /**
  59687. * An event triggered when the efffect layer changes its size.
  59688. */
  59689. onSizeChangedObservable: Observable<EffectLayer>;
  59690. /** @hidden */
  59691. static _SceneComponentInitialization: (scene: Scene) => void;
  59692. /**
  59693. * Instantiates a new effect Layer and references it in the scene.
  59694. * @param name The name of the layer
  59695. * @param scene The scene to use the layer in
  59696. */
  59697. constructor(
  59698. /** The Friendly of the effect in the scene */
  59699. name: string, scene: Scene);
  59700. /**
  59701. * Get the effect name of the layer.
  59702. * @return The effect name
  59703. */
  59704. abstract getEffectName(): string;
  59705. /**
  59706. * Checks for the readiness of the element composing the layer.
  59707. * @param subMesh the mesh to check for
  59708. * @param useInstances specify whether or not to use instances to render the mesh
  59709. * @return true if ready otherwise, false
  59710. */
  59711. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59712. /**
  59713. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59714. * @returns true if the effect requires stencil during the main canvas render pass.
  59715. */
  59716. abstract needStencil(): boolean;
  59717. /**
  59718. * Create the merge effect. This is the shader use to blit the information back
  59719. * to the main canvas at the end of the scene rendering.
  59720. * @returns The effect containing the shader used to merge the effect on the main canvas
  59721. */
  59722. protected abstract _createMergeEffect(): Effect;
  59723. /**
  59724. * Creates the render target textures and post processes used in the effect layer.
  59725. */
  59726. protected abstract _createTextureAndPostProcesses(): void;
  59727. /**
  59728. * Implementation specific of rendering the generating effect on the main canvas.
  59729. * @param effect The effect used to render through
  59730. */
  59731. protected abstract _internalRender(effect: Effect): void;
  59732. /**
  59733. * Sets the required values for both the emissive texture and and the main color.
  59734. */
  59735. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59736. /**
  59737. * Free any resources and references associated to a mesh.
  59738. * Internal use
  59739. * @param mesh The mesh to free.
  59740. */
  59741. abstract _disposeMesh(mesh: Mesh): void;
  59742. /**
  59743. * Serializes this layer (Glow or Highlight for example)
  59744. * @returns a serialized layer object
  59745. */
  59746. abstract serialize?(): any;
  59747. /**
  59748. * Initializes the effect layer with the required options.
  59749. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59750. */
  59751. protected _init(options: Partial<IEffectLayerOptions>): void;
  59752. /**
  59753. * Generates the index buffer of the full screen quad blending to the main canvas.
  59754. */
  59755. private _generateIndexBuffer;
  59756. /**
  59757. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59758. */
  59759. private _generateVertexBuffer;
  59760. /**
  59761. * Sets the main texture desired size which is the closest power of two
  59762. * of the engine canvas size.
  59763. */
  59764. private _setMainTextureSize;
  59765. /**
  59766. * Creates the main texture for the effect layer.
  59767. */
  59768. protected _createMainTexture(): void;
  59769. /**
  59770. * Adds specific effects defines.
  59771. * @param defines The defines to add specifics to.
  59772. */
  59773. protected _addCustomEffectDefines(defines: string[]): void;
  59774. /**
  59775. * Checks for the readiness of the element composing the layer.
  59776. * @param subMesh the mesh to check for
  59777. * @param useInstances specify whether or not to use instances to render the mesh
  59778. * @param emissiveTexture the associated emissive texture used to generate the glow
  59779. * @return true if ready otherwise, false
  59780. */
  59781. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59782. /**
  59783. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59784. */
  59785. render(): void;
  59786. /**
  59787. * Determine if a given mesh will be used in the current effect.
  59788. * @param mesh mesh to test
  59789. * @returns true if the mesh will be used
  59790. */
  59791. hasMesh(mesh: AbstractMesh): boolean;
  59792. /**
  59793. * Returns true if the layer contains information to display, otherwise false.
  59794. * @returns true if the glow layer should be rendered
  59795. */
  59796. shouldRender(): boolean;
  59797. /**
  59798. * Returns true if the mesh should render, otherwise false.
  59799. * @param mesh The mesh to render
  59800. * @returns true if it should render otherwise false
  59801. */
  59802. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59803. /**
  59804. * Returns true if the mesh can be rendered, otherwise false.
  59805. * @param mesh The mesh to render
  59806. * @param material The material used on the mesh
  59807. * @returns true if it can be rendered otherwise false
  59808. */
  59809. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59810. /**
  59811. * Returns true if the mesh should render, otherwise false.
  59812. * @param mesh The mesh to render
  59813. * @returns true if it should render otherwise false
  59814. */
  59815. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59816. /**
  59817. * Renders the submesh passed in parameter to the generation map.
  59818. */
  59819. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59820. /**
  59821. * Defines whether the current material of the mesh should be use to render the effect.
  59822. * @param mesh defines the current mesh to render
  59823. */
  59824. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59825. /**
  59826. * Rebuild the required buffers.
  59827. * @hidden Internal use only.
  59828. */
  59829. _rebuild(): void;
  59830. /**
  59831. * Dispose only the render target textures and post process.
  59832. */
  59833. private _disposeTextureAndPostProcesses;
  59834. /**
  59835. * Dispose the highlight layer and free resources.
  59836. */
  59837. dispose(): void;
  59838. /**
  59839. * Gets the class name of the effect layer
  59840. * @returns the string with the class name of the effect layer
  59841. */
  59842. getClassName(): string;
  59843. /**
  59844. * Creates an effect layer from parsed effect layer data
  59845. * @param parsedEffectLayer defines effect layer data
  59846. * @param scene defines the current scene
  59847. * @param rootUrl defines the root URL containing the effect layer information
  59848. * @returns a parsed effect Layer
  59849. */
  59850. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59851. }
  59852. }
  59853. declare module BABYLON {
  59854. interface AbstractScene {
  59855. /**
  59856. * The list of effect layers (highlights/glow) added to the scene
  59857. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59858. * @see https://doc.babylonjs.com/how_to/glow_layer
  59859. */
  59860. effectLayers: Array<EffectLayer>;
  59861. /**
  59862. * Removes the given effect layer from this scene.
  59863. * @param toRemove defines the effect layer to remove
  59864. * @returns the index of the removed effect layer
  59865. */
  59866. removeEffectLayer(toRemove: EffectLayer): number;
  59867. /**
  59868. * Adds the given effect layer to this scene
  59869. * @param newEffectLayer defines the effect layer to add
  59870. */
  59871. addEffectLayer(newEffectLayer: EffectLayer): void;
  59872. }
  59873. /**
  59874. * Defines the layer scene component responsible to manage any effect layers
  59875. * in a given scene.
  59876. */
  59877. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59878. /**
  59879. * The component name helpfull to identify the component in the list of scene components.
  59880. */
  59881. readonly name: string;
  59882. /**
  59883. * The scene the component belongs to.
  59884. */
  59885. scene: Scene;
  59886. private _engine;
  59887. private _renderEffects;
  59888. private _needStencil;
  59889. private _previousStencilState;
  59890. /**
  59891. * Creates a new instance of the component for the given scene
  59892. * @param scene Defines the scene to register the component in
  59893. */
  59894. constructor(scene: Scene);
  59895. /**
  59896. * Registers the component in a given scene
  59897. */
  59898. register(): void;
  59899. /**
  59900. * Rebuilds the elements related to this component in case of
  59901. * context lost for instance.
  59902. */
  59903. rebuild(): void;
  59904. /**
  59905. * Serializes the component data to the specified json object
  59906. * @param serializationObject The object to serialize to
  59907. */
  59908. serialize(serializationObject: any): void;
  59909. /**
  59910. * Adds all the elements from the container to the scene
  59911. * @param container the container holding the elements
  59912. */
  59913. addFromContainer(container: AbstractScene): void;
  59914. /**
  59915. * Removes all the elements in the container from the scene
  59916. * @param container contains the elements to remove
  59917. * @param dispose if the removed element should be disposed (default: false)
  59918. */
  59919. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59920. /**
  59921. * Disposes the component and the associated ressources.
  59922. */
  59923. dispose(): void;
  59924. private _isReadyForMesh;
  59925. private _renderMainTexture;
  59926. private _setStencil;
  59927. private _setStencilBack;
  59928. private _draw;
  59929. private _drawCamera;
  59930. private _drawRenderingGroup;
  59931. }
  59932. }
  59933. declare module BABYLON {
  59934. /** @hidden */
  59935. export var glowMapMergePixelShader: {
  59936. name: string;
  59937. shader: string;
  59938. };
  59939. }
  59940. declare module BABYLON {
  59941. /** @hidden */
  59942. export var glowMapMergeVertexShader: {
  59943. name: string;
  59944. shader: string;
  59945. };
  59946. }
  59947. declare module BABYLON {
  59948. interface AbstractScene {
  59949. /**
  59950. * Return a the first highlight layer of the scene with a given name.
  59951. * @param name The name of the highlight layer to look for.
  59952. * @return The highlight layer if found otherwise null.
  59953. */
  59954. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59955. }
  59956. /**
  59957. * Glow layer options. This helps customizing the behaviour
  59958. * of the glow layer.
  59959. */
  59960. export interface IGlowLayerOptions {
  59961. /**
  59962. * Multiplication factor apply to the canvas size to compute the render target size
  59963. * used to generated the glowing objects (the smaller the faster).
  59964. */
  59965. mainTextureRatio: number;
  59966. /**
  59967. * Enforces a fixed size texture to ensure resize independant blur.
  59968. */
  59969. mainTextureFixedSize?: number;
  59970. /**
  59971. * How big is the kernel of the blur texture.
  59972. */
  59973. blurKernelSize: number;
  59974. /**
  59975. * The camera attached to the layer.
  59976. */
  59977. camera: Nullable<Camera>;
  59978. /**
  59979. * Enable MSAA by chosing the number of samples.
  59980. */
  59981. mainTextureSamples?: number;
  59982. /**
  59983. * The rendering group to draw the layer in.
  59984. */
  59985. renderingGroupId: number;
  59986. }
  59987. /**
  59988. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59989. *
  59990. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59991. *
  59992. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59993. */
  59994. export class GlowLayer extends EffectLayer {
  59995. /**
  59996. * Effect Name of the layer.
  59997. */
  59998. static readonly EffectName: string;
  59999. /**
  60000. * The default blur kernel size used for the glow.
  60001. */
  60002. static DefaultBlurKernelSize: number;
  60003. /**
  60004. * The default texture size ratio used for the glow.
  60005. */
  60006. static DefaultTextureRatio: number;
  60007. /**
  60008. * Sets the kernel size of the blur.
  60009. */
  60010. set blurKernelSize(value: number);
  60011. /**
  60012. * Gets the kernel size of the blur.
  60013. */
  60014. get blurKernelSize(): number;
  60015. /**
  60016. * Sets the glow intensity.
  60017. */
  60018. set intensity(value: number);
  60019. /**
  60020. * Gets the glow intensity.
  60021. */
  60022. get intensity(): number;
  60023. private _options;
  60024. private _intensity;
  60025. private _horizontalBlurPostprocess1;
  60026. private _verticalBlurPostprocess1;
  60027. private _horizontalBlurPostprocess2;
  60028. private _verticalBlurPostprocess2;
  60029. private _blurTexture1;
  60030. private _blurTexture2;
  60031. private _postProcesses1;
  60032. private _postProcesses2;
  60033. private _includedOnlyMeshes;
  60034. private _excludedMeshes;
  60035. private _meshesUsingTheirOwnMaterials;
  60036. /**
  60037. * Callback used to let the user override the color selection on a per mesh basis
  60038. */
  60039. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60040. /**
  60041. * Callback used to let the user override the texture selection on a per mesh basis
  60042. */
  60043. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60044. /**
  60045. * Instantiates a new glow Layer and references it to the scene.
  60046. * @param name The name of the layer
  60047. * @param scene The scene to use the layer in
  60048. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60049. */
  60050. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60051. /**
  60052. * Get the effect name of the layer.
  60053. * @return The effect name
  60054. */
  60055. getEffectName(): string;
  60056. /**
  60057. * Create the merge effect. This is the shader use to blit the information back
  60058. * to the main canvas at the end of the scene rendering.
  60059. */
  60060. protected _createMergeEffect(): Effect;
  60061. /**
  60062. * Creates the render target textures and post processes used in the glow layer.
  60063. */
  60064. protected _createTextureAndPostProcesses(): void;
  60065. /**
  60066. * Checks for the readiness of the element composing the layer.
  60067. * @param subMesh the mesh to check for
  60068. * @param useInstances specify wether or not to use instances to render the mesh
  60069. * @param emissiveTexture the associated emissive texture used to generate the glow
  60070. * @return true if ready otherwise, false
  60071. */
  60072. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60073. /**
  60074. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60075. */
  60076. needStencil(): boolean;
  60077. /**
  60078. * Returns true if the mesh can be rendered, otherwise false.
  60079. * @param mesh The mesh to render
  60080. * @param material The material used on the mesh
  60081. * @returns true if it can be rendered otherwise false
  60082. */
  60083. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60084. /**
  60085. * Implementation specific of rendering the generating effect on the main canvas.
  60086. * @param effect The effect used to render through
  60087. */
  60088. protected _internalRender(effect: Effect): void;
  60089. /**
  60090. * Sets the required values for both the emissive texture and and the main color.
  60091. */
  60092. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60093. /**
  60094. * Returns true if the mesh should render, otherwise false.
  60095. * @param mesh The mesh to render
  60096. * @returns true if it should render otherwise false
  60097. */
  60098. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60099. /**
  60100. * Adds specific effects defines.
  60101. * @param defines The defines to add specifics to.
  60102. */
  60103. protected _addCustomEffectDefines(defines: string[]): void;
  60104. /**
  60105. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60106. * @param mesh The mesh to exclude from the glow layer
  60107. */
  60108. addExcludedMesh(mesh: Mesh): void;
  60109. /**
  60110. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60111. * @param mesh The mesh to remove
  60112. */
  60113. removeExcludedMesh(mesh: Mesh): void;
  60114. /**
  60115. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60116. * @param mesh The mesh to include in the glow layer
  60117. */
  60118. addIncludedOnlyMesh(mesh: Mesh): void;
  60119. /**
  60120. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60121. * @param mesh The mesh to remove
  60122. */
  60123. removeIncludedOnlyMesh(mesh: Mesh): void;
  60124. /**
  60125. * Determine if a given mesh will be used in the glow layer
  60126. * @param mesh The mesh to test
  60127. * @returns true if the mesh will be highlighted by the current glow layer
  60128. */
  60129. hasMesh(mesh: AbstractMesh): boolean;
  60130. /**
  60131. * Defines whether the current material of the mesh should be use to render the effect.
  60132. * @param mesh defines the current mesh to render
  60133. */
  60134. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60135. /**
  60136. * Add a mesh to be rendered through its own material and not with emissive only.
  60137. * @param mesh The mesh for which we need to use its material
  60138. */
  60139. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60140. /**
  60141. * Remove a mesh from being rendered through its own material and not with emissive only.
  60142. * @param mesh The mesh for which we need to not use its material
  60143. */
  60144. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60145. /**
  60146. * Free any resources and references associated to a mesh.
  60147. * Internal use
  60148. * @param mesh The mesh to free.
  60149. * @hidden
  60150. */
  60151. _disposeMesh(mesh: Mesh): void;
  60152. /**
  60153. * Gets the class name of the effect layer
  60154. * @returns the string with the class name of the effect layer
  60155. */
  60156. getClassName(): string;
  60157. /**
  60158. * Serializes this glow layer
  60159. * @returns a serialized glow layer object
  60160. */
  60161. serialize(): any;
  60162. /**
  60163. * Creates a Glow Layer from parsed glow layer data
  60164. * @param parsedGlowLayer defines glow layer data
  60165. * @param scene defines the current scene
  60166. * @param rootUrl defines the root URL containing the glow layer information
  60167. * @returns a parsed Glow Layer
  60168. */
  60169. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60170. }
  60171. }
  60172. declare module BABYLON {
  60173. /** @hidden */
  60174. export var glowBlurPostProcessPixelShader: {
  60175. name: string;
  60176. shader: string;
  60177. };
  60178. }
  60179. declare module BABYLON {
  60180. interface AbstractScene {
  60181. /**
  60182. * Return a the first highlight layer of the scene with a given name.
  60183. * @param name The name of the highlight layer to look for.
  60184. * @return The highlight layer if found otherwise null.
  60185. */
  60186. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60187. }
  60188. /**
  60189. * Highlight layer options. This helps customizing the behaviour
  60190. * of the highlight layer.
  60191. */
  60192. export interface IHighlightLayerOptions {
  60193. /**
  60194. * Multiplication factor apply to the canvas size to compute the render target size
  60195. * used to generated the glowing objects (the smaller the faster).
  60196. */
  60197. mainTextureRatio: number;
  60198. /**
  60199. * Enforces a fixed size texture to ensure resize independant blur.
  60200. */
  60201. mainTextureFixedSize?: number;
  60202. /**
  60203. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60204. * of the picture to blur (the smaller the faster).
  60205. */
  60206. blurTextureSizeRatio: number;
  60207. /**
  60208. * How big in texel of the blur texture is the vertical blur.
  60209. */
  60210. blurVerticalSize: number;
  60211. /**
  60212. * How big in texel of the blur texture is the horizontal blur.
  60213. */
  60214. blurHorizontalSize: number;
  60215. /**
  60216. * Alpha blending mode used to apply the blur. Default is combine.
  60217. */
  60218. alphaBlendingMode: number;
  60219. /**
  60220. * The camera attached to the layer.
  60221. */
  60222. camera: Nullable<Camera>;
  60223. /**
  60224. * Should we display highlight as a solid stroke?
  60225. */
  60226. isStroke?: boolean;
  60227. /**
  60228. * The rendering group to draw the layer in.
  60229. */
  60230. renderingGroupId: number;
  60231. }
  60232. /**
  60233. * The highlight layer Helps adding a glow effect around a mesh.
  60234. *
  60235. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60236. * glowy meshes to your scene.
  60237. *
  60238. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60239. */
  60240. export class HighlightLayer extends EffectLayer {
  60241. name: string;
  60242. /**
  60243. * Effect Name of the highlight layer.
  60244. */
  60245. static readonly EffectName: string;
  60246. /**
  60247. * The neutral color used during the preparation of the glow effect.
  60248. * This is black by default as the blend operation is a blend operation.
  60249. */
  60250. static NeutralColor: Color4;
  60251. /**
  60252. * Stencil value used for glowing meshes.
  60253. */
  60254. static GlowingMeshStencilReference: number;
  60255. /**
  60256. * Stencil value used for the other meshes in the scene.
  60257. */
  60258. static NormalMeshStencilReference: number;
  60259. /**
  60260. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60261. */
  60262. innerGlow: boolean;
  60263. /**
  60264. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60265. */
  60266. outerGlow: boolean;
  60267. /**
  60268. * Specifies the horizontal size of the blur.
  60269. */
  60270. set blurHorizontalSize(value: number);
  60271. /**
  60272. * Specifies the vertical size of the blur.
  60273. */
  60274. set blurVerticalSize(value: number);
  60275. /**
  60276. * Gets the horizontal size of the blur.
  60277. */
  60278. get blurHorizontalSize(): number;
  60279. /**
  60280. * Gets the vertical size of the blur.
  60281. */
  60282. get blurVerticalSize(): number;
  60283. /**
  60284. * An event triggered when the highlight layer is being blurred.
  60285. */
  60286. onBeforeBlurObservable: Observable<HighlightLayer>;
  60287. /**
  60288. * An event triggered when the highlight layer has been blurred.
  60289. */
  60290. onAfterBlurObservable: Observable<HighlightLayer>;
  60291. private _instanceGlowingMeshStencilReference;
  60292. private _options;
  60293. private _downSamplePostprocess;
  60294. private _horizontalBlurPostprocess;
  60295. private _verticalBlurPostprocess;
  60296. private _blurTexture;
  60297. private _meshes;
  60298. private _excludedMeshes;
  60299. /**
  60300. * Instantiates a new highlight Layer and references it to the scene..
  60301. * @param name The name of the layer
  60302. * @param scene The scene to use the layer in
  60303. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60304. */
  60305. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60306. /**
  60307. * Get the effect name of the layer.
  60308. * @return The effect name
  60309. */
  60310. getEffectName(): string;
  60311. /**
  60312. * Create the merge effect. This is the shader use to blit the information back
  60313. * to the main canvas at the end of the scene rendering.
  60314. */
  60315. protected _createMergeEffect(): Effect;
  60316. /**
  60317. * Creates the render target textures and post processes used in the highlight layer.
  60318. */
  60319. protected _createTextureAndPostProcesses(): void;
  60320. /**
  60321. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60322. */
  60323. needStencil(): boolean;
  60324. /**
  60325. * Checks for the readiness of the element composing the layer.
  60326. * @param subMesh the mesh to check for
  60327. * @param useInstances specify wether or not to use instances to render the mesh
  60328. * @param emissiveTexture the associated emissive texture used to generate the glow
  60329. * @return true if ready otherwise, false
  60330. */
  60331. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60332. /**
  60333. * Implementation specific of rendering the generating effect on the main canvas.
  60334. * @param effect The effect used to render through
  60335. */
  60336. protected _internalRender(effect: Effect): void;
  60337. /**
  60338. * Returns true if the layer contains information to display, otherwise false.
  60339. */
  60340. shouldRender(): boolean;
  60341. /**
  60342. * Returns true if the mesh should render, otherwise false.
  60343. * @param mesh The mesh to render
  60344. * @returns true if it should render otherwise false
  60345. */
  60346. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60347. /**
  60348. * Returns true if the mesh can be rendered, otherwise false.
  60349. * @param mesh The mesh to render
  60350. * @param material The material used on the mesh
  60351. * @returns true if it can be rendered otherwise false
  60352. */
  60353. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60354. /**
  60355. * Adds specific effects defines.
  60356. * @param defines The defines to add specifics to.
  60357. */
  60358. protected _addCustomEffectDefines(defines: string[]): void;
  60359. /**
  60360. * Sets the required values for both the emissive texture and and the main color.
  60361. */
  60362. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60363. /**
  60364. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60365. * @param mesh The mesh to exclude from the highlight layer
  60366. */
  60367. addExcludedMesh(mesh: Mesh): void;
  60368. /**
  60369. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60370. * @param mesh The mesh to highlight
  60371. */
  60372. removeExcludedMesh(mesh: Mesh): void;
  60373. /**
  60374. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60375. * @param mesh mesh to test
  60376. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60377. */
  60378. hasMesh(mesh: AbstractMesh): boolean;
  60379. /**
  60380. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60381. * @param mesh The mesh to highlight
  60382. * @param color The color of the highlight
  60383. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60384. */
  60385. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60386. /**
  60387. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60388. * @param mesh The mesh to highlight
  60389. */
  60390. removeMesh(mesh: Mesh): void;
  60391. /**
  60392. * Remove all the meshes currently referenced in the highlight layer
  60393. */
  60394. removeAllMeshes(): void;
  60395. /**
  60396. * Force the stencil to the normal expected value for none glowing parts
  60397. */
  60398. private _defaultStencilReference;
  60399. /**
  60400. * Free any resources and references associated to a mesh.
  60401. * Internal use
  60402. * @param mesh The mesh to free.
  60403. * @hidden
  60404. */
  60405. _disposeMesh(mesh: Mesh): void;
  60406. /**
  60407. * Dispose the highlight layer and free resources.
  60408. */
  60409. dispose(): void;
  60410. /**
  60411. * Gets the class name of the effect layer
  60412. * @returns the string with the class name of the effect layer
  60413. */
  60414. getClassName(): string;
  60415. /**
  60416. * Serializes this Highlight layer
  60417. * @returns a serialized Highlight layer object
  60418. */
  60419. serialize(): any;
  60420. /**
  60421. * Creates a Highlight layer from parsed Highlight layer data
  60422. * @param parsedHightlightLayer defines the Highlight layer data
  60423. * @param scene defines the current scene
  60424. * @param rootUrl defines the root URL containing the Highlight layer information
  60425. * @returns a parsed Highlight layer
  60426. */
  60427. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60428. }
  60429. }
  60430. declare module BABYLON {
  60431. interface AbstractScene {
  60432. /**
  60433. * The list of layers (background and foreground) of the scene
  60434. */
  60435. layers: Array<Layer>;
  60436. }
  60437. /**
  60438. * Defines the layer scene component responsible to manage any layers
  60439. * in a given scene.
  60440. */
  60441. export class LayerSceneComponent implements ISceneComponent {
  60442. /**
  60443. * The component name helpfull to identify the component in the list of scene components.
  60444. */
  60445. readonly name: string;
  60446. /**
  60447. * The scene the component belongs to.
  60448. */
  60449. scene: Scene;
  60450. private _engine;
  60451. /**
  60452. * Creates a new instance of the component for the given scene
  60453. * @param scene Defines the scene to register the component in
  60454. */
  60455. constructor(scene: Scene);
  60456. /**
  60457. * Registers the component in a given scene
  60458. */
  60459. register(): void;
  60460. /**
  60461. * Rebuilds the elements related to this component in case of
  60462. * context lost for instance.
  60463. */
  60464. rebuild(): void;
  60465. /**
  60466. * Disposes the component and the associated ressources.
  60467. */
  60468. dispose(): void;
  60469. private _draw;
  60470. private _drawCameraPredicate;
  60471. private _drawCameraBackground;
  60472. private _drawCameraForeground;
  60473. private _drawRenderTargetPredicate;
  60474. private _drawRenderTargetBackground;
  60475. private _drawRenderTargetForeground;
  60476. /**
  60477. * Adds all the elements from the container to the scene
  60478. * @param container the container holding the elements
  60479. */
  60480. addFromContainer(container: AbstractScene): void;
  60481. /**
  60482. * Removes all the elements in the container from the scene
  60483. * @param container contains the elements to remove
  60484. * @param dispose if the removed element should be disposed (default: false)
  60485. */
  60486. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60487. }
  60488. }
  60489. declare module BABYLON {
  60490. /** @hidden */
  60491. export var layerPixelShader: {
  60492. name: string;
  60493. shader: string;
  60494. };
  60495. }
  60496. declare module BABYLON {
  60497. /** @hidden */
  60498. export var layerVertexShader: {
  60499. name: string;
  60500. shader: string;
  60501. };
  60502. }
  60503. declare module BABYLON {
  60504. /**
  60505. * This represents a full screen 2d layer.
  60506. * This can be useful to display a picture in the background of your scene for instance.
  60507. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60508. */
  60509. export class Layer {
  60510. /**
  60511. * Define the name of the layer.
  60512. */
  60513. name: string;
  60514. /**
  60515. * Define the texture the layer should display.
  60516. */
  60517. texture: Nullable<Texture>;
  60518. /**
  60519. * Is the layer in background or foreground.
  60520. */
  60521. isBackground: boolean;
  60522. /**
  60523. * Define the color of the layer (instead of texture).
  60524. */
  60525. color: Color4;
  60526. /**
  60527. * Define the scale of the layer in order to zoom in out of the texture.
  60528. */
  60529. scale: Vector2;
  60530. /**
  60531. * Define an offset for the layer in order to shift the texture.
  60532. */
  60533. offset: Vector2;
  60534. /**
  60535. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60536. */
  60537. alphaBlendingMode: number;
  60538. /**
  60539. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60540. * Alpha test will not mix with the background color in case of transparency.
  60541. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60542. */
  60543. alphaTest: boolean;
  60544. /**
  60545. * Define a mask to restrict the layer to only some of the scene cameras.
  60546. */
  60547. layerMask: number;
  60548. /**
  60549. * Define the list of render target the layer is visible into.
  60550. */
  60551. renderTargetTextures: RenderTargetTexture[];
  60552. /**
  60553. * Define if the layer is only used in renderTarget or if it also
  60554. * renders in the main frame buffer of the canvas.
  60555. */
  60556. renderOnlyInRenderTargetTextures: boolean;
  60557. private _scene;
  60558. private _vertexBuffers;
  60559. private _indexBuffer;
  60560. private _effect;
  60561. private _previousDefines;
  60562. /**
  60563. * An event triggered when the layer is disposed.
  60564. */
  60565. onDisposeObservable: Observable<Layer>;
  60566. private _onDisposeObserver;
  60567. /**
  60568. * Back compatibility with callback before the onDisposeObservable existed.
  60569. * The set callback will be triggered when the layer has been disposed.
  60570. */
  60571. set onDispose(callback: () => void);
  60572. /**
  60573. * An event triggered before rendering the scene
  60574. */
  60575. onBeforeRenderObservable: Observable<Layer>;
  60576. private _onBeforeRenderObserver;
  60577. /**
  60578. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60579. * The set callback will be triggered just before rendering the layer.
  60580. */
  60581. set onBeforeRender(callback: () => void);
  60582. /**
  60583. * An event triggered after rendering the scene
  60584. */
  60585. onAfterRenderObservable: Observable<Layer>;
  60586. private _onAfterRenderObserver;
  60587. /**
  60588. * Back compatibility with callback before the onAfterRenderObservable existed.
  60589. * The set callback will be triggered just after rendering the layer.
  60590. */
  60591. set onAfterRender(callback: () => void);
  60592. /**
  60593. * Instantiates a new layer.
  60594. * This represents a full screen 2d layer.
  60595. * This can be useful to display a picture in the background of your scene for instance.
  60596. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60597. * @param name Define the name of the layer in the scene
  60598. * @param imgUrl Define the url of the texture to display in the layer
  60599. * @param scene Define the scene the layer belongs to
  60600. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60601. * @param color Defines a color for the layer
  60602. */
  60603. constructor(
  60604. /**
  60605. * Define the name of the layer.
  60606. */
  60607. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60608. private _createIndexBuffer;
  60609. /** @hidden */
  60610. _rebuild(): void;
  60611. /**
  60612. * Renders the layer in the scene.
  60613. */
  60614. render(): void;
  60615. /**
  60616. * Disposes and releases the associated ressources.
  60617. */
  60618. dispose(): void;
  60619. }
  60620. }
  60621. declare module BABYLON {
  60622. /** @hidden */
  60623. export var lensFlarePixelShader: {
  60624. name: string;
  60625. shader: string;
  60626. };
  60627. }
  60628. declare module BABYLON {
  60629. /** @hidden */
  60630. export var lensFlareVertexShader: {
  60631. name: string;
  60632. shader: string;
  60633. };
  60634. }
  60635. declare module BABYLON {
  60636. /**
  60637. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60638. * It is usually composed of several `lensFlare`.
  60639. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60640. */
  60641. export class LensFlareSystem {
  60642. /**
  60643. * Define the name of the lens flare system
  60644. */
  60645. name: string;
  60646. /**
  60647. * List of lens flares used in this system.
  60648. */
  60649. lensFlares: LensFlare[];
  60650. /**
  60651. * Define a limit from the border the lens flare can be visible.
  60652. */
  60653. borderLimit: number;
  60654. /**
  60655. * Define a viewport border we do not want to see the lens flare in.
  60656. */
  60657. viewportBorder: number;
  60658. /**
  60659. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60660. */
  60661. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60662. /**
  60663. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60664. */
  60665. layerMask: number;
  60666. /**
  60667. * Define the id of the lens flare system in the scene.
  60668. * (equal to name by default)
  60669. */
  60670. id: string;
  60671. private _scene;
  60672. private _emitter;
  60673. private _vertexBuffers;
  60674. private _indexBuffer;
  60675. private _effect;
  60676. private _positionX;
  60677. private _positionY;
  60678. private _isEnabled;
  60679. /** @hidden */
  60680. static _SceneComponentInitialization: (scene: Scene) => void;
  60681. /**
  60682. * Instantiates a lens flare system.
  60683. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60684. * It is usually composed of several `lensFlare`.
  60685. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60686. * @param name Define the name of the lens flare system in the scene
  60687. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60688. * @param scene Define the scene the lens flare system belongs to
  60689. */
  60690. constructor(
  60691. /**
  60692. * Define the name of the lens flare system
  60693. */
  60694. name: string, emitter: any, scene: Scene);
  60695. /**
  60696. * Define if the lens flare system is enabled.
  60697. */
  60698. get isEnabled(): boolean;
  60699. set isEnabled(value: boolean);
  60700. /**
  60701. * Get the scene the effects belongs to.
  60702. * @returns the scene holding the lens flare system
  60703. */
  60704. getScene(): Scene;
  60705. /**
  60706. * Get the emitter of the lens flare system.
  60707. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60708. * @returns the emitter of the lens flare system
  60709. */
  60710. getEmitter(): any;
  60711. /**
  60712. * Set the emitter of the lens flare system.
  60713. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60714. * @param newEmitter Define the new emitter of the system
  60715. */
  60716. setEmitter(newEmitter: any): void;
  60717. /**
  60718. * Get the lens flare system emitter position.
  60719. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60720. * @returns the position
  60721. */
  60722. getEmitterPosition(): Vector3;
  60723. /**
  60724. * @hidden
  60725. */
  60726. computeEffectivePosition(globalViewport: Viewport): boolean;
  60727. /** @hidden */
  60728. _isVisible(): boolean;
  60729. /**
  60730. * @hidden
  60731. */
  60732. render(): boolean;
  60733. /**
  60734. * Dispose and release the lens flare with its associated resources.
  60735. */
  60736. dispose(): void;
  60737. /**
  60738. * Parse a lens flare system from a JSON repressentation
  60739. * @param parsedLensFlareSystem Define the JSON to parse
  60740. * @param scene Define the scene the parsed system should be instantiated in
  60741. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60742. * @returns the parsed system
  60743. */
  60744. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60745. /**
  60746. * Serialize the current Lens Flare System into a JSON representation.
  60747. * @returns the serialized JSON
  60748. */
  60749. serialize(): any;
  60750. }
  60751. }
  60752. declare module BABYLON {
  60753. /**
  60754. * This represents one of the lens effect in a `lensFlareSystem`.
  60755. * It controls one of the indiviual texture used in the effect.
  60756. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60757. */
  60758. export class LensFlare {
  60759. /**
  60760. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60761. */
  60762. size: number;
  60763. /**
  60764. * 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.
  60765. */
  60766. position: number;
  60767. /**
  60768. * Define the lens color.
  60769. */
  60770. color: Color3;
  60771. /**
  60772. * Define the lens texture.
  60773. */
  60774. texture: Nullable<Texture>;
  60775. /**
  60776. * Define the alpha mode to render this particular lens.
  60777. */
  60778. alphaMode: number;
  60779. private _system;
  60780. /**
  60781. * Creates a new Lens Flare.
  60782. * This represents one of the lens effect in a `lensFlareSystem`.
  60783. * It controls one of the indiviual texture used in the effect.
  60784. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60785. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60786. * @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.
  60787. * @param color Define the lens color
  60788. * @param imgUrl Define the lens texture url
  60789. * @param system Define the `lensFlareSystem` this flare is part of
  60790. * @returns The newly created Lens Flare
  60791. */
  60792. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60793. /**
  60794. * Instantiates a new Lens Flare.
  60795. * This represents one of the lens effect in a `lensFlareSystem`.
  60796. * It controls one of the indiviual texture used in the effect.
  60797. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60798. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60799. * @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.
  60800. * @param color Define the lens color
  60801. * @param imgUrl Define the lens texture url
  60802. * @param system Define the `lensFlareSystem` this flare is part of
  60803. */
  60804. constructor(
  60805. /**
  60806. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60807. */
  60808. size: number,
  60809. /**
  60810. * 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.
  60811. */
  60812. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60813. /**
  60814. * Dispose and release the lens flare with its associated resources.
  60815. */
  60816. dispose(): void;
  60817. }
  60818. }
  60819. declare module BABYLON {
  60820. interface AbstractScene {
  60821. /**
  60822. * The list of lens flare system added to the scene
  60823. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60824. */
  60825. lensFlareSystems: Array<LensFlareSystem>;
  60826. /**
  60827. * Removes the given lens flare system from this scene.
  60828. * @param toRemove The lens flare system to remove
  60829. * @returns The index of the removed lens flare system
  60830. */
  60831. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60832. /**
  60833. * Adds the given lens flare system to this scene
  60834. * @param newLensFlareSystem The lens flare system to add
  60835. */
  60836. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60837. /**
  60838. * Gets a lens flare system using its name
  60839. * @param name defines the name to look for
  60840. * @returns the lens flare system or null if not found
  60841. */
  60842. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60843. /**
  60844. * Gets a lens flare system using its id
  60845. * @param id defines the id to look for
  60846. * @returns the lens flare system or null if not found
  60847. */
  60848. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60849. }
  60850. /**
  60851. * Defines the lens flare scene component responsible to manage any lens flares
  60852. * in a given scene.
  60853. */
  60854. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60855. /**
  60856. * The component name helpfull to identify the component in the list of scene components.
  60857. */
  60858. readonly name: string;
  60859. /**
  60860. * The scene the component belongs to.
  60861. */
  60862. scene: Scene;
  60863. /**
  60864. * Creates a new instance of the component for the given scene
  60865. * @param scene Defines the scene to register the component in
  60866. */
  60867. constructor(scene: Scene);
  60868. /**
  60869. * Registers the component in a given scene
  60870. */
  60871. register(): void;
  60872. /**
  60873. * Rebuilds the elements related to this component in case of
  60874. * context lost for instance.
  60875. */
  60876. rebuild(): void;
  60877. /**
  60878. * Adds all the elements from the container to the scene
  60879. * @param container the container holding the elements
  60880. */
  60881. addFromContainer(container: AbstractScene): void;
  60882. /**
  60883. * Removes all the elements in the container from the scene
  60884. * @param container contains the elements to remove
  60885. * @param dispose if the removed element should be disposed (default: false)
  60886. */
  60887. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60888. /**
  60889. * Serializes the component data to the specified json object
  60890. * @param serializationObject The object to serialize to
  60891. */
  60892. serialize(serializationObject: any): void;
  60893. /**
  60894. * Disposes the component and the associated ressources.
  60895. */
  60896. dispose(): void;
  60897. private _draw;
  60898. }
  60899. }
  60900. declare module BABYLON {
  60901. /** @hidden */
  60902. export var depthPixelShader: {
  60903. name: string;
  60904. shader: string;
  60905. };
  60906. }
  60907. declare module BABYLON {
  60908. /** @hidden */
  60909. export var depthVertexShader: {
  60910. name: string;
  60911. shader: string;
  60912. };
  60913. }
  60914. declare module BABYLON {
  60915. /**
  60916. * This represents a depth renderer in Babylon.
  60917. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60918. */
  60919. export class DepthRenderer {
  60920. private _scene;
  60921. private _depthMap;
  60922. private _effect;
  60923. private readonly _storeNonLinearDepth;
  60924. private readonly _clearColor;
  60925. /** Get if the depth renderer is using packed depth or not */
  60926. readonly isPacked: boolean;
  60927. private _cachedDefines;
  60928. private _camera;
  60929. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60930. enabled: boolean;
  60931. /**
  60932. * Specifiess that the depth renderer will only be used within
  60933. * the camera it is created for.
  60934. * This can help forcing its rendering during the camera processing.
  60935. */
  60936. useOnlyInActiveCamera: boolean;
  60937. /** @hidden */
  60938. static _SceneComponentInitialization: (scene: Scene) => void;
  60939. /**
  60940. * Instantiates a depth renderer
  60941. * @param scene The scene the renderer belongs to
  60942. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60943. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60944. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60945. */
  60946. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60947. /**
  60948. * Creates the depth rendering effect and checks if the effect is ready.
  60949. * @param subMesh The submesh to be used to render the depth map of
  60950. * @param useInstances If multiple world instances should be used
  60951. * @returns if the depth renderer is ready to render the depth map
  60952. */
  60953. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60954. /**
  60955. * Gets the texture which the depth map will be written to.
  60956. * @returns The depth map texture
  60957. */
  60958. getDepthMap(): RenderTargetTexture;
  60959. /**
  60960. * Disposes of the depth renderer.
  60961. */
  60962. dispose(): void;
  60963. }
  60964. }
  60965. declare module BABYLON {
  60966. /** @hidden */
  60967. export var minmaxReduxPixelShader: {
  60968. name: string;
  60969. shader: string;
  60970. };
  60971. }
  60972. declare module BABYLON {
  60973. /**
  60974. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60975. * and maximum values from all values of the texture.
  60976. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60977. * The source values are read from the red channel of the texture.
  60978. */
  60979. export class MinMaxReducer {
  60980. /**
  60981. * Observable triggered when the computation has been performed
  60982. */
  60983. onAfterReductionPerformed: Observable<{
  60984. min: number;
  60985. max: number;
  60986. }>;
  60987. protected _camera: Camera;
  60988. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60989. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60990. protected _postProcessManager: PostProcessManager;
  60991. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60992. protected _forceFullscreenViewport: boolean;
  60993. /**
  60994. * Creates a min/max reducer
  60995. * @param camera The camera to use for the post processes
  60996. */
  60997. constructor(camera: Camera);
  60998. /**
  60999. * Gets the texture used to read the values from.
  61000. */
  61001. get sourceTexture(): Nullable<RenderTargetTexture>;
  61002. /**
  61003. * Sets the source texture to read the values from.
  61004. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61005. * because in such textures '1' value must not be taken into account to compute the maximum
  61006. * as this value is used to clear the texture.
  61007. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61008. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61009. * @param depthRedux Indicates if the texture is a depth texture or not
  61010. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61011. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61012. */
  61013. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61014. /**
  61015. * Defines the refresh rate of the computation.
  61016. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61017. */
  61018. get refreshRate(): number;
  61019. set refreshRate(value: number);
  61020. protected _activated: boolean;
  61021. /**
  61022. * Gets the activation status of the reducer
  61023. */
  61024. get activated(): boolean;
  61025. /**
  61026. * Activates the reduction computation.
  61027. * When activated, the observers registered in onAfterReductionPerformed are
  61028. * called after the compuation is performed
  61029. */
  61030. activate(): void;
  61031. /**
  61032. * Deactivates the reduction computation.
  61033. */
  61034. deactivate(): void;
  61035. /**
  61036. * Disposes the min/max reducer
  61037. * @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.
  61038. */
  61039. dispose(disposeAll?: boolean): void;
  61040. }
  61041. }
  61042. declare module BABYLON {
  61043. /**
  61044. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61045. */
  61046. export class DepthReducer extends MinMaxReducer {
  61047. private _depthRenderer;
  61048. private _depthRendererId;
  61049. /**
  61050. * Gets the depth renderer used for the computation.
  61051. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61052. */
  61053. get depthRenderer(): Nullable<DepthRenderer>;
  61054. /**
  61055. * Creates a depth reducer
  61056. * @param camera The camera used to render the depth texture
  61057. */
  61058. constructor(camera: Camera);
  61059. /**
  61060. * Sets the depth renderer to use to generate the depth map
  61061. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61062. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61063. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61064. */
  61065. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61066. /** @hidden */
  61067. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61068. /**
  61069. * Activates the reduction computation.
  61070. * When activated, the observers registered in onAfterReductionPerformed are
  61071. * called after the compuation is performed
  61072. */
  61073. activate(): void;
  61074. /**
  61075. * Deactivates the reduction computation.
  61076. */
  61077. deactivate(): void;
  61078. /**
  61079. * Disposes the depth reducer
  61080. * @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.
  61081. */
  61082. dispose(disposeAll?: boolean): void;
  61083. }
  61084. }
  61085. declare module BABYLON {
  61086. /**
  61087. * A CSM implementation allowing casting shadows on large scenes.
  61088. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61089. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61090. */
  61091. export class CascadedShadowGenerator extends ShadowGenerator {
  61092. private static readonly frustumCornersNDCSpace;
  61093. /**
  61094. * Name of the CSM class
  61095. */
  61096. static CLASSNAME: string;
  61097. /**
  61098. * Defines the default number of cascades used by the CSM.
  61099. */
  61100. static readonly DEFAULT_CASCADES_COUNT: number;
  61101. /**
  61102. * Defines the minimum number of cascades used by the CSM.
  61103. */
  61104. static readonly MIN_CASCADES_COUNT: number;
  61105. /**
  61106. * Defines the maximum number of cascades used by the CSM.
  61107. */
  61108. static readonly MAX_CASCADES_COUNT: number;
  61109. protected _validateFilter(filter: number): number;
  61110. /**
  61111. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61112. */
  61113. penumbraDarkness: number;
  61114. private _numCascades;
  61115. /**
  61116. * Gets or set the number of cascades used by the CSM.
  61117. */
  61118. get numCascades(): number;
  61119. set numCascades(value: number);
  61120. /**
  61121. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61122. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61123. */
  61124. stabilizeCascades: boolean;
  61125. private _freezeShadowCastersBoundingInfo;
  61126. private _freezeShadowCastersBoundingInfoObservable;
  61127. /**
  61128. * Enables or disables the shadow casters bounding info computation.
  61129. * If your shadow casters don't move, you can disable this feature.
  61130. * If it is enabled, the bounding box computation is done every frame.
  61131. */
  61132. get freezeShadowCastersBoundingInfo(): boolean;
  61133. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61134. private _scbiMin;
  61135. private _scbiMax;
  61136. protected _computeShadowCastersBoundingInfo(): void;
  61137. protected _shadowCastersBoundingInfo: BoundingInfo;
  61138. /**
  61139. * Gets or sets the shadow casters bounding info.
  61140. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61141. * so that the system won't overwrite the bounds you provide
  61142. */
  61143. get shadowCastersBoundingInfo(): BoundingInfo;
  61144. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61145. protected _breaksAreDirty: boolean;
  61146. protected _minDistance: number;
  61147. protected _maxDistance: number;
  61148. /**
  61149. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61150. *
  61151. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61152. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61153. * @param min minimal distance for the breaks (default to 0.)
  61154. * @param max maximal distance for the breaks (default to 1.)
  61155. */
  61156. setMinMaxDistance(min: number, max: number): void;
  61157. /** Gets the minimal distance used in the cascade break computation */
  61158. get minDistance(): number;
  61159. /** Gets the maximal distance used in the cascade break computation */
  61160. get maxDistance(): number;
  61161. /**
  61162. * Gets the class name of that object
  61163. * @returns "CascadedShadowGenerator"
  61164. */
  61165. getClassName(): string;
  61166. private _cascadeMinExtents;
  61167. private _cascadeMaxExtents;
  61168. /**
  61169. * Gets a cascade minimum extents
  61170. * @param cascadeIndex index of the cascade
  61171. * @returns the minimum cascade extents
  61172. */
  61173. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61174. /**
  61175. * Gets a cascade maximum extents
  61176. * @param cascadeIndex index of the cascade
  61177. * @returns the maximum cascade extents
  61178. */
  61179. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61180. private _cascades;
  61181. private _currentLayer;
  61182. private _viewSpaceFrustumsZ;
  61183. private _viewMatrices;
  61184. private _projectionMatrices;
  61185. private _transformMatrices;
  61186. private _transformMatricesAsArray;
  61187. private _frustumLengths;
  61188. private _lightSizeUVCorrection;
  61189. private _depthCorrection;
  61190. private _frustumCornersWorldSpace;
  61191. private _frustumCenter;
  61192. private _shadowCameraPos;
  61193. private _shadowMaxZ;
  61194. /**
  61195. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61196. * It defaults to camera.maxZ
  61197. */
  61198. get shadowMaxZ(): number;
  61199. /**
  61200. * Sets the shadow max z distance.
  61201. */
  61202. set shadowMaxZ(value: number);
  61203. protected _debug: boolean;
  61204. /**
  61205. * Gets or sets the debug flag.
  61206. * When enabled, the cascades are materialized by different colors on the screen.
  61207. */
  61208. get debug(): boolean;
  61209. set debug(dbg: boolean);
  61210. private _depthClamp;
  61211. /**
  61212. * Gets or sets the depth clamping value.
  61213. *
  61214. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61215. * to account for the shadow casters far away.
  61216. *
  61217. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61218. */
  61219. get depthClamp(): boolean;
  61220. set depthClamp(value: boolean);
  61221. private _cascadeBlendPercentage;
  61222. /**
  61223. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61224. * It defaults to 0.1 (10% blending).
  61225. */
  61226. get cascadeBlendPercentage(): number;
  61227. set cascadeBlendPercentage(value: number);
  61228. private _lambda;
  61229. /**
  61230. * Gets or set the lambda parameter.
  61231. * This parameter is used to split the camera frustum and create the cascades.
  61232. * 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.
  61233. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61234. */
  61235. get lambda(): number;
  61236. set lambda(value: number);
  61237. /**
  61238. * Gets the view matrix corresponding to a given cascade
  61239. * @param cascadeNum cascade to retrieve the view matrix from
  61240. * @returns the cascade view matrix
  61241. */
  61242. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61243. /**
  61244. * Gets the projection matrix corresponding to a given cascade
  61245. * @param cascadeNum cascade to retrieve the projection matrix from
  61246. * @returns the cascade projection matrix
  61247. */
  61248. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61249. /**
  61250. * Gets the transformation matrix corresponding to a given cascade
  61251. * @param cascadeNum cascade to retrieve the transformation matrix from
  61252. * @returns the cascade transformation matrix
  61253. */
  61254. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61255. private _depthRenderer;
  61256. /**
  61257. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61258. *
  61259. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61260. *
  61261. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61262. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61263. * @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
  61264. */
  61265. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61266. private _depthReducer;
  61267. private _autoCalcDepthBounds;
  61268. /**
  61269. * Gets or sets the autoCalcDepthBounds property.
  61270. *
  61271. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61272. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61273. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61274. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61275. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61276. */
  61277. get autoCalcDepthBounds(): boolean;
  61278. set autoCalcDepthBounds(value: boolean);
  61279. /**
  61280. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61281. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61282. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61283. * for setting the refresh rate on the renderer yourself!
  61284. */
  61285. get autoCalcDepthBoundsRefreshRate(): number;
  61286. set autoCalcDepthBoundsRefreshRate(value: number);
  61287. /**
  61288. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61289. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61290. * you change the camera near/far planes!
  61291. */
  61292. splitFrustum(): void;
  61293. private _splitFrustum;
  61294. private _computeMatrices;
  61295. private _computeFrustumInWorldSpace;
  61296. private _computeCascadeFrustum;
  61297. /**
  61298. * Support test.
  61299. */
  61300. static get IsSupported(): boolean;
  61301. /** @hidden */
  61302. static _SceneComponentInitialization: (scene: Scene) => void;
  61303. /**
  61304. * Creates a Cascaded Shadow Generator object.
  61305. * A ShadowGenerator is the required tool to use the shadows.
  61306. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61307. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61308. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61309. * @param light The directional light object generating the shadows.
  61310. * @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.
  61311. */
  61312. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61313. protected _initializeGenerator(): void;
  61314. protected _createTargetRenderTexture(): void;
  61315. protected _initializeShadowMap(): void;
  61316. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61317. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61318. /**
  61319. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61320. * @param defines Defines of the material we want to update
  61321. * @param lightIndex Index of the light in the enabled light list of the material
  61322. */
  61323. prepareDefines(defines: any, lightIndex: number): void;
  61324. /**
  61325. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61326. * defined in the generator but impacting the effect).
  61327. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61328. * @param effect The effect we are binfing the information for
  61329. */
  61330. bindShadowLight(lightIndex: string, effect: Effect): void;
  61331. /**
  61332. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61333. * (eq to view projection * shadow projection matrices)
  61334. * @returns The transform matrix used to create the shadow map
  61335. */
  61336. getTransformMatrix(): Matrix;
  61337. /**
  61338. * Disposes the ShadowGenerator.
  61339. * Returns nothing.
  61340. */
  61341. dispose(): void;
  61342. /**
  61343. * Serializes the shadow generator setup to a json object.
  61344. * @returns The serialized JSON object
  61345. */
  61346. serialize(): any;
  61347. /**
  61348. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61349. * @param parsedShadowGenerator The JSON object to parse
  61350. * @param scene The scene to create the shadow map for
  61351. * @returns The parsed shadow generator
  61352. */
  61353. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61354. }
  61355. }
  61356. declare module BABYLON {
  61357. /**
  61358. * Defines the shadow generator component responsible to manage any shadow generators
  61359. * in a given scene.
  61360. */
  61361. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61362. /**
  61363. * The component name helpfull to identify the component in the list of scene components.
  61364. */
  61365. readonly name: string;
  61366. /**
  61367. * The scene the component belongs to.
  61368. */
  61369. scene: Scene;
  61370. /**
  61371. * Creates a new instance of the component for the given scene
  61372. * @param scene Defines the scene to register the component in
  61373. */
  61374. constructor(scene: Scene);
  61375. /**
  61376. * Registers the component in a given scene
  61377. */
  61378. register(): void;
  61379. /**
  61380. * Rebuilds the elements related to this component in case of
  61381. * context lost for instance.
  61382. */
  61383. rebuild(): void;
  61384. /**
  61385. * Serializes the component data to the specified json object
  61386. * @param serializationObject The object to serialize to
  61387. */
  61388. serialize(serializationObject: any): void;
  61389. /**
  61390. * Adds all the elements from the container to the scene
  61391. * @param container the container holding the elements
  61392. */
  61393. addFromContainer(container: AbstractScene): void;
  61394. /**
  61395. * Removes all the elements in the container from the scene
  61396. * @param container contains the elements to remove
  61397. * @param dispose if the removed element should be disposed (default: false)
  61398. */
  61399. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61400. /**
  61401. * Rebuilds the elements related to this component in case of
  61402. * context lost for instance.
  61403. */
  61404. dispose(): void;
  61405. private _gatherRenderTargets;
  61406. }
  61407. }
  61408. declare module BABYLON {
  61409. /**
  61410. * A point light is a light defined by an unique point in world space.
  61411. * The light is emitted in every direction from this point.
  61412. * A good example of a point light is a standard light bulb.
  61413. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61414. */
  61415. export class PointLight extends ShadowLight {
  61416. private _shadowAngle;
  61417. /**
  61418. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61419. * This specifies what angle the shadow will use to be created.
  61420. *
  61421. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61422. */
  61423. get shadowAngle(): number;
  61424. /**
  61425. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61426. * This specifies what angle the shadow will use to be created.
  61427. *
  61428. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61429. */
  61430. set shadowAngle(value: number);
  61431. /**
  61432. * Gets the direction if it has been set.
  61433. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61434. */
  61435. get direction(): Vector3;
  61436. /**
  61437. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61438. */
  61439. set direction(value: Vector3);
  61440. /**
  61441. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61442. * A PointLight emits the light in every direction.
  61443. * It can cast shadows.
  61444. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61445. * ```javascript
  61446. * var pointLight = new PointLight("pl", camera.position, scene);
  61447. * ```
  61448. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61449. * @param name The light friendly name
  61450. * @param position The position of the point light in the scene
  61451. * @param scene The scene the lights belongs to
  61452. */
  61453. constructor(name: string, position: Vector3, scene: Scene);
  61454. /**
  61455. * Returns the string "PointLight"
  61456. * @returns the class name
  61457. */
  61458. getClassName(): string;
  61459. /**
  61460. * Returns the integer 0.
  61461. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61462. */
  61463. getTypeID(): number;
  61464. /**
  61465. * Specifies wether or not the shadowmap should be a cube texture.
  61466. * @returns true if the shadowmap needs to be a cube texture.
  61467. */
  61468. needCube(): boolean;
  61469. /**
  61470. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61471. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61472. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61473. */
  61474. getShadowDirection(faceIndex?: number): Vector3;
  61475. /**
  61476. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61477. * - fov = PI / 2
  61478. * - aspect ratio : 1.0
  61479. * - z-near and far equal to the active camera minZ and maxZ.
  61480. * Returns the PointLight.
  61481. */
  61482. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61483. protected _buildUniformLayout(): void;
  61484. /**
  61485. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61486. * @param effect The effect to update
  61487. * @param lightIndex The index of the light in the effect to update
  61488. * @returns The point light
  61489. */
  61490. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61491. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61492. /**
  61493. * Prepares the list of defines specific to the light type.
  61494. * @param defines the list of defines
  61495. * @param lightIndex defines the index of the light for the effect
  61496. */
  61497. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61498. }
  61499. }
  61500. declare module BABYLON {
  61501. /**
  61502. * Header information of HDR texture files.
  61503. */
  61504. export interface HDRInfo {
  61505. /**
  61506. * The height of the texture in pixels.
  61507. */
  61508. height: number;
  61509. /**
  61510. * The width of the texture in pixels.
  61511. */
  61512. width: number;
  61513. /**
  61514. * The index of the beginning of the data in the binary file.
  61515. */
  61516. dataPosition: number;
  61517. }
  61518. /**
  61519. * This groups tools to convert HDR texture to native colors array.
  61520. */
  61521. export class HDRTools {
  61522. private static Ldexp;
  61523. private static Rgbe2float;
  61524. private static readStringLine;
  61525. /**
  61526. * Reads header information from an RGBE texture stored in a native array.
  61527. * More information on this format are available here:
  61528. * https://en.wikipedia.org/wiki/RGBE_image_format
  61529. *
  61530. * @param uint8array The binary file stored in native array.
  61531. * @return The header information.
  61532. */
  61533. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61534. /**
  61535. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61536. * This RGBE texture needs to store the information as a panorama.
  61537. *
  61538. * More information on this format are available here:
  61539. * https://en.wikipedia.org/wiki/RGBE_image_format
  61540. *
  61541. * @param buffer The binary file stored in an array buffer.
  61542. * @param size The expected size of the extracted cubemap.
  61543. * @return The Cube Map information.
  61544. */
  61545. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61546. /**
  61547. * Returns the pixels data extracted from an RGBE texture.
  61548. * This pixels will be stored left to right up to down in the R G B order in one array.
  61549. *
  61550. * More information on this format are available here:
  61551. * https://en.wikipedia.org/wiki/RGBE_image_format
  61552. *
  61553. * @param uint8array The binary file stored in an array buffer.
  61554. * @param hdrInfo The header information of the file.
  61555. * @return The pixels data in RGB right to left up to down order.
  61556. */
  61557. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61558. private static RGBE_ReadPixels_RLE;
  61559. private static RGBE_ReadPixels_NOT_RLE;
  61560. }
  61561. }
  61562. declare module BABYLON {
  61563. /**
  61564. * Effect Render Options
  61565. */
  61566. export interface IEffectRendererOptions {
  61567. /**
  61568. * Defines the vertices positions.
  61569. */
  61570. positions?: number[];
  61571. /**
  61572. * Defines the indices.
  61573. */
  61574. indices?: number[];
  61575. }
  61576. /**
  61577. * Helper class to render one or more effects.
  61578. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61579. */
  61580. export class EffectRenderer {
  61581. private engine;
  61582. private static _DefaultOptions;
  61583. private _vertexBuffers;
  61584. private _indexBuffer;
  61585. private _fullscreenViewport;
  61586. /**
  61587. * Creates an effect renderer
  61588. * @param engine the engine to use for rendering
  61589. * @param options defines the options of the effect renderer
  61590. */
  61591. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61592. /**
  61593. * Sets the current viewport in normalized coordinates 0-1
  61594. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61595. */
  61596. setViewport(viewport?: Viewport): void;
  61597. /**
  61598. * Binds the embedded attributes buffer to the effect.
  61599. * @param effect Defines the effect to bind the attributes for
  61600. */
  61601. bindBuffers(effect: Effect): void;
  61602. /**
  61603. * Sets the current effect wrapper to use during draw.
  61604. * The effect needs to be ready before calling this api.
  61605. * This also sets the default full screen position attribute.
  61606. * @param effectWrapper Defines the effect to draw with
  61607. */
  61608. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61609. /**
  61610. * Restores engine states
  61611. */
  61612. restoreStates(): void;
  61613. /**
  61614. * Draws a full screen quad.
  61615. */
  61616. draw(): void;
  61617. private isRenderTargetTexture;
  61618. /**
  61619. * renders one or more effects to a specified texture
  61620. * @param effectWrapper the effect to renderer
  61621. * @param outputTexture texture to draw to, if null it will render to the screen.
  61622. */
  61623. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61624. /**
  61625. * Disposes of the effect renderer
  61626. */
  61627. dispose(): void;
  61628. }
  61629. /**
  61630. * Options to create an EffectWrapper
  61631. */
  61632. interface EffectWrapperCreationOptions {
  61633. /**
  61634. * Engine to use to create the effect
  61635. */
  61636. engine: ThinEngine;
  61637. /**
  61638. * Fragment shader for the effect
  61639. */
  61640. fragmentShader: string;
  61641. /**
  61642. * Use the shader store instead of direct source code
  61643. */
  61644. useShaderStore?: boolean;
  61645. /**
  61646. * Vertex shader for the effect
  61647. */
  61648. vertexShader?: string;
  61649. /**
  61650. * Attributes to use in the shader
  61651. */
  61652. attributeNames?: Array<string>;
  61653. /**
  61654. * Uniforms to use in the shader
  61655. */
  61656. uniformNames?: Array<string>;
  61657. /**
  61658. * Texture sampler names to use in the shader
  61659. */
  61660. samplerNames?: Array<string>;
  61661. /**
  61662. * Defines to use in the shader
  61663. */
  61664. defines?: Array<string>;
  61665. /**
  61666. * Callback when effect is compiled
  61667. */
  61668. onCompiled?: Nullable<(effect: Effect) => void>;
  61669. /**
  61670. * The friendly name of the effect displayed in Spector.
  61671. */
  61672. name?: string;
  61673. }
  61674. /**
  61675. * Wraps an effect to be used for rendering
  61676. */
  61677. export class EffectWrapper {
  61678. /**
  61679. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61680. */
  61681. onApplyObservable: Observable<{}>;
  61682. /**
  61683. * The underlying effect
  61684. */
  61685. effect: Effect;
  61686. /**
  61687. * Creates an effect to be renderer
  61688. * @param creationOptions options to create the effect
  61689. */
  61690. constructor(creationOptions: EffectWrapperCreationOptions);
  61691. /**
  61692. * Disposes of the effect wrapper
  61693. */
  61694. dispose(): void;
  61695. }
  61696. }
  61697. declare module BABYLON {
  61698. /** @hidden */
  61699. export var hdrFilteringVertexShader: {
  61700. name: string;
  61701. shader: string;
  61702. };
  61703. }
  61704. declare module BABYLON {
  61705. /** @hidden */
  61706. export var hdrFilteringPixelShader: {
  61707. name: string;
  61708. shader: string;
  61709. };
  61710. }
  61711. declare module BABYLON {
  61712. /**
  61713. * Options for texture filtering
  61714. */
  61715. interface IHDRFilteringOptions {
  61716. /**
  61717. * Scales pixel intensity for the input HDR map.
  61718. */
  61719. hdrScale?: number;
  61720. /**
  61721. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61722. */
  61723. quality?: number;
  61724. }
  61725. /**
  61726. * Filters HDR maps to get correct renderings of PBR reflections
  61727. */
  61728. export class HDRFiltering {
  61729. private _engine;
  61730. private _effectRenderer;
  61731. private _effectWrapper;
  61732. private _lodGenerationOffset;
  61733. private _lodGenerationScale;
  61734. /**
  61735. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61736. * you care about baking speed.
  61737. */
  61738. quality: number;
  61739. /**
  61740. * Scales pixel intensity for the input HDR map.
  61741. */
  61742. hdrScale: number;
  61743. /**
  61744. * Instantiates HDR filter for reflection maps
  61745. *
  61746. * @param engine Thin engine
  61747. * @param options Options
  61748. */
  61749. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61750. private _createRenderTarget;
  61751. private _prefilterInternal;
  61752. private _createEffect;
  61753. /**
  61754. * Get a value indicating if the filter is ready to be used
  61755. * @param texture Texture to filter
  61756. * @returns true if the filter is ready
  61757. */
  61758. isReady(texture: BaseTexture): boolean;
  61759. /**
  61760. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61761. * Prefiltering will be invoked at the end of next rendering pass.
  61762. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61763. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61764. * @param texture Texture to filter
  61765. * @param onFinished Callback when filtering is done
  61766. * @return Promise called when prefiltering is done
  61767. */
  61768. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61769. }
  61770. }
  61771. declare module BABYLON {
  61772. /**
  61773. * This represents a texture coming from an HDR input.
  61774. *
  61775. * The only supported format is currently panorama picture stored in RGBE format.
  61776. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61777. */
  61778. export class HDRCubeTexture extends BaseTexture {
  61779. private static _facesMapping;
  61780. private _generateHarmonics;
  61781. private _noMipmap;
  61782. private _prefilterOnLoad;
  61783. private _textureMatrix;
  61784. private _size;
  61785. private _onLoad;
  61786. private _onError;
  61787. /**
  61788. * The texture URL.
  61789. */
  61790. url: string;
  61791. protected _isBlocking: boolean;
  61792. /**
  61793. * Sets wether or not the texture is blocking during loading.
  61794. */
  61795. set isBlocking(value: boolean);
  61796. /**
  61797. * Gets wether or not the texture is blocking during loading.
  61798. */
  61799. get isBlocking(): boolean;
  61800. protected _rotationY: number;
  61801. /**
  61802. * Sets texture matrix rotation angle around Y axis in radians.
  61803. */
  61804. set rotationY(value: number);
  61805. /**
  61806. * Gets texture matrix rotation angle around Y axis radians.
  61807. */
  61808. get rotationY(): number;
  61809. /**
  61810. * Gets or sets the center of the bounding box associated with the cube texture
  61811. * It must define where the camera used to render the texture was set
  61812. */
  61813. boundingBoxPosition: Vector3;
  61814. private _boundingBoxSize;
  61815. /**
  61816. * Gets or sets the size of the bounding box associated with the cube texture
  61817. * When defined, the cubemap will switch to local mode
  61818. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61819. * @example https://www.babylonjs-playground.com/#RNASML
  61820. */
  61821. set boundingBoxSize(value: Vector3);
  61822. get boundingBoxSize(): Vector3;
  61823. /**
  61824. * Instantiates an HDRTexture from the following parameters.
  61825. *
  61826. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61827. * @param sceneOrEngine The scene or engine the texture will be used in
  61828. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61829. * @param noMipmap Forces to not generate the mipmap if true
  61830. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61831. * @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)
  61832. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61833. */
  61834. 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>);
  61835. /**
  61836. * Get the current class name of the texture useful for serialization or dynamic coding.
  61837. * @returns "HDRCubeTexture"
  61838. */
  61839. getClassName(): string;
  61840. /**
  61841. * Occurs when the file is raw .hdr file.
  61842. */
  61843. private loadTexture;
  61844. clone(): HDRCubeTexture;
  61845. delayLoad(): void;
  61846. /**
  61847. * Get the texture reflection matrix used to rotate/transform the reflection.
  61848. * @returns the reflection matrix
  61849. */
  61850. getReflectionTextureMatrix(): Matrix;
  61851. /**
  61852. * Set the texture reflection matrix used to rotate/transform the reflection.
  61853. * @param value Define the reflection matrix to set
  61854. */
  61855. setReflectionTextureMatrix(value: Matrix): void;
  61856. /**
  61857. * Parses a JSON representation of an HDR Texture in order to create the texture
  61858. * @param parsedTexture Define the JSON representation
  61859. * @param scene Define the scene the texture should be created in
  61860. * @param rootUrl Define the root url in case we need to load relative dependencies
  61861. * @returns the newly created texture after parsing
  61862. */
  61863. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61864. serialize(): any;
  61865. }
  61866. }
  61867. declare module BABYLON {
  61868. /**
  61869. * Class used to control physics engine
  61870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61871. */
  61872. export class PhysicsEngine implements IPhysicsEngine {
  61873. private _physicsPlugin;
  61874. /**
  61875. * Global value used to control the smallest number supported by the simulation
  61876. */
  61877. static Epsilon: number;
  61878. private _impostors;
  61879. private _joints;
  61880. private _subTimeStep;
  61881. /**
  61882. * Gets the gravity vector used by the simulation
  61883. */
  61884. gravity: Vector3;
  61885. /**
  61886. * Factory used to create the default physics plugin.
  61887. * @returns The default physics plugin
  61888. */
  61889. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61890. /**
  61891. * Creates a new Physics Engine
  61892. * @param gravity defines the gravity vector used by the simulation
  61893. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61894. */
  61895. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61896. /**
  61897. * Sets the gravity vector used by the simulation
  61898. * @param gravity defines the gravity vector to use
  61899. */
  61900. setGravity(gravity: Vector3): void;
  61901. /**
  61902. * Set the time step of the physics engine.
  61903. * Default is 1/60.
  61904. * To slow it down, enter 1/600 for example.
  61905. * To speed it up, 1/30
  61906. * @param newTimeStep defines the new timestep to apply to this world.
  61907. */
  61908. setTimeStep(newTimeStep?: number): void;
  61909. /**
  61910. * Get the time step of the physics engine.
  61911. * @returns the current time step
  61912. */
  61913. getTimeStep(): number;
  61914. /**
  61915. * Set the sub time step of the physics engine.
  61916. * Default is 0 meaning there is no sub steps
  61917. * To increase physics resolution precision, set a small value (like 1 ms)
  61918. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61919. */
  61920. setSubTimeStep(subTimeStep?: number): void;
  61921. /**
  61922. * Get the sub time step of the physics engine.
  61923. * @returns the current sub time step
  61924. */
  61925. getSubTimeStep(): number;
  61926. /**
  61927. * Release all resources
  61928. */
  61929. dispose(): void;
  61930. /**
  61931. * Gets the name of the current physics plugin
  61932. * @returns the name of the plugin
  61933. */
  61934. getPhysicsPluginName(): string;
  61935. /**
  61936. * Adding a new impostor for the impostor tracking.
  61937. * This will be done by the impostor itself.
  61938. * @param impostor the impostor to add
  61939. */
  61940. addImpostor(impostor: PhysicsImpostor): void;
  61941. /**
  61942. * Remove an impostor from the engine.
  61943. * This impostor and its mesh will not longer be updated by the physics engine.
  61944. * @param impostor the impostor to remove
  61945. */
  61946. removeImpostor(impostor: PhysicsImpostor): void;
  61947. /**
  61948. * Add a joint to the physics engine
  61949. * @param mainImpostor defines the main impostor to which the joint is added.
  61950. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61951. * @param joint defines the joint that will connect both impostors.
  61952. */
  61953. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61954. /**
  61955. * Removes a joint from the simulation
  61956. * @param mainImpostor defines the impostor used with the joint
  61957. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61958. * @param joint defines the joint to remove
  61959. */
  61960. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61961. /**
  61962. * Called by the scene. No need to call it.
  61963. * @param delta defines the timespam between frames
  61964. */
  61965. _step(delta: number): void;
  61966. /**
  61967. * Gets the current plugin used to run the simulation
  61968. * @returns current plugin
  61969. */
  61970. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61971. /**
  61972. * Gets the list of physic impostors
  61973. * @returns an array of PhysicsImpostor
  61974. */
  61975. getImpostors(): Array<PhysicsImpostor>;
  61976. /**
  61977. * Gets the impostor for a physics enabled object
  61978. * @param object defines the object impersonated by the impostor
  61979. * @returns the PhysicsImpostor or null if not found
  61980. */
  61981. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61982. /**
  61983. * Gets the impostor for a physics body object
  61984. * @param body defines physics body used by the impostor
  61985. * @returns the PhysicsImpostor or null if not found
  61986. */
  61987. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61988. /**
  61989. * Does a raycast in the physics world
  61990. * @param from when should the ray start?
  61991. * @param to when should the ray end?
  61992. * @returns PhysicsRaycastResult
  61993. */
  61994. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61995. }
  61996. }
  61997. declare module BABYLON {
  61998. /** @hidden */
  61999. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62000. private _useDeltaForWorldStep;
  62001. world: any;
  62002. name: string;
  62003. private _physicsMaterials;
  62004. private _fixedTimeStep;
  62005. private _cannonRaycastResult;
  62006. private _raycastResult;
  62007. private _physicsBodysToRemoveAfterStep;
  62008. private _firstFrame;
  62009. BJSCANNON: any;
  62010. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62011. setGravity(gravity: Vector3): void;
  62012. setTimeStep(timeStep: number): void;
  62013. getTimeStep(): number;
  62014. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62015. private _removeMarkedPhysicsBodiesFromWorld;
  62016. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62017. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62018. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62019. private _processChildMeshes;
  62020. removePhysicsBody(impostor: PhysicsImpostor): void;
  62021. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62022. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62023. private _addMaterial;
  62024. private _checkWithEpsilon;
  62025. private _createShape;
  62026. private _createHeightmap;
  62027. private _minus90X;
  62028. private _plus90X;
  62029. private _tmpPosition;
  62030. private _tmpDeltaPosition;
  62031. private _tmpUnityRotation;
  62032. private _updatePhysicsBodyTransformation;
  62033. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62034. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62035. isSupported(): boolean;
  62036. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62037. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62038. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62039. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62040. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62041. getBodyMass(impostor: PhysicsImpostor): number;
  62042. getBodyFriction(impostor: PhysicsImpostor): number;
  62043. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62044. getBodyRestitution(impostor: PhysicsImpostor): number;
  62045. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62046. sleepBody(impostor: PhysicsImpostor): void;
  62047. wakeUpBody(impostor: PhysicsImpostor): void;
  62048. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62049. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62050. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62051. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62052. getRadius(impostor: PhysicsImpostor): number;
  62053. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62054. dispose(): void;
  62055. private _extendNamespace;
  62056. /**
  62057. * Does a raycast in the physics world
  62058. * @param from when should the ray start?
  62059. * @param to when should the ray end?
  62060. * @returns PhysicsRaycastResult
  62061. */
  62062. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62063. }
  62064. }
  62065. declare module BABYLON {
  62066. /** @hidden */
  62067. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62068. private _useDeltaForWorldStep;
  62069. world: any;
  62070. name: string;
  62071. BJSOIMO: any;
  62072. private _raycastResult;
  62073. private _fixedTimeStep;
  62074. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62075. setGravity(gravity: Vector3): void;
  62076. setTimeStep(timeStep: number): void;
  62077. getTimeStep(): number;
  62078. private _tmpImpostorsArray;
  62079. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62080. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62081. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62082. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62083. private _tmpPositionVector;
  62084. removePhysicsBody(impostor: PhysicsImpostor): void;
  62085. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62086. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62087. isSupported(): boolean;
  62088. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62089. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62090. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62091. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62092. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62093. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62094. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62095. getBodyMass(impostor: PhysicsImpostor): number;
  62096. getBodyFriction(impostor: PhysicsImpostor): number;
  62097. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62098. getBodyRestitution(impostor: PhysicsImpostor): number;
  62099. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62100. sleepBody(impostor: PhysicsImpostor): void;
  62101. wakeUpBody(impostor: PhysicsImpostor): void;
  62102. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62103. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62104. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62105. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62106. getRadius(impostor: PhysicsImpostor): number;
  62107. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62108. dispose(): void;
  62109. /**
  62110. * Does a raycast in the physics world
  62111. * @param from when should the ray start?
  62112. * @param to when should the ray end?
  62113. * @returns PhysicsRaycastResult
  62114. */
  62115. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62116. }
  62117. }
  62118. declare module BABYLON {
  62119. /**
  62120. * AmmoJS Physics plugin
  62121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62122. * @see https://github.com/kripken/ammo.js/
  62123. */
  62124. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62125. private _useDeltaForWorldStep;
  62126. /**
  62127. * Reference to the Ammo library
  62128. */
  62129. bjsAMMO: any;
  62130. /**
  62131. * Created ammoJS world which physics bodies are added to
  62132. */
  62133. world: any;
  62134. /**
  62135. * Name of the plugin
  62136. */
  62137. name: string;
  62138. private _timeStep;
  62139. private _fixedTimeStep;
  62140. private _maxSteps;
  62141. private _tmpQuaternion;
  62142. private _tmpAmmoTransform;
  62143. private _tmpAmmoQuaternion;
  62144. private _tmpAmmoConcreteContactResultCallback;
  62145. private _collisionConfiguration;
  62146. private _dispatcher;
  62147. private _overlappingPairCache;
  62148. private _solver;
  62149. private _softBodySolver;
  62150. private _tmpAmmoVectorA;
  62151. private _tmpAmmoVectorB;
  62152. private _tmpAmmoVectorC;
  62153. private _tmpAmmoVectorD;
  62154. private _tmpContactCallbackResult;
  62155. private _tmpAmmoVectorRCA;
  62156. private _tmpAmmoVectorRCB;
  62157. private _raycastResult;
  62158. private _tmpContactPoint;
  62159. private static readonly DISABLE_COLLISION_FLAG;
  62160. private static readonly KINEMATIC_FLAG;
  62161. private static readonly DISABLE_DEACTIVATION_FLAG;
  62162. /**
  62163. * Initializes the ammoJS plugin
  62164. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62165. * @param ammoInjection can be used to inject your own ammo reference
  62166. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62167. */
  62168. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62169. /**
  62170. * Sets the gravity of the physics world (m/(s^2))
  62171. * @param gravity Gravity to set
  62172. */
  62173. setGravity(gravity: Vector3): void;
  62174. /**
  62175. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62176. * @param timeStep timestep to use in seconds
  62177. */
  62178. setTimeStep(timeStep: number): void;
  62179. /**
  62180. * 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)
  62181. * @param fixedTimeStep fixedTimeStep to use in seconds
  62182. */
  62183. setFixedTimeStep(fixedTimeStep: number): void;
  62184. /**
  62185. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62186. * @param maxSteps the maximum number of steps by the physics engine per frame
  62187. */
  62188. setMaxSteps(maxSteps: number): void;
  62189. /**
  62190. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62191. * @returns the current timestep in seconds
  62192. */
  62193. getTimeStep(): number;
  62194. /**
  62195. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62196. */
  62197. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62198. private _isImpostorInContact;
  62199. private _isImpostorPairInContact;
  62200. private _stepSimulation;
  62201. /**
  62202. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62203. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62204. * After the step the babylon meshes are set to the position of the physics imposters
  62205. * @param delta amount of time to step forward
  62206. * @param impostors array of imposters to update before/after the step
  62207. */
  62208. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62209. /**
  62210. * Update babylon mesh to match physics world object
  62211. * @param impostor imposter to match
  62212. */
  62213. private _afterSoftStep;
  62214. /**
  62215. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62216. * @param impostor imposter to match
  62217. */
  62218. private _ropeStep;
  62219. /**
  62220. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62221. * @param impostor imposter to match
  62222. */
  62223. private _softbodyOrClothStep;
  62224. private _tmpMatrix;
  62225. /**
  62226. * Applies an impulse on the imposter
  62227. * @param impostor imposter to apply impulse to
  62228. * @param force amount of force to be applied to the imposter
  62229. * @param contactPoint the location to apply the impulse on the imposter
  62230. */
  62231. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62232. /**
  62233. * Applies a force on the imposter
  62234. * @param impostor imposter to apply force
  62235. * @param force amount of force to be applied to the imposter
  62236. * @param contactPoint the location to apply the force on the imposter
  62237. */
  62238. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62239. /**
  62240. * Creates a physics body using the plugin
  62241. * @param impostor the imposter to create the physics body on
  62242. */
  62243. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62244. /**
  62245. * Removes the physics body from the imposter and disposes of the body's memory
  62246. * @param impostor imposter to remove the physics body from
  62247. */
  62248. removePhysicsBody(impostor: PhysicsImpostor): void;
  62249. /**
  62250. * Generates a joint
  62251. * @param impostorJoint the imposter joint to create the joint with
  62252. */
  62253. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62254. /**
  62255. * Removes a joint
  62256. * @param impostorJoint the imposter joint to remove the joint from
  62257. */
  62258. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62259. private _addMeshVerts;
  62260. /**
  62261. * Initialise the soft body vertices to match its object's (mesh) vertices
  62262. * Softbody vertices (nodes) are in world space and to match this
  62263. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62264. * @param impostor to create the softbody for
  62265. */
  62266. private _softVertexData;
  62267. /**
  62268. * Create an impostor's soft body
  62269. * @param impostor to create the softbody for
  62270. */
  62271. private _createSoftbody;
  62272. /**
  62273. * Create cloth for an impostor
  62274. * @param impostor to create the softbody for
  62275. */
  62276. private _createCloth;
  62277. /**
  62278. * Create rope for an impostor
  62279. * @param impostor to create the softbody for
  62280. */
  62281. private _createRope;
  62282. /**
  62283. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62284. * @param impostor to create the custom physics shape for
  62285. */
  62286. private _createCustom;
  62287. private _addHullVerts;
  62288. private _createShape;
  62289. /**
  62290. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62291. * @param impostor imposter containing the physics body and babylon object
  62292. */
  62293. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62294. /**
  62295. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62296. * @param impostor imposter containing the physics body and babylon object
  62297. * @param newPosition new position
  62298. * @param newRotation new rotation
  62299. */
  62300. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62301. /**
  62302. * If this plugin is supported
  62303. * @returns true if its supported
  62304. */
  62305. isSupported(): boolean;
  62306. /**
  62307. * Sets the linear velocity of the physics body
  62308. * @param impostor imposter to set the velocity on
  62309. * @param velocity velocity to set
  62310. */
  62311. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62312. /**
  62313. * Sets the angular velocity of the physics body
  62314. * @param impostor imposter to set the velocity on
  62315. * @param velocity velocity to set
  62316. */
  62317. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62318. /**
  62319. * gets the linear velocity
  62320. * @param impostor imposter to get linear velocity from
  62321. * @returns linear velocity
  62322. */
  62323. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62324. /**
  62325. * gets the angular velocity
  62326. * @param impostor imposter to get angular velocity from
  62327. * @returns angular velocity
  62328. */
  62329. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62330. /**
  62331. * Sets the mass of physics body
  62332. * @param impostor imposter to set the mass on
  62333. * @param mass mass to set
  62334. */
  62335. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62336. /**
  62337. * Gets the mass of the physics body
  62338. * @param impostor imposter to get the mass from
  62339. * @returns mass
  62340. */
  62341. getBodyMass(impostor: PhysicsImpostor): number;
  62342. /**
  62343. * Gets friction of the impostor
  62344. * @param impostor impostor to get friction from
  62345. * @returns friction value
  62346. */
  62347. getBodyFriction(impostor: PhysicsImpostor): number;
  62348. /**
  62349. * Sets friction of the impostor
  62350. * @param impostor impostor to set friction on
  62351. * @param friction friction value
  62352. */
  62353. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62354. /**
  62355. * Gets restitution of the impostor
  62356. * @param impostor impostor to get restitution from
  62357. * @returns restitution value
  62358. */
  62359. getBodyRestitution(impostor: PhysicsImpostor): number;
  62360. /**
  62361. * Sets resitution of the impostor
  62362. * @param impostor impostor to set resitution on
  62363. * @param restitution resitution value
  62364. */
  62365. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62366. /**
  62367. * Gets pressure inside the impostor
  62368. * @param impostor impostor to get pressure from
  62369. * @returns pressure value
  62370. */
  62371. getBodyPressure(impostor: PhysicsImpostor): number;
  62372. /**
  62373. * Sets pressure inside a soft body impostor
  62374. * Cloth and rope must remain 0 pressure
  62375. * @param impostor impostor to set pressure on
  62376. * @param pressure pressure value
  62377. */
  62378. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62379. /**
  62380. * Gets stiffness of the impostor
  62381. * @param impostor impostor to get stiffness from
  62382. * @returns pressure value
  62383. */
  62384. getBodyStiffness(impostor: PhysicsImpostor): number;
  62385. /**
  62386. * Sets stiffness of the impostor
  62387. * @param impostor impostor to set stiffness on
  62388. * @param stiffness stiffness value from 0 to 1
  62389. */
  62390. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62391. /**
  62392. * Gets velocityIterations of the impostor
  62393. * @param impostor impostor to get velocity iterations from
  62394. * @returns velocityIterations value
  62395. */
  62396. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62397. /**
  62398. * Sets velocityIterations of the impostor
  62399. * @param impostor impostor to set velocity iterations on
  62400. * @param velocityIterations velocityIterations value
  62401. */
  62402. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62403. /**
  62404. * Gets positionIterations of the impostor
  62405. * @param impostor impostor to get position iterations from
  62406. * @returns positionIterations value
  62407. */
  62408. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62409. /**
  62410. * Sets positionIterations of the impostor
  62411. * @param impostor impostor to set position on
  62412. * @param positionIterations positionIterations value
  62413. */
  62414. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62415. /**
  62416. * Append an anchor to a cloth object
  62417. * @param impostor is the cloth impostor to add anchor to
  62418. * @param otherImpostor is the rigid impostor to anchor to
  62419. * @param width ratio across width from 0 to 1
  62420. * @param height ratio up height from 0 to 1
  62421. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62422. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62423. */
  62424. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62425. /**
  62426. * Append an hook to a rope object
  62427. * @param impostor is the rope impostor to add hook to
  62428. * @param otherImpostor is the rigid impostor to hook to
  62429. * @param length ratio along the rope from 0 to 1
  62430. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62431. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62432. */
  62433. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62434. /**
  62435. * Sleeps the physics body and stops it from being active
  62436. * @param impostor impostor to sleep
  62437. */
  62438. sleepBody(impostor: PhysicsImpostor): void;
  62439. /**
  62440. * Activates the physics body
  62441. * @param impostor impostor to activate
  62442. */
  62443. wakeUpBody(impostor: PhysicsImpostor): void;
  62444. /**
  62445. * Updates the distance parameters of the joint
  62446. * @param joint joint to update
  62447. * @param maxDistance maximum distance of the joint
  62448. * @param minDistance minimum distance of the joint
  62449. */
  62450. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62451. /**
  62452. * Sets a motor on the joint
  62453. * @param joint joint to set motor on
  62454. * @param speed speed of the motor
  62455. * @param maxForce maximum force of the motor
  62456. * @param motorIndex index of the motor
  62457. */
  62458. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62459. /**
  62460. * Sets the motors limit
  62461. * @param joint joint to set limit on
  62462. * @param upperLimit upper limit
  62463. * @param lowerLimit lower limit
  62464. */
  62465. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62466. /**
  62467. * Syncs the position and rotation of a mesh with the impostor
  62468. * @param mesh mesh to sync
  62469. * @param impostor impostor to update the mesh with
  62470. */
  62471. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62472. /**
  62473. * Gets the radius of the impostor
  62474. * @param impostor impostor to get radius from
  62475. * @returns the radius
  62476. */
  62477. getRadius(impostor: PhysicsImpostor): number;
  62478. /**
  62479. * Gets the box size of the impostor
  62480. * @param impostor impostor to get box size from
  62481. * @param result the resulting box size
  62482. */
  62483. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62484. /**
  62485. * Disposes of the impostor
  62486. */
  62487. dispose(): void;
  62488. /**
  62489. * Does a raycast in the physics world
  62490. * @param from when should the ray start?
  62491. * @param to when should the ray end?
  62492. * @returns PhysicsRaycastResult
  62493. */
  62494. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62495. }
  62496. }
  62497. declare module BABYLON {
  62498. interface AbstractScene {
  62499. /**
  62500. * The list of reflection probes added to the scene
  62501. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62502. */
  62503. reflectionProbes: Array<ReflectionProbe>;
  62504. /**
  62505. * Removes the given reflection probe from this scene.
  62506. * @param toRemove The reflection probe to remove
  62507. * @returns The index of the removed reflection probe
  62508. */
  62509. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62510. /**
  62511. * Adds the given reflection probe to this scene.
  62512. * @param newReflectionProbe The reflection probe to add
  62513. */
  62514. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62515. }
  62516. /**
  62517. * Class used to generate realtime reflection / refraction cube textures
  62518. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62519. */
  62520. export class ReflectionProbe {
  62521. /** defines the name of the probe */
  62522. name: string;
  62523. private _scene;
  62524. private _renderTargetTexture;
  62525. private _projectionMatrix;
  62526. private _viewMatrix;
  62527. private _target;
  62528. private _add;
  62529. private _attachedMesh;
  62530. private _invertYAxis;
  62531. /** Gets or sets probe position (center of the cube map) */
  62532. position: Vector3;
  62533. /**
  62534. * Creates a new reflection probe
  62535. * @param name defines the name of the probe
  62536. * @param size defines the texture resolution (for each face)
  62537. * @param scene defines the hosting scene
  62538. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62539. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62540. */
  62541. constructor(
  62542. /** defines the name of the probe */
  62543. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62544. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62545. get samples(): number;
  62546. set samples(value: number);
  62547. /** Gets or sets the refresh rate to use (on every frame by default) */
  62548. get refreshRate(): number;
  62549. set refreshRate(value: number);
  62550. /**
  62551. * Gets the hosting scene
  62552. * @returns a Scene
  62553. */
  62554. getScene(): Scene;
  62555. /** Gets the internal CubeTexture used to render to */
  62556. get cubeTexture(): RenderTargetTexture;
  62557. /** Gets the list of meshes to render */
  62558. get renderList(): Nullable<AbstractMesh[]>;
  62559. /**
  62560. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62561. * @param mesh defines the mesh to attach to
  62562. */
  62563. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62564. /**
  62565. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62566. * @param renderingGroupId The rendering group id corresponding to its index
  62567. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62568. */
  62569. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62570. /**
  62571. * Clean all associated resources
  62572. */
  62573. dispose(): void;
  62574. /**
  62575. * Converts the reflection probe information to a readable string for debug purpose.
  62576. * @param fullDetails Supports for multiple levels of logging within scene loading
  62577. * @returns the human readable reflection probe info
  62578. */
  62579. toString(fullDetails?: boolean): string;
  62580. /**
  62581. * Get the class name of the relfection probe.
  62582. * @returns "ReflectionProbe"
  62583. */
  62584. getClassName(): string;
  62585. /**
  62586. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62587. * @returns The JSON representation of the texture
  62588. */
  62589. serialize(): any;
  62590. /**
  62591. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62592. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62593. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62594. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62595. * @returns The parsed reflection probe if successful
  62596. */
  62597. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62598. }
  62599. }
  62600. declare module BABYLON {
  62601. /** @hidden */
  62602. export var _BabylonLoaderRegistered: boolean;
  62603. /**
  62604. * Helps setting up some configuration for the babylon file loader.
  62605. */
  62606. export class BabylonFileLoaderConfiguration {
  62607. /**
  62608. * The loader does not allow injecting custom physix engine into the plugins.
  62609. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62610. * So you could set this variable to your engine import to make it work.
  62611. */
  62612. static LoaderInjectedPhysicsEngine: any;
  62613. }
  62614. }
  62615. declare module BABYLON {
  62616. /**
  62617. * The Physically based simple base material of BJS.
  62618. *
  62619. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62620. * It is used as the base class for both the specGloss and metalRough conventions.
  62621. */
  62622. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62623. /**
  62624. * Number of Simultaneous lights allowed on the material.
  62625. */
  62626. maxSimultaneousLights: number;
  62627. /**
  62628. * If sets to true, disables all the lights affecting the material.
  62629. */
  62630. disableLighting: boolean;
  62631. /**
  62632. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62633. */
  62634. environmentTexture: BaseTexture;
  62635. /**
  62636. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62637. */
  62638. invertNormalMapX: boolean;
  62639. /**
  62640. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62641. */
  62642. invertNormalMapY: boolean;
  62643. /**
  62644. * Normal map used in the model.
  62645. */
  62646. normalTexture: BaseTexture;
  62647. /**
  62648. * Emissivie color used to self-illuminate the model.
  62649. */
  62650. emissiveColor: Color3;
  62651. /**
  62652. * Emissivie texture used to self-illuminate the model.
  62653. */
  62654. emissiveTexture: BaseTexture;
  62655. /**
  62656. * Occlusion Channel Strenght.
  62657. */
  62658. occlusionStrength: number;
  62659. /**
  62660. * Occlusion Texture of the material (adding extra occlusion effects).
  62661. */
  62662. occlusionTexture: BaseTexture;
  62663. /**
  62664. * Defines the alpha limits in alpha test mode.
  62665. */
  62666. alphaCutOff: number;
  62667. /**
  62668. * Gets the current double sided mode.
  62669. */
  62670. get doubleSided(): boolean;
  62671. /**
  62672. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62673. */
  62674. set doubleSided(value: boolean);
  62675. /**
  62676. * Stores the pre-calculated light information of a mesh in a texture.
  62677. */
  62678. lightmapTexture: BaseTexture;
  62679. /**
  62680. * If true, the light map contains occlusion information instead of lighting info.
  62681. */
  62682. useLightmapAsShadowmap: boolean;
  62683. /**
  62684. * Instantiates a new PBRMaterial instance.
  62685. *
  62686. * @param name The material name
  62687. * @param scene The scene the material will be use in.
  62688. */
  62689. constructor(name: string, scene: Scene);
  62690. getClassName(): string;
  62691. }
  62692. }
  62693. declare module BABYLON {
  62694. /**
  62695. * The PBR material of BJS following the metal roughness convention.
  62696. *
  62697. * This fits to the PBR convention in the GLTF definition:
  62698. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62699. */
  62700. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62701. /**
  62702. * The base color has two different interpretations depending on the value of metalness.
  62703. * When the material is a metal, the base color is the specific measured reflectance value
  62704. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62705. * of the material.
  62706. */
  62707. baseColor: Color3;
  62708. /**
  62709. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62710. * well as opacity information in the alpha channel.
  62711. */
  62712. baseTexture: BaseTexture;
  62713. /**
  62714. * Specifies the metallic scalar value of the material.
  62715. * Can also be used to scale the metalness values of the metallic texture.
  62716. */
  62717. metallic: number;
  62718. /**
  62719. * Specifies the roughness scalar value of the material.
  62720. * Can also be used to scale the roughness values of the metallic texture.
  62721. */
  62722. roughness: number;
  62723. /**
  62724. * Texture containing both the metallic value in the B channel and the
  62725. * roughness value in the G channel to keep better precision.
  62726. */
  62727. metallicRoughnessTexture: BaseTexture;
  62728. /**
  62729. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62730. *
  62731. * @param name The material name
  62732. * @param scene The scene the material will be use in.
  62733. */
  62734. constructor(name: string, scene: Scene);
  62735. /**
  62736. * Return the currrent class name of the material.
  62737. */
  62738. getClassName(): string;
  62739. /**
  62740. * Makes a duplicate of the current material.
  62741. * @param name - name to use for the new material.
  62742. */
  62743. clone(name: string): PBRMetallicRoughnessMaterial;
  62744. /**
  62745. * Serialize the material to a parsable JSON object.
  62746. */
  62747. serialize(): any;
  62748. /**
  62749. * Parses a JSON object correponding to the serialize function.
  62750. */
  62751. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62752. }
  62753. }
  62754. declare module BABYLON {
  62755. /**
  62756. * The PBR material of BJS following the specular glossiness convention.
  62757. *
  62758. * This fits to the PBR convention in the GLTF definition:
  62759. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62760. */
  62761. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62762. /**
  62763. * Specifies the diffuse color of the material.
  62764. */
  62765. diffuseColor: Color3;
  62766. /**
  62767. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62768. * channel.
  62769. */
  62770. diffuseTexture: BaseTexture;
  62771. /**
  62772. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62773. */
  62774. specularColor: Color3;
  62775. /**
  62776. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62777. */
  62778. glossiness: number;
  62779. /**
  62780. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62781. */
  62782. specularGlossinessTexture: BaseTexture;
  62783. /**
  62784. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62785. *
  62786. * @param name The material name
  62787. * @param scene The scene the material will be use in.
  62788. */
  62789. constructor(name: string, scene: Scene);
  62790. /**
  62791. * Return the currrent class name of the material.
  62792. */
  62793. getClassName(): string;
  62794. /**
  62795. * Makes a duplicate of the current material.
  62796. * @param name - name to use for the new material.
  62797. */
  62798. clone(name: string): PBRSpecularGlossinessMaterial;
  62799. /**
  62800. * Serialize the material to a parsable JSON object.
  62801. */
  62802. serialize(): any;
  62803. /**
  62804. * Parses a JSON object correponding to the serialize function.
  62805. */
  62806. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62807. }
  62808. }
  62809. declare module BABYLON {
  62810. /**
  62811. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62812. * It can help converting any input color in a desired output one. This can then be used to create effects
  62813. * from sepia, black and white to sixties or futuristic rendering...
  62814. *
  62815. * The only supported format is currently 3dl.
  62816. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62817. */
  62818. export class ColorGradingTexture extends BaseTexture {
  62819. /**
  62820. * The texture URL.
  62821. */
  62822. url: string;
  62823. /**
  62824. * Empty line regex stored for GC.
  62825. */
  62826. private static _noneEmptyLineRegex;
  62827. private _textureMatrix;
  62828. private _onLoad;
  62829. /**
  62830. * Instantiates a ColorGradingTexture from the following parameters.
  62831. *
  62832. * @param url The location of the color gradind data (currently only supporting 3dl)
  62833. * @param sceneOrEngine The scene or engine the texture will be used in
  62834. * @param onLoad defines a callback triggered when the texture has been loaded
  62835. */
  62836. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62837. /**
  62838. * Fires the onload event from the constructor if requested.
  62839. */
  62840. private _triggerOnLoad;
  62841. /**
  62842. * Returns the texture matrix used in most of the material.
  62843. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62844. */
  62845. getTextureMatrix(): Matrix;
  62846. /**
  62847. * Occurs when the file being loaded is a .3dl LUT file.
  62848. */
  62849. private load3dlTexture;
  62850. /**
  62851. * Starts the loading process of the texture.
  62852. */
  62853. private loadTexture;
  62854. /**
  62855. * Clones the color gradind texture.
  62856. */
  62857. clone(): ColorGradingTexture;
  62858. /**
  62859. * Called during delayed load for textures.
  62860. */
  62861. delayLoad(): void;
  62862. /**
  62863. * Parses a color grading texture serialized by Babylon.
  62864. * @param parsedTexture The texture information being parsedTexture
  62865. * @param scene The scene to load the texture in
  62866. * @param rootUrl The root url of the data assets to load
  62867. * @return A color gradind texture
  62868. */
  62869. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62870. /**
  62871. * Serializes the LUT texture to json format.
  62872. */
  62873. serialize(): any;
  62874. }
  62875. }
  62876. declare module BABYLON {
  62877. /**
  62878. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62879. */
  62880. export class EquiRectangularCubeTexture extends BaseTexture {
  62881. /** The six faces of the cube. */
  62882. private static _FacesMapping;
  62883. private _noMipmap;
  62884. private _onLoad;
  62885. private _onError;
  62886. /** The size of the cubemap. */
  62887. private _size;
  62888. /** The buffer of the image. */
  62889. private _buffer;
  62890. /** The width of the input image. */
  62891. private _width;
  62892. /** The height of the input image. */
  62893. private _height;
  62894. /** The URL to the image. */
  62895. url: string;
  62896. /**
  62897. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62898. * @param url The location of the image
  62899. * @param scene The scene the texture will be used in
  62900. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62901. * @param noMipmap Forces to not generate the mipmap if true
  62902. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62903. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62904. * @param onLoad — defines a callback called when texture is loaded
  62905. * @param onError — defines a callback called if there is an error
  62906. */
  62907. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62908. /**
  62909. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62910. */
  62911. private loadImage;
  62912. /**
  62913. * Convert the image buffer into a cubemap and create a CubeTexture.
  62914. */
  62915. private loadTexture;
  62916. /**
  62917. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62918. * @param buffer The ArrayBuffer that should be converted.
  62919. * @returns The buffer as Float32Array.
  62920. */
  62921. private getFloat32ArrayFromArrayBuffer;
  62922. /**
  62923. * Get the current class name of the texture useful for serialization or dynamic coding.
  62924. * @returns "EquiRectangularCubeTexture"
  62925. */
  62926. getClassName(): string;
  62927. /**
  62928. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62929. * @returns A clone of the current EquiRectangularCubeTexture.
  62930. */
  62931. clone(): EquiRectangularCubeTexture;
  62932. }
  62933. }
  62934. declare module BABYLON {
  62935. /**
  62936. * Defines the options related to the creation of an HtmlElementTexture
  62937. */
  62938. export interface IHtmlElementTextureOptions {
  62939. /**
  62940. * Defines wether mip maps should be created or not.
  62941. */
  62942. generateMipMaps?: boolean;
  62943. /**
  62944. * Defines the sampling mode of the texture.
  62945. */
  62946. samplingMode?: number;
  62947. /**
  62948. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62949. */
  62950. engine: Nullable<ThinEngine>;
  62951. /**
  62952. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62953. */
  62954. scene: Nullable<Scene>;
  62955. }
  62956. /**
  62957. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62958. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62959. * is automatically managed.
  62960. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62961. * in your application.
  62962. *
  62963. * As the update is not automatic, you need to call them manually.
  62964. */
  62965. export class HtmlElementTexture extends BaseTexture {
  62966. /**
  62967. * The texture URL.
  62968. */
  62969. element: HTMLVideoElement | HTMLCanvasElement;
  62970. private static readonly DefaultOptions;
  62971. private _textureMatrix;
  62972. private _isVideo;
  62973. private _generateMipMaps;
  62974. private _samplingMode;
  62975. /**
  62976. * Instantiates a HtmlElementTexture from the following parameters.
  62977. *
  62978. * @param name Defines the name of the texture
  62979. * @param element Defines the video or canvas the texture is filled with
  62980. * @param options Defines the other none mandatory texture creation options
  62981. */
  62982. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62983. private _createInternalTexture;
  62984. /**
  62985. * Returns the texture matrix used in most of the material.
  62986. */
  62987. getTextureMatrix(): Matrix;
  62988. /**
  62989. * Updates the content of the texture.
  62990. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62991. */
  62992. update(invertY?: Nullable<boolean>): void;
  62993. }
  62994. }
  62995. declare module BABYLON {
  62996. /**
  62997. * Based on jsTGALoader - Javascript loader for TGA file
  62998. * By Vincent Thibault
  62999. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63000. */
  63001. export class TGATools {
  63002. private static _TYPE_INDEXED;
  63003. private static _TYPE_RGB;
  63004. private static _TYPE_GREY;
  63005. private static _TYPE_RLE_INDEXED;
  63006. private static _TYPE_RLE_RGB;
  63007. private static _TYPE_RLE_GREY;
  63008. private static _ORIGIN_MASK;
  63009. private static _ORIGIN_SHIFT;
  63010. private static _ORIGIN_BL;
  63011. private static _ORIGIN_BR;
  63012. private static _ORIGIN_UL;
  63013. private static _ORIGIN_UR;
  63014. /**
  63015. * Gets the header of a TGA file
  63016. * @param data defines the TGA data
  63017. * @returns the header
  63018. */
  63019. static GetTGAHeader(data: Uint8Array): any;
  63020. /**
  63021. * Uploads TGA content to a Babylon Texture
  63022. * @hidden
  63023. */
  63024. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63025. /** @hidden */
  63026. 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;
  63027. /** @hidden */
  63028. 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;
  63029. /** @hidden */
  63030. 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;
  63031. /** @hidden */
  63032. 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;
  63033. /** @hidden */
  63034. 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;
  63035. /** @hidden */
  63036. 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;
  63037. }
  63038. }
  63039. declare module BABYLON {
  63040. /**
  63041. * Implementation of the TGA Texture Loader.
  63042. * @hidden
  63043. */
  63044. export class _TGATextureLoader implements IInternalTextureLoader {
  63045. /**
  63046. * Defines wether the loader supports cascade loading the different faces.
  63047. */
  63048. readonly supportCascades: boolean;
  63049. /**
  63050. * This returns if the loader support the current file information.
  63051. * @param extension defines the file extension of the file being loaded
  63052. * @returns true if the loader can load the specified file
  63053. */
  63054. canLoad(extension: string): boolean;
  63055. /**
  63056. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63057. * @param data contains the texture data
  63058. * @param texture defines the BabylonJS internal texture
  63059. * @param createPolynomials will be true if polynomials have been requested
  63060. * @param onLoad defines the callback to trigger once the texture is ready
  63061. * @param onError defines the callback to trigger in case of error
  63062. */
  63063. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63064. /**
  63065. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63066. * @param data contains the texture data
  63067. * @param texture defines the BabylonJS internal texture
  63068. * @param callback defines the method to call once ready to upload
  63069. */
  63070. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63071. }
  63072. }
  63073. declare module BABYLON {
  63074. /**
  63075. * Info about the .basis files
  63076. */
  63077. class BasisFileInfo {
  63078. /**
  63079. * If the file has alpha
  63080. */
  63081. hasAlpha: boolean;
  63082. /**
  63083. * Info about each image of the basis file
  63084. */
  63085. images: Array<{
  63086. levels: Array<{
  63087. width: number;
  63088. height: number;
  63089. transcodedPixels: ArrayBufferView;
  63090. }>;
  63091. }>;
  63092. }
  63093. /**
  63094. * Result of transcoding a basis file
  63095. */
  63096. class TranscodeResult {
  63097. /**
  63098. * Info about the .basis file
  63099. */
  63100. fileInfo: BasisFileInfo;
  63101. /**
  63102. * Format to use when loading the file
  63103. */
  63104. format: number;
  63105. }
  63106. /**
  63107. * Configuration options for the Basis transcoder
  63108. */
  63109. export class BasisTranscodeConfiguration {
  63110. /**
  63111. * Supported compression formats used to determine the supported output format of the transcoder
  63112. */
  63113. supportedCompressionFormats?: {
  63114. /**
  63115. * etc1 compression format
  63116. */
  63117. etc1?: boolean;
  63118. /**
  63119. * s3tc compression format
  63120. */
  63121. s3tc?: boolean;
  63122. /**
  63123. * pvrtc compression format
  63124. */
  63125. pvrtc?: boolean;
  63126. /**
  63127. * etc2 compression format
  63128. */
  63129. etc2?: boolean;
  63130. };
  63131. /**
  63132. * If mipmap levels should be loaded for transcoded images (Default: true)
  63133. */
  63134. loadMipmapLevels?: boolean;
  63135. /**
  63136. * Index of a single image to load (Default: all images)
  63137. */
  63138. loadSingleImage?: number;
  63139. }
  63140. /**
  63141. * Used to load .Basis files
  63142. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63143. */
  63144. export class BasisTools {
  63145. private static _IgnoreSupportedFormats;
  63146. /**
  63147. * URL to use when loading the basis transcoder
  63148. */
  63149. static JSModuleURL: string;
  63150. /**
  63151. * URL to use when loading the wasm module for the transcoder
  63152. */
  63153. static WasmModuleURL: string;
  63154. /**
  63155. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63156. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63157. * @returns internal format corresponding to the Basis format
  63158. */
  63159. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63160. private static _WorkerPromise;
  63161. private static _Worker;
  63162. private static _actionId;
  63163. private static _CreateWorkerAsync;
  63164. /**
  63165. * Transcodes a loaded image file to compressed pixel data
  63166. * @param data image data to transcode
  63167. * @param config configuration options for the transcoding
  63168. * @returns a promise resulting in the transcoded image
  63169. */
  63170. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63171. /**
  63172. * Loads a texture from the transcode result
  63173. * @param texture texture load to
  63174. * @param transcodeResult the result of transcoding the basis file to load from
  63175. */
  63176. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63177. }
  63178. }
  63179. declare module BABYLON {
  63180. /**
  63181. * Loader for .basis file format
  63182. */
  63183. export class _BasisTextureLoader implements IInternalTextureLoader {
  63184. /**
  63185. * Defines whether the loader supports cascade loading the different faces.
  63186. */
  63187. readonly supportCascades: boolean;
  63188. /**
  63189. * This returns if the loader support the current file information.
  63190. * @param extension defines the file extension of the file being loaded
  63191. * @returns true if the loader can load the specified file
  63192. */
  63193. canLoad(extension: string): boolean;
  63194. /**
  63195. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63196. * @param data contains the texture data
  63197. * @param texture defines the BabylonJS internal texture
  63198. * @param createPolynomials will be true if polynomials have been requested
  63199. * @param onLoad defines the callback to trigger once the texture is ready
  63200. * @param onError defines the callback to trigger in case of error
  63201. */
  63202. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63203. /**
  63204. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63205. * @param data contains the texture data
  63206. * @param texture defines the BabylonJS internal texture
  63207. * @param callback defines the method to call once ready to upload
  63208. */
  63209. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63210. }
  63211. }
  63212. declare module BABYLON {
  63213. /**
  63214. * Defines the basic options interface of a TexturePacker Frame
  63215. */
  63216. export interface ITexturePackerFrame {
  63217. /**
  63218. * The frame ID
  63219. */
  63220. id: number;
  63221. /**
  63222. * The frames Scale
  63223. */
  63224. scale: Vector2;
  63225. /**
  63226. * The Frames offset
  63227. */
  63228. offset: Vector2;
  63229. }
  63230. /**
  63231. * This is a support class for frame Data on texture packer sets.
  63232. */
  63233. export class TexturePackerFrame implements ITexturePackerFrame {
  63234. /**
  63235. * The frame ID
  63236. */
  63237. id: number;
  63238. /**
  63239. * The frames Scale
  63240. */
  63241. scale: Vector2;
  63242. /**
  63243. * The Frames offset
  63244. */
  63245. offset: Vector2;
  63246. /**
  63247. * Initializes a texture package frame.
  63248. * @param id The numerical frame identifier
  63249. * @param scale Scalar Vector2 for UV frame
  63250. * @param offset Vector2 for the frame position in UV units.
  63251. * @returns TexturePackerFrame
  63252. */
  63253. constructor(id: number, scale: Vector2, offset: Vector2);
  63254. }
  63255. }
  63256. declare module BABYLON {
  63257. /**
  63258. * Defines the basic options interface of a TexturePacker
  63259. */
  63260. export interface ITexturePackerOptions {
  63261. /**
  63262. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63263. */
  63264. map?: string[];
  63265. /**
  63266. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63267. */
  63268. uvsIn?: string;
  63269. /**
  63270. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63271. */
  63272. uvsOut?: string;
  63273. /**
  63274. * number representing the layout style. Defaults to LAYOUT_STRIP
  63275. */
  63276. layout?: number;
  63277. /**
  63278. * number of columns if using custom column count layout(2). This defaults to 4.
  63279. */
  63280. colnum?: number;
  63281. /**
  63282. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63283. */
  63284. updateInputMeshes?: boolean;
  63285. /**
  63286. * boolean flag to dispose all the source textures. Defaults to true.
  63287. */
  63288. disposeSources?: boolean;
  63289. /**
  63290. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63291. */
  63292. fillBlanks?: boolean;
  63293. /**
  63294. * string value representing the context fill style color. Defaults to 'black'.
  63295. */
  63296. customFillColor?: string;
  63297. /**
  63298. * Width and Height Value of each Frame in the TexturePacker Sets
  63299. */
  63300. frameSize?: number;
  63301. /**
  63302. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63303. */
  63304. paddingRatio?: number;
  63305. /**
  63306. * Number that declares the fill method for the padding gutter.
  63307. */
  63308. paddingMode?: number;
  63309. /**
  63310. * If in SUBUV_COLOR padding mode what color to use.
  63311. */
  63312. paddingColor?: Color3 | Color4;
  63313. }
  63314. /**
  63315. * Defines the basic interface of a TexturePacker JSON File
  63316. */
  63317. export interface ITexturePackerJSON {
  63318. /**
  63319. * The frame ID
  63320. */
  63321. name: string;
  63322. /**
  63323. * The base64 channel data
  63324. */
  63325. sets: any;
  63326. /**
  63327. * The options of the Packer
  63328. */
  63329. options: ITexturePackerOptions;
  63330. /**
  63331. * The frame data of the Packer
  63332. */
  63333. frames: Array<number>;
  63334. }
  63335. /**
  63336. * This is a support class that generates a series of packed texture sets.
  63337. * @see https://doc.babylonjs.com/babylon101/materials
  63338. */
  63339. export class TexturePacker {
  63340. /** Packer Layout Constant 0 */
  63341. static readonly LAYOUT_STRIP: number;
  63342. /** Packer Layout Constant 1 */
  63343. static readonly LAYOUT_POWER2: number;
  63344. /** Packer Layout Constant 2 */
  63345. static readonly LAYOUT_COLNUM: number;
  63346. /** Packer Layout Constant 0 */
  63347. static readonly SUBUV_WRAP: number;
  63348. /** Packer Layout Constant 1 */
  63349. static readonly SUBUV_EXTEND: number;
  63350. /** Packer Layout Constant 2 */
  63351. static readonly SUBUV_COLOR: number;
  63352. /** The Name of the Texture Package */
  63353. name: string;
  63354. /** The scene scope of the TexturePacker */
  63355. scene: Scene;
  63356. /** The Meshes to target */
  63357. meshes: AbstractMesh[];
  63358. /** Arguments passed with the Constructor */
  63359. options: ITexturePackerOptions;
  63360. /** The promise that is started upon initialization */
  63361. promise: Nullable<Promise<TexturePacker | string>>;
  63362. /** The Container object for the channel sets that are generated */
  63363. sets: object;
  63364. /** The Container array for the frames that are generated */
  63365. frames: TexturePackerFrame[];
  63366. /** The expected number of textures the system is parsing. */
  63367. private _expecting;
  63368. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63369. private _paddingValue;
  63370. /**
  63371. * Initializes a texture package series from an array of meshes or a single mesh.
  63372. * @param name The name of the package
  63373. * @param meshes The target meshes to compose the package from
  63374. * @param options The arguments that texture packer should follow while building.
  63375. * @param scene The scene which the textures are scoped to.
  63376. * @returns TexturePacker
  63377. */
  63378. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63379. /**
  63380. * Starts the package process
  63381. * @param resolve The promises resolution function
  63382. * @returns TexturePacker
  63383. */
  63384. private _createFrames;
  63385. /**
  63386. * Calculates the Size of the Channel Sets
  63387. * @returns Vector2
  63388. */
  63389. private _calculateSize;
  63390. /**
  63391. * Calculates the UV data for the frames.
  63392. * @param baseSize the base frameSize
  63393. * @param padding the base frame padding
  63394. * @param dtSize size of the Dynamic Texture for that channel
  63395. * @param dtUnits is 1/dtSize
  63396. * @param update flag to update the input meshes
  63397. */
  63398. private _calculateMeshUVFrames;
  63399. /**
  63400. * Calculates the frames Offset.
  63401. * @param index of the frame
  63402. * @returns Vector2
  63403. */
  63404. private _getFrameOffset;
  63405. /**
  63406. * Updates a Mesh to the frame data
  63407. * @param mesh that is the target
  63408. * @param frameID or the frame index
  63409. */
  63410. private _updateMeshUV;
  63411. /**
  63412. * Updates a Meshes materials to use the texture packer channels
  63413. * @param m is the mesh to target
  63414. * @param force all channels on the packer to be set.
  63415. */
  63416. private _updateTextureReferences;
  63417. /**
  63418. * Public method to set a Mesh to a frame
  63419. * @param m that is the target
  63420. * @param frameID or the frame index
  63421. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63422. */
  63423. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63424. /**
  63425. * Starts the async promise to compile the texture packer.
  63426. * @returns Promise<void>
  63427. */
  63428. processAsync(): Promise<void>;
  63429. /**
  63430. * Disposes all textures associated with this packer
  63431. */
  63432. dispose(): void;
  63433. /**
  63434. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63435. * @param imageType is the image type to use.
  63436. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63437. */
  63438. download(imageType?: string, quality?: number): void;
  63439. /**
  63440. * Public method to load a texturePacker JSON file.
  63441. * @param data of the JSON file in string format.
  63442. */
  63443. updateFromJSON(data: string): void;
  63444. }
  63445. }
  63446. declare module BABYLON {
  63447. /**
  63448. * 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.
  63449. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63450. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63451. */
  63452. export class CustomProceduralTexture extends ProceduralTexture {
  63453. private _animate;
  63454. private _time;
  63455. private _config;
  63456. private _texturePath;
  63457. /**
  63458. * Instantiates a new Custom Procedural Texture.
  63459. * 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.
  63460. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63461. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63462. * @param name Define the name of the texture
  63463. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63464. * @param size Define the size of the texture to create
  63465. * @param scene Define the scene the texture belongs to
  63466. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63467. * @param generateMipMaps Define if the texture should creates mip maps or not
  63468. */
  63469. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63470. private _loadJson;
  63471. /**
  63472. * Is the texture ready to be used ? (rendered at least once)
  63473. * @returns true if ready, otherwise, false.
  63474. */
  63475. isReady(): boolean;
  63476. /**
  63477. * Render the texture to its associated render target.
  63478. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63479. */
  63480. render(useCameraPostProcess?: boolean): void;
  63481. /**
  63482. * Update the list of dependant textures samplers in the shader.
  63483. */
  63484. updateTextures(): void;
  63485. /**
  63486. * Update the uniform values of the procedural texture in the shader.
  63487. */
  63488. updateShaderUniforms(): void;
  63489. /**
  63490. * Define if the texture animates or not.
  63491. */
  63492. get animate(): boolean;
  63493. set animate(value: boolean);
  63494. }
  63495. }
  63496. declare module BABYLON {
  63497. /** @hidden */
  63498. export var noisePixelShader: {
  63499. name: string;
  63500. shader: string;
  63501. };
  63502. }
  63503. declare module BABYLON {
  63504. /**
  63505. * Class used to generate noise procedural textures
  63506. */
  63507. export class NoiseProceduralTexture extends ProceduralTexture {
  63508. /** Gets or sets the start time (default is 0) */
  63509. time: number;
  63510. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63511. brightness: number;
  63512. /** Defines the number of octaves to process */
  63513. octaves: number;
  63514. /** Defines the level of persistence (0.8 by default) */
  63515. persistence: number;
  63516. /** Gets or sets animation speed factor (default is 1) */
  63517. animationSpeedFactor: number;
  63518. /**
  63519. * Creates a new NoiseProceduralTexture
  63520. * @param name defines the name fo the texture
  63521. * @param size defines the size of the texture (default is 256)
  63522. * @param scene defines the hosting scene
  63523. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63524. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63525. */
  63526. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63527. private _updateShaderUniforms;
  63528. protected _getDefines(): string;
  63529. /** Generate the current state of the procedural texture */
  63530. render(useCameraPostProcess?: boolean): void;
  63531. /**
  63532. * Serializes this noise procedural texture
  63533. * @returns a serialized noise procedural texture object
  63534. */
  63535. serialize(): any;
  63536. /**
  63537. * Clone the texture.
  63538. * @returns the cloned texture
  63539. */
  63540. clone(): NoiseProceduralTexture;
  63541. /**
  63542. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63543. * @param parsedTexture defines parsed texture data
  63544. * @param scene defines the current scene
  63545. * @param rootUrl defines the root URL containing noise procedural texture information
  63546. * @returns a parsed NoiseProceduralTexture
  63547. */
  63548. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63549. }
  63550. }
  63551. declare module BABYLON {
  63552. /**
  63553. * Raw cube texture where the raw buffers are passed in
  63554. */
  63555. export class RawCubeTexture extends CubeTexture {
  63556. /**
  63557. * Creates a cube texture where the raw buffers are passed in.
  63558. * @param scene defines the scene the texture is attached to
  63559. * @param data defines the array of data to use to create each face
  63560. * @param size defines the size of the textures
  63561. * @param format defines the format of the data
  63562. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63563. * @param generateMipMaps defines if the engine should generate the mip levels
  63564. * @param invertY defines if data must be stored with Y axis inverted
  63565. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63566. * @param compression defines the compression used (null by default)
  63567. */
  63568. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63569. /**
  63570. * Updates the raw cube texture.
  63571. * @param data defines the data to store
  63572. * @param format defines the data format
  63573. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63574. * @param invertY defines if data must be stored with Y axis inverted
  63575. * @param compression defines the compression used (null by default)
  63576. * @param level defines which level of the texture to update
  63577. */
  63578. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63579. /**
  63580. * Updates a raw cube texture with RGBD encoded data.
  63581. * @param data defines the array of data [mipmap][face] to use to create each face
  63582. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63583. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63584. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63585. * @returns a promsie that resolves when the operation is complete
  63586. */
  63587. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63588. /**
  63589. * Clones the raw cube texture.
  63590. * @return a new cube texture
  63591. */
  63592. clone(): CubeTexture;
  63593. /** @hidden */
  63594. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63595. }
  63596. }
  63597. declare module BABYLON {
  63598. /**
  63599. * Class used to store 2D array textures containing user data
  63600. */
  63601. export class RawTexture2DArray extends Texture {
  63602. /** Gets or sets the texture format to use */
  63603. format: number;
  63604. /**
  63605. * Create a new RawTexture2DArray
  63606. * @param data defines the data of the texture
  63607. * @param width defines the width of the texture
  63608. * @param height defines the height of the texture
  63609. * @param depth defines the number of layers of the texture
  63610. * @param format defines the texture format to use
  63611. * @param scene defines the hosting scene
  63612. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63613. * @param invertY defines if texture must be stored with Y axis inverted
  63614. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63615. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63616. */
  63617. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63618. /** Gets or sets the texture format to use */
  63619. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63620. /**
  63621. * Update the texture with new data
  63622. * @param data defines the data to store in the texture
  63623. */
  63624. update(data: ArrayBufferView): void;
  63625. }
  63626. }
  63627. declare module BABYLON {
  63628. /**
  63629. * Class used to store 3D textures containing user data
  63630. */
  63631. export class RawTexture3D extends Texture {
  63632. /** Gets or sets the texture format to use */
  63633. format: number;
  63634. /**
  63635. * Create a new RawTexture3D
  63636. * @param data defines the data of the texture
  63637. * @param width defines the width of the texture
  63638. * @param height defines the height of the texture
  63639. * @param depth defines the depth of the texture
  63640. * @param format defines the texture format to use
  63641. * @param scene defines the hosting scene
  63642. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63643. * @param invertY defines if texture must be stored with Y axis inverted
  63644. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63645. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63646. */
  63647. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63648. /** Gets or sets the texture format to use */
  63649. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63650. /**
  63651. * Update the texture with new data
  63652. * @param data defines the data to store in the texture
  63653. */
  63654. update(data: ArrayBufferView): void;
  63655. }
  63656. }
  63657. declare module BABYLON {
  63658. /**
  63659. * Creates a refraction texture used by refraction channel of the standard material.
  63660. * It is like a mirror but to see through a material.
  63661. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63662. */
  63663. export class RefractionTexture extends RenderTargetTexture {
  63664. /**
  63665. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63666. * 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.
  63667. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63668. */
  63669. refractionPlane: Plane;
  63670. /**
  63671. * Define how deep under the surface we should see.
  63672. */
  63673. depth: number;
  63674. /**
  63675. * Creates a refraction texture used by refraction channel of the standard material.
  63676. * It is like a mirror but to see through a material.
  63677. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63678. * @param name Define the texture name
  63679. * @param size Define the size of the underlying texture
  63680. * @param scene Define the scene the refraction belongs to
  63681. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63682. */
  63683. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63684. /**
  63685. * Clone the refraction texture.
  63686. * @returns the cloned texture
  63687. */
  63688. clone(): RefractionTexture;
  63689. /**
  63690. * Serialize the texture to a JSON representation you could use in Parse later on
  63691. * @returns the serialized JSON representation
  63692. */
  63693. serialize(): any;
  63694. }
  63695. }
  63696. declare module BABYLON {
  63697. /**
  63698. * Block used to add support for vertex skinning (bones)
  63699. */
  63700. export class BonesBlock extends NodeMaterialBlock {
  63701. /**
  63702. * Creates a new BonesBlock
  63703. * @param name defines the block name
  63704. */
  63705. constructor(name: string);
  63706. /**
  63707. * Initialize the block and prepare the context for build
  63708. * @param state defines the state that will be used for the build
  63709. */
  63710. initialize(state: NodeMaterialBuildState): void;
  63711. /**
  63712. * Gets the current class name
  63713. * @returns the class name
  63714. */
  63715. getClassName(): string;
  63716. /**
  63717. * Gets the matrix indices input component
  63718. */
  63719. get matricesIndices(): NodeMaterialConnectionPoint;
  63720. /**
  63721. * Gets the matrix weights input component
  63722. */
  63723. get matricesWeights(): NodeMaterialConnectionPoint;
  63724. /**
  63725. * Gets the extra matrix indices input component
  63726. */
  63727. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63728. /**
  63729. * Gets the extra matrix weights input component
  63730. */
  63731. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63732. /**
  63733. * Gets the world input component
  63734. */
  63735. get world(): NodeMaterialConnectionPoint;
  63736. /**
  63737. * Gets the output component
  63738. */
  63739. get output(): NodeMaterialConnectionPoint;
  63740. autoConfigure(material: NodeMaterial): void;
  63741. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63742. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63743. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63744. protected _buildBlock(state: NodeMaterialBuildState): this;
  63745. }
  63746. }
  63747. declare module BABYLON {
  63748. /**
  63749. * Block used to add support for instances
  63750. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63751. */
  63752. export class InstancesBlock extends NodeMaterialBlock {
  63753. /**
  63754. * Creates a new InstancesBlock
  63755. * @param name defines the block name
  63756. */
  63757. constructor(name: string);
  63758. /**
  63759. * Gets the current class name
  63760. * @returns the class name
  63761. */
  63762. getClassName(): string;
  63763. /**
  63764. * Gets the first world row input component
  63765. */
  63766. get world0(): NodeMaterialConnectionPoint;
  63767. /**
  63768. * Gets the second world row input component
  63769. */
  63770. get world1(): NodeMaterialConnectionPoint;
  63771. /**
  63772. * Gets the third world row input component
  63773. */
  63774. get world2(): NodeMaterialConnectionPoint;
  63775. /**
  63776. * Gets the forth world row input component
  63777. */
  63778. get world3(): NodeMaterialConnectionPoint;
  63779. /**
  63780. * Gets the world input component
  63781. */
  63782. get world(): NodeMaterialConnectionPoint;
  63783. /**
  63784. * Gets the output component
  63785. */
  63786. get output(): NodeMaterialConnectionPoint;
  63787. /**
  63788. * Gets the isntanceID component
  63789. */
  63790. get instanceID(): NodeMaterialConnectionPoint;
  63791. autoConfigure(material: NodeMaterial): void;
  63792. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63793. protected _buildBlock(state: NodeMaterialBuildState): this;
  63794. }
  63795. }
  63796. declare module BABYLON {
  63797. /**
  63798. * Block used to add morph targets support to vertex shader
  63799. */
  63800. export class MorphTargetsBlock extends NodeMaterialBlock {
  63801. private _repeatableContentAnchor;
  63802. /**
  63803. * Create a new MorphTargetsBlock
  63804. * @param name defines the block name
  63805. */
  63806. constructor(name: string);
  63807. /**
  63808. * Gets the current class name
  63809. * @returns the class name
  63810. */
  63811. getClassName(): string;
  63812. /**
  63813. * Gets the position input component
  63814. */
  63815. get position(): NodeMaterialConnectionPoint;
  63816. /**
  63817. * Gets the normal input component
  63818. */
  63819. get normal(): NodeMaterialConnectionPoint;
  63820. /**
  63821. * Gets the tangent input component
  63822. */
  63823. get tangent(): NodeMaterialConnectionPoint;
  63824. /**
  63825. * Gets the tangent input component
  63826. */
  63827. get uv(): NodeMaterialConnectionPoint;
  63828. /**
  63829. * Gets the position output component
  63830. */
  63831. get positionOutput(): NodeMaterialConnectionPoint;
  63832. /**
  63833. * Gets the normal output component
  63834. */
  63835. get normalOutput(): NodeMaterialConnectionPoint;
  63836. /**
  63837. * Gets the tangent output component
  63838. */
  63839. get tangentOutput(): NodeMaterialConnectionPoint;
  63840. /**
  63841. * Gets the tangent output component
  63842. */
  63843. get uvOutput(): NodeMaterialConnectionPoint;
  63844. initialize(state: NodeMaterialBuildState): void;
  63845. autoConfigure(material: NodeMaterial): void;
  63846. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63847. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63848. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63849. protected _buildBlock(state: NodeMaterialBuildState): this;
  63850. }
  63851. }
  63852. declare module BABYLON {
  63853. /**
  63854. * Block used to get data information from a light
  63855. */
  63856. export class LightInformationBlock extends NodeMaterialBlock {
  63857. private _lightDataUniformName;
  63858. private _lightColorUniformName;
  63859. private _lightTypeDefineName;
  63860. /**
  63861. * Gets or sets the light associated with this block
  63862. */
  63863. light: Nullable<Light>;
  63864. /**
  63865. * Creates a new LightInformationBlock
  63866. * @param name defines the block name
  63867. */
  63868. constructor(name: string);
  63869. /**
  63870. * Gets the current class name
  63871. * @returns the class name
  63872. */
  63873. getClassName(): string;
  63874. /**
  63875. * Gets the world position input component
  63876. */
  63877. get worldPosition(): NodeMaterialConnectionPoint;
  63878. /**
  63879. * Gets the direction output component
  63880. */
  63881. get direction(): NodeMaterialConnectionPoint;
  63882. /**
  63883. * Gets the direction output component
  63884. */
  63885. get color(): NodeMaterialConnectionPoint;
  63886. /**
  63887. * Gets the direction output component
  63888. */
  63889. get intensity(): NodeMaterialConnectionPoint;
  63890. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63892. protected _buildBlock(state: NodeMaterialBuildState): this;
  63893. serialize(): any;
  63894. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63895. }
  63896. }
  63897. declare module BABYLON {
  63898. /**
  63899. * Block used to add image processing support to fragment shader
  63900. */
  63901. export class ImageProcessingBlock extends NodeMaterialBlock {
  63902. /**
  63903. * Create a new ImageProcessingBlock
  63904. * @param name defines the block name
  63905. */
  63906. constructor(name: string);
  63907. /**
  63908. * Gets the current class name
  63909. * @returns the class name
  63910. */
  63911. getClassName(): string;
  63912. /**
  63913. * Gets the color input component
  63914. */
  63915. get color(): NodeMaterialConnectionPoint;
  63916. /**
  63917. * Gets the output component
  63918. */
  63919. get output(): NodeMaterialConnectionPoint;
  63920. /**
  63921. * Initialize the block and prepare the context for build
  63922. * @param state defines the state that will be used for the build
  63923. */
  63924. initialize(state: NodeMaterialBuildState): void;
  63925. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63927. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63928. protected _buildBlock(state: NodeMaterialBuildState): this;
  63929. }
  63930. }
  63931. declare module BABYLON {
  63932. /**
  63933. * Block used to pertub normals based on a normal map
  63934. */
  63935. export class PerturbNormalBlock extends NodeMaterialBlock {
  63936. private _tangentSpaceParameterName;
  63937. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63938. invertX: boolean;
  63939. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63940. invertY: boolean;
  63941. /**
  63942. * Create a new PerturbNormalBlock
  63943. * @param name defines the block name
  63944. */
  63945. constructor(name: string);
  63946. /**
  63947. * Gets the current class name
  63948. * @returns the class name
  63949. */
  63950. getClassName(): string;
  63951. /**
  63952. * Gets the world position input component
  63953. */
  63954. get worldPosition(): NodeMaterialConnectionPoint;
  63955. /**
  63956. * Gets the world normal input component
  63957. */
  63958. get worldNormal(): NodeMaterialConnectionPoint;
  63959. /**
  63960. * Gets the world tangent input component
  63961. */
  63962. get worldTangent(): NodeMaterialConnectionPoint;
  63963. /**
  63964. * Gets the uv input component
  63965. */
  63966. get uv(): NodeMaterialConnectionPoint;
  63967. /**
  63968. * Gets the normal map color input component
  63969. */
  63970. get normalMapColor(): NodeMaterialConnectionPoint;
  63971. /**
  63972. * Gets the strength input component
  63973. */
  63974. get strength(): NodeMaterialConnectionPoint;
  63975. /**
  63976. * Gets the output component
  63977. */
  63978. get output(): NodeMaterialConnectionPoint;
  63979. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63980. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63981. autoConfigure(material: NodeMaterial): void;
  63982. protected _buildBlock(state: NodeMaterialBuildState): this;
  63983. protected _dumpPropertiesCode(): string;
  63984. serialize(): any;
  63985. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63986. }
  63987. }
  63988. declare module BABYLON {
  63989. /**
  63990. * Block used to discard a pixel if a value is smaller than a cutoff
  63991. */
  63992. export class DiscardBlock extends NodeMaterialBlock {
  63993. /**
  63994. * Create a new DiscardBlock
  63995. * @param name defines the block name
  63996. */
  63997. constructor(name: string);
  63998. /**
  63999. * Gets the current class name
  64000. * @returns the class name
  64001. */
  64002. getClassName(): string;
  64003. /**
  64004. * Gets the color input component
  64005. */
  64006. get value(): NodeMaterialConnectionPoint;
  64007. /**
  64008. * Gets the cutoff input component
  64009. */
  64010. get cutoff(): NodeMaterialConnectionPoint;
  64011. protected _buildBlock(state: NodeMaterialBuildState): this;
  64012. }
  64013. }
  64014. declare module BABYLON {
  64015. /**
  64016. * Block used to test if the fragment shader is front facing
  64017. */
  64018. export class FrontFacingBlock extends NodeMaterialBlock {
  64019. /**
  64020. * Creates a new FrontFacingBlock
  64021. * @param name defines the block name
  64022. */
  64023. constructor(name: string);
  64024. /**
  64025. * Gets the current class name
  64026. * @returns the class name
  64027. */
  64028. getClassName(): string;
  64029. /**
  64030. * Gets the output component
  64031. */
  64032. get output(): NodeMaterialConnectionPoint;
  64033. protected _buildBlock(state: NodeMaterialBuildState): this;
  64034. }
  64035. }
  64036. declare module BABYLON {
  64037. /**
  64038. * Block used to get the derivative value on x and y of a given input
  64039. */
  64040. export class DerivativeBlock extends NodeMaterialBlock {
  64041. /**
  64042. * Create a new DerivativeBlock
  64043. * @param name defines the block name
  64044. */
  64045. constructor(name: string);
  64046. /**
  64047. * Gets the current class name
  64048. * @returns the class name
  64049. */
  64050. getClassName(): string;
  64051. /**
  64052. * Gets the input component
  64053. */
  64054. get input(): NodeMaterialConnectionPoint;
  64055. /**
  64056. * Gets the derivative output on x
  64057. */
  64058. get dx(): NodeMaterialConnectionPoint;
  64059. /**
  64060. * Gets the derivative output on y
  64061. */
  64062. get dy(): NodeMaterialConnectionPoint;
  64063. protected _buildBlock(state: NodeMaterialBuildState): this;
  64064. }
  64065. }
  64066. declare module BABYLON {
  64067. /**
  64068. * Block used to make gl_FragCoord available
  64069. */
  64070. export class FragCoordBlock extends NodeMaterialBlock {
  64071. /**
  64072. * Creates a new FragCoordBlock
  64073. * @param name defines the block name
  64074. */
  64075. constructor(name: string);
  64076. /**
  64077. * Gets the current class name
  64078. * @returns the class name
  64079. */
  64080. getClassName(): string;
  64081. /**
  64082. * Gets the xy component
  64083. */
  64084. get xy(): NodeMaterialConnectionPoint;
  64085. /**
  64086. * Gets the xyz component
  64087. */
  64088. get xyz(): NodeMaterialConnectionPoint;
  64089. /**
  64090. * Gets the xyzw component
  64091. */
  64092. get xyzw(): NodeMaterialConnectionPoint;
  64093. /**
  64094. * Gets the x component
  64095. */
  64096. get x(): NodeMaterialConnectionPoint;
  64097. /**
  64098. * Gets the y component
  64099. */
  64100. get y(): NodeMaterialConnectionPoint;
  64101. /**
  64102. * Gets the z component
  64103. */
  64104. get z(): NodeMaterialConnectionPoint;
  64105. /**
  64106. * Gets the w component
  64107. */
  64108. get output(): NodeMaterialConnectionPoint;
  64109. protected writeOutputs(state: NodeMaterialBuildState): string;
  64110. protected _buildBlock(state: NodeMaterialBuildState): this;
  64111. }
  64112. }
  64113. declare module BABYLON {
  64114. /**
  64115. * Block used to get the screen sizes
  64116. */
  64117. export class ScreenSizeBlock extends NodeMaterialBlock {
  64118. private _varName;
  64119. private _scene;
  64120. /**
  64121. * Creates a new ScreenSizeBlock
  64122. * @param name defines the block name
  64123. */
  64124. constructor(name: string);
  64125. /**
  64126. * Gets the current class name
  64127. * @returns the class name
  64128. */
  64129. getClassName(): string;
  64130. /**
  64131. * Gets the xy component
  64132. */
  64133. get xy(): NodeMaterialConnectionPoint;
  64134. /**
  64135. * Gets the x component
  64136. */
  64137. get x(): NodeMaterialConnectionPoint;
  64138. /**
  64139. * Gets the y component
  64140. */
  64141. get y(): NodeMaterialConnectionPoint;
  64142. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64143. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64144. protected _buildBlock(state: NodeMaterialBuildState): this;
  64145. }
  64146. }
  64147. declare module BABYLON {
  64148. /**
  64149. * Block used to add support for scene fog
  64150. */
  64151. export class FogBlock extends NodeMaterialBlock {
  64152. private _fogDistanceName;
  64153. private _fogParameters;
  64154. /**
  64155. * Create a new FogBlock
  64156. * @param name defines the block name
  64157. */
  64158. constructor(name: string);
  64159. /**
  64160. * Gets the current class name
  64161. * @returns the class name
  64162. */
  64163. getClassName(): string;
  64164. /**
  64165. * Gets the world position input component
  64166. */
  64167. get worldPosition(): NodeMaterialConnectionPoint;
  64168. /**
  64169. * Gets the view input component
  64170. */
  64171. get view(): NodeMaterialConnectionPoint;
  64172. /**
  64173. * Gets the color input component
  64174. */
  64175. get input(): NodeMaterialConnectionPoint;
  64176. /**
  64177. * Gets the fog color input component
  64178. */
  64179. get fogColor(): NodeMaterialConnectionPoint;
  64180. /**
  64181. * Gets the output component
  64182. */
  64183. get output(): NodeMaterialConnectionPoint;
  64184. autoConfigure(material: NodeMaterial): void;
  64185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64186. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64187. protected _buildBlock(state: NodeMaterialBuildState): this;
  64188. }
  64189. }
  64190. declare module BABYLON {
  64191. /**
  64192. * Block used to add light in the fragment shader
  64193. */
  64194. export class LightBlock extends NodeMaterialBlock {
  64195. private _lightId;
  64196. /**
  64197. * Gets or sets the light associated with this block
  64198. */
  64199. light: Nullable<Light>;
  64200. /**
  64201. * Create a new LightBlock
  64202. * @param name defines the block name
  64203. */
  64204. constructor(name: string);
  64205. /**
  64206. * Gets the current class name
  64207. * @returns the class name
  64208. */
  64209. getClassName(): string;
  64210. /**
  64211. * Gets the world position input component
  64212. */
  64213. get worldPosition(): NodeMaterialConnectionPoint;
  64214. /**
  64215. * Gets the world normal input component
  64216. */
  64217. get worldNormal(): NodeMaterialConnectionPoint;
  64218. /**
  64219. * Gets the camera (or eye) position component
  64220. */
  64221. get cameraPosition(): NodeMaterialConnectionPoint;
  64222. /**
  64223. * Gets the glossiness component
  64224. */
  64225. get glossiness(): NodeMaterialConnectionPoint;
  64226. /**
  64227. * Gets the glossinness power component
  64228. */
  64229. get glossPower(): NodeMaterialConnectionPoint;
  64230. /**
  64231. * Gets the diffuse color component
  64232. */
  64233. get diffuseColor(): NodeMaterialConnectionPoint;
  64234. /**
  64235. * Gets the specular color component
  64236. */
  64237. get specularColor(): NodeMaterialConnectionPoint;
  64238. /**
  64239. * Gets the view matrix component
  64240. */
  64241. get view(): NodeMaterialConnectionPoint;
  64242. /**
  64243. * Gets the diffuse output component
  64244. */
  64245. get diffuseOutput(): NodeMaterialConnectionPoint;
  64246. /**
  64247. * Gets the specular output component
  64248. */
  64249. get specularOutput(): NodeMaterialConnectionPoint;
  64250. /**
  64251. * Gets the shadow output component
  64252. */
  64253. get shadow(): NodeMaterialConnectionPoint;
  64254. autoConfigure(material: NodeMaterial): void;
  64255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64256. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64257. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64258. private _injectVertexCode;
  64259. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64260. serialize(): any;
  64261. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64262. }
  64263. }
  64264. declare module BABYLON {
  64265. /**
  64266. * Block used to read a reflection texture from a sampler
  64267. */
  64268. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64269. /**
  64270. * Create a new ReflectionTextureBlock
  64271. * @param name defines the block name
  64272. */
  64273. constructor(name: string);
  64274. /**
  64275. * Gets the current class name
  64276. * @returns the class name
  64277. */
  64278. getClassName(): string;
  64279. /**
  64280. * Gets the world position input component
  64281. */
  64282. get position(): NodeMaterialConnectionPoint;
  64283. /**
  64284. * Gets the world position input component
  64285. */
  64286. get worldPosition(): NodeMaterialConnectionPoint;
  64287. /**
  64288. * Gets the world normal input component
  64289. */
  64290. get worldNormal(): NodeMaterialConnectionPoint;
  64291. /**
  64292. * Gets the world input component
  64293. */
  64294. get world(): NodeMaterialConnectionPoint;
  64295. /**
  64296. * Gets the camera (or eye) position component
  64297. */
  64298. get cameraPosition(): NodeMaterialConnectionPoint;
  64299. /**
  64300. * Gets the view input component
  64301. */
  64302. get view(): NodeMaterialConnectionPoint;
  64303. /**
  64304. * Gets the rgb output component
  64305. */
  64306. get rgb(): NodeMaterialConnectionPoint;
  64307. /**
  64308. * Gets the rgba output component
  64309. */
  64310. get rgba(): NodeMaterialConnectionPoint;
  64311. /**
  64312. * Gets the r output component
  64313. */
  64314. get r(): NodeMaterialConnectionPoint;
  64315. /**
  64316. * Gets the g output component
  64317. */
  64318. get g(): NodeMaterialConnectionPoint;
  64319. /**
  64320. * Gets the b output component
  64321. */
  64322. get b(): NodeMaterialConnectionPoint;
  64323. /**
  64324. * Gets the a output component
  64325. */
  64326. get a(): NodeMaterialConnectionPoint;
  64327. autoConfigure(material: NodeMaterial): void;
  64328. protected _buildBlock(state: NodeMaterialBuildState): this;
  64329. }
  64330. }
  64331. declare module BABYLON {
  64332. /**
  64333. * Block used to add 2 vectors
  64334. */
  64335. export class AddBlock extends NodeMaterialBlock {
  64336. /**
  64337. * Creates a new AddBlock
  64338. * @param name defines the block name
  64339. */
  64340. constructor(name: string);
  64341. /**
  64342. * Gets the current class name
  64343. * @returns the class name
  64344. */
  64345. getClassName(): string;
  64346. /**
  64347. * Gets the left operand input component
  64348. */
  64349. get left(): NodeMaterialConnectionPoint;
  64350. /**
  64351. * Gets the right operand input component
  64352. */
  64353. get right(): NodeMaterialConnectionPoint;
  64354. /**
  64355. * Gets the output component
  64356. */
  64357. get output(): NodeMaterialConnectionPoint;
  64358. protected _buildBlock(state: NodeMaterialBuildState): this;
  64359. }
  64360. }
  64361. declare module BABYLON {
  64362. /**
  64363. * Block used to scale a vector by a float
  64364. */
  64365. export class ScaleBlock extends NodeMaterialBlock {
  64366. /**
  64367. * Creates a new ScaleBlock
  64368. * @param name defines the block name
  64369. */
  64370. constructor(name: string);
  64371. /**
  64372. * Gets the current class name
  64373. * @returns the class name
  64374. */
  64375. getClassName(): string;
  64376. /**
  64377. * Gets the input component
  64378. */
  64379. get input(): NodeMaterialConnectionPoint;
  64380. /**
  64381. * Gets the factor input component
  64382. */
  64383. get factor(): NodeMaterialConnectionPoint;
  64384. /**
  64385. * Gets the output component
  64386. */
  64387. get output(): NodeMaterialConnectionPoint;
  64388. protected _buildBlock(state: NodeMaterialBuildState): this;
  64389. }
  64390. }
  64391. declare module BABYLON {
  64392. /**
  64393. * Block used to clamp a float
  64394. */
  64395. export class ClampBlock extends NodeMaterialBlock {
  64396. /** Gets or sets the minimum range */
  64397. minimum: number;
  64398. /** Gets or sets the maximum range */
  64399. maximum: number;
  64400. /**
  64401. * Creates a new ClampBlock
  64402. * @param name defines the block name
  64403. */
  64404. constructor(name: string);
  64405. /**
  64406. * Gets the current class name
  64407. * @returns the class name
  64408. */
  64409. getClassName(): string;
  64410. /**
  64411. * Gets the value input component
  64412. */
  64413. get value(): NodeMaterialConnectionPoint;
  64414. /**
  64415. * Gets the output component
  64416. */
  64417. get output(): NodeMaterialConnectionPoint;
  64418. protected _buildBlock(state: NodeMaterialBuildState): this;
  64419. protected _dumpPropertiesCode(): string;
  64420. serialize(): any;
  64421. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64422. }
  64423. }
  64424. declare module BABYLON {
  64425. /**
  64426. * Block used to apply a cross product between 2 vectors
  64427. */
  64428. export class CrossBlock extends NodeMaterialBlock {
  64429. /**
  64430. * Creates a new CrossBlock
  64431. * @param name defines the block name
  64432. */
  64433. constructor(name: string);
  64434. /**
  64435. * Gets the current class name
  64436. * @returns the class name
  64437. */
  64438. getClassName(): string;
  64439. /**
  64440. * Gets the left operand input component
  64441. */
  64442. get left(): NodeMaterialConnectionPoint;
  64443. /**
  64444. * Gets the right operand input component
  64445. */
  64446. get right(): NodeMaterialConnectionPoint;
  64447. /**
  64448. * Gets the output component
  64449. */
  64450. get output(): NodeMaterialConnectionPoint;
  64451. protected _buildBlock(state: NodeMaterialBuildState): this;
  64452. }
  64453. }
  64454. declare module BABYLON {
  64455. /**
  64456. * Block used to apply a dot product between 2 vectors
  64457. */
  64458. export class DotBlock extends NodeMaterialBlock {
  64459. /**
  64460. * Creates a new DotBlock
  64461. * @param name defines the block name
  64462. */
  64463. constructor(name: string);
  64464. /**
  64465. * Gets the current class name
  64466. * @returns the class name
  64467. */
  64468. getClassName(): string;
  64469. /**
  64470. * Gets the left operand input component
  64471. */
  64472. get left(): NodeMaterialConnectionPoint;
  64473. /**
  64474. * Gets the right operand input component
  64475. */
  64476. get right(): NodeMaterialConnectionPoint;
  64477. /**
  64478. * Gets the output component
  64479. */
  64480. get output(): NodeMaterialConnectionPoint;
  64481. protected _buildBlock(state: NodeMaterialBuildState): this;
  64482. }
  64483. }
  64484. declare module BABYLON {
  64485. /**
  64486. * Block used to normalize a vector
  64487. */
  64488. export class NormalizeBlock extends NodeMaterialBlock {
  64489. /**
  64490. * Creates a new NormalizeBlock
  64491. * @param name defines the block name
  64492. */
  64493. constructor(name: string);
  64494. /**
  64495. * Gets the current class name
  64496. * @returns the class name
  64497. */
  64498. getClassName(): string;
  64499. /**
  64500. * Gets the input component
  64501. */
  64502. get input(): NodeMaterialConnectionPoint;
  64503. /**
  64504. * Gets the output component
  64505. */
  64506. get output(): NodeMaterialConnectionPoint;
  64507. protected _buildBlock(state: NodeMaterialBuildState): this;
  64508. }
  64509. }
  64510. declare module BABYLON {
  64511. /**
  64512. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64513. */
  64514. export class ColorMergerBlock extends NodeMaterialBlock {
  64515. /**
  64516. * Create a new ColorMergerBlock
  64517. * @param name defines the block name
  64518. */
  64519. constructor(name: string);
  64520. /**
  64521. * Gets the current class name
  64522. * @returns the class name
  64523. */
  64524. getClassName(): string;
  64525. /**
  64526. * Gets the rgb component (input)
  64527. */
  64528. get rgbIn(): NodeMaterialConnectionPoint;
  64529. /**
  64530. * Gets the r component (input)
  64531. */
  64532. get r(): NodeMaterialConnectionPoint;
  64533. /**
  64534. * Gets the g component (input)
  64535. */
  64536. get g(): NodeMaterialConnectionPoint;
  64537. /**
  64538. * Gets the b component (input)
  64539. */
  64540. get b(): NodeMaterialConnectionPoint;
  64541. /**
  64542. * Gets the a component (input)
  64543. */
  64544. get a(): NodeMaterialConnectionPoint;
  64545. /**
  64546. * Gets the rgba component (output)
  64547. */
  64548. get rgba(): NodeMaterialConnectionPoint;
  64549. /**
  64550. * Gets the rgb component (output)
  64551. */
  64552. get rgbOut(): NodeMaterialConnectionPoint;
  64553. /**
  64554. * Gets the rgb component (output)
  64555. * @deprecated Please use rgbOut instead.
  64556. */
  64557. get rgb(): NodeMaterialConnectionPoint;
  64558. protected _buildBlock(state: NodeMaterialBuildState): this;
  64559. }
  64560. }
  64561. declare module BABYLON {
  64562. /**
  64563. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64564. */
  64565. export class VectorSplitterBlock extends NodeMaterialBlock {
  64566. /**
  64567. * Create a new VectorSplitterBlock
  64568. * @param name defines the block name
  64569. */
  64570. constructor(name: string);
  64571. /**
  64572. * Gets the current class name
  64573. * @returns the class name
  64574. */
  64575. getClassName(): string;
  64576. /**
  64577. * Gets the xyzw component (input)
  64578. */
  64579. get xyzw(): NodeMaterialConnectionPoint;
  64580. /**
  64581. * Gets the xyz component (input)
  64582. */
  64583. get xyzIn(): NodeMaterialConnectionPoint;
  64584. /**
  64585. * Gets the xy component (input)
  64586. */
  64587. get xyIn(): NodeMaterialConnectionPoint;
  64588. /**
  64589. * Gets the xyz component (output)
  64590. */
  64591. get xyzOut(): NodeMaterialConnectionPoint;
  64592. /**
  64593. * Gets the xy component (output)
  64594. */
  64595. get xyOut(): NodeMaterialConnectionPoint;
  64596. /**
  64597. * Gets the x component (output)
  64598. */
  64599. get x(): NodeMaterialConnectionPoint;
  64600. /**
  64601. * Gets the y component (output)
  64602. */
  64603. get y(): NodeMaterialConnectionPoint;
  64604. /**
  64605. * Gets the z component (output)
  64606. */
  64607. get z(): NodeMaterialConnectionPoint;
  64608. /**
  64609. * Gets the w component (output)
  64610. */
  64611. get w(): NodeMaterialConnectionPoint;
  64612. protected _inputRename(name: string): string;
  64613. protected _outputRename(name: string): string;
  64614. protected _buildBlock(state: NodeMaterialBuildState): this;
  64615. }
  64616. }
  64617. declare module BABYLON {
  64618. /**
  64619. * Block used to lerp between 2 values
  64620. */
  64621. export class LerpBlock extends NodeMaterialBlock {
  64622. /**
  64623. * Creates a new LerpBlock
  64624. * @param name defines the block name
  64625. */
  64626. constructor(name: string);
  64627. /**
  64628. * Gets the current class name
  64629. * @returns the class name
  64630. */
  64631. getClassName(): string;
  64632. /**
  64633. * Gets the left operand input component
  64634. */
  64635. get left(): NodeMaterialConnectionPoint;
  64636. /**
  64637. * Gets the right operand input component
  64638. */
  64639. get right(): NodeMaterialConnectionPoint;
  64640. /**
  64641. * Gets the gradient operand input component
  64642. */
  64643. get gradient(): NodeMaterialConnectionPoint;
  64644. /**
  64645. * Gets the output component
  64646. */
  64647. get output(): NodeMaterialConnectionPoint;
  64648. protected _buildBlock(state: NodeMaterialBuildState): this;
  64649. }
  64650. }
  64651. declare module BABYLON {
  64652. /**
  64653. * Block used to divide 2 vectors
  64654. */
  64655. export class DivideBlock extends NodeMaterialBlock {
  64656. /**
  64657. * Creates a new DivideBlock
  64658. * @param name defines the block name
  64659. */
  64660. constructor(name: string);
  64661. /**
  64662. * Gets the current class name
  64663. * @returns the class name
  64664. */
  64665. getClassName(): string;
  64666. /**
  64667. * Gets the left operand input component
  64668. */
  64669. get left(): NodeMaterialConnectionPoint;
  64670. /**
  64671. * Gets the right operand input component
  64672. */
  64673. get right(): NodeMaterialConnectionPoint;
  64674. /**
  64675. * Gets the output component
  64676. */
  64677. get output(): NodeMaterialConnectionPoint;
  64678. protected _buildBlock(state: NodeMaterialBuildState): this;
  64679. }
  64680. }
  64681. declare module BABYLON {
  64682. /**
  64683. * Block used to subtract 2 vectors
  64684. */
  64685. export class SubtractBlock extends NodeMaterialBlock {
  64686. /**
  64687. * Creates a new SubtractBlock
  64688. * @param name defines the block name
  64689. */
  64690. constructor(name: string);
  64691. /**
  64692. * Gets the current class name
  64693. * @returns the class name
  64694. */
  64695. getClassName(): string;
  64696. /**
  64697. * Gets the left operand input component
  64698. */
  64699. get left(): NodeMaterialConnectionPoint;
  64700. /**
  64701. * Gets the right operand input component
  64702. */
  64703. get right(): NodeMaterialConnectionPoint;
  64704. /**
  64705. * Gets the output component
  64706. */
  64707. get output(): NodeMaterialConnectionPoint;
  64708. protected _buildBlock(state: NodeMaterialBuildState): this;
  64709. }
  64710. }
  64711. declare module BABYLON {
  64712. /**
  64713. * Block used to step a value
  64714. */
  64715. export class StepBlock extends NodeMaterialBlock {
  64716. /**
  64717. * Creates a new StepBlock
  64718. * @param name defines the block name
  64719. */
  64720. constructor(name: string);
  64721. /**
  64722. * Gets the current class name
  64723. * @returns the class name
  64724. */
  64725. getClassName(): string;
  64726. /**
  64727. * Gets the value operand input component
  64728. */
  64729. get value(): NodeMaterialConnectionPoint;
  64730. /**
  64731. * Gets the edge operand input component
  64732. */
  64733. get edge(): NodeMaterialConnectionPoint;
  64734. /**
  64735. * Gets the output component
  64736. */
  64737. get output(): NodeMaterialConnectionPoint;
  64738. protected _buildBlock(state: NodeMaterialBuildState): this;
  64739. }
  64740. }
  64741. declare module BABYLON {
  64742. /**
  64743. * Block used to get the opposite (1 - x) of a value
  64744. */
  64745. export class OneMinusBlock extends NodeMaterialBlock {
  64746. /**
  64747. * Creates a new OneMinusBlock
  64748. * @param name defines the block name
  64749. */
  64750. constructor(name: string);
  64751. /**
  64752. * Gets the current class name
  64753. * @returns the class name
  64754. */
  64755. getClassName(): string;
  64756. /**
  64757. * Gets the input component
  64758. */
  64759. get input(): NodeMaterialConnectionPoint;
  64760. /**
  64761. * Gets the output component
  64762. */
  64763. get output(): NodeMaterialConnectionPoint;
  64764. protected _buildBlock(state: NodeMaterialBuildState): this;
  64765. }
  64766. }
  64767. declare module BABYLON {
  64768. /**
  64769. * Block used to get the view direction
  64770. */
  64771. export class ViewDirectionBlock extends NodeMaterialBlock {
  64772. /**
  64773. * Creates a new ViewDirectionBlock
  64774. * @param name defines the block name
  64775. */
  64776. constructor(name: string);
  64777. /**
  64778. * Gets the current class name
  64779. * @returns the class name
  64780. */
  64781. getClassName(): string;
  64782. /**
  64783. * Gets the world position component
  64784. */
  64785. get worldPosition(): NodeMaterialConnectionPoint;
  64786. /**
  64787. * Gets the camera position component
  64788. */
  64789. get cameraPosition(): NodeMaterialConnectionPoint;
  64790. /**
  64791. * Gets the output component
  64792. */
  64793. get output(): NodeMaterialConnectionPoint;
  64794. autoConfigure(material: NodeMaterial): void;
  64795. protected _buildBlock(state: NodeMaterialBuildState): this;
  64796. }
  64797. }
  64798. declare module BABYLON {
  64799. /**
  64800. * Block used to compute fresnel value
  64801. */
  64802. export class FresnelBlock extends NodeMaterialBlock {
  64803. /**
  64804. * Create a new FresnelBlock
  64805. * @param name defines the block name
  64806. */
  64807. constructor(name: string);
  64808. /**
  64809. * Gets the current class name
  64810. * @returns the class name
  64811. */
  64812. getClassName(): string;
  64813. /**
  64814. * Gets the world normal input component
  64815. */
  64816. get worldNormal(): NodeMaterialConnectionPoint;
  64817. /**
  64818. * Gets the view direction input component
  64819. */
  64820. get viewDirection(): NodeMaterialConnectionPoint;
  64821. /**
  64822. * Gets the bias input component
  64823. */
  64824. get bias(): NodeMaterialConnectionPoint;
  64825. /**
  64826. * Gets the camera (or eye) position component
  64827. */
  64828. get power(): NodeMaterialConnectionPoint;
  64829. /**
  64830. * Gets the fresnel output component
  64831. */
  64832. get fresnel(): NodeMaterialConnectionPoint;
  64833. autoConfigure(material: NodeMaterial): void;
  64834. protected _buildBlock(state: NodeMaterialBuildState): this;
  64835. }
  64836. }
  64837. declare module BABYLON {
  64838. /**
  64839. * Block used to get the max of 2 values
  64840. */
  64841. export class MaxBlock extends NodeMaterialBlock {
  64842. /**
  64843. * Creates a new MaxBlock
  64844. * @param name defines the block name
  64845. */
  64846. constructor(name: string);
  64847. /**
  64848. * Gets the current class name
  64849. * @returns the class name
  64850. */
  64851. getClassName(): string;
  64852. /**
  64853. * Gets the left operand input component
  64854. */
  64855. get left(): NodeMaterialConnectionPoint;
  64856. /**
  64857. * Gets the right operand input component
  64858. */
  64859. get right(): NodeMaterialConnectionPoint;
  64860. /**
  64861. * Gets the output component
  64862. */
  64863. get output(): NodeMaterialConnectionPoint;
  64864. protected _buildBlock(state: NodeMaterialBuildState): this;
  64865. }
  64866. }
  64867. declare module BABYLON {
  64868. /**
  64869. * Block used to get the min of 2 values
  64870. */
  64871. export class MinBlock extends NodeMaterialBlock {
  64872. /**
  64873. * Creates a new MinBlock
  64874. * @param name defines the block name
  64875. */
  64876. constructor(name: string);
  64877. /**
  64878. * Gets the current class name
  64879. * @returns the class name
  64880. */
  64881. getClassName(): string;
  64882. /**
  64883. * Gets the left operand input component
  64884. */
  64885. get left(): NodeMaterialConnectionPoint;
  64886. /**
  64887. * Gets the right operand input component
  64888. */
  64889. get right(): NodeMaterialConnectionPoint;
  64890. /**
  64891. * Gets the output component
  64892. */
  64893. get output(): NodeMaterialConnectionPoint;
  64894. protected _buildBlock(state: NodeMaterialBuildState): this;
  64895. }
  64896. }
  64897. declare module BABYLON {
  64898. /**
  64899. * Block used to get the distance between 2 values
  64900. */
  64901. export class DistanceBlock extends NodeMaterialBlock {
  64902. /**
  64903. * Creates a new DistanceBlock
  64904. * @param name defines the block name
  64905. */
  64906. constructor(name: string);
  64907. /**
  64908. * Gets the current class name
  64909. * @returns the class name
  64910. */
  64911. getClassName(): string;
  64912. /**
  64913. * Gets the left operand input component
  64914. */
  64915. get left(): NodeMaterialConnectionPoint;
  64916. /**
  64917. * Gets the right operand input component
  64918. */
  64919. get right(): NodeMaterialConnectionPoint;
  64920. /**
  64921. * Gets the output component
  64922. */
  64923. get output(): NodeMaterialConnectionPoint;
  64924. protected _buildBlock(state: NodeMaterialBuildState): this;
  64925. }
  64926. }
  64927. declare module BABYLON {
  64928. /**
  64929. * Block used to get the length of a vector
  64930. */
  64931. export class LengthBlock extends NodeMaterialBlock {
  64932. /**
  64933. * Creates a new LengthBlock
  64934. * @param name defines the block name
  64935. */
  64936. constructor(name: string);
  64937. /**
  64938. * Gets the current class name
  64939. * @returns the class name
  64940. */
  64941. getClassName(): string;
  64942. /**
  64943. * Gets the value input component
  64944. */
  64945. get value(): NodeMaterialConnectionPoint;
  64946. /**
  64947. * Gets the output component
  64948. */
  64949. get output(): NodeMaterialConnectionPoint;
  64950. protected _buildBlock(state: NodeMaterialBuildState): this;
  64951. }
  64952. }
  64953. declare module BABYLON {
  64954. /**
  64955. * Block used to get negative version of a value (i.e. x * -1)
  64956. */
  64957. export class NegateBlock extends NodeMaterialBlock {
  64958. /**
  64959. * Creates a new NegateBlock
  64960. * @param name defines the block name
  64961. */
  64962. constructor(name: string);
  64963. /**
  64964. * Gets the current class name
  64965. * @returns the class name
  64966. */
  64967. getClassName(): string;
  64968. /**
  64969. * Gets the value input component
  64970. */
  64971. get value(): NodeMaterialConnectionPoint;
  64972. /**
  64973. * Gets the output component
  64974. */
  64975. get output(): NodeMaterialConnectionPoint;
  64976. protected _buildBlock(state: NodeMaterialBuildState): this;
  64977. }
  64978. }
  64979. declare module BABYLON {
  64980. /**
  64981. * Block used to get the value of the first parameter raised to the power of the second
  64982. */
  64983. export class PowBlock extends NodeMaterialBlock {
  64984. /**
  64985. * Creates a new PowBlock
  64986. * @param name defines the block name
  64987. */
  64988. constructor(name: string);
  64989. /**
  64990. * Gets the current class name
  64991. * @returns the class name
  64992. */
  64993. getClassName(): string;
  64994. /**
  64995. * Gets the value operand input component
  64996. */
  64997. get value(): NodeMaterialConnectionPoint;
  64998. /**
  64999. * Gets the power operand input component
  65000. */
  65001. get power(): NodeMaterialConnectionPoint;
  65002. /**
  65003. * Gets the output component
  65004. */
  65005. get output(): NodeMaterialConnectionPoint;
  65006. protected _buildBlock(state: NodeMaterialBuildState): this;
  65007. }
  65008. }
  65009. declare module BABYLON {
  65010. /**
  65011. * Block used to get a random number
  65012. */
  65013. export class RandomNumberBlock extends NodeMaterialBlock {
  65014. /**
  65015. * Creates a new RandomNumberBlock
  65016. * @param name defines the block name
  65017. */
  65018. constructor(name: string);
  65019. /**
  65020. * Gets the current class name
  65021. * @returns the class name
  65022. */
  65023. getClassName(): string;
  65024. /**
  65025. * Gets the seed input component
  65026. */
  65027. get seed(): NodeMaterialConnectionPoint;
  65028. /**
  65029. * Gets the output component
  65030. */
  65031. get output(): NodeMaterialConnectionPoint;
  65032. protected _buildBlock(state: NodeMaterialBuildState): this;
  65033. }
  65034. }
  65035. declare module BABYLON {
  65036. /**
  65037. * Block used to compute arc tangent of 2 values
  65038. */
  65039. export class ArcTan2Block extends NodeMaterialBlock {
  65040. /**
  65041. * Creates a new ArcTan2Block
  65042. * @param name defines the block name
  65043. */
  65044. constructor(name: string);
  65045. /**
  65046. * Gets the current class name
  65047. * @returns the class name
  65048. */
  65049. getClassName(): string;
  65050. /**
  65051. * Gets the x operand input component
  65052. */
  65053. get x(): NodeMaterialConnectionPoint;
  65054. /**
  65055. * Gets the y operand input component
  65056. */
  65057. get y(): NodeMaterialConnectionPoint;
  65058. /**
  65059. * Gets the output component
  65060. */
  65061. get output(): NodeMaterialConnectionPoint;
  65062. protected _buildBlock(state: NodeMaterialBuildState): this;
  65063. }
  65064. }
  65065. declare module BABYLON {
  65066. /**
  65067. * Block used to smooth step a value
  65068. */
  65069. export class SmoothStepBlock extends NodeMaterialBlock {
  65070. /**
  65071. * Creates a new SmoothStepBlock
  65072. * @param name defines the block name
  65073. */
  65074. constructor(name: string);
  65075. /**
  65076. * Gets the current class name
  65077. * @returns the class name
  65078. */
  65079. getClassName(): string;
  65080. /**
  65081. * Gets the value operand input component
  65082. */
  65083. get value(): NodeMaterialConnectionPoint;
  65084. /**
  65085. * Gets the first edge operand input component
  65086. */
  65087. get edge0(): NodeMaterialConnectionPoint;
  65088. /**
  65089. * Gets the second edge operand input component
  65090. */
  65091. get edge1(): NodeMaterialConnectionPoint;
  65092. /**
  65093. * Gets the output component
  65094. */
  65095. get output(): NodeMaterialConnectionPoint;
  65096. protected _buildBlock(state: NodeMaterialBuildState): this;
  65097. }
  65098. }
  65099. declare module BABYLON {
  65100. /**
  65101. * Block used to get the reciprocal (1 / x) of a value
  65102. */
  65103. export class ReciprocalBlock extends NodeMaterialBlock {
  65104. /**
  65105. * Creates a new ReciprocalBlock
  65106. * @param name defines the block name
  65107. */
  65108. constructor(name: string);
  65109. /**
  65110. * Gets the current class name
  65111. * @returns the class name
  65112. */
  65113. getClassName(): string;
  65114. /**
  65115. * Gets the input component
  65116. */
  65117. get input(): NodeMaterialConnectionPoint;
  65118. /**
  65119. * Gets the output component
  65120. */
  65121. get output(): NodeMaterialConnectionPoint;
  65122. protected _buildBlock(state: NodeMaterialBuildState): this;
  65123. }
  65124. }
  65125. declare module BABYLON {
  65126. /**
  65127. * Block used to replace a color by another one
  65128. */
  65129. export class ReplaceColorBlock extends NodeMaterialBlock {
  65130. /**
  65131. * Creates a new ReplaceColorBlock
  65132. * @param name defines the block name
  65133. */
  65134. constructor(name: string);
  65135. /**
  65136. * Gets the current class name
  65137. * @returns the class name
  65138. */
  65139. getClassName(): string;
  65140. /**
  65141. * Gets the value input component
  65142. */
  65143. get value(): NodeMaterialConnectionPoint;
  65144. /**
  65145. * Gets the reference input component
  65146. */
  65147. get reference(): NodeMaterialConnectionPoint;
  65148. /**
  65149. * Gets the distance input component
  65150. */
  65151. get distance(): NodeMaterialConnectionPoint;
  65152. /**
  65153. * Gets the replacement input component
  65154. */
  65155. get replacement(): NodeMaterialConnectionPoint;
  65156. /**
  65157. * Gets the output component
  65158. */
  65159. get output(): NodeMaterialConnectionPoint;
  65160. protected _buildBlock(state: NodeMaterialBuildState): this;
  65161. }
  65162. }
  65163. declare module BABYLON {
  65164. /**
  65165. * Block used to posterize a value
  65166. * @see https://en.wikipedia.org/wiki/Posterization
  65167. */
  65168. export class PosterizeBlock extends NodeMaterialBlock {
  65169. /**
  65170. * Creates a new PosterizeBlock
  65171. * @param name defines the block name
  65172. */
  65173. constructor(name: string);
  65174. /**
  65175. * Gets the current class name
  65176. * @returns the class name
  65177. */
  65178. getClassName(): string;
  65179. /**
  65180. * Gets the value input component
  65181. */
  65182. get value(): NodeMaterialConnectionPoint;
  65183. /**
  65184. * Gets the steps input component
  65185. */
  65186. get steps(): NodeMaterialConnectionPoint;
  65187. /**
  65188. * Gets the output component
  65189. */
  65190. get output(): NodeMaterialConnectionPoint;
  65191. protected _buildBlock(state: NodeMaterialBuildState): this;
  65192. }
  65193. }
  65194. declare module BABYLON {
  65195. /**
  65196. * Operations supported by the Wave block
  65197. */
  65198. export enum WaveBlockKind {
  65199. /** SawTooth */
  65200. SawTooth = 0,
  65201. /** Square */
  65202. Square = 1,
  65203. /** Triangle */
  65204. Triangle = 2
  65205. }
  65206. /**
  65207. * Block used to apply wave operation to floats
  65208. */
  65209. export class WaveBlock extends NodeMaterialBlock {
  65210. /**
  65211. * Gets or sets the kibnd of wave to be applied by the block
  65212. */
  65213. kind: WaveBlockKind;
  65214. /**
  65215. * Creates a new WaveBlock
  65216. * @param name defines the block name
  65217. */
  65218. constructor(name: string);
  65219. /**
  65220. * Gets the current class name
  65221. * @returns the class name
  65222. */
  65223. getClassName(): string;
  65224. /**
  65225. * Gets the input component
  65226. */
  65227. get input(): NodeMaterialConnectionPoint;
  65228. /**
  65229. * Gets the output component
  65230. */
  65231. get output(): NodeMaterialConnectionPoint;
  65232. protected _buildBlock(state: NodeMaterialBuildState): this;
  65233. serialize(): any;
  65234. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65235. }
  65236. }
  65237. declare module BABYLON {
  65238. /**
  65239. * Class used to store a color step for the GradientBlock
  65240. */
  65241. export class GradientBlockColorStep {
  65242. private _step;
  65243. /**
  65244. * Gets value indicating which step this color is associated with (between 0 and 1)
  65245. */
  65246. get step(): number;
  65247. /**
  65248. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65249. */
  65250. set step(val: number);
  65251. private _color;
  65252. /**
  65253. * Gets the color associated with this step
  65254. */
  65255. get color(): Color3;
  65256. /**
  65257. * Sets the color associated with this step
  65258. */
  65259. set color(val: Color3);
  65260. /**
  65261. * Creates a new GradientBlockColorStep
  65262. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65263. * @param color defines the color associated with this step
  65264. */
  65265. constructor(step: number, color: Color3);
  65266. }
  65267. /**
  65268. * Block used to return a color from a gradient based on an input value between 0 and 1
  65269. */
  65270. export class GradientBlock extends NodeMaterialBlock {
  65271. /**
  65272. * Gets or sets the list of color steps
  65273. */
  65274. colorSteps: GradientBlockColorStep[];
  65275. /** Gets an observable raised when the value is changed */
  65276. onValueChangedObservable: Observable<GradientBlock>;
  65277. /** calls observable when the value is changed*/
  65278. colorStepsUpdated(): void;
  65279. /**
  65280. * Creates a new GradientBlock
  65281. * @param name defines the block name
  65282. */
  65283. constructor(name: string);
  65284. /**
  65285. * Gets the current class name
  65286. * @returns the class name
  65287. */
  65288. getClassName(): string;
  65289. /**
  65290. * Gets the gradient input component
  65291. */
  65292. get gradient(): NodeMaterialConnectionPoint;
  65293. /**
  65294. * Gets the output component
  65295. */
  65296. get output(): NodeMaterialConnectionPoint;
  65297. private _writeColorConstant;
  65298. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65299. serialize(): any;
  65300. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65301. protected _dumpPropertiesCode(): string;
  65302. }
  65303. }
  65304. declare module BABYLON {
  65305. /**
  65306. * Block used to normalize lerp between 2 values
  65307. */
  65308. export class NLerpBlock extends NodeMaterialBlock {
  65309. /**
  65310. * Creates a new NLerpBlock
  65311. * @param name defines the block name
  65312. */
  65313. constructor(name: string);
  65314. /**
  65315. * Gets the current class name
  65316. * @returns the class name
  65317. */
  65318. getClassName(): string;
  65319. /**
  65320. * Gets the left operand input component
  65321. */
  65322. get left(): NodeMaterialConnectionPoint;
  65323. /**
  65324. * Gets the right operand input component
  65325. */
  65326. get right(): NodeMaterialConnectionPoint;
  65327. /**
  65328. * Gets the gradient operand input component
  65329. */
  65330. get gradient(): NodeMaterialConnectionPoint;
  65331. /**
  65332. * Gets the output component
  65333. */
  65334. get output(): NodeMaterialConnectionPoint;
  65335. protected _buildBlock(state: NodeMaterialBuildState): this;
  65336. }
  65337. }
  65338. declare module BABYLON {
  65339. /**
  65340. * block used to Generate a Worley Noise 3D Noise Pattern
  65341. */
  65342. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65343. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65344. manhattanDistance: boolean;
  65345. /**
  65346. * Creates a new WorleyNoise3DBlock
  65347. * @param name defines the block name
  65348. */
  65349. constructor(name: string);
  65350. /**
  65351. * Gets the current class name
  65352. * @returns the class name
  65353. */
  65354. getClassName(): string;
  65355. /**
  65356. * Gets the seed input component
  65357. */
  65358. get seed(): NodeMaterialConnectionPoint;
  65359. /**
  65360. * Gets the jitter input component
  65361. */
  65362. get jitter(): NodeMaterialConnectionPoint;
  65363. /**
  65364. * Gets the output component
  65365. */
  65366. get output(): NodeMaterialConnectionPoint;
  65367. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65368. /**
  65369. * Exposes the properties to the UI?
  65370. */
  65371. protected _dumpPropertiesCode(): string;
  65372. /**
  65373. * Exposes the properties to the Seralize?
  65374. */
  65375. serialize(): any;
  65376. /**
  65377. * Exposes the properties to the deseralize?
  65378. */
  65379. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65380. }
  65381. }
  65382. declare module BABYLON {
  65383. /**
  65384. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65385. */
  65386. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65387. /**
  65388. * Creates a new SimplexPerlin3DBlock
  65389. * @param name defines the block name
  65390. */
  65391. constructor(name: string);
  65392. /**
  65393. * Gets the current class name
  65394. * @returns the class name
  65395. */
  65396. getClassName(): string;
  65397. /**
  65398. * Gets the seed operand input component
  65399. */
  65400. get seed(): NodeMaterialConnectionPoint;
  65401. /**
  65402. * Gets the output component
  65403. */
  65404. get output(): NodeMaterialConnectionPoint;
  65405. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65406. }
  65407. }
  65408. declare module BABYLON {
  65409. /**
  65410. * Block used to blend normals
  65411. */
  65412. export class NormalBlendBlock extends NodeMaterialBlock {
  65413. /**
  65414. * Creates a new NormalBlendBlock
  65415. * @param name defines the block name
  65416. */
  65417. constructor(name: string);
  65418. /**
  65419. * Gets the current class name
  65420. * @returns the class name
  65421. */
  65422. getClassName(): string;
  65423. /**
  65424. * Gets the first input component
  65425. */
  65426. get normalMap0(): NodeMaterialConnectionPoint;
  65427. /**
  65428. * Gets the second input component
  65429. */
  65430. get normalMap1(): NodeMaterialConnectionPoint;
  65431. /**
  65432. * Gets the output component
  65433. */
  65434. get output(): NodeMaterialConnectionPoint;
  65435. protected _buildBlock(state: NodeMaterialBuildState): this;
  65436. }
  65437. }
  65438. declare module BABYLON {
  65439. /**
  65440. * Block used to rotate a 2d vector by a given angle
  65441. */
  65442. export class Rotate2dBlock extends NodeMaterialBlock {
  65443. /**
  65444. * Creates a new Rotate2dBlock
  65445. * @param name defines the block name
  65446. */
  65447. constructor(name: string);
  65448. /**
  65449. * Gets the current class name
  65450. * @returns the class name
  65451. */
  65452. getClassName(): string;
  65453. /**
  65454. * Gets the input vector
  65455. */
  65456. get input(): NodeMaterialConnectionPoint;
  65457. /**
  65458. * Gets the input angle
  65459. */
  65460. get angle(): NodeMaterialConnectionPoint;
  65461. /**
  65462. * Gets the output component
  65463. */
  65464. get output(): NodeMaterialConnectionPoint;
  65465. autoConfigure(material: NodeMaterial): void;
  65466. protected _buildBlock(state: NodeMaterialBuildState): this;
  65467. }
  65468. }
  65469. declare module BABYLON {
  65470. /**
  65471. * Block used to get the reflected vector from a direction and a normal
  65472. */
  65473. export class ReflectBlock extends NodeMaterialBlock {
  65474. /**
  65475. * Creates a new ReflectBlock
  65476. * @param name defines the block name
  65477. */
  65478. constructor(name: string);
  65479. /**
  65480. * Gets the current class name
  65481. * @returns the class name
  65482. */
  65483. getClassName(): string;
  65484. /**
  65485. * Gets the incident component
  65486. */
  65487. get incident(): NodeMaterialConnectionPoint;
  65488. /**
  65489. * Gets the normal component
  65490. */
  65491. get normal(): NodeMaterialConnectionPoint;
  65492. /**
  65493. * Gets the output component
  65494. */
  65495. get output(): NodeMaterialConnectionPoint;
  65496. protected _buildBlock(state: NodeMaterialBuildState): this;
  65497. }
  65498. }
  65499. declare module BABYLON {
  65500. /**
  65501. * Block used to get the refracted vector from a direction and a normal
  65502. */
  65503. export class RefractBlock extends NodeMaterialBlock {
  65504. /**
  65505. * Creates a new RefractBlock
  65506. * @param name defines the block name
  65507. */
  65508. constructor(name: string);
  65509. /**
  65510. * Gets the current class name
  65511. * @returns the class name
  65512. */
  65513. getClassName(): string;
  65514. /**
  65515. * Gets the incident component
  65516. */
  65517. get incident(): NodeMaterialConnectionPoint;
  65518. /**
  65519. * Gets the normal component
  65520. */
  65521. get normal(): NodeMaterialConnectionPoint;
  65522. /**
  65523. * Gets the index of refraction component
  65524. */
  65525. get ior(): NodeMaterialConnectionPoint;
  65526. /**
  65527. * Gets the output component
  65528. */
  65529. get output(): NodeMaterialConnectionPoint;
  65530. protected _buildBlock(state: NodeMaterialBuildState): this;
  65531. }
  65532. }
  65533. declare module BABYLON {
  65534. /**
  65535. * Block used to desaturate a color
  65536. */
  65537. export class DesaturateBlock extends NodeMaterialBlock {
  65538. /**
  65539. * Creates a new DesaturateBlock
  65540. * @param name defines the block name
  65541. */
  65542. constructor(name: string);
  65543. /**
  65544. * Gets the current class name
  65545. * @returns the class name
  65546. */
  65547. getClassName(): string;
  65548. /**
  65549. * Gets the color operand input component
  65550. */
  65551. get color(): NodeMaterialConnectionPoint;
  65552. /**
  65553. * Gets the level operand input component
  65554. */
  65555. get level(): NodeMaterialConnectionPoint;
  65556. /**
  65557. * Gets the output component
  65558. */
  65559. get output(): NodeMaterialConnectionPoint;
  65560. protected _buildBlock(state: NodeMaterialBuildState): this;
  65561. }
  65562. }
  65563. declare module BABYLON {
  65564. /**
  65565. * Block used to implement the reflection module of the PBR material
  65566. */
  65567. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65568. /** @hidden */
  65569. _defineLODReflectionAlpha: string;
  65570. /** @hidden */
  65571. _defineLinearSpecularReflection: string;
  65572. private _vEnvironmentIrradianceName;
  65573. /** @hidden */
  65574. _vReflectionMicrosurfaceInfosName: string;
  65575. /** @hidden */
  65576. _vReflectionInfosName: string;
  65577. /** @hidden */
  65578. _vReflectionFilteringInfoName: string;
  65579. private _scene;
  65580. /**
  65581. * The properties below are set by the main PBR block prior to calling methods of this class.
  65582. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65583. * It's less burden on the user side in the editor part.
  65584. */
  65585. /** @hidden */
  65586. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65587. /** @hidden */
  65588. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65589. /** @hidden */
  65590. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65591. /** @hidden */
  65592. viewConnectionPoint: NodeMaterialConnectionPoint;
  65593. /**
  65594. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65595. * diffuse part of the IBL.
  65596. */
  65597. useSphericalHarmonics: boolean;
  65598. /**
  65599. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65600. */
  65601. forceIrradianceInFragment: boolean;
  65602. /**
  65603. * Create a new ReflectionBlock
  65604. * @param name defines the block name
  65605. */
  65606. constructor(name: string);
  65607. /**
  65608. * Gets the current class name
  65609. * @returns the class name
  65610. */
  65611. getClassName(): string;
  65612. /**
  65613. * Gets the position input component
  65614. */
  65615. get position(): NodeMaterialConnectionPoint;
  65616. /**
  65617. * Gets the world position input component
  65618. */
  65619. get worldPosition(): NodeMaterialConnectionPoint;
  65620. /**
  65621. * Gets the world normal input component
  65622. */
  65623. get worldNormal(): NodeMaterialConnectionPoint;
  65624. /**
  65625. * Gets the world input component
  65626. */
  65627. get world(): NodeMaterialConnectionPoint;
  65628. /**
  65629. * Gets the camera (or eye) position component
  65630. */
  65631. get cameraPosition(): NodeMaterialConnectionPoint;
  65632. /**
  65633. * Gets the view input component
  65634. */
  65635. get view(): NodeMaterialConnectionPoint;
  65636. /**
  65637. * Gets the color input component
  65638. */
  65639. get color(): NodeMaterialConnectionPoint;
  65640. /**
  65641. * Gets the reflection object output component
  65642. */
  65643. get reflection(): NodeMaterialConnectionPoint;
  65644. /**
  65645. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65646. */
  65647. get hasTexture(): boolean;
  65648. /**
  65649. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65650. */
  65651. get reflectionColor(): string;
  65652. protected _getTexture(): Nullable<BaseTexture>;
  65653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65654. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65655. /**
  65656. * Gets the code to inject in the vertex shader
  65657. * @param state current state of the node material building
  65658. * @returns the shader code
  65659. */
  65660. handleVertexSide(state: NodeMaterialBuildState): string;
  65661. /**
  65662. * Gets the main code of the block (fragment side)
  65663. * @param state current state of the node material building
  65664. * @param normalVarName name of the existing variable corresponding to the normal
  65665. * @returns the shader code
  65666. */
  65667. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65668. protected _buildBlock(state: NodeMaterialBuildState): this;
  65669. protected _dumpPropertiesCode(): string;
  65670. serialize(): any;
  65671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65672. }
  65673. }
  65674. declare module BABYLON {
  65675. /**
  65676. * Block used to implement the sheen module of the PBR material
  65677. */
  65678. export class SheenBlock extends NodeMaterialBlock {
  65679. /**
  65680. * Create a new SheenBlock
  65681. * @param name defines the block name
  65682. */
  65683. constructor(name: string);
  65684. /**
  65685. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65686. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65687. * making it easier to setup and tweak the effect
  65688. */
  65689. albedoScaling: boolean;
  65690. /**
  65691. * Defines if the sheen is linked to the sheen color.
  65692. */
  65693. linkSheenWithAlbedo: boolean;
  65694. /**
  65695. * Initialize the block and prepare the context for build
  65696. * @param state defines the state that will be used for the build
  65697. */
  65698. initialize(state: NodeMaterialBuildState): void;
  65699. /**
  65700. * Gets the current class name
  65701. * @returns the class name
  65702. */
  65703. getClassName(): string;
  65704. /**
  65705. * Gets the intensity input component
  65706. */
  65707. get intensity(): NodeMaterialConnectionPoint;
  65708. /**
  65709. * Gets the color input component
  65710. */
  65711. get color(): NodeMaterialConnectionPoint;
  65712. /**
  65713. * Gets the roughness input component
  65714. */
  65715. get roughness(): NodeMaterialConnectionPoint;
  65716. /**
  65717. * Gets the sheen object output component
  65718. */
  65719. get sheen(): NodeMaterialConnectionPoint;
  65720. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65721. /**
  65722. * Gets the main code of the block (fragment side)
  65723. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65724. * @returns the shader code
  65725. */
  65726. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65727. protected _buildBlock(state: NodeMaterialBuildState): this;
  65728. protected _dumpPropertiesCode(): string;
  65729. serialize(): any;
  65730. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65731. }
  65732. }
  65733. declare module BABYLON {
  65734. /**
  65735. * Block used to implement the anisotropy module of the PBR material
  65736. */
  65737. export class AnisotropyBlock extends NodeMaterialBlock {
  65738. /**
  65739. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65740. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65741. * It's less burden on the user side in the editor part.
  65742. */
  65743. /** @hidden */
  65744. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65745. /** @hidden */
  65746. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65747. /**
  65748. * Create a new AnisotropyBlock
  65749. * @param name defines the block name
  65750. */
  65751. constructor(name: string);
  65752. /**
  65753. * Initialize the block and prepare the context for build
  65754. * @param state defines the state that will be used for the build
  65755. */
  65756. initialize(state: NodeMaterialBuildState): void;
  65757. /**
  65758. * Gets the current class name
  65759. * @returns the class name
  65760. */
  65761. getClassName(): string;
  65762. /**
  65763. * Gets the intensity input component
  65764. */
  65765. get intensity(): NodeMaterialConnectionPoint;
  65766. /**
  65767. * Gets the direction input component
  65768. */
  65769. get direction(): NodeMaterialConnectionPoint;
  65770. /**
  65771. * Gets the uv input component
  65772. */
  65773. get uv(): NodeMaterialConnectionPoint;
  65774. /**
  65775. * Gets the worldTangent input component
  65776. */
  65777. get worldTangent(): NodeMaterialConnectionPoint;
  65778. /**
  65779. * Gets the anisotropy object output component
  65780. */
  65781. get anisotropy(): NodeMaterialConnectionPoint;
  65782. private _generateTBNSpace;
  65783. /**
  65784. * Gets the main code of the block (fragment side)
  65785. * @param state current state of the node material building
  65786. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65787. * @returns the shader code
  65788. */
  65789. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65790. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65791. protected _buildBlock(state: NodeMaterialBuildState): this;
  65792. }
  65793. }
  65794. declare module BABYLON {
  65795. /**
  65796. * Block used to implement the clear coat module of the PBR material
  65797. */
  65798. export class ClearCoatBlock extends NodeMaterialBlock {
  65799. private _scene;
  65800. /**
  65801. * Create a new ClearCoatBlock
  65802. * @param name defines the block name
  65803. */
  65804. constructor(name: string);
  65805. /**
  65806. * Defines if the F0 value should be remapped to account for the interface change in the material.
  65807. */
  65808. remapF0OnInterfaceChange: boolean;
  65809. /**
  65810. * Initialize the block and prepare the context for build
  65811. * @param state defines the state that will be used for the build
  65812. */
  65813. initialize(state: NodeMaterialBuildState): void;
  65814. /**
  65815. * Gets the current class name
  65816. * @returns the class name
  65817. */
  65818. getClassName(): string;
  65819. /**
  65820. * Gets the intensity input component
  65821. */
  65822. get intensity(): NodeMaterialConnectionPoint;
  65823. /**
  65824. * Gets the roughness input component
  65825. */
  65826. get roughness(): NodeMaterialConnectionPoint;
  65827. /**
  65828. * Gets the ior input component
  65829. */
  65830. get indexOfRefraction(): NodeMaterialConnectionPoint;
  65831. /**
  65832. * Gets the bump texture input component
  65833. */
  65834. get normalMapColor(): NodeMaterialConnectionPoint;
  65835. /**
  65836. * Gets the uv input component
  65837. */
  65838. get uv(): NodeMaterialConnectionPoint;
  65839. /**
  65840. * Gets the tint color input component
  65841. */
  65842. get tintColor(): NodeMaterialConnectionPoint;
  65843. /**
  65844. * Gets the tint "at distance" input component
  65845. */
  65846. get tintAtDistance(): NodeMaterialConnectionPoint;
  65847. /**
  65848. * Gets the tint thickness input component
  65849. */
  65850. get tintThickness(): NodeMaterialConnectionPoint;
  65851. /**
  65852. * Gets the world tangent input component
  65853. */
  65854. get worldTangent(): NodeMaterialConnectionPoint;
  65855. /**
  65856. * Gets the clear coat object output component
  65857. */
  65858. get clearcoat(): NodeMaterialConnectionPoint;
  65859. autoConfigure(material: NodeMaterial): void;
  65860. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65861. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65862. private _generateTBNSpace;
  65863. /**
  65864. * Gets the main code of the block (fragment side)
  65865. * @param state current state of the node material building
  65866. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65867. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65868. * @param worldPosVarName name of the variable holding the world position
  65869. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65870. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65871. * @param worldNormalVarName name of the variable holding the world normal
  65872. * @returns the shader code
  65873. */
  65874. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65875. protected _buildBlock(state: NodeMaterialBuildState): this;
  65876. protected _dumpPropertiesCode(): string;
  65877. serialize(): any;
  65878. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65879. }
  65880. }
  65881. declare module BABYLON {
  65882. /**
  65883. * Block used to implement the sub surface module of the PBR material
  65884. */
  65885. export class SubSurfaceBlock extends NodeMaterialBlock {
  65886. /**
  65887. * Create a new SubSurfaceBlock
  65888. * @param name defines the block name
  65889. */
  65890. constructor(name: string);
  65891. /**
  65892. * Initialize the block and prepare the context for build
  65893. * @param state defines the state that will be used for the build
  65894. */
  65895. initialize(state: NodeMaterialBuildState): void;
  65896. /**
  65897. * Gets the current class name
  65898. * @returns the class name
  65899. */
  65900. getClassName(): string;
  65901. /**
  65902. * Gets the thickness component
  65903. */
  65904. get thickness(): NodeMaterialConnectionPoint;
  65905. /**
  65906. * Gets the tint color input component
  65907. */
  65908. get tintColor(): NodeMaterialConnectionPoint;
  65909. /**
  65910. * Gets the translucency intensity input component
  65911. */
  65912. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65913. /**
  65914. * Gets the translucency diffusion distance input component
  65915. */
  65916. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  65917. /**
  65918. * Gets the refraction object parameters
  65919. */
  65920. get refraction(): NodeMaterialConnectionPoint;
  65921. /**
  65922. * Gets the sub surface object output component
  65923. */
  65924. get subsurface(): NodeMaterialConnectionPoint;
  65925. autoConfigure(material: NodeMaterial): void;
  65926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65927. /**
  65928. * Gets the main code of the block (fragment side)
  65929. * @param state current state of the node material building
  65930. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65931. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65932. * @param worldPosVarName name of the variable holding the world position
  65933. * @returns the shader code
  65934. */
  65935. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65936. protected _buildBlock(state: NodeMaterialBuildState): this;
  65937. }
  65938. }
  65939. declare module BABYLON {
  65940. /**
  65941. * Block used to implement the PBR metallic/roughness model
  65942. */
  65943. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65944. /**
  65945. * Gets or sets the light associated with this block
  65946. */
  65947. light: Nullable<Light>;
  65948. private _lightId;
  65949. private _scene;
  65950. private _environmentBRDFTexture;
  65951. private _environmentBrdfSamplerName;
  65952. private _vNormalWName;
  65953. private _invertNormalName;
  65954. private _metallicReflectanceColor;
  65955. private _metallicF0Factor;
  65956. private _vMetallicReflectanceFactorsName;
  65957. /**
  65958. * Create a new ReflectionBlock
  65959. * @param name defines the block name
  65960. */
  65961. constructor(name: string);
  65962. /**
  65963. * Intensity of the direct lights e.g. the four lights available in your scene.
  65964. * This impacts both the direct diffuse and specular highlights.
  65965. */
  65966. directIntensity: number;
  65967. /**
  65968. * Intensity of the environment e.g. how much the environment will light the object
  65969. * either through harmonics for rough material or through the refelction for shiny ones.
  65970. */
  65971. environmentIntensity: number;
  65972. /**
  65973. * This is a special control allowing the reduction of the specular highlights coming from the
  65974. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65975. */
  65976. specularIntensity: number;
  65977. /**
  65978. * Defines the falloff type used in this material.
  65979. * It by default is Physical.
  65980. */
  65981. lightFalloff: number;
  65982. /**
  65983. * Specifies that alpha test should be used
  65984. */
  65985. useAlphaTest: boolean;
  65986. /**
  65987. * Defines the alpha limits in alpha test mode.
  65988. */
  65989. alphaTestCutoff: number;
  65990. /**
  65991. * Specifies that alpha blending should be used
  65992. */
  65993. useAlphaBlending: boolean;
  65994. /**
  65995. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65996. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65997. */
  65998. useRadianceOverAlpha: boolean;
  65999. /**
  66000. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66001. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66002. */
  66003. useSpecularOverAlpha: boolean;
  66004. /**
  66005. * Enables specular anti aliasing in the PBR shader.
  66006. * It will both interacts on the Geometry for analytical and IBL lighting.
  66007. * It also prefilter the roughness map based on the bump values.
  66008. */
  66009. enableSpecularAntiAliasing: boolean;
  66010. /**
  66011. * Enables realtime filtering on the texture.
  66012. */
  66013. realTimeFiltering: boolean;
  66014. /**
  66015. * Quality switch for realtime filtering
  66016. */
  66017. realTimeFilteringQuality: number;
  66018. /**
  66019. * Defines if the material uses energy conservation.
  66020. */
  66021. useEnergyConservation: boolean;
  66022. /**
  66023. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66024. * too much the area relying on ambient texture to define their ambient occlusion.
  66025. */
  66026. useRadianceOcclusion: boolean;
  66027. /**
  66028. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66029. * makes the reflect vector face the model (under horizon).
  66030. */
  66031. useHorizonOcclusion: boolean;
  66032. /**
  66033. * If set to true, no lighting calculations will be applied.
  66034. */
  66035. unlit: boolean;
  66036. /**
  66037. * Force normal to face away from face.
  66038. */
  66039. forceNormalForward: boolean;
  66040. /**
  66041. * Defines the material debug mode.
  66042. * It helps seeing only some components of the material while troubleshooting.
  66043. */
  66044. debugMode: number;
  66045. /**
  66046. * Specify from where on screen the debug mode should start.
  66047. * The value goes from -1 (full screen) to 1 (not visible)
  66048. * It helps with side by side comparison against the final render
  66049. * This defaults to 0
  66050. */
  66051. debugLimit: number;
  66052. /**
  66053. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66054. * You can use the factor to better multiply the final value.
  66055. */
  66056. debugFactor: number;
  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 world position input component
  66069. */
  66070. get worldPosition(): NodeMaterialConnectionPoint;
  66071. /**
  66072. * Gets the world normal input component
  66073. */
  66074. get worldNormal(): NodeMaterialConnectionPoint;
  66075. /**
  66076. * Gets the view matrix parameter
  66077. */
  66078. get view(): NodeMaterialConnectionPoint;
  66079. /**
  66080. * Gets the camera position input component
  66081. */
  66082. get cameraPosition(): NodeMaterialConnectionPoint;
  66083. /**
  66084. * Gets the perturbed normal input component
  66085. */
  66086. get perturbedNormal(): NodeMaterialConnectionPoint;
  66087. /**
  66088. * Gets the base color input component
  66089. */
  66090. get baseColor(): NodeMaterialConnectionPoint;
  66091. /**
  66092. * Gets the metallic input component
  66093. */
  66094. get metallic(): NodeMaterialConnectionPoint;
  66095. /**
  66096. * Gets the roughness input component
  66097. */
  66098. get roughness(): NodeMaterialConnectionPoint;
  66099. /**
  66100. * Gets the ambient occlusion input component
  66101. */
  66102. get ambientOcc(): NodeMaterialConnectionPoint;
  66103. /**
  66104. * Gets the opacity input component
  66105. */
  66106. get opacity(): NodeMaterialConnectionPoint;
  66107. /**
  66108. * Gets the index of refraction input component
  66109. */
  66110. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66111. /**
  66112. * Gets the ambient color input component
  66113. */
  66114. get ambientColor(): NodeMaterialConnectionPoint;
  66115. /**
  66116. * Gets the reflection object parameters
  66117. */
  66118. get reflection(): NodeMaterialConnectionPoint;
  66119. /**
  66120. * Gets the clear coat object parameters
  66121. */
  66122. get clearcoat(): NodeMaterialConnectionPoint;
  66123. /**
  66124. * Gets the sheen object parameters
  66125. */
  66126. get sheen(): NodeMaterialConnectionPoint;
  66127. /**
  66128. * Gets the sub surface object parameters
  66129. */
  66130. get subsurface(): NodeMaterialConnectionPoint;
  66131. /**
  66132. * Gets the anisotropy object parameters
  66133. */
  66134. get anisotropy(): NodeMaterialConnectionPoint;
  66135. /**
  66136. * Gets the ambient output component
  66137. */
  66138. get ambientClr(): NodeMaterialConnectionPoint;
  66139. /**
  66140. * Gets the diffuse output component
  66141. */
  66142. get diffuseDir(): NodeMaterialConnectionPoint;
  66143. /**
  66144. * Gets the specular output component
  66145. */
  66146. get specularDir(): NodeMaterialConnectionPoint;
  66147. /**
  66148. * Gets the clear coat output component
  66149. */
  66150. get clearcoatDir(): NodeMaterialConnectionPoint;
  66151. /**
  66152. * Gets the sheen output component
  66153. */
  66154. get sheenDir(): NodeMaterialConnectionPoint;
  66155. /**
  66156. * Gets the indirect diffuse output component
  66157. */
  66158. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66159. /**
  66160. * Gets the indirect specular output component
  66161. */
  66162. get specularIndirect(): NodeMaterialConnectionPoint;
  66163. /**
  66164. * Gets the indirect clear coat output component
  66165. */
  66166. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66167. /**
  66168. * Gets the indirect sheen output component
  66169. */
  66170. get sheenIndirect(): NodeMaterialConnectionPoint;
  66171. /**
  66172. * Gets the refraction output component
  66173. */
  66174. get refraction(): NodeMaterialConnectionPoint;
  66175. /**
  66176. * Gets the global lighting output component
  66177. */
  66178. get lighting(): NodeMaterialConnectionPoint;
  66179. /**
  66180. * Gets the shadow output component
  66181. */
  66182. get shadow(): NodeMaterialConnectionPoint;
  66183. /**
  66184. * Gets the alpha output component
  66185. */
  66186. get alpha(): NodeMaterialConnectionPoint;
  66187. autoConfigure(material: NodeMaterial): void;
  66188. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66189. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66190. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66191. private _injectVertexCode;
  66192. private _getAlbedoOpacityCode;
  66193. private _getAmbientOcclusionCode;
  66194. private _getReflectivityCode;
  66195. protected _buildBlock(state: NodeMaterialBuildState): this;
  66196. protected _dumpPropertiesCode(): string;
  66197. serialize(): any;
  66198. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66199. }
  66200. }
  66201. declare module BABYLON {
  66202. /**
  66203. * Block used to compute value of one parameter modulo another
  66204. */
  66205. export class ModBlock extends NodeMaterialBlock {
  66206. /**
  66207. * Creates a new ModBlock
  66208. * @param name defines the block name
  66209. */
  66210. constructor(name: string);
  66211. /**
  66212. * Gets the current class name
  66213. * @returns the class name
  66214. */
  66215. getClassName(): string;
  66216. /**
  66217. * Gets the left operand input component
  66218. */
  66219. get left(): NodeMaterialConnectionPoint;
  66220. /**
  66221. * Gets the right operand input component
  66222. */
  66223. get right(): NodeMaterialConnectionPoint;
  66224. /**
  66225. * Gets the output component
  66226. */
  66227. get output(): NodeMaterialConnectionPoint;
  66228. protected _buildBlock(state: NodeMaterialBuildState): this;
  66229. }
  66230. }
  66231. declare module BABYLON {
  66232. /**
  66233. * Configuration for Draco compression
  66234. */
  66235. export interface IDracoCompressionConfiguration {
  66236. /**
  66237. * Configuration for the decoder.
  66238. */
  66239. decoder: {
  66240. /**
  66241. * The url to the WebAssembly module.
  66242. */
  66243. wasmUrl?: string;
  66244. /**
  66245. * The url to the WebAssembly binary.
  66246. */
  66247. wasmBinaryUrl?: string;
  66248. /**
  66249. * The url to the fallback JavaScript module.
  66250. */
  66251. fallbackUrl?: string;
  66252. };
  66253. }
  66254. /**
  66255. * Draco compression (https://google.github.io/draco/)
  66256. *
  66257. * This class wraps the Draco module.
  66258. *
  66259. * **Encoder**
  66260. *
  66261. * The encoder is not currently implemented.
  66262. *
  66263. * **Decoder**
  66264. *
  66265. * 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.
  66266. *
  66267. * To update the configuration, use the following code:
  66268. * ```javascript
  66269. * DracoCompression.Configuration = {
  66270. * decoder: {
  66271. * wasmUrl: "<url to the WebAssembly library>",
  66272. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66273. * fallbackUrl: "<url to the fallback JavaScript library>",
  66274. * }
  66275. * };
  66276. * ```
  66277. *
  66278. * 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.
  66279. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66280. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66281. *
  66282. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66283. * ```javascript
  66284. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66285. * ```
  66286. *
  66287. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66288. */
  66289. export class DracoCompression implements IDisposable {
  66290. private _workerPoolPromise?;
  66291. private _decoderModulePromise?;
  66292. /**
  66293. * The configuration. Defaults to the following urls:
  66294. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66295. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66296. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66297. */
  66298. static Configuration: IDracoCompressionConfiguration;
  66299. /**
  66300. * Returns true if the decoder configuration is available.
  66301. */
  66302. static get DecoderAvailable(): boolean;
  66303. /**
  66304. * Default number of workers to create when creating the draco compression object.
  66305. */
  66306. static DefaultNumWorkers: number;
  66307. private static GetDefaultNumWorkers;
  66308. private static _Default;
  66309. /**
  66310. * Default instance for the draco compression object.
  66311. */
  66312. static get Default(): DracoCompression;
  66313. /**
  66314. * Constructor
  66315. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66316. */
  66317. constructor(numWorkers?: number);
  66318. /**
  66319. * Stop all async operations and release resources.
  66320. */
  66321. dispose(): void;
  66322. /**
  66323. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66324. * @returns a promise that resolves when ready
  66325. */
  66326. whenReadyAsync(): Promise<void>;
  66327. /**
  66328. * Decode Draco compressed mesh data to vertex data.
  66329. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66330. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66331. * @returns A promise that resolves with the decoded vertex data
  66332. */
  66333. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66334. [kind: string]: number;
  66335. }): Promise<VertexData>;
  66336. }
  66337. }
  66338. declare module BABYLON {
  66339. /**
  66340. * Class for building Constructive Solid Geometry
  66341. */
  66342. export class CSG {
  66343. private polygons;
  66344. /**
  66345. * The world matrix
  66346. */
  66347. matrix: Matrix;
  66348. /**
  66349. * Stores the position
  66350. */
  66351. position: Vector3;
  66352. /**
  66353. * Stores the rotation
  66354. */
  66355. rotation: Vector3;
  66356. /**
  66357. * Stores the rotation quaternion
  66358. */
  66359. rotationQuaternion: Nullable<Quaternion>;
  66360. /**
  66361. * Stores the scaling vector
  66362. */
  66363. scaling: Vector3;
  66364. /**
  66365. * Convert the Mesh to CSG
  66366. * @param mesh The Mesh to convert to CSG
  66367. * @returns A new CSG from the Mesh
  66368. */
  66369. static FromMesh(mesh: Mesh): CSG;
  66370. /**
  66371. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66372. * @param polygons Polygons used to construct a CSG solid
  66373. */
  66374. private static FromPolygons;
  66375. /**
  66376. * Clones, or makes a deep copy, of the CSG
  66377. * @returns A new CSG
  66378. */
  66379. clone(): CSG;
  66380. /**
  66381. * Unions this CSG with another CSG
  66382. * @param csg The CSG to union against this CSG
  66383. * @returns The unioned CSG
  66384. */
  66385. union(csg: CSG): CSG;
  66386. /**
  66387. * Unions this CSG with another CSG in place
  66388. * @param csg The CSG to union against this CSG
  66389. */
  66390. unionInPlace(csg: CSG): void;
  66391. /**
  66392. * Subtracts this CSG with another CSG
  66393. * @param csg The CSG to subtract against this CSG
  66394. * @returns A new CSG
  66395. */
  66396. subtract(csg: CSG): CSG;
  66397. /**
  66398. * Subtracts this CSG with another CSG in place
  66399. * @param csg The CSG to subtact against this CSG
  66400. */
  66401. subtractInPlace(csg: CSG): void;
  66402. /**
  66403. * Intersect this CSG with another CSG
  66404. * @param csg The CSG to intersect against this CSG
  66405. * @returns A new CSG
  66406. */
  66407. intersect(csg: CSG): CSG;
  66408. /**
  66409. * Intersects this CSG with another CSG in place
  66410. * @param csg The CSG to intersect against this CSG
  66411. */
  66412. intersectInPlace(csg: CSG): void;
  66413. /**
  66414. * Return a new CSG solid with solid and empty space switched. This solid is
  66415. * not modified.
  66416. * @returns A new CSG solid with solid and empty space switched
  66417. */
  66418. inverse(): CSG;
  66419. /**
  66420. * Inverses the CSG in place
  66421. */
  66422. inverseInPlace(): void;
  66423. /**
  66424. * This is used to keep meshes transformations so they can be restored
  66425. * when we build back a Babylon Mesh
  66426. * NB : All CSG operations are performed in world coordinates
  66427. * @param csg The CSG to copy the transform attributes from
  66428. * @returns This CSG
  66429. */
  66430. copyTransformAttributes(csg: CSG): CSG;
  66431. /**
  66432. * Build Raw mesh from CSG
  66433. * Coordinates here are in world space
  66434. * @param name The name of the mesh geometry
  66435. * @param scene The Scene
  66436. * @param keepSubMeshes Specifies if the submeshes should be kept
  66437. * @returns A new Mesh
  66438. */
  66439. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66440. /**
  66441. * Build Mesh from CSG taking material and transforms into account
  66442. * @param name The name of the Mesh
  66443. * @param material The material of the Mesh
  66444. * @param scene The Scene
  66445. * @param keepSubMeshes Specifies if submeshes should be kept
  66446. * @returns The new Mesh
  66447. */
  66448. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66449. }
  66450. }
  66451. declare module BABYLON {
  66452. /**
  66453. * Class used to create a trail following a mesh
  66454. */
  66455. export class TrailMesh extends Mesh {
  66456. private _generator;
  66457. private _autoStart;
  66458. private _running;
  66459. private _diameter;
  66460. private _length;
  66461. private _sectionPolygonPointsCount;
  66462. private _sectionVectors;
  66463. private _sectionNormalVectors;
  66464. private _beforeRenderObserver;
  66465. /**
  66466. * @constructor
  66467. * @param name The value used by scene.getMeshByName() to do a lookup.
  66468. * @param generator The mesh or transform node to generate a trail.
  66469. * @param scene The scene to add this mesh to.
  66470. * @param diameter Diameter of trailing mesh. Default is 1.
  66471. * @param length Length of trailing mesh. Default is 60.
  66472. * @param autoStart Automatically start trailing mesh. Default true.
  66473. */
  66474. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66475. /**
  66476. * "TrailMesh"
  66477. * @returns "TrailMesh"
  66478. */
  66479. getClassName(): string;
  66480. private _createMesh;
  66481. /**
  66482. * Start trailing mesh.
  66483. */
  66484. start(): void;
  66485. /**
  66486. * Stop trailing mesh.
  66487. */
  66488. stop(): void;
  66489. /**
  66490. * Update trailing mesh geometry.
  66491. */
  66492. update(): void;
  66493. /**
  66494. * Returns a new TrailMesh object.
  66495. * @param name is a string, the name given to the new mesh
  66496. * @param newGenerator use new generator object for cloned trail mesh
  66497. * @returns a new mesh
  66498. */
  66499. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66500. /**
  66501. * Serializes this trail mesh
  66502. * @param serializationObject object to write serialization to
  66503. */
  66504. serialize(serializationObject: any): void;
  66505. /**
  66506. * Parses a serialized trail mesh
  66507. * @param parsedMesh the serialized mesh
  66508. * @param scene the scene to create the trail mesh in
  66509. * @returns the created trail mesh
  66510. */
  66511. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66512. }
  66513. }
  66514. declare module BABYLON {
  66515. /**
  66516. * Class containing static functions to help procedurally build meshes
  66517. */
  66518. export class TiledBoxBuilder {
  66519. /**
  66520. * Creates a box mesh
  66521. * 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)
  66522. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66524. * * 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
  66525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66526. * @param name defines the name of the mesh
  66527. * @param options defines the options used to create the mesh
  66528. * @param scene defines the hosting scene
  66529. * @returns the box mesh
  66530. */
  66531. static CreateTiledBox(name: string, options: {
  66532. pattern?: number;
  66533. width?: number;
  66534. height?: number;
  66535. depth?: number;
  66536. tileSize?: number;
  66537. tileWidth?: number;
  66538. tileHeight?: number;
  66539. alignHorizontal?: number;
  66540. alignVertical?: number;
  66541. faceUV?: Vector4[];
  66542. faceColors?: Color4[];
  66543. sideOrientation?: number;
  66544. updatable?: boolean;
  66545. }, scene?: Nullable<Scene>): Mesh;
  66546. }
  66547. }
  66548. declare module BABYLON {
  66549. /**
  66550. * Class containing static functions to help procedurally build meshes
  66551. */
  66552. export class TorusKnotBuilder {
  66553. /**
  66554. * Creates a torus knot mesh
  66555. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66556. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66557. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66558. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66560. * * 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
  66561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66562. * @param name defines the name of the mesh
  66563. * @param options defines the options used to create the mesh
  66564. * @param scene defines the hosting scene
  66565. * @returns the torus knot mesh
  66566. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66567. */
  66568. static CreateTorusKnot(name: string, options: {
  66569. radius?: number;
  66570. tube?: number;
  66571. radialSegments?: number;
  66572. tubularSegments?: number;
  66573. p?: number;
  66574. q?: number;
  66575. updatable?: boolean;
  66576. sideOrientation?: number;
  66577. frontUVs?: Vector4;
  66578. backUVs?: Vector4;
  66579. }, scene: any): Mesh;
  66580. }
  66581. }
  66582. declare module BABYLON {
  66583. /**
  66584. * Polygon
  66585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66586. */
  66587. export class Polygon {
  66588. /**
  66589. * Creates a rectangle
  66590. * @param xmin bottom X coord
  66591. * @param ymin bottom Y coord
  66592. * @param xmax top X coord
  66593. * @param ymax top Y coord
  66594. * @returns points that make the resulting rectation
  66595. */
  66596. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66597. /**
  66598. * Creates a circle
  66599. * @param radius radius of circle
  66600. * @param cx scale in x
  66601. * @param cy scale in y
  66602. * @param numberOfSides number of sides that make up the circle
  66603. * @returns points that make the resulting circle
  66604. */
  66605. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66606. /**
  66607. * Creates a polygon from input string
  66608. * @param input Input polygon data
  66609. * @returns the parsed points
  66610. */
  66611. static Parse(input: string): Vector2[];
  66612. /**
  66613. * Starts building a polygon from x and y coordinates
  66614. * @param x x coordinate
  66615. * @param y y coordinate
  66616. * @returns the started path2
  66617. */
  66618. static StartingAt(x: number, y: number): Path2;
  66619. }
  66620. /**
  66621. * Builds a polygon
  66622. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66623. */
  66624. export class PolygonMeshBuilder {
  66625. private _points;
  66626. private _outlinepoints;
  66627. private _holes;
  66628. private _name;
  66629. private _scene;
  66630. private _epoints;
  66631. private _eholes;
  66632. private _addToepoint;
  66633. /**
  66634. * Babylon reference to the earcut plugin.
  66635. */
  66636. bjsEarcut: any;
  66637. /**
  66638. * Creates a PolygonMeshBuilder
  66639. * @param name name of the builder
  66640. * @param contours Path of the polygon
  66641. * @param scene scene to add to when creating the mesh
  66642. * @param earcutInjection can be used to inject your own earcut reference
  66643. */
  66644. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66645. /**
  66646. * Adds a whole within the polygon
  66647. * @param hole Array of points defining the hole
  66648. * @returns this
  66649. */
  66650. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66651. /**
  66652. * Creates the polygon
  66653. * @param updatable If the mesh should be updatable
  66654. * @param depth The depth of the mesh created
  66655. * @returns the created mesh
  66656. */
  66657. build(updatable?: boolean, depth?: number): Mesh;
  66658. /**
  66659. * Creates the polygon
  66660. * @param depth The depth of the mesh created
  66661. * @returns the created VertexData
  66662. */
  66663. buildVertexData(depth?: number): VertexData;
  66664. /**
  66665. * Adds a side to the polygon
  66666. * @param positions points that make the polygon
  66667. * @param normals normals of the polygon
  66668. * @param uvs uvs of the polygon
  66669. * @param indices indices of the polygon
  66670. * @param bounds bounds of the polygon
  66671. * @param points points of the polygon
  66672. * @param depth depth of the polygon
  66673. * @param flip flip of the polygon
  66674. */
  66675. private addSide;
  66676. }
  66677. }
  66678. declare module BABYLON {
  66679. /**
  66680. * Class containing static functions to help procedurally build meshes
  66681. */
  66682. export class PolygonBuilder {
  66683. /**
  66684. * Creates a polygon mesh
  66685. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66686. * * 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
  66687. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66689. * * 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)
  66690. * * Remember you can only change the shape positions, not their number when updating a polygon
  66691. * @param name defines the name of the mesh
  66692. * @param options defines the options used to create the mesh
  66693. * @param scene defines the hosting scene
  66694. * @param earcutInjection can be used to inject your own earcut reference
  66695. * @returns the polygon mesh
  66696. */
  66697. static CreatePolygon(name: string, options: {
  66698. shape: Vector3[];
  66699. holes?: Vector3[][];
  66700. depth?: number;
  66701. faceUV?: Vector4[];
  66702. faceColors?: Color4[];
  66703. updatable?: boolean;
  66704. sideOrientation?: number;
  66705. frontUVs?: Vector4;
  66706. backUVs?: Vector4;
  66707. wrap?: boolean;
  66708. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66709. /**
  66710. * Creates an extruded polygon mesh, with depth in the Y direction.
  66711. * * 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)
  66712. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66713. * @param name defines the name of the mesh
  66714. * @param options defines the options used to create the mesh
  66715. * @param scene defines the hosting scene
  66716. * @param earcutInjection can be used to inject your own earcut reference
  66717. * @returns the polygon mesh
  66718. */
  66719. static ExtrudePolygon(name: string, options: {
  66720. shape: Vector3[];
  66721. holes?: Vector3[][];
  66722. depth?: number;
  66723. faceUV?: Vector4[];
  66724. faceColors?: Color4[];
  66725. updatable?: boolean;
  66726. sideOrientation?: number;
  66727. frontUVs?: Vector4;
  66728. backUVs?: Vector4;
  66729. wrap?: boolean;
  66730. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66731. }
  66732. }
  66733. declare module BABYLON {
  66734. /**
  66735. * Class containing static functions to help procedurally build meshes
  66736. */
  66737. export class LatheBuilder {
  66738. /**
  66739. * Creates lathe mesh.
  66740. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66741. * * 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
  66742. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66743. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66744. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66745. * * 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
  66746. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66747. * * 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
  66748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66749. * * 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
  66750. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66752. * @param name defines the name of the mesh
  66753. * @param options defines the options used to create the mesh
  66754. * @param scene defines the hosting scene
  66755. * @returns the lathe mesh
  66756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66757. */
  66758. static CreateLathe(name: string, options: {
  66759. shape: Vector3[];
  66760. radius?: number;
  66761. tessellation?: number;
  66762. clip?: number;
  66763. arc?: number;
  66764. closed?: boolean;
  66765. updatable?: boolean;
  66766. sideOrientation?: number;
  66767. frontUVs?: Vector4;
  66768. backUVs?: Vector4;
  66769. cap?: number;
  66770. invertUV?: boolean;
  66771. }, scene?: Nullable<Scene>): Mesh;
  66772. }
  66773. }
  66774. declare module BABYLON {
  66775. /**
  66776. * Class containing static functions to help procedurally build meshes
  66777. */
  66778. export class TiledPlaneBuilder {
  66779. /**
  66780. * Creates a tiled plane mesh
  66781. * * The parameter `pattern` will, depending on value, do nothing or
  66782. * * * flip (reflect about central vertical) alternate tiles across and up
  66783. * * * flip every tile on alternate rows
  66784. * * * rotate (180 degs) alternate tiles across and up
  66785. * * * rotate every tile on alternate rows
  66786. * * * flip and rotate alternate tiles across and up
  66787. * * * flip and rotate every tile on alternate rows
  66788. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66789. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66790. * * 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
  66791. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66792. * * 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)
  66793. * * 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)
  66794. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66795. * @param name defines the name of the mesh
  66796. * @param options defines the options used to create the mesh
  66797. * @param scene defines the hosting scene
  66798. * @returns the box mesh
  66799. */
  66800. static CreateTiledPlane(name: string, options: {
  66801. pattern?: number;
  66802. tileSize?: number;
  66803. tileWidth?: number;
  66804. tileHeight?: number;
  66805. size?: number;
  66806. width?: number;
  66807. height?: number;
  66808. alignHorizontal?: number;
  66809. alignVertical?: number;
  66810. sideOrientation?: number;
  66811. frontUVs?: Vector4;
  66812. backUVs?: Vector4;
  66813. updatable?: boolean;
  66814. }, scene?: Nullable<Scene>): Mesh;
  66815. }
  66816. }
  66817. declare module BABYLON {
  66818. /**
  66819. * Class containing static functions to help procedurally build meshes
  66820. */
  66821. export class TubeBuilder {
  66822. /**
  66823. * Creates a tube mesh.
  66824. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66825. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66826. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66827. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66828. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66829. * * 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)
  66830. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66831. * * 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
  66832. * * 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
  66833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66834. * * 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
  66835. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66837. * @param name defines the name of the mesh
  66838. * @param options defines the options used to create the mesh
  66839. * @param scene defines the hosting scene
  66840. * @returns the tube mesh
  66841. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66842. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66843. */
  66844. static CreateTube(name: string, options: {
  66845. path: Vector3[];
  66846. radius?: number;
  66847. tessellation?: number;
  66848. radiusFunction?: {
  66849. (i: number, distance: number): number;
  66850. };
  66851. cap?: number;
  66852. arc?: number;
  66853. updatable?: boolean;
  66854. sideOrientation?: number;
  66855. frontUVs?: Vector4;
  66856. backUVs?: Vector4;
  66857. instance?: Mesh;
  66858. invertUV?: boolean;
  66859. }, scene?: Nullable<Scene>): Mesh;
  66860. }
  66861. }
  66862. declare module BABYLON {
  66863. /**
  66864. * Class containing static functions to help procedurally build meshes
  66865. */
  66866. export class IcoSphereBuilder {
  66867. /**
  66868. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66869. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66870. * * 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`)
  66871. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66872. * * 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
  66873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66874. * * 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
  66875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66876. * @param name defines the name of the mesh
  66877. * @param options defines the options used to create the mesh
  66878. * @param scene defines the hosting scene
  66879. * @returns the icosahedron mesh
  66880. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66881. */
  66882. static CreateIcoSphere(name: string, options: {
  66883. radius?: number;
  66884. radiusX?: number;
  66885. radiusY?: number;
  66886. radiusZ?: number;
  66887. flat?: boolean;
  66888. subdivisions?: number;
  66889. sideOrientation?: number;
  66890. frontUVs?: Vector4;
  66891. backUVs?: Vector4;
  66892. updatable?: boolean;
  66893. }, scene?: Nullable<Scene>): Mesh;
  66894. }
  66895. }
  66896. declare module BABYLON {
  66897. /**
  66898. * Class containing static functions to help procedurally build meshes
  66899. */
  66900. export class DecalBuilder {
  66901. /**
  66902. * Creates a decal mesh.
  66903. * 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
  66904. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66905. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66906. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66907. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66908. * @param name defines the name of the mesh
  66909. * @param sourceMesh defines the mesh where the decal must be applied
  66910. * @param options defines the options used to create the mesh
  66911. * @param scene defines the hosting scene
  66912. * @returns the decal mesh
  66913. * @see https://doc.babylonjs.com/how_to/decals
  66914. */
  66915. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66916. position?: Vector3;
  66917. normal?: Vector3;
  66918. size?: Vector3;
  66919. angle?: number;
  66920. }): Mesh;
  66921. }
  66922. }
  66923. declare module BABYLON {
  66924. /**
  66925. * Class containing static functions to help procedurally build meshes
  66926. */
  66927. export class MeshBuilder {
  66928. /**
  66929. * Creates a box mesh
  66930. * * The parameter `size` sets the size (float) of each box side (default 1)
  66931. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66932. * * 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)
  66933. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66935. * * 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
  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. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66938. * @param name defines the name of the mesh
  66939. * @param options defines the options used to create the mesh
  66940. * @param scene defines the hosting scene
  66941. * @returns the box mesh
  66942. */
  66943. static CreateBox(name: string, options: {
  66944. size?: number;
  66945. width?: number;
  66946. height?: number;
  66947. depth?: number;
  66948. faceUV?: Vector4[];
  66949. faceColors?: Color4[];
  66950. sideOrientation?: number;
  66951. frontUVs?: Vector4;
  66952. backUVs?: Vector4;
  66953. wrap?: boolean;
  66954. topBaseAt?: number;
  66955. bottomBaseAt?: number;
  66956. updatable?: boolean;
  66957. }, scene?: Nullable<Scene>): Mesh;
  66958. /**
  66959. * Creates a tiled box mesh
  66960. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66962. * @param name defines the name of the mesh
  66963. * @param options defines the options used to create the mesh
  66964. * @param scene defines the hosting scene
  66965. * @returns the tiled box mesh
  66966. */
  66967. static CreateTiledBox(name: string, options: {
  66968. pattern?: number;
  66969. size?: number;
  66970. width?: number;
  66971. height?: number;
  66972. depth: number;
  66973. tileSize?: number;
  66974. tileWidth?: number;
  66975. tileHeight?: number;
  66976. faceUV?: Vector4[];
  66977. faceColors?: Color4[];
  66978. alignHorizontal?: number;
  66979. alignVertical?: number;
  66980. sideOrientation?: number;
  66981. updatable?: boolean;
  66982. }, scene?: Nullable<Scene>): Mesh;
  66983. /**
  66984. * Creates a sphere mesh
  66985. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66986. * * 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`)
  66987. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66988. * * 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
  66989. * * 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)
  66990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66991. * * 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
  66992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66993. * @param name defines the name of the mesh
  66994. * @param options defines the options used to create the mesh
  66995. * @param scene defines the hosting scene
  66996. * @returns the sphere mesh
  66997. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66998. */
  66999. static CreateSphere(name: string, options: {
  67000. segments?: number;
  67001. diameter?: number;
  67002. diameterX?: number;
  67003. diameterY?: number;
  67004. diameterZ?: number;
  67005. arc?: number;
  67006. slice?: number;
  67007. sideOrientation?: number;
  67008. frontUVs?: Vector4;
  67009. backUVs?: Vector4;
  67010. updatable?: boolean;
  67011. }, scene?: Nullable<Scene>): Mesh;
  67012. /**
  67013. * Creates a plane polygonal mesh. By default, this is a disc
  67014. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67015. * * 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
  67016. * * 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
  67017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67018. * * 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
  67019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67020. * @param name defines the name of the mesh
  67021. * @param options defines the options used to create the mesh
  67022. * @param scene defines the hosting scene
  67023. * @returns the plane polygonal mesh
  67024. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67025. */
  67026. static CreateDisc(name: string, options: {
  67027. radius?: number;
  67028. tessellation?: number;
  67029. arc?: number;
  67030. updatable?: boolean;
  67031. sideOrientation?: number;
  67032. frontUVs?: Vector4;
  67033. backUVs?: Vector4;
  67034. }, scene?: Nullable<Scene>): Mesh;
  67035. /**
  67036. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67037. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67038. * * 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`)
  67039. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67040. * * 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
  67041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67042. * * 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
  67043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67044. * @param name defines the name of the mesh
  67045. * @param options defines the options used to create the mesh
  67046. * @param scene defines the hosting scene
  67047. * @returns the icosahedron mesh
  67048. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67049. */
  67050. static CreateIcoSphere(name: string, options: {
  67051. radius?: number;
  67052. radiusX?: number;
  67053. radiusY?: number;
  67054. radiusZ?: number;
  67055. flat?: boolean;
  67056. subdivisions?: number;
  67057. sideOrientation?: number;
  67058. frontUVs?: Vector4;
  67059. backUVs?: Vector4;
  67060. updatable?: boolean;
  67061. }, scene?: Nullable<Scene>): Mesh;
  67062. /**
  67063. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67064. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67065. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67066. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67067. * * 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
  67068. * * 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
  67069. * * 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
  67070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67071. * * 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
  67072. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67073. * * 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
  67074. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67075. * * 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
  67076. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67078. * @param name defines the name of the mesh
  67079. * @param options defines the options used to create the mesh
  67080. * @param scene defines the hosting scene
  67081. * @returns the ribbon mesh
  67082. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67083. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67084. */
  67085. static CreateRibbon(name: string, options: {
  67086. pathArray: Vector3[][];
  67087. closeArray?: boolean;
  67088. closePath?: boolean;
  67089. offset?: number;
  67090. updatable?: boolean;
  67091. sideOrientation?: number;
  67092. frontUVs?: Vector4;
  67093. backUVs?: Vector4;
  67094. instance?: Mesh;
  67095. invertUV?: boolean;
  67096. uvs?: Vector2[];
  67097. colors?: Color4[];
  67098. }, scene?: Nullable<Scene>): Mesh;
  67099. /**
  67100. * Creates a cylinder or a cone mesh
  67101. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67102. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67103. * * 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.
  67104. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67105. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67106. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67107. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67108. * * 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).
  67109. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67110. * * 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).
  67111. * * 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
  67112. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67113. * * 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
  67114. * * 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.
  67115. * * If `enclose` is false, a ring surface is one element.
  67116. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67117. * * 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
  67118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67119. * * 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
  67120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67121. * @param name defines the name of the mesh
  67122. * @param options defines the options used to create the mesh
  67123. * @param scene defines the hosting scene
  67124. * @returns the cylinder mesh
  67125. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67126. */
  67127. static CreateCylinder(name: string, options: {
  67128. height?: number;
  67129. diameterTop?: number;
  67130. diameterBottom?: number;
  67131. diameter?: number;
  67132. tessellation?: number;
  67133. subdivisions?: number;
  67134. arc?: number;
  67135. faceColors?: Color4[];
  67136. faceUV?: Vector4[];
  67137. updatable?: boolean;
  67138. hasRings?: boolean;
  67139. enclose?: boolean;
  67140. cap?: number;
  67141. sideOrientation?: number;
  67142. frontUVs?: Vector4;
  67143. backUVs?: Vector4;
  67144. }, scene?: Nullable<Scene>): Mesh;
  67145. /**
  67146. * Creates a torus mesh
  67147. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67148. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67149. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67151. * * 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
  67152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67153. * @param name defines the name of the mesh
  67154. * @param options defines the options used to create the mesh
  67155. * @param scene defines the hosting scene
  67156. * @returns the torus mesh
  67157. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67158. */
  67159. static CreateTorus(name: string, options: {
  67160. diameter?: number;
  67161. thickness?: number;
  67162. tessellation?: number;
  67163. updatable?: boolean;
  67164. sideOrientation?: number;
  67165. frontUVs?: Vector4;
  67166. backUVs?: Vector4;
  67167. }, scene?: Nullable<Scene>): Mesh;
  67168. /**
  67169. * Creates a torus knot mesh
  67170. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67171. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67172. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67173. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67175. * * 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
  67176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67177. * @param name defines the name of the mesh
  67178. * @param options defines the options used to create the mesh
  67179. * @param scene defines the hosting scene
  67180. * @returns the torus knot mesh
  67181. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67182. */
  67183. static CreateTorusKnot(name: string, options: {
  67184. radius?: number;
  67185. tube?: number;
  67186. radialSegments?: number;
  67187. tubularSegments?: number;
  67188. p?: number;
  67189. q?: number;
  67190. updatable?: boolean;
  67191. sideOrientation?: number;
  67192. frontUVs?: Vector4;
  67193. backUVs?: Vector4;
  67194. }, scene?: Nullable<Scene>): Mesh;
  67195. /**
  67196. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67197. * * 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
  67198. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67199. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67200. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67201. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67202. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67203. * * 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
  67204. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67207. * @param name defines the name of the new line system
  67208. * @param options defines the options used to create the line system
  67209. * @param scene defines the hosting scene
  67210. * @returns a new line system mesh
  67211. */
  67212. static CreateLineSystem(name: string, options: {
  67213. lines: Vector3[][];
  67214. updatable?: boolean;
  67215. instance?: Nullable<LinesMesh>;
  67216. colors?: Nullable<Color4[][]>;
  67217. useVertexAlpha?: boolean;
  67218. }, scene: Nullable<Scene>): LinesMesh;
  67219. /**
  67220. * Creates a line mesh
  67221. * 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
  67222. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67223. * * The parameter `points` is an array successive Vector3
  67224. * * 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
  67225. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67226. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67227. * * When updating an instance, remember that only point positions can change, not the number of points
  67228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67230. * @param name defines the name of the new line system
  67231. * @param options defines the options used to create the line system
  67232. * @param scene defines the hosting scene
  67233. * @returns a new line mesh
  67234. */
  67235. static CreateLines(name: string, options: {
  67236. points: Vector3[];
  67237. updatable?: boolean;
  67238. instance?: Nullable<LinesMesh>;
  67239. colors?: Color4[];
  67240. useVertexAlpha?: boolean;
  67241. }, scene?: Nullable<Scene>): LinesMesh;
  67242. /**
  67243. * Creates a dashed line mesh
  67244. * * 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
  67245. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67246. * * The parameter `points` is an array successive Vector3
  67247. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67248. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67249. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67250. * * 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
  67251. * * When updating an instance, remember that only point positions can change, not the number of points
  67252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67253. * @param name defines the name of the mesh
  67254. * @param options defines the options used to create the mesh
  67255. * @param scene defines the hosting scene
  67256. * @returns the dashed line mesh
  67257. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67258. */
  67259. static CreateDashedLines(name: string, options: {
  67260. points: Vector3[];
  67261. dashSize?: number;
  67262. gapSize?: number;
  67263. dashNb?: number;
  67264. updatable?: boolean;
  67265. instance?: LinesMesh;
  67266. }, scene?: Nullable<Scene>): LinesMesh;
  67267. /**
  67268. * 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.
  67269. * * 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.
  67270. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67271. * * 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.
  67272. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67273. * * 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
  67274. * * 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
  67275. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67277. * * 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
  67278. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67280. * @param name defines the name of the mesh
  67281. * @param options defines the options used to create the mesh
  67282. * @param scene defines the hosting scene
  67283. * @returns the extruded shape mesh
  67284. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67286. */
  67287. static ExtrudeShape(name: string, options: {
  67288. shape: Vector3[];
  67289. path: Vector3[];
  67290. scale?: number;
  67291. rotation?: number;
  67292. cap?: number;
  67293. updatable?: boolean;
  67294. sideOrientation?: number;
  67295. frontUVs?: Vector4;
  67296. backUVs?: Vector4;
  67297. instance?: Mesh;
  67298. invertUV?: boolean;
  67299. }, scene?: Nullable<Scene>): Mesh;
  67300. /**
  67301. * Creates an custom extruded shape mesh.
  67302. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67303. * * 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.
  67304. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67305. * * 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
  67306. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67307. * * 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
  67308. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67309. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67310. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67311. * * 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
  67312. * * 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
  67313. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67315. * * 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
  67316. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67318. * @param name defines the name of the mesh
  67319. * @param options defines the options used to create the mesh
  67320. * @param scene defines the hosting scene
  67321. * @returns the custom extruded shape mesh
  67322. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67323. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67325. */
  67326. static ExtrudeShapeCustom(name: string, options: {
  67327. shape: Vector3[];
  67328. path: Vector3[];
  67329. scaleFunction?: any;
  67330. rotationFunction?: any;
  67331. ribbonCloseArray?: boolean;
  67332. ribbonClosePath?: boolean;
  67333. cap?: number;
  67334. updatable?: boolean;
  67335. sideOrientation?: number;
  67336. frontUVs?: Vector4;
  67337. backUVs?: Vector4;
  67338. instance?: Mesh;
  67339. invertUV?: boolean;
  67340. }, scene?: Nullable<Scene>): Mesh;
  67341. /**
  67342. * Creates lathe mesh.
  67343. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67344. * * 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
  67345. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67346. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67347. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67348. * * 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
  67349. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67350. * * 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
  67351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67352. * * 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
  67353. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67355. * @param name defines the name of the mesh
  67356. * @param options defines the options used to create the mesh
  67357. * @param scene defines the hosting scene
  67358. * @returns the lathe mesh
  67359. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67360. */
  67361. static CreateLathe(name: string, options: {
  67362. shape: Vector3[];
  67363. radius?: number;
  67364. tessellation?: number;
  67365. clip?: number;
  67366. arc?: number;
  67367. closed?: boolean;
  67368. updatable?: boolean;
  67369. sideOrientation?: number;
  67370. frontUVs?: Vector4;
  67371. backUVs?: Vector4;
  67372. cap?: number;
  67373. invertUV?: boolean;
  67374. }, scene?: Nullable<Scene>): Mesh;
  67375. /**
  67376. * Creates a tiled plane mesh
  67377. * * You can set a limited pattern arrangement with the tiles
  67378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67379. * * 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
  67380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67381. * @param name defines the name of the mesh
  67382. * @param options defines the options used to create the mesh
  67383. * @param scene defines the hosting scene
  67384. * @returns the plane mesh
  67385. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67386. */
  67387. static CreateTiledPlane(name: string, options: {
  67388. pattern?: number;
  67389. tileSize?: number;
  67390. tileWidth?: number;
  67391. tileHeight?: number;
  67392. size?: number;
  67393. width?: number;
  67394. height?: number;
  67395. alignHorizontal?: number;
  67396. alignVertical?: number;
  67397. sideOrientation?: number;
  67398. frontUVs?: Vector4;
  67399. backUVs?: Vector4;
  67400. updatable?: boolean;
  67401. }, scene?: Nullable<Scene>): Mesh;
  67402. /**
  67403. * Creates a plane mesh
  67404. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67405. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67406. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67408. * * 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
  67409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67410. * @param name defines the name of the mesh
  67411. * @param options defines the options used to create the mesh
  67412. * @param scene defines the hosting scene
  67413. * @returns the plane mesh
  67414. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67415. */
  67416. static CreatePlane(name: string, options: {
  67417. size?: number;
  67418. width?: number;
  67419. height?: number;
  67420. sideOrientation?: number;
  67421. frontUVs?: Vector4;
  67422. backUVs?: Vector4;
  67423. updatable?: boolean;
  67424. sourcePlane?: Plane;
  67425. }, scene?: Nullable<Scene>): Mesh;
  67426. /**
  67427. * Creates a ground mesh
  67428. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67429. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67431. * @param name defines the name of the mesh
  67432. * @param options defines the options used to create the mesh
  67433. * @param scene defines the hosting scene
  67434. * @returns the ground mesh
  67435. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67436. */
  67437. static CreateGround(name: string, options: {
  67438. width?: number;
  67439. height?: number;
  67440. subdivisions?: number;
  67441. subdivisionsX?: number;
  67442. subdivisionsY?: number;
  67443. updatable?: boolean;
  67444. }, scene?: Nullable<Scene>): Mesh;
  67445. /**
  67446. * Creates a tiled ground mesh
  67447. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67448. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67449. * * 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
  67450. * * 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
  67451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67452. * @param name defines the name of the mesh
  67453. * @param options defines the options used to create the mesh
  67454. * @param scene defines the hosting scene
  67455. * @returns the tiled ground mesh
  67456. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67457. */
  67458. static CreateTiledGround(name: string, options: {
  67459. xmin: number;
  67460. zmin: number;
  67461. xmax: number;
  67462. zmax: number;
  67463. subdivisions?: {
  67464. w: number;
  67465. h: number;
  67466. };
  67467. precision?: {
  67468. w: number;
  67469. h: number;
  67470. };
  67471. updatable?: boolean;
  67472. }, scene?: Nullable<Scene>): Mesh;
  67473. /**
  67474. * Creates a ground mesh from a height map
  67475. * * The parameter `url` sets the URL of the height map image resource.
  67476. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67477. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67478. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67479. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67480. * * 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.
  67481. * * 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).
  67482. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67484. * @param name defines the name of the mesh
  67485. * @param url defines the url to the height map
  67486. * @param options defines the options used to create the mesh
  67487. * @param scene defines the hosting scene
  67488. * @returns the ground mesh
  67489. * @see https://doc.babylonjs.com/babylon101/height_map
  67490. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67491. */
  67492. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67493. width?: number;
  67494. height?: number;
  67495. subdivisions?: number;
  67496. minHeight?: number;
  67497. maxHeight?: number;
  67498. colorFilter?: Color3;
  67499. alphaFilter?: number;
  67500. updatable?: boolean;
  67501. onReady?: (mesh: GroundMesh) => void;
  67502. }, scene?: Nullable<Scene>): GroundMesh;
  67503. /**
  67504. * Creates a polygon mesh
  67505. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67506. * * 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
  67507. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67509. * * 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)
  67510. * * Remember you can only change the shape positions, not their number when updating a polygon
  67511. * @param name defines the name of the mesh
  67512. * @param options defines the options used to create the mesh
  67513. * @param scene defines the hosting scene
  67514. * @param earcutInjection can be used to inject your own earcut reference
  67515. * @returns the polygon mesh
  67516. */
  67517. static CreatePolygon(name: string, options: {
  67518. shape: Vector3[];
  67519. holes?: Vector3[][];
  67520. depth?: number;
  67521. faceUV?: Vector4[];
  67522. faceColors?: Color4[];
  67523. updatable?: boolean;
  67524. sideOrientation?: number;
  67525. frontUVs?: Vector4;
  67526. backUVs?: Vector4;
  67527. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67528. /**
  67529. * Creates an extruded polygon mesh, with depth in the Y direction.
  67530. * * 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)
  67531. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67532. * @param name defines the name of the mesh
  67533. * @param options defines the options used to create the mesh
  67534. * @param scene defines the hosting scene
  67535. * @param earcutInjection can be used to inject your own earcut reference
  67536. * @returns the polygon mesh
  67537. */
  67538. static ExtrudePolygon(name: string, options: {
  67539. shape: Vector3[];
  67540. holes?: Vector3[][];
  67541. depth?: number;
  67542. faceUV?: Vector4[];
  67543. faceColors?: Color4[];
  67544. updatable?: boolean;
  67545. sideOrientation?: number;
  67546. frontUVs?: Vector4;
  67547. backUVs?: Vector4;
  67548. wrap?: boolean;
  67549. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67550. /**
  67551. * Creates a tube mesh.
  67552. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67553. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67554. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67555. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67556. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67557. * * 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)
  67558. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  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 Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  67561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67562. * * 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
  67563. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67565. * @param name defines the name of the mesh
  67566. * @param options defines the options used to create the mesh
  67567. * @param scene defines the hosting scene
  67568. * @returns the tube mesh
  67569. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67570. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67571. */
  67572. static CreateTube(name: string, options: {
  67573. path: Vector3[];
  67574. radius?: number;
  67575. tessellation?: number;
  67576. radiusFunction?: {
  67577. (i: number, distance: number): number;
  67578. };
  67579. cap?: number;
  67580. arc?: number;
  67581. updatable?: boolean;
  67582. sideOrientation?: number;
  67583. frontUVs?: Vector4;
  67584. backUVs?: Vector4;
  67585. instance?: Mesh;
  67586. invertUV?: boolean;
  67587. }, scene?: Nullable<Scene>): Mesh;
  67588. /**
  67589. * Creates a polyhedron mesh
  67590. * * 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
  67591. * * The parameter `size` (positive float, default 1) sets the polygon size
  67592. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67593. * * 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`
  67594. * * 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
  67595. * * 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)`)
  67596. * * 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
  67597. * * 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
  67598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67599. * * 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
  67600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67601. * @param name defines the name of the mesh
  67602. * @param options defines the options used to create the mesh
  67603. * @param scene defines the hosting scene
  67604. * @returns the polyhedron mesh
  67605. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67606. */
  67607. static CreatePolyhedron(name: string, options: {
  67608. type?: number;
  67609. size?: number;
  67610. sizeX?: number;
  67611. sizeY?: number;
  67612. sizeZ?: number;
  67613. custom?: any;
  67614. faceUV?: Vector4[];
  67615. faceColors?: Color4[];
  67616. flat?: boolean;
  67617. updatable?: boolean;
  67618. sideOrientation?: number;
  67619. frontUVs?: Vector4;
  67620. backUVs?: Vector4;
  67621. }, scene?: Nullable<Scene>): Mesh;
  67622. /**
  67623. * Creates a decal mesh.
  67624. * 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
  67625. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67626. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67627. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67628. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67629. * @param name defines the name of the mesh
  67630. * @param sourceMesh defines the mesh where the decal must be applied
  67631. * @param options defines the options used to create the mesh
  67632. * @param scene defines the hosting scene
  67633. * @returns the decal mesh
  67634. * @see https://doc.babylonjs.com/how_to/decals
  67635. */
  67636. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67637. position?: Vector3;
  67638. normal?: Vector3;
  67639. size?: Vector3;
  67640. angle?: number;
  67641. }): Mesh;
  67642. /**
  67643. * Creates a Capsule Mesh
  67644. * @param name defines the name of the mesh.
  67645. * @param options the constructors options used to shape the mesh.
  67646. * @param scene defines the scene the mesh is scoped to.
  67647. * @returns the capsule mesh
  67648. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67649. */
  67650. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67651. }
  67652. }
  67653. declare module BABYLON {
  67654. /**
  67655. * A simplifier interface for future simplification implementations
  67656. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67657. */
  67658. export interface ISimplifier {
  67659. /**
  67660. * Simplification of a given mesh according to the given settings.
  67661. * Since this requires computation, it is assumed that the function runs async.
  67662. * @param settings The settings of the simplification, including quality and distance
  67663. * @param successCallback A callback that will be called after the mesh was simplified.
  67664. * @param errorCallback in case of an error, this callback will be called. optional.
  67665. */
  67666. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67667. }
  67668. /**
  67669. * Expected simplification settings.
  67670. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67671. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67672. */
  67673. export interface ISimplificationSettings {
  67674. /**
  67675. * Gets or sets the expected quality
  67676. */
  67677. quality: number;
  67678. /**
  67679. * Gets or sets the distance when this optimized version should be used
  67680. */
  67681. distance: number;
  67682. /**
  67683. * Gets an already optimized mesh
  67684. */
  67685. optimizeMesh?: boolean;
  67686. }
  67687. /**
  67688. * Class used to specify simplification options
  67689. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67690. */
  67691. export class SimplificationSettings implements ISimplificationSettings {
  67692. /** expected quality */
  67693. quality: number;
  67694. /** distance when this optimized version should be used */
  67695. distance: number;
  67696. /** already optimized mesh */
  67697. optimizeMesh?: boolean | undefined;
  67698. /**
  67699. * Creates a SimplificationSettings
  67700. * @param quality expected quality
  67701. * @param distance distance when this optimized version should be used
  67702. * @param optimizeMesh already optimized mesh
  67703. */
  67704. constructor(
  67705. /** expected quality */
  67706. quality: number,
  67707. /** distance when this optimized version should be used */
  67708. distance: number,
  67709. /** already optimized mesh */
  67710. optimizeMesh?: boolean | undefined);
  67711. }
  67712. /**
  67713. * Interface used to define a simplification task
  67714. */
  67715. export interface ISimplificationTask {
  67716. /**
  67717. * Array of settings
  67718. */
  67719. settings: Array<ISimplificationSettings>;
  67720. /**
  67721. * Simplification type
  67722. */
  67723. simplificationType: SimplificationType;
  67724. /**
  67725. * Mesh to simplify
  67726. */
  67727. mesh: Mesh;
  67728. /**
  67729. * Callback called on success
  67730. */
  67731. successCallback?: () => void;
  67732. /**
  67733. * Defines if parallel processing can be used
  67734. */
  67735. parallelProcessing: boolean;
  67736. }
  67737. /**
  67738. * Queue used to order the simplification tasks
  67739. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67740. */
  67741. export class SimplificationQueue {
  67742. private _simplificationArray;
  67743. /**
  67744. * Gets a boolean indicating that the process is still running
  67745. */
  67746. running: boolean;
  67747. /**
  67748. * Creates a new queue
  67749. */
  67750. constructor();
  67751. /**
  67752. * Adds a new simplification task
  67753. * @param task defines a task to add
  67754. */
  67755. addTask(task: ISimplificationTask): void;
  67756. /**
  67757. * Execute next task
  67758. */
  67759. executeNext(): void;
  67760. /**
  67761. * Execute a simplification task
  67762. * @param task defines the task to run
  67763. */
  67764. runSimplification(task: ISimplificationTask): void;
  67765. private getSimplifier;
  67766. }
  67767. /**
  67768. * The implemented types of simplification
  67769. * At the moment only Quadratic Error Decimation is implemented
  67770. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67771. */
  67772. export enum SimplificationType {
  67773. /** Quadratic error decimation */
  67774. QUADRATIC = 0
  67775. }
  67776. /**
  67777. * An implementation of the Quadratic Error simplification algorithm.
  67778. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67779. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67780. * @author RaananW
  67781. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67782. */
  67783. export class QuadraticErrorSimplification implements ISimplifier {
  67784. private _mesh;
  67785. private triangles;
  67786. private vertices;
  67787. private references;
  67788. private _reconstructedMesh;
  67789. /** Gets or sets the number pf sync interations */
  67790. syncIterations: number;
  67791. /** Gets or sets the aggressiveness of the simplifier */
  67792. aggressiveness: number;
  67793. /** Gets or sets the number of allowed iterations for decimation */
  67794. decimationIterations: number;
  67795. /** Gets or sets the espilon to use for bounding box computation */
  67796. boundingBoxEpsilon: number;
  67797. /**
  67798. * Creates a new QuadraticErrorSimplification
  67799. * @param _mesh defines the target mesh
  67800. */
  67801. constructor(_mesh: Mesh);
  67802. /**
  67803. * Simplification of a given mesh according to the given settings.
  67804. * Since this requires computation, it is assumed that the function runs async.
  67805. * @param settings The settings of the simplification, including quality and distance
  67806. * @param successCallback A callback that will be called after the mesh was simplified.
  67807. */
  67808. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67809. private runDecimation;
  67810. private initWithMesh;
  67811. private init;
  67812. private reconstructMesh;
  67813. private initDecimatedMesh;
  67814. private isFlipped;
  67815. private updateTriangles;
  67816. private identifyBorder;
  67817. private updateMesh;
  67818. private vertexError;
  67819. private calculateError;
  67820. }
  67821. }
  67822. declare module BABYLON {
  67823. interface Scene {
  67824. /** @hidden (Backing field) */
  67825. _simplificationQueue: SimplificationQueue;
  67826. /**
  67827. * Gets or sets the simplification queue attached to the scene
  67828. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67829. */
  67830. simplificationQueue: SimplificationQueue;
  67831. }
  67832. interface Mesh {
  67833. /**
  67834. * Simplify the mesh according to the given array of settings.
  67835. * Function will return immediately and will simplify async
  67836. * @param settings a collection of simplification settings
  67837. * @param parallelProcessing should all levels calculate parallel or one after the other
  67838. * @param simplificationType the type of simplification to run
  67839. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67840. * @returns the current mesh
  67841. */
  67842. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67843. }
  67844. /**
  67845. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67846. * created in a scene
  67847. */
  67848. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67849. /**
  67850. * The component name helpfull to identify the component in the list of scene components.
  67851. */
  67852. readonly name: string;
  67853. /**
  67854. * The scene the component belongs to.
  67855. */
  67856. scene: Scene;
  67857. /**
  67858. * Creates a new instance of the component for the given scene
  67859. * @param scene Defines the scene to register the component in
  67860. */
  67861. constructor(scene: Scene);
  67862. /**
  67863. * Registers the component in a given scene
  67864. */
  67865. register(): void;
  67866. /**
  67867. * Rebuilds the elements related to this component in case of
  67868. * context lost for instance.
  67869. */
  67870. rebuild(): void;
  67871. /**
  67872. * Disposes the component and the associated ressources
  67873. */
  67874. dispose(): void;
  67875. private _beforeCameraUpdate;
  67876. }
  67877. }
  67878. declare module BABYLON {
  67879. interface Mesh {
  67880. /**
  67881. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67882. */
  67883. thinInstanceEnablePicking: boolean;
  67884. /**
  67885. * Creates a new thin instance
  67886. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67887. * @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
  67888. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67889. */
  67890. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67891. /**
  67892. * Adds the transformation (matrix) of the current mesh as a thin instance
  67893. * @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
  67894. * @returns the thin instance index number
  67895. */
  67896. thinInstanceAddSelf(refresh: boolean): number;
  67897. /**
  67898. * Registers a custom attribute to be used with thin instances
  67899. * @param kind name of the attribute
  67900. * @param stride size in floats of the attribute
  67901. */
  67902. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67903. /**
  67904. * Sets the matrix of a thin instance
  67905. * @param index index of the thin instance
  67906. * @param matrix matrix to set
  67907. * @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
  67908. */
  67909. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67910. /**
  67911. * Sets the value of a custom attribute for a thin instance
  67912. * @param kind name of the attribute
  67913. * @param index index of the thin instance
  67914. * @param value value to set
  67915. * @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
  67916. */
  67917. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67918. /**
  67919. * 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.
  67920. */
  67921. thinInstanceCount: number;
  67922. /**
  67923. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67924. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67925. * @param buffer buffer to set
  67926. * @param stride size in floats of each value of the buffer
  67927. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67928. */
  67929. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67930. /**
  67931. * Gets the list of world matrices
  67932. * @return an array containing all the world matrices from the thin instances
  67933. */
  67934. thinInstanceGetWorldMatrices(): Matrix[];
  67935. /**
  67936. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67937. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67938. */
  67939. thinInstanceBufferUpdated(kind: string): void;
  67940. /**
  67941. * Applies a partial update to a buffer directly on the GPU
  67942. * 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
  67943. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67944. * @param data the data to set in the GPU buffer
  67945. * @param offset the offset in the GPU buffer where to update the data
  67946. */
  67947. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67948. /**
  67949. * Refreshes the bounding info, taking into account all the thin instances defined
  67950. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67951. */
  67952. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67953. /** @hidden */
  67954. _thinInstanceInitializeUserStorage(): void;
  67955. /** @hidden */
  67956. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67957. /** @hidden */
  67958. _userThinInstanceBuffersStorage: {
  67959. data: {
  67960. [key: string]: Float32Array;
  67961. };
  67962. sizes: {
  67963. [key: string]: number;
  67964. };
  67965. vertexBuffers: {
  67966. [key: string]: Nullable<VertexBuffer>;
  67967. };
  67968. strides: {
  67969. [key: string]: number;
  67970. };
  67971. };
  67972. }
  67973. }
  67974. declare module BABYLON {
  67975. /**
  67976. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67977. */
  67978. export interface INavigationEnginePlugin {
  67979. /**
  67980. * plugin name
  67981. */
  67982. name: string;
  67983. /**
  67984. * Creates a navigation mesh
  67985. * @param meshes array of all the geometry used to compute the navigatio mesh
  67986. * @param parameters bunch of parameters used to filter geometry
  67987. */
  67988. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67989. /**
  67990. * Create a navigation mesh debug mesh
  67991. * @param scene is where the mesh will be added
  67992. * @returns debug display mesh
  67993. */
  67994. createDebugNavMesh(scene: Scene): Mesh;
  67995. /**
  67996. * Get a navigation mesh constrained position, closest to the parameter position
  67997. * @param position world position
  67998. * @returns the closest point to position constrained by the navigation mesh
  67999. */
  68000. getClosestPoint(position: Vector3): Vector3;
  68001. /**
  68002. * Get a navigation mesh constrained position, closest to the parameter position
  68003. * @param position world position
  68004. * @param result output the closest point to position constrained by the navigation mesh
  68005. */
  68006. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68007. /**
  68008. * Get a navigation mesh constrained position, within a particular radius
  68009. * @param position world position
  68010. * @param maxRadius the maximum distance to the constrained world position
  68011. * @returns the closest point to position constrained by the navigation mesh
  68012. */
  68013. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68014. /**
  68015. * Get a navigation mesh constrained position, within a particular radius
  68016. * @param position world position
  68017. * @param maxRadius the maximum distance to the constrained world position
  68018. * @param result output the closest point to position constrained by the navigation mesh
  68019. */
  68020. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68021. /**
  68022. * Compute the final position from a segment made of destination-position
  68023. * @param position world position
  68024. * @param destination world position
  68025. * @returns the resulting point along the navmesh
  68026. */
  68027. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68028. /**
  68029. * Compute the final position from a segment made of destination-position
  68030. * @param position world position
  68031. * @param destination world position
  68032. * @param result output the resulting point along the navmesh
  68033. */
  68034. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68035. /**
  68036. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68037. * @param start world position
  68038. * @param end world position
  68039. * @returns array containing world position composing the path
  68040. */
  68041. computePath(start: Vector3, end: Vector3): Vector3[];
  68042. /**
  68043. * If this plugin is supported
  68044. * @returns true if plugin is supported
  68045. */
  68046. isSupported(): boolean;
  68047. /**
  68048. * Create a new Crowd so you can add agents
  68049. * @param maxAgents the maximum agent count in the crowd
  68050. * @param maxAgentRadius the maximum radius an agent can have
  68051. * @param scene to attach the crowd to
  68052. * @returns the crowd you can add agents to
  68053. */
  68054. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68055. /**
  68056. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68057. * The queries will try to find a solution within those bounds
  68058. * default is (1,1,1)
  68059. * @param extent x,y,z value that define the extent around the queries point of reference
  68060. */
  68061. setDefaultQueryExtent(extent: Vector3): void;
  68062. /**
  68063. * Get the Bounding box extent specified by setDefaultQueryExtent
  68064. * @returns the box extent values
  68065. */
  68066. getDefaultQueryExtent(): Vector3;
  68067. /**
  68068. * build the navmesh from a previously saved state using getNavmeshData
  68069. * @param data the Uint8Array returned by getNavmeshData
  68070. */
  68071. buildFromNavmeshData(data: Uint8Array): void;
  68072. /**
  68073. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68074. * @returns data the Uint8Array that can be saved and reused
  68075. */
  68076. getNavmeshData(): Uint8Array;
  68077. /**
  68078. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68079. * @param result output the box extent values
  68080. */
  68081. getDefaultQueryExtentToRef(result: Vector3): void;
  68082. /**
  68083. * Release all resources
  68084. */
  68085. dispose(): void;
  68086. }
  68087. /**
  68088. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68089. */
  68090. export interface ICrowd {
  68091. /**
  68092. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68093. * You can attach anything to that node. The node position is updated in the scene update tick.
  68094. * @param pos world position that will be constrained by the navigation mesh
  68095. * @param parameters agent parameters
  68096. * @param transform hooked to the agent that will be update by the scene
  68097. * @returns agent index
  68098. */
  68099. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68100. /**
  68101. * Returns the agent position in world space
  68102. * @param index agent index returned by addAgent
  68103. * @returns world space position
  68104. */
  68105. getAgentPosition(index: number): Vector3;
  68106. /**
  68107. * Gets the agent position result in world space
  68108. * @param index agent index returned by addAgent
  68109. * @param result output world space position
  68110. */
  68111. getAgentPositionToRef(index: number, result: Vector3): void;
  68112. /**
  68113. * Gets the agent velocity in world space
  68114. * @param index agent index returned by addAgent
  68115. * @returns world space velocity
  68116. */
  68117. getAgentVelocity(index: number): Vector3;
  68118. /**
  68119. * Gets the agent velocity result in world space
  68120. * @param index agent index returned by addAgent
  68121. * @param result output world space velocity
  68122. */
  68123. getAgentVelocityToRef(index: number, result: Vector3): void;
  68124. /**
  68125. * Gets the agent next target point on the path
  68126. * @param index agent index returned by addAgent
  68127. * @returns world space position
  68128. */
  68129. getAgentNextTargetPath(index: number): Vector3;
  68130. /**
  68131. * Gets the agent state
  68132. * @param index agent index returned by addAgent
  68133. * @returns agent state
  68134. */
  68135. getAgentState(index: number): number;
  68136. /**
  68137. * returns true if the agent in over an off mesh link connection
  68138. * @param index agent index returned by addAgent
  68139. * @returns true if over an off mesh link connection
  68140. */
  68141. overOffmeshConnection(index: number): boolean;
  68142. /**
  68143. * Gets the agent next target point on the path
  68144. * @param index agent index returned by addAgent
  68145. * @param result output world space position
  68146. */
  68147. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68148. /**
  68149. * remove a particular agent previously created
  68150. * @param index agent index returned by addAgent
  68151. */
  68152. removeAgent(index: number): void;
  68153. /**
  68154. * get the list of all agents attached to this crowd
  68155. * @returns list of agent indices
  68156. */
  68157. getAgents(): number[];
  68158. /**
  68159. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68160. * @param deltaTime in seconds
  68161. */
  68162. update(deltaTime: number): void;
  68163. /**
  68164. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68165. * @param index agent index returned by addAgent
  68166. * @param destination targeted world position
  68167. */
  68168. agentGoto(index: number, destination: Vector3): void;
  68169. /**
  68170. * Teleport the agent to a new position
  68171. * @param index agent index returned by addAgent
  68172. * @param destination targeted world position
  68173. */
  68174. agentTeleport(index: number, destination: Vector3): void;
  68175. /**
  68176. * Update agent parameters
  68177. * @param index agent index returned by addAgent
  68178. * @param parameters agent parameters
  68179. */
  68180. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68181. /**
  68182. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68183. * The queries will try to find a solution within those bounds
  68184. * default is (1,1,1)
  68185. * @param extent x,y,z value that define the extent around the queries point of reference
  68186. */
  68187. setDefaultQueryExtent(extent: Vector3): void;
  68188. /**
  68189. * Get the Bounding box extent specified by setDefaultQueryExtent
  68190. * @returns the box extent values
  68191. */
  68192. getDefaultQueryExtent(): Vector3;
  68193. /**
  68194. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68195. * @param result output the box extent values
  68196. */
  68197. getDefaultQueryExtentToRef(result: Vector3): void;
  68198. /**
  68199. * Release all resources
  68200. */
  68201. dispose(): void;
  68202. }
  68203. /**
  68204. * Configures an agent
  68205. */
  68206. export interface IAgentParameters {
  68207. /**
  68208. * Agent radius. [Limit: >= 0]
  68209. */
  68210. radius: number;
  68211. /**
  68212. * Agent height. [Limit: > 0]
  68213. */
  68214. height: number;
  68215. /**
  68216. * Maximum allowed acceleration. [Limit: >= 0]
  68217. */
  68218. maxAcceleration: number;
  68219. /**
  68220. * Maximum allowed speed. [Limit: >= 0]
  68221. */
  68222. maxSpeed: number;
  68223. /**
  68224. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68225. */
  68226. collisionQueryRange: number;
  68227. /**
  68228. * The path visibility optimization range. [Limit: > 0]
  68229. */
  68230. pathOptimizationRange: number;
  68231. /**
  68232. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68233. */
  68234. separationWeight: number;
  68235. }
  68236. /**
  68237. * Configures the navigation mesh creation
  68238. */
  68239. export interface INavMeshParameters {
  68240. /**
  68241. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68242. */
  68243. cs: number;
  68244. /**
  68245. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68246. */
  68247. ch: number;
  68248. /**
  68249. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68250. */
  68251. walkableSlopeAngle: number;
  68252. /**
  68253. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68254. * be considered walkable. [Limit: >= 3] [Units: vx]
  68255. */
  68256. walkableHeight: number;
  68257. /**
  68258. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68259. */
  68260. walkableClimb: number;
  68261. /**
  68262. * The distance to erode/shrink the walkable area of the heightfield away from
  68263. * obstructions. [Limit: >=0] [Units: vx]
  68264. */
  68265. walkableRadius: number;
  68266. /**
  68267. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68268. */
  68269. maxEdgeLen: number;
  68270. /**
  68271. * The maximum distance a simplfied contour's border edges should deviate
  68272. * the original raw contour. [Limit: >=0] [Units: vx]
  68273. */
  68274. maxSimplificationError: number;
  68275. /**
  68276. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68277. */
  68278. minRegionArea: number;
  68279. /**
  68280. * Any regions with a span count smaller than this value will, if possible,
  68281. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68282. */
  68283. mergeRegionArea: number;
  68284. /**
  68285. * The maximum number of vertices allowed for polygons generated during the
  68286. * contour to polygon conversion process. [Limit: >= 3]
  68287. */
  68288. maxVertsPerPoly: number;
  68289. /**
  68290. * Sets the sampling distance to use when generating the detail mesh.
  68291. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68292. */
  68293. detailSampleDist: number;
  68294. /**
  68295. * The maximum distance the detail mesh surface should deviate from heightfield
  68296. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68297. */
  68298. detailSampleMaxError: number;
  68299. }
  68300. }
  68301. declare module BABYLON {
  68302. /**
  68303. * RecastJS navigation plugin
  68304. */
  68305. export class RecastJSPlugin implements INavigationEnginePlugin {
  68306. /**
  68307. * Reference to the Recast library
  68308. */
  68309. bjsRECAST: any;
  68310. /**
  68311. * plugin name
  68312. */
  68313. name: string;
  68314. /**
  68315. * the first navmesh created. We might extend this to support multiple navmeshes
  68316. */
  68317. navMesh: any;
  68318. /**
  68319. * Initializes the recastJS plugin
  68320. * @param recastInjection can be used to inject your own recast reference
  68321. */
  68322. constructor(recastInjection?: any);
  68323. /**
  68324. * Creates a navigation mesh
  68325. * @param meshes array of all the geometry used to compute the navigatio mesh
  68326. * @param parameters bunch of parameters used to filter geometry
  68327. */
  68328. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68329. /**
  68330. * Create a navigation mesh debug mesh
  68331. * @param scene is where the mesh will be added
  68332. * @returns debug display mesh
  68333. */
  68334. createDebugNavMesh(scene: Scene): Mesh;
  68335. /**
  68336. * Get a navigation mesh constrained position, closest to the parameter position
  68337. * @param position world position
  68338. * @returns the closest point to position constrained by the navigation mesh
  68339. */
  68340. getClosestPoint(position: Vector3): Vector3;
  68341. /**
  68342. * Get a navigation mesh constrained position, closest to the parameter position
  68343. * @param position world position
  68344. * @param result output the closest point to position constrained by the navigation mesh
  68345. */
  68346. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68347. /**
  68348. * Get a navigation mesh constrained position, within a particular radius
  68349. * @param position world position
  68350. * @param maxRadius the maximum distance to the constrained world position
  68351. * @returns the closest point to position constrained by the navigation mesh
  68352. */
  68353. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68354. /**
  68355. * Get a navigation mesh constrained position, within a particular radius
  68356. * @param position world position
  68357. * @param maxRadius the maximum distance to the constrained world position
  68358. * @param result output the closest point to position constrained by the navigation mesh
  68359. */
  68360. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68361. /**
  68362. * Compute the final position from a segment made of destination-position
  68363. * @param position world position
  68364. * @param destination world position
  68365. * @returns the resulting point along the navmesh
  68366. */
  68367. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68368. /**
  68369. * Compute the final position from a segment made of destination-position
  68370. * @param position world position
  68371. * @param destination world position
  68372. * @param result output the resulting point along the navmesh
  68373. */
  68374. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68375. /**
  68376. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68377. * @param start world position
  68378. * @param end world position
  68379. * @returns array containing world position composing the path
  68380. */
  68381. computePath(start: Vector3, end: Vector3): Vector3[];
  68382. /**
  68383. * Create a new Crowd so you can add agents
  68384. * @param maxAgents the maximum agent count in the crowd
  68385. * @param maxAgentRadius the maximum radius an agent can have
  68386. * @param scene to attach the crowd to
  68387. * @returns the crowd you can add agents to
  68388. */
  68389. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68390. /**
  68391. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68392. * The queries will try to find a solution within those bounds
  68393. * default is (1,1,1)
  68394. * @param extent x,y,z value that define the extent around the queries point of reference
  68395. */
  68396. setDefaultQueryExtent(extent: Vector3): void;
  68397. /**
  68398. * Get the Bounding box extent specified by setDefaultQueryExtent
  68399. * @returns the box extent values
  68400. */
  68401. getDefaultQueryExtent(): Vector3;
  68402. /**
  68403. * build the navmesh from a previously saved state using getNavmeshData
  68404. * @param data the Uint8Array returned by getNavmeshData
  68405. */
  68406. buildFromNavmeshData(data: Uint8Array): void;
  68407. /**
  68408. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68409. * @returns data the Uint8Array that can be saved and reused
  68410. */
  68411. getNavmeshData(): Uint8Array;
  68412. /**
  68413. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68414. * @param result output the box extent values
  68415. */
  68416. getDefaultQueryExtentToRef(result: Vector3): void;
  68417. /**
  68418. * Disposes
  68419. */
  68420. dispose(): void;
  68421. /**
  68422. * If this plugin is supported
  68423. * @returns true if plugin is supported
  68424. */
  68425. isSupported(): boolean;
  68426. }
  68427. /**
  68428. * Recast detour crowd implementation
  68429. */
  68430. export class RecastJSCrowd implements ICrowd {
  68431. /**
  68432. * Recast/detour plugin
  68433. */
  68434. bjsRECASTPlugin: RecastJSPlugin;
  68435. /**
  68436. * Link to the detour crowd
  68437. */
  68438. recastCrowd: any;
  68439. /**
  68440. * One transform per agent
  68441. */
  68442. transforms: TransformNode[];
  68443. /**
  68444. * All agents created
  68445. */
  68446. agents: number[];
  68447. /**
  68448. * Link to the scene is kept to unregister the crowd from the scene
  68449. */
  68450. private _scene;
  68451. /**
  68452. * Observer for crowd updates
  68453. */
  68454. private _onBeforeAnimationsObserver;
  68455. /**
  68456. * Constructor
  68457. * @param plugin recastJS plugin
  68458. * @param maxAgents the maximum agent count in the crowd
  68459. * @param maxAgentRadius the maximum radius an agent can have
  68460. * @param scene to attach the crowd to
  68461. * @returns the crowd you can add agents to
  68462. */
  68463. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68464. /**
  68465. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68466. * You can attach anything to that node. The node position is updated in the scene update tick.
  68467. * @param pos world position that will be constrained by the navigation mesh
  68468. * @param parameters agent parameters
  68469. * @param transform hooked to the agent that will be update by the scene
  68470. * @returns agent index
  68471. */
  68472. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68473. /**
  68474. * Returns the agent position in world space
  68475. * @param index agent index returned by addAgent
  68476. * @returns world space position
  68477. */
  68478. getAgentPosition(index: number): Vector3;
  68479. /**
  68480. * Returns the agent position result in world space
  68481. * @param index agent index returned by addAgent
  68482. * @param result output world space position
  68483. */
  68484. getAgentPositionToRef(index: number, result: Vector3): void;
  68485. /**
  68486. * Returns the agent velocity in world space
  68487. * @param index agent index returned by addAgent
  68488. * @returns world space velocity
  68489. */
  68490. getAgentVelocity(index: number): Vector3;
  68491. /**
  68492. * Returns the agent velocity result in world space
  68493. * @param index agent index returned by addAgent
  68494. * @param result output world space velocity
  68495. */
  68496. getAgentVelocityToRef(index: number, result: Vector3): void;
  68497. /**
  68498. * Returns the agent next target point on the path
  68499. * @param index agent index returned by addAgent
  68500. * @returns world space position
  68501. */
  68502. getAgentNextTargetPath(index: number): Vector3;
  68503. /**
  68504. * Returns the agent next target point on the path
  68505. * @param index agent index returned by addAgent
  68506. * @param result output world space position
  68507. */
  68508. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68509. /**
  68510. * Gets the agent state
  68511. * @param index agent index returned by addAgent
  68512. * @returns agent state
  68513. */
  68514. getAgentState(index: number): number;
  68515. /**
  68516. * returns true if the agent in over an off mesh link connection
  68517. * @param index agent index returned by addAgent
  68518. * @returns true if over an off mesh link connection
  68519. */
  68520. overOffmeshConnection(index: number): boolean;
  68521. /**
  68522. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68523. * @param index agent index returned by addAgent
  68524. * @param destination targeted world position
  68525. */
  68526. agentGoto(index: number, destination: Vector3): void;
  68527. /**
  68528. * Teleport the agent to a new position
  68529. * @param index agent index returned by addAgent
  68530. * @param destination targeted world position
  68531. */
  68532. agentTeleport(index: number, destination: Vector3): void;
  68533. /**
  68534. * Update agent parameters
  68535. * @param index agent index returned by addAgent
  68536. * @param parameters agent parameters
  68537. */
  68538. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68539. /**
  68540. * remove a particular agent previously created
  68541. * @param index agent index returned by addAgent
  68542. */
  68543. removeAgent(index: number): void;
  68544. /**
  68545. * get the list of all agents attached to this crowd
  68546. * @returns list of agent indices
  68547. */
  68548. getAgents(): number[];
  68549. /**
  68550. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68551. * @param deltaTime in seconds
  68552. */
  68553. update(deltaTime: number): void;
  68554. /**
  68555. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68556. * The queries will try to find a solution within those bounds
  68557. * default is (1,1,1)
  68558. * @param extent x,y,z value that define the extent around the queries point of reference
  68559. */
  68560. setDefaultQueryExtent(extent: Vector3): void;
  68561. /**
  68562. * Get the Bounding box extent specified by setDefaultQueryExtent
  68563. * @returns the box extent values
  68564. */
  68565. getDefaultQueryExtent(): Vector3;
  68566. /**
  68567. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68568. * @param result output the box extent values
  68569. */
  68570. getDefaultQueryExtentToRef(result: Vector3): void;
  68571. /**
  68572. * Release all resources
  68573. */
  68574. dispose(): void;
  68575. }
  68576. }
  68577. declare module BABYLON {
  68578. /**
  68579. * Class used to enable access to IndexedDB
  68580. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68581. */
  68582. export class Database implements IOfflineProvider {
  68583. private _callbackManifestChecked;
  68584. private _currentSceneUrl;
  68585. private _db;
  68586. private _enableSceneOffline;
  68587. private _enableTexturesOffline;
  68588. private _manifestVersionFound;
  68589. private _mustUpdateRessources;
  68590. private _hasReachedQuota;
  68591. private _isSupported;
  68592. private _idbFactory;
  68593. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68594. private static IsUASupportingBlobStorage;
  68595. /**
  68596. * Gets a boolean indicating if Database storate is enabled (off by default)
  68597. */
  68598. static IDBStorageEnabled: boolean;
  68599. /**
  68600. * Gets a boolean indicating if scene must be saved in the database
  68601. */
  68602. get enableSceneOffline(): boolean;
  68603. /**
  68604. * Gets a boolean indicating if textures must be saved in the database
  68605. */
  68606. get enableTexturesOffline(): boolean;
  68607. /**
  68608. * Creates a new Database
  68609. * @param urlToScene defines the url to load the scene
  68610. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68611. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68612. */
  68613. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68614. private static _ParseURL;
  68615. private static _ReturnFullUrlLocation;
  68616. private _checkManifestFile;
  68617. /**
  68618. * Open the database and make it available
  68619. * @param successCallback defines the callback to call on success
  68620. * @param errorCallback defines the callback to call on error
  68621. */
  68622. open(successCallback: () => void, errorCallback: () => void): void;
  68623. /**
  68624. * Loads an image from the database
  68625. * @param url defines the url to load from
  68626. * @param image defines the target DOM image
  68627. */
  68628. loadImage(url: string, image: HTMLImageElement): void;
  68629. private _loadImageFromDBAsync;
  68630. private _saveImageIntoDBAsync;
  68631. private _checkVersionFromDB;
  68632. private _loadVersionFromDBAsync;
  68633. private _saveVersionIntoDBAsync;
  68634. /**
  68635. * Loads a file from database
  68636. * @param url defines the URL to load from
  68637. * @param sceneLoaded defines a callback to call on success
  68638. * @param progressCallBack defines a callback to call when progress changed
  68639. * @param errorCallback defines a callback to call on error
  68640. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68641. */
  68642. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68643. private _loadFileAsync;
  68644. private _saveFileAsync;
  68645. /**
  68646. * Validates if xhr data is correct
  68647. * @param xhr defines the request to validate
  68648. * @param dataType defines the expected data type
  68649. * @returns true if data is correct
  68650. */
  68651. private static _ValidateXHRData;
  68652. }
  68653. }
  68654. declare module BABYLON {
  68655. /** @hidden */
  68656. export var gpuUpdateParticlesPixelShader: {
  68657. name: string;
  68658. shader: string;
  68659. };
  68660. }
  68661. declare module BABYLON {
  68662. /** @hidden */
  68663. export var gpuUpdateParticlesVertexShader: {
  68664. name: string;
  68665. shader: string;
  68666. };
  68667. }
  68668. declare module BABYLON {
  68669. /** @hidden */
  68670. export var clipPlaneFragmentDeclaration2: {
  68671. name: string;
  68672. shader: string;
  68673. };
  68674. }
  68675. declare module BABYLON {
  68676. /** @hidden */
  68677. export var gpuRenderParticlesPixelShader: {
  68678. name: string;
  68679. shader: string;
  68680. };
  68681. }
  68682. declare module BABYLON {
  68683. /** @hidden */
  68684. export var clipPlaneVertexDeclaration2: {
  68685. name: string;
  68686. shader: string;
  68687. };
  68688. }
  68689. declare module BABYLON {
  68690. /** @hidden */
  68691. export var gpuRenderParticlesVertexShader: {
  68692. name: string;
  68693. shader: string;
  68694. };
  68695. }
  68696. declare module BABYLON {
  68697. /**
  68698. * This represents a GPU particle system in Babylon
  68699. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68700. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68701. */
  68702. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68703. /**
  68704. * The layer mask we are rendering the particles through.
  68705. */
  68706. layerMask: number;
  68707. private _capacity;
  68708. private _activeCount;
  68709. private _currentActiveCount;
  68710. private _accumulatedCount;
  68711. private _renderEffect;
  68712. private _updateEffect;
  68713. private _buffer0;
  68714. private _buffer1;
  68715. private _spriteBuffer;
  68716. private _updateVAO;
  68717. private _renderVAO;
  68718. private _targetIndex;
  68719. private _sourceBuffer;
  68720. private _targetBuffer;
  68721. private _currentRenderId;
  68722. private _started;
  68723. private _stopped;
  68724. private _timeDelta;
  68725. private _randomTexture;
  68726. private _randomTexture2;
  68727. private _attributesStrideSize;
  68728. private _updateEffectOptions;
  68729. private _randomTextureSize;
  68730. private _actualFrame;
  68731. private _customEffect;
  68732. private readonly _rawTextureWidth;
  68733. /**
  68734. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68735. */
  68736. static get IsSupported(): boolean;
  68737. /**
  68738. * An event triggered when the system is disposed.
  68739. */
  68740. onDisposeObservable: Observable<IParticleSystem>;
  68741. /**
  68742. * An event triggered when the system is stopped
  68743. */
  68744. onStoppedObservable: Observable<IParticleSystem>;
  68745. /**
  68746. * Gets the maximum number of particles active at the same time.
  68747. * @returns The max number of active particles.
  68748. */
  68749. getCapacity(): number;
  68750. /**
  68751. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68752. * to override the particles.
  68753. */
  68754. forceDepthWrite: boolean;
  68755. /**
  68756. * Gets or set the number of active particles
  68757. */
  68758. get activeParticleCount(): number;
  68759. set activeParticleCount(value: number);
  68760. private _preWarmDone;
  68761. /**
  68762. * Specifies if the particles are updated in emitter local space or world space.
  68763. */
  68764. isLocal: boolean;
  68765. /** Gets or sets a matrix to use to compute projection */
  68766. defaultProjectionMatrix: Matrix;
  68767. /**
  68768. * Is this system ready to be used/rendered
  68769. * @return true if the system is ready
  68770. */
  68771. isReady(): boolean;
  68772. /**
  68773. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68774. * @returns True if it has been started, otherwise false.
  68775. */
  68776. isStarted(): boolean;
  68777. /**
  68778. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68779. * @returns True if it has been stopped, otherwise false.
  68780. */
  68781. isStopped(): boolean;
  68782. /**
  68783. * Gets a boolean indicating that the system is stopping
  68784. * @returns true if the system is currently stopping
  68785. */
  68786. isStopping(): boolean;
  68787. /**
  68788. * Gets the number of particles active at the same time.
  68789. * @returns The number of active particles.
  68790. */
  68791. getActiveCount(): number;
  68792. /**
  68793. * Starts the particle system and begins to emit
  68794. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68795. */
  68796. start(delay?: number): void;
  68797. /**
  68798. * Stops the particle system.
  68799. */
  68800. stop(): void;
  68801. /**
  68802. * Remove all active particles
  68803. */
  68804. reset(): void;
  68805. /**
  68806. * Returns the string "GPUParticleSystem"
  68807. * @returns a string containing the class name
  68808. */
  68809. getClassName(): string;
  68810. /**
  68811. * Gets the custom effect used to render the particles
  68812. * @param blendMode Blend mode for which the effect should be retrieved
  68813. * @returns The effect
  68814. */
  68815. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68816. /**
  68817. * Sets the custom effect used to render the particles
  68818. * @param effect The effect to set
  68819. * @param blendMode Blend mode for which the effect should be set
  68820. */
  68821. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68822. /** @hidden */
  68823. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68824. /**
  68825. * Observable that will be called just before the particles are drawn
  68826. */
  68827. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68828. /**
  68829. * Gets the name of the particle vertex shader
  68830. */
  68831. get vertexShaderName(): string;
  68832. private _colorGradientsTexture;
  68833. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68834. /**
  68835. * Adds a new color gradient
  68836. * @param gradient defines the gradient to use (between 0 and 1)
  68837. * @param color1 defines the color to affect to the specified gradient
  68838. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68839. * @returns the current particle system
  68840. */
  68841. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68842. private _refreshColorGradient;
  68843. /** Force the system to rebuild all gradients that need to be resync */
  68844. forceRefreshGradients(): void;
  68845. /**
  68846. * Remove a specific color gradient
  68847. * @param gradient defines the gradient to remove
  68848. * @returns the current particle system
  68849. */
  68850. removeColorGradient(gradient: number): GPUParticleSystem;
  68851. private _angularSpeedGradientsTexture;
  68852. private _sizeGradientsTexture;
  68853. private _velocityGradientsTexture;
  68854. private _limitVelocityGradientsTexture;
  68855. private _dragGradientsTexture;
  68856. private _addFactorGradient;
  68857. /**
  68858. * Adds a new size gradient
  68859. * @param gradient defines the gradient to use (between 0 and 1)
  68860. * @param factor defines the size factor to affect to the specified gradient
  68861. * @returns the current particle system
  68862. */
  68863. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68864. /**
  68865. * Remove a specific size gradient
  68866. * @param gradient defines the gradient to remove
  68867. * @returns the current particle system
  68868. */
  68869. removeSizeGradient(gradient: number): GPUParticleSystem;
  68870. private _refreshFactorGradient;
  68871. /**
  68872. * Adds a new angular speed gradient
  68873. * @param gradient defines the gradient to use (between 0 and 1)
  68874. * @param factor defines the angular speed to affect to the specified gradient
  68875. * @returns the current particle system
  68876. */
  68877. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68878. /**
  68879. * Remove a specific angular speed gradient
  68880. * @param gradient defines the gradient to remove
  68881. * @returns the current particle system
  68882. */
  68883. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68884. /**
  68885. * Adds a new velocity gradient
  68886. * @param gradient defines the gradient to use (between 0 and 1)
  68887. * @param factor defines the velocity to affect to the specified gradient
  68888. * @returns the current particle system
  68889. */
  68890. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68891. /**
  68892. * Remove a specific velocity gradient
  68893. * @param gradient defines the gradient to remove
  68894. * @returns the current particle system
  68895. */
  68896. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68897. /**
  68898. * Adds a new limit velocity gradient
  68899. * @param gradient defines the gradient to use (between 0 and 1)
  68900. * @param factor defines the limit velocity value to affect to the specified gradient
  68901. * @returns the current particle system
  68902. */
  68903. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68904. /**
  68905. * Remove a specific limit velocity gradient
  68906. * @param gradient defines the gradient to remove
  68907. * @returns the current particle system
  68908. */
  68909. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68910. /**
  68911. * Adds a new drag gradient
  68912. * @param gradient defines the gradient to use (between 0 and 1)
  68913. * @param factor defines the drag value to affect to the specified gradient
  68914. * @returns the current particle system
  68915. */
  68916. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68917. /**
  68918. * Remove a specific drag gradient
  68919. * @param gradient defines the gradient to remove
  68920. * @returns the current particle system
  68921. */
  68922. removeDragGradient(gradient: number): GPUParticleSystem;
  68923. /**
  68924. * Not supported by GPUParticleSystem
  68925. * @param gradient defines the gradient to use (between 0 and 1)
  68926. * @param factor defines the emit rate value to affect to the specified gradient
  68927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68928. * @returns the current particle system
  68929. */
  68930. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68931. /**
  68932. * Not supported by GPUParticleSystem
  68933. * @param gradient defines the gradient to remove
  68934. * @returns the current particle system
  68935. */
  68936. removeEmitRateGradient(gradient: number): IParticleSystem;
  68937. /**
  68938. * Not supported by GPUParticleSystem
  68939. * @param gradient defines the gradient to use (between 0 and 1)
  68940. * @param factor defines the start size value to affect to the specified gradient
  68941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68942. * @returns the current particle system
  68943. */
  68944. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68945. /**
  68946. * Not supported by GPUParticleSystem
  68947. * @param gradient defines the gradient to remove
  68948. * @returns the current particle system
  68949. */
  68950. removeStartSizeGradient(gradient: number): IParticleSystem;
  68951. /**
  68952. * Not supported by GPUParticleSystem
  68953. * @param gradient defines the gradient to use (between 0 and 1)
  68954. * @param min defines the color remap minimal range
  68955. * @param max defines the color remap maximal range
  68956. * @returns the current particle system
  68957. */
  68958. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68959. /**
  68960. * Not supported by GPUParticleSystem
  68961. * @param gradient defines the gradient to remove
  68962. * @returns the current particle system
  68963. */
  68964. removeColorRemapGradient(): IParticleSystem;
  68965. /**
  68966. * Not supported by GPUParticleSystem
  68967. * @param gradient defines the gradient to use (between 0 and 1)
  68968. * @param min defines the alpha remap minimal range
  68969. * @param max defines the alpha remap maximal range
  68970. * @returns the current particle system
  68971. */
  68972. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68973. /**
  68974. * Not supported by GPUParticleSystem
  68975. * @param gradient defines the gradient to remove
  68976. * @returns the current particle system
  68977. */
  68978. removeAlphaRemapGradient(): IParticleSystem;
  68979. /**
  68980. * Not supported by GPUParticleSystem
  68981. * @param gradient defines the gradient to use (between 0 and 1)
  68982. * @param color defines the color to affect to the specified gradient
  68983. * @returns the current particle system
  68984. */
  68985. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68986. /**
  68987. * Not supported by GPUParticleSystem
  68988. * @param gradient defines the gradient to remove
  68989. * @returns the current particle system
  68990. */
  68991. removeRampGradient(): IParticleSystem;
  68992. /**
  68993. * Not supported by GPUParticleSystem
  68994. * @returns the list of ramp gradients
  68995. */
  68996. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68997. /**
  68998. * Not supported by GPUParticleSystem
  68999. * Gets or sets a boolean indicating that ramp gradients must be used
  69000. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69001. */
  69002. get useRampGradients(): boolean;
  69003. set useRampGradients(value: boolean);
  69004. /**
  69005. * Not supported by GPUParticleSystem
  69006. * @param gradient defines the gradient to use (between 0 and 1)
  69007. * @param factor defines the life time factor to affect to the specified gradient
  69008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69009. * @returns the current particle system
  69010. */
  69011. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69012. /**
  69013. * Not supported by GPUParticleSystem
  69014. * @param gradient defines the gradient to remove
  69015. * @returns the current particle system
  69016. */
  69017. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69018. /**
  69019. * Instantiates a GPU particle system.
  69020. * 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.
  69021. * @param name The name of the particle system
  69022. * @param options The options used to create the system
  69023. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  69024. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69025. * @param customEffect a custom effect used to change the way particles are rendered by default
  69026. */
  69027. constructor(name: string, options: Partial<{
  69028. capacity: number;
  69029. randomTextureSize: number;
  69030. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69031. protected _reset(): void;
  69032. private _createUpdateVAO;
  69033. private _createRenderVAO;
  69034. private _initialize;
  69035. /** @hidden */
  69036. _recreateUpdateEffect(): void;
  69037. private _getEffect;
  69038. /**
  69039. * Fill the defines array according to the current settings of the particle system
  69040. * @param defines Array to be updated
  69041. * @param blendMode blend mode to take into account when updating the array
  69042. */
  69043. fillDefines(defines: Array<string>, blendMode?: number): void;
  69044. /**
  69045. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69046. * @param uniforms Uniforms array to fill
  69047. * @param attributes Attributes array to fill
  69048. * @param samplers Samplers array to fill
  69049. */
  69050. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69051. /** @hidden */
  69052. _recreateRenderEffect(): Effect;
  69053. /**
  69054. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69055. * @param preWarm defines if we are in the pre-warmimg phase
  69056. */
  69057. animate(preWarm?: boolean): void;
  69058. private _createFactorGradientTexture;
  69059. private _createSizeGradientTexture;
  69060. private _createAngularSpeedGradientTexture;
  69061. private _createVelocityGradientTexture;
  69062. private _createLimitVelocityGradientTexture;
  69063. private _createDragGradientTexture;
  69064. private _createColorGradientTexture;
  69065. /**
  69066. * Renders the particle system in its current state
  69067. * @param preWarm defines if the system should only update the particles but not render them
  69068. * @returns the current number of particles
  69069. */
  69070. render(preWarm?: boolean): number;
  69071. /**
  69072. * Rebuilds the particle system
  69073. */
  69074. rebuild(): void;
  69075. private _releaseBuffers;
  69076. private _releaseVAOs;
  69077. /**
  69078. * Disposes the particle system and free the associated resources
  69079. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69080. */
  69081. dispose(disposeTexture?: boolean): void;
  69082. /**
  69083. * Clones the particle system.
  69084. * @param name The name of the cloned object
  69085. * @param newEmitter The new emitter to use
  69086. * @returns the cloned particle system
  69087. */
  69088. clone(name: string, newEmitter: any): GPUParticleSystem;
  69089. /**
  69090. * Serializes the particle system to a JSON object
  69091. * @param serializeTexture defines if the texture must be serialized as well
  69092. * @returns the JSON object
  69093. */
  69094. serialize(serializeTexture?: boolean): any;
  69095. /**
  69096. * Parses a JSON object to create a GPU particle system.
  69097. * @param parsedParticleSystem The JSON object to parse
  69098. * @param sceneOrEngine The scene or the engine to create the particle system in
  69099. * @param rootUrl The root url to use to load external dependencies like texture
  69100. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69101. * @returns the parsed GPU particle system
  69102. */
  69103. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69104. }
  69105. }
  69106. declare module BABYLON {
  69107. /**
  69108. * Represents a set of particle systems working together to create a specific effect
  69109. */
  69110. export class ParticleSystemSet implements IDisposable {
  69111. /**
  69112. * Gets or sets base Assets URL
  69113. */
  69114. static BaseAssetsUrl: string;
  69115. private _emitterCreationOptions;
  69116. private _emitterNode;
  69117. /**
  69118. * Gets the particle system list
  69119. */
  69120. systems: IParticleSystem[];
  69121. /**
  69122. * Gets the emitter node used with this set
  69123. */
  69124. get emitterNode(): Nullable<TransformNode>;
  69125. /**
  69126. * Creates a new emitter mesh as a sphere
  69127. * @param options defines the options used to create the sphere
  69128. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69129. * @param scene defines the hosting scene
  69130. */
  69131. setEmitterAsSphere(options: {
  69132. diameter: number;
  69133. segments: number;
  69134. color: Color3;
  69135. }, renderingGroupId: number, scene: Scene): void;
  69136. /**
  69137. * Starts all particle systems of the set
  69138. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69139. */
  69140. start(emitter?: AbstractMesh): void;
  69141. /**
  69142. * Release all associated resources
  69143. */
  69144. dispose(): void;
  69145. /**
  69146. * Serialize the set into a JSON compatible object
  69147. * @param serializeTexture defines if the texture must be serialized as well
  69148. * @returns a JSON compatible representation of the set
  69149. */
  69150. serialize(serializeTexture?: boolean): any;
  69151. /**
  69152. * Parse a new ParticleSystemSet from a serialized source
  69153. * @param data defines a JSON compatible representation of the set
  69154. * @param scene defines the hosting scene
  69155. * @param gpu defines if we want GPU particles or CPU particles
  69156. * @returns a new ParticleSystemSet
  69157. */
  69158. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69159. }
  69160. }
  69161. declare module BABYLON {
  69162. /**
  69163. * This class is made for on one-liner static method to help creating particle system set.
  69164. */
  69165. export class ParticleHelper {
  69166. /**
  69167. * Gets or sets base Assets URL
  69168. */
  69169. static BaseAssetsUrl: string;
  69170. /** Define the Url to load snippets */
  69171. static SnippetUrl: string;
  69172. /**
  69173. * Create a default particle system that you can tweak
  69174. * @param emitter defines the emitter to use
  69175. * @param capacity defines the system capacity (default is 500 particles)
  69176. * @param scene defines the hosting scene
  69177. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69178. * @returns the new Particle system
  69179. */
  69180. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69181. /**
  69182. * This is the main static method (one-liner) of this helper to create different particle systems
  69183. * @param type This string represents the type to the particle system to create
  69184. * @param scene The scene where the particle system should live
  69185. * @param gpu If the system will use gpu
  69186. * @returns the ParticleSystemSet created
  69187. */
  69188. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69189. /**
  69190. * Static function used to export a particle system to a ParticleSystemSet variable.
  69191. * Please note that the emitter shape is not exported
  69192. * @param systems defines the particle systems to export
  69193. * @returns the created particle system set
  69194. */
  69195. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69196. /**
  69197. * Creates a particle system from a snippet saved in a remote file
  69198. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69199. * @param url defines the url to load from
  69200. * @param scene defines the hosting scene
  69201. * @param gpu If the system will use gpu
  69202. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69203. * @returns a promise that will resolve to the new particle system
  69204. */
  69205. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69206. /**
  69207. * Creates a particle system from a snippet saved by the particle system editor
  69208. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69209. * @param scene defines the hosting scene
  69210. * @param gpu If the system will use gpu
  69211. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69212. * @returns a promise that will resolve to the new particle system
  69213. */
  69214. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69215. }
  69216. }
  69217. declare module BABYLON {
  69218. interface Engine {
  69219. /**
  69220. * Create an effect to use with particle systems.
  69221. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69222. * the particle system for which you want to create a custom effect in the last parameter
  69223. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69224. * @param uniformsNames defines a list of attribute names
  69225. * @param samplers defines an array of string used to represent textures
  69226. * @param defines defines the string containing the defines to use to compile the shaders
  69227. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69228. * @param onCompiled defines a function to call when the effect creation is successful
  69229. * @param onError defines a function to call when the effect creation has failed
  69230. * @param particleSystem the particle system you want to create the effect for
  69231. * @returns the new Effect
  69232. */
  69233. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69234. }
  69235. interface Mesh {
  69236. /**
  69237. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69238. * @returns an array of IParticleSystem
  69239. */
  69240. getEmittedParticleSystems(): IParticleSystem[];
  69241. /**
  69242. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69243. * @returns an array of IParticleSystem
  69244. */
  69245. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69246. }
  69247. }
  69248. declare module BABYLON {
  69249. /** Defines the 4 color options */
  69250. export enum PointColor {
  69251. /** color value */
  69252. Color = 2,
  69253. /** uv value */
  69254. UV = 1,
  69255. /** random value */
  69256. Random = 0,
  69257. /** stated value */
  69258. Stated = 3
  69259. }
  69260. /**
  69261. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69262. * 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.
  69263. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69264. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69265. *
  69266. * Full documentation here : TO BE ENTERED
  69267. */
  69268. export class PointsCloudSystem implements IDisposable {
  69269. /**
  69270. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69271. * Example : var p = SPS.particles[i];
  69272. */
  69273. particles: CloudPoint[];
  69274. /**
  69275. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69276. */
  69277. nbParticles: number;
  69278. /**
  69279. * This a counter for your own usage. It's not set by any SPS functions.
  69280. */
  69281. counter: number;
  69282. /**
  69283. * The PCS name. This name is also given to the underlying mesh.
  69284. */
  69285. name: string;
  69286. /**
  69287. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69288. */
  69289. mesh: Mesh;
  69290. /**
  69291. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69292. * Please read :
  69293. */
  69294. vars: any;
  69295. /**
  69296. * @hidden
  69297. */
  69298. _size: number;
  69299. private _scene;
  69300. private _promises;
  69301. private _positions;
  69302. private _indices;
  69303. private _normals;
  69304. private _colors;
  69305. private _uvs;
  69306. private _indices32;
  69307. private _positions32;
  69308. private _colors32;
  69309. private _uvs32;
  69310. private _updatable;
  69311. private _isVisibilityBoxLocked;
  69312. private _alwaysVisible;
  69313. private _groups;
  69314. private _groupCounter;
  69315. private _computeParticleColor;
  69316. private _computeParticleTexture;
  69317. private _computeParticleRotation;
  69318. private _computeBoundingBox;
  69319. private _isReady;
  69320. /**
  69321. * Creates a PCS (Points Cloud System) object
  69322. * @param name (String) is the PCS name, this will be the underlying mesh name
  69323. * @param pointSize (number) is the size for each point
  69324. * @param scene (Scene) is the scene in which the PCS is added
  69325. * @param options defines the options of the PCS e.g.
  69326. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69327. */
  69328. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69329. updatable?: boolean;
  69330. });
  69331. /**
  69332. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69333. * If no points were added to the PCS, the returned mesh is just a single point.
  69334. * @returns a promise for the created mesh
  69335. */
  69336. buildMeshAsync(): Promise<Mesh>;
  69337. /**
  69338. * @hidden
  69339. */
  69340. private _buildMesh;
  69341. private _addParticle;
  69342. private _randomUnitVector;
  69343. private _getColorIndicesForCoord;
  69344. private _setPointsColorOrUV;
  69345. private _colorFromTexture;
  69346. private _calculateDensity;
  69347. /**
  69348. * Adds points to the PCS in random positions within a unit sphere
  69349. * @param nb (positive integer) the number of particles to be created from this model
  69350. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69351. * @returns the number of groups in the system
  69352. */
  69353. addPoints(nb: number, pointFunction?: any): number;
  69354. /**
  69355. * Adds points to the PCS from the surface of the model shape
  69356. * @param mesh is any Mesh object that will be used as a surface model for the points
  69357. * @param nb (positive integer) the number of particles to be created from this model
  69358. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69359. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69360. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69361. * @returns the number of groups in the system
  69362. */
  69363. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69364. /**
  69365. * Adds points to the PCS inside the model shape
  69366. * @param mesh is any Mesh object that will be used as a surface model for the points
  69367. * @param nb (positive integer) the number of particles to be created from this model
  69368. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69369. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69370. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69371. * @returns the number of groups in the system
  69372. */
  69373. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69374. /**
  69375. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69376. * This method calls `updateParticle()` for each particle of the SPS.
  69377. * For an animated SPS, it is usually called within the render loop.
  69378. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69379. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69380. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69381. * @returns the PCS.
  69382. */
  69383. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69384. /**
  69385. * Disposes the PCS.
  69386. */
  69387. dispose(): void;
  69388. /**
  69389. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69390. * doc :
  69391. * @returns the PCS.
  69392. */
  69393. refreshVisibleSize(): PointsCloudSystem;
  69394. /**
  69395. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69396. * @param size the size (float) of the visibility box
  69397. * note : this doesn't lock the PCS mesh bounding box.
  69398. * doc :
  69399. */
  69400. setVisibilityBox(size: number): void;
  69401. /**
  69402. * Gets whether the PCS is always visible or not
  69403. * doc :
  69404. */
  69405. get isAlwaysVisible(): boolean;
  69406. /**
  69407. * Sets the PCS as always visible or not
  69408. * doc :
  69409. */
  69410. set isAlwaysVisible(val: boolean);
  69411. /**
  69412. * Tells to `setParticles()` to compute the particle rotations or not
  69413. * Default value : false. The PCS is faster when it's set to false
  69414. * Note : particle rotations are only applied to parent particles
  69415. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69416. */
  69417. set computeParticleRotation(val: boolean);
  69418. /**
  69419. * Tells to `setParticles()` to compute the particle colors or not.
  69420. * Default value : true. The PCS is faster when it's set to false.
  69421. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69422. */
  69423. set computeParticleColor(val: boolean);
  69424. set computeParticleTexture(val: boolean);
  69425. /**
  69426. * Gets if `setParticles()` computes the particle colors or not.
  69427. * Default value : false. The PCS is faster when it's set to false.
  69428. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69429. */
  69430. get computeParticleColor(): boolean;
  69431. /**
  69432. * Gets if `setParticles()` computes the particle textures or not.
  69433. * Default value : false. The PCS is faster when it's set to false.
  69434. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69435. */
  69436. get computeParticleTexture(): boolean;
  69437. /**
  69438. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69439. */
  69440. set computeBoundingBox(val: boolean);
  69441. /**
  69442. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69443. */
  69444. get computeBoundingBox(): boolean;
  69445. /**
  69446. * This function does nothing. It may be overwritten to set all the particle first values.
  69447. * The PCS doesn't call this function, you may have to call it by your own.
  69448. * doc :
  69449. */
  69450. initParticles(): void;
  69451. /**
  69452. * This function does nothing. It may be overwritten to recycle a particle
  69453. * The PCS doesn't call this function, you can to call it
  69454. * doc :
  69455. * @param particle The particle to recycle
  69456. * @returns the recycled particle
  69457. */
  69458. recycleParticle(particle: CloudPoint): CloudPoint;
  69459. /**
  69460. * Updates a particle : this function should be overwritten by the user.
  69461. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69462. * doc :
  69463. * @example : just set a particle position or velocity and recycle conditions
  69464. * @param particle The particle to update
  69465. * @returns the updated particle
  69466. */
  69467. updateParticle(particle: CloudPoint): CloudPoint;
  69468. /**
  69469. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69470. * This does nothing and may be overwritten by the user.
  69471. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69472. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69473. * @param update the boolean update value actually passed to setParticles()
  69474. */
  69475. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69476. /**
  69477. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69478. * This will be passed three parameters.
  69479. * This does nothing and may be overwritten by the user.
  69480. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69481. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69482. * @param update the boolean update value actually passed to setParticles()
  69483. */
  69484. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69485. }
  69486. }
  69487. declare module BABYLON {
  69488. /**
  69489. * Represents one particle of a points cloud system.
  69490. */
  69491. export class CloudPoint {
  69492. /**
  69493. * particle global index
  69494. */
  69495. idx: number;
  69496. /**
  69497. * The color of the particle
  69498. */
  69499. color: Nullable<Color4>;
  69500. /**
  69501. * The world space position of the particle.
  69502. */
  69503. position: Vector3;
  69504. /**
  69505. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69506. */
  69507. rotation: Vector3;
  69508. /**
  69509. * The world space rotation quaternion of the particle.
  69510. */
  69511. rotationQuaternion: Nullable<Quaternion>;
  69512. /**
  69513. * The uv of the particle.
  69514. */
  69515. uv: Nullable<Vector2>;
  69516. /**
  69517. * The current speed of the particle.
  69518. */
  69519. velocity: Vector3;
  69520. /**
  69521. * The pivot point in the particle local space.
  69522. */
  69523. pivot: Vector3;
  69524. /**
  69525. * Must the particle be translated from its pivot point in its local space ?
  69526. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69527. * Default : false
  69528. */
  69529. translateFromPivot: boolean;
  69530. /**
  69531. * Index of this particle in the global "positions" array (Internal use)
  69532. * @hidden
  69533. */
  69534. _pos: number;
  69535. /**
  69536. * @hidden Index of this particle in the global "indices" array (Internal use)
  69537. */
  69538. _ind: number;
  69539. /**
  69540. * Group this particle belongs to
  69541. */
  69542. _group: PointsGroup;
  69543. /**
  69544. * Group id of this particle
  69545. */
  69546. groupId: number;
  69547. /**
  69548. * Index of the particle in its group id (Internal use)
  69549. */
  69550. idxInGroup: number;
  69551. /**
  69552. * @hidden Particle BoundingInfo object (Internal use)
  69553. */
  69554. _boundingInfo: BoundingInfo;
  69555. /**
  69556. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69557. */
  69558. _pcs: PointsCloudSystem;
  69559. /**
  69560. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69561. */
  69562. _stillInvisible: boolean;
  69563. /**
  69564. * @hidden Last computed particle rotation matrix
  69565. */
  69566. _rotationMatrix: number[];
  69567. /**
  69568. * Parent particle Id, if any.
  69569. * Default null.
  69570. */
  69571. parentId: Nullable<number>;
  69572. /**
  69573. * @hidden Internal global position in the PCS.
  69574. */
  69575. _globalPosition: Vector3;
  69576. /**
  69577. * Creates a Point Cloud object.
  69578. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69579. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69580. * @param group (PointsGroup) is the group the particle belongs to
  69581. * @param groupId (integer) is the group identifier in the PCS.
  69582. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69583. * @param pcs defines the PCS it is associated to
  69584. */
  69585. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69586. /**
  69587. * get point size
  69588. */
  69589. get size(): Vector3;
  69590. /**
  69591. * Set point size
  69592. */
  69593. set size(scale: Vector3);
  69594. /**
  69595. * Legacy support, changed quaternion to rotationQuaternion
  69596. */
  69597. get quaternion(): Nullable<Quaternion>;
  69598. /**
  69599. * Legacy support, changed quaternion to rotationQuaternion
  69600. */
  69601. set quaternion(q: Nullable<Quaternion>);
  69602. /**
  69603. * Returns a boolean. True if the particle intersects a mesh, else false
  69604. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69605. * @param target is the object (point or mesh) what the intersection is computed against
  69606. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69607. * @returns true if it intersects
  69608. */
  69609. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69610. /**
  69611. * get the rotation matrix of the particle
  69612. * @hidden
  69613. */
  69614. getRotationMatrix(m: Matrix): void;
  69615. }
  69616. /**
  69617. * Represents a group of points in a points cloud system
  69618. * * PCS internal tool, don't use it manually.
  69619. */
  69620. export class PointsGroup {
  69621. /**
  69622. * The group id
  69623. * @hidden
  69624. */
  69625. groupID: number;
  69626. /**
  69627. * image data for group (internal use)
  69628. * @hidden
  69629. */
  69630. _groupImageData: Nullable<ArrayBufferView>;
  69631. /**
  69632. * Image Width (internal use)
  69633. * @hidden
  69634. */
  69635. _groupImgWidth: number;
  69636. /**
  69637. * Image Height (internal use)
  69638. * @hidden
  69639. */
  69640. _groupImgHeight: number;
  69641. /**
  69642. * Custom position function (internal use)
  69643. * @hidden
  69644. */
  69645. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69646. /**
  69647. * density per facet for surface points
  69648. * @hidden
  69649. */
  69650. _groupDensity: number[];
  69651. /**
  69652. * Only when points are colored by texture carries pointer to texture list array
  69653. * @hidden
  69654. */
  69655. _textureNb: number;
  69656. /**
  69657. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69658. * PCS internal tool, don't use it manually.
  69659. * @hidden
  69660. */
  69661. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69662. }
  69663. }
  69664. declare module BABYLON {
  69665. interface Scene {
  69666. /** @hidden (Backing field) */
  69667. _physicsEngine: Nullable<IPhysicsEngine>;
  69668. /** @hidden */
  69669. _physicsTimeAccumulator: number;
  69670. /**
  69671. * Gets the current physics engine
  69672. * @returns a IPhysicsEngine or null if none attached
  69673. */
  69674. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69675. /**
  69676. * Enables physics to the current scene
  69677. * @param gravity defines the scene's gravity for the physics engine
  69678. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69679. * @return a boolean indicating if the physics engine was initialized
  69680. */
  69681. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69682. /**
  69683. * Disables and disposes the physics engine associated with the scene
  69684. */
  69685. disablePhysicsEngine(): void;
  69686. /**
  69687. * Gets a boolean indicating if there is an active physics engine
  69688. * @returns a boolean indicating if there is an active physics engine
  69689. */
  69690. isPhysicsEnabled(): boolean;
  69691. /**
  69692. * Deletes a physics compound impostor
  69693. * @param compound defines the compound to delete
  69694. */
  69695. deleteCompoundImpostor(compound: any): void;
  69696. /**
  69697. * An event triggered when physic simulation is about to be run
  69698. */
  69699. onBeforePhysicsObservable: Observable<Scene>;
  69700. /**
  69701. * An event triggered when physic simulation has been done
  69702. */
  69703. onAfterPhysicsObservable: Observable<Scene>;
  69704. }
  69705. interface AbstractMesh {
  69706. /** @hidden */
  69707. _physicsImpostor: Nullable<PhysicsImpostor>;
  69708. /**
  69709. * Gets or sets impostor used for physic simulation
  69710. * @see https://doc.babylonjs.com/features/physics_engine
  69711. */
  69712. physicsImpostor: Nullable<PhysicsImpostor>;
  69713. /**
  69714. * Gets the current physics impostor
  69715. * @see https://doc.babylonjs.com/features/physics_engine
  69716. * @returns a physics impostor or null
  69717. */
  69718. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69719. /** Apply a physic impulse to the mesh
  69720. * @param force defines the force to apply
  69721. * @param contactPoint defines where to apply the force
  69722. * @returns the current mesh
  69723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69724. */
  69725. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69726. /**
  69727. * Creates a physic joint between two meshes
  69728. * @param otherMesh defines the other mesh to use
  69729. * @param pivot1 defines the pivot to use on this mesh
  69730. * @param pivot2 defines the pivot to use on the other mesh
  69731. * @param options defines additional options (can be plugin dependent)
  69732. * @returns the current mesh
  69733. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69734. */
  69735. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69736. /** @hidden */
  69737. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69738. }
  69739. /**
  69740. * Defines the physics engine scene component responsible to manage a physics engine
  69741. */
  69742. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69743. /**
  69744. * The component name helpful to identify the component in the list of scene components.
  69745. */
  69746. readonly name: string;
  69747. /**
  69748. * The scene the component belongs to.
  69749. */
  69750. scene: Scene;
  69751. /**
  69752. * Creates a new instance of the component for the given scene
  69753. * @param scene Defines the scene to register the component in
  69754. */
  69755. constructor(scene: Scene);
  69756. /**
  69757. * Registers the component in a given scene
  69758. */
  69759. register(): void;
  69760. /**
  69761. * Rebuilds the elements related to this component in case of
  69762. * context lost for instance.
  69763. */
  69764. rebuild(): void;
  69765. /**
  69766. * Disposes the component and the associated ressources
  69767. */
  69768. dispose(): void;
  69769. }
  69770. }
  69771. declare module BABYLON {
  69772. /**
  69773. * A helper for physics simulations
  69774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69775. */
  69776. export class PhysicsHelper {
  69777. private _scene;
  69778. private _physicsEngine;
  69779. /**
  69780. * Initializes the Physics helper
  69781. * @param scene Babylon.js scene
  69782. */
  69783. constructor(scene: Scene);
  69784. /**
  69785. * Applies a radial explosion impulse
  69786. * @param origin the origin of the explosion
  69787. * @param radiusOrEventOptions the radius or the options of radial explosion
  69788. * @param strength the explosion strength
  69789. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69790. * @returns A physics radial explosion event, or null
  69791. */
  69792. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69793. /**
  69794. * Applies a radial explosion force
  69795. * @param origin the origin of the explosion
  69796. * @param radiusOrEventOptions the radius or the options of radial explosion
  69797. * @param strength the explosion strength
  69798. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69799. * @returns A physics radial explosion event, or null
  69800. */
  69801. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69802. /**
  69803. * Creates a gravitational field
  69804. * @param origin the origin of the explosion
  69805. * @param radiusOrEventOptions the radius or the options of radial explosion
  69806. * @param strength the explosion strength
  69807. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69808. * @returns A physics gravitational field event, or null
  69809. */
  69810. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69811. /**
  69812. * Creates a physics updraft event
  69813. * @param origin the origin of the updraft
  69814. * @param radiusOrEventOptions the radius or the options of the updraft
  69815. * @param strength the strength of the updraft
  69816. * @param height the height of the updraft
  69817. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69818. * @returns A physics updraft event, or null
  69819. */
  69820. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69821. /**
  69822. * Creates a physics vortex event
  69823. * @param origin the of the vortex
  69824. * @param radiusOrEventOptions the radius or the options of the vortex
  69825. * @param strength the strength of the vortex
  69826. * @param height the height of the vortex
  69827. * @returns a Physics vortex event, or null
  69828. * A physics vortex event or null
  69829. */
  69830. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69831. }
  69832. /**
  69833. * Represents a physics radial explosion event
  69834. */
  69835. class PhysicsRadialExplosionEvent {
  69836. private _scene;
  69837. private _options;
  69838. private _sphere;
  69839. private _dataFetched;
  69840. /**
  69841. * Initializes a radial explosioin event
  69842. * @param _scene BabylonJS scene
  69843. * @param _options The options for the vortex event
  69844. */
  69845. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69846. /**
  69847. * Returns the data related to the radial explosion event (sphere).
  69848. * @returns The radial explosion event data
  69849. */
  69850. getData(): PhysicsRadialExplosionEventData;
  69851. /**
  69852. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69853. * @param impostor A physics imposter
  69854. * @param origin the origin of the explosion
  69855. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69856. */
  69857. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69858. /**
  69859. * Triggers affecterd impostors callbacks
  69860. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69861. */
  69862. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69863. /**
  69864. * Disposes the sphere.
  69865. * @param force Specifies if the sphere should be disposed by force
  69866. */
  69867. dispose(force?: boolean): void;
  69868. /*** Helpers ***/
  69869. private _prepareSphere;
  69870. private _intersectsWithSphere;
  69871. }
  69872. /**
  69873. * Represents a gravitational field event
  69874. */
  69875. class PhysicsGravitationalFieldEvent {
  69876. private _physicsHelper;
  69877. private _scene;
  69878. private _origin;
  69879. private _options;
  69880. private _tickCallback;
  69881. private _sphere;
  69882. private _dataFetched;
  69883. /**
  69884. * Initializes the physics gravitational field event
  69885. * @param _physicsHelper A physics helper
  69886. * @param _scene BabylonJS scene
  69887. * @param _origin The origin position of the gravitational field event
  69888. * @param _options The options for the vortex event
  69889. */
  69890. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69891. /**
  69892. * Returns the data related to the gravitational field event (sphere).
  69893. * @returns A gravitational field event
  69894. */
  69895. getData(): PhysicsGravitationalFieldEventData;
  69896. /**
  69897. * Enables the gravitational field.
  69898. */
  69899. enable(): void;
  69900. /**
  69901. * Disables the gravitational field.
  69902. */
  69903. disable(): void;
  69904. /**
  69905. * Disposes the sphere.
  69906. * @param force The force to dispose from the gravitational field event
  69907. */
  69908. dispose(force?: boolean): void;
  69909. private _tick;
  69910. }
  69911. /**
  69912. * Represents a physics updraft event
  69913. */
  69914. class PhysicsUpdraftEvent {
  69915. private _scene;
  69916. private _origin;
  69917. private _options;
  69918. private _physicsEngine;
  69919. private _originTop;
  69920. private _originDirection;
  69921. private _tickCallback;
  69922. private _cylinder;
  69923. private _cylinderPosition;
  69924. private _dataFetched;
  69925. /**
  69926. * Initializes the physics updraft event
  69927. * @param _scene BabylonJS scene
  69928. * @param _origin The origin position of the updraft
  69929. * @param _options The options for the updraft event
  69930. */
  69931. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69932. /**
  69933. * Returns the data related to the updraft event (cylinder).
  69934. * @returns A physics updraft event
  69935. */
  69936. getData(): PhysicsUpdraftEventData;
  69937. /**
  69938. * Enables the updraft.
  69939. */
  69940. enable(): void;
  69941. /**
  69942. * Disables the updraft.
  69943. */
  69944. disable(): void;
  69945. /**
  69946. * Disposes the cylinder.
  69947. * @param force Specifies if the updraft should be disposed by force
  69948. */
  69949. dispose(force?: boolean): void;
  69950. private getImpostorHitData;
  69951. private _tick;
  69952. /*** Helpers ***/
  69953. private _prepareCylinder;
  69954. private _intersectsWithCylinder;
  69955. }
  69956. /**
  69957. * Represents a physics vortex event
  69958. */
  69959. class PhysicsVortexEvent {
  69960. private _scene;
  69961. private _origin;
  69962. private _options;
  69963. private _physicsEngine;
  69964. private _originTop;
  69965. private _tickCallback;
  69966. private _cylinder;
  69967. private _cylinderPosition;
  69968. private _dataFetched;
  69969. /**
  69970. * Initializes the physics vortex event
  69971. * @param _scene The BabylonJS scene
  69972. * @param _origin The origin position of the vortex
  69973. * @param _options The options for the vortex event
  69974. */
  69975. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69976. /**
  69977. * Returns the data related to the vortex event (cylinder).
  69978. * @returns The physics vortex event data
  69979. */
  69980. getData(): PhysicsVortexEventData;
  69981. /**
  69982. * Enables the vortex.
  69983. */
  69984. enable(): void;
  69985. /**
  69986. * Disables the cortex.
  69987. */
  69988. disable(): void;
  69989. /**
  69990. * Disposes the sphere.
  69991. * @param force
  69992. */
  69993. dispose(force?: boolean): void;
  69994. private getImpostorHitData;
  69995. private _tick;
  69996. /*** Helpers ***/
  69997. private _prepareCylinder;
  69998. private _intersectsWithCylinder;
  69999. }
  70000. /**
  70001. * Options fot the radial explosion event
  70002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70003. */
  70004. export class PhysicsRadialExplosionEventOptions {
  70005. /**
  70006. * The radius of the sphere for the radial explosion.
  70007. */
  70008. radius: number;
  70009. /**
  70010. * The strenth of the explosion.
  70011. */
  70012. strength: number;
  70013. /**
  70014. * The strenght of the force in correspondence to the distance of the affected object
  70015. */
  70016. falloff: PhysicsRadialImpulseFalloff;
  70017. /**
  70018. * Sphere options for the radial explosion.
  70019. */
  70020. sphere: {
  70021. segments: number;
  70022. diameter: number;
  70023. };
  70024. /**
  70025. * Sphere options for the radial explosion.
  70026. */
  70027. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70028. }
  70029. /**
  70030. * Options fot the updraft event
  70031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70032. */
  70033. export class PhysicsUpdraftEventOptions {
  70034. /**
  70035. * The radius of the cylinder for the vortex
  70036. */
  70037. radius: number;
  70038. /**
  70039. * The strenth of the updraft.
  70040. */
  70041. strength: number;
  70042. /**
  70043. * The height of the cylinder for the updraft.
  70044. */
  70045. height: number;
  70046. /**
  70047. * The mode for the the updraft.
  70048. */
  70049. updraftMode: PhysicsUpdraftMode;
  70050. }
  70051. /**
  70052. * Options fot the vortex event
  70053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70054. */
  70055. export class PhysicsVortexEventOptions {
  70056. /**
  70057. * The radius of the cylinder for the vortex
  70058. */
  70059. radius: number;
  70060. /**
  70061. * The strenth of the vortex.
  70062. */
  70063. strength: number;
  70064. /**
  70065. * The height of the cylinder for the vortex.
  70066. */
  70067. height: number;
  70068. /**
  70069. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70070. */
  70071. centripetalForceThreshold: number;
  70072. /**
  70073. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70074. */
  70075. centripetalForceMultiplier: number;
  70076. /**
  70077. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70078. */
  70079. centrifugalForceMultiplier: number;
  70080. /**
  70081. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70082. */
  70083. updraftForceMultiplier: number;
  70084. }
  70085. /**
  70086. * The strenght of the force in correspondence to the distance of the affected object
  70087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70088. */
  70089. export enum PhysicsRadialImpulseFalloff {
  70090. /** Defines that impulse is constant in strength across it's whole radius */
  70091. Constant = 0,
  70092. /** Defines that impulse gets weaker if it's further from the origin */
  70093. Linear = 1
  70094. }
  70095. /**
  70096. * The strength of the force in correspondence to the distance of the affected object
  70097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70098. */
  70099. export enum PhysicsUpdraftMode {
  70100. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70101. Center = 0,
  70102. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70103. Perpendicular = 1
  70104. }
  70105. /**
  70106. * Interface for a physics hit data
  70107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70108. */
  70109. export interface PhysicsHitData {
  70110. /**
  70111. * The force applied at the contact point
  70112. */
  70113. force: Vector3;
  70114. /**
  70115. * The contact point
  70116. */
  70117. contactPoint: Vector3;
  70118. /**
  70119. * The distance from the origin to the contact point
  70120. */
  70121. distanceFromOrigin: number;
  70122. }
  70123. /**
  70124. * Interface for radial explosion event data
  70125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70126. */
  70127. export interface PhysicsRadialExplosionEventData {
  70128. /**
  70129. * A sphere used for the radial explosion event
  70130. */
  70131. sphere: Mesh;
  70132. }
  70133. /**
  70134. * Interface for gravitational field event data
  70135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70136. */
  70137. export interface PhysicsGravitationalFieldEventData {
  70138. /**
  70139. * A sphere mesh used for the gravitational field event
  70140. */
  70141. sphere: Mesh;
  70142. }
  70143. /**
  70144. * Interface for updraft event data
  70145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70146. */
  70147. export interface PhysicsUpdraftEventData {
  70148. /**
  70149. * A cylinder used for the updraft event
  70150. */
  70151. cylinder: Mesh;
  70152. }
  70153. /**
  70154. * Interface for vortex event data
  70155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70156. */
  70157. export interface PhysicsVortexEventData {
  70158. /**
  70159. * A cylinder used for the vortex event
  70160. */
  70161. cylinder: Mesh;
  70162. }
  70163. /**
  70164. * Interface for an affected physics impostor
  70165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70166. */
  70167. export interface PhysicsAffectedImpostorWithData {
  70168. /**
  70169. * The impostor affected by the effect
  70170. */
  70171. impostor: PhysicsImpostor;
  70172. /**
  70173. * The data about the hit/horce from the explosion
  70174. */
  70175. hitData: PhysicsHitData;
  70176. }
  70177. }
  70178. declare module BABYLON {
  70179. /** @hidden */
  70180. export var blackAndWhitePixelShader: {
  70181. name: string;
  70182. shader: string;
  70183. };
  70184. }
  70185. declare module BABYLON {
  70186. /**
  70187. * Post process used to render in black and white
  70188. */
  70189. export class BlackAndWhitePostProcess extends PostProcess {
  70190. /**
  70191. * Linear about to convert he result to black and white (default: 1)
  70192. */
  70193. degree: number;
  70194. /**
  70195. * Gets a string identifying the name of the class
  70196. * @returns "BlackAndWhitePostProcess" string
  70197. */
  70198. getClassName(): string;
  70199. /**
  70200. * Creates a black and white post process
  70201. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70202. * @param name The name of the effect.
  70203. * @param options The required width/height ratio to downsize to before computing the render pass.
  70204. * @param camera The camera to apply the render pass to.
  70205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70206. * @param engine The engine which the post process will be applied. (default: current engine)
  70207. * @param reusable If the post process can be reused on the same frame. (default: false)
  70208. */
  70209. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70210. /** @hidden */
  70211. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70212. }
  70213. }
  70214. declare module BABYLON {
  70215. /**
  70216. * This represents a set of one or more post processes in Babylon.
  70217. * A post process can be used to apply a shader to a texture after it is rendered.
  70218. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70219. */
  70220. export class PostProcessRenderEffect {
  70221. private _postProcesses;
  70222. private _getPostProcesses;
  70223. private _singleInstance;
  70224. private _cameras;
  70225. private _indicesForCamera;
  70226. /**
  70227. * Name of the effect
  70228. * @hidden
  70229. */
  70230. _name: string;
  70231. /**
  70232. * Instantiates a post process render effect.
  70233. * A post process can be used to apply a shader to a texture after it is rendered.
  70234. * @param engine The engine the effect is tied to
  70235. * @param name The name of the effect
  70236. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70237. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70238. */
  70239. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70240. /**
  70241. * Checks if all the post processes in the effect are supported.
  70242. */
  70243. get isSupported(): boolean;
  70244. /**
  70245. * Updates the current state of the effect
  70246. * @hidden
  70247. */
  70248. _update(): void;
  70249. /**
  70250. * Attaches the effect on cameras
  70251. * @param cameras The camera to attach to.
  70252. * @hidden
  70253. */
  70254. _attachCameras(cameras: Camera): void;
  70255. /**
  70256. * Attaches the effect on cameras
  70257. * @param cameras The camera to attach to.
  70258. * @hidden
  70259. */
  70260. _attachCameras(cameras: Camera[]): void;
  70261. /**
  70262. * Detaches the effect on cameras
  70263. * @param cameras The camera to detatch from.
  70264. * @hidden
  70265. */
  70266. _detachCameras(cameras: Camera): void;
  70267. /**
  70268. * Detatches the effect on cameras
  70269. * @param cameras The camera to detatch from.
  70270. * @hidden
  70271. */
  70272. _detachCameras(cameras: Camera[]): void;
  70273. /**
  70274. * Enables the effect on given cameras
  70275. * @param cameras The camera to enable.
  70276. * @hidden
  70277. */
  70278. _enable(cameras: Camera): void;
  70279. /**
  70280. * Enables the effect on given cameras
  70281. * @param cameras The camera to enable.
  70282. * @hidden
  70283. */
  70284. _enable(cameras: Nullable<Camera[]>): void;
  70285. /**
  70286. * Disables the effect on the given cameras
  70287. * @param cameras The camera to disable.
  70288. * @hidden
  70289. */
  70290. _disable(cameras: Camera): void;
  70291. /**
  70292. * Disables the effect on the given cameras
  70293. * @param cameras The camera to disable.
  70294. * @hidden
  70295. */
  70296. _disable(cameras: Nullable<Camera[]>): void;
  70297. /**
  70298. * Gets a list of the post processes contained in the effect.
  70299. * @param camera The camera to get the post processes on.
  70300. * @returns The list of the post processes in the effect.
  70301. */
  70302. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70303. }
  70304. }
  70305. declare module BABYLON {
  70306. /** @hidden */
  70307. export var extractHighlightsPixelShader: {
  70308. name: string;
  70309. shader: string;
  70310. };
  70311. }
  70312. declare module BABYLON {
  70313. /**
  70314. * 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.
  70315. */
  70316. export class ExtractHighlightsPostProcess extends PostProcess {
  70317. /**
  70318. * The luminance threshold, pixels below this value will be set to black.
  70319. */
  70320. threshold: number;
  70321. /** @hidden */
  70322. _exposure: number;
  70323. /**
  70324. * Post process which has the input texture to be used when performing highlight extraction
  70325. * @hidden
  70326. */
  70327. _inputPostProcess: Nullable<PostProcess>;
  70328. /**
  70329. * Gets a string identifying the name of the class
  70330. * @returns "ExtractHighlightsPostProcess" string
  70331. */
  70332. getClassName(): string;
  70333. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70334. }
  70335. }
  70336. declare module BABYLON {
  70337. /** @hidden */
  70338. export var bloomMergePixelShader: {
  70339. name: string;
  70340. shader: string;
  70341. };
  70342. }
  70343. declare module BABYLON {
  70344. /**
  70345. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70346. */
  70347. export class BloomMergePostProcess extends PostProcess {
  70348. /** Weight of the bloom to be added to the original input. */
  70349. weight: number;
  70350. /**
  70351. * Gets a string identifying the name of the class
  70352. * @returns "BloomMergePostProcess" string
  70353. */
  70354. getClassName(): string;
  70355. /**
  70356. * Creates a new instance of @see BloomMergePostProcess
  70357. * @param name The name of the effect.
  70358. * @param originalFromInput Post process which's input will be used for the merge.
  70359. * @param blurred Blurred highlights post process which's output will be used.
  70360. * @param weight Weight of the bloom to be added to the original input.
  70361. * @param options The required width/height ratio to downsize to before computing the render pass.
  70362. * @param camera The camera to apply the render pass to.
  70363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70364. * @param engine The engine which the post process will be applied. (default: current engine)
  70365. * @param reusable If the post process can be reused on the same frame. (default: false)
  70366. * @param textureType Type of textures used when performing the post process. (default: 0)
  70367. * @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)
  70368. */
  70369. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70370. /** Weight of the bloom to be added to the original input. */
  70371. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70372. }
  70373. }
  70374. declare module BABYLON {
  70375. /**
  70376. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70377. */
  70378. export class BloomEffect extends PostProcessRenderEffect {
  70379. private bloomScale;
  70380. /**
  70381. * @hidden Internal
  70382. */
  70383. _effects: Array<PostProcess>;
  70384. /**
  70385. * @hidden Internal
  70386. */
  70387. _downscale: ExtractHighlightsPostProcess;
  70388. private _blurX;
  70389. private _blurY;
  70390. private _merge;
  70391. /**
  70392. * The luminance threshold to find bright areas of the image to bloom.
  70393. */
  70394. get threshold(): number;
  70395. set threshold(value: number);
  70396. /**
  70397. * The strength of the bloom.
  70398. */
  70399. get weight(): number;
  70400. set weight(value: number);
  70401. /**
  70402. * Specifies the size of the bloom blur kernel, relative to the final output size
  70403. */
  70404. get kernel(): number;
  70405. set kernel(value: number);
  70406. /**
  70407. * Creates a new instance of @see BloomEffect
  70408. * @param scene The scene the effect belongs to.
  70409. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70410. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70411. * @param bloomWeight The the strength of bloom.
  70412. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70413. * @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)
  70414. */
  70415. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70416. /**
  70417. * Disposes each of the internal effects for a given camera.
  70418. * @param camera The camera to dispose the effect on.
  70419. */
  70420. disposeEffects(camera: Camera): void;
  70421. /**
  70422. * @hidden Internal
  70423. */
  70424. _updateEffects(): void;
  70425. /**
  70426. * Internal
  70427. * @returns if all the contained post processes are ready.
  70428. * @hidden
  70429. */
  70430. _isReady(): boolean;
  70431. }
  70432. }
  70433. declare module BABYLON {
  70434. /** @hidden */
  70435. export var chromaticAberrationPixelShader: {
  70436. name: string;
  70437. shader: string;
  70438. };
  70439. }
  70440. declare module BABYLON {
  70441. /**
  70442. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70443. */
  70444. export class ChromaticAberrationPostProcess extends PostProcess {
  70445. /**
  70446. * The amount of seperation of rgb channels (default: 30)
  70447. */
  70448. aberrationAmount: number;
  70449. /**
  70450. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70451. */
  70452. radialIntensity: number;
  70453. /**
  70454. * 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))
  70455. */
  70456. direction: Vector2;
  70457. /**
  70458. * 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))
  70459. */
  70460. centerPosition: Vector2;
  70461. /** The width of the screen to apply the effect on */
  70462. screenWidth: number;
  70463. /** The height of the screen to apply the effect on */
  70464. screenHeight: number;
  70465. /**
  70466. * Gets a string identifying the name of the class
  70467. * @returns "ChromaticAberrationPostProcess" string
  70468. */
  70469. getClassName(): string;
  70470. /**
  70471. * Creates a new instance ChromaticAberrationPostProcess
  70472. * @param name The name of the effect.
  70473. * @param screenWidth The width of the screen to apply the effect on.
  70474. * @param screenHeight The height of the screen to apply the effect on.
  70475. * @param options The required width/height ratio to downsize to before computing the render pass.
  70476. * @param camera The camera to apply the render pass to.
  70477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70478. * @param engine The engine which the post process will be applied. (default: current engine)
  70479. * @param reusable If the post process can be reused on the same frame. (default: false)
  70480. * @param textureType Type of textures used when performing the post process. (default: 0)
  70481. * @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)
  70482. */
  70483. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70484. /** @hidden */
  70485. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70486. }
  70487. }
  70488. declare module BABYLON {
  70489. /** @hidden */
  70490. export var circleOfConfusionPixelShader: {
  70491. name: string;
  70492. shader: string;
  70493. };
  70494. }
  70495. declare module BABYLON {
  70496. /**
  70497. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70498. */
  70499. export class CircleOfConfusionPostProcess extends PostProcess {
  70500. /**
  70501. * 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.
  70502. */
  70503. lensSize: number;
  70504. /**
  70505. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70506. */
  70507. fStop: number;
  70508. /**
  70509. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70510. */
  70511. focusDistance: number;
  70512. /**
  70513. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70514. */
  70515. focalLength: number;
  70516. /**
  70517. * Gets a string identifying the name of the class
  70518. * @returns "CircleOfConfusionPostProcess" string
  70519. */
  70520. getClassName(): string;
  70521. private _depthTexture;
  70522. /**
  70523. * Creates a new instance CircleOfConfusionPostProcess
  70524. * @param name The name of the effect.
  70525. * @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.
  70526. * @param options The required width/height ratio to downsize to before computing the render pass.
  70527. * @param camera The camera to apply the render pass to.
  70528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70529. * @param engine The engine which the post process will be applied. (default: current engine)
  70530. * @param reusable If the post process can be reused on the same frame. (default: false)
  70531. * @param textureType Type of textures used when performing the post process. (default: 0)
  70532. * @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)
  70533. */
  70534. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70535. /**
  70536. * 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.
  70537. */
  70538. set depthTexture(value: RenderTargetTexture);
  70539. }
  70540. }
  70541. declare module BABYLON {
  70542. /** @hidden */
  70543. export var colorCorrectionPixelShader: {
  70544. name: string;
  70545. shader: string;
  70546. };
  70547. }
  70548. declare module BABYLON {
  70549. /**
  70550. *
  70551. * This post-process allows the modification of rendered colors by using
  70552. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70553. *
  70554. * The object needs to be provided an url to a texture containing the color
  70555. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70556. * Use an image editing software to tweak the LUT to match your needs.
  70557. *
  70558. * For an example of a color LUT, see here:
  70559. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70560. * For explanations on color grading, see here:
  70561. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70562. *
  70563. */
  70564. export class ColorCorrectionPostProcess extends PostProcess {
  70565. private _colorTableTexture;
  70566. /**
  70567. * Gets the color table url used to create the LUT texture
  70568. */
  70569. colorTableUrl: string;
  70570. /**
  70571. * Gets a string identifying the name of the class
  70572. * @returns "ColorCorrectionPostProcess" string
  70573. */
  70574. getClassName(): string;
  70575. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70576. /** @hidden */
  70577. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70578. }
  70579. }
  70580. declare module BABYLON {
  70581. /** @hidden */
  70582. export var convolutionPixelShader: {
  70583. name: string;
  70584. shader: string;
  70585. };
  70586. }
  70587. declare module BABYLON {
  70588. /**
  70589. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70590. * input texture to perform effects such as edge detection or sharpening
  70591. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70592. */
  70593. export class ConvolutionPostProcess extends PostProcess {
  70594. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70595. kernel: number[];
  70596. /**
  70597. * Gets a string identifying the name of the class
  70598. * @returns "ConvolutionPostProcess" string
  70599. */
  70600. getClassName(): string;
  70601. /**
  70602. * Creates a new instance ConvolutionPostProcess
  70603. * @param name The name of the effect.
  70604. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70605. * @param options The required width/height ratio to downsize to before computing the render pass.
  70606. * @param camera The camera to apply the render pass to.
  70607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70608. * @param engine The engine which the post process will be applied. (default: current engine)
  70609. * @param reusable If the post process can be reused on the same frame. (default: false)
  70610. * @param textureType Type of textures used when performing the post process. (default: 0)
  70611. */
  70612. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70613. /** @hidden */
  70614. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70615. /**
  70616. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70617. */
  70618. static EdgeDetect0Kernel: number[];
  70619. /**
  70620. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70621. */
  70622. static EdgeDetect1Kernel: number[];
  70623. /**
  70624. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70625. */
  70626. static EdgeDetect2Kernel: number[];
  70627. /**
  70628. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70629. */
  70630. static SharpenKernel: number[];
  70631. /**
  70632. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70633. */
  70634. static EmbossKernel: number[];
  70635. /**
  70636. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70637. */
  70638. static GaussianKernel: number[];
  70639. }
  70640. }
  70641. declare module BABYLON {
  70642. /**
  70643. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70644. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70645. * based on samples that have a large difference in distance than the center pixel.
  70646. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70647. */
  70648. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70649. /**
  70650. * The direction the blur should be applied
  70651. */
  70652. direction: Vector2;
  70653. /**
  70654. * Gets a string identifying the name of the class
  70655. * @returns "DepthOfFieldBlurPostProcess" string
  70656. */
  70657. getClassName(): string;
  70658. /**
  70659. * Creates a new instance CircleOfConfusionPostProcess
  70660. * @param name The name of the effect.
  70661. * @param scene The scene the effect belongs to.
  70662. * @param direction The direction the blur should be applied.
  70663. * @param kernel The size of the kernel used to blur.
  70664. * @param options The required width/height ratio to downsize to before computing the render pass.
  70665. * @param camera The camera to apply the render pass to.
  70666. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70667. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70669. * @param engine The engine which the post process will be applied. (default: current engine)
  70670. * @param reusable If the post process can be reused on the same frame. (default: false)
  70671. * @param textureType Type of textures used when performing the post process. (default: 0)
  70672. * @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)
  70673. */
  70674. 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);
  70675. }
  70676. }
  70677. declare module BABYLON {
  70678. /** @hidden */
  70679. export var depthOfFieldMergePixelShader: {
  70680. name: string;
  70681. shader: string;
  70682. };
  70683. }
  70684. declare module BABYLON {
  70685. /**
  70686. * Options to be set when merging outputs from the default pipeline.
  70687. */
  70688. export class DepthOfFieldMergePostProcessOptions {
  70689. /**
  70690. * The original image to merge on top of
  70691. */
  70692. originalFromInput: PostProcess;
  70693. /**
  70694. * Parameters to perform the merge of the depth of field effect
  70695. */
  70696. depthOfField?: {
  70697. circleOfConfusion: PostProcess;
  70698. blurSteps: Array<PostProcess>;
  70699. };
  70700. /**
  70701. * Parameters to perform the merge of bloom effect
  70702. */
  70703. bloom?: {
  70704. blurred: PostProcess;
  70705. weight: number;
  70706. };
  70707. }
  70708. /**
  70709. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70710. */
  70711. export class DepthOfFieldMergePostProcess extends PostProcess {
  70712. private blurSteps;
  70713. /**
  70714. * Gets a string identifying the name of the class
  70715. * @returns "DepthOfFieldMergePostProcess" string
  70716. */
  70717. getClassName(): string;
  70718. /**
  70719. * Creates a new instance of DepthOfFieldMergePostProcess
  70720. * @param name The name of the effect.
  70721. * @param originalFromInput Post process which's input will be used for the merge.
  70722. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70723. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70724. * @param options The required width/height ratio to downsize to before computing the render pass.
  70725. * @param camera The camera to apply the render pass to.
  70726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70727. * @param engine The engine which the post process will be applied. (default: current engine)
  70728. * @param reusable If the post process can be reused on the same frame. (default: false)
  70729. * @param textureType Type of textures used when performing the post process. (default: 0)
  70730. * @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)
  70731. */
  70732. 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);
  70733. /**
  70734. * Updates the effect with the current post process compile time values and recompiles the shader.
  70735. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70736. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70737. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70738. * @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
  70739. * @param onCompiled Called when the shader has been compiled.
  70740. * @param onError Called if there is an error when compiling a shader.
  70741. */
  70742. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70743. }
  70744. }
  70745. declare module BABYLON {
  70746. /**
  70747. * Specifies the level of max blur that should be applied when using the depth of field effect
  70748. */
  70749. export enum DepthOfFieldEffectBlurLevel {
  70750. /**
  70751. * Subtle blur
  70752. */
  70753. Low = 0,
  70754. /**
  70755. * Medium blur
  70756. */
  70757. Medium = 1,
  70758. /**
  70759. * Large blur
  70760. */
  70761. High = 2
  70762. }
  70763. /**
  70764. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70765. */
  70766. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70767. private _circleOfConfusion;
  70768. /**
  70769. * @hidden Internal, blurs from high to low
  70770. */
  70771. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70772. private _depthOfFieldBlurY;
  70773. private _dofMerge;
  70774. /**
  70775. * @hidden Internal post processes in depth of field effect
  70776. */
  70777. _effects: Array<PostProcess>;
  70778. /**
  70779. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70780. */
  70781. set focalLength(value: number);
  70782. get focalLength(): number;
  70783. /**
  70784. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70785. */
  70786. set fStop(value: number);
  70787. get fStop(): number;
  70788. /**
  70789. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70790. */
  70791. set focusDistance(value: number);
  70792. get focusDistance(): number;
  70793. /**
  70794. * 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.
  70795. */
  70796. set lensSize(value: number);
  70797. get lensSize(): number;
  70798. /**
  70799. * Creates a new instance DepthOfFieldEffect
  70800. * @param scene The scene the effect belongs to.
  70801. * @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.
  70802. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70803. * @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)
  70804. */
  70805. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70806. /**
  70807. * Get the current class name of the current effet
  70808. * @returns "DepthOfFieldEffect"
  70809. */
  70810. getClassName(): string;
  70811. /**
  70812. * 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.
  70813. */
  70814. set depthTexture(value: RenderTargetTexture);
  70815. /**
  70816. * Disposes each of the internal effects for a given camera.
  70817. * @param camera The camera to dispose the effect on.
  70818. */
  70819. disposeEffects(camera: Camera): void;
  70820. /**
  70821. * @hidden Internal
  70822. */
  70823. _updateEffects(): void;
  70824. /**
  70825. * Internal
  70826. * @returns if all the contained post processes are ready.
  70827. * @hidden
  70828. */
  70829. _isReady(): boolean;
  70830. }
  70831. }
  70832. declare module BABYLON {
  70833. /** @hidden */
  70834. export var displayPassPixelShader: {
  70835. name: string;
  70836. shader: string;
  70837. };
  70838. }
  70839. declare module BABYLON {
  70840. /**
  70841. * DisplayPassPostProcess which produces an output the same as it's input
  70842. */
  70843. export class DisplayPassPostProcess extends PostProcess {
  70844. /**
  70845. * Gets a string identifying the name of the class
  70846. * @returns "DisplayPassPostProcess" string
  70847. */
  70848. getClassName(): string;
  70849. /**
  70850. * Creates the DisplayPassPostProcess
  70851. * @param name The name of the effect.
  70852. * @param options The required width/height ratio to downsize to before computing the render pass.
  70853. * @param camera The camera to apply the render pass to.
  70854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70855. * @param engine The engine which the post process will be applied. (default: current engine)
  70856. * @param reusable If the post process can be reused on the same frame. (default: false)
  70857. */
  70858. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70859. /** @hidden */
  70860. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70861. }
  70862. }
  70863. declare module BABYLON {
  70864. /** @hidden */
  70865. export var filterPixelShader: {
  70866. name: string;
  70867. shader: string;
  70868. };
  70869. }
  70870. declare module BABYLON {
  70871. /**
  70872. * Applies a kernel filter to the image
  70873. */
  70874. export class FilterPostProcess extends PostProcess {
  70875. /** The matrix to be applied to the image */
  70876. kernelMatrix: Matrix;
  70877. /**
  70878. * Gets a string identifying the name of the class
  70879. * @returns "FilterPostProcess" string
  70880. */
  70881. getClassName(): string;
  70882. /**
  70883. *
  70884. * @param name The name of the effect.
  70885. * @param kernelMatrix The matrix to be applied to the image
  70886. * @param options The required width/height ratio to downsize to before computing the render pass.
  70887. * @param camera The camera to apply the render pass to.
  70888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70889. * @param engine The engine which the post process will be applied. (default: current engine)
  70890. * @param reusable If the post process can be reused on the same frame. (default: false)
  70891. */
  70892. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70893. /** @hidden */
  70894. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70895. }
  70896. }
  70897. declare module BABYLON {
  70898. /** @hidden */
  70899. export var fxaaPixelShader: {
  70900. name: string;
  70901. shader: string;
  70902. };
  70903. }
  70904. declare module BABYLON {
  70905. /** @hidden */
  70906. export var fxaaVertexShader: {
  70907. name: string;
  70908. shader: string;
  70909. };
  70910. }
  70911. declare module BABYLON {
  70912. /**
  70913. * Fxaa post process
  70914. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70915. */
  70916. export class FxaaPostProcess extends PostProcess {
  70917. /**
  70918. * Gets a string identifying the name of the class
  70919. * @returns "FxaaPostProcess" string
  70920. */
  70921. getClassName(): string;
  70922. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70923. private _getDefines;
  70924. /** @hidden */
  70925. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70926. }
  70927. }
  70928. declare module BABYLON {
  70929. /** @hidden */
  70930. export var grainPixelShader: {
  70931. name: string;
  70932. shader: string;
  70933. };
  70934. }
  70935. declare module BABYLON {
  70936. /**
  70937. * The GrainPostProcess adds noise to the image at mid luminance levels
  70938. */
  70939. export class GrainPostProcess extends PostProcess {
  70940. /**
  70941. * The intensity of the grain added (default: 30)
  70942. */
  70943. intensity: number;
  70944. /**
  70945. * If the grain should be randomized on every frame
  70946. */
  70947. animated: boolean;
  70948. /**
  70949. * Gets a string identifying the name of the class
  70950. * @returns "GrainPostProcess" string
  70951. */
  70952. getClassName(): string;
  70953. /**
  70954. * Creates a new instance of @see GrainPostProcess
  70955. * @param name The name of the effect.
  70956. * @param options The required width/height ratio to downsize to before computing the render pass.
  70957. * @param camera The camera to apply the render pass to.
  70958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70959. * @param engine The engine which the post process will be applied. (default: current engine)
  70960. * @param reusable If the post process can be reused on the same frame. (default: false)
  70961. * @param textureType Type of textures used when performing the post process. (default: 0)
  70962. * @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)
  70963. */
  70964. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70965. /** @hidden */
  70966. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70967. }
  70968. }
  70969. declare module BABYLON {
  70970. /** @hidden */
  70971. export var highlightsPixelShader: {
  70972. name: string;
  70973. shader: string;
  70974. };
  70975. }
  70976. declare module BABYLON {
  70977. /**
  70978. * Extracts highlights from the image
  70979. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70980. */
  70981. export class HighlightsPostProcess extends PostProcess {
  70982. /**
  70983. * Gets a string identifying the name of the class
  70984. * @returns "HighlightsPostProcess" string
  70985. */
  70986. getClassName(): string;
  70987. /**
  70988. * Extracts highlights from the image
  70989. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70990. * @param name The name of the effect.
  70991. * @param options The required width/height ratio to downsize to before computing the render pass.
  70992. * @param camera The camera to apply the render pass to.
  70993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70994. * @param engine The engine which the post process will be applied. (default: current engine)
  70995. * @param reusable If the post process can be reused on the same frame. (default: false)
  70996. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70997. */
  70998. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70999. }
  71000. }
  71001. declare module BABYLON {
  71002. /**
  71003. * Contains all parameters needed for the prepass to perform
  71004. * motion blur
  71005. */
  71006. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  71007. /**
  71008. * Is motion blur enabled
  71009. */
  71010. enabled: boolean;
  71011. /**
  71012. * Name of the configuration
  71013. */
  71014. name: string;
  71015. /**
  71016. * Textures that should be present in the MRT for this effect to work
  71017. */
  71018. readonly texturesRequired: number[];
  71019. }
  71020. }
  71021. declare module BABYLON {
  71022. interface Scene {
  71023. /** @hidden (Backing field) */
  71024. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71025. /**
  71026. * Gets or Sets the current geometry buffer associated to the scene.
  71027. */
  71028. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71029. /**
  71030. * Enables a GeometryBufferRender and associates it with the scene
  71031. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71032. * @returns the GeometryBufferRenderer
  71033. */
  71034. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71035. /**
  71036. * Disables the GeometryBufferRender associated with the scene
  71037. */
  71038. disableGeometryBufferRenderer(): void;
  71039. }
  71040. /**
  71041. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71042. * in several rendering techniques.
  71043. */
  71044. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71045. /**
  71046. * The component name helpful to identify the component in the list of scene components.
  71047. */
  71048. readonly name: string;
  71049. /**
  71050. * The scene the component belongs to.
  71051. */
  71052. scene: Scene;
  71053. /**
  71054. * Creates a new instance of the component for the given scene
  71055. * @param scene Defines the scene to register the component in
  71056. */
  71057. constructor(scene: Scene);
  71058. /**
  71059. * Registers the component in a given scene
  71060. */
  71061. register(): void;
  71062. /**
  71063. * Rebuilds the elements related to this component in case of
  71064. * context lost for instance.
  71065. */
  71066. rebuild(): void;
  71067. /**
  71068. * Disposes the component and the associated ressources
  71069. */
  71070. dispose(): void;
  71071. private _gatherRenderTargets;
  71072. }
  71073. }
  71074. declare module BABYLON {
  71075. /** @hidden */
  71076. export var motionBlurPixelShader: {
  71077. name: string;
  71078. shader: string;
  71079. };
  71080. }
  71081. declare module BABYLON {
  71082. /**
  71083. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71084. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71085. * As an example, all you have to do is to create the post-process:
  71086. * var mb = new BABYLON.MotionBlurPostProcess(
  71087. * 'mb', // The name of the effect.
  71088. * scene, // The scene containing the objects to blur according to their velocity.
  71089. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71090. * camera // The camera to apply the render pass to.
  71091. * );
  71092. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71093. */
  71094. export class MotionBlurPostProcess extends PostProcess {
  71095. /**
  71096. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71097. */
  71098. motionStrength: number;
  71099. /**
  71100. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71101. */
  71102. get motionBlurSamples(): number;
  71103. /**
  71104. * Sets the number of iterations to be used for motion blur quality
  71105. */
  71106. set motionBlurSamples(samples: number);
  71107. private _motionBlurSamples;
  71108. private _forceGeometryBuffer;
  71109. private _geometryBufferRenderer;
  71110. private _prePassRenderer;
  71111. /**
  71112. * Gets a string identifying the name of the class
  71113. * @returns "MotionBlurPostProcess" string
  71114. */
  71115. getClassName(): string;
  71116. /**
  71117. * Creates a new instance MotionBlurPostProcess
  71118. * @param name The name of the effect.
  71119. * @param scene The scene containing the objects to blur according to their velocity.
  71120. * @param options The required width/height ratio to downsize to before computing the render pass.
  71121. * @param camera The camera to apply the render pass to.
  71122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71123. * @param engine The engine which the post process will be applied. (default: current engine)
  71124. * @param reusable If the post process can be reused on the same frame. (default: false)
  71125. * @param textureType Type of textures used when performing the post process. (default: 0)
  71126. * @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)
  71127. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71128. */
  71129. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71130. /**
  71131. * Excludes the given skinned mesh from computing bones velocities.
  71132. * 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.
  71133. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71134. */
  71135. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71136. /**
  71137. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71138. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71139. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71140. */
  71141. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71142. /**
  71143. * Disposes the post process.
  71144. * @param camera The camera to dispose the post process on.
  71145. */
  71146. dispose(camera?: Camera): void;
  71147. /** @hidden */
  71148. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71149. }
  71150. }
  71151. declare module BABYLON {
  71152. /** @hidden */
  71153. export var refractionPixelShader: {
  71154. name: string;
  71155. shader: string;
  71156. };
  71157. }
  71158. declare module BABYLON {
  71159. /**
  71160. * Post process which applies a refractin texture
  71161. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71162. */
  71163. export class RefractionPostProcess extends PostProcess {
  71164. private _refTexture;
  71165. private _ownRefractionTexture;
  71166. /** the base color of the refraction (used to taint the rendering) */
  71167. color: Color3;
  71168. /** simulated refraction depth */
  71169. depth: number;
  71170. /** the coefficient of the base color (0 to remove base color tainting) */
  71171. colorLevel: number;
  71172. /** Gets the url used to load the refraction texture */
  71173. refractionTextureUrl: string;
  71174. /**
  71175. * Gets or sets the refraction texture
  71176. * Please note that you are responsible for disposing the texture if you set it manually
  71177. */
  71178. get refractionTexture(): Texture;
  71179. set refractionTexture(value: Texture);
  71180. /**
  71181. * Gets a string identifying the name of the class
  71182. * @returns "RefractionPostProcess" string
  71183. */
  71184. getClassName(): string;
  71185. /**
  71186. * Initializes the RefractionPostProcess
  71187. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71188. * @param name The name of the effect.
  71189. * @param refractionTextureUrl Url of the refraction texture to use
  71190. * @param color the base color of the refraction (used to taint the rendering)
  71191. * @param depth simulated refraction depth
  71192. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71193. * @param camera The camera to apply the render pass to.
  71194. * @param options The required width/height ratio to downsize to before computing the render pass.
  71195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71196. * @param engine The engine which the post process will be applied. (default: current engine)
  71197. * @param reusable If the post process can be reused on the same frame. (default: false)
  71198. */
  71199. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71200. /**
  71201. * Disposes of the post process
  71202. * @param camera Camera to dispose post process on
  71203. */
  71204. dispose(camera: Camera): void;
  71205. /** @hidden */
  71206. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71207. }
  71208. }
  71209. declare module BABYLON {
  71210. /** @hidden */
  71211. export var sharpenPixelShader: {
  71212. name: string;
  71213. shader: string;
  71214. };
  71215. }
  71216. declare module BABYLON {
  71217. /**
  71218. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71219. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71220. */
  71221. export class SharpenPostProcess extends PostProcess {
  71222. /**
  71223. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71224. */
  71225. colorAmount: number;
  71226. /**
  71227. * How much sharpness should be applied (default: 0.3)
  71228. */
  71229. edgeAmount: number;
  71230. /**
  71231. * Gets a string identifying the name of the class
  71232. * @returns "SharpenPostProcess" string
  71233. */
  71234. getClassName(): string;
  71235. /**
  71236. * Creates a new instance ConvolutionPostProcess
  71237. * @param name The name of the effect.
  71238. * @param options The required width/height ratio to downsize to before computing the render pass.
  71239. * @param camera The camera to apply the render pass to.
  71240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71241. * @param engine The engine which the post process will be applied. (default: current engine)
  71242. * @param reusable If the post process can be reused on the same frame. (default: false)
  71243. * @param textureType Type of textures used when performing the post process. (default: 0)
  71244. * @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)
  71245. */
  71246. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71247. /** @hidden */
  71248. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71249. }
  71250. }
  71251. declare module BABYLON {
  71252. /**
  71253. * PostProcessRenderPipeline
  71254. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71255. */
  71256. export class PostProcessRenderPipeline {
  71257. private engine;
  71258. private _renderEffects;
  71259. private _renderEffectsForIsolatedPass;
  71260. /**
  71261. * List of inspectable custom properties (used by the Inspector)
  71262. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71263. */
  71264. inspectableCustomProperties: IInspectable[];
  71265. /**
  71266. * @hidden
  71267. */
  71268. protected _cameras: Camera[];
  71269. /** @hidden */
  71270. _name: string;
  71271. /**
  71272. * Gets pipeline name
  71273. */
  71274. get name(): string;
  71275. /** Gets the list of attached cameras */
  71276. get cameras(): Camera[];
  71277. /**
  71278. * Initializes a PostProcessRenderPipeline
  71279. * @param engine engine to add the pipeline to
  71280. * @param name name of the pipeline
  71281. */
  71282. constructor(engine: Engine, name: string);
  71283. /**
  71284. * Gets the class name
  71285. * @returns "PostProcessRenderPipeline"
  71286. */
  71287. getClassName(): string;
  71288. /**
  71289. * If all the render effects in the pipeline are supported
  71290. */
  71291. get isSupported(): boolean;
  71292. /**
  71293. * Adds an effect to the pipeline
  71294. * @param renderEffect the effect to add
  71295. */
  71296. addEffect(renderEffect: PostProcessRenderEffect): void;
  71297. /** @hidden */
  71298. _rebuild(): void;
  71299. /** @hidden */
  71300. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71301. /** @hidden */
  71302. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71303. /** @hidden */
  71304. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71305. /** @hidden */
  71306. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71307. /** @hidden */
  71308. _attachCameras(cameras: Camera, unique: boolean): void;
  71309. /** @hidden */
  71310. _attachCameras(cameras: Camera[], unique: boolean): void;
  71311. /** @hidden */
  71312. _detachCameras(cameras: Camera): void;
  71313. /** @hidden */
  71314. _detachCameras(cameras: Nullable<Camera[]>): void;
  71315. /** @hidden */
  71316. _update(): void;
  71317. /** @hidden */
  71318. _reset(): void;
  71319. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71320. /**
  71321. * Sets the required values to the prepass renderer.
  71322. * @param prePassRenderer defines the prepass renderer to setup.
  71323. * @returns true if the pre pass is needed.
  71324. */
  71325. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71326. /**
  71327. * Disposes of the pipeline
  71328. */
  71329. dispose(): void;
  71330. }
  71331. }
  71332. declare module BABYLON {
  71333. /**
  71334. * PostProcessRenderPipelineManager class
  71335. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71336. */
  71337. export class PostProcessRenderPipelineManager {
  71338. private _renderPipelines;
  71339. /**
  71340. * Initializes a PostProcessRenderPipelineManager
  71341. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71342. */
  71343. constructor();
  71344. /**
  71345. * Gets the list of supported render pipelines
  71346. */
  71347. get supportedPipelines(): PostProcessRenderPipeline[];
  71348. /**
  71349. * Adds a pipeline to the manager
  71350. * @param renderPipeline The pipeline to add
  71351. */
  71352. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71353. /**
  71354. * Attaches a camera to the pipeline
  71355. * @param renderPipelineName The name of the pipeline to attach to
  71356. * @param cameras the camera to attach
  71357. * @param unique if the camera can be attached multiple times to the pipeline
  71358. */
  71359. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71360. /**
  71361. * Detaches a camera from the pipeline
  71362. * @param renderPipelineName The name of the pipeline to detach from
  71363. * @param cameras the camera to detach
  71364. */
  71365. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71366. /**
  71367. * Enables an effect by name on a pipeline
  71368. * @param renderPipelineName the name of the pipeline to enable the effect in
  71369. * @param renderEffectName the name of the effect to enable
  71370. * @param cameras the cameras that the effect should be enabled on
  71371. */
  71372. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71373. /**
  71374. * Disables an effect by name on a pipeline
  71375. * @param renderPipelineName the name of the pipeline to disable the effect in
  71376. * @param renderEffectName the name of the effect to disable
  71377. * @param cameras the cameras that the effect should be disabled on
  71378. */
  71379. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71380. /**
  71381. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71382. */
  71383. update(): void;
  71384. /** @hidden */
  71385. _rebuild(): void;
  71386. /**
  71387. * Disposes of the manager and pipelines
  71388. */
  71389. dispose(): void;
  71390. }
  71391. }
  71392. declare module BABYLON {
  71393. interface Scene {
  71394. /** @hidden (Backing field) */
  71395. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71396. /**
  71397. * Gets the postprocess render pipeline manager
  71398. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71399. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71400. */
  71401. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71402. }
  71403. /**
  71404. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71405. */
  71406. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71407. /**
  71408. * The component name helpfull to identify the component in the list of scene components.
  71409. */
  71410. readonly name: string;
  71411. /**
  71412. * The scene the component belongs to.
  71413. */
  71414. scene: Scene;
  71415. /**
  71416. * Creates a new instance of the component for the given scene
  71417. * @param scene Defines the scene to register the component in
  71418. */
  71419. constructor(scene: Scene);
  71420. /**
  71421. * Registers the component in a given scene
  71422. */
  71423. register(): void;
  71424. /**
  71425. * Rebuilds the elements related to this component in case of
  71426. * context lost for instance.
  71427. */
  71428. rebuild(): void;
  71429. /**
  71430. * Disposes the component and the associated ressources
  71431. */
  71432. dispose(): void;
  71433. private _gatherRenderTargets;
  71434. }
  71435. }
  71436. declare module BABYLON {
  71437. /**
  71438. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71439. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71440. */
  71441. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71442. private _scene;
  71443. private _camerasToBeAttached;
  71444. /**
  71445. * ID of the sharpen post process,
  71446. */
  71447. private readonly SharpenPostProcessId;
  71448. /**
  71449. * @ignore
  71450. * ID of the image processing post process;
  71451. */
  71452. readonly ImageProcessingPostProcessId: string;
  71453. /**
  71454. * @ignore
  71455. * ID of the Fast Approximate Anti-Aliasing post process;
  71456. */
  71457. readonly FxaaPostProcessId: string;
  71458. /**
  71459. * ID of the chromatic aberration post process,
  71460. */
  71461. private readonly ChromaticAberrationPostProcessId;
  71462. /**
  71463. * ID of the grain post process
  71464. */
  71465. private readonly GrainPostProcessId;
  71466. /**
  71467. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71468. */
  71469. sharpen: SharpenPostProcess;
  71470. private _sharpenEffect;
  71471. private bloom;
  71472. /**
  71473. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71474. */
  71475. depthOfField: DepthOfFieldEffect;
  71476. /**
  71477. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71478. */
  71479. fxaa: FxaaPostProcess;
  71480. /**
  71481. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71482. */
  71483. imageProcessing: ImageProcessingPostProcess;
  71484. /**
  71485. * Chromatic aberration post process which will shift rgb colors in the image
  71486. */
  71487. chromaticAberration: ChromaticAberrationPostProcess;
  71488. private _chromaticAberrationEffect;
  71489. /**
  71490. * Grain post process which add noise to the image
  71491. */
  71492. grain: GrainPostProcess;
  71493. private _grainEffect;
  71494. /**
  71495. * Glow post process which adds a glow to emissive areas of the image
  71496. */
  71497. private _glowLayer;
  71498. /**
  71499. * Animations which can be used to tweak settings over a period of time
  71500. */
  71501. animations: Animation[];
  71502. private _imageProcessingConfigurationObserver;
  71503. private _sharpenEnabled;
  71504. private _bloomEnabled;
  71505. private _depthOfFieldEnabled;
  71506. private _depthOfFieldBlurLevel;
  71507. private _fxaaEnabled;
  71508. private _imageProcessingEnabled;
  71509. private _defaultPipelineTextureType;
  71510. private _bloomScale;
  71511. private _chromaticAberrationEnabled;
  71512. private _grainEnabled;
  71513. private _buildAllowed;
  71514. /**
  71515. * This is triggered each time the pipeline has been built.
  71516. */
  71517. onBuildObservable: Observable<DefaultRenderingPipeline>;
  71518. /**
  71519. * Gets active scene
  71520. */
  71521. get scene(): Scene;
  71522. /**
  71523. * Enable or disable the sharpen process from the pipeline
  71524. */
  71525. set sharpenEnabled(enabled: boolean);
  71526. get sharpenEnabled(): boolean;
  71527. private _resizeObserver;
  71528. private _hardwareScaleLevel;
  71529. private _bloomKernel;
  71530. /**
  71531. * Specifies the size of the bloom blur kernel, relative to the final output size
  71532. */
  71533. get bloomKernel(): number;
  71534. set bloomKernel(value: number);
  71535. /**
  71536. * Specifies the weight of the bloom in the final rendering
  71537. */
  71538. private _bloomWeight;
  71539. /**
  71540. * Specifies the luma threshold for the area that will be blurred by the bloom
  71541. */
  71542. private _bloomThreshold;
  71543. private _hdr;
  71544. /**
  71545. * The strength of the bloom.
  71546. */
  71547. set bloomWeight(value: number);
  71548. get bloomWeight(): number;
  71549. /**
  71550. * The strength of the bloom.
  71551. */
  71552. set bloomThreshold(value: number);
  71553. get bloomThreshold(): number;
  71554. /**
  71555. * The scale of the bloom, lower value will provide better performance.
  71556. */
  71557. set bloomScale(value: number);
  71558. get bloomScale(): number;
  71559. /**
  71560. * Enable or disable the bloom from the pipeline
  71561. */
  71562. set bloomEnabled(enabled: boolean);
  71563. get bloomEnabled(): boolean;
  71564. private _rebuildBloom;
  71565. /**
  71566. * If the depth of field is enabled.
  71567. */
  71568. get depthOfFieldEnabled(): boolean;
  71569. set depthOfFieldEnabled(enabled: boolean);
  71570. /**
  71571. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71572. */
  71573. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71574. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71575. /**
  71576. * If the anti aliasing is enabled.
  71577. */
  71578. set fxaaEnabled(enabled: boolean);
  71579. get fxaaEnabled(): boolean;
  71580. private _samples;
  71581. /**
  71582. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71583. */
  71584. set samples(sampleCount: number);
  71585. get samples(): number;
  71586. /**
  71587. * If image processing is enabled.
  71588. */
  71589. set imageProcessingEnabled(enabled: boolean);
  71590. get imageProcessingEnabled(): boolean;
  71591. /**
  71592. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71593. */
  71594. set glowLayerEnabled(enabled: boolean);
  71595. get glowLayerEnabled(): boolean;
  71596. /**
  71597. * Gets the glow layer (or null if not defined)
  71598. */
  71599. get glowLayer(): Nullable<GlowLayer>;
  71600. /**
  71601. * Enable or disable the chromaticAberration process from the pipeline
  71602. */
  71603. set chromaticAberrationEnabled(enabled: boolean);
  71604. get chromaticAberrationEnabled(): boolean;
  71605. /**
  71606. * Enable or disable the grain process from the pipeline
  71607. */
  71608. set grainEnabled(enabled: boolean);
  71609. get grainEnabled(): boolean;
  71610. /**
  71611. * @constructor
  71612. * @param name - The rendering pipeline name (default: "")
  71613. * @param hdr - If high dynamic range textures should be used (default: true)
  71614. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71615. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71616. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71617. */
  71618. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71619. /**
  71620. * Get the class name
  71621. * @returns "DefaultRenderingPipeline"
  71622. */
  71623. getClassName(): string;
  71624. /**
  71625. * Force the compilation of the entire pipeline.
  71626. */
  71627. prepare(): void;
  71628. private _hasCleared;
  71629. private _prevPostProcess;
  71630. private _prevPrevPostProcess;
  71631. private _setAutoClearAndTextureSharing;
  71632. private _depthOfFieldSceneObserver;
  71633. private _buildPipeline;
  71634. private _disposePostProcesses;
  71635. /**
  71636. * Adds a camera to the pipeline
  71637. * @param camera the camera to be added
  71638. */
  71639. addCamera(camera: Camera): void;
  71640. /**
  71641. * Removes a camera from the pipeline
  71642. * @param camera the camera to remove
  71643. */
  71644. removeCamera(camera: Camera): void;
  71645. /**
  71646. * Dispose of the pipeline and stop all post processes
  71647. */
  71648. dispose(): void;
  71649. /**
  71650. * Serialize the rendering pipeline (Used when exporting)
  71651. * @returns the serialized object
  71652. */
  71653. serialize(): any;
  71654. /**
  71655. * Parse the serialized pipeline
  71656. * @param source Source pipeline.
  71657. * @param scene The scene to load the pipeline to.
  71658. * @param rootUrl The URL of the serialized pipeline.
  71659. * @returns An instantiated pipeline from the serialized object.
  71660. */
  71661. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71662. }
  71663. }
  71664. declare module BABYLON {
  71665. /** @hidden */
  71666. export var lensHighlightsPixelShader: {
  71667. name: string;
  71668. shader: string;
  71669. };
  71670. }
  71671. declare module BABYLON {
  71672. /** @hidden */
  71673. export var depthOfFieldPixelShader: {
  71674. name: string;
  71675. shader: string;
  71676. };
  71677. }
  71678. declare module BABYLON {
  71679. /**
  71680. * BABYLON.JS Chromatic Aberration GLSL Shader
  71681. * Author: Olivier Guyot
  71682. * Separates very slightly R, G and B colors on the edges of the screen
  71683. * Inspired by Francois Tarlier & Martins Upitis
  71684. */
  71685. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71686. /**
  71687. * @ignore
  71688. * The chromatic aberration PostProcess id in the pipeline
  71689. */
  71690. LensChromaticAberrationEffect: string;
  71691. /**
  71692. * @ignore
  71693. * The highlights enhancing PostProcess id in the pipeline
  71694. */
  71695. HighlightsEnhancingEffect: string;
  71696. /**
  71697. * @ignore
  71698. * The depth-of-field PostProcess id in the pipeline
  71699. */
  71700. LensDepthOfFieldEffect: string;
  71701. private _scene;
  71702. private _depthTexture;
  71703. private _grainTexture;
  71704. private _chromaticAberrationPostProcess;
  71705. private _highlightsPostProcess;
  71706. private _depthOfFieldPostProcess;
  71707. private _edgeBlur;
  71708. private _grainAmount;
  71709. private _chromaticAberration;
  71710. private _distortion;
  71711. private _highlightsGain;
  71712. private _highlightsThreshold;
  71713. private _dofDistance;
  71714. private _dofAperture;
  71715. private _dofDarken;
  71716. private _dofPentagon;
  71717. private _blurNoise;
  71718. /**
  71719. * @constructor
  71720. *
  71721. * Effect parameters are as follow:
  71722. * {
  71723. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71724. * edge_blur: number; // from 0 to x (1 for realism)
  71725. * distortion: number; // from 0 to x (1 for realism)
  71726. * grain_amount: number; // from 0 to 1
  71727. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71728. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71729. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71730. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71731. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71732. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71733. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71734. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71735. * }
  71736. * Note: if an effect parameter is unset, effect is disabled
  71737. *
  71738. * @param name The rendering pipeline name
  71739. * @param parameters - An object containing all parameters (see above)
  71740. * @param scene The scene linked to this pipeline
  71741. * @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)
  71742. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71743. */
  71744. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71745. /**
  71746. * Get the class name
  71747. * @returns "LensRenderingPipeline"
  71748. */
  71749. getClassName(): string;
  71750. /**
  71751. * Gets associated scene
  71752. */
  71753. get scene(): Scene;
  71754. /**
  71755. * Gets or sets the edge blur
  71756. */
  71757. get edgeBlur(): number;
  71758. set edgeBlur(value: number);
  71759. /**
  71760. * Gets or sets the grain amount
  71761. */
  71762. get grainAmount(): number;
  71763. set grainAmount(value: number);
  71764. /**
  71765. * Gets or sets the chromatic aberration amount
  71766. */
  71767. get chromaticAberration(): number;
  71768. set chromaticAberration(value: number);
  71769. /**
  71770. * Gets or sets the depth of field aperture
  71771. */
  71772. get dofAperture(): number;
  71773. set dofAperture(value: number);
  71774. /**
  71775. * Gets or sets the edge distortion
  71776. */
  71777. get edgeDistortion(): number;
  71778. set edgeDistortion(value: number);
  71779. /**
  71780. * Gets or sets the depth of field distortion
  71781. */
  71782. get dofDistortion(): number;
  71783. set dofDistortion(value: number);
  71784. /**
  71785. * Gets or sets the darken out of focus amount
  71786. */
  71787. get darkenOutOfFocus(): number;
  71788. set darkenOutOfFocus(value: number);
  71789. /**
  71790. * Gets or sets a boolean indicating if blur noise is enabled
  71791. */
  71792. get blurNoise(): boolean;
  71793. set blurNoise(value: boolean);
  71794. /**
  71795. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71796. */
  71797. get pentagonBokeh(): boolean;
  71798. set pentagonBokeh(value: boolean);
  71799. /**
  71800. * Gets or sets the highlight grain amount
  71801. */
  71802. get highlightsGain(): number;
  71803. set highlightsGain(value: number);
  71804. /**
  71805. * Gets or sets the highlight threshold
  71806. */
  71807. get highlightsThreshold(): number;
  71808. set highlightsThreshold(value: number);
  71809. /**
  71810. * Sets the amount of blur at the edges
  71811. * @param amount blur amount
  71812. */
  71813. setEdgeBlur(amount: number): void;
  71814. /**
  71815. * Sets edge blur to 0
  71816. */
  71817. disableEdgeBlur(): void;
  71818. /**
  71819. * Sets the amout of grain
  71820. * @param amount Amount of grain
  71821. */
  71822. setGrainAmount(amount: number): void;
  71823. /**
  71824. * Set grain amount to 0
  71825. */
  71826. disableGrain(): void;
  71827. /**
  71828. * Sets the chromatic aberration amount
  71829. * @param amount amount of chromatic aberration
  71830. */
  71831. setChromaticAberration(amount: number): void;
  71832. /**
  71833. * Sets chromatic aberration amount to 0
  71834. */
  71835. disableChromaticAberration(): void;
  71836. /**
  71837. * Sets the EdgeDistortion amount
  71838. * @param amount amount of EdgeDistortion
  71839. */
  71840. setEdgeDistortion(amount: number): void;
  71841. /**
  71842. * Sets edge distortion to 0
  71843. */
  71844. disableEdgeDistortion(): void;
  71845. /**
  71846. * Sets the FocusDistance amount
  71847. * @param amount amount of FocusDistance
  71848. */
  71849. setFocusDistance(amount: number): void;
  71850. /**
  71851. * Disables depth of field
  71852. */
  71853. disableDepthOfField(): void;
  71854. /**
  71855. * Sets the Aperture amount
  71856. * @param amount amount of Aperture
  71857. */
  71858. setAperture(amount: number): void;
  71859. /**
  71860. * Sets the DarkenOutOfFocus amount
  71861. * @param amount amount of DarkenOutOfFocus
  71862. */
  71863. setDarkenOutOfFocus(amount: number): void;
  71864. private _pentagonBokehIsEnabled;
  71865. /**
  71866. * Creates a pentagon bokeh effect
  71867. */
  71868. enablePentagonBokeh(): void;
  71869. /**
  71870. * Disables the pentagon bokeh effect
  71871. */
  71872. disablePentagonBokeh(): void;
  71873. /**
  71874. * Enables noise blur
  71875. */
  71876. enableNoiseBlur(): void;
  71877. /**
  71878. * Disables noise blur
  71879. */
  71880. disableNoiseBlur(): void;
  71881. /**
  71882. * Sets the HighlightsGain amount
  71883. * @param amount amount of HighlightsGain
  71884. */
  71885. setHighlightsGain(amount: number): void;
  71886. /**
  71887. * Sets the HighlightsThreshold amount
  71888. * @param amount amount of HighlightsThreshold
  71889. */
  71890. setHighlightsThreshold(amount: number): void;
  71891. /**
  71892. * Disables highlights
  71893. */
  71894. disableHighlights(): void;
  71895. /**
  71896. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71897. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71898. */
  71899. dispose(disableDepthRender?: boolean): void;
  71900. private _createChromaticAberrationPostProcess;
  71901. private _createHighlightsPostProcess;
  71902. private _createDepthOfFieldPostProcess;
  71903. private _createGrainTexture;
  71904. }
  71905. }
  71906. declare module BABYLON {
  71907. /**
  71908. * Contains all parameters needed for the prepass to perform
  71909. * screen space subsurface scattering
  71910. */
  71911. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71912. /**
  71913. * Is subsurface enabled
  71914. */
  71915. enabled: boolean;
  71916. /**
  71917. * Name of the configuration
  71918. */
  71919. name: string;
  71920. /**
  71921. * Textures that should be present in the MRT for this effect to work
  71922. */
  71923. readonly texturesRequired: number[];
  71924. }
  71925. }
  71926. declare module BABYLON {
  71927. /** @hidden */
  71928. export var ssao2PixelShader: {
  71929. name: string;
  71930. shader: string;
  71931. };
  71932. }
  71933. declare module BABYLON {
  71934. /** @hidden */
  71935. export var ssaoCombinePixelShader: {
  71936. name: string;
  71937. shader: string;
  71938. };
  71939. }
  71940. declare module BABYLON {
  71941. /**
  71942. * Render pipeline to produce ssao effect
  71943. */
  71944. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71945. /**
  71946. * @ignore
  71947. * The PassPostProcess id in the pipeline that contains the original scene color
  71948. */
  71949. SSAOOriginalSceneColorEffect: string;
  71950. /**
  71951. * @ignore
  71952. * The SSAO PostProcess id in the pipeline
  71953. */
  71954. SSAORenderEffect: string;
  71955. /**
  71956. * @ignore
  71957. * The horizontal blur PostProcess id in the pipeline
  71958. */
  71959. SSAOBlurHRenderEffect: string;
  71960. /**
  71961. * @ignore
  71962. * The vertical blur PostProcess id in the pipeline
  71963. */
  71964. SSAOBlurVRenderEffect: string;
  71965. /**
  71966. * @ignore
  71967. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71968. */
  71969. SSAOCombineRenderEffect: string;
  71970. /**
  71971. * The output strength of the SSAO post-process. Default value is 1.0.
  71972. */
  71973. totalStrength: number;
  71974. /**
  71975. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71976. */
  71977. maxZ: number;
  71978. /**
  71979. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71980. */
  71981. minZAspect: number;
  71982. private _samples;
  71983. /**
  71984. * Number of samples used for the SSAO calculations. Default value is 8
  71985. */
  71986. set samples(n: number);
  71987. get samples(): number;
  71988. private _textureSamples;
  71989. /**
  71990. * Number of samples to use for antialiasing
  71991. */
  71992. set textureSamples(n: number);
  71993. get textureSamples(): number;
  71994. /**
  71995. * Force rendering the geometry through geometry buffer
  71996. */
  71997. private _forceGeometryBuffer;
  71998. /**
  71999. * Ratio object used for SSAO ratio and blur ratio
  72000. */
  72001. private _ratio;
  72002. /**
  72003. * Dynamically generated sphere sampler.
  72004. */
  72005. private _sampleSphere;
  72006. /**
  72007. * Blur filter offsets
  72008. */
  72009. private _samplerOffsets;
  72010. private _expensiveBlur;
  72011. /**
  72012. * If bilateral blur should be used
  72013. */
  72014. set expensiveBlur(b: boolean);
  72015. get expensiveBlur(): boolean;
  72016. /**
  72017. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72018. */
  72019. radius: number;
  72020. /**
  72021. * The base color of the SSAO post-process
  72022. * The final result is "base + ssao" between [0, 1]
  72023. */
  72024. base: number;
  72025. /**
  72026. * Support test.
  72027. */
  72028. static get IsSupported(): boolean;
  72029. private _scene;
  72030. private _randomTexture;
  72031. private _originalColorPostProcess;
  72032. private _ssaoPostProcess;
  72033. private _blurHPostProcess;
  72034. private _blurVPostProcess;
  72035. private _ssaoCombinePostProcess;
  72036. private _prePassRenderer;
  72037. /**
  72038. * Gets active scene
  72039. */
  72040. get scene(): Scene;
  72041. /**
  72042. * @constructor
  72043. * @param name The rendering pipeline name
  72044. * @param scene The scene linked to this pipeline
  72045. * @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 }
  72046. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72047. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  72048. */
  72049. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  72050. /**
  72051. * Get the class name
  72052. * @returns "SSAO2RenderingPipeline"
  72053. */
  72054. getClassName(): string;
  72055. /**
  72056. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72057. */
  72058. dispose(disableGeometryBufferRenderer?: boolean): void;
  72059. private _createBlurPostProcess;
  72060. /** @hidden */
  72061. _rebuild(): void;
  72062. private _bits;
  72063. private _radicalInverse_VdC;
  72064. private _hammersley;
  72065. private _hemisphereSample_uniform;
  72066. private _generateHemisphere;
  72067. private _getDefinesForSSAO;
  72068. private _createSSAOPostProcess;
  72069. private _createSSAOCombinePostProcess;
  72070. private _createRandomTexture;
  72071. /**
  72072. * Serialize the rendering pipeline (Used when exporting)
  72073. * @returns the serialized object
  72074. */
  72075. serialize(): any;
  72076. /**
  72077. * Parse the serialized pipeline
  72078. * @param source Source pipeline.
  72079. * @param scene The scene to load the pipeline to.
  72080. * @param rootUrl The URL of the serialized pipeline.
  72081. * @returns An instantiated pipeline from the serialized object.
  72082. */
  72083. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72084. }
  72085. }
  72086. declare module BABYLON {
  72087. /** @hidden */
  72088. export var ssaoPixelShader: {
  72089. name: string;
  72090. shader: string;
  72091. };
  72092. }
  72093. declare module BABYLON {
  72094. /**
  72095. * Render pipeline to produce ssao effect
  72096. */
  72097. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72098. /**
  72099. * @ignore
  72100. * The PassPostProcess id in the pipeline that contains the original scene color
  72101. */
  72102. SSAOOriginalSceneColorEffect: string;
  72103. /**
  72104. * @ignore
  72105. * The SSAO PostProcess id in the pipeline
  72106. */
  72107. SSAORenderEffect: string;
  72108. /**
  72109. * @ignore
  72110. * The horizontal blur PostProcess id in the pipeline
  72111. */
  72112. SSAOBlurHRenderEffect: string;
  72113. /**
  72114. * @ignore
  72115. * The vertical blur PostProcess id in the pipeline
  72116. */
  72117. SSAOBlurVRenderEffect: string;
  72118. /**
  72119. * @ignore
  72120. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72121. */
  72122. SSAOCombineRenderEffect: string;
  72123. /**
  72124. * The output strength of the SSAO post-process. Default value is 1.0.
  72125. */
  72126. totalStrength: number;
  72127. /**
  72128. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72129. */
  72130. radius: number;
  72131. /**
  72132. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72133. * Must not be equal to fallOff and superior to fallOff.
  72134. * Default value is 0.0075
  72135. */
  72136. area: number;
  72137. /**
  72138. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72139. * Must not be equal to area and inferior to area.
  72140. * Default value is 0.000001
  72141. */
  72142. fallOff: number;
  72143. /**
  72144. * The base color of the SSAO post-process
  72145. * The final result is "base + ssao" between [0, 1]
  72146. */
  72147. base: number;
  72148. private _scene;
  72149. private _depthTexture;
  72150. private _randomTexture;
  72151. private _originalColorPostProcess;
  72152. private _ssaoPostProcess;
  72153. private _blurHPostProcess;
  72154. private _blurVPostProcess;
  72155. private _ssaoCombinePostProcess;
  72156. private _firstUpdate;
  72157. /**
  72158. * Gets active scene
  72159. */
  72160. get scene(): Scene;
  72161. /**
  72162. * @constructor
  72163. * @param name - The rendering pipeline name
  72164. * @param scene - The scene linked to this pipeline
  72165. * @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 }
  72166. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72167. */
  72168. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72169. /**
  72170. * Get the class name
  72171. * @returns "SSAORenderingPipeline"
  72172. */
  72173. getClassName(): string;
  72174. /**
  72175. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72176. */
  72177. dispose(disableDepthRender?: boolean): void;
  72178. private _createBlurPostProcess;
  72179. /** @hidden */
  72180. _rebuild(): void;
  72181. private _createSSAOPostProcess;
  72182. private _createSSAOCombinePostProcess;
  72183. private _createRandomTexture;
  72184. }
  72185. }
  72186. declare module BABYLON {
  72187. /**
  72188. * Contains all parameters needed for the prepass to perform
  72189. * screen space reflections
  72190. */
  72191. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72192. /**
  72193. * Is ssr enabled
  72194. */
  72195. enabled: boolean;
  72196. /**
  72197. * Name of the configuration
  72198. */
  72199. name: string;
  72200. /**
  72201. * Textures that should be present in the MRT for this effect to work
  72202. */
  72203. readonly texturesRequired: number[];
  72204. }
  72205. }
  72206. declare module BABYLON {
  72207. /** @hidden */
  72208. export var screenSpaceReflectionPixelShader: {
  72209. name: string;
  72210. shader: string;
  72211. };
  72212. }
  72213. declare module BABYLON {
  72214. /**
  72215. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72216. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72217. */
  72218. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72219. /**
  72220. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72221. */
  72222. threshold: number;
  72223. /**
  72224. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72225. */
  72226. strength: number;
  72227. /**
  72228. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72229. */
  72230. reflectionSpecularFalloffExponent: number;
  72231. /**
  72232. * 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]
  72233. */
  72234. step: number;
  72235. /**
  72236. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72237. */
  72238. roughnessFactor: number;
  72239. private _forceGeometryBuffer;
  72240. private _geometryBufferRenderer;
  72241. private _prePassRenderer;
  72242. private _enableSmoothReflections;
  72243. private _reflectionSamples;
  72244. private _smoothSteps;
  72245. /**
  72246. * Gets a string identifying the name of the class
  72247. * @returns "ScreenSpaceReflectionPostProcess" string
  72248. */
  72249. getClassName(): string;
  72250. /**
  72251. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72252. * @param name The name of the effect.
  72253. * @param scene The scene containing the objects to calculate reflections.
  72254. * @param options The required width/height ratio to downsize to before computing the render pass.
  72255. * @param camera The camera to apply the render pass to.
  72256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72257. * @param engine The engine which the post process will be applied. (default: current engine)
  72258. * @param reusable If the post process can be reused on the same frame. (default: false)
  72259. * @param textureType Type of textures used when performing the post process. (default: 0)
  72260. * @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)
  72261. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72262. */
  72263. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72264. /**
  72265. * Gets wether or not smoothing reflections is enabled.
  72266. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72267. */
  72268. get enableSmoothReflections(): boolean;
  72269. /**
  72270. * Sets wether or not smoothing reflections is enabled.
  72271. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72272. */
  72273. set enableSmoothReflections(enabled: boolean);
  72274. /**
  72275. * Gets the number of samples taken while computing reflections. More samples count is high,
  72276. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72277. */
  72278. get reflectionSamples(): number;
  72279. /**
  72280. * Sets the number of samples taken while computing reflections. More samples count is high,
  72281. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72282. */
  72283. set reflectionSamples(samples: number);
  72284. /**
  72285. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72286. * more the post-process will require GPU power and can generate a drop in FPS.
  72287. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72288. */
  72289. get smoothSteps(): number;
  72290. set smoothSteps(steps: number);
  72291. private _updateEffectDefines;
  72292. /** @hidden */
  72293. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72294. }
  72295. }
  72296. declare module BABYLON {
  72297. /** @hidden */
  72298. export var standardPixelShader: {
  72299. name: string;
  72300. shader: string;
  72301. };
  72302. }
  72303. declare module BABYLON {
  72304. /**
  72305. * Standard rendering pipeline
  72306. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72307. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72308. */
  72309. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72310. /**
  72311. * Public members
  72312. */
  72313. /**
  72314. * Post-process which contains the original scene color before the pipeline applies all the effects
  72315. */
  72316. originalPostProcess: Nullable<PostProcess>;
  72317. /**
  72318. * Post-process used to down scale an image x4
  72319. */
  72320. downSampleX4PostProcess: Nullable<PostProcess>;
  72321. /**
  72322. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72323. */
  72324. brightPassPostProcess: Nullable<PostProcess>;
  72325. /**
  72326. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72327. */
  72328. blurHPostProcesses: PostProcess[];
  72329. /**
  72330. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72331. */
  72332. blurVPostProcesses: PostProcess[];
  72333. /**
  72334. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72335. */
  72336. textureAdderPostProcess: Nullable<PostProcess>;
  72337. /**
  72338. * Post-process used to create volumetric lighting effect
  72339. */
  72340. volumetricLightPostProcess: Nullable<PostProcess>;
  72341. /**
  72342. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72343. */
  72344. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72345. /**
  72346. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72347. */
  72348. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72349. /**
  72350. * Post-process used to merge the volumetric light effect and the real scene color
  72351. */
  72352. volumetricLightMergePostProces: Nullable<PostProcess>;
  72353. /**
  72354. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72355. */
  72356. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72357. /**
  72358. * Base post-process used to calculate the average luminance of the final image for HDR
  72359. */
  72360. luminancePostProcess: Nullable<PostProcess>;
  72361. /**
  72362. * Post-processes used to create down sample post-processes in order to get
  72363. * the average luminance of the final image for HDR
  72364. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72365. */
  72366. luminanceDownSamplePostProcesses: PostProcess[];
  72367. /**
  72368. * Post-process used to create a HDR effect (light adaptation)
  72369. */
  72370. hdrPostProcess: Nullable<PostProcess>;
  72371. /**
  72372. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72373. */
  72374. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72375. /**
  72376. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72377. */
  72378. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72379. /**
  72380. * Post-process used to merge the final HDR post-process and the real scene color
  72381. */
  72382. hdrFinalPostProcess: Nullable<PostProcess>;
  72383. /**
  72384. * Post-process used to create a lens flare effect
  72385. */
  72386. lensFlarePostProcess: Nullable<PostProcess>;
  72387. /**
  72388. * Post-process that merges the result of the lens flare post-process and the real scene color
  72389. */
  72390. lensFlareComposePostProcess: Nullable<PostProcess>;
  72391. /**
  72392. * Post-process used to create a motion blur effect
  72393. */
  72394. motionBlurPostProcess: Nullable<PostProcess>;
  72395. /**
  72396. * Post-process used to create a depth of field effect
  72397. */
  72398. depthOfFieldPostProcess: Nullable<PostProcess>;
  72399. /**
  72400. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72401. */
  72402. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72403. /**
  72404. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72405. */
  72406. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72407. /**
  72408. * Represents the brightness threshold in order to configure the illuminated surfaces
  72409. */
  72410. brightThreshold: number;
  72411. /**
  72412. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72413. */
  72414. blurWidth: number;
  72415. /**
  72416. * Sets if the blur for highlighted surfaces must be only horizontal
  72417. */
  72418. horizontalBlur: boolean;
  72419. /**
  72420. * Gets the overall exposure used by the pipeline
  72421. */
  72422. get exposure(): number;
  72423. /**
  72424. * Sets the overall exposure used by the pipeline
  72425. */
  72426. set exposure(value: number);
  72427. /**
  72428. * Texture used typically to simulate "dirty" on camera lens
  72429. */
  72430. lensTexture: Nullable<Texture>;
  72431. /**
  72432. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72433. */
  72434. volumetricLightCoefficient: number;
  72435. /**
  72436. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72437. */
  72438. volumetricLightPower: number;
  72439. /**
  72440. * Used the set the blur intensity to smooth the volumetric lights
  72441. */
  72442. volumetricLightBlurScale: number;
  72443. /**
  72444. * Light (spot or directional) used to generate the volumetric lights rays
  72445. * The source light must have a shadow generate so the pipeline can get its
  72446. * depth map
  72447. */
  72448. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72449. /**
  72450. * For eye adaptation, represents the minimum luminance the eye can see
  72451. */
  72452. hdrMinimumLuminance: number;
  72453. /**
  72454. * For eye adaptation, represents the decrease luminance speed
  72455. */
  72456. hdrDecreaseRate: number;
  72457. /**
  72458. * For eye adaptation, represents the increase luminance speed
  72459. */
  72460. hdrIncreaseRate: number;
  72461. /**
  72462. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72463. */
  72464. get hdrAutoExposure(): boolean;
  72465. /**
  72466. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72467. */
  72468. set hdrAutoExposure(value: boolean);
  72469. /**
  72470. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72471. */
  72472. lensColorTexture: Nullable<Texture>;
  72473. /**
  72474. * The overall strengh for the lens flare effect
  72475. */
  72476. lensFlareStrength: number;
  72477. /**
  72478. * Dispersion coefficient for lens flare ghosts
  72479. */
  72480. lensFlareGhostDispersal: number;
  72481. /**
  72482. * Main lens flare halo width
  72483. */
  72484. lensFlareHaloWidth: number;
  72485. /**
  72486. * Based on the lens distortion effect, defines how much the lens flare result
  72487. * is distorted
  72488. */
  72489. lensFlareDistortionStrength: number;
  72490. /**
  72491. * Configures the blur intensity used for for lens flare (halo)
  72492. */
  72493. lensFlareBlurWidth: number;
  72494. /**
  72495. * Lens star texture must be used to simulate rays on the flares and is available
  72496. * in the documentation
  72497. */
  72498. lensStarTexture: Nullable<Texture>;
  72499. /**
  72500. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72501. * flare effect by taking account of the dirt texture
  72502. */
  72503. lensFlareDirtTexture: Nullable<Texture>;
  72504. /**
  72505. * Represents the focal length for the depth of field effect
  72506. */
  72507. depthOfFieldDistance: number;
  72508. /**
  72509. * Represents the blur intensity for the blurred part of the depth of field effect
  72510. */
  72511. depthOfFieldBlurWidth: number;
  72512. /**
  72513. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72514. */
  72515. get motionStrength(): number;
  72516. /**
  72517. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72518. */
  72519. set motionStrength(strength: number);
  72520. /**
  72521. * Gets wether or not the motion blur post-process is object based or screen based.
  72522. */
  72523. get objectBasedMotionBlur(): boolean;
  72524. /**
  72525. * Sets wether or not the motion blur post-process should be object based or screen based
  72526. */
  72527. set objectBasedMotionBlur(value: boolean);
  72528. /**
  72529. * List of animations for the pipeline (IAnimatable implementation)
  72530. */
  72531. animations: Animation[];
  72532. /**
  72533. * Private members
  72534. */
  72535. private _scene;
  72536. private _currentDepthOfFieldSource;
  72537. private _basePostProcess;
  72538. private _fixedExposure;
  72539. private _currentExposure;
  72540. private _hdrAutoExposure;
  72541. private _hdrCurrentLuminance;
  72542. private _motionStrength;
  72543. private _isObjectBasedMotionBlur;
  72544. private _floatTextureType;
  72545. private _camerasToBeAttached;
  72546. private _ratio;
  72547. private _bloomEnabled;
  72548. private _depthOfFieldEnabled;
  72549. private _vlsEnabled;
  72550. private _lensFlareEnabled;
  72551. private _hdrEnabled;
  72552. private _motionBlurEnabled;
  72553. private _fxaaEnabled;
  72554. private _screenSpaceReflectionsEnabled;
  72555. private _motionBlurSamples;
  72556. private _volumetricLightStepsCount;
  72557. private _samples;
  72558. /**
  72559. * @ignore
  72560. * Specifies if the bloom pipeline is enabled
  72561. */
  72562. get BloomEnabled(): boolean;
  72563. set BloomEnabled(enabled: boolean);
  72564. /**
  72565. * @ignore
  72566. * Specifies if the depth of field pipeline is enabed
  72567. */
  72568. get DepthOfFieldEnabled(): boolean;
  72569. set DepthOfFieldEnabled(enabled: boolean);
  72570. /**
  72571. * @ignore
  72572. * Specifies if the lens flare pipeline is enabed
  72573. */
  72574. get LensFlareEnabled(): boolean;
  72575. set LensFlareEnabled(enabled: boolean);
  72576. /**
  72577. * @ignore
  72578. * Specifies if the HDR pipeline is enabled
  72579. */
  72580. get HDREnabled(): boolean;
  72581. set HDREnabled(enabled: boolean);
  72582. /**
  72583. * @ignore
  72584. * Specifies if the volumetric lights scattering effect is enabled
  72585. */
  72586. get VLSEnabled(): boolean;
  72587. set VLSEnabled(enabled: boolean);
  72588. /**
  72589. * @ignore
  72590. * Specifies if the motion blur effect is enabled
  72591. */
  72592. get MotionBlurEnabled(): boolean;
  72593. set MotionBlurEnabled(enabled: boolean);
  72594. /**
  72595. * Specifies if anti-aliasing is enabled
  72596. */
  72597. get fxaaEnabled(): boolean;
  72598. set fxaaEnabled(enabled: boolean);
  72599. /**
  72600. * Specifies if screen space reflections are enabled.
  72601. */
  72602. get screenSpaceReflectionsEnabled(): boolean;
  72603. set screenSpaceReflectionsEnabled(enabled: boolean);
  72604. /**
  72605. * Specifies the number of steps used to calculate the volumetric lights
  72606. * Typically in interval [50, 200]
  72607. */
  72608. get volumetricLightStepsCount(): number;
  72609. set volumetricLightStepsCount(count: number);
  72610. /**
  72611. * Specifies the number of samples used for the motion blur effect
  72612. * Typically in interval [16, 64]
  72613. */
  72614. get motionBlurSamples(): number;
  72615. set motionBlurSamples(samples: number);
  72616. /**
  72617. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72618. */
  72619. get samples(): number;
  72620. set samples(sampleCount: number);
  72621. /**
  72622. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72623. * @constructor
  72624. * @param name The rendering pipeline name
  72625. * @param scene The scene linked to this pipeline
  72626. * @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)
  72627. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72628. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72629. */
  72630. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72631. private _buildPipeline;
  72632. private _createDownSampleX4PostProcess;
  72633. private _createBrightPassPostProcess;
  72634. private _createBlurPostProcesses;
  72635. private _createTextureAdderPostProcess;
  72636. private _createVolumetricLightPostProcess;
  72637. private _createLuminancePostProcesses;
  72638. private _createHdrPostProcess;
  72639. private _createLensFlarePostProcess;
  72640. private _createDepthOfFieldPostProcess;
  72641. private _createMotionBlurPostProcess;
  72642. private _getDepthTexture;
  72643. private _disposePostProcesses;
  72644. /**
  72645. * Dispose of the pipeline and stop all post processes
  72646. */
  72647. dispose(): void;
  72648. /**
  72649. * Serialize the rendering pipeline (Used when exporting)
  72650. * @returns the serialized object
  72651. */
  72652. serialize(): any;
  72653. /**
  72654. * Parse the serialized pipeline
  72655. * @param source Source pipeline.
  72656. * @param scene The scene to load the pipeline to.
  72657. * @param rootUrl The URL of the serialized pipeline.
  72658. * @returns An instantiated pipeline from the serialized object.
  72659. */
  72660. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72661. /**
  72662. * Luminance steps
  72663. */
  72664. static LuminanceSteps: number;
  72665. }
  72666. }
  72667. declare module BABYLON {
  72668. /** @hidden */
  72669. export var stereoscopicInterlacePixelShader: {
  72670. name: string;
  72671. shader: string;
  72672. };
  72673. }
  72674. declare module BABYLON {
  72675. /**
  72676. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72677. */
  72678. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72679. private _stepSize;
  72680. private _passedProcess;
  72681. /**
  72682. * Gets a string identifying the name of the class
  72683. * @returns "StereoscopicInterlacePostProcessI" string
  72684. */
  72685. getClassName(): string;
  72686. /**
  72687. * Initializes a StereoscopicInterlacePostProcessI
  72688. * @param name The name of the effect.
  72689. * @param rigCameras The rig cameras to be appled to the post process
  72690. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72691. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72693. * @param engine The engine which the post process will be applied. (default: current engine)
  72694. * @param reusable If the post process can be reused on the same frame. (default: false)
  72695. */
  72696. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72697. }
  72698. /**
  72699. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72700. */
  72701. export class StereoscopicInterlacePostProcess extends PostProcess {
  72702. private _stepSize;
  72703. private _passedProcess;
  72704. /**
  72705. * Gets a string identifying the name of the class
  72706. * @returns "StereoscopicInterlacePostProcess" string
  72707. */
  72708. getClassName(): string;
  72709. /**
  72710. * Initializes a StereoscopicInterlacePostProcess
  72711. * @param name The name of the effect.
  72712. * @param rigCameras The rig cameras to be appled to the post process
  72713. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72715. * @param engine The engine which the post process will be applied. (default: current engine)
  72716. * @param reusable If the post process can be reused on the same frame. (default: false)
  72717. */
  72718. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72719. }
  72720. }
  72721. declare module BABYLON {
  72722. /** @hidden */
  72723. export var tonemapPixelShader: {
  72724. name: string;
  72725. shader: string;
  72726. };
  72727. }
  72728. declare module BABYLON {
  72729. /** Defines operator used for tonemapping */
  72730. export enum TonemappingOperator {
  72731. /** Hable */
  72732. Hable = 0,
  72733. /** Reinhard */
  72734. Reinhard = 1,
  72735. /** HejiDawson */
  72736. HejiDawson = 2,
  72737. /** Photographic */
  72738. Photographic = 3
  72739. }
  72740. /**
  72741. * Defines a post process to apply tone mapping
  72742. */
  72743. export class TonemapPostProcess extends PostProcess {
  72744. private _operator;
  72745. /** Defines the required exposure adjustement */
  72746. exposureAdjustment: number;
  72747. /**
  72748. * Gets a string identifying the name of the class
  72749. * @returns "TonemapPostProcess" string
  72750. */
  72751. getClassName(): string;
  72752. /**
  72753. * Creates a new TonemapPostProcess
  72754. * @param name defines the name of the postprocess
  72755. * @param _operator defines the operator to use
  72756. * @param exposureAdjustment defines the required exposure adjustement
  72757. * @param camera defines the camera to use (can be null)
  72758. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72759. * @param engine defines the hosting engine (can be ignore if camera is set)
  72760. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72761. */
  72762. constructor(name: string, _operator: TonemappingOperator,
  72763. /** Defines the required exposure adjustement */
  72764. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72765. }
  72766. }
  72767. declare module BABYLON {
  72768. /** @hidden */
  72769. export var volumetricLightScatteringPixelShader: {
  72770. name: string;
  72771. shader: string;
  72772. };
  72773. }
  72774. declare module BABYLON {
  72775. /** @hidden */
  72776. export var volumetricLightScatteringPassVertexShader: {
  72777. name: string;
  72778. shader: string;
  72779. };
  72780. }
  72781. declare module BABYLON {
  72782. /** @hidden */
  72783. export var volumetricLightScatteringPassPixelShader: {
  72784. name: string;
  72785. shader: string;
  72786. };
  72787. }
  72788. declare module BABYLON {
  72789. /**
  72790. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72791. */
  72792. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72793. private _volumetricLightScatteringPass;
  72794. private _volumetricLightScatteringRTT;
  72795. private _viewPort;
  72796. private _screenCoordinates;
  72797. private _cachedDefines;
  72798. /**
  72799. * If not undefined, the mesh position is computed from the attached node position
  72800. */
  72801. attachedNode: {
  72802. position: Vector3;
  72803. };
  72804. /**
  72805. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72806. */
  72807. customMeshPosition: Vector3;
  72808. /**
  72809. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72810. */
  72811. useCustomMeshPosition: boolean;
  72812. /**
  72813. * If the post-process should inverse the light scattering direction
  72814. */
  72815. invert: boolean;
  72816. /**
  72817. * The internal mesh used by the post-process
  72818. */
  72819. mesh: Mesh;
  72820. /**
  72821. * @hidden
  72822. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72823. */
  72824. get useDiffuseColor(): boolean;
  72825. set useDiffuseColor(useDiffuseColor: boolean);
  72826. /**
  72827. * Array containing the excluded meshes not rendered in the internal pass
  72828. */
  72829. excludedMeshes: AbstractMesh[];
  72830. /**
  72831. * Controls the overall intensity of the post-process
  72832. */
  72833. exposure: number;
  72834. /**
  72835. * Dissipates each sample's contribution in range [0, 1]
  72836. */
  72837. decay: number;
  72838. /**
  72839. * Controls the overall intensity of each sample
  72840. */
  72841. weight: number;
  72842. /**
  72843. * Controls the density of each sample
  72844. */
  72845. density: number;
  72846. /**
  72847. * @constructor
  72848. * @param name The post-process name
  72849. * @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)
  72850. * @param camera The camera that the post-process will be attached to
  72851. * @param mesh The mesh used to create the light scattering
  72852. * @param samples The post-process quality, default 100
  72853. * @param samplingModeThe post-process filtering mode
  72854. * @param engine The babylon engine
  72855. * @param reusable If the post-process is reusable
  72856. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72857. */
  72858. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72859. /**
  72860. * Returns the string "VolumetricLightScatteringPostProcess"
  72861. * @returns "VolumetricLightScatteringPostProcess"
  72862. */
  72863. getClassName(): string;
  72864. private _isReady;
  72865. /**
  72866. * Sets the new light position for light scattering effect
  72867. * @param position The new custom light position
  72868. */
  72869. setCustomMeshPosition(position: Vector3): void;
  72870. /**
  72871. * Returns the light position for light scattering effect
  72872. * @return Vector3 The custom light position
  72873. */
  72874. getCustomMeshPosition(): Vector3;
  72875. /**
  72876. * Disposes the internal assets and detaches the post-process from the camera
  72877. */
  72878. dispose(camera: Camera): void;
  72879. /**
  72880. * Returns the render target texture used by the post-process
  72881. * @return the render target texture used by the post-process
  72882. */
  72883. getPass(): RenderTargetTexture;
  72884. private _meshExcluded;
  72885. private _createPass;
  72886. private _updateMeshScreenCoordinates;
  72887. /**
  72888. * Creates a default mesh for the Volumeric Light Scattering post-process
  72889. * @param name The mesh name
  72890. * @param scene The scene where to create the mesh
  72891. * @return the default mesh
  72892. */
  72893. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72894. }
  72895. }
  72896. declare module BABYLON {
  72897. /** @hidden */
  72898. export var screenSpaceCurvaturePixelShader: {
  72899. name: string;
  72900. shader: string;
  72901. };
  72902. }
  72903. declare module BABYLON {
  72904. /**
  72905. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72906. */
  72907. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72908. /**
  72909. * Defines how much ridge the curvature effect displays.
  72910. */
  72911. ridge: number;
  72912. /**
  72913. * Defines how much valley the curvature effect displays.
  72914. */
  72915. valley: number;
  72916. private _geometryBufferRenderer;
  72917. /**
  72918. * Gets a string identifying the name of the class
  72919. * @returns "ScreenSpaceCurvaturePostProcess" string
  72920. */
  72921. getClassName(): string;
  72922. /**
  72923. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72924. * @param name The name of the effect.
  72925. * @param scene The scene containing the objects to blur according to their velocity.
  72926. * @param options The required width/height ratio to downsize to before computing the render pass.
  72927. * @param camera The camera to apply the render pass to.
  72928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72929. * @param engine The engine which the post process will be applied. (default: current engine)
  72930. * @param reusable If the post process can be reused on the same frame. (default: false)
  72931. * @param textureType Type of textures used when performing the post process. (default: 0)
  72932. * @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)
  72933. */
  72934. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72935. /**
  72936. * Support test.
  72937. */
  72938. static get IsSupported(): boolean;
  72939. /** @hidden */
  72940. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72941. }
  72942. }
  72943. declare module BABYLON {
  72944. interface Scene {
  72945. /** @hidden (Backing field) */
  72946. _boundingBoxRenderer: BoundingBoxRenderer;
  72947. /** @hidden (Backing field) */
  72948. _forceShowBoundingBoxes: boolean;
  72949. /**
  72950. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72951. */
  72952. forceShowBoundingBoxes: boolean;
  72953. /**
  72954. * Gets the bounding box renderer associated with the scene
  72955. * @returns a BoundingBoxRenderer
  72956. */
  72957. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72958. }
  72959. interface AbstractMesh {
  72960. /** @hidden (Backing field) */
  72961. _showBoundingBox: boolean;
  72962. /**
  72963. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72964. */
  72965. showBoundingBox: boolean;
  72966. }
  72967. /**
  72968. * Component responsible of rendering the bounding box of the meshes in a scene.
  72969. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72970. */
  72971. export class BoundingBoxRenderer implements ISceneComponent {
  72972. /**
  72973. * The component name helpfull to identify the component in the list of scene components.
  72974. */
  72975. readonly name: string;
  72976. /**
  72977. * The scene the component belongs to.
  72978. */
  72979. scene: Scene;
  72980. /**
  72981. * Color of the bounding box lines placed in front of an object
  72982. */
  72983. frontColor: Color3;
  72984. /**
  72985. * Color of the bounding box lines placed behind an object
  72986. */
  72987. backColor: Color3;
  72988. /**
  72989. * Defines if the renderer should show the back lines or not
  72990. */
  72991. showBackLines: boolean;
  72992. /**
  72993. * Observable raised before rendering a bounding box
  72994. */
  72995. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72996. /**
  72997. * Observable raised after rendering a bounding box
  72998. */
  72999. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73000. /**
  73001. * Observable raised after resources are created
  73002. */
  73003. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  73004. /**
  73005. * When false, no bounding boxes will be rendered
  73006. */
  73007. enabled: boolean;
  73008. /**
  73009. * @hidden
  73010. */
  73011. renderList: SmartArray<BoundingBox>;
  73012. private _colorShader;
  73013. private _vertexBuffers;
  73014. private _indexBuffer;
  73015. private _fillIndexBuffer;
  73016. private _fillIndexData;
  73017. /**
  73018. * Instantiates a new bounding box renderer in a scene.
  73019. * @param scene the scene the renderer renders in
  73020. */
  73021. constructor(scene: Scene);
  73022. /**
  73023. * Registers the component in a given scene
  73024. */
  73025. register(): void;
  73026. private _evaluateSubMesh;
  73027. private _preActiveMesh;
  73028. private _prepareResources;
  73029. private _createIndexBuffer;
  73030. /**
  73031. * Rebuilds the elements related to this component in case of
  73032. * context lost for instance.
  73033. */
  73034. rebuild(): void;
  73035. /**
  73036. * @hidden
  73037. */
  73038. reset(): void;
  73039. /**
  73040. * Render the bounding boxes of a specific rendering group
  73041. * @param renderingGroupId defines the rendering group to render
  73042. */
  73043. render(renderingGroupId: number): void;
  73044. /**
  73045. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73046. * @param mesh Define the mesh to render the occlusion bounding box for
  73047. */
  73048. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73049. /**
  73050. * Dispose and release the resources attached to this renderer.
  73051. */
  73052. dispose(): void;
  73053. }
  73054. }
  73055. declare module BABYLON {
  73056. interface Scene {
  73057. /** @hidden (Backing field) */
  73058. _depthRenderer: {
  73059. [id: string]: DepthRenderer;
  73060. };
  73061. /**
  73062. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73063. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73064. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73065. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  73066. * @returns the created depth renderer
  73067. */
  73068. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  73069. /**
  73070. * Disables a depth renderer for a given camera
  73071. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73072. */
  73073. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73074. }
  73075. /**
  73076. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73077. * in several rendering techniques.
  73078. */
  73079. export class DepthRendererSceneComponent implements ISceneComponent {
  73080. /**
  73081. * The component name helpfull to identify the component in the list of scene components.
  73082. */
  73083. readonly name: string;
  73084. /**
  73085. * The scene the component belongs to.
  73086. */
  73087. scene: Scene;
  73088. /**
  73089. * Creates a new instance of the component for the given scene
  73090. * @param scene Defines the scene to register the component in
  73091. */
  73092. constructor(scene: Scene);
  73093. /**
  73094. * Registers the component in a given scene
  73095. */
  73096. register(): void;
  73097. /**
  73098. * Rebuilds the elements related to this component in case of
  73099. * context lost for instance.
  73100. */
  73101. rebuild(): void;
  73102. /**
  73103. * Disposes the component and the associated ressources
  73104. */
  73105. dispose(): void;
  73106. private _gatherRenderTargets;
  73107. private _gatherActiveCameraRenderTargets;
  73108. }
  73109. }
  73110. declare module BABYLON {
  73111. interface AbstractScene {
  73112. /** @hidden (Backing field) */
  73113. _prePassRenderer: Nullable<PrePassRenderer>;
  73114. /**
  73115. * Gets or Sets the current prepass renderer associated to the scene.
  73116. */
  73117. prePassRenderer: Nullable<PrePassRenderer>;
  73118. /**
  73119. * Enables the prepass and associates it with the scene
  73120. * @returns the PrePassRenderer
  73121. */
  73122. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73123. /**
  73124. * Disables the prepass associated with the scene
  73125. */
  73126. disablePrePassRenderer(): void;
  73127. }
  73128. /**
  73129. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73130. * in several rendering techniques.
  73131. */
  73132. export class PrePassRendererSceneComponent implements ISceneComponent {
  73133. /**
  73134. * The component name helpful to identify the component in the list of scene components.
  73135. */
  73136. readonly name: string;
  73137. /**
  73138. * The scene the component belongs to.
  73139. */
  73140. scene: Scene;
  73141. /**
  73142. * Creates a new instance of the component for the given scene
  73143. * @param scene Defines the scene to register the component in
  73144. */
  73145. constructor(scene: Scene);
  73146. /**
  73147. * Registers the component in a given scene
  73148. */
  73149. register(): void;
  73150. private _beforeCameraDraw;
  73151. private _afterCameraDraw;
  73152. private _beforeClearStage;
  73153. /**
  73154. * Rebuilds the elements related to this component in case of
  73155. * context lost for instance.
  73156. */
  73157. rebuild(): void;
  73158. /**
  73159. * Disposes the component and the associated ressources
  73160. */
  73161. dispose(): void;
  73162. }
  73163. }
  73164. declare module BABYLON {
  73165. /** @hidden */
  73166. export var fibonacci: {
  73167. name: string;
  73168. shader: string;
  73169. };
  73170. }
  73171. declare module BABYLON {
  73172. /** @hidden */
  73173. export var diffusionProfile: {
  73174. name: string;
  73175. shader: string;
  73176. };
  73177. }
  73178. declare module BABYLON {
  73179. /** @hidden */
  73180. export var subSurfaceScatteringPixelShader: {
  73181. name: string;
  73182. shader: string;
  73183. };
  73184. }
  73185. declare module BABYLON {
  73186. /**
  73187. * Sub surface scattering post process
  73188. */
  73189. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73190. /**
  73191. * Gets a string identifying the name of the class
  73192. * @returns "SubSurfaceScatteringPostProcess" string
  73193. */
  73194. getClassName(): string;
  73195. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73196. }
  73197. }
  73198. declare module BABYLON {
  73199. /**
  73200. * Contains all parameters needed for the prepass to perform
  73201. * screen space subsurface scattering
  73202. */
  73203. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73204. /** @hidden */
  73205. static _SceneComponentInitialization: (scene: Scene) => void;
  73206. private _ssDiffusionS;
  73207. private _ssFilterRadii;
  73208. private _ssDiffusionD;
  73209. /**
  73210. * Post process to attach for screen space subsurface scattering
  73211. */
  73212. postProcess: SubSurfaceScatteringPostProcess;
  73213. /**
  73214. * Diffusion profile color for subsurface scattering
  73215. */
  73216. get ssDiffusionS(): number[];
  73217. /**
  73218. * Diffusion profile max color channel value for subsurface scattering
  73219. */
  73220. get ssDiffusionD(): number[];
  73221. /**
  73222. * Diffusion profile filter radius for subsurface scattering
  73223. */
  73224. get ssFilterRadii(): number[];
  73225. /**
  73226. * Is subsurface enabled
  73227. */
  73228. enabled: boolean;
  73229. /**
  73230. * Name of the configuration
  73231. */
  73232. name: string;
  73233. /**
  73234. * Diffusion profile colors for subsurface scattering
  73235. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73236. * See ...
  73237. * Note that you can only store up to 5 of them
  73238. */
  73239. ssDiffusionProfileColors: Color3[];
  73240. /**
  73241. * Defines the ratio real world => scene units.
  73242. * Used for subsurface scattering
  73243. */
  73244. metersPerUnit: number;
  73245. /**
  73246. * Textures that should be present in the MRT for this effect to work
  73247. */
  73248. readonly texturesRequired: number[];
  73249. private _scene;
  73250. /**
  73251. * Builds a subsurface configuration object
  73252. * @param scene The scene
  73253. */
  73254. constructor(scene: Scene);
  73255. /**
  73256. * Adds a new diffusion profile.
  73257. * Useful for more realistic subsurface scattering on diverse materials.
  73258. * @param color The color of the diffusion profile. Should be the average color of the material.
  73259. * @return The index of the diffusion profile for the material subsurface configuration
  73260. */
  73261. addDiffusionProfile(color: Color3): number;
  73262. /**
  73263. * Creates the sss post process
  73264. * @return The created post process
  73265. */
  73266. createPostProcess(): SubSurfaceScatteringPostProcess;
  73267. /**
  73268. * Deletes all diffusion profiles.
  73269. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73270. */
  73271. clearAllDiffusionProfiles(): void;
  73272. /**
  73273. * Disposes this object
  73274. */
  73275. dispose(): void;
  73276. /**
  73277. * @hidden
  73278. * https://zero-radiance.github.io/post/sampling-diffusion/
  73279. *
  73280. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73281. * ------------------------------------------------------------------------------------
  73282. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73283. * PDF[r, phi, s] = r * R[r, phi, s]
  73284. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73285. * ------------------------------------------------------------------------------------
  73286. * We importance sample the color channel with the widest scattering distance.
  73287. */
  73288. getDiffusionProfileParameters(color: Color3): number;
  73289. /**
  73290. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73291. * 'u' is the random number (the value of the CDF): [0, 1).
  73292. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73293. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73294. */
  73295. private _sampleBurleyDiffusionProfile;
  73296. }
  73297. }
  73298. declare module BABYLON {
  73299. interface AbstractScene {
  73300. /** @hidden (Backing field) */
  73301. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73302. /**
  73303. * Gets or Sets the current prepass renderer associated to the scene.
  73304. */
  73305. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73306. /**
  73307. * Enables the subsurface effect for prepass
  73308. * @returns the SubSurfaceConfiguration
  73309. */
  73310. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73311. /**
  73312. * Disables the subsurface effect for prepass
  73313. */
  73314. disableSubSurfaceForPrePass(): void;
  73315. }
  73316. /**
  73317. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73318. * in several rendering techniques.
  73319. */
  73320. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73321. /**
  73322. * The component name helpful to identify the component in the list of scene components.
  73323. */
  73324. readonly name: string;
  73325. /**
  73326. * The scene the component belongs to.
  73327. */
  73328. scene: Scene;
  73329. /**
  73330. * Creates a new instance of the component for the given scene
  73331. * @param scene Defines the scene to register the component in
  73332. */
  73333. constructor(scene: Scene);
  73334. /**
  73335. * Registers the component in a given scene
  73336. */
  73337. register(): void;
  73338. /**
  73339. * Serializes the component data to the specified json object
  73340. * @param serializationObject The object to serialize to
  73341. */
  73342. serialize(serializationObject: any): void;
  73343. /**
  73344. * Adds all the elements from the container to the scene
  73345. * @param container the container holding the elements
  73346. */
  73347. addFromContainer(container: AbstractScene): void;
  73348. /**
  73349. * Removes all the elements in the container from the scene
  73350. * @param container contains the elements to remove
  73351. * @param dispose if the removed element should be disposed (default: false)
  73352. */
  73353. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73354. /**
  73355. * Rebuilds the elements related to this component in case of
  73356. * context lost for instance.
  73357. */
  73358. rebuild(): void;
  73359. /**
  73360. * Disposes the component and the associated ressources
  73361. */
  73362. dispose(): void;
  73363. }
  73364. }
  73365. declare module BABYLON {
  73366. /** @hidden */
  73367. export var outlinePixelShader: {
  73368. name: string;
  73369. shader: string;
  73370. };
  73371. }
  73372. declare module BABYLON {
  73373. /** @hidden */
  73374. export var outlineVertexShader: {
  73375. name: string;
  73376. shader: string;
  73377. };
  73378. }
  73379. declare module BABYLON {
  73380. interface Scene {
  73381. /** @hidden */
  73382. _outlineRenderer: OutlineRenderer;
  73383. /**
  73384. * Gets the outline renderer associated with the scene
  73385. * @returns a OutlineRenderer
  73386. */
  73387. getOutlineRenderer(): OutlineRenderer;
  73388. }
  73389. interface AbstractMesh {
  73390. /** @hidden (Backing field) */
  73391. _renderOutline: boolean;
  73392. /**
  73393. * Gets or sets a boolean indicating if the outline must be rendered as well
  73394. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73395. */
  73396. renderOutline: boolean;
  73397. /** @hidden (Backing field) */
  73398. _renderOverlay: boolean;
  73399. /**
  73400. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73401. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73402. */
  73403. renderOverlay: boolean;
  73404. }
  73405. /**
  73406. * This class is responsible to draw bothe outline/overlay of meshes.
  73407. * It should not be used directly but through the available method on mesh.
  73408. */
  73409. export class OutlineRenderer implements ISceneComponent {
  73410. /**
  73411. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73412. */
  73413. private static _StencilReference;
  73414. /**
  73415. * The name of the component. Each component must have a unique name.
  73416. */
  73417. name: string;
  73418. /**
  73419. * The scene the component belongs to.
  73420. */
  73421. scene: Scene;
  73422. /**
  73423. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73424. */
  73425. zOffset: number;
  73426. private _engine;
  73427. private _effect;
  73428. private _cachedDefines;
  73429. private _savedDepthWrite;
  73430. /**
  73431. * Instantiates a new outline renderer. (There could be only one per scene).
  73432. * @param scene Defines the scene it belongs to
  73433. */
  73434. constructor(scene: Scene);
  73435. /**
  73436. * Register the component to one instance of a scene.
  73437. */
  73438. register(): void;
  73439. /**
  73440. * Rebuilds the elements related to this component in case of
  73441. * context lost for instance.
  73442. */
  73443. rebuild(): void;
  73444. /**
  73445. * Disposes the component and the associated ressources.
  73446. */
  73447. dispose(): void;
  73448. /**
  73449. * Renders the outline in the canvas.
  73450. * @param subMesh Defines the sumesh to render
  73451. * @param batch Defines the batch of meshes in case of instances
  73452. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73453. */
  73454. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73455. /**
  73456. * Returns whether or not the outline renderer is ready for a given submesh.
  73457. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73458. * @param subMesh Defines the submesh to check readyness for
  73459. * @param useInstances Defines wheter wee are trying to render instances or not
  73460. * @returns true if ready otherwise false
  73461. */
  73462. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73463. private _beforeRenderingMesh;
  73464. private _afterRenderingMesh;
  73465. }
  73466. }
  73467. declare module BABYLON {
  73468. /**
  73469. * Defines the basic options interface of a Sprite Frame Source Size.
  73470. */
  73471. export interface ISpriteJSONSpriteSourceSize {
  73472. /**
  73473. * number of the original width of the Frame
  73474. */
  73475. w: number;
  73476. /**
  73477. * number of the original height of the Frame
  73478. */
  73479. h: number;
  73480. }
  73481. /**
  73482. * Defines the basic options interface of a Sprite Frame Data.
  73483. */
  73484. export interface ISpriteJSONSpriteFrameData {
  73485. /**
  73486. * number of the x offset of the Frame
  73487. */
  73488. x: number;
  73489. /**
  73490. * number of the y offset of the Frame
  73491. */
  73492. y: number;
  73493. /**
  73494. * number of the width of the Frame
  73495. */
  73496. w: number;
  73497. /**
  73498. * number of the height of the Frame
  73499. */
  73500. h: number;
  73501. }
  73502. /**
  73503. * Defines the basic options interface of a JSON Sprite.
  73504. */
  73505. export interface ISpriteJSONSprite {
  73506. /**
  73507. * string name of the Frame
  73508. */
  73509. filename: string;
  73510. /**
  73511. * ISpriteJSONSpriteFrame basic object of the frame data
  73512. */
  73513. frame: ISpriteJSONSpriteFrameData;
  73514. /**
  73515. * boolean to flag is the frame was rotated.
  73516. */
  73517. rotated: boolean;
  73518. /**
  73519. * boolean to flag is the frame was trimmed.
  73520. */
  73521. trimmed: boolean;
  73522. /**
  73523. * ISpriteJSONSpriteFrame basic object of the source data
  73524. */
  73525. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73526. /**
  73527. * ISpriteJSONSpriteFrame basic object of the source data
  73528. */
  73529. sourceSize: ISpriteJSONSpriteSourceSize;
  73530. }
  73531. /**
  73532. * Defines the basic options interface of a JSON atlas.
  73533. */
  73534. export interface ISpriteJSONAtlas {
  73535. /**
  73536. * Array of objects that contain the frame data.
  73537. */
  73538. frames: Array<ISpriteJSONSprite>;
  73539. /**
  73540. * object basic object containing the sprite meta data.
  73541. */
  73542. meta?: object;
  73543. }
  73544. }
  73545. declare module BABYLON {
  73546. /** @hidden */
  73547. export var spriteMapPixelShader: {
  73548. name: string;
  73549. shader: string;
  73550. };
  73551. }
  73552. declare module BABYLON {
  73553. /** @hidden */
  73554. export var spriteMapVertexShader: {
  73555. name: string;
  73556. shader: string;
  73557. };
  73558. }
  73559. declare module BABYLON {
  73560. /**
  73561. * Defines the basic options interface of a SpriteMap
  73562. */
  73563. export interface ISpriteMapOptions {
  73564. /**
  73565. * Vector2 of the number of cells in the grid.
  73566. */
  73567. stageSize?: Vector2;
  73568. /**
  73569. * Vector2 of the size of the output plane in World Units.
  73570. */
  73571. outputSize?: Vector2;
  73572. /**
  73573. * Vector3 of the position of the output plane in World Units.
  73574. */
  73575. outputPosition?: Vector3;
  73576. /**
  73577. * Vector3 of the rotation of the output plane.
  73578. */
  73579. outputRotation?: Vector3;
  73580. /**
  73581. * number of layers that the system will reserve in resources.
  73582. */
  73583. layerCount?: number;
  73584. /**
  73585. * number of max animation frames a single cell will reserve in resources.
  73586. */
  73587. maxAnimationFrames?: number;
  73588. /**
  73589. * number cell index of the base tile when the system compiles.
  73590. */
  73591. baseTile?: number;
  73592. /**
  73593. * boolean flip the sprite after its been repositioned by the framing data.
  73594. */
  73595. flipU?: boolean;
  73596. /**
  73597. * Vector3 scalar of the global RGB values of the SpriteMap.
  73598. */
  73599. colorMultiply?: Vector3;
  73600. }
  73601. /**
  73602. * Defines the IDisposable interface in order to be cleanable from resources.
  73603. */
  73604. export interface ISpriteMap extends IDisposable {
  73605. /**
  73606. * String name of the SpriteMap.
  73607. */
  73608. name: string;
  73609. /**
  73610. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73611. */
  73612. atlasJSON: ISpriteJSONAtlas;
  73613. /**
  73614. * Texture of the SpriteMap.
  73615. */
  73616. spriteSheet: Texture;
  73617. /**
  73618. * The parameters to initialize the SpriteMap with.
  73619. */
  73620. options: ISpriteMapOptions;
  73621. }
  73622. /**
  73623. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73624. */
  73625. export class SpriteMap implements ISpriteMap {
  73626. /** The Name of the spriteMap */
  73627. name: string;
  73628. /** The JSON file with the frame and meta data */
  73629. atlasJSON: ISpriteJSONAtlas;
  73630. /** The systems Sprite Sheet Texture */
  73631. spriteSheet: Texture;
  73632. /** Arguments passed with the Constructor */
  73633. options: ISpriteMapOptions;
  73634. /** Public Sprite Storage array, parsed from atlasJSON */
  73635. sprites: Array<ISpriteJSONSprite>;
  73636. /** Returns the Number of Sprites in the System */
  73637. get spriteCount(): number;
  73638. /** Returns the Position of Output Plane*/
  73639. get position(): Vector3;
  73640. /** Returns the Position of Output Plane*/
  73641. set position(v: Vector3);
  73642. /** Returns the Rotation of Output Plane*/
  73643. get rotation(): Vector3;
  73644. /** Returns the Rotation of Output Plane*/
  73645. set rotation(v: Vector3);
  73646. /** Sets the AnimationMap*/
  73647. get animationMap(): RawTexture;
  73648. /** Sets the AnimationMap*/
  73649. set animationMap(v: RawTexture);
  73650. /** Scene that the SpriteMap was created in */
  73651. private _scene;
  73652. /** Texture Buffer of Float32 that holds tile frame data*/
  73653. private _frameMap;
  73654. /** Texture Buffers of Float32 that holds tileMap data*/
  73655. private _tileMaps;
  73656. /** Texture Buffer of Float32 that holds Animation Data*/
  73657. private _animationMap;
  73658. /** Custom ShaderMaterial Central to the System*/
  73659. private _material;
  73660. /** Custom ShaderMaterial Central to the System*/
  73661. private _output;
  73662. /** Systems Time Ticker*/
  73663. private _time;
  73664. /**
  73665. * Creates a new SpriteMap
  73666. * @param name defines the SpriteMaps Name
  73667. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73668. * @param spriteSheet is the Texture that the Sprites are on.
  73669. * @param options a basic deployment configuration
  73670. * @param scene The Scene that the map is deployed on
  73671. */
  73672. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73673. /**
  73674. * Returns tileID location
  73675. * @returns Vector2 the cell position ID
  73676. */
  73677. getTileID(): Vector2;
  73678. /**
  73679. * Gets the UV location of the mouse over the SpriteMap.
  73680. * @returns Vector2 the UV position of the mouse interaction
  73681. */
  73682. getMousePosition(): Vector2;
  73683. /**
  73684. * Creates the "frame" texture Buffer
  73685. * -------------------------------------
  73686. * Structure of frames
  73687. * "filename": "Falling-Water-2.png",
  73688. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73689. * "rotated": true,
  73690. * "trimmed": true,
  73691. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73692. * "sourceSize": {"w":32,"h":32}
  73693. * @returns RawTexture of the frameMap
  73694. */
  73695. private _createFrameBuffer;
  73696. /**
  73697. * Creates the tileMap texture Buffer
  73698. * @param buffer normally and array of numbers, or a false to generate from scratch
  73699. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73700. * @returns RawTexture of the tileMap
  73701. */
  73702. private _createTileBuffer;
  73703. /**
  73704. * Modifies the data of the tileMaps
  73705. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73706. * @param pos is the iVector2 Coordinates of the Tile
  73707. * @param tile The SpriteIndex of the new Tile
  73708. */
  73709. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73710. /**
  73711. * Creates the animationMap texture Buffer
  73712. * @param buffer normally and array of numbers, or a false to generate from scratch
  73713. * @returns RawTexture of the animationMap
  73714. */
  73715. private _createTileAnimationBuffer;
  73716. /**
  73717. * Modifies the data of the animationMap
  73718. * @param cellID is the Index of the Sprite
  73719. * @param _frame is the target Animation frame
  73720. * @param toCell is the Target Index of the next frame of the animation
  73721. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73722. * @param speed is a global scalar of the time variable on the map.
  73723. */
  73724. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73725. /**
  73726. * Exports the .tilemaps file
  73727. */
  73728. saveTileMaps(): void;
  73729. /**
  73730. * Imports the .tilemaps file
  73731. * @param url of the .tilemaps file
  73732. */
  73733. loadTileMaps(url: string): void;
  73734. /**
  73735. * Release associated resources
  73736. */
  73737. dispose(): void;
  73738. }
  73739. }
  73740. declare module BABYLON {
  73741. /**
  73742. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73743. * @see https://doc.babylonjs.com/babylon101/sprites
  73744. */
  73745. export class SpritePackedManager extends SpriteManager {
  73746. /** defines the packed manager's name */
  73747. name: string;
  73748. /**
  73749. * Creates a new sprite manager from a packed sprite sheet
  73750. * @param name defines the manager's name
  73751. * @param imgUrl defines the sprite sheet url
  73752. * @param capacity defines the maximum allowed number of sprites
  73753. * @param scene defines the hosting scene
  73754. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73755. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73756. * @param samplingMode defines the smapling mode to use with spritesheet
  73757. * @param fromPacked set to true; do not alter
  73758. */
  73759. constructor(
  73760. /** defines the packed manager's name */
  73761. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73762. }
  73763. }
  73764. declare module BABYLON {
  73765. /**
  73766. * Defines the list of states available for a task inside a AssetsManager
  73767. */
  73768. export enum AssetTaskState {
  73769. /**
  73770. * Initialization
  73771. */
  73772. INIT = 0,
  73773. /**
  73774. * Running
  73775. */
  73776. RUNNING = 1,
  73777. /**
  73778. * Done
  73779. */
  73780. DONE = 2,
  73781. /**
  73782. * Error
  73783. */
  73784. ERROR = 3
  73785. }
  73786. /**
  73787. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73788. */
  73789. export abstract class AbstractAssetTask {
  73790. /**
  73791. * Task name
  73792. */ name: string;
  73793. /**
  73794. * Callback called when the task is successful
  73795. */
  73796. onSuccess: (task: any) => void;
  73797. /**
  73798. * Callback called when the task is not successful
  73799. */
  73800. onError: (task: any, message?: string, exception?: any) => void;
  73801. /**
  73802. * Creates a new AssetsManager
  73803. * @param name defines the name of the task
  73804. */
  73805. constructor(
  73806. /**
  73807. * Task name
  73808. */ name: string);
  73809. private _isCompleted;
  73810. private _taskState;
  73811. private _errorObject;
  73812. /**
  73813. * Get if the task is completed
  73814. */
  73815. get isCompleted(): boolean;
  73816. /**
  73817. * Gets the current state of the task
  73818. */
  73819. get taskState(): AssetTaskState;
  73820. /**
  73821. * Gets the current error object (if task is in error)
  73822. */
  73823. get errorObject(): {
  73824. message?: string;
  73825. exception?: any;
  73826. };
  73827. /**
  73828. * Internal only
  73829. * @hidden
  73830. */
  73831. _setErrorObject(message?: string, exception?: any): void;
  73832. /**
  73833. * Execute the current task
  73834. * @param scene defines the scene where you want your assets to be loaded
  73835. * @param onSuccess is a callback called when the task is successfully executed
  73836. * @param onError is a callback called if an error occurs
  73837. */
  73838. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73839. /**
  73840. * Execute the current task
  73841. * @param scene defines the scene where you want your assets to be loaded
  73842. * @param onSuccess is a callback called when the task is successfully executed
  73843. * @param onError is a callback called if an error occurs
  73844. */
  73845. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73846. /**
  73847. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73848. * This can be used with failed tasks that have the reason for failure fixed.
  73849. */
  73850. reset(): void;
  73851. private onErrorCallback;
  73852. private onDoneCallback;
  73853. }
  73854. /**
  73855. * Define the interface used by progress events raised during assets loading
  73856. */
  73857. export interface IAssetsProgressEvent {
  73858. /**
  73859. * Defines the number of remaining tasks to process
  73860. */
  73861. remainingCount: number;
  73862. /**
  73863. * Defines the total number of tasks
  73864. */
  73865. totalCount: number;
  73866. /**
  73867. * Defines the task that was just processed
  73868. */
  73869. task: AbstractAssetTask;
  73870. }
  73871. /**
  73872. * Class used to share progress information about assets loading
  73873. */
  73874. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73875. /**
  73876. * Defines the number of remaining tasks to process
  73877. */
  73878. remainingCount: number;
  73879. /**
  73880. * Defines the total number of tasks
  73881. */
  73882. totalCount: number;
  73883. /**
  73884. * Defines the task that was just processed
  73885. */
  73886. task: AbstractAssetTask;
  73887. /**
  73888. * Creates a AssetsProgressEvent
  73889. * @param remainingCount defines the number of remaining tasks to process
  73890. * @param totalCount defines the total number of tasks
  73891. * @param task defines the task that was just processed
  73892. */
  73893. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73894. }
  73895. /**
  73896. * Define a task used by AssetsManager to load assets into a container
  73897. */
  73898. export class ContainerAssetTask extends AbstractAssetTask {
  73899. /**
  73900. * Defines the name of the task
  73901. */
  73902. name: string;
  73903. /**
  73904. * Defines the list of mesh's names you want to load
  73905. */
  73906. meshesNames: any;
  73907. /**
  73908. * Defines the root url to use as a base to load your meshes and associated resources
  73909. */
  73910. rootUrl: string;
  73911. /**
  73912. * Defines the filename or File of the scene to load from
  73913. */
  73914. sceneFilename: string | File;
  73915. /**
  73916. * Get the loaded asset container
  73917. */
  73918. loadedContainer: AssetContainer;
  73919. /**
  73920. * Gets the list of loaded meshes
  73921. */
  73922. loadedMeshes: Array<AbstractMesh>;
  73923. /**
  73924. * Gets the list of loaded particle systems
  73925. */
  73926. loadedParticleSystems: Array<IParticleSystem>;
  73927. /**
  73928. * Gets the list of loaded skeletons
  73929. */
  73930. loadedSkeletons: Array<Skeleton>;
  73931. /**
  73932. * Gets the list of loaded animation groups
  73933. */
  73934. loadedAnimationGroups: Array<AnimationGroup>;
  73935. /**
  73936. * Callback called when the task is successful
  73937. */
  73938. onSuccess: (task: ContainerAssetTask) => void;
  73939. /**
  73940. * Callback called when the task is successful
  73941. */
  73942. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73943. /**
  73944. * Creates a new ContainerAssetTask
  73945. * @param name defines the name of the task
  73946. * @param meshesNames defines the list of mesh's names you want to load
  73947. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73948. * @param sceneFilename defines the filename or File of the scene to load from
  73949. */
  73950. constructor(
  73951. /**
  73952. * Defines the name of the task
  73953. */
  73954. name: string,
  73955. /**
  73956. * Defines the list of mesh's names you want to load
  73957. */
  73958. meshesNames: any,
  73959. /**
  73960. * Defines the root url to use as a base to load your meshes and associated resources
  73961. */
  73962. rootUrl: string,
  73963. /**
  73964. * Defines the filename or File of the scene to load from
  73965. */
  73966. sceneFilename: string | File);
  73967. /**
  73968. * Execute the current task
  73969. * @param scene defines the scene where you want your assets to be loaded
  73970. * @param onSuccess is a callback called when the task is successfully executed
  73971. * @param onError is a callback called if an error occurs
  73972. */
  73973. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73974. }
  73975. /**
  73976. * Define a task used by AssetsManager to load meshes
  73977. */
  73978. export class MeshAssetTask extends AbstractAssetTask {
  73979. /**
  73980. * Defines the name of the task
  73981. */
  73982. name: string;
  73983. /**
  73984. * Defines the list of mesh's names you want to load
  73985. */
  73986. meshesNames: any;
  73987. /**
  73988. * Defines the root url to use as a base to load your meshes and associated resources
  73989. */
  73990. rootUrl: string;
  73991. /**
  73992. * Defines the filename or File of the scene to load from
  73993. */
  73994. sceneFilename: string | File;
  73995. /**
  73996. * Gets the list of loaded meshes
  73997. */
  73998. loadedMeshes: Array<AbstractMesh>;
  73999. /**
  74000. * Gets the list of loaded particle systems
  74001. */
  74002. loadedParticleSystems: Array<IParticleSystem>;
  74003. /**
  74004. * Gets the list of loaded skeletons
  74005. */
  74006. loadedSkeletons: Array<Skeleton>;
  74007. /**
  74008. * Gets the list of loaded animation groups
  74009. */
  74010. loadedAnimationGroups: Array<AnimationGroup>;
  74011. /**
  74012. * Callback called when the task is successful
  74013. */
  74014. onSuccess: (task: MeshAssetTask) => void;
  74015. /**
  74016. * Callback called when the task is successful
  74017. */
  74018. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74019. /**
  74020. * Creates a new MeshAssetTask
  74021. * @param name defines the name of the task
  74022. * @param meshesNames defines the list of mesh's names you want to load
  74023. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74024. * @param sceneFilename defines the filename or File of the scene to load from
  74025. */
  74026. constructor(
  74027. /**
  74028. * Defines the name of the task
  74029. */
  74030. name: string,
  74031. /**
  74032. * Defines the list of mesh's names you want to load
  74033. */
  74034. meshesNames: any,
  74035. /**
  74036. * Defines the root url to use as a base to load your meshes and associated resources
  74037. */
  74038. rootUrl: string,
  74039. /**
  74040. * Defines the filename or File of the scene to load from
  74041. */
  74042. sceneFilename: string | File);
  74043. /**
  74044. * Execute the current task
  74045. * @param scene defines the scene where you want your assets to be loaded
  74046. * @param onSuccess is a callback called when the task is successfully executed
  74047. * @param onError is a callback called if an error occurs
  74048. */
  74049. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74050. }
  74051. /**
  74052. * Define a task used by AssetsManager to load text content
  74053. */
  74054. export class TextFileAssetTask extends AbstractAssetTask {
  74055. /**
  74056. * Defines the name of the task
  74057. */
  74058. name: string;
  74059. /**
  74060. * Defines the location of the file to load
  74061. */
  74062. url: string;
  74063. /**
  74064. * Gets the loaded text string
  74065. */
  74066. text: string;
  74067. /**
  74068. * Callback called when the task is successful
  74069. */
  74070. onSuccess: (task: TextFileAssetTask) => void;
  74071. /**
  74072. * Callback called when the task is successful
  74073. */
  74074. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74075. /**
  74076. * Creates a new TextFileAssetTask object
  74077. * @param name defines the name of the task
  74078. * @param url defines the location of the file to load
  74079. */
  74080. constructor(
  74081. /**
  74082. * Defines the name of the task
  74083. */
  74084. name: string,
  74085. /**
  74086. * Defines the location of the file to load
  74087. */
  74088. url: string);
  74089. /**
  74090. * Execute the current task
  74091. * @param scene defines the scene where you want your assets to be loaded
  74092. * @param onSuccess is a callback called when the task is successfully executed
  74093. * @param onError is a callback called if an error occurs
  74094. */
  74095. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74096. }
  74097. /**
  74098. * Define a task used by AssetsManager to load binary data
  74099. */
  74100. export class BinaryFileAssetTask extends AbstractAssetTask {
  74101. /**
  74102. * Defines the name of the task
  74103. */
  74104. name: string;
  74105. /**
  74106. * Defines the location of the file to load
  74107. */
  74108. url: string;
  74109. /**
  74110. * Gets the lodaded data (as an array buffer)
  74111. */
  74112. data: ArrayBuffer;
  74113. /**
  74114. * Callback called when the task is successful
  74115. */
  74116. onSuccess: (task: BinaryFileAssetTask) => void;
  74117. /**
  74118. * Callback called when the task is successful
  74119. */
  74120. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74121. /**
  74122. * Creates a new BinaryFileAssetTask object
  74123. * @param name defines the name of the new task
  74124. * @param url defines the location of the file to load
  74125. */
  74126. constructor(
  74127. /**
  74128. * Defines the name of the task
  74129. */
  74130. name: string,
  74131. /**
  74132. * Defines the location of the file to load
  74133. */
  74134. url: string);
  74135. /**
  74136. * Execute the current task
  74137. * @param scene defines the scene where you want your assets to be loaded
  74138. * @param onSuccess is a callback called when the task is successfully executed
  74139. * @param onError is a callback called if an error occurs
  74140. */
  74141. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74142. }
  74143. /**
  74144. * Define a task used by AssetsManager to load images
  74145. */
  74146. export class ImageAssetTask extends AbstractAssetTask {
  74147. /**
  74148. * Defines the name of the task
  74149. */
  74150. name: string;
  74151. /**
  74152. * Defines the location of the image to load
  74153. */
  74154. url: string;
  74155. /**
  74156. * Gets the loaded images
  74157. */
  74158. image: HTMLImageElement;
  74159. /**
  74160. * Callback called when the task is successful
  74161. */
  74162. onSuccess: (task: ImageAssetTask) => void;
  74163. /**
  74164. * Callback called when the task is successful
  74165. */
  74166. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74167. /**
  74168. * Creates a new ImageAssetTask
  74169. * @param name defines the name of the task
  74170. * @param url defines the location of the image to load
  74171. */
  74172. constructor(
  74173. /**
  74174. * Defines the name of the task
  74175. */
  74176. name: string,
  74177. /**
  74178. * Defines the location of the image to load
  74179. */
  74180. url: string);
  74181. /**
  74182. * Execute the current task
  74183. * @param scene defines the scene where you want your assets to be loaded
  74184. * @param onSuccess is a callback called when the task is successfully executed
  74185. * @param onError is a callback called if an error occurs
  74186. */
  74187. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74188. }
  74189. /**
  74190. * Defines the interface used by texture loading tasks
  74191. */
  74192. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74193. /**
  74194. * Gets the loaded texture
  74195. */
  74196. texture: TEX;
  74197. }
  74198. /**
  74199. * Define a task used by AssetsManager to load 2D textures
  74200. */
  74201. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74202. /**
  74203. * Defines the name of the task
  74204. */
  74205. name: string;
  74206. /**
  74207. * Defines the location of the file to load
  74208. */
  74209. url: string;
  74210. /**
  74211. * Defines if mipmap should not be generated (default is false)
  74212. */
  74213. noMipmap?: boolean | undefined;
  74214. /**
  74215. * Defines if texture must be inverted on Y axis (default is true)
  74216. */
  74217. invertY: boolean;
  74218. /**
  74219. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74220. */
  74221. samplingMode: number;
  74222. /**
  74223. * Gets the loaded texture
  74224. */
  74225. texture: Texture;
  74226. /**
  74227. * Callback called when the task is successful
  74228. */
  74229. onSuccess: (task: TextureAssetTask) => void;
  74230. /**
  74231. * Callback called when the task is successful
  74232. */
  74233. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74234. /**
  74235. * Creates a new TextureAssetTask object
  74236. * @param name defines the name of the task
  74237. * @param url defines the location of the file to load
  74238. * @param noMipmap defines if mipmap should not be generated (default is false)
  74239. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74240. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74241. */
  74242. constructor(
  74243. /**
  74244. * Defines the name of the task
  74245. */
  74246. name: string,
  74247. /**
  74248. * Defines the location of the file to load
  74249. */
  74250. url: string,
  74251. /**
  74252. * Defines if mipmap should not be generated (default is false)
  74253. */
  74254. noMipmap?: boolean | undefined,
  74255. /**
  74256. * Defines if texture must be inverted on Y axis (default is true)
  74257. */
  74258. invertY?: boolean,
  74259. /**
  74260. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74261. */
  74262. samplingMode?: number);
  74263. /**
  74264. * Execute the current task
  74265. * @param scene defines the scene where you want your assets to be loaded
  74266. * @param onSuccess is a callback called when the task is successfully executed
  74267. * @param onError is a callback called if an error occurs
  74268. */
  74269. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74270. }
  74271. /**
  74272. * Define a task used by AssetsManager to load cube textures
  74273. */
  74274. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74275. /**
  74276. * Defines the name of the task
  74277. */
  74278. name: string;
  74279. /**
  74280. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74281. */
  74282. url: string;
  74283. /**
  74284. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74285. */
  74286. extensions?: string[] | undefined;
  74287. /**
  74288. * Defines if mipmaps should not be generated (default is false)
  74289. */
  74290. noMipmap?: boolean | undefined;
  74291. /**
  74292. * Defines the explicit list of files (undefined by default)
  74293. */
  74294. files?: string[] | undefined;
  74295. /**
  74296. * Gets the loaded texture
  74297. */
  74298. texture: CubeTexture;
  74299. /**
  74300. * Callback called when the task is successful
  74301. */
  74302. onSuccess: (task: CubeTextureAssetTask) => void;
  74303. /**
  74304. * Callback called when the task is successful
  74305. */
  74306. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74307. /**
  74308. * Creates a new CubeTextureAssetTask
  74309. * @param name defines the name of the task
  74310. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74311. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74312. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74313. * @param files defines the explicit list of files (undefined by default)
  74314. */
  74315. constructor(
  74316. /**
  74317. * Defines the name of the task
  74318. */
  74319. name: string,
  74320. /**
  74321. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74322. */
  74323. url: string,
  74324. /**
  74325. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74326. */
  74327. extensions?: string[] | undefined,
  74328. /**
  74329. * Defines if mipmaps should not be generated (default is false)
  74330. */
  74331. noMipmap?: boolean | undefined,
  74332. /**
  74333. * Defines the explicit list of files (undefined by default)
  74334. */
  74335. files?: string[] | undefined);
  74336. /**
  74337. * Execute the current task
  74338. * @param scene defines the scene where you want your assets to be loaded
  74339. * @param onSuccess is a callback called when the task is successfully executed
  74340. * @param onError is a callback called if an error occurs
  74341. */
  74342. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74343. }
  74344. /**
  74345. * Define a task used by AssetsManager to load HDR cube textures
  74346. */
  74347. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74348. /**
  74349. * Defines the name of the task
  74350. */
  74351. name: string;
  74352. /**
  74353. * Defines the location of the file to load
  74354. */
  74355. url: string;
  74356. /**
  74357. * Defines the desired size (the more it increases the longer the generation will be)
  74358. */
  74359. size: number;
  74360. /**
  74361. * Defines if mipmaps should not be generated (default is false)
  74362. */
  74363. noMipmap: boolean;
  74364. /**
  74365. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74366. */
  74367. generateHarmonics: boolean;
  74368. /**
  74369. * 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)
  74370. */
  74371. gammaSpace: boolean;
  74372. /**
  74373. * Internal Use Only
  74374. */
  74375. reserved: boolean;
  74376. /**
  74377. * Gets the loaded texture
  74378. */
  74379. texture: HDRCubeTexture;
  74380. /**
  74381. * Callback called when the task is successful
  74382. */
  74383. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74384. /**
  74385. * Callback called when the task is successful
  74386. */
  74387. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74388. /**
  74389. * Creates a new HDRCubeTextureAssetTask object
  74390. * @param name defines the name of the task
  74391. * @param url defines the location of the file to load
  74392. * @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.
  74393. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74394. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74395. * @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)
  74396. * @param reserved Internal use only
  74397. */
  74398. constructor(
  74399. /**
  74400. * Defines the name of the task
  74401. */
  74402. name: string,
  74403. /**
  74404. * Defines the location of the file to load
  74405. */
  74406. url: string,
  74407. /**
  74408. * Defines the desired size (the more it increases the longer the generation will be)
  74409. */
  74410. size: number,
  74411. /**
  74412. * Defines if mipmaps should not be generated (default is false)
  74413. */
  74414. noMipmap?: boolean,
  74415. /**
  74416. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74417. */
  74418. generateHarmonics?: boolean,
  74419. /**
  74420. * 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)
  74421. */
  74422. gammaSpace?: boolean,
  74423. /**
  74424. * Internal Use Only
  74425. */
  74426. reserved?: boolean);
  74427. /**
  74428. * Execute the current task
  74429. * @param scene defines the scene where you want your assets to be loaded
  74430. * @param onSuccess is a callback called when the task is successfully executed
  74431. * @param onError is a callback called if an error occurs
  74432. */
  74433. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74434. }
  74435. /**
  74436. * Define a task used by AssetsManager to load Equirectangular cube textures
  74437. */
  74438. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74439. /**
  74440. * Defines the name of the task
  74441. */
  74442. name: string;
  74443. /**
  74444. * Defines the location of the file to load
  74445. */
  74446. url: string;
  74447. /**
  74448. * Defines the desired size (the more it increases the longer the generation will be)
  74449. */
  74450. size: number;
  74451. /**
  74452. * Defines if mipmaps should not be generated (default is false)
  74453. */
  74454. noMipmap: boolean;
  74455. /**
  74456. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74457. * but the standard material would require them in Gamma space) (default is true)
  74458. */
  74459. gammaSpace: boolean;
  74460. /**
  74461. * Gets the loaded texture
  74462. */
  74463. texture: EquiRectangularCubeTexture;
  74464. /**
  74465. * Callback called when the task is successful
  74466. */
  74467. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74468. /**
  74469. * Callback called when the task is successful
  74470. */
  74471. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74472. /**
  74473. * Creates a new EquiRectangularCubeTextureAssetTask object
  74474. * @param name defines the name of the task
  74475. * @param url defines the location of the file to load
  74476. * @param size defines the desired size (the more it increases the longer the generation will be)
  74477. * If the size is omitted this implies you are using a preprocessed cubemap.
  74478. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74479. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74480. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74481. * (default is true)
  74482. */
  74483. constructor(
  74484. /**
  74485. * Defines the name of the task
  74486. */
  74487. name: string,
  74488. /**
  74489. * Defines the location of the file to load
  74490. */
  74491. url: string,
  74492. /**
  74493. * Defines the desired size (the more it increases the longer the generation will be)
  74494. */
  74495. size: number,
  74496. /**
  74497. * Defines if mipmaps should not be generated (default is false)
  74498. */
  74499. noMipmap?: boolean,
  74500. /**
  74501. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74502. * but the standard material would require them in Gamma space) (default is true)
  74503. */
  74504. gammaSpace?: boolean);
  74505. /**
  74506. * Execute the current task
  74507. * @param scene defines the scene where you want your assets to be loaded
  74508. * @param onSuccess is a callback called when the task is successfully executed
  74509. * @param onError is a callback called if an error occurs
  74510. */
  74511. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74512. }
  74513. /**
  74514. * This class can be used to easily import assets into a scene
  74515. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74516. */
  74517. export class AssetsManager {
  74518. private _scene;
  74519. private _isLoading;
  74520. protected _tasks: AbstractAssetTask[];
  74521. protected _waitingTasksCount: number;
  74522. protected _totalTasksCount: number;
  74523. /**
  74524. * Callback called when all tasks are processed
  74525. */
  74526. onFinish: (tasks: AbstractAssetTask[]) => void;
  74527. /**
  74528. * Callback called when a task is successful
  74529. */
  74530. onTaskSuccess: (task: AbstractAssetTask) => void;
  74531. /**
  74532. * Callback called when a task had an error
  74533. */
  74534. onTaskError: (task: AbstractAssetTask) => void;
  74535. /**
  74536. * Callback called when a task is done (whatever the result is)
  74537. */
  74538. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74539. /**
  74540. * Observable called when all tasks are processed
  74541. */
  74542. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74543. /**
  74544. * Observable called when a task had an error
  74545. */
  74546. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74547. /**
  74548. * Observable called when all tasks were executed
  74549. */
  74550. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74551. /**
  74552. * Observable called when a task is done (whatever the result is)
  74553. */
  74554. onProgressObservable: Observable<IAssetsProgressEvent>;
  74555. /**
  74556. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74557. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74558. */
  74559. useDefaultLoadingScreen: boolean;
  74560. /**
  74561. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74562. * when all assets have been downloaded.
  74563. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74564. */
  74565. autoHideLoadingUI: boolean;
  74566. /**
  74567. * Creates a new AssetsManager
  74568. * @param scene defines the scene to work on
  74569. */
  74570. constructor(scene: Scene);
  74571. /**
  74572. * Add a ContainerAssetTask to the list of active tasks
  74573. * @param taskName defines the name of the new task
  74574. * @param meshesNames defines the name of meshes to load
  74575. * @param rootUrl defines the root url to use to locate files
  74576. * @param sceneFilename defines the filename of the scene file
  74577. * @returns a new ContainerAssetTask object
  74578. */
  74579. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74580. /**
  74581. * Add a MeshAssetTask to the list of active tasks
  74582. * @param taskName defines the name of the new task
  74583. * @param meshesNames defines the name of meshes to load
  74584. * @param rootUrl defines the root url to use to locate files
  74585. * @param sceneFilename defines the filename of the scene file
  74586. * @returns a new MeshAssetTask object
  74587. */
  74588. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74589. /**
  74590. * Add a TextFileAssetTask to the list of active tasks
  74591. * @param taskName defines the name of the new task
  74592. * @param url defines the url of the file to load
  74593. * @returns a new TextFileAssetTask object
  74594. */
  74595. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74596. /**
  74597. * Add a BinaryFileAssetTask to the list of active tasks
  74598. * @param taskName defines the name of the new task
  74599. * @param url defines the url of the file to load
  74600. * @returns a new BinaryFileAssetTask object
  74601. */
  74602. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74603. /**
  74604. * Add a ImageAssetTask to the list of active tasks
  74605. * @param taskName defines the name of the new task
  74606. * @param url defines the url of the file to load
  74607. * @returns a new ImageAssetTask object
  74608. */
  74609. addImageTask(taskName: string, url: string): ImageAssetTask;
  74610. /**
  74611. * Add a TextureAssetTask to the list of active tasks
  74612. * @param taskName defines the name of the new task
  74613. * @param url defines the url of the file to load
  74614. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74615. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74616. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74617. * @returns a new TextureAssetTask object
  74618. */
  74619. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74620. /**
  74621. * Add a CubeTextureAssetTask to the list of active tasks
  74622. * @param taskName defines the name of the new task
  74623. * @param url defines the url of the file to load
  74624. * @param extensions defines the extension to use to load the cube map (can be null)
  74625. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74626. * @param files defines the list of files to load (can be null)
  74627. * @returns a new CubeTextureAssetTask object
  74628. */
  74629. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74630. /**
  74631. *
  74632. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74633. * @param taskName defines the name of the new task
  74634. * @param url defines the url of the file to load
  74635. * @param size defines the size you want for the cubemap (can be null)
  74636. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74637. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74638. * @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)
  74639. * @param reserved Internal use only
  74640. * @returns a new HDRCubeTextureAssetTask object
  74641. */
  74642. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74643. /**
  74644. *
  74645. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74646. * @param taskName defines the name of the new task
  74647. * @param url defines the url of the file to load
  74648. * @param size defines the size you want for the cubemap (can be null)
  74649. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74650. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74651. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74652. * @returns a new EquiRectangularCubeTextureAssetTask object
  74653. */
  74654. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74655. /**
  74656. * Remove a task from the assets manager.
  74657. * @param task the task to remove
  74658. */
  74659. removeTask(task: AbstractAssetTask): void;
  74660. private _decreaseWaitingTasksCount;
  74661. private _runTask;
  74662. /**
  74663. * Reset the AssetsManager and remove all tasks
  74664. * @return the current instance of the AssetsManager
  74665. */
  74666. reset(): AssetsManager;
  74667. /**
  74668. * Start the loading process
  74669. * @return the current instance of the AssetsManager
  74670. */
  74671. load(): AssetsManager;
  74672. /**
  74673. * Start the loading process as an async operation
  74674. * @return a promise returning the list of failed tasks
  74675. */
  74676. loadAsync(): Promise<void>;
  74677. }
  74678. }
  74679. declare module BABYLON {
  74680. /**
  74681. * Wrapper class for promise with external resolve and reject.
  74682. */
  74683. export class Deferred<T> {
  74684. /**
  74685. * The promise associated with this deferred object.
  74686. */
  74687. readonly promise: Promise<T>;
  74688. private _resolve;
  74689. private _reject;
  74690. /**
  74691. * The resolve method of the promise associated with this deferred object.
  74692. */
  74693. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74694. /**
  74695. * The reject method of the promise associated with this deferred object.
  74696. */
  74697. get reject(): (reason?: any) => void;
  74698. /**
  74699. * Constructor for this deferred object.
  74700. */
  74701. constructor();
  74702. }
  74703. }
  74704. declare module BABYLON {
  74705. /**
  74706. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74707. */
  74708. export class MeshExploder {
  74709. private _centerMesh;
  74710. private _meshes;
  74711. private _meshesOrigins;
  74712. private _toCenterVectors;
  74713. private _scaledDirection;
  74714. private _newPosition;
  74715. private _centerPosition;
  74716. /**
  74717. * Explodes meshes from a center mesh.
  74718. * @param meshes The meshes to explode.
  74719. * @param centerMesh The mesh to be center of explosion.
  74720. */
  74721. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74722. private _setCenterMesh;
  74723. /**
  74724. * Get class name
  74725. * @returns "MeshExploder"
  74726. */
  74727. getClassName(): string;
  74728. /**
  74729. * "Exploded meshes"
  74730. * @returns Array of meshes with the centerMesh at index 0.
  74731. */
  74732. getMeshes(): Array<Mesh>;
  74733. /**
  74734. * Explodes meshes giving a specific direction
  74735. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74736. */
  74737. explode(direction?: number): void;
  74738. }
  74739. }
  74740. declare module BABYLON {
  74741. /**
  74742. * Class used to help managing file picking and drag'n'drop
  74743. */
  74744. export class FilesInput {
  74745. /**
  74746. * List of files ready to be loaded
  74747. */
  74748. static get FilesToLoad(): {
  74749. [key: string]: File;
  74750. };
  74751. /**
  74752. * Callback called when a file is processed
  74753. */
  74754. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74755. private _engine;
  74756. private _currentScene;
  74757. private _sceneLoadedCallback;
  74758. private _progressCallback;
  74759. private _additionalRenderLoopLogicCallback;
  74760. private _textureLoadingCallback;
  74761. private _startingProcessingFilesCallback;
  74762. private _onReloadCallback;
  74763. private _errorCallback;
  74764. private _elementToMonitor;
  74765. private _sceneFileToLoad;
  74766. private _filesToLoad;
  74767. /**
  74768. * Creates a new FilesInput
  74769. * @param engine defines the rendering engine
  74770. * @param scene defines the hosting scene
  74771. * @param sceneLoadedCallback callback called when scene is loaded
  74772. * @param progressCallback callback called to track progress
  74773. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74774. * @param textureLoadingCallback callback called when a texture is loading
  74775. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74776. * @param onReloadCallback callback called when a reload is requested
  74777. * @param errorCallback callback call if an error occurs
  74778. */
  74779. 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>);
  74780. private _dragEnterHandler;
  74781. private _dragOverHandler;
  74782. private _dropHandler;
  74783. /**
  74784. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74785. * @param elementToMonitor defines the DOM element to track
  74786. */
  74787. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74788. /** Gets the current list of files to load */
  74789. get filesToLoad(): File[];
  74790. /**
  74791. * Release all associated resources
  74792. */
  74793. dispose(): void;
  74794. private renderFunction;
  74795. private drag;
  74796. private drop;
  74797. private _traverseFolder;
  74798. private _processFiles;
  74799. /**
  74800. * Load files from a drop event
  74801. * @param event defines the drop event to use as source
  74802. */
  74803. loadFiles(event: any): void;
  74804. private _processReload;
  74805. /**
  74806. * Reload the current scene from the loaded files
  74807. */
  74808. reload(): void;
  74809. }
  74810. }
  74811. declare module BABYLON {
  74812. /**
  74813. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74814. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74815. */
  74816. export class SceneOptimization {
  74817. /**
  74818. * Defines the priority of this optimization (0 by default which means first in the list)
  74819. */
  74820. priority: number;
  74821. /**
  74822. * Gets a string describing the action executed by the current optimization
  74823. * @returns description string
  74824. */
  74825. getDescription(): string;
  74826. /**
  74827. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74828. * @param scene defines the current scene where to apply this optimization
  74829. * @param optimizer defines the current optimizer
  74830. * @returns true if everything that can be done was applied
  74831. */
  74832. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74833. /**
  74834. * Creates the SceneOptimization object
  74835. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74836. * @param desc defines the description associated with the optimization
  74837. */
  74838. constructor(
  74839. /**
  74840. * Defines the priority of this optimization (0 by default which means first in the list)
  74841. */
  74842. priority?: number);
  74843. }
  74844. /**
  74845. * Defines an optimization used to reduce the size of render target textures
  74846. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74847. */
  74848. export class TextureOptimization extends SceneOptimization {
  74849. /**
  74850. * Defines the priority of this optimization (0 by default which means first in the list)
  74851. */
  74852. priority: number;
  74853. /**
  74854. * 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
  74855. */
  74856. maximumSize: number;
  74857. /**
  74858. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74859. */
  74860. step: number;
  74861. /**
  74862. * Gets a string describing the action executed by the current optimization
  74863. * @returns description string
  74864. */
  74865. getDescription(): string;
  74866. /**
  74867. * Creates the TextureOptimization object
  74868. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74869. * @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
  74870. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74871. */
  74872. constructor(
  74873. /**
  74874. * Defines the priority of this optimization (0 by default which means first in the list)
  74875. */
  74876. priority?: number,
  74877. /**
  74878. * 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
  74879. */
  74880. maximumSize?: number,
  74881. /**
  74882. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74883. */
  74884. step?: number);
  74885. /**
  74886. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74887. * @param scene defines the current scene where to apply this optimization
  74888. * @param optimizer defines the current optimizer
  74889. * @returns true if everything that can be done was applied
  74890. */
  74891. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74892. }
  74893. /**
  74894. * Defines an optimization used to increase or decrease the rendering resolution
  74895. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74896. */
  74897. export class HardwareScalingOptimization extends SceneOptimization {
  74898. /**
  74899. * Defines the priority of this optimization (0 by default which means first in the list)
  74900. */
  74901. priority: number;
  74902. /**
  74903. * Defines the maximum scale to use (2 by default)
  74904. */
  74905. maximumScale: number;
  74906. /**
  74907. * Defines the step to use between two passes (0.5 by default)
  74908. */
  74909. step: number;
  74910. private _currentScale;
  74911. private _directionOffset;
  74912. /**
  74913. * Gets a string describing the action executed by the current optimization
  74914. * @return description string
  74915. */
  74916. getDescription(): string;
  74917. /**
  74918. * Creates the HardwareScalingOptimization object
  74919. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74920. * @param maximumScale defines the maximum scale to use (2 by default)
  74921. * @param step defines the step to use between two passes (0.5 by default)
  74922. */
  74923. constructor(
  74924. /**
  74925. * Defines the priority of this optimization (0 by default which means first in the list)
  74926. */
  74927. priority?: number,
  74928. /**
  74929. * Defines the maximum scale to use (2 by default)
  74930. */
  74931. maximumScale?: number,
  74932. /**
  74933. * Defines the step to use between two passes (0.5 by default)
  74934. */
  74935. step?: number);
  74936. /**
  74937. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74938. * @param scene defines the current scene where to apply this optimization
  74939. * @param optimizer defines the current optimizer
  74940. * @returns true if everything that can be done was applied
  74941. */
  74942. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74943. }
  74944. /**
  74945. * Defines an optimization used to remove shadows
  74946. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74947. */
  74948. export class ShadowsOptimization extends SceneOptimization {
  74949. /**
  74950. * Gets a string describing the action executed by the current optimization
  74951. * @return description string
  74952. */
  74953. getDescription(): string;
  74954. /**
  74955. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74956. * @param scene defines the current scene where to apply this optimization
  74957. * @param optimizer defines the current optimizer
  74958. * @returns true if everything that can be done was applied
  74959. */
  74960. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74961. }
  74962. /**
  74963. * Defines an optimization used to turn post-processes off
  74964. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74965. */
  74966. export class PostProcessesOptimization extends SceneOptimization {
  74967. /**
  74968. * Gets a string describing the action executed by the current optimization
  74969. * @return description string
  74970. */
  74971. getDescription(): string;
  74972. /**
  74973. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74974. * @param scene defines the current scene where to apply this optimization
  74975. * @param optimizer defines the current optimizer
  74976. * @returns true if everything that can be done was applied
  74977. */
  74978. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74979. }
  74980. /**
  74981. * Defines an optimization used to turn lens flares off
  74982. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74983. */
  74984. export class LensFlaresOptimization extends SceneOptimization {
  74985. /**
  74986. * Gets a string describing the action executed by the current optimization
  74987. * @return description string
  74988. */
  74989. getDescription(): string;
  74990. /**
  74991. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74992. * @param scene defines the current scene where to apply this optimization
  74993. * @param optimizer defines the current optimizer
  74994. * @returns true if everything that can be done was applied
  74995. */
  74996. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74997. }
  74998. /**
  74999. * Defines an optimization based on user defined callback.
  75000. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75001. */
  75002. export class CustomOptimization extends SceneOptimization {
  75003. /**
  75004. * Callback called to apply the custom optimization.
  75005. */
  75006. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75007. /**
  75008. * Callback called to get custom description
  75009. */
  75010. onGetDescription: () => string;
  75011. /**
  75012. * Gets a string describing the action executed by the current optimization
  75013. * @returns description string
  75014. */
  75015. getDescription(): string;
  75016. /**
  75017. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75018. * @param scene defines the current scene where to apply this optimization
  75019. * @param optimizer defines the current optimizer
  75020. * @returns true if everything that can be done was applied
  75021. */
  75022. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75023. }
  75024. /**
  75025. * Defines an optimization used to turn particles off
  75026. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75027. */
  75028. export class ParticlesOptimization extends SceneOptimization {
  75029. /**
  75030. * Gets a string describing the action executed by the current optimization
  75031. * @return description string
  75032. */
  75033. getDescription(): string;
  75034. /**
  75035. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75036. * @param scene defines the current scene where to apply this optimization
  75037. * @param optimizer defines the current optimizer
  75038. * @returns true if everything that can be done was applied
  75039. */
  75040. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75041. }
  75042. /**
  75043. * Defines an optimization used to turn render targets off
  75044. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75045. */
  75046. export class RenderTargetsOptimization extends SceneOptimization {
  75047. /**
  75048. * Gets a string describing the action executed by the current optimization
  75049. * @return description string
  75050. */
  75051. getDescription(): string;
  75052. /**
  75053. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75054. * @param scene defines the current scene where to apply this optimization
  75055. * @param optimizer defines the current optimizer
  75056. * @returns true if everything that can be done was applied
  75057. */
  75058. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75059. }
  75060. /**
  75061. * Defines an optimization used to merge meshes with compatible materials
  75062. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75063. */
  75064. export class MergeMeshesOptimization extends SceneOptimization {
  75065. private static _UpdateSelectionTree;
  75066. /**
  75067. * Gets or sets a boolean which defines if optimization octree has to be updated
  75068. */
  75069. static get UpdateSelectionTree(): boolean;
  75070. /**
  75071. * Gets or sets a boolean which defines if optimization octree has to be updated
  75072. */
  75073. static set UpdateSelectionTree(value: boolean);
  75074. /**
  75075. * Gets a string describing the action executed by the current optimization
  75076. * @return description string
  75077. */
  75078. getDescription(): string;
  75079. private _canBeMerged;
  75080. /**
  75081. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75082. * @param scene defines the current scene where to apply this optimization
  75083. * @param optimizer defines the current optimizer
  75084. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75085. * @returns true if everything that can be done was applied
  75086. */
  75087. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75088. }
  75089. /**
  75090. * Defines a list of options used by SceneOptimizer
  75091. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75092. */
  75093. export class SceneOptimizerOptions {
  75094. /**
  75095. * Defines the target frame rate to reach (60 by default)
  75096. */
  75097. targetFrameRate: number;
  75098. /**
  75099. * Defines the interval between two checkes (2000ms by default)
  75100. */
  75101. trackerDuration: number;
  75102. /**
  75103. * Gets the list of optimizations to apply
  75104. */
  75105. optimizations: SceneOptimization[];
  75106. /**
  75107. * Creates a new list of options used by SceneOptimizer
  75108. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75109. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75110. */
  75111. constructor(
  75112. /**
  75113. * Defines the target frame rate to reach (60 by default)
  75114. */
  75115. targetFrameRate?: number,
  75116. /**
  75117. * Defines the interval between two checkes (2000ms by default)
  75118. */
  75119. trackerDuration?: number);
  75120. /**
  75121. * Add a new optimization
  75122. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75123. * @returns the current SceneOptimizerOptions
  75124. */
  75125. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75126. /**
  75127. * Add a new custom optimization
  75128. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75129. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75130. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75131. * @returns the current SceneOptimizerOptions
  75132. */
  75133. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75134. /**
  75135. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75136. * @param targetFrameRate defines the target frame rate (60 by default)
  75137. * @returns a SceneOptimizerOptions object
  75138. */
  75139. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75140. /**
  75141. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75142. * @param targetFrameRate defines the target frame rate (60 by default)
  75143. * @returns a SceneOptimizerOptions object
  75144. */
  75145. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75146. /**
  75147. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75148. * @param targetFrameRate defines the target frame rate (60 by default)
  75149. * @returns a SceneOptimizerOptions object
  75150. */
  75151. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75152. }
  75153. /**
  75154. * Class used to run optimizations in order to reach a target frame rate
  75155. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75156. */
  75157. export class SceneOptimizer implements IDisposable {
  75158. private _isRunning;
  75159. private _options;
  75160. private _scene;
  75161. private _currentPriorityLevel;
  75162. private _targetFrameRate;
  75163. private _trackerDuration;
  75164. private _currentFrameRate;
  75165. private _sceneDisposeObserver;
  75166. private _improvementMode;
  75167. /**
  75168. * Defines an observable called when the optimizer reaches the target frame rate
  75169. */
  75170. onSuccessObservable: Observable<SceneOptimizer>;
  75171. /**
  75172. * Defines an observable called when the optimizer enables an optimization
  75173. */
  75174. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75175. /**
  75176. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75177. */
  75178. onFailureObservable: Observable<SceneOptimizer>;
  75179. /**
  75180. * Gets a boolean indicating if the optimizer is in improvement mode
  75181. */
  75182. get isInImprovementMode(): boolean;
  75183. /**
  75184. * Gets the current priority level (0 at start)
  75185. */
  75186. get currentPriorityLevel(): number;
  75187. /**
  75188. * Gets the current frame rate checked by the SceneOptimizer
  75189. */
  75190. get currentFrameRate(): number;
  75191. /**
  75192. * Gets or sets the current target frame rate (60 by default)
  75193. */
  75194. get targetFrameRate(): number;
  75195. /**
  75196. * Gets or sets the current target frame rate (60 by default)
  75197. */
  75198. set targetFrameRate(value: number);
  75199. /**
  75200. * Gets or sets the current interval between two checks (every 2000ms by default)
  75201. */
  75202. get trackerDuration(): number;
  75203. /**
  75204. * Gets or sets the current interval between two checks (every 2000ms by default)
  75205. */
  75206. set trackerDuration(value: number);
  75207. /**
  75208. * Gets the list of active optimizations
  75209. */
  75210. get optimizations(): SceneOptimization[];
  75211. /**
  75212. * Creates a new SceneOptimizer
  75213. * @param scene defines the scene to work on
  75214. * @param options defines the options to use with the SceneOptimizer
  75215. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75216. * @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)
  75217. */
  75218. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75219. /**
  75220. * Stops the current optimizer
  75221. */
  75222. stop(): void;
  75223. /**
  75224. * Reset the optimizer to initial step (current priority level = 0)
  75225. */
  75226. reset(): void;
  75227. /**
  75228. * Start the optimizer. By default it will try to reach a specific framerate
  75229. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75230. */
  75231. start(): void;
  75232. private _checkCurrentState;
  75233. /**
  75234. * Release all resources
  75235. */
  75236. dispose(): void;
  75237. /**
  75238. * Helper function to create a SceneOptimizer with one single line of code
  75239. * @param scene defines the scene to work on
  75240. * @param options defines the options to use with the SceneOptimizer
  75241. * @param onSuccess defines a callback to call on success
  75242. * @param onFailure defines a callback to call on failure
  75243. * @returns the new SceneOptimizer object
  75244. */
  75245. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75246. }
  75247. }
  75248. declare module BABYLON {
  75249. /**
  75250. * Class used to serialize a scene into a string
  75251. */
  75252. export class SceneSerializer {
  75253. /**
  75254. * Clear cache used by a previous serialization
  75255. */
  75256. static ClearCache(): void;
  75257. /**
  75258. * Serialize a scene into a JSON compatible object
  75259. * @param scene defines the scene to serialize
  75260. * @returns a JSON compatible object
  75261. */
  75262. static Serialize(scene: Scene): any;
  75263. /**
  75264. * Serialize a mesh into a JSON compatible object
  75265. * @param toSerialize defines the mesh to serialize
  75266. * @param withParents defines if parents must be serialized as well
  75267. * @param withChildren defines if children must be serialized as well
  75268. * @returns a JSON compatible object
  75269. */
  75270. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75271. }
  75272. }
  75273. declare module BABYLON {
  75274. /**
  75275. * Class used to host texture specific utilities
  75276. */
  75277. export class TextureTools {
  75278. /**
  75279. * Uses the GPU to create a copy texture rescaled at a given size
  75280. * @param texture Texture to copy from
  75281. * @param width defines the desired width
  75282. * @param height defines the desired height
  75283. * @param useBilinearMode defines if bilinear mode has to be used
  75284. * @return the generated texture
  75285. */
  75286. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75287. }
  75288. }
  75289. declare module BABYLON {
  75290. /**
  75291. * This represents the different options available for the video capture.
  75292. */
  75293. export interface VideoRecorderOptions {
  75294. /** Defines the mime type of the video. */
  75295. mimeType: string;
  75296. /** Defines the FPS the video should be recorded at. */
  75297. fps: number;
  75298. /** Defines the chunk size for the recording data. */
  75299. recordChunckSize: number;
  75300. /** The audio tracks to attach to the recording. */
  75301. audioTracks?: MediaStreamTrack[];
  75302. }
  75303. /**
  75304. * This can help with recording videos from BabylonJS.
  75305. * This is based on the available WebRTC functionalities of the browser.
  75306. *
  75307. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75308. */
  75309. export class VideoRecorder {
  75310. private static readonly _defaultOptions;
  75311. /**
  75312. * Returns whether or not the VideoRecorder is available in your browser.
  75313. * @param engine Defines the Babylon Engine.
  75314. * @returns true if supported otherwise false.
  75315. */
  75316. static IsSupported(engine: Engine): boolean;
  75317. private readonly _options;
  75318. private _canvas;
  75319. private _mediaRecorder;
  75320. private _recordedChunks;
  75321. private _fileName;
  75322. private _resolve;
  75323. private _reject;
  75324. /**
  75325. * True when a recording is already in progress.
  75326. */
  75327. get isRecording(): boolean;
  75328. /**
  75329. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75330. * @param engine Defines the BabylonJS Engine you wish to record.
  75331. * @param options Defines options that can be used to customize the capture.
  75332. */
  75333. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75334. /**
  75335. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75336. */
  75337. stopRecording(): void;
  75338. /**
  75339. * Starts recording the canvas for a max duration specified in parameters.
  75340. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75341. * If null no automatic download will start and you can rely on the promise to get the data back.
  75342. * @param maxDuration Defines the maximum recording time in seconds.
  75343. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75344. * @return A promise callback at the end of the recording with the video data in Blob.
  75345. */
  75346. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75347. /**
  75348. * Releases internal resources used during the recording.
  75349. */
  75350. dispose(): void;
  75351. private _handleDataAvailable;
  75352. private _handleError;
  75353. private _handleStop;
  75354. }
  75355. }
  75356. declare module BABYLON {
  75357. /**
  75358. * Class containing a set of static utilities functions for screenshots
  75359. */
  75360. export class ScreenshotTools {
  75361. /**
  75362. * Captures a screenshot of the current rendering
  75363. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75364. * @param engine defines the rendering engine
  75365. * @param camera defines the source camera
  75366. * @param size This parameter can be set to a single number or to an object with the
  75367. * following (optional) properties: precision, width, height. If a single number is passed,
  75368. * it will be used for both width and height. If an object is passed, the screenshot size
  75369. * will be derived from the parameters. The precision property is a multiplier allowing
  75370. * rendering at a higher or lower resolution
  75371. * @param successCallback defines the callback receives a single parameter which contains the
  75372. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75373. * src parameter of an <img> to display it
  75374. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75375. * Check your browser for supported MIME types
  75376. */
  75377. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75378. /**
  75379. * Captures a screenshot of the current rendering
  75380. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75381. * @param engine defines the rendering engine
  75382. * @param camera defines the source camera
  75383. * @param size This parameter can be set to a single number or to an object with the
  75384. * following (optional) properties: precision, width, height. If a single number is passed,
  75385. * it will be used for both width and height. If an object is passed, the screenshot size
  75386. * will be derived from the parameters. The precision property is a multiplier allowing
  75387. * rendering at a higher or lower resolution
  75388. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75389. * Check your browser for supported MIME types
  75390. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75391. * to the src parameter of an <img> to display it
  75392. */
  75393. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75394. /**
  75395. * Generates an image screenshot from the specified camera.
  75396. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75397. * @param engine The engine to use for rendering
  75398. * @param camera The camera to use for rendering
  75399. * @param size This parameter can be set to a single number or to an object with the
  75400. * following (optional) properties: precision, width, height. If a single number is passed,
  75401. * it will be used for both width and height. If an object is passed, the screenshot size
  75402. * will be derived from the parameters. The precision property is a multiplier allowing
  75403. * rendering at a higher or lower resolution
  75404. * @param successCallback The callback receives a single parameter which contains the
  75405. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75406. * src parameter of an <img> to display it
  75407. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75408. * Check your browser for supported MIME types
  75409. * @param samples Texture samples (default: 1)
  75410. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75411. * @param fileName A name for for the downloaded file.
  75412. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75413. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75414. */
  75415. 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;
  75416. /**
  75417. * Generates an image screenshot from the specified camera.
  75418. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75419. * @param engine The engine to use for rendering
  75420. * @param camera The camera to use for rendering
  75421. * @param size This parameter can be set to a single number or to an object with the
  75422. * following (optional) properties: precision, width, height. If a single number is passed,
  75423. * it will be used for both width and height. If an object is passed, the screenshot size
  75424. * will be derived from the parameters. The precision property is a multiplier allowing
  75425. * rendering at a higher or lower resolution
  75426. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75427. * Check your browser for supported MIME types
  75428. * @param samples Texture samples (default: 1)
  75429. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75430. * @param fileName A name for for the downloaded file.
  75431. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75432. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75433. * to the src parameter of an <img> to display it
  75434. */
  75435. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75436. /**
  75437. * Gets height and width for screenshot size
  75438. * @private
  75439. */
  75440. private static _getScreenshotSize;
  75441. }
  75442. }
  75443. declare module BABYLON {
  75444. /**
  75445. * Interface for a data buffer
  75446. */
  75447. export interface IDataBuffer {
  75448. /**
  75449. * Reads bytes from the data buffer.
  75450. * @param byteOffset The byte offset to read
  75451. * @param byteLength The byte length to read
  75452. * @returns A promise that resolves when the bytes are read
  75453. */
  75454. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75455. /**
  75456. * The byte length of the buffer.
  75457. */
  75458. readonly byteLength: number;
  75459. }
  75460. /**
  75461. * Utility class for reading from a data buffer
  75462. */
  75463. export class DataReader {
  75464. /**
  75465. * The data buffer associated with this data reader.
  75466. */
  75467. readonly buffer: IDataBuffer;
  75468. /**
  75469. * The current byte offset from the beginning of the data buffer.
  75470. */
  75471. byteOffset: number;
  75472. private _dataView;
  75473. private _dataByteOffset;
  75474. /**
  75475. * Constructor
  75476. * @param buffer The buffer to read
  75477. */
  75478. constructor(buffer: IDataBuffer);
  75479. /**
  75480. * Loads the given byte length.
  75481. * @param byteLength The byte length to load
  75482. * @returns A promise that resolves when the load is complete
  75483. */
  75484. loadAsync(byteLength: number): Promise<void>;
  75485. /**
  75486. * Read a unsigned 32-bit integer from the currently loaded data range.
  75487. * @returns The 32-bit integer read
  75488. */
  75489. readUint32(): number;
  75490. /**
  75491. * Read a byte array from the currently loaded data range.
  75492. * @param byteLength The byte length to read
  75493. * @returns The byte array read
  75494. */
  75495. readUint8Array(byteLength: number): Uint8Array;
  75496. /**
  75497. * Read a string from the currently loaded data range.
  75498. * @param byteLength The byte length to read
  75499. * @returns The string read
  75500. */
  75501. readString(byteLength: number): string;
  75502. /**
  75503. * Skips the given byte length the currently loaded data range.
  75504. * @param byteLength The byte length to skip
  75505. */
  75506. skipBytes(byteLength: number): void;
  75507. }
  75508. }
  75509. declare module BABYLON {
  75510. /**
  75511. * Class for storing data to local storage if available or in-memory storage otherwise
  75512. */
  75513. export class DataStorage {
  75514. private static _Storage;
  75515. private static _GetStorage;
  75516. /**
  75517. * Reads a string from the data storage
  75518. * @param key The key to read
  75519. * @param defaultValue The value if the key doesn't exist
  75520. * @returns The string value
  75521. */
  75522. static ReadString(key: string, defaultValue: string): string;
  75523. /**
  75524. * Writes a string to the data storage
  75525. * @param key The key to write
  75526. * @param value The value to write
  75527. */
  75528. static WriteString(key: string, value: string): void;
  75529. /**
  75530. * Reads a boolean from the data storage
  75531. * @param key The key to read
  75532. * @param defaultValue The value if the key doesn't exist
  75533. * @returns The boolean value
  75534. */
  75535. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75536. /**
  75537. * Writes a boolean to the data storage
  75538. * @param key The key to write
  75539. * @param value The value to write
  75540. */
  75541. static WriteBoolean(key: string, value: boolean): void;
  75542. /**
  75543. * Reads a number from the data storage
  75544. * @param key The key to read
  75545. * @param defaultValue The value if the key doesn't exist
  75546. * @returns The number value
  75547. */
  75548. static ReadNumber(key: string, defaultValue: number): number;
  75549. /**
  75550. * Writes a number to the data storage
  75551. * @param key The key to write
  75552. * @param value The value to write
  75553. */
  75554. static WriteNumber(key: string, value: number): void;
  75555. }
  75556. }
  75557. declare module BABYLON {
  75558. /**
  75559. * Class used to record delta files between 2 scene states
  75560. */
  75561. export class SceneRecorder {
  75562. private _trackedScene;
  75563. private _savedJSON;
  75564. /**
  75565. * Track a given scene. This means the current scene state will be considered the original state
  75566. * @param scene defines the scene to track
  75567. */
  75568. track(scene: Scene): void;
  75569. /**
  75570. * Get the delta between current state and original state
  75571. * @returns a string containing the delta
  75572. */
  75573. getDelta(): any;
  75574. private _compareArray;
  75575. private _compareObjects;
  75576. private _compareCollections;
  75577. private static GetShadowGeneratorById;
  75578. /**
  75579. * Apply a given delta to a given scene
  75580. * @param deltaJSON defines the JSON containing the delta
  75581. * @param scene defines the scene to apply the delta to
  75582. */
  75583. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75584. private static _ApplyPropertiesToEntity;
  75585. private static _ApplyDeltaForEntity;
  75586. }
  75587. }
  75588. declare module BABYLON {
  75589. /**
  75590. * A 3D trajectory consisting of an order list of vectors describing a
  75591. * path of motion through 3D space.
  75592. */
  75593. export class Trajectory {
  75594. private _points;
  75595. private readonly _segmentLength;
  75596. /**
  75597. * Serialize to JSON.
  75598. * @returns serialized JSON string
  75599. */
  75600. serialize(): string;
  75601. /**
  75602. * Deserialize from JSON.
  75603. * @param json serialized JSON string
  75604. * @returns deserialized Trajectory
  75605. */
  75606. static Deserialize(json: string): Trajectory;
  75607. /**
  75608. * Create a new empty Trajectory.
  75609. * @param segmentLength radius of discretization for Trajectory points
  75610. */
  75611. constructor(segmentLength?: number);
  75612. /**
  75613. * Get the length of the Trajectory.
  75614. * @returns length of the Trajectory
  75615. */
  75616. getLength(): number;
  75617. /**
  75618. * Append a new point to the Trajectory.
  75619. * NOTE: This implementation has many allocations.
  75620. * @param point point to append to the Trajectory
  75621. */
  75622. add(point: DeepImmutable<Vector3>): void;
  75623. /**
  75624. * Create a new Trajectory with a segment length chosen to make it
  75625. * probable that the new Trajectory will have a specified number of
  75626. * segments. This operation is imprecise.
  75627. * @param targetResolution number of segments desired
  75628. * @returns new Trajectory with approximately the requested number of segments
  75629. */
  75630. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75631. /**
  75632. * Convert Trajectory segments into tokenized representation. This
  75633. * representation is an array of numbers where each nth number is the
  75634. * index of the token which is most similar to the nth segment of the
  75635. * Trajectory.
  75636. * @param tokens list of vectors which serve as discrete tokens
  75637. * @returns list of indices of most similar token per segment
  75638. */
  75639. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75640. private static _forwardDir;
  75641. private static _inverseFromVec;
  75642. private static _upDir;
  75643. private static _fromToVec;
  75644. private static _lookMatrix;
  75645. /**
  75646. * Transform the rotation (i.e., direction) of a segment to isolate
  75647. * the relative transformation represented by the segment. This operation
  75648. * may or may not succeed due to singularities in the equations that define
  75649. * motion relativity in this context.
  75650. * @param priorVec the origin of the prior segment
  75651. * @param fromVec the origin of the current segment
  75652. * @param toVec the destination of the current segment
  75653. * @param result reference to output variable
  75654. * @returns whether or not transformation was successful
  75655. */
  75656. private static _transformSegmentDirToRef;
  75657. private static _bestMatch;
  75658. private static _score;
  75659. private static _bestScore;
  75660. /**
  75661. * Determine which token vector is most similar to the
  75662. * segment vector.
  75663. * @param segment segment vector
  75664. * @param tokens token vector list
  75665. * @returns index of the most similar token to the segment
  75666. */
  75667. private static _tokenizeSegment;
  75668. }
  75669. /**
  75670. * Class representing a set of known, named trajectories to which Trajectories can be
  75671. * added and using which Trajectories can be recognized.
  75672. */
  75673. export class TrajectoryClassifier {
  75674. private _maximumAllowableMatchCost;
  75675. private _vector3Alphabet;
  75676. private _levenshteinAlphabet;
  75677. private _nameToDescribedTrajectory;
  75678. /**
  75679. * Serialize to JSON.
  75680. * @returns JSON serialization
  75681. */
  75682. serialize(): string;
  75683. /**
  75684. * Deserialize from JSON.
  75685. * @param json JSON serialization
  75686. * @returns deserialized TrajectorySet
  75687. */
  75688. static Deserialize(json: string): TrajectoryClassifier;
  75689. /**
  75690. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75691. * VERY naive, need to be generating these things from known
  75692. * sets. Better version later, probably eliminating this one.
  75693. * @returns auto-generated TrajectorySet
  75694. */
  75695. static Generate(): TrajectoryClassifier;
  75696. private constructor();
  75697. /**
  75698. * Add a new Trajectory to the set with a given name.
  75699. * @param trajectory new Trajectory to be added
  75700. * @param classification name to which to add the Trajectory
  75701. */
  75702. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75703. /**
  75704. * Remove a known named trajectory and all Trajectories associated with it.
  75705. * @param classification name to remove
  75706. * @returns whether anything was removed
  75707. */
  75708. deleteClassification(classification: string): boolean;
  75709. /**
  75710. * Attempt to recognize a Trajectory from among all the classifications
  75711. * already known to the classifier.
  75712. * @param trajectory Trajectory to be recognized
  75713. * @returns classification of Trajectory if recognized, null otherwise
  75714. */
  75715. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75716. }
  75717. }
  75718. declare module BABYLON {
  75719. /**
  75720. * An interface for all Hit test features
  75721. */
  75722. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75723. /**
  75724. * Triggered when new babylon (transformed) hit test results are available
  75725. */
  75726. onHitTestResultObservable: Observable<T[]>;
  75727. }
  75728. /**
  75729. * Options used for hit testing
  75730. */
  75731. export interface IWebXRLegacyHitTestOptions {
  75732. /**
  75733. * Only test when user interacted with the scene. Default - hit test every frame
  75734. */
  75735. testOnPointerDownOnly?: boolean;
  75736. /**
  75737. * The node to use to transform the local results to world coordinates
  75738. */
  75739. worldParentNode?: TransformNode;
  75740. }
  75741. /**
  75742. * Interface defining the babylon result of raycasting/hit-test
  75743. */
  75744. export interface IWebXRLegacyHitResult {
  75745. /**
  75746. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75747. */
  75748. transformationMatrix: Matrix;
  75749. /**
  75750. * The native hit test result
  75751. */
  75752. xrHitResult: XRHitResult | XRHitTestResult;
  75753. }
  75754. /**
  75755. * The currently-working hit-test module.
  75756. * Hit test (or Ray-casting) is used to interact with the real world.
  75757. * For further information read here - https://github.com/immersive-web/hit-test
  75758. */
  75759. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75760. /**
  75761. * options to use when constructing this feature
  75762. */
  75763. readonly options: IWebXRLegacyHitTestOptions;
  75764. private _direction;
  75765. private _mat;
  75766. private _onSelectEnabled;
  75767. private _origin;
  75768. /**
  75769. * The module's name
  75770. */
  75771. static readonly Name: string;
  75772. /**
  75773. * The (Babylon) version of this module.
  75774. * This is an integer representing the implementation version.
  75775. * This number does not correspond to the WebXR specs version
  75776. */
  75777. static readonly Version: number;
  75778. /**
  75779. * Populated with the last native XR Hit Results
  75780. */
  75781. lastNativeXRHitResults: XRHitResult[];
  75782. /**
  75783. * Triggered when new babylon (transformed) hit test results are available
  75784. */
  75785. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75786. /**
  75787. * Creates a new instance of the (legacy version) hit test feature
  75788. * @param _xrSessionManager an instance of WebXRSessionManager
  75789. * @param options options to use when constructing this feature
  75790. */
  75791. constructor(_xrSessionManager: WebXRSessionManager,
  75792. /**
  75793. * options to use when constructing this feature
  75794. */
  75795. options?: IWebXRLegacyHitTestOptions);
  75796. /**
  75797. * execute a hit test with an XR Ray
  75798. *
  75799. * @param xrSession a native xrSession that will execute this hit test
  75800. * @param xrRay the ray (position and direction) to use for ray-casting
  75801. * @param referenceSpace native XR reference space to use for the hit-test
  75802. * @param filter filter function that will filter the results
  75803. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75804. */
  75805. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75806. /**
  75807. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75808. * @param event the (select) event to use to select with
  75809. * @param referenceSpace the reference space to use for this hit test
  75810. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75811. */
  75812. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75813. /**
  75814. * attach this feature
  75815. * Will usually be called by the features manager
  75816. *
  75817. * @returns true if successful.
  75818. */
  75819. attach(): boolean;
  75820. /**
  75821. * detach this feature.
  75822. * Will usually be called by the features manager
  75823. *
  75824. * @returns true if successful.
  75825. */
  75826. detach(): boolean;
  75827. /**
  75828. * Dispose this feature and all of the resources attached
  75829. */
  75830. dispose(): void;
  75831. protected _onXRFrame(frame: XRFrame): void;
  75832. private _onHitTestResults;
  75833. private _onSelect;
  75834. }
  75835. }
  75836. declare module BABYLON {
  75837. /**
  75838. * Options used for hit testing (version 2)
  75839. */
  75840. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75841. /**
  75842. * Do not create a permanent hit test. Will usually be used when only
  75843. * transient inputs are needed.
  75844. */
  75845. disablePermanentHitTest?: boolean;
  75846. /**
  75847. * Enable transient (for example touch-based) hit test inspections
  75848. */
  75849. enableTransientHitTest?: boolean;
  75850. /**
  75851. * Offset ray for the permanent hit test
  75852. */
  75853. offsetRay?: Vector3;
  75854. /**
  75855. * Offset ray for the transient hit test
  75856. */
  75857. transientOffsetRay?: Vector3;
  75858. /**
  75859. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75860. */
  75861. useReferenceSpace?: boolean;
  75862. /**
  75863. * Override the default entity type(s) of the hit-test result
  75864. */
  75865. entityTypes?: XRHitTestTrackableType[];
  75866. }
  75867. /**
  75868. * Interface defining the babylon result of hit-test
  75869. */
  75870. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75871. /**
  75872. * The input source that generated this hit test (if transient)
  75873. */
  75874. inputSource?: XRInputSource;
  75875. /**
  75876. * Is this a transient hit test
  75877. */
  75878. isTransient?: boolean;
  75879. /**
  75880. * Position of the hit test result
  75881. */
  75882. position: Vector3;
  75883. /**
  75884. * Rotation of the hit test result
  75885. */
  75886. rotationQuaternion: Quaternion;
  75887. /**
  75888. * The native hit test result
  75889. */
  75890. xrHitResult: XRHitTestResult;
  75891. }
  75892. /**
  75893. * The currently-working hit-test module.
  75894. * Hit test (or Ray-casting) is used to interact with the real world.
  75895. * For further information read here - https://github.com/immersive-web/hit-test
  75896. *
  75897. * Tested on chrome (mobile) 80.
  75898. */
  75899. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75900. /**
  75901. * options to use when constructing this feature
  75902. */
  75903. readonly options: IWebXRHitTestOptions;
  75904. private _tmpMat;
  75905. private _tmpPos;
  75906. private _tmpQuat;
  75907. private _transientXrHitTestSource;
  75908. private _xrHitTestSource;
  75909. private initHitTestSource;
  75910. /**
  75911. * The module's name
  75912. */
  75913. static readonly Name: string;
  75914. /**
  75915. * The (Babylon) version of this module.
  75916. * This is an integer representing the implementation version.
  75917. * This number does not correspond to the WebXR specs version
  75918. */
  75919. static readonly Version: number;
  75920. /**
  75921. * When set to true, each hit test will have its own position/rotation objects
  75922. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75923. * the developers will clone them or copy them as they see fit.
  75924. */
  75925. autoCloneTransformation: boolean;
  75926. /**
  75927. * Triggered when new babylon (transformed) hit test results are available
  75928. * Note - this will be called when results come back from the device. It can be an empty array!!
  75929. */
  75930. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75931. /**
  75932. * Use this to temporarily pause hit test checks.
  75933. */
  75934. paused: boolean;
  75935. /**
  75936. * Creates a new instance of the hit test feature
  75937. * @param _xrSessionManager an instance of WebXRSessionManager
  75938. * @param options options to use when constructing this feature
  75939. */
  75940. constructor(_xrSessionManager: WebXRSessionManager,
  75941. /**
  75942. * options to use when constructing this feature
  75943. */
  75944. options?: IWebXRHitTestOptions);
  75945. /**
  75946. * attach this feature
  75947. * Will usually be called by the features manager
  75948. *
  75949. * @returns true if successful.
  75950. */
  75951. attach(): boolean;
  75952. /**
  75953. * detach this feature.
  75954. * Will usually be called by the features manager
  75955. *
  75956. * @returns true if successful.
  75957. */
  75958. detach(): boolean;
  75959. /**
  75960. * Dispose this feature and all of the resources attached
  75961. */
  75962. dispose(): void;
  75963. protected _onXRFrame(frame: XRFrame): void;
  75964. private _processWebXRHitTestResult;
  75965. }
  75966. }
  75967. declare module BABYLON {
  75968. /**
  75969. * Configuration options of the anchor system
  75970. */
  75971. export interface IWebXRAnchorSystemOptions {
  75972. /**
  75973. * a node that will be used to convert local to world coordinates
  75974. */
  75975. worldParentNode?: TransformNode;
  75976. /**
  75977. * If set to true a reference of the created anchors will be kept until the next session starts
  75978. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75979. */
  75980. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75981. }
  75982. /**
  75983. * A babylon container for an XR Anchor
  75984. */
  75985. export interface IWebXRAnchor {
  75986. /**
  75987. * A babylon-assigned ID for this anchor
  75988. */
  75989. id: number;
  75990. /**
  75991. * Transformation matrix to apply to an object attached to this anchor
  75992. */
  75993. transformationMatrix: Matrix;
  75994. /**
  75995. * The native anchor object
  75996. */
  75997. xrAnchor: XRAnchor;
  75998. /**
  75999. * if defined, this object will be constantly updated by the anchor's position and rotation
  76000. */
  76001. attachedNode?: TransformNode;
  76002. /**
  76003. * Remove this anchor from the scene
  76004. */
  76005. remove(): void;
  76006. }
  76007. /**
  76008. * An implementation of the anchor system for WebXR.
  76009. * For further information see https://github.com/immersive-web/anchors/
  76010. */
  76011. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76012. private _options;
  76013. private _lastFrameDetected;
  76014. private _trackedAnchors;
  76015. private _referenceSpaceForFrameAnchors;
  76016. private _futureAnchors;
  76017. /**
  76018. * The module's name
  76019. */
  76020. static readonly Name: string;
  76021. /**
  76022. * The (Babylon) version of this module.
  76023. * This is an integer representing the implementation version.
  76024. * This number does not correspond to the WebXR specs version
  76025. */
  76026. static readonly Version: number;
  76027. /**
  76028. * Observers registered here will be executed when a new anchor was added to the session
  76029. */
  76030. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76031. /**
  76032. * Observers registered here will be executed when an anchor was removed from the session
  76033. */
  76034. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76035. /**
  76036. * Observers registered here will be executed when an existing anchor updates
  76037. * This can execute N times every frame
  76038. */
  76039. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76040. /**
  76041. * Set the reference space to use for anchor creation, when not using a hit test.
  76042. * Will default to the session's reference space if not defined
  76043. */
  76044. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76045. /**
  76046. * constructs a new anchor system
  76047. * @param _xrSessionManager an instance of WebXRSessionManager
  76048. * @param _options configuration object for this feature
  76049. */
  76050. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76051. private _tmpVector;
  76052. private _tmpQuaternion;
  76053. private _populateTmpTransformation;
  76054. /**
  76055. * Create a new anchor point using a hit test result at a specific point in the scene
  76056. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76057. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76058. *
  76059. * @param hitTestResult The hit test result to use for this anchor creation
  76060. * @param position an optional position offset for this anchor
  76061. * @param rotationQuaternion an optional rotation offset for this anchor
  76062. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76063. */
  76064. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  76065. /**
  76066. * Add a new anchor at a specific position and rotation
  76067. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76068. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76069. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76070. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76071. *
  76072. * @param position the position in which to add an anchor
  76073. * @param rotationQuaternion an optional rotation for the anchor transformation
  76074. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76075. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76076. */
  76077. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  76078. /**
  76079. * detach this feature.
  76080. * Will usually be called by the features manager
  76081. *
  76082. * @returns true if successful.
  76083. */
  76084. detach(): boolean;
  76085. /**
  76086. * Dispose this feature and all of the resources attached
  76087. */
  76088. dispose(): void;
  76089. protected _onXRFrame(frame: XRFrame): void;
  76090. /**
  76091. * avoiding using Array.find for global support.
  76092. * @param xrAnchor the plane to find in the array
  76093. */
  76094. private _findIndexInAnchorArray;
  76095. private _updateAnchorWithXRFrame;
  76096. private _createAnchorAtTransformation;
  76097. }
  76098. }
  76099. declare module BABYLON {
  76100. /**
  76101. * Options used in the plane detector module
  76102. */
  76103. export interface IWebXRPlaneDetectorOptions {
  76104. /**
  76105. * The node to use to transform the local results to world coordinates
  76106. */
  76107. worldParentNode?: TransformNode;
  76108. /**
  76109. * If set to true a reference of the created planes will be kept until the next session starts
  76110. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76111. */
  76112. doNotRemovePlanesOnSessionEnded?: boolean;
  76113. }
  76114. /**
  76115. * A babylon interface for a WebXR plane.
  76116. * A Plane is actually a polygon, built from N points in space
  76117. *
  76118. * Supported in chrome 79, not supported in canary 81 ATM
  76119. */
  76120. export interface IWebXRPlane {
  76121. /**
  76122. * a babylon-assigned ID for this polygon
  76123. */
  76124. id: number;
  76125. /**
  76126. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76127. */
  76128. polygonDefinition: Array<Vector3>;
  76129. /**
  76130. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76131. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76132. */
  76133. transformationMatrix: Matrix;
  76134. /**
  76135. * the native xr-plane object
  76136. */
  76137. xrPlane: XRPlane;
  76138. }
  76139. /**
  76140. * The plane detector is used to detect planes in the real world when in AR
  76141. * For more information see https://github.com/immersive-web/real-world-geometry/
  76142. */
  76143. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76144. private _options;
  76145. private _detectedPlanes;
  76146. private _enabled;
  76147. private _lastFrameDetected;
  76148. /**
  76149. * The module's name
  76150. */
  76151. static readonly Name: string;
  76152. /**
  76153. * The (Babylon) version of this module.
  76154. * This is an integer representing the implementation version.
  76155. * This number does not correspond to the WebXR specs version
  76156. */
  76157. static readonly Version: number;
  76158. /**
  76159. * Observers registered here will be executed when a new plane was added to the session
  76160. */
  76161. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76162. /**
  76163. * Observers registered here will be executed when a plane is no longer detected in the session
  76164. */
  76165. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76166. /**
  76167. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76168. * This can execute N times every frame
  76169. */
  76170. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76171. /**
  76172. * construct a new Plane Detector
  76173. * @param _xrSessionManager an instance of xr Session manager
  76174. * @param _options configuration to use when constructing this feature
  76175. */
  76176. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76177. /**
  76178. * detach this feature.
  76179. * Will usually be called by the features manager
  76180. *
  76181. * @returns true if successful.
  76182. */
  76183. detach(): boolean;
  76184. /**
  76185. * Dispose this feature and all of the resources attached
  76186. */
  76187. dispose(): void;
  76188. /**
  76189. * Check if the needed objects are defined.
  76190. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76191. */
  76192. isCompatible(): boolean;
  76193. protected _onXRFrame(frame: XRFrame): void;
  76194. private _init;
  76195. private _updatePlaneWithXRPlane;
  76196. /**
  76197. * avoiding using Array.find for global support.
  76198. * @param xrPlane the plane to find in the array
  76199. */
  76200. private findIndexInPlaneArray;
  76201. }
  76202. }
  76203. declare module BABYLON {
  76204. /**
  76205. * Options interface for the background remover plugin
  76206. */
  76207. export interface IWebXRBackgroundRemoverOptions {
  76208. /**
  76209. * Further background meshes to disable when entering AR
  76210. */
  76211. backgroundMeshes?: AbstractMesh[];
  76212. /**
  76213. * flags to configure the removal of the environment helper.
  76214. * If not set, the entire background will be removed. If set, flags should be set as well.
  76215. */
  76216. environmentHelperRemovalFlags?: {
  76217. /**
  76218. * Should the skybox be removed (default false)
  76219. */
  76220. skyBox?: boolean;
  76221. /**
  76222. * Should the ground be removed (default false)
  76223. */
  76224. ground?: boolean;
  76225. };
  76226. /**
  76227. * don't disable the environment helper
  76228. */
  76229. ignoreEnvironmentHelper?: boolean;
  76230. }
  76231. /**
  76232. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76233. */
  76234. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76235. /**
  76236. * read-only options to be used in this module
  76237. */
  76238. readonly options: IWebXRBackgroundRemoverOptions;
  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. * registered observers will be triggered when the background state changes
  76251. */
  76252. onBackgroundStateChangedObservable: Observable<boolean>;
  76253. /**
  76254. * constructs a new background remover module
  76255. * @param _xrSessionManager the session manager for this module
  76256. * @param options read-only options to be used in this module
  76257. */
  76258. constructor(_xrSessionManager: WebXRSessionManager,
  76259. /**
  76260. * read-only options to be used in this module
  76261. */
  76262. options?: IWebXRBackgroundRemoverOptions);
  76263. /**
  76264. * attach this feature
  76265. * Will usually be called by the features manager
  76266. *
  76267. * @returns true if successful.
  76268. */
  76269. attach(): boolean;
  76270. /**
  76271. * detach this feature.
  76272. * Will usually be called by the features manager
  76273. *
  76274. * @returns true if successful.
  76275. */
  76276. detach(): boolean;
  76277. /**
  76278. * Dispose this feature and all of the resources attached
  76279. */
  76280. dispose(): void;
  76281. protected _onXRFrame(_xrFrame: XRFrame): void;
  76282. private _setBackgroundState;
  76283. }
  76284. }
  76285. declare module BABYLON {
  76286. /**
  76287. * Options for the controller physics feature
  76288. */
  76289. export class IWebXRControllerPhysicsOptions {
  76290. /**
  76291. * Should the headset get its own impostor
  76292. */
  76293. enableHeadsetImpostor?: boolean;
  76294. /**
  76295. * Optional parameters for the headset impostor
  76296. */
  76297. headsetImpostorParams?: {
  76298. /**
  76299. * The type of impostor to create. Default is sphere
  76300. */
  76301. impostorType: number;
  76302. /**
  76303. * the size of the impostor. Defaults to 10cm
  76304. */
  76305. impostorSize?: number | {
  76306. width: number;
  76307. height: number;
  76308. depth: number;
  76309. };
  76310. /**
  76311. * Friction definitions
  76312. */
  76313. friction?: number;
  76314. /**
  76315. * Restitution
  76316. */
  76317. restitution?: number;
  76318. };
  76319. /**
  76320. * The physics properties of the future impostors
  76321. */
  76322. physicsProperties?: {
  76323. /**
  76324. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76325. * Note that this requires a physics engine that supports mesh impostors!
  76326. */
  76327. useControllerMesh?: boolean;
  76328. /**
  76329. * The type of impostor to create. Default is sphere
  76330. */
  76331. impostorType?: number;
  76332. /**
  76333. * the size of the impostor. Defaults to 10cm
  76334. */
  76335. impostorSize?: number | {
  76336. width: number;
  76337. height: number;
  76338. depth: number;
  76339. };
  76340. /**
  76341. * Friction definitions
  76342. */
  76343. friction?: number;
  76344. /**
  76345. * Restitution
  76346. */
  76347. restitution?: number;
  76348. };
  76349. /**
  76350. * the xr input to use with this pointer selection
  76351. */
  76352. xrInput: WebXRInput;
  76353. }
  76354. /**
  76355. * Add physics impostor to your webxr controllers,
  76356. * including naive calculation of their linear and angular velocity
  76357. */
  76358. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76359. private readonly _options;
  76360. private _attachController;
  76361. private _controllers;
  76362. private _debugMode;
  76363. private _delta;
  76364. private _headsetImpostor?;
  76365. private _headsetMesh?;
  76366. private _lastTimestamp;
  76367. private _tmpQuaternion;
  76368. private _tmpVector;
  76369. /**
  76370. * The module's name
  76371. */
  76372. static readonly Name: string;
  76373. /**
  76374. * The (Babylon) version of this module.
  76375. * This is an integer representing the implementation version.
  76376. * This number does not correspond to the webxr specs version
  76377. */
  76378. static readonly Version: number;
  76379. /**
  76380. * Construct a new Controller Physics Feature
  76381. * @param _xrSessionManager the corresponding xr session manager
  76382. * @param _options options to create this feature with
  76383. */
  76384. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76385. /**
  76386. * @hidden
  76387. * enable debugging - will show console outputs and the impostor mesh
  76388. */
  76389. _enablePhysicsDebug(): void;
  76390. /**
  76391. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76392. * @param xrController the controller to add
  76393. */
  76394. addController(xrController: WebXRInputSource): void;
  76395. /**
  76396. * attach this feature
  76397. * Will usually be called by the features manager
  76398. *
  76399. * @returns true if successful.
  76400. */
  76401. attach(): boolean;
  76402. /**
  76403. * detach this feature.
  76404. * Will usually be called by the features manager
  76405. *
  76406. * @returns true if successful.
  76407. */
  76408. detach(): boolean;
  76409. /**
  76410. * Get the headset impostor, if enabled
  76411. * @returns the impostor
  76412. */
  76413. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76414. /**
  76415. * Get the physics impostor of a specific controller.
  76416. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76417. * @param controller the controller or the controller id of which to get the impostor
  76418. * @returns the impostor or null
  76419. */
  76420. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76421. /**
  76422. * Update the physics properties provided in the constructor
  76423. * @param newProperties the new properties object
  76424. */
  76425. setPhysicsProperties(newProperties: {
  76426. impostorType?: number;
  76427. impostorSize?: number | {
  76428. width: number;
  76429. height: number;
  76430. depth: number;
  76431. };
  76432. friction?: number;
  76433. restitution?: number;
  76434. }): void;
  76435. protected _onXRFrame(_xrFrame: any): void;
  76436. private _detachController;
  76437. }
  76438. }
  76439. declare module BABYLON {
  76440. /**
  76441. * A babylon interface for a "WebXR" feature point.
  76442. * Represents the position and confidence value of a given feature point.
  76443. */
  76444. export interface IWebXRFeaturePoint {
  76445. /**
  76446. * Represents the position of the feature point in world space.
  76447. */
  76448. position: Vector3;
  76449. /**
  76450. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76451. */
  76452. confidenceValue: number;
  76453. }
  76454. /**
  76455. * The feature point system is used to detect feature points from real world geometry.
  76456. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76457. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76458. */
  76459. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76460. private _enabled;
  76461. private _featurePointCloud;
  76462. /**
  76463. * The module's name
  76464. */
  76465. static readonly Name: string;
  76466. /**
  76467. * The (Babylon) version of this module.
  76468. * This is an integer representing the implementation version.
  76469. * This number does not correspond to the WebXR specs version
  76470. */
  76471. static readonly Version: number;
  76472. /**
  76473. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76474. * Will notify the observers about which feature points have been added.
  76475. */
  76476. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76477. /**
  76478. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76479. * Will notify the observers about which feature points have been updated.
  76480. */
  76481. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76482. /**
  76483. * The current feature point cloud maintained across frames.
  76484. */
  76485. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76486. /**
  76487. * construct the feature point system
  76488. * @param _xrSessionManager an instance of xr Session manager
  76489. */
  76490. constructor(_xrSessionManager: WebXRSessionManager);
  76491. /**
  76492. * Detach this feature.
  76493. * Will usually be called by the features manager
  76494. *
  76495. * @returns true if successful.
  76496. */
  76497. detach(): boolean;
  76498. /**
  76499. * Dispose this feature and all of the resources attached
  76500. */
  76501. dispose(): void;
  76502. /**
  76503. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76504. */
  76505. protected _onXRFrame(frame: XRFrame): void;
  76506. /**
  76507. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76508. */
  76509. private _init;
  76510. }
  76511. }
  76512. declare module BABYLON {
  76513. /**
  76514. * Configuration interface for the hand tracking feature
  76515. */
  76516. export interface IWebXRHandTrackingOptions {
  76517. /**
  76518. * The xrInput that will be used as source for new hands
  76519. */
  76520. xrInput: WebXRInput;
  76521. /**
  76522. * Configuration object for the joint meshes
  76523. */
  76524. jointMeshes?: {
  76525. /**
  76526. * Should the meshes created be invisible (defaults to false)
  76527. */
  76528. invisible?: boolean;
  76529. /**
  76530. * A source mesh to be used to create instances. Defaults to a sphere.
  76531. * This mesh will be the source for all other (25) meshes.
  76532. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76533. */
  76534. sourceMesh?: Mesh;
  76535. /**
  76536. * This function will be called after a mesh was created for a specific joint.
  76537. * Using this function you can either manipulate the instance or return a new mesh.
  76538. * When returning a new mesh the instance created before will be disposed
  76539. */
  76540. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76541. /**
  76542. * Should the source mesh stay visible. Defaults to false
  76543. */
  76544. keepOriginalVisible?: boolean;
  76545. /**
  76546. * Scale factor for all instances (defaults to 2)
  76547. */
  76548. scaleFactor?: number;
  76549. /**
  76550. * Should each instance have its own physics impostor
  76551. */
  76552. enablePhysics?: boolean;
  76553. /**
  76554. * If enabled, override default physics properties
  76555. */
  76556. physicsProps?: {
  76557. friction?: number;
  76558. restitution?: number;
  76559. impostorType?: number;
  76560. };
  76561. /**
  76562. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76563. */
  76564. handMesh?: AbstractMesh;
  76565. };
  76566. }
  76567. /**
  76568. * Parts of the hands divided to writs and finger names
  76569. */
  76570. export const enum HandPart {
  76571. /**
  76572. * HandPart - Wrist
  76573. */
  76574. WRIST = "wrist",
  76575. /**
  76576. * HandPart - The THumb
  76577. */
  76578. THUMB = "thumb",
  76579. /**
  76580. * HandPart - Index finger
  76581. */
  76582. INDEX = "index",
  76583. /**
  76584. * HandPart - Middle finger
  76585. */
  76586. MIDDLE = "middle",
  76587. /**
  76588. * HandPart - Ring finger
  76589. */
  76590. RING = "ring",
  76591. /**
  76592. * HandPart - Little finger
  76593. */
  76594. LITTLE = "little"
  76595. }
  76596. /**
  76597. * Representing a single hand (with its corresponding native XRHand object)
  76598. */
  76599. export class WebXRHand implements IDisposable {
  76600. /** the controller to which the hand correlates */
  76601. readonly xrController: WebXRInputSource;
  76602. /** the meshes to be used to track the hand joints */
  76603. readonly trackedMeshes: AbstractMesh[];
  76604. /**
  76605. * Hand-parts definition (key is HandPart)
  76606. */
  76607. handPartsDefinition: {
  76608. [key: string]: number[];
  76609. };
  76610. /**
  76611. * Populate the HandPartsDefinition object.
  76612. * This is called as a side effect since certain browsers don't have XRHand defined.
  76613. */
  76614. private generateHandPartsDefinition;
  76615. /**
  76616. * Construct a new hand object
  76617. * @param xrController the controller to which the hand correlates
  76618. * @param trackedMeshes the meshes to be used to track the hand joints
  76619. */
  76620. constructor(
  76621. /** the controller to which the hand correlates */
  76622. xrController: WebXRInputSource,
  76623. /** the meshes to be used to track the hand joints */
  76624. trackedMeshes: AbstractMesh[]);
  76625. /**
  76626. * Update this hand from the latest xr frame
  76627. * @param xrFrame xrFrame to update from
  76628. * @param referenceSpace The current viewer reference space
  76629. * @param scaleFactor optional scale factor for the meshes
  76630. */
  76631. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76632. /**
  76633. * Get meshes of part of the hand
  76634. * @param part the part of hand to get
  76635. * @returns An array of meshes that correlate to the hand part requested
  76636. */
  76637. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76638. /**
  76639. * Dispose this Hand object
  76640. */
  76641. dispose(): void;
  76642. }
  76643. /**
  76644. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76645. */
  76646. export class WebXRHandTracking extends WebXRAbstractFeature {
  76647. /**
  76648. * options to use when constructing this feature
  76649. */
  76650. readonly options: IWebXRHandTrackingOptions;
  76651. private static _idCounter;
  76652. /**
  76653. * The module's name
  76654. */
  76655. static readonly Name: string;
  76656. /**
  76657. * The (Babylon) version of this module.
  76658. * This is an integer representing the implementation version.
  76659. * This number does not correspond to the WebXR specs version
  76660. */
  76661. static readonly Version: number;
  76662. /**
  76663. * This observable will notify registered observers when a new hand object was added and initialized
  76664. */
  76665. onHandAddedObservable: Observable<WebXRHand>;
  76666. /**
  76667. * This observable will notify its observers right before the hand object is disposed
  76668. */
  76669. onHandRemovedObservable: Observable<WebXRHand>;
  76670. private _hands;
  76671. /**
  76672. * Creates a new instance of the hit test feature
  76673. * @param _xrSessionManager an instance of WebXRSessionManager
  76674. * @param options options to use when constructing this feature
  76675. */
  76676. constructor(_xrSessionManager: WebXRSessionManager,
  76677. /**
  76678. * options to use when constructing this feature
  76679. */
  76680. options: IWebXRHandTrackingOptions);
  76681. /**
  76682. * Check if the needed objects are defined.
  76683. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76684. */
  76685. isCompatible(): boolean;
  76686. /**
  76687. * attach this feature
  76688. * Will usually be called by the features manager
  76689. *
  76690. * @returns true if successful.
  76691. */
  76692. attach(): boolean;
  76693. /**
  76694. * detach this feature.
  76695. * Will usually be called by the features manager
  76696. *
  76697. * @returns true if successful.
  76698. */
  76699. detach(): boolean;
  76700. /**
  76701. * Dispose this feature and all of the resources attached
  76702. */
  76703. dispose(): void;
  76704. /**
  76705. * Get the hand object according to the controller id
  76706. * @param controllerId the controller id to which we want to get the hand
  76707. * @returns null if not found or the WebXRHand object if found
  76708. */
  76709. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76710. /**
  76711. * Get a hand object according to the requested handedness
  76712. * @param handedness the handedness to request
  76713. * @returns null if not found or the WebXRHand object if found
  76714. */
  76715. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76716. protected _onXRFrame(_xrFrame: XRFrame): void;
  76717. private _attachHand;
  76718. private _detachHand;
  76719. }
  76720. }
  76721. declare module BABYLON {
  76722. /**
  76723. * The motion controller class for all microsoft mixed reality controllers
  76724. */
  76725. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76726. protected readonly _mapping: {
  76727. defaultButton: {
  76728. valueNodeName: string;
  76729. unpressedNodeName: string;
  76730. pressedNodeName: string;
  76731. };
  76732. defaultAxis: {
  76733. valueNodeName: string;
  76734. minNodeName: string;
  76735. maxNodeName: string;
  76736. };
  76737. buttons: {
  76738. "xr-standard-trigger": {
  76739. rootNodeName: string;
  76740. componentProperty: string;
  76741. states: string[];
  76742. };
  76743. "xr-standard-squeeze": {
  76744. rootNodeName: string;
  76745. componentProperty: string;
  76746. states: string[];
  76747. };
  76748. "xr-standard-touchpad": {
  76749. rootNodeName: string;
  76750. labelAnchorNodeName: string;
  76751. touchPointNodeName: string;
  76752. };
  76753. "xr-standard-thumbstick": {
  76754. rootNodeName: string;
  76755. componentProperty: string;
  76756. states: string[];
  76757. };
  76758. };
  76759. axes: {
  76760. "xr-standard-touchpad": {
  76761. "x-axis": {
  76762. rootNodeName: string;
  76763. };
  76764. "y-axis": {
  76765. rootNodeName: string;
  76766. };
  76767. };
  76768. "xr-standard-thumbstick": {
  76769. "x-axis": {
  76770. rootNodeName: string;
  76771. };
  76772. "y-axis": {
  76773. rootNodeName: string;
  76774. };
  76775. };
  76776. };
  76777. };
  76778. /**
  76779. * The base url used to load the left and right controller models
  76780. */
  76781. static MODEL_BASE_URL: string;
  76782. /**
  76783. * The name of the left controller model file
  76784. */
  76785. static MODEL_LEFT_FILENAME: string;
  76786. /**
  76787. * The name of the right controller model file
  76788. */
  76789. static MODEL_RIGHT_FILENAME: string;
  76790. profileId: string;
  76791. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76792. protected _getFilenameAndPath(): {
  76793. filename: string;
  76794. path: string;
  76795. };
  76796. protected _getModelLoadingConstraints(): boolean;
  76797. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76798. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76799. protected _updateModel(): void;
  76800. }
  76801. }
  76802. declare module BABYLON {
  76803. /**
  76804. * The motion controller class for oculus touch (quest, rift).
  76805. * This class supports legacy mapping as well the standard xr mapping
  76806. */
  76807. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76808. private _forceLegacyControllers;
  76809. private _modelRootNode;
  76810. /**
  76811. * The base url used to load the left and right controller models
  76812. */
  76813. static MODEL_BASE_URL: string;
  76814. /**
  76815. * The name of the left controller model file
  76816. */
  76817. static MODEL_LEFT_FILENAME: string;
  76818. /**
  76819. * The name of the right controller model file
  76820. */
  76821. static MODEL_RIGHT_FILENAME: string;
  76822. /**
  76823. * Base Url for the Quest controller model.
  76824. */
  76825. static QUEST_MODEL_BASE_URL: string;
  76826. profileId: string;
  76827. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76828. protected _getFilenameAndPath(): {
  76829. filename: string;
  76830. path: string;
  76831. };
  76832. protected _getModelLoadingConstraints(): boolean;
  76833. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76834. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76835. protected _updateModel(): void;
  76836. /**
  76837. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76838. * between the touch and touch 2.
  76839. */
  76840. private _isQuest;
  76841. }
  76842. }
  76843. declare module BABYLON {
  76844. /**
  76845. * The motion controller class for the standard HTC-Vive controllers
  76846. */
  76847. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76848. private _modelRootNode;
  76849. /**
  76850. * The base url used to load the left and right controller models
  76851. */
  76852. static MODEL_BASE_URL: string;
  76853. /**
  76854. * File name for the controller model.
  76855. */
  76856. static MODEL_FILENAME: string;
  76857. profileId: string;
  76858. /**
  76859. * Create a new Vive motion controller object
  76860. * @param scene the scene to use to create this controller
  76861. * @param gamepadObject the corresponding gamepad object
  76862. * @param handedness the handedness of the controller
  76863. */
  76864. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76865. protected _getFilenameAndPath(): {
  76866. filename: string;
  76867. path: string;
  76868. };
  76869. protected _getModelLoadingConstraints(): boolean;
  76870. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76871. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76872. protected _updateModel(): void;
  76873. }
  76874. }
  76875. declare module BABYLON {
  76876. /**
  76877. * A cursor which tracks a point on a path
  76878. */
  76879. export class PathCursor {
  76880. private path;
  76881. /**
  76882. * Stores path cursor callbacks for when an onchange event is triggered
  76883. */
  76884. private _onchange;
  76885. /**
  76886. * The value of the path cursor
  76887. */
  76888. value: number;
  76889. /**
  76890. * The animation array of the path cursor
  76891. */
  76892. animations: Animation[];
  76893. /**
  76894. * Initializes the path cursor
  76895. * @param path The path to track
  76896. */
  76897. constructor(path: Path2);
  76898. /**
  76899. * Gets the cursor point on the path
  76900. * @returns A point on the path cursor at the cursor location
  76901. */
  76902. getPoint(): Vector3;
  76903. /**
  76904. * Moves the cursor ahead by the step amount
  76905. * @param step The amount to move the cursor forward
  76906. * @returns This path cursor
  76907. */
  76908. moveAhead(step?: number): PathCursor;
  76909. /**
  76910. * Moves the cursor behind by the step amount
  76911. * @param step The amount to move the cursor back
  76912. * @returns This path cursor
  76913. */
  76914. moveBack(step?: number): PathCursor;
  76915. /**
  76916. * Moves the cursor by the step amount
  76917. * If the step amount is greater than one, an exception is thrown
  76918. * @param step The amount to move the cursor
  76919. * @returns This path cursor
  76920. */
  76921. move(step: number): PathCursor;
  76922. /**
  76923. * Ensures that the value is limited between zero and one
  76924. * @returns This path cursor
  76925. */
  76926. private ensureLimits;
  76927. /**
  76928. * Runs onchange callbacks on change (used by the animation engine)
  76929. * @returns This path cursor
  76930. */
  76931. private raiseOnChange;
  76932. /**
  76933. * Executes a function on change
  76934. * @param f A path cursor onchange callback
  76935. * @returns This path cursor
  76936. */
  76937. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76938. }
  76939. }
  76940. declare module BABYLON {
  76941. /** @hidden */
  76942. export var blurPixelShader: {
  76943. name: string;
  76944. shader: string;
  76945. };
  76946. }
  76947. declare module BABYLON {
  76948. /** @hidden */
  76949. export var pointCloudVertexDeclaration: {
  76950. name: string;
  76951. shader: string;
  76952. };
  76953. }
  76954. declare module BABYLON {
  76955. /**
  76956. * ThinSprite Class used to represent a thin sprite
  76957. * This is the base class for sprites but can also directly be used with ThinEngine
  76958. * @see https://doc.babylonjs.com/babylon101/sprites
  76959. */
  76960. export class ThinSprite {
  76961. /** Gets or sets the cell index in the sprite sheet */
  76962. cellIndex: number;
  76963. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  76964. cellRef: string;
  76965. /** Gets or sets the current world position */
  76966. position: IVector3Like;
  76967. /** Gets or sets the main color */
  76968. color: IColor4Like;
  76969. /** Gets or sets the width */
  76970. width: number;
  76971. /** Gets or sets the height */
  76972. height: number;
  76973. /** Gets or sets rotation angle */
  76974. angle: number;
  76975. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  76976. invertU: boolean;
  76977. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  76978. invertV: boolean;
  76979. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  76980. isVisible: boolean;
  76981. /**
  76982. * Returns a boolean indicating if the animation is started
  76983. */
  76984. get animationStarted(): boolean;
  76985. /** Gets the initial key for the animation (setting it will restart the animation) */
  76986. get fromIndex(): number;
  76987. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  76988. get toIndex(): number;
  76989. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  76990. get loopAnimation(): boolean;
  76991. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  76992. get delay(): number;
  76993. /** @hidden */
  76994. _xOffset: number;
  76995. /** @hidden */
  76996. _yOffset: number;
  76997. /** @hidden */
  76998. _xSize: number;
  76999. /** @hidden */
  77000. _ySize: number;
  77001. private _animationStarted;
  77002. private _loopAnimation;
  77003. private _fromIndex;
  77004. private _toIndex;
  77005. private _delay;
  77006. private _direction;
  77007. private _time;
  77008. private _onBaseAnimationEnd;
  77009. /**
  77010. * Creates a new Thin Sprite
  77011. */
  77012. constructor();
  77013. /**
  77014. * Starts an animation
  77015. * @param from defines the initial key
  77016. * @param to defines the end key
  77017. * @param loop defines if the animation must loop
  77018. * @param delay defines the start delay (in ms)
  77019. * @param onAnimationEnd defines a callback for when the animation ends
  77020. */
  77021. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  77022. /** Stops current animation (if any) */
  77023. stopAnimation(): void;
  77024. /** @hidden */
  77025. _animate(deltaTime: number): void;
  77026. }
  77027. }
  77028. declare module BABYLON {
  77029. /**
  77030. * Class used to render sprites.
  77031. *
  77032. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  77033. */
  77034. export class SpriteRenderer {
  77035. /**
  77036. * Defines the texture of the spritesheet
  77037. */
  77038. texture: Nullable<ThinTexture>;
  77039. /**
  77040. * Defines the default width of a cell in the spritesheet
  77041. */
  77042. cellWidth: number;
  77043. /**
  77044. * Defines the default height of a cell in the spritesheet
  77045. */
  77046. cellHeight: number;
  77047. /**
  77048. * Blend mode use to render the particle, it can be any of
  77049. * the static Constants.ALPHA_x properties provided in this class.
  77050. * Default value is Constants.ALPHA_COMBINE
  77051. */
  77052. blendMode: number;
  77053. /**
  77054. * Gets or sets a boolean indicating if alpha mode is automatically
  77055. * reset.
  77056. */
  77057. autoResetAlpha: boolean;
  77058. /**
  77059. * Disables writing to the depth buffer when rendering the sprites.
  77060. * It can be handy to disable depth writing when using textures without alpha channel
  77061. * and setting some specific blend modes.
  77062. */
  77063. disableDepthWrite: boolean;
  77064. /**
  77065. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  77066. */
  77067. fogEnabled: boolean;
  77068. /**
  77069. * Gets the capacity of the manager
  77070. */
  77071. get capacity(): number;
  77072. private readonly _engine;
  77073. private readonly _useVAO;
  77074. private readonly _useInstancing;
  77075. private readonly _scene;
  77076. private readonly _capacity;
  77077. private readonly _epsilon;
  77078. private _vertexBufferSize;
  77079. private _vertexData;
  77080. private _buffer;
  77081. private _vertexBuffers;
  77082. private _spriteBuffer;
  77083. private _indexBuffer;
  77084. private _effectBase;
  77085. private _effectFog;
  77086. private _vertexArrayObject;
  77087. /**
  77088. * Creates a new sprite Renderer
  77089. * @param engine defines the engine the renderer works with
  77090. * @param capacity defines the maximum allowed number of sprites
  77091. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77092. * @param scene defines the hosting scene
  77093. */
  77094. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  77095. /**
  77096. * Render all child sprites
  77097. * @param sprites defines the list of sprites to render
  77098. * @param deltaTime defines the time since last frame
  77099. * @param viewMatrix defines the viewMatrix to use to render the sprites
  77100. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  77101. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  77102. */
  77103. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  77104. private _appendSpriteVertex;
  77105. /**
  77106. * Release associated resources
  77107. */
  77108. dispose(): void;
  77109. }
  77110. }
  77111. // Mixins
  77112. interface Window {
  77113. mozIndexedDB: IDBFactory;
  77114. webkitIndexedDB: IDBFactory;
  77115. msIndexedDB: IDBFactory;
  77116. webkitURL: typeof URL;
  77117. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  77118. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  77119. WebGLRenderingContext: WebGLRenderingContext;
  77120. MSGesture: MSGesture;
  77121. CANNON: any;
  77122. AudioContext: AudioContext;
  77123. webkitAudioContext: AudioContext;
  77124. PointerEvent: any;
  77125. Math: Math;
  77126. Uint8Array: Uint8ArrayConstructor;
  77127. Float32Array: Float32ArrayConstructor;
  77128. mozURL: typeof URL;
  77129. msURL: typeof URL;
  77130. VRFrameData: any; // WebVR, from specs 1.1
  77131. DracoDecoderModule: any;
  77132. setImmediate(handler: (...args: any[]) => void): number;
  77133. }
  77134. interface HTMLCanvasElement {
  77135. requestPointerLock(): void;
  77136. msRequestPointerLock?(): void;
  77137. mozRequestPointerLock?(): void;
  77138. webkitRequestPointerLock?(): void;
  77139. /** Track wether a record is in progress */
  77140. isRecording: boolean;
  77141. /** Capture Stream method defined by some browsers */
  77142. captureStream(fps?: number): MediaStream;
  77143. }
  77144. interface CanvasRenderingContext2D {
  77145. msImageSmoothingEnabled: boolean;
  77146. }
  77147. interface MouseEvent {
  77148. mozMovementX: number;
  77149. mozMovementY: number;
  77150. webkitMovementX: number;
  77151. webkitMovementY: number;
  77152. msMovementX: number;
  77153. msMovementY: number;
  77154. }
  77155. interface Navigator {
  77156. mozGetVRDevices: (any: any) => any;
  77157. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77158. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77159. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77160. webkitGetGamepads(): Gamepad[];
  77161. msGetGamepads(): Gamepad[];
  77162. webkitGamepads(): Gamepad[];
  77163. }
  77164. interface HTMLVideoElement {
  77165. mozSrcObject: any;
  77166. }
  77167. interface Math {
  77168. fround(x: number): number;
  77169. imul(a: number, b: number): number;
  77170. }
  77171. interface WebGLRenderingContext {
  77172. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  77173. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  77174. vertexAttribDivisor(index: number, divisor: number): void;
  77175. createVertexArray(): any;
  77176. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  77177. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  77178. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  77179. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  77180. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  77181. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  77182. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  77183. // Queries
  77184. createQuery(): WebGLQuery;
  77185. deleteQuery(query: WebGLQuery): void;
  77186. beginQuery(target: number, query: WebGLQuery): void;
  77187. endQuery(target: number): void;
  77188. getQueryParameter(query: WebGLQuery, pname: number): any;
  77189. getQuery(target: number, pname: number): any;
  77190. MAX_SAMPLES: number;
  77191. RGBA8: number;
  77192. READ_FRAMEBUFFER: number;
  77193. DRAW_FRAMEBUFFER: number;
  77194. UNIFORM_BUFFER: number;
  77195. HALF_FLOAT_OES: number;
  77196. RGBA16F: number;
  77197. RGBA32F: number;
  77198. R32F: number;
  77199. RG32F: number;
  77200. RGB32F: number;
  77201. R16F: number;
  77202. RG16F: number;
  77203. RGB16F: number;
  77204. RED: number;
  77205. RG: number;
  77206. R8: number;
  77207. RG8: number;
  77208. UNSIGNED_INT_24_8: number;
  77209. DEPTH24_STENCIL8: number;
  77210. MIN: number;
  77211. MAX: number;
  77212. /* Multiple Render Targets */
  77213. drawBuffers(buffers: number[]): void;
  77214. readBuffer(src: number): void;
  77215. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  77216. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  77217. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  77218. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  77219. // Occlusion Query
  77220. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  77221. ANY_SAMPLES_PASSED: number;
  77222. QUERY_RESULT_AVAILABLE: number;
  77223. QUERY_RESULT: number;
  77224. }
  77225. interface WebGLProgram {
  77226. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  77227. }
  77228. interface EXT_disjoint_timer_query {
  77229. QUERY_COUNTER_BITS_EXT: number;
  77230. TIME_ELAPSED_EXT: number;
  77231. TIMESTAMP_EXT: number;
  77232. GPU_DISJOINT_EXT: number;
  77233. QUERY_RESULT_EXT: number;
  77234. QUERY_RESULT_AVAILABLE_EXT: number;
  77235. queryCounterEXT(query: WebGLQuery, target: number): void;
  77236. createQueryEXT(): WebGLQuery;
  77237. beginQueryEXT(target: number, query: WebGLQuery): void;
  77238. endQueryEXT(target: number): void;
  77239. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  77240. deleteQueryEXT(query: WebGLQuery): void;
  77241. }
  77242. interface WebGLUniformLocation {
  77243. _currentState: any;
  77244. }
  77245. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  77246. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  77247. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  77248. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77249. interface WebGLRenderingContext {
  77250. readonly RASTERIZER_DISCARD: number;
  77251. readonly DEPTH_COMPONENT24: number;
  77252. readonly TEXTURE_3D: number;
  77253. readonly TEXTURE_2D_ARRAY: number;
  77254. readonly TEXTURE_COMPARE_FUNC: number;
  77255. readonly TEXTURE_COMPARE_MODE: number;
  77256. readonly COMPARE_REF_TO_TEXTURE: number;
  77257. readonly TEXTURE_WRAP_R: number;
  77258. readonly HALF_FLOAT: number;
  77259. readonly RGB8: number;
  77260. readonly RED_INTEGER: number;
  77261. readonly RG_INTEGER: number;
  77262. readonly RGB_INTEGER: number;
  77263. readonly RGBA_INTEGER: number;
  77264. readonly R8_SNORM: number;
  77265. readonly RG8_SNORM: number;
  77266. readonly RGB8_SNORM: number;
  77267. readonly RGBA8_SNORM: number;
  77268. readonly R8I: number;
  77269. readonly RG8I: number;
  77270. readonly RGB8I: number;
  77271. readonly RGBA8I: number;
  77272. readonly R8UI: number;
  77273. readonly RG8UI: number;
  77274. readonly RGB8UI: number;
  77275. readonly RGBA8UI: number;
  77276. readonly R16I: number;
  77277. readonly RG16I: number;
  77278. readonly RGB16I: number;
  77279. readonly RGBA16I: number;
  77280. readonly R16UI: number;
  77281. readonly RG16UI: number;
  77282. readonly RGB16UI: number;
  77283. readonly RGBA16UI: number;
  77284. readonly R32I: number;
  77285. readonly RG32I: number;
  77286. readonly RGB32I: number;
  77287. readonly RGBA32I: number;
  77288. readonly R32UI: number;
  77289. readonly RG32UI: number;
  77290. readonly RGB32UI: number;
  77291. readonly RGBA32UI: number;
  77292. readonly RGB10_A2UI: number;
  77293. readonly R11F_G11F_B10F: number;
  77294. readonly RGB9_E5: number;
  77295. readonly RGB10_A2: number;
  77296. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77297. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77298. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77299. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77300. readonly DEPTH_COMPONENT32F: number;
  77301. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77302. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77303. 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;
  77304. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77305. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77306. readonly TRANSFORM_FEEDBACK: number;
  77307. readonly INTERLEAVED_ATTRIBS: number;
  77308. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77309. createTransformFeedback(): WebGLTransformFeedback;
  77310. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77311. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77312. beginTransformFeedback(primitiveMode: number): void;
  77313. endTransformFeedback(): void;
  77314. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77315. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77316. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77317. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77318. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77319. }
  77320. interface ImageBitmap {
  77321. readonly width: number;
  77322. readonly height: number;
  77323. close(): void;
  77324. }
  77325. interface WebGLQuery extends WebGLObject {
  77326. }
  77327. declare var WebGLQuery: {
  77328. prototype: WebGLQuery;
  77329. new(): WebGLQuery;
  77330. };
  77331. interface WebGLSampler extends WebGLObject {
  77332. }
  77333. declare var WebGLSampler: {
  77334. prototype: WebGLSampler;
  77335. new(): WebGLSampler;
  77336. };
  77337. interface WebGLSync extends WebGLObject {
  77338. }
  77339. declare var WebGLSync: {
  77340. prototype: WebGLSync;
  77341. new(): WebGLSync;
  77342. };
  77343. interface WebGLTransformFeedback extends WebGLObject {
  77344. }
  77345. declare var WebGLTransformFeedback: {
  77346. prototype: WebGLTransformFeedback;
  77347. new(): WebGLTransformFeedback;
  77348. };
  77349. interface WebGLVertexArrayObject extends WebGLObject {
  77350. }
  77351. declare var WebGLVertexArrayObject: {
  77352. prototype: WebGLVertexArrayObject;
  77353. new(): WebGLVertexArrayObject;
  77354. };
  77355. // Type definitions for WebVR API
  77356. // Project: https://w3c.github.io/webvr/
  77357. // Definitions by: six a <https://github.com/lostfictions>
  77358. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77359. interface VRDisplay extends EventTarget {
  77360. /**
  77361. * Dictionary of capabilities describing the VRDisplay.
  77362. */
  77363. readonly capabilities: VRDisplayCapabilities;
  77364. /**
  77365. * z-depth defining the far plane of the eye view frustum
  77366. * enables mapping of values in the render target depth
  77367. * attachment to scene coordinates. Initially set to 10000.0.
  77368. */
  77369. depthFar: number;
  77370. /**
  77371. * z-depth defining the near plane of the eye view frustum
  77372. * enables mapping of values in the render target depth
  77373. * attachment to scene coordinates. Initially set to 0.01.
  77374. */
  77375. depthNear: number;
  77376. /**
  77377. * An identifier for this distinct VRDisplay. Used as an
  77378. * association point in the Gamepad API.
  77379. */
  77380. readonly displayId: number;
  77381. /**
  77382. * A display name, a user-readable name identifying it.
  77383. */
  77384. readonly displayName: string;
  77385. readonly isConnected: boolean;
  77386. readonly isPresenting: boolean;
  77387. /**
  77388. * If this VRDisplay supports room-scale experiences, the optional
  77389. * stage attribute contains details on the room-scale parameters.
  77390. */
  77391. readonly stageParameters: VRStageParameters | null;
  77392. /**
  77393. * Passing the value returned by `requestAnimationFrame` to
  77394. * `cancelAnimationFrame` will unregister the callback.
  77395. * @param handle Define the hanle of the request to cancel
  77396. */
  77397. cancelAnimationFrame(handle: number): void;
  77398. /**
  77399. * Stops presenting to the VRDisplay.
  77400. * @returns a promise to know when it stopped
  77401. */
  77402. exitPresent(): Promise<void>;
  77403. /**
  77404. * Return the current VREyeParameters for the given eye.
  77405. * @param whichEye Define the eye we want the parameter for
  77406. * @returns the eye parameters
  77407. */
  77408. getEyeParameters(whichEye: string): VREyeParameters;
  77409. /**
  77410. * Populates the passed VRFrameData with the information required to render
  77411. * the current frame.
  77412. * @param frameData Define the data structure to populate
  77413. * @returns true if ok otherwise false
  77414. */
  77415. getFrameData(frameData: VRFrameData): boolean;
  77416. /**
  77417. * Get the layers currently being presented.
  77418. * @returns the list of VR layers
  77419. */
  77420. getLayers(): VRLayer[];
  77421. /**
  77422. * Return a VRPose containing the future predicted pose of the VRDisplay
  77423. * when the current frame will be presented. The value returned will not
  77424. * change until JavaScript has returned control to the browser.
  77425. *
  77426. * The VRPose will contain the position, orientation, velocity,
  77427. * and acceleration of each of these properties.
  77428. * @returns the pose object
  77429. */
  77430. getPose(): VRPose;
  77431. /**
  77432. * Return the current instantaneous pose of the VRDisplay, with no
  77433. * prediction applied.
  77434. * @returns the current instantaneous pose
  77435. */
  77436. getImmediatePose(): VRPose;
  77437. /**
  77438. * The callback passed to `requestAnimationFrame` will be called
  77439. * any time a new frame should be rendered. When the VRDisplay is
  77440. * presenting the callback will be called at the native refresh
  77441. * rate of the HMD. When not presenting this function acts
  77442. * identically to how window.requestAnimationFrame acts. Content should
  77443. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77444. * asynchronously from other displays and at differing refresh rates.
  77445. * @param callback Define the eaction to run next frame
  77446. * @returns the request handle it
  77447. */
  77448. requestAnimationFrame(callback: FrameRequestCallback): number;
  77449. /**
  77450. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77451. * Repeat calls while already presenting will update the VRLayers being displayed.
  77452. * @param layers Define the list of layer to present
  77453. * @returns a promise to know when the request has been fulfilled
  77454. */
  77455. requestPresent(layers: VRLayer[]): Promise<void>;
  77456. /**
  77457. * Reset the pose for this display, treating its current position and
  77458. * orientation as the "origin/zero" values. VRPose.position,
  77459. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77460. * updated when calling resetPose(). This should be called in only
  77461. * sitting-space experiences.
  77462. */
  77463. resetPose(): void;
  77464. /**
  77465. * The VRLayer provided to the VRDisplay will be captured and presented
  77466. * in the HMD. Calling this function has the same effect on the source
  77467. * canvas as any other operation that uses its source image, and canvases
  77468. * created without preserveDrawingBuffer set to true will be cleared.
  77469. * @param pose Define the pose to submit
  77470. */
  77471. submitFrame(pose?: VRPose): void;
  77472. }
  77473. declare var VRDisplay: {
  77474. prototype: VRDisplay;
  77475. new(): VRDisplay;
  77476. };
  77477. interface VRLayer {
  77478. leftBounds?: number[] | Float32Array | null;
  77479. rightBounds?: number[] | Float32Array | null;
  77480. source?: HTMLCanvasElement | null;
  77481. }
  77482. interface VRDisplayCapabilities {
  77483. readonly canPresent: boolean;
  77484. readonly hasExternalDisplay: boolean;
  77485. readonly hasOrientation: boolean;
  77486. readonly hasPosition: boolean;
  77487. readonly maxLayers: number;
  77488. }
  77489. interface VREyeParameters {
  77490. /** @deprecated */
  77491. readonly fieldOfView: VRFieldOfView;
  77492. readonly offset: Float32Array;
  77493. readonly renderHeight: number;
  77494. readonly renderWidth: number;
  77495. }
  77496. interface VRFieldOfView {
  77497. readonly downDegrees: number;
  77498. readonly leftDegrees: number;
  77499. readonly rightDegrees: number;
  77500. readonly upDegrees: number;
  77501. }
  77502. interface VRFrameData {
  77503. readonly leftProjectionMatrix: Float32Array;
  77504. readonly leftViewMatrix: Float32Array;
  77505. readonly pose: VRPose;
  77506. readonly rightProjectionMatrix: Float32Array;
  77507. readonly rightViewMatrix: Float32Array;
  77508. readonly timestamp: number;
  77509. }
  77510. interface VRPose {
  77511. readonly angularAcceleration: Float32Array | null;
  77512. readonly angularVelocity: Float32Array | null;
  77513. readonly linearAcceleration: Float32Array | null;
  77514. readonly linearVelocity: Float32Array | null;
  77515. readonly orientation: Float32Array | null;
  77516. readonly position: Float32Array | null;
  77517. readonly timestamp: number;
  77518. }
  77519. interface VRStageParameters {
  77520. sittingToStandingTransform?: Float32Array;
  77521. sizeX?: number;
  77522. sizeY?: number;
  77523. }
  77524. interface Navigator {
  77525. getVRDisplays(): Promise<VRDisplay[]>;
  77526. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77527. }
  77528. interface Window {
  77529. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77530. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77531. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77532. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77533. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77534. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77535. }
  77536. interface Gamepad {
  77537. readonly displayId: number;
  77538. }
  77539. /**
  77540. * Available session modes
  77541. */
  77542. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77543. /**
  77544. * Reference space types
  77545. */
  77546. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77547. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77548. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77549. /**
  77550. * Handedness types
  77551. */
  77552. type XRHandedness = "none" | "left" | "right";
  77553. /**
  77554. * InputSource target ray modes
  77555. */
  77556. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77557. /**
  77558. * Eye types
  77559. */
  77560. type XREye = "none" | "left" | "right";
  77561. /**
  77562. * Type of XR events available
  77563. */
  77564. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77565. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77566. type XRPlaneSet = Set<XRPlane>;
  77567. type XRAnchorSet = Set<XRAnchor>;
  77568. type XREventHandler = (callback: any) => void;
  77569. interface XRLayer extends EventTarget {}
  77570. interface XRSessionInit {
  77571. optionalFeatures?: string[];
  77572. requiredFeatures?: string[];
  77573. }
  77574. interface XRSessionEvent extends Event {
  77575. readonly session: XRSession;
  77576. }
  77577. interface XRSystem {
  77578. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77579. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77580. }
  77581. interface XRViewport {
  77582. readonly x: number;
  77583. readonly y: number;
  77584. readonly width: number;
  77585. readonly height: number;
  77586. }
  77587. interface XRWebGLLayerInit {
  77588. antialias?: boolean;
  77589. depth?: boolean;
  77590. stencil?: boolean;
  77591. alpha?: boolean;
  77592. multiview?: boolean;
  77593. framebufferScaleFactor?: number;
  77594. }
  77595. declare class XRWebGLLayer {
  77596. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77597. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77598. readonly antialias: boolean;
  77599. readonly framebuffer: WebGLFramebuffer;
  77600. readonly framebufferWidth: number;
  77601. readonly framebufferHeight: number;
  77602. readonly ignoreDepthValues: boolean;
  77603. getViewport: (view: XRView) => XRViewport;
  77604. }
  77605. // tslint:disable-next-line no-empty-interface
  77606. interface XRSpace extends EventTarget {}
  77607. interface XRRenderState {
  77608. readonly baseLayer?: XRWebGLLayer;
  77609. readonly depthFar: number;
  77610. readonly depthNear: number;
  77611. readonly inlineVerticalFieldOfView?: number;
  77612. }
  77613. interface XRRenderStateInit extends XRRenderState {
  77614. baseLayer: XRWebGLLayer;
  77615. depthFar: number;
  77616. depthNear: number;
  77617. inlineVerticalFieldOfView?: number;
  77618. layers?: XRLayer[];
  77619. }
  77620. interface XRReferenceSpace extends XRSpace {
  77621. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77622. onreset: XREventHandler;
  77623. }
  77624. interface XRBoundedReferenceSpace extends XRSpace {
  77625. readonly boundsGeometry: DOMPointReadOnly[];
  77626. }
  77627. interface XRInputSource {
  77628. readonly handedness: XRHandedness;
  77629. readonly targetRayMode: XRTargetRayMode;
  77630. readonly targetRaySpace: XRSpace;
  77631. readonly gripSpace?: XRSpace;
  77632. readonly gamepad?: Gamepad;
  77633. readonly profiles: Array<string>;
  77634. readonly hand?: XRHand;
  77635. }
  77636. interface XRPose {
  77637. readonly transform: XRRigidTransform;
  77638. readonly emulatedPosition: boolean;
  77639. }
  77640. interface XRFrame {
  77641. readonly session: XRSession;
  77642. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77643. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77644. // AR
  77645. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77646. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77647. // Anchors
  77648. trackedAnchors?: XRAnchorSet;
  77649. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77650. // Planes
  77651. worldInformation?: {
  77652. detectedPlanes?: XRPlaneSet;
  77653. };
  77654. // Hand tracking
  77655. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77656. }
  77657. interface XRInputSourceEvent extends Event {
  77658. readonly frame: XRFrame;
  77659. readonly inputSource: XRInputSource;
  77660. }
  77661. type XRInputSourceArray = XRInputSource[];
  77662. interface XRSession {
  77663. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77664. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77665. /**
  77666. * Returns a list of this session's XRInputSources, each representing an input device
  77667. * used to control the camera and/or scene.
  77668. */
  77669. readonly inputSources: Array<XRInputSource>;
  77670. /**
  77671. * object which contains options affecting how the imagery is rendered.
  77672. * This includes things such as the near and far clipping planes
  77673. */
  77674. readonly renderState: XRRenderState;
  77675. readonly visibilityState: XRVisibilityState;
  77676. /**
  77677. * Removes a callback from the animation frame painting callback from
  77678. * XRSession's set of animation frame rendering callbacks, given the
  77679. * identifying handle returned by a previous call to requestAnimationFrame().
  77680. */
  77681. cancelAnimationFrame: (handle: number) => void;
  77682. /**
  77683. * Ends the WebXR session. Returns a promise which resolves when the
  77684. * session has been shut down.
  77685. */
  77686. end(): Promise<void>;
  77687. /**
  77688. * Schedules the specified method to be called the next time the user agent
  77689. * is working on rendering an animation frame for the WebXR device. Returns an
  77690. * integer value which can be used to identify the request for the purposes of
  77691. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77692. * to the Window.requestAnimationFrame() method.
  77693. */
  77694. requestAnimationFrame: XRFrameRequestCallback;
  77695. /**
  77696. * Requests that a new XRReferenceSpace of the specified type be created.
  77697. * Returns a promise which resolves with the XRReferenceSpace or
  77698. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77699. * the requested space type isn't supported by the device.
  77700. */
  77701. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77702. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77703. onend: XREventHandler;
  77704. oninputsourceschange: XREventHandler;
  77705. onselect: XREventHandler;
  77706. onselectstart: XREventHandler;
  77707. onselectend: XREventHandler;
  77708. onsqueeze: XREventHandler;
  77709. onsqueezestart: XREventHandler;
  77710. onsqueezeend: XREventHandler;
  77711. onvisibilitychange: XREventHandler;
  77712. // hit test
  77713. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77714. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77715. // legacy AR hit test
  77716. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77717. // legacy plane detection
  77718. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77719. }
  77720. interface XRViewerPose extends XRPose {
  77721. readonly views: Array<XRView>;
  77722. }
  77723. declare class XRRigidTransform {
  77724. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77725. position: DOMPointReadOnly;
  77726. orientation: DOMPointReadOnly;
  77727. matrix: Float32Array;
  77728. inverse: XRRigidTransform;
  77729. }
  77730. interface XRView {
  77731. readonly eye: XREye;
  77732. readonly projectionMatrix: Float32Array;
  77733. readonly transform: XRRigidTransform;
  77734. readonly recommendedViewportScale?: number;
  77735. requestViewportScale(scale: number): void;
  77736. }
  77737. interface XRInputSourceChangeEvent extends Event {
  77738. session: XRSession;
  77739. removed: Array<XRInputSource>;
  77740. added: Array<XRInputSource>;
  77741. }
  77742. // Experimental/Draft features
  77743. declare class XRRay {
  77744. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77745. origin: DOMPointReadOnly;
  77746. direction: DOMPointReadOnly;
  77747. matrix: Float32Array;
  77748. }
  77749. declare enum XRHitTestTrackableType {
  77750. "point",
  77751. "plane",
  77752. "mesh",
  77753. }
  77754. interface XRHitResult {
  77755. hitMatrix: Float32Array;
  77756. }
  77757. interface XRTransientInputHitTestResult {
  77758. readonly inputSource: XRInputSource;
  77759. readonly results: Array<XRHitTestResult>;
  77760. }
  77761. interface XRHitTestResult {
  77762. getPose(baseSpace: XRSpace): XRPose | undefined;
  77763. // When anchor system is enabled
  77764. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77765. }
  77766. interface XRHitTestSource {
  77767. cancel(): void;
  77768. }
  77769. interface XRTransientInputHitTestSource {
  77770. cancel(): void;
  77771. }
  77772. interface XRHitTestOptionsInit {
  77773. space: XRSpace;
  77774. entityTypes?: Array<XRHitTestTrackableType>;
  77775. offsetRay?: XRRay;
  77776. }
  77777. interface XRTransientInputHitTestOptionsInit {
  77778. profile: string;
  77779. entityTypes?: Array<XRHitTestTrackableType>;
  77780. offsetRay?: XRRay;
  77781. }
  77782. interface XRAnchor {
  77783. anchorSpace: XRSpace;
  77784. delete(): void;
  77785. }
  77786. interface XRPlane {
  77787. orientation: "Horizontal" | "Vertical";
  77788. planeSpace: XRSpace;
  77789. polygon: Array<DOMPointReadOnly>;
  77790. lastChangedTime: number;
  77791. }
  77792. interface XRJointSpace extends XRSpace {}
  77793. interface XRJointPose extends XRPose {
  77794. radius: number | undefined;
  77795. }
  77796. interface XRHand extends Iterable<XRJointSpace> {
  77797. readonly length: number;
  77798. [index: number]: XRJointSpace;
  77799. readonly WRIST: number;
  77800. readonly THUMB_METACARPAL: number;
  77801. readonly THUMB_PHALANX_PROXIMAL: number;
  77802. readonly THUMB_PHALANX_DISTAL: number;
  77803. readonly THUMB_PHALANX_TIP: number;
  77804. readonly INDEX_METACARPAL: number;
  77805. readonly INDEX_PHALANX_PROXIMAL: number;
  77806. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77807. readonly INDEX_PHALANX_DISTAL: number;
  77808. readonly INDEX_PHALANX_TIP: number;
  77809. readonly MIDDLE_METACARPAL: number;
  77810. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77811. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77812. readonly MIDDLE_PHALANX_DISTAL: number;
  77813. readonly MIDDLE_PHALANX_TIP: number;
  77814. readonly RING_METACARPAL: number;
  77815. readonly RING_PHALANX_PROXIMAL: number;
  77816. readonly RING_PHALANX_INTERMEDIATE: number;
  77817. readonly RING_PHALANX_DISTAL: number;
  77818. readonly RING_PHALANX_TIP: number;
  77819. readonly LITTLE_METACARPAL: number;
  77820. readonly LITTLE_PHALANX_PROXIMAL: number;
  77821. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77822. readonly LITTLE_PHALANX_DISTAL: number;
  77823. readonly LITTLE_PHALANX_TIP: number;
  77824. }
  77825. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77826. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77827. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77828. interface XRSession {
  77829. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77830. }
  77831. interface XRFrame {
  77832. featurePointCloud? : Array<number>;
  77833. }
  77834. /**
  77835. * @ignore
  77836. */
  77837. declare module BABYLON.GLTF2.Exporter {
  77838. }
  77839. /**
  77840. * @ignore
  77841. */
  77842. declare module BABYLON.GLTF1 {
  77843. }
  77844. declare module BABYLON.GUI {
  77845. /**
  77846. * Class used to specific a value and its associated unit
  77847. */
  77848. export class ValueAndUnit {
  77849. /** defines the unit to store */
  77850. unit: number;
  77851. /** defines a boolean indicating if the value can be negative */
  77852. negativeValueAllowed: boolean;
  77853. private _value;
  77854. private _originalUnit;
  77855. /**
  77856. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77857. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77858. */
  77859. ignoreAdaptiveScaling: boolean;
  77860. /**
  77861. * Creates a new ValueAndUnit
  77862. * @param value defines the value to store
  77863. * @param unit defines the unit to store
  77864. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77865. */
  77866. constructor(value: number,
  77867. /** defines the unit to store */
  77868. unit?: number,
  77869. /** defines a boolean indicating if the value can be negative */
  77870. negativeValueAllowed?: boolean);
  77871. /** Gets a boolean indicating if the value is a percentage */
  77872. get isPercentage(): boolean;
  77873. /** Gets a boolean indicating if the value is store as pixel */
  77874. get isPixel(): boolean;
  77875. /** Gets direct internal value */
  77876. get internalValue(): number;
  77877. /**
  77878. * Gets value as pixel
  77879. * @param host defines the root host
  77880. * @param refValue defines the reference value for percentages
  77881. * @returns the value as pixel
  77882. */
  77883. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77884. /**
  77885. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77886. * @param value defines the value to store
  77887. * @param unit defines the unit to store
  77888. * @returns the current ValueAndUnit
  77889. */
  77890. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77891. /**
  77892. * Gets the value accordingly to its unit
  77893. * @param host defines the root host
  77894. * @returns the value
  77895. */
  77896. getValue(host: AdvancedDynamicTexture): number;
  77897. /**
  77898. * Gets a string representation of the value
  77899. * @param host defines the root host
  77900. * @param decimals defines an optional number of decimals to display
  77901. * @returns a string
  77902. */
  77903. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77904. /**
  77905. * Store a value parsed from a string
  77906. * @param source defines the source string
  77907. * @returns true if the value was successfully parsed
  77908. */
  77909. fromString(source: string | number): boolean;
  77910. private static _Regex;
  77911. private static _UNITMODE_PERCENTAGE;
  77912. private static _UNITMODE_PIXEL;
  77913. /** UNITMODE_PERCENTAGE */
  77914. static get UNITMODE_PERCENTAGE(): number;
  77915. /** UNITMODE_PIXEL */
  77916. static get UNITMODE_PIXEL(): number;
  77917. }
  77918. }
  77919. declare module BABYLON.GUI {
  77920. /**
  77921. * Define a style used by control to automatically setup properties based on a template.
  77922. * Only support font related properties so far
  77923. */
  77924. export class Style implements BABYLON.IDisposable {
  77925. private _fontFamily;
  77926. private _fontStyle;
  77927. private _fontWeight;
  77928. /** @hidden */
  77929. _host: AdvancedDynamicTexture;
  77930. /** @hidden */
  77931. _fontSize: ValueAndUnit;
  77932. /**
  77933. * BABYLON.Observable raised when the style values are changed
  77934. */
  77935. onChangedObservable: BABYLON.Observable<Style>;
  77936. /**
  77937. * Creates a new style object
  77938. * @param host defines the AdvancedDynamicTexture which hosts this style
  77939. */
  77940. constructor(host: AdvancedDynamicTexture);
  77941. /**
  77942. * Gets or sets the font size
  77943. */
  77944. get fontSize(): string | number;
  77945. set fontSize(value: string | number);
  77946. /**
  77947. * Gets or sets the font family
  77948. */
  77949. get fontFamily(): string;
  77950. set fontFamily(value: string);
  77951. /**
  77952. * Gets or sets the font style
  77953. */
  77954. get fontStyle(): string;
  77955. set fontStyle(value: string);
  77956. /** Gets or sets font weight */
  77957. get fontWeight(): string;
  77958. set fontWeight(value: string);
  77959. /** Dispose all associated resources */
  77960. dispose(): void;
  77961. }
  77962. }
  77963. declare module BABYLON.GUI {
  77964. /**
  77965. * Class used to transport BABYLON.Vector2 information for pointer events
  77966. */
  77967. export class Vector2WithInfo extends BABYLON.Vector2 {
  77968. /** defines the current mouse button index */
  77969. buttonIndex: number;
  77970. /**
  77971. * Creates a new Vector2WithInfo
  77972. * @param source defines the vector2 data to transport
  77973. * @param buttonIndex defines the current mouse button index
  77974. */
  77975. constructor(source: BABYLON.Vector2,
  77976. /** defines the current mouse button index */
  77977. buttonIndex?: number);
  77978. }
  77979. /** Class used to provide 2D matrix features */
  77980. export class Matrix2D {
  77981. /** Gets the internal array of 6 floats used to store matrix data */
  77982. m: Float32Array;
  77983. /**
  77984. * Creates a new matrix
  77985. * @param m00 defines value for (0, 0)
  77986. * @param m01 defines value for (0, 1)
  77987. * @param m10 defines value for (1, 0)
  77988. * @param m11 defines value for (1, 1)
  77989. * @param m20 defines value for (2, 0)
  77990. * @param m21 defines value for (2, 1)
  77991. */
  77992. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77993. /**
  77994. * Fills the matrix from direct values
  77995. * @param m00 defines value for (0, 0)
  77996. * @param m01 defines value for (0, 1)
  77997. * @param m10 defines value for (1, 0)
  77998. * @param m11 defines value for (1, 1)
  77999. * @param m20 defines value for (2, 0)
  78000. * @param m21 defines value for (2, 1)
  78001. * @returns the current modified matrix
  78002. */
  78003. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  78004. /**
  78005. * Gets matrix determinant
  78006. * @returns the determinant
  78007. */
  78008. determinant(): number;
  78009. /**
  78010. * Inverses the matrix and stores it in a target matrix
  78011. * @param result defines the target matrix
  78012. * @returns the current matrix
  78013. */
  78014. invertToRef(result: Matrix2D): Matrix2D;
  78015. /**
  78016. * Multiplies the current matrix with another one
  78017. * @param other defines the second operand
  78018. * @param result defines the target matrix
  78019. * @returns the current matrix
  78020. */
  78021. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  78022. /**
  78023. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  78024. * @param x defines the x coordinate to transform
  78025. * @param y defines the x coordinate to transform
  78026. * @param result defines the target vector2
  78027. * @returns the current matrix
  78028. */
  78029. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  78030. /**
  78031. * Creates an identity matrix
  78032. * @returns a new matrix
  78033. */
  78034. static Identity(): Matrix2D;
  78035. /**
  78036. * Creates a translation matrix and stores it in a target matrix
  78037. * @param x defines the x coordinate of the translation
  78038. * @param y defines the y coordinate of the translation
  78039. * @param result defines the target matrix
  78040. */
  78041. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  78042. /**
  78043. * Creates a scaling matrix and stores it in a target matrix
  78044. * @param x defines the x coordinate of the scaling
  78045. * @param y defines the y coordinate of the scaling
  78046. * @param result defines the target matrix
  78047. */
  78048. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  78049. /**
  78050. * Creates a rotation matrix and stores it in a target matrix
  78051. * @param angle defines the rotation angle
  78052. * @param result defines the target matrix
  78053. */
  78054. static RotationToRef(angle: number, result: Matrix2D): void;
  78055. private static _TempPreTranslationMatrix;
  78056. private static _TempPostTranslationMatrix;
  78057. private static _TempRotationMatrix;
  78058. private static _TempScalingMatrix;
  78059. private static _TempCompose0;
  78060. private static _TempCompose1;
  78061. private static _TempCompose2;
  78062. /**
  78063. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  78064. * @param tx defines the x coordinate of the translation
  78065. * @param ty defines the y coordinate of the translation
  78066. * @param angle defines the rotation angle
  78067. * @param scaleX defines the x coordinate of the scaling
  78068. * @param scaleY defines the y coordinate of the scaling
  78069. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  78070. * @param result defines the target matrix
  78071. */
  78072. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  78073. }
  78074. }
  78075. declare module BABYLON.GUI {
  78076. /**
  78077. * Class used to store 2D control sizes
  78078. */
  78079. export class Measure {
  78080. /** defines left coordinate */
  78081. left: number;
  78082. /** defines top coordinate */
  78083. top: number;
  78084. /** defines width dimension */
  78085. width: number;
  78086. /** defines height dimension */
  78087. height: number;
  78088. /**
  78089. * Creates a new measure
  78090. * @param left defines left coordinate
  78091. * @param top defines top coordinate
  78092. * @param width defines width dimension
  78093. * @param height defines height dimension
  78094. */
  78095. constructor(
  78096. /** defines left coordinate */
  78097. left: number,
  78098. /** defines top coordinate */
  78099. top: number,
  78100. /** defines width dimension */
  78101. width: number,
  78102. /** defines height dimension */
  78103. height: number);
  78104. /**
  78105. * Copy from another measure
  78106. * @param other defines the other measure to copy from
  78107. */
  78108. copyFrom(other: Measure): void;
  78109. /**
  78110. * Copy from a group of 4 floats
  78111. * @param left defines left coordinate
  78112. * @param top defines top coordinate
  78113. * @param width defines width dimension
  78114. * @param height defines height dimension
  78115. */
  78116. copyFromFloats(left: number, top: number, width: number, height: number): void;
  78117. /**
  78118. * Computes the axis aligned bounding box measure for two given measures
  78119. * @param a Input measure
  78120. * @param b Input measure
  78121. * @param result the resulting bounding measure
  78122. */
  78123. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  78124. /**
  78125. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78126. * @param transform the matrix to transform the measure before computing the AABB
  78127. * @param addX number to add to left
  78128. * @param addY number to add to top
  78129. * @param addWidth number to add to width
  78130. * @param addHeight number to add to height
  78131. * @param result the resulting AABB
  78132. */
  78133. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  78134. /**
  78135. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78136. * @param transform the matrix to transform the measure before computing the AABB
  78137. * @param result the resulting AABB
  78138. */
  78139. transformToRef(transform: Matrix2D, result: Measure): void;
  78140. /**
  78141. * Check equality between this measure and another one
  78142. * @param other defines the other measures
  78143. * @returns true if both measures are equals
  78144. */
  78145. isEqualsTo(other: Measure): boolean;
  78146. /**
  78147. * Creates an empty measure
  78148. * @returns a new measure
  78149. */
  78150. static Empty(): Measure;
  78151. }
  78152. }
  78153. declare module BABYLON.GUI {
  78154. /**
  78155. * Interface used to define a control that can receive focus
  78156. */
  78157. export interface IFocusableControl {
  78158. /**
  78159. * Function called when the control receives the focus
  78160. */
  78161. onFocus(): void;
  78162. /**
  78163. * Function called when the control loses the focus
  78164. */
  78165. onBlur(): void;
  78166. /**
  78167. * Function called to let the control handle keyboard events
  78168. * @param evt defines the current keyboard event
  78169. */
  78170. processKeyboard(evt: KeyboardEvent): void;
  78171. /**
  78172. * Function called to get the list of controls that should not steal the focus from this control
  78173. * @returns an array of controls
  78174. */
  78175. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78176. }
  78177. /**
  78178. * Class used to create texture to support 2D GUI elements
  78179. * @see https://doc.babylonjs.com/how_to/gui
  78180. */
  78181. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  78182. private _isDirty;
  78183. private _renderObserver;
  78184. private _resizeObserver;
  78185. private _preKeyboardObserver;
  78186. private _pointerMoveObserver;
  78187. private _pointerObserver;
  78188. private _canvasPointerOutObserver;
  78189. private _canvasBlurObserver;
  78190. private _background;
  78191. /** @hidden */
  78192. _rootContainer: Container;
  78193. /** @hidden */
  78194. _lastPickedControl: Control;
  78195. /** @hidden */
  78196. _lastControlOver: {
  78197. [pointerId: number]: Control;
  78198. };
  78199. /** @hidden */
  78200. _lastControlDown: {
  78201. [pointerId: number]: Control;
  78202. };
  78203. /** @hidden */
  78204. _capturingControl: {
  78205. [pointerId: number]: Control;
  78206. };
  78207. /** @hidden */
  78208. _shouldBlockPointer: boolean;
  78209. /** @hidden */
  78210. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  78211. /** @hidden */
  78212. _linkedControls: Control[];
  78213. private _isFullscreen;
  78214. private _fullscreenViewport;
  78215. private _idealWidth;
  78216. private _idealHeight;
  78217. private _useSmallestIdeal;
  78218. private _renderAtIdealSize;
  78219. private _focusedControl;
  78220. private _blockNextFocusCheck;
  78221. private _renderScale;
  78222. private _rootElement;
  78223. private _cursorChanged;
  78224. private _defaultMousePointerId;
  78225. /** @hidden */
  78226. _numLayoutCalls: number;
  78227. /** Gets the number of layout calls made the last time the ADT has been rendered */
  78228. get numLayoutCalls(): number;
  78229. /** @hidden */
  78230. _numRenderCalls: number;
  78231. /** Gets the number of render calls made the last time the ADT has been rendered */
  78232. get numRenderCalls(): number;
  78233. /**
  78234. * Define type to string to ensure compatibility across browsers
  78235. * Safari doesn't support DataTransfer constructor
  78236. */
  78237. private _clipboardData;
  78238. /**
  78239. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  78240. */
  78241. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  78242. /**
  78243. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  78244. */
  78245. onControlPickedObservable: BABYLON.Observable<Control>;
  78246. /**
  78247. * BABYLON.Observable event triggered before layout is evaluated
  78248. */
  78249. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78250. /**
  78251. * BABYLON.Observable event triggered after the layout was evaluated
  78252. */
  78253. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78254. /**
  78255. * BABYLON.Observable event triggered before the texture is rendered
  78256. */
  78257. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78258. /**
  78259. * BABYLON.Observable event triggered after the texture was rendered
  78260. */
  78261. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78262. /**
  78263. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78264. */
  78265. premulAlpha: boolean;
  78266. /**
  78267. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78268. * Useful when you want more antialiasing
  78269. */
  78270. get renderScale(): number;
  78271. set renderScale(value: number);
  78272. /** Gets or sets the background color */
  78273. get background(): string;
  78274. set background(value: string);
  78275. /**
  78276. * Gets or sets the ideal width used to design controls.
  78277. * The GUI will then rescale everything accordingly
  78278. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78279. */
  78280. get idealWidth(): number;
  78281. set idealWidth(value: number);
  78282. /**
  78283. * Gets or sets the ideal height used to design controls.
  78284. * The GUI will then rescale everything accordingly
  78285. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78286. */
  78287. get idealHeight(): number;
  78288. set idealHeight(value: number);
  78289. /**
  78290. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78291. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78292. */
  78293. get useSmallestIdeal(): boolean;
  78294. set useSmallestIdeal(value: boolean);
  78295. /**
  78296. * Gets or sets a boolean indicating if adaptive scaling must be used
  78297. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78298. */
  78299. get renderAtIdealSize(): boolean;
  78300. set renderAtIdealSize(value: boolean);
  78301. /**
  78302. * Gets the ratio used when in "ideal mode"
  78303. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78304. * */
  78305. get idealRatio(): number;
  78306. /**
  78307. * Gets the underlying layer used to render the texture when in fullscreen mode
  78308. */
  78309. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78310. /**
  78311. * Gets the root container control
  78312. */
  78313. get rootContainer(): Container;
  78314. /**
  78315. * Returns an array containing the root container.
  78316. * This is mostly used to let the Inspector introspects the ADT
  78317. * @returns an array containing the rootContainer
  78318. */
  78319. getChildren(): Array<Container>;
  78320. /**
  78321. * Will return all controls that are inside this texture
  78322. * @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
  78323. * @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
  78324. * @return all child controls
  78325. */
  78326. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78327. /**
  78328. * Gets or sets the current focused control
  78329. */
  78330. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78331. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78332. /**
  78333. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78334. */
  78335. get isForeground(): boolean;
  78336. set isForeground(value: boolean);
  78337. /**
  78338. * Gets or set information about clipboardData
  78339. */
  78340. get clipboardData(): string;
  78341. set clipboardData(value: string);
  78342. /**
  78343. * Creates a new AdvancedDynamicTexture
  78344. * @param name defines the name of the texture
  78345. * @param width defines the width of the texture
  78346. * @param height defines the height of the texture
  78347. * @param scene defines the hosting scene
  78348. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78349. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78350. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78351. */
  78352. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78353. /**
  78354. * Get the current class name of the texture useful for serialization or dynamic coding.
  78355. * @returns "AdvancedDynamicTexture"
  78356. */
  78357. getClassName(): string;
  78358. /**
  78359. * Function used to execute a function on all controls
  78360. * @param func defines the function to execute
  78361. * @param container defines the container where controls belong. If null the root container will be used
  78362. */
  78363. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78364. private _useInvalidateRectOptimization;
  78365. /**
  78366. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78367. */
  78368. get useInvalidateRectOptimization(): boolean;
  78369. set useInvalidateRectOptimization(value: boolean);
  78370. private _invalidatedRectangle;
  78371. /**
  78372. * Invalidates a rectangle area on the gui texture
  78373. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78374. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78375. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78376. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78377. */
  78378. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78379. /**
  78380. * Marks the texture as dirty forcing a complete update
  78381. */
  78382. markAsDirty(): void;
  78383. /**
  78384. * Helper function used to create a new style
  78385. * @returns a new style
  78386. * @see https://doc.babylonjs.com/how_to/gui#styles
  78387. */
  78388. createStyle(): Style;
  78389. /**
  78390. * Adds a new control to the root container
  78391. * @param control defines the control to add
  78392. * @returns the current texture
  78393. */
  78394. addControl(control: Control): AdvancedDynamicTexture;
  78395. /**
  78396. * Removes a control from the root container
  78397. * @param control defines the control to remove
  78398. * @returns the current texture
  78399. */
  78400. removeControl(control: Control): AdvancedDynamicTexture;
  78401. /**
  78402. * Release all resources
  78403. */
  78404. dispose(): void;
  78405. private _onResize;
  78406. /** @hidden */
  78407. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78408. /**
  78409. * Get screen coordinates for a vector3
  78410. * @param position defines the position to project
  78411. * @param worldMatrix defines the world matrix to use
  78412. * @returns the projected position
  78413. */
  78414. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78415. /**
  78416. * Get screen coordinates for a vector3
  78417. * @param position defines the position to project
  78418. * @param worldMatrix defines the world matrix to use
  78419. * @returns the projected position with Z
  78420. */
  78421. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  78422. private _checkUpdate;
  78423. private _clearMeasure;
  78424. private _render;
  78425. /** @hidden */
  78426. _changeCursor(cursor: string): void;
  78427. /** @hidden */
  78428. _registerLastControlDown(control: Control, pointerId: number): void;
  78429. private _doPicking;
  78430. /** @hidden */
  78431. _cleanControlAfterRemovalFromList(list: {
  78432. [pointerId: number]: Control;
  78433. }, control: Control): void;
  78434. /** @hidden */
  78435. _cleanControlAfterRemoval(control: Control): void;
  78436. /** Attach to all scene events required to support pointer events */
  78437. attach(): void;
  78438. /** @hidden */
  78439. private onClipboardCopy;
  78440. /** @hidden */
  78441. private onClipboardCut;
  78442. /** @hidden */
  78443. private onClipboardPaste;
  78444. /**
  78445. * Register the clipboard Events onto the canvas
  78446. */
  78447. registerClipboardEvents(): void;
  78448. /**
  78449. * Unregister the clipboard Events from the canvas
  78450. */
  78451. unRegisterClipboardEvents(): void;
  78452. /**
  78453. * Connect the texture to a hosting mesh to enable interactions
  78454. * @param mesh defines the mesh to attach to
  78455. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78456. */
  78457. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78458. /**
  78459. * Move the focus to a specific control
  78460. * @param control defines the control which will receive the focus
  78461. */
  78462. moveFocusToControl(control: IFocusableControl): void;
  78463. private _manageFocus;
  78464. private _attachToOnPointerOut;
  78465. private _attachToOnBlur;
  78466. /**
  78467. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78468. * @param mesh defines the mesh which will receive the texture
  78469. * @param width defines the texture width (1024 by default)
  78470. * @param height defines the texture height (1024 by default)
  78471. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78472. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78473. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78474. * @returns a new AdvancedDynamicTexture
  78475. */
  78476. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78477. /**
  78478. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78479. * In this mode the texture will rely on a layer for its rendering.
  78480. * This allows it to be treated like any other layer.
  78481. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78482. * LayerMask is set through advancedTexture.layer.layerMask
  78483. * @param name defines name for the texture
  78484. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78485. * @param scene defines the hsoting scene
  78486. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78487. * @returns a new AdvancedDynamicTexture
  78488. */
  78489. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78490. }
  78491. }
  78492. declare module BABYLON.GUI {
  78493. /**
  78494. * Root class used for all 2D controls
  78495. * @see https://doc.babylonjs.com/how_to/gui#controls
  78496. */
  78497. export class Control {
  78498. /** defines the name of the control */
  78499. name?: string | undefined;
  78500. /**
  78501. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78502. */
  78503. static AllowAlphaInheritance: boolean;
  78504. private _alpha;
  78505. private _alphaSet;
  78506. private _zIndex;
  78507. /** @hidden */
  78508. _host: AdvancedDynamicTexture;
  78509. /** Gets or sets the control parent */
  78510. parent: BABYLON.Nullable<Container>;
  78511. /** @hidden */
  78512. _currentMeasure: Measure;
  78513. private _fontFamily;
  78514. private _fontStyle;
  78515. private _fontWeight;
  78516. private _fontSize;
  78517. private _font;
  78518. /** @hidden */
  78519. _width: ValueAndUnit;
  78520. /** @hidden */
  78521. _height: ValueAndUnit;
  78522. /** @hidden */
  78523. protected _fontOffset: {
  78524. ascent: number;
  78525. height: number;
  78526. descent: number;
  78527. };
  78528. private _color;
  78529. private _style;
  78530. private _styleObserver;
  78531. /** @hidden */
  78532. protected _horizontalAlignment: number;
  78533. /** @hidden */
  78534. protected _verticalAlignment: number;
  78535. /** @hidden */
  78536. protected _isDirty: boolean;
  78537. /** @hidden */
  78538. protected _wasDirty: boolean;
  78539. /** @hidden */
  78540. _tempParentMeasure: Measure;
  78541. /** @hidden */
  78542. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78543. /** @hidden */
  78544. protected _cachedParentMeasure: Measure;
  78545. private _paddingLeft;
  78546. private _paddingRight;
  78547. private _paddingTop;
  78548. private _paddingBottom;
  78549. /** @hidden */
  78550. _left: ValueAndUnit;
  78551. /** @hidden */
  78552. _top: ValueAndUnit;
  78553. private _scaleX;
  78554. private _scaleY;
  78555. private _rotation;
  78556. private _transformCenterX;
  78557. private _transformCenterY;
  78558. /** @hidden */
  78559. _transformMatrix: Matrix2D;
  78560. /** @hidden */
  78561. protected _invertTransformMatrix: Matrix2D;
  78562. /** @hidden */
  78563. protected _transformedPosition: BABYLON.Vector2;
  78564. private _isMatrixDirty;
  78565. private _cachedOffsetX;
  78566. private _cachedOffsetY;
  78567. private _isVisible;
  78568. private _isHighlighted;
  78569. /** @hidden */
  78570. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78571. private _fontSet;
  78572. private _dummyVector2;
  78573. private _downCount;
  78574. private _enterCount;
  78575. private _doNotRender;
  78576. private _downPointerIds;
  78577. protected _isEnabled: boolean;
  78578. protected _disabledColor: string;
  78579. protected _disabledColorItem: string;
  78580. /** @hidden */
  78581. protected _rebuildLayout: boolean;
  78582. /** @hidden */
  78583. _customData: any;
  78584. /** @hidden */
  78585. _isClipped: boolean;
  78586. /** @hidden */
  78587. _automaticSize: boolean;
  78588. /** @hidden */
  78589. _tag: any;
  78590. /**
  78591. * 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
  78592. */
  78593. uniqueId: number;
  78594. /**
  78595. * Gets or sets an object used to store user defined information for the node
  78596. */
  78597. metadata: any;
  78598. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78599. isHitTestVisible: boolean;
  78600. /** Gets or sets a boolean indicating if the control can block pointer events */
  78601. isPointerBlocker: boolean;
  78602. /** Gets or sets a boolean indicating if the control can be focusable */
  78603. isFocusInvisible: boolean;
  78604. /**
  78605. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78606. * 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
  78607. */
  78608. clipChildren: boolean;
  78609. /**
  78610. * Gets or sets a boolean indicating that control content must be clipped
  78611. * 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
  78612. */
  78613. clipContent: boolean;
  78614. /**
  78615. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78616. */
  78617. useBitmapCache: boolean;
  78618. private _cacheData;
  78619. private _shadowOffsetX;
  78620. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78621. get shadowOffsetX(): number;
  78622. set shadowOffsetX(value: number);
  78623. private _shadowOffsetY;
  78624. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78625. get shadowOffsetY(): number;
  78626. set shadowOffsetY(value: number);
  78627. private _shadowBlur;
  78628. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78629. get shadowBlur(): number;
  78630. set shadowBlur(value: number);
  78631. private _shadowColor;
  78632. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78633. get shadowColor(): string;
  78634. set shadowColor(value: string);
  78635. /** Gets or sets the cursor to use when the control is hovered */
  78636. hoverCursor: string;
  78637. /** @hidden */
  78638. protected _linkOffsetX: ValueAndUnit;
  78639. /** @hidden */
  78640. protected _linkOffsetY: ValueAndUnit;
  78641. /** Gets the control type name */
  78642. get typeName(): string;
  78643. /**
  78644. * Get the current class name of the control.
  78645. * @returns current class name
  78646. */
  78647. getClassName(): string;
  78648. /**
  78649. * An event triggered when pointer wheel is scrolled
  78650. */
  78651. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78652. /**
  78653. * An event triggered when the pointer move over the control.
  78654. */
  78655. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78656. /**
  78657. * An event triggered when the pointer move out of the control.
  78658. */
  78659. onPointerOutObservable: BABYLON.Observable<Control>;
  78660. /**
  78661. * An event triggered when the pointer taps the control
  78662. */
  78663. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78664. /**
  78665. * An event triggered when pointer up
  78666. */
  78667. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78668. /**
  78669. * An event triggered when a control is clicked on
  78670. */
  78671. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78672. /**
  78673. * An event triggered when pointer enters the control
  78674. */
  78675. onPointerEnterObservable: BABYLON.Observable<Control>;
  78676. /**
  78677. * An event triggered when the control is marked as dirty
  78678. */
  78679. onDirtyObservable: BABYLON.Observable<Control>;
  78680. /**
  78681. * An event triggered before drawing the control
  78682. */
  78683. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78684. /**
  78685. * An event triggered after the control was drawn
  78686. */
  78687. onAfterDrawObservable: BABYLON.Observable<Control>;
  78688. /**
  78689. * An event triggered when the control has been disposed
  78690. */
  78691. onDisposeObservable: BABYLON.Observable<Control>;
  78692. /**
  78693. * Get the hosting AdvancedDynamicTexture
  78694. */
  78695. get host(): AdvancedDynamicTexture;
  78696. /** Gets or set information about font offsets (used to render and align text) */
  78697. get fontOffset(): {
  78698. ascent: number;
  78699. height: number;
  78700. descent: number;
  78701. };
  78702. set fontOffset(offset: {
  78703. ascent: number;
  78704. height: number;
  78705. descent: number;
  78706. });
  78707. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78708. get alpha(): number;
  78709. set alpha(value: number);
  78710. /**
  78711. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78712. */
  78713. get isHighlighted(): boolean;
  78714. set isHighlighted(value: boolean);
  78715. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78716. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78717. */
  78718. get scaleX(): number;
  78719. set scaleX(value: number);
  78720. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78721. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78722. */
  78723. get scaleY(): number;
  78724. set scaleY(value: number);
  78725. /** Gets or sets the rotation angle (0 by default)
  78726. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78727. */
  78728. get rotation(): number;
  78729. set rotation(value: number);
  78730. /** Gets or sets the transformation center on Y axis (0 by default)
  78731. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78732. */
  78733. get transformCenterY(): number;
  78734. set transformCenterY(value: number);
  78735. /** Gets or sets the transformation center on X axis (0 by default)
  78736. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78737. */
  78738. get transformCenterX(): number;
  78739. set transformCenterX(value: number);
  78740. /**
  78741. * Gets or sets the horizontal alignment
  78742. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78743. */
  78744. get horizontalAlignment(): number;
  78745. set horizontalAlignment(value: number);
  78746. /**
  78747. * Gets or sets the vertical alignment
  78748. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78749. */
  78750. get verticalAlignment(): number;
  78751. set verticalAlignment(value: number);
  78752. /**
  78753. * Gets or sets a fixed ratio for this control.
  78754. * When different from 0, the ratio is used to compute the "second" dimension.
  78755. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78756. * second dimension is computed as first dimension * fixedRatio
  78757. */
  78758. fixedRatio: number;
  78759. private _fixedRatioMasterIsWidth;
  78760. /**
  78761. * Gets or sets control width
  78762. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78763. */
  78764. get width(): string | number;
  78765. set width(value: string | number);
  78766. /**
  78767. * Gets or sets the control width in pixel
  78768. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78769. */
  78770. get widthInPixels(): number;
  78771. set widthInPixels(value: number);
  78772. /**
  78773. * Gets or sets control height
  78774. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78775. */
  78776. get height(): string | number;
  78777. set height(value: string | number);
  78778. /**
  78779. * Gets or sets control height in pixel
  78780. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78781. */
  78782. get heightInPixels(): number;
  78783. set heightInPixels(value: number);
  78784. /** Gets or set font family */
  78785. get fontFamily(): string;
  78786. set fontFamily(value: string);
  78787. /** Gets or sets font style */
  78788. get fontStyle(): string;
  78789. set fontStyle(value: string);
  78790. /** Gets or sets font weight */
  78791. get fontWeight(): string;
  78792. set fontWeight(value: string);
  78793. /**
  78794. * Gets or sets style
  78795. * @see https://doc.babylonjs.com/how_to/gui#styles
  78796. */
  78797. get style(): BABYLON.Nullable<Style>;
  78798. set style(value: BABYLON.Nullable<Style>);
  78799. /** @hidden */
  78800. get _isFontSizeInPercentage(): boolean;
  78801. /** Gets or sets font size in pixels */
  78802. get fontSizeInPixels(): number;
  78803. set fontSizeInPixels(value: number);
  78804. /** Gets or sets font size */
  78805. get fontSize(): string | number;
  78806. set fontSize(value: string | number);
  78807. /** Gets or sets foreground color */
  78808. get color(): string;
  78809. set color(value: string);
  78810. /** Gets or sets z index which is used to reorder controls on the z axis */
  78811. get zIndex(): number;
  78812. set zIndex(value: number);
  78813. /** Gets or sets a boolean indicating if the control can be rendered */
  78814. get notRenderable(): boolean;
  78815. set notRenderable(value: boolean);
  78816. /** Gets or sets a boolean indicating if the control is visible */
  78817. get isVisible(): boolean;
  78818. set isVisible(value: boolean);
  78819. /** Gets a boolean indicating that the control needs to update its rendering */
  78820. get isDirty(): boolean;
  78821. /**
  78822. * Gets the current linked mesh (or null if none)
  78823. */
  78824. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78825. /**
  78826. * Gets or sets a value indicating the padding to use on the left of the control
  78827. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78828. */
  78829. get paddingLeft(): string | number;
  78830. set paddingLeft(value: string | number);
  78831. /**
  78832. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78833. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78834. */
  78835. get paddingLeftInPixels(): number;
  78836. set paddingLeftInPixels(value: number);
  78837. /**
  78838. * Gets or sets a value indicating the padding to use on the right of the control
  78839. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78840. */
  78841. get paddingRight(): string | number;
  78842. set paddingRight(value: string | number);
  78843. /**
  78844. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78845. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78846. */
  78847. get paddingRightInPixels(): number;
  78848. set paddingRightInPixels(value: number);
  78849. /**
  78850. * Gets or sets a value indicating the padding to use on the top of the control
  78851. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78852. */
  78853. get paddingTop(): string | number;
  78854. set paddingTop(value: string | number);
  78855. /**
  78856. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78857. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78858. */
  78859. get paddingTopInPixels(): number;
  78860. set paddingTopInPixels(value: number);
  78861. /**
  78862. * Gets or sets a value indicating the padding to use on the bottom of the control
  78863. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78864. */
  78865. get paddingBottom(): string | number;
  78866. set paddingBottom(value: string | number);
  78867. /**
  78868. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78869. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78870. */
  78871. get paddingBottomInPixels(): number;
  78872. set paddingBottomInPixels(value: number);
  78873. /**
  78874. * Gets or sets a value indicating the left coordinate of the control
  78875. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78876. */
  78877. get left(): string | number;
  78878. set left(value: string | number);
  78879. /**
  78880. * Gets or sets a value indicating the left coordinate in pixels of the control
  78881. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78882. */
  78883. get leftInPixels(): number;
  78884. set leftInPixels(value: number);
  78885. /**
  78886. * Gets or sets a value indicating the top coordinate of the control
  78887. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78888. */
  78889. get top(): string | number;
  78890. set top(value: string | number);
  78891. /**
  78892. * Gets or sets a value indicating the top coordinate in pixels of the control
  78893. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78894. */
  78895. get topInPixels(): number;
  78896. set topInPixels(value: number);
  78897. /**
  78898. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78899. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78900. */
  78901. get linkOffsetX(): string | number;
  78902. set linkOffsetX(value: string | number);
  78903. /**
  78904. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78905. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78906. */
  78907. get linkOffsetXInPixels(): number;
  78908. set linkOffsetXInPixels(value: number);
  78909. /**
  78910. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78911. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78912. */
  78913. get linkOffsetY(): string | number;
  78914. set linkOffsetY(value: string | number);
  78915. /**
  78916. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78917. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78918. */
  78919. get linkOffsetYInPixels(): number;
  78920. set linkOffsetYInPixels(value: number);
  78921. /** Gets the center coordinate on X axis */
  78922. get centerX(): number;
  78923. /** Gets the center coordinate on Y axis */
  78924. get centerY(): number;
  78925. /** Gets or sets if control is Enabled*/
  78926. get isEnabled(): boolean;
  78927. set isEnabled(value: boolean);
  78928. /** Gets or sets background color of control if it's disabled*/
  78929. get disabledColor(): string;
  78930. set disabledColor(value: string);
  78931. /** Gets or sets front color of control if it's disabled*/
  78932. get disabledColorItem(): string;
  78933. set disabledColorItem(value: string);
  78934. /**
  78935. * Creates a new control
  78936. * @param name defines the name of the control
  78937. */
  78938. constructor(
  78939. /** defines the name of the control */
  78940. name?: string | undefined);
  78941. /** @hidden */
  78942. protected _getTypeName(): string;
  78943. /**
  78944. * Gets the first ascendant in the hierarchy of the given type
  78945. * @param className defines the required type
  78946. * @returns the ascendant or null if not found
  78947. */
  78948. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78949. /** @hidden */
  78950. _resetFontCache(): void;
  78951. /**
  78952. * Determines if a container is an ascendant of the current control
  78953. * @param container defines the container to look for
  78954. * @returns true if the container is one of the ascendant of the control
  78955. */
  78956. isAscendant(container: Control): boolean;
  78957. /**
  78958. * Gets coordinates in local control space
  78959. * @param globalCoordinates defines the coordinates to transform
  78960. * @returns the new coordinates in local space
  78961. */
  78962. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78963. /**
  78964. * Gets coordinates in local control space
  78965. * @param globalCoordinates defines the coordinates to transform
  78966. * @param result defines the target vector2 where to store the result
  78967. * @returns the current control
  78968. */
  78969. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78970. /**
  78971. * Gets coordinates in parent local control space
  78972. * @param globalCoordinates defines the coordinates to transform
  78973. * @returns the new coordinates in parent local space
  78974. */
  78975. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78976. /**
  78977. * Move the current control to a vector3 position projected onto the screen.
  78978. * @param position defines the target position
  78979. * @param scene defines the hosting scene
  78980. */
  78981. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78982. /**
  78983. * Will store all controls that have this control as ascendant in a given array
  78984. * @param results defines the array where to store the descendants
  78985. * @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
  78986. * @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
  78987. */
  78988. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78989. /**
  78990. * Will return all controls that have this control as ascendant
  78991. * @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
  78992. * @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
  78993. * @return all child controls
  78994. */
  78995. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78996. /**
  78997. * Link current control with a target mesh
  78998. * @param mesh defines the mesh to link with
  78999. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79000. */
  79001. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  79002. /** @hidden */
  79003. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  79004. /** @hidden */
  79005. _offsetLeft(offset: number): void;
  79006. /** @hidden */
  79007. _offsetTop(offset: number): void;
  79008. /** @hidden */
  79009. _markMatrixAsDirty(): void;
  79010. /** @hidden */
  79011. _flagDescendantsAsMatrixDirty(): void;
  79012. /** @hidden */
  79013. _intersectsRect(rect: Measure): boolean;
  79014. /** @hidden */
  79015. protected invalidateRect(): void;
  79016. /** @hidden */
  79017. _markAsDirty(force?: boolean): void;
  79018. /** @hidden */
  79019. _markAllAsDirty(): void;
  79020. /** @hidden */
  79021. _link(host: AdvancedDynamicTexture): void;
  79022. /** @hidden */
  79023. protected _transform(context?: CanvasRenderingContext2D): void;
  79024. /** @hidden */
  79025. _renderHighlight(context: CanvasRenderingContext2D): void;
  79026. /** @hidden */
  79027. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79028. /** @hidden */
  79029. protected _applyStates(context: CanvasRenderingContext2D): void;
  79030. /** @hidden */
  79031. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79032. /** @hidden */
  79033. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79034. protected _evaluateClippingState(parentMeasure: Measure): void;
  79035. /** @hidden */
  79036. _measure(): void;
  79037. /** @hidden */
  79038. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79039. /** @hidden */
  79040. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79041. /** @hidden */
  79042. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79043. /** @hidden */
  79044. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79045. private static _ClipMeasure;
  79046. private _tmpMeasureA;
  79047. private _clip;
  79048. /** @hidden */
  79049. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  79050. /** @hidden */
  79051. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79052. /**
  79053. * Tests if a given coordinates belong to the current control
  79054. * @param x defines x coordinate to test
  79055. * @param y defines y coordinate to test
  79056. * @returns true if the coordinates are inside the control
  79057. */
  79058. contains(x: number, y: number): boolean;
  79059. /** @hidden */
  79060. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79061. /** @hidden */
  79062. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79063. /** @hidden */
  79064. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79065. /** @hidden */
  79066. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  79067. /** @hidden */
  79068. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79069. /** @hidden */
  79070. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  79071. /** @hidden */
  79072. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79073. /** @hidden */
  79074. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  79075. /** @hidden */
  79076. _onCanvasBlur(): void;
  79077. /** @hidden */
  79078. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79079. private _prepareFont;
  79080. /** Releases associated resources */
  79081. dispose(): void;
  79082. private static _HORIZONTAL_ALIGNMENT_LEFT;
  79083. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  79084. private static _HORIZONTAL_ALIGNMENT_CENTER;
  79085. private static _VERTICAL_ALIGNMENT_TOP;
  79086. private static _VERTICAL_ALIGNMENT_BOTTOM;
  79087. private static _VERTICAL_ALIGNMENT_CENTER;
  79088. /** HORIZONTAL_ALIGNMENT_LEFT */
  79089. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  79090. /** HORIZONTAL_ALIGNMENT_RIGHT */
  79091. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  79092. /** HORIZONTAL_ALIGNMENT_CENTER */
  79093. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  79094. /** VERTICAL_ALIGNMENT_TOP */
  79095. static get VERTICAL_ALIGNMENT_TOP(): number;
  79096. /** VERTICAL_ALIGNMENT_BOTTOM */
  79097. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  79098. /** VERTICAL_ALIGNMENT_CENTER */
  79099. static get VERTICAL_ALIGNMENT_CENTER(): number;
  79100. private static _FontHeightSizes;
  79101. /** @hidden */
  79102. static _GetFontOffset(font: string): {
  79103. ascent: number;
  79104. height: number;
  79105. descent: number;
  79106. };
  79107. /**
  79108. * Creates a stack panel that can be used to render headers
  79109. * @param control defines the control to associate with the header
  79110. * @param text defines the text of the header
  79111. * @param size defines the size of the header
  79112. * @param options defines options used to configure the header
  79113. * @returns a new StackPanel
  79114. * @ignore
  79115. * @hidden
  79116. */
  79117. static AddHeader: (control: Control, text: string, size: string | number, options: {
  79118. isHorizontal: boolean;
  79119. controlFirst: boolean;
  79120. }) => any;
  79121. /** @hidden */
  79122. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  79123. }
  79124. }
  79125. declare module BABYLON.GUI {
  79126. /**
  79127. * Root class for 2D containers
  79128. * @see https://doc.babylonjs.com/how_to/gui#containers
  79129. */
  79130. export class Container extends Control {
  79131. name?: string | undefined;
  79132. /** @hidden */
  79133. _children: Control[];
  79134. /** @hidden */
  79135. protected _measureForChildren: Measure;
  79136. /** @hidden */
  79137. protected _background: string;
  79138. /** @hidden */
  79139. protected _adaptWidthToChildren: boolean;
  79140. /** @hidden */
  79141. protected _adaptHeightToChildren: boolean;
  79142. /**
  79143. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  79144. */
  79145. logLayoutCycleErrors: boolean;
  79146. /**
  79147. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  79148. */
  79149. maxLayoutCycle: number;
  79150. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  79151. get adaptHeightToChildren(): boolean;
  79152. set adaptHeightToChildren(value: boolean);
  79153. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  79154. get adaptWidthToChildren(): boolean;
  79155. set adaptWidthToChildren(value: boolean);
  79156. /** Gets or sets background color */
  79157. get background(): string;
  79158. set background(value: string);
  79159. /** Gets the list of children */
  79160. get children(): Control[];
  79161. /**
  79162. * Creates a new Container
  79163. * @param name defines the name of the container
  79164. */
  79165. constructor(name?: string | undefined);
  79166. protected _getTypeName(): string;
  79167. _flagDescendantsAsMatrixDirty(): void;
  79168. /**
  79169. * Gets a child using its name
  79170. * @param name defines the child name to look for
  79171. * @returns the child control if found
  79172. */
  79173. getChildByName(name: string): BABYLON.Nullable<Control>;
  79174. /**
  79175. * Gets a child using its type and its name
  79176. * @param name defines the child name to look for
  79177. * @param type defines the child type to look for
  79178. * @returns the child control if found
  79179. */
  79180. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  79181. /**
  79182. * Search for a specific control in children
  79183. * @param control defines the control to look for
  79184. * @returns true if the control is in child list
  79185. */
  79186. containsControl(control: Control): boolean;
  79187. /**
  79188. * Adds a new control to the current container
  79189. * @param control defines the control to add
  79190. * @returns the current container
  79191. */
  79192. addControl(control: BABYLON.Nullable<Control>): Container;
  79193. /**
  79194. * Removes all controls from the current container
  79195. * @returns the current container
  79196. */
  79197. clearControls(): Container;
  79198. /**
  79199. * Removes a control from the current container
  79200. * @param control defines the control to remove
  79201. * @returns the current container
  79202. */
  79203. removeControl(control: Control): Container;
  79204. /** @hidden */
  79205. _reOrderControl(control: Control): void;
  79206. /** @hidden */
  79207. _offsetLeft(offset: number): void;
  79208. /** @hidden */
  79209. _offsetTop(offset: number): void;
  79210. /** @hidden */
  79211. _markAllAsDirty(): void;
  79212. /** @hidden */
  79213. protected _localDraw(context: CanvasRenderingContext2D): void;
  79214. /** @hidden */
  79215. _link(host: AdvancedDynamicTexture): void;
  79216. /** @hidden */
  79217. protected _beforeLayout(): void;
  79218. /** @hidden */
  79219. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79220. /** @hidden */
  79221. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79222. protected _postMeasure(): void;
  79223. /** @hidden */
  79224. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79225. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79226. /** @hidden */
  79227. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79228. /** @hidden */
  79229. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79230. /** Releases associated resources */
  79231. dispose(): void;
  79232. }
  79233. }
  79234. declare module BABYLON.GUI {
  79235. /** Class used to create rectangle container */
  79236. export class Rectangle extends Container {
  79237. name?: string | undefined;
  79238. private _thickness;
  79239. private _cornerRadius;
  79240. /** Gets or sets border thickness */
  79241. get thickness(): number;
  79242. set thickness(value: number);
  79243. /** Gets or sets the corner radius angle */
  79244. get cornerRadius(): number;
  79245. set cornerRadius(value: number);
  79246. /**
  79247. * Creates a new Rectangle
  79248. * @param name defines the control name
  79249. */
  79250. constructor(name?: string | undefined);
  79251. protected _getTypeName(): string;
  79252. protected _localDraw(context: CanvasRenderingContext2D): void;
  79253. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79254. private _drawRoundedRect;
  79255. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79256. }
  79257. }
  79258. declare module BABYLON.GUI {
  79259. /**
  79260. * Enum that determines the text-wrapping mode to use.
  79261. */
  79262. export enum TextWrapping {
  79263. /**
  79264. * Clip the text when it's larger than Control.width; this is the default mode.
  79265. */
  79266. Clip = 0,
  79267. /**
  79268. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79269. */
  79270. WordWrap = 1,
  79271. /**
  79272. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79273. */
  79274. Ellipsis = 2
  79275. }
  79276. /**
  79277. * Class used to create text block control
  79278. */
  79279. export class TextBlock extends Control {
  79280. /**
  79281. * Defines the name of the control
  79282. */
  79283. name?: string | undefined;
  79284. private _text;
  79285. private _textWrapping;
  79286. private _textHorizontalAlignment;
  79287. private _textVerticalAlignment;
  79288. private _lines;
  79289. private _resizeToFit;
  79290. private _lineSpacing;
  79291. private _outlineWidth;
  79292. private _outlineColor;
  79293. private _underline;
  79294. private _lineThrough;
  79295. /**
  79296. * An event triggered after the text is changed
  79297. */
  79298. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79299. /**
  79300. * An event triggered after the text was broken up into lines
  79301. */
  79302. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79303. /**
  79304. * Function used to split a string into words. By default, a string is split at each space character found
  79305. */
  79306. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79307. /**
  79308. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79309. */
  79310. get lines(): any[];
  79311. /**
  79312. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79313. */
  79314. get resizeToFit(): boolean;
  79315. /**
  79316. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79317. */
  79318. set resizeToFit(value: boolean);
  79319. /**
  79320. * Gets or sets a boolean indicating if text must be wrapped
  79321. */
  79322. get textWrapping(): TextWrapping | boolean;
  79323. /**
  79324. * Gets or sets a boolean indicating if text must be wrapped
  79325. */
  79326. set textWrapping(value: TextWrapping | boolean);
  79327. /**
  79328. * Gets or sets text to display
  79329. */
  79330. get text(): string;
  79331. /**
  79332. * Gets or sets text to display
  79333. */
  79334. set text(value: string);
  79335. /**
  79336. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79337. */
  79338. get textHorizontalAlignment(): number;
  79339. /**
  79340. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79341. */
  79342. set textHorizontalAlignment(value: number);
  79343. /**
  79344. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79345. */
  79346. get textVerticalAlignment(): number;
  79347. /**
  79348. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79349. */
  79350. set textVerticalAlignment(value: number);
  79351. /**
  79352. * Gets or sets line spacing value
  79353. */
  79354. set lineSpacing(value: string | number);
  79355. /**
  79356. * Gets or sets line spacing value
  79357. */
  79358. get lineSpacing(): string | number;
  79359. /**
  79360. * Gets or sets outlineWidth of the text to display
  79361. */
  79362. get outlineWidth(): number;
  79363. /**
  79364. * Gets or sets outlineWidth of the text to display
  79365. */
  79366. set outlineWidth(value: number);
  79367. /**
  79368. * Gets or sets a boolean indicating that text must have underline
  79369. */
  79370. get underline(): boolean;
  79371. /**
  79372. * Gets or sets a boolean indicating that text must have underline
  79373. */
  79374. set underline(value: boolean);
  79375. /**
  79376. * Gets or sets an boolean indicating that text must be crossed out
  79377. */
  79378. get lineThrough(): boolean;
  79379. /**
  79380. * Gets or sets an boolean indicating that text must be crossed out
  79381. */
  79382. set lineThrough(value: boolean);
  79383. /**
  79384. * Gets or sets outlineColor of the text to display
  79385. */
  79386. get outlineColor(): string;
  79387. /**
  79388. * Gets or sets outlineColor of the text to display
  79389. */
  79390. set outlineColor(value: string);
  79391. /**
  79392. * Creates a new TextBlock object
  79393. * @param name defines the name of the control
  79394. * @param text defines the text to display (emptry string by default)
  79395. */
  79396. constructor(
  79397. /**
  79398. * Defines the name of the control
  79399. */
  79400. name?: string | undefined, text?: string);
  79401. protected _getTypeName(): string;
  79402. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79403. private _drawText;
  79404. /** @hidden */
  79405. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79406. protected _applyStates(context: CanvasRenderingContext2D): void;
  79407. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79408. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79409. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79410. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79411. protected _renderLines(context: CanvasRenderingContext2D): void;
  79412. /**
  79413. * Given a width constraint applied on the text block, find the expected height
  79414. * @returns expected height
  79415. */
  79416. computeExpectedHeight(): number;
  79417. dispose(): void;
  79418. }
  79419. }
  79420. declare module BABYLON.GUI {
  79421. /**
  79422. * Class used to create 2D images
  79423. */
  79424. export class Image extends Control {
  79425. name?: string | undefined;
  79426. private _workingCanvas;
  79427. private _domImage;
  79428. private _imageWidth;
  79429. private _imageHeight;
  79430. private _loaded;
  79431. private _stretch;
  79432. private _source;
  79433. private _autoScale;
  79434. private _sourceLeft;
  79435. private _sourceTop;
  79436. private _sourceWidth;
  79437. private _sourceHeight;
  79438. private _svgAttributesComputationCompleted;
  79439. private _isSVG;
  79440. private _cellWidth;
  79441. private _cellHeight;
  79442. private _cellId;
  79443. private _populateNinePatchSlicesFromImage;
  79444. private _sliceLeft;
  79445. private _sliceRight;
  79446. private _sliceTop;
  79447. private _sliceBottom;
  79448. private _detectPointerOnOpaqueOnly;
  79449. private _imageDataCache;
  79450. /**
  79451. * BABYLON.Observable notified when the content is loaded
  79452. */
  79453. onImageLoadedObservable: BABYLON.Observable<Image>;
  79454. /**
  79455. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79456. */
  79457. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79458. /**
  79459. * Gets a boolean indicating that the content is loaded
  79460. */
  79461. get isLoaded(): boolean;
  79462. /**
  79463. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79464. */
  79465. get populateNinePatchSlicesFromImage(): boolean;
  79466. set populateNinePatchSlicesFromImage(value: boolean);
  79467. /**
  79468. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79469. * Beware using this as this will comsume more memory as the image has to be stored twice
  79470. */
  79471. get detectPointerOnOpaqueOnly(): boolean;
  79472. set detectPointerOnOpaqueOnly(value: boolean);
  79473. /**
  79474. * Gets or sets the left value for slicing (9-patch)
  79475. */
  79476. get sliceLeft(): number;
  79477. set sliceLeft(value: number);
  79478. /**
  79479. * Gets or sets the right value for slicing (9-patch)
  79480. */
  79481. get sliceRight(): number;
  79482. set sliceRight(value: number);
  79483. /**
  79484. * Gets or sets the top value for slicing (9-patch)
  79485. */
  79486. get sliceTop(): number;
  79487. set sliceTop(value: number);
  79488. /**
  79489. * Gets or sets the bottom value for slicing (9-patch)
  79490. */
  79491. get sliceBottom(): number;
  79492. set sliceBottom(value: number);
  79493. /**
  79494. * Gets or sets the left coordinate in the source image
  79495. */
  79496. get sourceLeft(): number;
  79497. set sourceLeft(value: number);
  79498. /**
  79499. * Gets or sets the top coordinate in the source image
  79500. */
  79501. get sourceTop(): number;
  79502. set sourceTop(value: number);
  79503. /**
  79504. * Gets or sets the width to capture in the source image
  79505. */
  79506. get sourceWidth(): number;
  79507. set sourceWidth(value: number);
  79508. /**
  79509. * Gets or sets the height to capture in the source image
  79510. */
  79511. get sourceHeight(): number;
  79512. set sourceHeight(value: number);
  79513. /** Indicates if the format of the image is SVG */
  79514. get isSVG(): boolean;
  79515. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79516. get svgAttributesComputationCompleted(): boolean;
  79517. /**
  79518. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79519. * @see https://doc.babylonjs.com/how_to/gui#image
  79520. */
  79521. get autoScale(): boolean;
  79522. set autoScale(value: boolean);
  79523. /** Gets or sets the streching mode used by the image */
  79524. get stretch(): number;
  79525. set stretch(value: number);
  79526. /** @hidden */
  79527. _rotate90(n: number, preserveProperties?: boolean): Image;
  79528. private _handleRotationForSVGImage;
  79529. private _rotate90SourceProperties;
  79530. /**
  79531. * Gets or sets the internal DOM image used to render the control
  79532. */
  79533. set domImage(value: HTMLImageElement);
  79534. get domImage(): HTMLImageElement;
  79535. private _onImageLoaded;
  79536. private _extractNinePatchSliceDataFromImage;
  79537. /**
  79538. * Gets or sets image source url
  79539. */
  79540. set source(value: BABYLON.Nullable<string>);
  79541. /**
  79542. * Checks for svg document with icon id present
  79543. */
  79544. private _svgCheck;
  79545. /**
  79546. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79547. * given external svg file and icon id
  79548. */
  79549. private _getSVGAttribs;
  79550. /**
  79551. * Gets or sets the cell width to use when animation sheet is enabled
  79552. * @see https://doc.babylonjs.com/how_to/gui#image
  79553. */
  79554. get cellWidth(): number;
  79555. set cellWidth(value: number);
  79556. /**
  79557. * Gets or sets the cell height to use when animation sheet is enabled
  79558. * @see https://doc.babylonjs.com/how_to/gui#image
  79559. */
  79560. get cellHeight(): number;
  79561. set cellHeight(value: number);
  79562. /**
  79563. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79564. * @see https://doc.babylonjs.com/how_to/gui#image
  79565. */
  79566. get cellId(): number;
  79567. set cellId(value: number);
  79568. /**
  79569. * Creates a new Image
  79570. * @param name defines the control name
  79571. * @param url defines the image url
  79572. */
  79573. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79574. /**
  79575. * Tests if a given coordinates belong to the current control
  79576. * @param x defines x coordinate to test
  79577. * @param y defines y coordinate to test
  79578. * @returns true if the coordinates are inside the control
  79579. */
  79580. contains(x: number, y: number): boolean;
  79581. protected _getTypeName(): string;
  79582. /** Force the control to synchronize with its content */
  79583. synchronizeSizeWithContent(): void;
  79584. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79585. private _prepareWorkingCanvasForOpaqueDetection;
  79586. private _drawImage;
  79587. _draw(context: CanvasRenderingContext2D): void;
  79588. private _renderCornerPatch;
  79589. private _renderNinePatch;
  79590. dispose(): void;
  79591. /** STRETCH_NONE */
  79592. static readonly STRETCH_NONE: number;
  79593. /** STRETCH_FILL */
  79594. static readonly STRETCH_FILL: number;
  79595. /** STRETCH_UNIFORM */
  79596. static readonly STRETCH_UNIFORM: number;
  79597. /** STRETCH_EXTEND */
  79598. static readonly STRETCH_EXTEND: number;
  79599. /** NINE_PATCH */
  79600. static readonly STRETCH_NINE_PATCH: number;
  79601. }
  79602. }
  79603. declare module BABYLON.GUI {
  79604. /**
  79605. * Class used to create 2D buttons
  79606. */
  79607. export class Button extends Rectangle {
  79608. name?: string | undefined;
  79609. /**
  79610. * Function called to generate a pointer enter animation
  79611. */
  79612. pointerEnterAnimation: () => void;
  79613. /**
  79614. * Function called to generate a pointer out animation
  79615. */
  79616. pointerOutAnimation: () => void;
  79617. /**
  79618. * Function called to generate a pointer down animation
  79619. */
  79620. pointerDownAnimation: () => void;
  79621. /**
  79622. * Function called to generate a pointer up animation
  79623. */
  79624. pointerUpAnimation: () => void;
  79625. /**
  79626. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79627. */
  79628. delegatePickingToChildren: boolean;
  79629. private _image;
  79630. /**
  79631. * Returns the image part of the button (if any)
  79632. */
  79633. get image(): BABYLON.Nullable<Image>;
  79634. private _textBlock;
  79635. /**
  79636. * Returns the image part of the button (if any)
  79637. */
  79638. get textBlock(): BABYLON.Nullable<TextBlock>;
  79639. /**
  79640. * Creates a new Button
  79641. * @param name defines the name of the button
  79642. */
  79643. constructor(name?: string | undefined);
  79644. protected _getTypeName(): string;
  79645. /** @hidden */
  79646. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79647. /** @hidden */
  79648. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79649. /** @hidden */
  79650. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79651. /** @hidden */
  79652. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79653. /** @hidden */
  79654. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79655. /**
  79656. * Creates a new button made with an image and a text
  79657. * @param name defines the name of the button
  79658. * @param text defines the text of the button
  79659. * @param imageUrl defines the url of the image
  79660. * @returns a new Button
  79661. */
  79662. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79663. /**
  79664. * Creates a new button made with an image
  79665. * @param name defines the name of the button
  79666. * @param imageUrl defines the url of the image
  79667. * @returns a new Button
  79668. */
  79669. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79670. /**
  79671. * Creates a new button made with a text
  79672. * @param name defines the name of the button
  79673. * @param text defines the text of the button
  79674. * @returns a new Button
  79675. */
  79676. static CreateSimpleButton(name: string, text: string): Button;
  79677. /**
  79678. * Creates a new button made with an image and a centered text
  79679. * @param name defines the name of the button
  79680. * @param text defines the text of the button
  79681. * @param imageUrl defines the url of the image
  79682. * @returns a new Button
  79683. */
  79684. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79685. }
  79686. }
  79687. declare module BABYLON.GUI {
  79688. /**
  79689. * Class used to create a 2D stack panel container
  79690. */
  79691. export class StackPanel extends Container {
  79692. name?: string | undefined;
  79693. private _isVertical;
  79694. private _manualWidth;
  79695. private _manualHeight;
  79696. private _doNotTrackManualChanges;
  79697. /**
  79698. * Gets or sets a boolean indicating that layou warnings should be ignored
  79699. */
  79700. ignoreLayoutWarnings: boolean;
  79701. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79702. get isVertical(): boolean;
  79703. set isVertical(value: boolean);
  79704. /**
  79705. * Gets or sets panel width.
  79706. * This value should not be set when in horizontal mode as it will be computed automatically
  79707. */
  79708. set width(value: string | number);
  79709. get width(): string | number;
  79710. /**
  79711. * Gets or sets panel height.
  79712. * This value should not be set when in vertical mode as it will be computed automatically
  79713. */
  79714. set height(value: string | number);
  79715. get height(): string | number;
  79716. /**
  79717. * Creates a new StackPanel
  79718. * @param name defines control name
  79719. */
  79720. constructor(name?: string | undefined);
  79721. protected _getTypeName(): string;
  79722. /** @hidden */
  79723. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79724. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79725. protected _postMeasure(): void;
  79726. }
  79727. }
  79728. declare module BABYLON.GUI {
  79729. /**
  79730. * Class used to represent a 2D checkbox
  79731. */
  79732. export class Checkbox extends Control {
  79733. name?: string | undefined;
  79734. private _isChecked;
  79735. private _background;
  79736. private _checkSizeRatio;
  79737. private _thickness;
  79738. /** Gets or sets border thickness */
  79739. get thickness(): number;
  79740. set thickness(value: number);
  79741. /**
  79742. * BABYLON.Observable raised when isChecked property changes
  79743. */
  79744. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79745. /** Gets or sets a value indicating the ratio between overall size and check size */
  79746. get checkSizeRatio(): number;
  79747. set checkSizeRatio(value: number);
  79748. /** Gets or sets background color */
  79749. get background(): string;
  79750. set background(value: string);
  79751. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79752. get isChecked(): boolean;
  79753. set isChecked(value: boolean);
  79754. /**
  79755. * Creates a new CheckBox
  79756. * @param name defines the control name
  79757. */
  79758. constructor(name?: string | undefined);
  79759. protected _getTypeName(): string;
  79760. /** @hidden */
  79761. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79762. /** @hidden */
  79763. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79764. /**
  79765. * Utility function to easily create a checkbox with a header
  79766. * @param title defines the label to use for the header
  79767. * @param onValueChanged defines the callback to call when value changes
  79768. * @returns a StackPanel containing the checkbox and a textBlock
  79769. */
  79770. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79771. }
  79772. }
  79773. declare module BABYLON.GUI {
  79774. /**
  79775. * Class used to store key control properties
  79776. */
  79777. export class KeyPropertySet {
  79778. /** Width */
  79779. width?: string;
  79780. /** Height */
  79781. height?: string;
  79782. /** Left padding */
  79783. paddingLeft?: string;
  79784. /** Right padding */
  79785. paddingRight?: string;
  79786. /** Top padding */
  79787. paddingTop?: string;
  79788. /** Bottom padding */
  79789. paddingBottom?: string;
  79790. /** Foreground color */
  79791. color?: string;
  79792. /** Background color */
  79793. background?: string;
  79794. }
  79795. /**
  79796. * Class used to create virtual keyboard
  79797. */
  79798. export class VirtualKeyboard extends StackPanel {
  79799. /** BABYLON.Observable raised when a key is pressed */
  79800. onKeyPressObservable: BABYLON.Observable<string>;
  79801. /** Gets or sets default key button width */
  79802. defaultButtonWidth: string;
  79803. /** Gets or sets default key button height */
  79804. defaultButtonHeight: string;
  79805. /** Gets or sets default key button left padding */
  79806. defaultButtonPaddingLeft: string;
  79807. /** Gets or sets default key button right padding */
  79808. defaultButtonPaddingRight: string;
  79809. /** Gets or sets default key button top padding */
  79810. defaultButtonPaddingTop: string;
  79811. /** Gets or sets default key button bottom padding */
  79812. defaultButtonPaddingBottom: string;
  79813. /** Gets or sets default key button foreground color */
  79814. defaultButtonColor: string;
  79815. /** Gets or sets default key button background color */
  79816. defaultButtonBackground: string;
  79817. /** Gets or sets shift button foreground color */
  79818. shiftButtonColor: string;
  79819. /** Gets or sets shift button thickness*/
  79820. selectedShiftThickness: number;
  79821. /** Gets shift key state */
  79822. shiftState: number;
  79823. protected _getTypeName(): string;
  79824. private _createKey;
  79825. /**
  79826. * Adds a new row of keys
  79827. * @param keys defines the list of keys to add
  79828. * @param propertySets defines the associated property sets
  79829. */
  79830. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79831. /**
  79832. * Set the shift key to a specific state
  79833. * @param shiftState defines the new shift state
  79834. */
  79835. applyShiftState(shiftState: number): void;
  79836. private _currentlyConnectedInputText;
  79837. private _connectedInputTexts;
  79838. private _onKeyPressObserver;
  79839. /** Gets the input text control currently attached to the keyboard */
  79840. get connectedInputText(): BABYLON.Nullable<InputText>;
  79841. /**
  79842. * Connects the keyboard with an input text control
  79843. *
  79844. * @param input defines the target control
  79845. */
  79846. connect(input: InputText): void;
  79847. /**
  79848. * Disconnects the keyboard from connected InputText controls
  79849. *
  79850. * @param input optionally defines a target control, otherwise all are disconnected
  79851. */
  79852. disconnect(input?: InputText): void;
  79853. private _removeConnectedInputObservables;
  79854. /**
  79855. * Release all resources
  79856. */
  79857. dispose(): void;
  79858. /**
  79859. * Creates a new keyboard using a default layout
  79860. *
  79861. * @param name defines control name
  79862. * @returns a new VirtualKeyboard
  79863. */
  79864. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79865. }
  79866. }
  79867. declare module BABYLON.GUI {
  79868. /** @hidden */
  79869. export class TextWrapper {
  79870. private _text;
  79871. private _characters;
  79872. get text(): string;
  79873. set text(txt: string);
  79874. get length(): number;
  79875. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  79876. charAt(idx: number): string;
  79877. substr(from: number, length?: number): string;
  79878. substring(from: number, to?: number): string;
  79879. isWord(index: number): boolean;
  79880. }
  79881. }
  79882. declare module BABYLON.GUI {
  79883. /**
  79884. * Class used to create input text control
  79885. */
  79886. export class InputText extends Control implements IFocusableControl {
  79887. name?: string | undefined;
  79888. private _textWrapper;
  79889. private _placeholderText;
  79890. private _background;
  79891. private _focusedBackground;
  79892. private _focusedColor;
  79893. private _placeholderColor;
  79894. private _thickness;
  79895. private _margin;
  79896. private _autoStretchWidth;
  79897. private _maxWidth;
  79898. private _isFocused;
  79899. private _blinkTimeout;
  79900. private _blinkIsEven;
  79901. private _cursorOffset;
  79902. private _scrollLeft;
  79903. private _textWidth;
  79904. private _clickedCoordinate;
  79905. private _deadKey;
  79906. private _addKey;
  79907. private _currentKey;
  79908. private _isTextHighlightOn;
  79909. private _textHighlightColor;
  79910. private _highligherOpacity;
  79911. private _highlightedText;
  79912. private _startHighlightIndex;
  79913. private _endHighlightIndex;
  79914. private _cursorIndex;
  79915. private _onFocusSelectAll;
  79916. private _isPointerDown;
  79917. private _onClipboardObserver;
  79918. private _onPointerDblTapObserver;
  79919. /** @hidden */
  79920. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79921. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79922. promptMessage: string;
  79923. /** Force disable prompt on mobile device */
  79924. disableMobilePrompt: boolean;
  79925. /** BABYLON.Observable raised when the text changes */
  79926. onTextChangedObservable: BABYLON.Observable<InputText>;
  79927. /** BABYLON.Observable raised just before an entered character is to be added */
  79928. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79929. /** BABYLON.Observable raised when the control gets the focus */
  79930. onFocusObservable: BABYLON.Observable<InputText>;
  79931. /** BABYLON.Observable raised when the control loses the focus */
  79932. onBlurObservable: BABYLON.Observable<InputText>;
  79933. /**Observable raised when the text is highlighted */
  79934. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79935. /**Observable raised when copy event is triggered */
  79936. onTextCopyObservable: BABYLON.Observable<InputText>;
  79937. /** BABYLON.Observable raised when cut event is triggered */
  79938. onTextCutObservable: BABYLON.Observable<InputText>;
  79939. /** BABYLON.Observable raised when paste event is triggered */
  79940. onTextPasteObservable: BABYLON.Observable<InputText>;
  79941. /** BABYLON.Observable raised when a key event was processed */
  79942. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79943. /** Gets or sets the maximum width allowed by the control */
  79944. get maxWidth(): string | number;
  79945. /** Gets the maximum width allowed by the control in pixels */
  79946. get maxWidthInPixels(): number;
  79947. set maxWidth(value: string | number);
  79948. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79949. get highligherOpacity(): number;
  79950. set highligherOpacity(value: number);
  79951. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79952. get onFocusSelectAll(): boolean;
  79953. set onFocusSelectAll(value: boolean);
  79954. /** Gets or sets the text hightlight color */
  79955. get textHighlightColor(): string;
  79956. set textHighlightColor(value: string);
  79957. /** Gets or sets control margin */
  79958. get margin(): string;
  79959. /** Gets control margin in pixels */
  79960. get marginInPixels(): number;
  79961. set margin(value: string);
  79962. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79963. get autoStretchWidth(): boolean;
  79964. set autoStretchWidth(value: boolean);
  79965. /** Gets or sets border thickness */
  79966. get thickness(): number;
  79967. set thickness(value: number);
  79968. /** Gets or sets the background color when focused */
  79969. get focusedBackground(): string;
  79970. set focusedBackground(value: string);
  79971. /** Gets or sets the background color when focused */
  79972. get focusedColor(): string;
  79973. set focusedColor(value: string);
  79974. /** Gets or sets the background color */
  79975. get background(): string;
  79976. set background(value: string);
  79977. /** Gets or sets the placeholder color */
  79978. get placeholderColor(): string;
  79979. set placeholderColor(value: string);
  79980. /** Gets or sets the text displayed when the control is empty */
  79981. get placeholderText(): string;
  79982. set placeholderText(value: string);
  79983. /** Gets or sets the dead key flag */
  79984. get deadKey(): boolean;
  79985. set deadKey(flag: boolean);
  79986. /** Gets or sets the highlight text */
  79987. get highlightedText(): string;
  79988. set highlightedText(text: string);
  79989. /** Gets or sets if the current key should be added */
  79990. get addKey(): boolean;
  79991. set addKey(flag: boolean);
  79992. /** Gets or sets the value of the current key being entered */
  79993. get currentKey(): string;
  79994. set currentKey(key: string);
  79995. /** Gets or sets the text displayed in the control */
  79996. get text(): string;
  79997. set text(value: string);
  79998. private _textHasChanged;
  79999. /** Gets or sets control width */
  80000. get width(): string | number;
  80001. set width(value: string | number);
  80002. /**
  80003. * Creates a new InputText
  80004. * @param name defines the control name
  80005. * @param text defines the text of the control
  80006. */
  80007. constructor(name?: string | undefined, text?: string);
  80008. /** @hidden */
  80009. onBlur(): void;
  80010. /** @hidden */
  80011. onFocus(): void;
  80012. protected _getTypeName(): string;
  80013. /**
  80014. * Function called to get the list of controls that should not steal the focus from this control
  80015. * @returns an array of controls
  80016. */
  80017. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  80018. /** @hidden */
  80019. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  80020. /** @hidden */
  80021. private _updateValueFromCursorIndex;
  80022. /** @hidden */
  80023. private _processDblClick;
  80024. /** @hidden */
  80025. private _selectAllText;
  80026. /**
  80027. * Handles the keyboard event
  80028. * @param evt Defines the KeyboardEvent
  80029. */
  80030. processKeyboard(evt: KeyboardEvent): void;
  80031. /** @hidden */
  80032. private _onCopyText;
  80033. /** @hidden */
  80034. private _onCutText;
  80035. /** @hidden */
  80036. private _onPasteText;
  80037. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80038. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80039. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80040. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80041. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80042. dispose(): void;
  80043. }
  80044. }
  80045. declare module BABYLON.GUI {
  80046. /**
  80047. * Class used to create a 2D grid container
  80048. */
  80049. export class Grid extends Container {
  80050. name?: string | undefined;
  80051. private _rowDefinitions;
  80052. private _columnDefinitions;
  80053. private _cells;
  80054. private _childControls;
  80055. /**
  80056. * Gets the number of columns
  80057. */
  80058. get columnCount(): number;
  80059. /**
  80060. * Gets the number of rows
  80061. */
  80062. get rowCount(): number;
  80063. /** Gets the list of children */
  80064. get children(): Control[];
  80065. /** Gets the list of cells (e.g. the containers) */
  80066. get cells(): {
  80067. [key: string]: Container;
  80068. };
  80069. /**
  80070. * Gets the definition of a specific row
  80071. * @param index defines the index of the row
  80072. * @returns the row definition
  80073. */
  80074. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80075. /**
  80076. * Gets the definition of a specific column
  80077. * @param index defines the index of the column
  80078. * @returns the column definition
  80079. */
  80080. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80081. /**
  80082. * Adds a new row to the grid
  80083. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80084. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  80085. * @returns the current grid
  80086. */
  80087. addRowDefinition(height: number, isPixel?: boolean): Grid;
  80088. /**
  80089. * Adds a new column to the grid
  80090. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80091. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80092. * @returns the current grid
  80093. */
  80094. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  80095. /**
  80096. * Update a row definition
  80097. * @param index defines the index of the row to update
  80098. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80099. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  80100. * @returns the current grid
  80101. */
  80102. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  80103. /**
  80104. * Update a column definition
  80105. * @param index defines the index of the column to update
  80106. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80107. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80108. * @returns the current grid
  80109. */
  80110. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  80111. /**
  80112. * Gets the list of children stored in a specific cell
  80113. * @param row defines the row to check
  80114. * @param column defines the column to check
  80115. * @returns the list of controls
  80116. */
  80117. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  80118. /**
  80119. * Gets a string representing the child cell info (row x column)
  80120. * @param child defines the control to get info from
  80121. * @returns a string containing the child cell info (row x column)
  80122. */
  80123. getChildCellInfo(child: Control): string;
  80124. private _removeCell;
  80125. private _offsetCell;
  80126. /**
  80127. * Remove a column definition at specified index
  80128. * @param index defines the index of the column to remove
  80129. * @returns the current grid
  80130. */
  80131. removeColumnDefinition(index: number): Grid;
  80132. /**
  80133. * Remove a row definition at specified index
  80134. * @param index defines the index of the row to remove
  80135. * @returns the current grid
  80136. */
  80137. removeRowDefinition(index: number): Grid;
  80138. /**
  80139. * Adds a new control to the current grid
  80140. * @param control defines the control to add
  80141. * @param row defines the row where to add the control (0 by default)
  80142. * @param column defines the column where to add the control (0 by default)
  80143. * @returns the current grid
  80144. */
  80145. addControl(control: Control, row?: number, column?: number): Grid;
  80146. /**
  80147. * Removes a control from the current container
  80148. * @param control defines the control to remove
  80149. * @returns the current container
  80150. */
  80151. removeControl(control: Control): Container;
  80152. /**
  80153. * Creates a new Grid
  80154. * @param name defines control name
  80155. */
  80156. constructor(name?: string | undefined);
  80157. protected _getTypeName(): string;
  80158. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  80159. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80160. _flagDescendantsAsMatrixDirty(): void;
  80161. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80162. /** Releases associated resources */
  80163. dispose(): void;
  80164. }
  80165. }
  80166. declare module BABYLON.GUI {
  80167. /** Class used to create color pickers */
  80168. export class ColorPicker extends Control {
  80169. name?: string | undefined;
  80170. private static _Epsilon;
  80171. private _colorWheelCanvas;
  80172. private _value;
  80173. private _tmpColor;
  80174. private _pointerStartedOnSquare;
  80175. private _pointerStartedOnWheel;
  80176. private _squareLeft;
  80177. private _squareTop;
  80178. private _squareSize;
  80179. private _h;
  80180. private _s;
  80181. private _v;
  80182. private _lastPointerDownID;
  80183. /**
  80184. * BABYLON.Observable raised when the value changes
  80185. */
  80186. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  80187. /** Gets or sets the color of the color picker */
  80188. get value(): BABYLON.Color3;
  80189. set value(value: BABYLON.Color3);
  80190. /**
  80191. * Gets or sets control width
  80192. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80193. */
  80194. get width(): string | number;
  80195. set width(value: string | number);
  80196. /**
  80197. * Gets or sets control height
  80198. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80199. */
  80200. get height(): string | number;
  80201. /** Gets or sets control height */
  80202. set height(value: string | number);
  80203. /** Gets or sets control size */
  80204. get size(): string | number;
  80205. set size(value: string | number);
  80206. /**
  80207. * Creates a new ColorPicker
  80208. * @param name defines the control name
  80209. */
  80210. constructor(name?: string | undefined);
  80211. protected _getTypeName(): string;
  80212. /** @hidden */
  80213. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80214. private _updateSquareProps;
  80215. private _drawGradientSquare;
  80216. private _drawCircle;
  80217. private _createColorWheelCanvas;
  80218. /** @hidden */
  80219. _draw(context: CanvasRenderingContext2D): void;
  80220. private _pointerIsDown;
  80221. private _updateValueFromPointer;
  80222. private _isPointOnSquare;
  80223. private _isPointOnWheel;
  80224. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80225. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80226. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  80227. _onCanvasBlur(): void;
  80228. /**
  80229. * This function expands the color picker by creating a color picker dialog with manual
  80230. * color value input and the ability to save colors into an array to be used later in
  80231. * subsequent launches of the dialogue.
  80232. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  80233. * @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.
  80234. * @returns picked color as a hex string and the saved colors array as hex strings.
  80235. */
  80236. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  80237. pickerWidth?: string;
  80238. pickerHeight?: string;
  80239. headerHeight?: string;
  80240. lastColor?: string;
  80241. swatchLimit?: number;
  80242. numSwatchesPerLine?: number;
  80243. savedColors?: Array<string>;
  80244. }): Promise<{
  80245. savedColors?: string[];
  80246. pickedColor: string;
  80247. }>;
  80248. }
  80249. }
  80250. declare module BABYLON.GUI {
  80251. /** Class used to create 2D ellipse containers */
  80252. export class Ellipse extends Container {
  80253. name?: string | undefined;
  80254. private _thickness;
  80255. /** Gets or sets border thickness */
  80256. get thickness(): number;
  80257. set thickness(value: number);
  80258. /**
  80259. * Creates a new Ellipse
  80260. * @param name defines the control name
  80261. */
  80262. constructor(name?: string | undefined);
  80263. protected _getTypeName(): string;
  80264. protected _localDraw(context: CanvasRenderingContext2D): void;
  80265. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80266. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  80267. }
  80268. }
  80269. declare module BABYLON.GUI {
  80270. /**
  80271. * Class used to create a password control
  80272. */
  80273. export class InputPassword extends InputText {
  80274. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80275. }
  80276. }
  80277. declare module BABYLON.GUI {
  80278. /** Class used to render 2D lines */
  80279. export class Line extends Control {
  80280. name?: string | undefined;
  80281. private _lineWidth;
  80282. private _x1;
  80283. private _y1;
  80284. private _x2;
  80285. private _y2;
  80286. private _dash;
  80287. private _connectedControl;
  80288. private _connectedControlDirtyObserver;
  80289. /** Gets or sets the dash pattern */
  80290. get dash(): Array<number>;
  80291. set dash(value: Array<number>);
  80292. /** Gets or sets the control connected with the line end */
  80293. get connectedControl(): Control;
  80294. set connectedControl(value: Control);
  80295. /** Gets or sets start coordinates on X axis */
  80296. get x1(): string | number;
  80297. set x1(value: string | number);
  80298. /** Gets or sets start coordinates on Y axis */
  80299. get y1(): string | number;
  80300. set y1(value: string | number);
  80301. /** Gets or sets end coordinates on X axis */
  80302. get x2(): string | number;
  80303. set x2(value: string | number);
  80304. /** Gets or sets end coordinates on Y axis */
  80305. get y2(): string | number;
  80306. set y2(value: string | number);
  80307. /** Gets or sets line width */
  80308. get lineWidth(): number;
  80309. set lineWidth(value: number);
  80310. /** Gets or sets horizontal alignment */
  80311. set horizontalAlignment(value: number);
  80312. /** Gets or sets vertical alignment */
  80313. set verticalAlignment(value: number);
  80314. private get _effectiveX2();
  80315. private get _effectiveY2();
  80316. /**
  80317. * Creates a new Line
  80318. * @param name defines the control name
  80319. */
  80320. constructor(name?: string | undefined);
  80321. protected _getTypeName(): string;
  80322. _draw(context: CanvasRenderingContext2D): void;
  80323. _measure(): void;
  80324. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80325. /**
  80326. * Move one end of the line given 3D cartesian coordinates.
  80327. * @param position Targeted world position
  80328. * @param scene BABYLON.Scene
  80329. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80330. */
  80331. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80332. /**
  80333. * Move one end of the line to a position in screen absolute space.
  80334. * @param projectedPosition Position in screen absolute space (X, Y)
  80335. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80336. */
  80337. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80338. }
  80339. }
  80340. declare module BABYLON.GUI {
  80341. /**
  80342. * Class used to store a point for a MultiLine object.
  80343. * The point can be pure 2D coordinates, a mesh or a control
  80344. */
  80345. export class MultiLinePoint {
  80346. private _multiLine;
  80347. private _x;
  80348. private _y;
  80349. private _control;
  80350. private _mesh;
  80351. private _controlObserver;
  80352. private _meshObserver;
  80353. /** @hidden */
  80354. _point: BABYLON.Vector3;
  80355. /**
  80356. * Creates a new MultiLinePoint
  80357. * @param multiLine defines the source MultiLine object
  80358. */
  80359. constructor(multiLine: MultiLine);
  80360. /** Gets or sets x coordinate */
  80361. get x(): string | number;
  80362. set x(value: string | number);
  80363. /** Gets or sets y coordinate */
  80364. get y(): string | number;
  80365. set y(value: string | number);
  80366. /** Gets or sets the control associated with this point */
  80367. get control(): BABYLON.Nullable<Control>;
  80368. set control(value: BABYLON.Nullable<Control>);
  80369. /** Gets or sets the mesh associated with this point */
  80370. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80371. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80372. /** Resets links */
  80373. resetLinks(): void;
  80374. /**
  80375. * Gets a translation vector with Z component
  80376. * @returns the translation vector
  80377. */
  80378. translate(): BABYLON.Vector3;
  80379. private _translatePoint;
  80380. /** Release associated resources */
  80381. dispose(): void;
  80382. }
  80383. }
  80384. declare module BABYLON.GUI {
  80385. /**
  80386. * Class used to create multi line control
  80387. */
  80388. export class MultiLine extends Control {
  80389. name?: string | undefined;
  80390. private _lineWidth;
  80391. private _dash;
  80392. private _points;
  80393. private _minX;
  80394. private _minY;
  80395. private _maxX;
  80396. private _maxY;
  80397. /**
  80398. * Creates a new MultiLine
  80399. * @param name defines the control name
  80400. */
  80401. constructor(name?: string | undefined);
  80402. /** Gets or sets dash pattern */
  80403. get dash(): Array<number>;
  80404. set dash(value: Array<number>);
  80405. /**
  80406. * Gets point stored at specified index
  80407. * @param index defines the index to look for
  80408. * @returns the requested point if found
  80409. */
  80410. getAt(index: number): MultiLinePoint;
  80411. /** Function called when a point is updated */
  80412. onPointUpdate: () => void;
  80413. /**
  80414. * Adds new points to the point collection
  80415. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80416. * @returns the list of created MultiLinePoint
  80417. */
  80418. add(...items: (AbstractMesh | Control | {
  80419. x: string | number;
  80420. y: string | number;
  80421. })[]): MultiLinePoint[];
  80422. /**
  80423. * Adds a new point to the point collection
  80424. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80425. * @returns the created MultiLinePoint
  80426. */
  80427. push(item?: (AbstractMesh | Control | {
  80428. x: string | number;
  80429. y: string | number;
  80430. })): MultiLinePoint;
  80431. /**
  80432. * Remove a specific value or point from the active point collection
  80433. * @param value defines the value or point to remove
  80434. */
  80435. remove(value: number | MultiLinePoint): void;
  80436. /**
  80437. * Resets this object to initial state (no point)
  80438. */
  80439. reset(): void;
  80440. /**
  80441. * Resets all links
  80442. */
  80443. resetLinks(): void;
  80444. /** Gets or sets line width */
  80445. get lineWidth(): number;
  80446. set lineWidth(value: number);
  80447. set horizontalAlignment(value: number);
  80448. set verticalAlignment(value: number);
  80449. protected _getTypeName(): string;
  80450. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80451. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80452. _measure(): void;
  80453. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80454. dispose(): void;
  80455. }
  80456. }
  80457. declare module BABYLON.GUI {
  80458. /**
  80459. * Class used to create radio button controls
  80460. */
  80461. export class RadioButton extends Control {
  80462. name?: string | undefined;
  80463. private _isChecked;
  80464. private _background;
  80465. private _checkSizeRatio;
  80466. private _thickness;
  80467. /** Gets or sets border thickness */
  80468. get thickness(): number;
  80469. set thickness(value: number);
  80470. /** Gets or sets group name */
  80471. group: string;
  80472. /** BABYLON.Observable raised when isChecked is changed */
  80473. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80474. /** Gets or sets a value indicating the ratio between overall size and check size */
  80475. get checkSizeRatio(): number;
  80476. set checkSizeRatio(value: number);
  80477. /** Gets or sets background color */
  80478. get background(): string;
  80479. set background(value: string);
  80480. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80481. get isChecked(): boolean;
  80482. set isChecked(value: boolean);
  80483. /**
  80484. * Creates a new RadioButton
  80485. * @param name defines the control name
  80486. */
  80487. constructor(name?: string | undefined);
  80488. protected _getTypeName(): string;
  80489. _draw(context: CanvasRenderingContext2D): void;
  80490. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80491. /**
  80492. * Utility function to easily create a radio button with a header
  80493. * @param title defines the label to use for the header
  80494. * @param group defines the group to use for the radio button
  80495. * @param isChecked defines the initial state of the radio button
  80496. * @param onValueChanged defines the callback to call when value changes
  80497. * @returns a StackPanel containing the radio button and a textBlock
  80498. */
  80499. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80500. }
  80501. }
  80502. declare module BABYLON.GUI {
  80503. /**
  80504. * Class used to create slider controls
  80505. */
  80506. export class BaseSlider extends Control {
  80507. name?: string | undefined;
  80508. protected _thumbWidth: ValueAndUnit;
  80509. private _minimum;
  80510. private _maximum;
  80511. private _value;
  80512. private _isVertical;
  80513. protected _barOffset: ValueAndUnit;
  80514. private _isThumbClamped;
  80515. protected _displayThumb: boolean;
  80516. private _step;
  80517. private _lastPointerDownID;
  80518. protected _effectiveBarOffset: number;
  80519. protected _renderLeft: number;
  80520. protected _renderTop: number;
  80521. protected _renderWidth: number;
  80522. protected _renderHeight: number;
  80523. protected _backgroundBoxLength: number;
  80524. protected _backgroundBoxThickness: number;
  80525. protected _effectiveThumbThickness: number;
  80526. /** BABYLON.Observable raised when the sldier value changes */
  80527. onValueChangedObservable: BABYLON.Observable<number>;
  80528. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80529. get displayThumb(): boolean;
  80530. set displayThumb(value: boolean);
  80531. /** Gets or sets a step to apply to values (0 by default) */
  80532. get step(): number;
  80533. set step(value: number);
  80534. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80535. get barOffset(): string | number;
  80536. /** Gets main bar offset in pixels*/
  80537. get barOffsetInPixels(): number;
  80538. set barOffset(value: string | number);
  80539. /** Gets or sets thumb width */
  80540. get thumbWidth(): string | number;
  80541. /** Gets thumb width in pixels */
  80542. get thumbWidthInPixels(): number;
  80543. set thumbWidth(value: string | number);
  80544. /** Gets or sets minimum value */
  80545. get minimum(): number;
  80546. set minimum(value: number);
  80547. /** Gets or sets maximum value */
  80548. get maximum(): number;
  80549. set maximum(value: number);
  80550. /** Gets or sets current value */
  80551. get value(): number;
  80552. set value(value: number);
  80553. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80554. get isVertical(): boolean;
  80555. set isVertical(value: boolean);
  80556. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80557. get isThumbClamped(): boolean;
  80558. set isThumbClamped(value: boolean);
  80559. /**
  80560. * Creates a new BaseSlider
  80561. * @param name defines the control name
  80562. */
  80563. constructor(name?: string | undefined);
  80564. protected _getTypeName(): string;
  80565. protected _getThumbPosition(): number;
  80566. protected _getThumbThickness(type: string): number;
  80567. protected _prepareRenderingData(type: string): void;
  80568. private _pointerIsDown;
  80569. /** @hidden */
  80570. protected _updateValueFromPointer(x: number, y: number): void;
  80571. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80572. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80573. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80574. _onCanvasBlur(): void;
  80575. }
  80576. }
  80577. declare module BABYLON.GUI {
  80578. /**
  80579. * Class used to create slider controls
  80580. */
  80581. export class Slider extends BaseSlider {
  80582. name?: string | undefined;
  80583. private _background;
  80584. private _borderColor;
  80585. private _thumbColor;
  80586. private _isThumbCircle;
  80587. protected _displayValueBar: boolean;
  80588. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80589. get displayValueBar(): boolean;
  80590. set displayValueBar(value: boolean);
  80591. /** Gets or sets border color */
  80592. get borderColor(): string;
  80593. set borderColor(value: string);
  80594. /** Gets or sets background color */
  80595. get background(): string;
  80596. set background(value: string);
  80597. /** Gets or sets thumb's color */
  80598. get thumbColor(): string;
  80599. set thumbColor(value: string);
  80600. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80601. get isThumbCircle(): boolean;
  80602. set isThumbCircle(value: boolean);
  80603. /**
  80604. * Creates a new Slider
  80605. * @param name defines the control name
  80606. */
  80607. constructor(name?: string | undefined);
  80608. protected _getTypeName(): string;
  80609. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80610. }
  80611. }
  80612. declare module BABYLON.GUI {
  80613. /** Class used to create a RadioGroup
  80614. * which contains groups of radio buttons
  80615. */
  80616. export class SelectorGroup {
  80617. /** name of SelectorGroup */
  80618. name: string;
  80619. private _groupPanel;
  80620. private _selectors;
  80621. private _groupHeader;
  80622. /**
  80623. * Creates a new SelectorGroup
  80624. * @param name of group, used as a group heading
  80625. */
  80626. constructor(
  80627. /** name of SelectorGroup */
  80628. name: string);
  80629. /** Gets the groupPanel of the SelectorGroup */
  80630. get groupPanel(): StackPanel;
  80631. /** Gets the selectors array */
  80632. get selectors(): StackPanel[];
  80633. /** Gets and sets the group header */
  80634. get header(): string;
  80635. set header(label: string);
  80636. /** @hidden */
  80637. private _addGroupHeader;
  80638. /** @hidden*/
  80639. _getSelector(selectorNb: number): StackPanel | undefined;
  80640. /** Removes the selector at the given position
  80641. * @param selectorNb the position of the selector within the group
  80642. */
  80643. removeSelector(selectorNb: number): void;
  80644. }
  80645. /** Class used to create a CheckboxGroup
  80646. * which contains groups of checkbox buttons
  80647. */
  80648. export class CheckboxGroup extends SelectorGroup {
  80649. /** Adds a checkbox as a control
  80650. * @param text is the label for the selector
  80651. * @param func is the function called when the Selector is checked
  80652. * @param checked is true when Selector is checked
  80653. */
  80654. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80655. /** @hidden */
  80656. _setSelectorLabel(selectorNb: number, label: string): void;
  80657. /** @hidden */
  80658. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80659. /** @hidden */
  80660. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80661. /** @hidden */
  80662. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80663. }
  80664. /** Class used to create a RadioGroup
  80665. * which contains groups of radio buttons
  80666. */
  80667. export class RadioGroup extends SelectorGroup {
  80668. private _selectNb;
  80669. /** Adds a radio button as a control
  80670. * @param label is the label for the selector
  80671. * @param func is the function called when the Selector is checked
  80672. * @param checked is true when Selector is checked
  80673. */
  80674. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80675. /** @hidden */
  80676. _setSelectorLabel(selectorNb: number, label: string): void;
  80677. /** @hidden */
  80678. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80679. /** @hidden */
  80680. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80681. /** @hidden */
  80682. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80683. }
  80684. /** Class used to create a SliderGroup
  80685. * which contains groups of slider buttons
  80686. */
  80687. export class SliderGroup extends SelectorGroup {
  80688. /**
  80689. * Adds a slider to the SelectorGroup
  80690. * @param label is the label for the SliderBar
  80691. * @param func is the function called when the Slider moves
  80692. * @param unit is a string describing the units used, eg degrees or metres
  80693. * @param min is the minimum value for the Slider
  80694. * @param max is the maximum value for the Slider
  80695. * @param value is the start value for the Slider between min and max
  80696. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80697. */
  80698. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80699. /** @hidden */
  80700. _setSelectorLabel(selectorNb: number, label: string): void;
  80701. /** @hidden */
  80702. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80703. /** @hidden */
  80704. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80705. /** @hidden */
  80706. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80707. }
  80708. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80709. * @see https://doc.babylonjs.com/how_to/selector
  80710. */
  80711. export class SelectionPanel extends Rectangle {
  80712. /** name of SelectionPanel */
  80713. name: string;
  80714. /** an array of SelectionGroups */
  80715. groups: SelectorGroup[];
  80716. private _panel;
  80717. private _buttonColor;
  80718. private _buttonBackground;
  80719. private _headerColor;
  80720. private _barColor;
  80721. private _barHeight;
  80722. private _spacerHeight;
  80723. private _labelColor;
  80724. private _groups;
  80725. private _bars;
  80726. /**
  80727. * Creates a new SelectionPanel
  80728. * @param name of SelectionPanel
  80729. * @param groups is an array of SelectionGroups
  80730. */
  80731. constructor(
  80732. /** name of SelectionPanel */
  80733. name: string,
  80734. /** an array of SelectionGroups */
  80735. groups?: SelectorGroup[]);
  80736. protected _getTypeName(): string;
  80737. /** Gets the (stack) panel of the SelectionPanel */
  80738. get panel(): StackPanel;
  80739. /** Gets or sets the headerColor */
  80740. get headerColor(): string;
  80741. set headerColor(color: string);
  80742. private _setHeaderColor;
  80743. /** Gets or sets the button color */
  80744. get buttonColor(): string;
  80745. set buttonColor(color: string);
  80746. private _setbuttonColor;
  80747. /** Gets or sets the label color */
  80748. get labelColor(): string;
  80749. set labelColor(color: string);
  80750. private _setLabelColor;
  80751. /** Gets or sets the button background */
  80752. get buttonBackground(): string;
  80753. set buttonBackground(color: string);
  80754. private _setButtonBackground;
  80755. /** Gets or sets the color of separator bar */
  80756. get barColor(): string;
  80757. set barColor(color: string);
  80758. private _setBarColor;
  80759. /** Gets or sets the height of separator bar */
  80760. get barHeight(): string;
  80761. set barHeight(value: string);
  80762. private _setBarHeight;
  80763. /** Gets or sets the height of spacers*/
  80764. get spacerHeight(): string;
  80765. set spacerHeight(value: string);
  80766. private _setSpacerHeight;
  80767. /** Adds a bar between groups */
  80768. private _addSpacer;
  80769. /** Add a group to the selection panel
  80770. * @param group is the selector group to add
  80771. */
  80772. addGroup(group: SelectorGroup): void;
  80773. /** Remove the group from the given position
  80774. * @param groupNb is the position of the group in the list
  80775. */
  80776. removeGroup(groupNb: number): void;
  80777. /** Change a group header label
  80778. * @param label is the new group header label
  80779. * @param groupNb is the number of the group to relabel
  80780. * */
  80781. setHeaderName(label: string, groupNb: number): void;
  80782. /** Change selector label to the one given
  80783. * @param label is the new selector label
  80784. * @param groupNb is the number of the groupcontaining the selector
  80785. * @param selectorNb is the number of the selector within a group to relabel
  80786. * */
  80787. relabel(label: string, groupNb: number, selectorNb: number): void;
  80788. /** For a given group position remove the selector at the given position
  80789. * @param groupNb is the number of the group to remove the selector from
  80790. * @param selectorNb is the number of the selector within the group
  80791. */
  80792. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80793. /** For a given group position of correct type add a checkbox button
  80794. * @param groupNb is the number of the group to remove the selector from
  80795. * @param label is the label for the selector
  80796. * @param func is the function called when the Selector is checked
  80797. * @param checked is true when Selector is checked
  80798. */
  80799. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80800. /** For a given group position of correct type add a radio button
  80801. * @param groupNb is the number of the group to remove the selector from
  80802. * @param label is the label for the selector
  80803. * @param func is the function called when the Selector is checked
  80804. * @param checked is true when Selector is checked
  80805. */
  80806. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80807. /**
  80808. * For a given slider group add a slider
  80809. * @param groupNb is the number of the group to add the slider to
  80810. * @param label is the label for the Slider
  80811. * @param func is the function called when the Slider moves
  80812. * @param unit is a string describing the units used, eg degrees or metres
  80813. * @param min is the minimum value for the Slider
  80814. * @param max is the maximum value for the Slider
  80815. * @param value is the start value for the Slider between min and max
  80816. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80817. */
  80818. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80819. }
  80820. }
  80821. declare module BABYLON.GUI {
  80822. /**
  80823. * Class used to hold a the container for ScrollViewer
  80824. * @hidden
  80825. */
  80826. export class _ScrollViewerWindow extends Container {
  80827. parentClientWidth: number;
  80828. parentClientHeight: number;
  80829. private _freezeControls;
  80830. private _parentMeasure;
  80831. private _oldLeft;
  80832. private _oldTop;
  80833. get freezeControls(): boolean;
  80834. set freezeControls(value: boolean);
  80835. private _bucketWidth;
  80836. private _bucketHeight;
  80837. private _buckets;
  80838. private _bucketLen;
  80839. get bucketWidth(): number;
  80840. get bucketHeight(): number;
  80841. setBucketSizes(width: number, height: number): void;
  80842. private _useBuckets;
  80843. private _makeBuckets;
  80844. private _dispatchInBuckets;
  80845. private _updateMeasures;
  80846. private _updateChildrenMeasures;
  80847. private _restoreMeasures;
  80848. /**
  80849. * Creates a new ScrollViewerWindow
  80850. * @param name of ScrollViewerWindow
  80851. */
  80852. constructor(name?: string);
  80853. protected _getTypeName(): string;
  80854. /** @hidden */
  80855. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80856. /** @hidden */
  80857. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80858. private _scrollChildren;
  80859. private _scrollChildrenWithBuckets;
  80860. /** @hidden */
  80861. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80862. protected _postMeasure(): void;
  80863. }
  80864. }
  80865. declare module BABYLON.GUI {
  80866. /**
  80867. * Class used to create slider controls
  80868. */
  80869. export class ScrollBar extends BaseSlider {
  80870. name?: string | undefined;
  80871. private _background;
  80872. private _borderColor;
  80873. private _tempMeasure;
  80874. /** Gets or sets border color */
  80875. get borderColor(): string;
  80876. set borderColor(value: string);
  80877. /** Gets or sets background color */
  80878. get background(): string;
  80879. set background(value: string);
  80880. /**
  80881. * Creates a new Slider
  80882. * @param name defines the control name
  80883. */
  80884. constructor(name?: string | undefined);
  80885. protected _getTypeName(): string;
  80886. protected _getThumbThickness(): number;
  80887. _draw(context: CanvasRenderingContext2D): void;
  80888. private _first;
  80889. private _originX;
  80890. private _originY;
  80891. /** @hidden */
  80892. protected _updateValueFromPointer(x: number, y: number): void;
  80893. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80894. }
  80895. }
  80896. declare module BABYLON.GUI {
  80897. /**
  80898. * Class used to create slider controls
  80899. */
  80900. export class ImageScrollBar extends BaseSlider {
  80901. name?: string | undefined;
  80902. private _backgroundBaseImage;
  80903. private _backgroundImage;
  80904. private _thumbImage;
  80905. private _thumbBaseImage;
  80906. private _thumbLength;
  80907. private _thumbHeight;
  80908. private _barImageHeight;
  80909. private _tempMeasure;
  80910. /** Number of 90° rotation to apply on the images when in vertical mode */
  80911. num90RotationInVerticalMode: number;
  80912. /**
  80913. * Gets or sets the image used to render the background for horizontal bar
  80914. */
  80915. get backgroundImage(): Image;
  80916. set backgroundImage(value: Image);
  80917. /**
  80918. * Gets or sets the image used to render the thumb
  80919. */
  80920. get thumbImage(): Image;
  80921. set thumbImage(value: Image);
  80922. /**
  80923. * Gets or sets the length of the thumb
  80924. */
  80925. get thumbLength(): number;
  80926. set thumbLength(value: number);
  80927. /**
  80928. * Gets or sets the height of the thumb
  80929. */
  80930. get thumbHeight(): number;
  80931. set thumbHeight(value: number);
  80932. /**
  80933. * Gets or sets the height of the bar image
  80934. */
  80935. get barImageHeight(): number;
  80936. set barImageHeight(value: number);
  80937. /**
  80938. * Creates a new ImageScrollBar
  80939. * @param name defines the control name
  80940. */
  80941. constructor(name?: string | undefined);
  80942. protected _getTypeName(): string;
  80943. protected _getThumbThickness(): number;
  80944. _draw(context: CanvasRenderingContext2D): void;
  80945. private _first;
  80946. private _originX;
  80947. private _originY;
  80948. /** @hidden */
  80949. protected _updateValueFromPointer(x: number, y: number): void;
  80950. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80951. }
  80952. }
  80953. declare module BABYLON.GUI {
  80954. /**
  80955. * Class used to hold a viewer window and sliders in a grid
  80956. */
  80957. export class ScrollViewer extends Rectangle {
  80958. private _grid;
  80959. private _horizontalBarSpace;
  80960. private _verticalBarSpace;
  80961. private _dragSpace;
  80962. private _horizontalBar;
  80963. private _verticalBar;
  80964. private _barColor;
  80965. private _barBackground;
  80966. private _barImage;
  80967. private _horizontalBarImage;
  80968. private _verticalBarImage;
  80969. private _barBackgroundImage;
  80970. private _horizontalBarBackgroundImage;
  80971. private _verticalBarBackgroundImage;
  80972. private _barSize;
  80973. private _window;
  80974. private _pointerIsOver;
  80975. private _wheelPrecision;
  80976. private _onWheelObserver;
  80977. private _clientWidth;
  80978. private _clientHeight;
  80979. private _useImageBar;
  80980. private _thumbLength;
  80981. private _thumbHeight;
  80982. private _barImageHeight;
  80983. private _horizontalBarImageHeight;
  80984. private _verticalBarImageHeight;
  80985. private _oldWindowContentsWidth;
  80986. private _oldWindowContentsHeight;
  80987. /**
  80988. * Gets the horizontal scrollbar
  80989. */
  80990. get horizontalBar(): ScrollBar | ImageScrollBar;
  80991. /**
  80992. * Gets the vertical scrollbar
  80993. */
  80994. get verticalBar(): ScrollBar | ImageScrollBar;
  80995. /**
  80996. * Adds a new control to the current container
  80997. * @param control defines the control to add
  80998. * @returns the current container
  80999. */
  81000. addControl(control: BABYLON.Nullable<Control>): Container;
  81001. /**
  81002. * Removes a control from the current container
  81003. * @param control defines the control to remove
  81004. * @returns the current container
  81005. */
  81006. removeControl(control: Control): Container;
  81007. /** Gets the list of children */
  81008. get children(): Control[];
  81009. _flagDescendantsAsMatrixDirty(): void;
  81010. /**
  81011. * Freezes or unfreezes the controls in the window.
  81012. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  81013. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  81014. */
  81015. get freezeControls(): boolean;
  81016. set freezeControls(value: boolean);
  81017. /** Gets the bucket width */
  81018. get bucketWidth(): number;
  81019. /** Gets the bucket height */
  81020. get bucketHeight(): number;
  81021. /**
  81022. * Sets the bucket sizes.
  81023. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  81024. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  81025. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  81026. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  81027. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  81028. * used), that's why it is not enabled by default.
  81029. * @param width width of the bucket
  81030. * @param height height of the bucket
  81031. */
  81032. setBucketSizes(width: number, height: number): void;
  81033. private _forceHorizontalBar;
  81034. private _forceVerticalBar;
  81035. /**
  81036. * Forces the horizontal scroll bar to be displayed
  81037. */
  81038. get forceHorizontalBar(): boolean;
  81039. set forceHorizontalBar(value: boolean);
  81040. /**
  81041. * Forces the vertical scroll bar to be displayed
  81042. */
  81043. get forceVerticalBar(): boolean;
  81044. set forceVerticalBar(value: boolean);
  81045. /**
  81046. * Creates a new ScrollViewer
  81047. * @param name of ScrollViewer
  81048. */
  81049. constructor(name?: string, isImageBased?: boolean);
  81050. /** Reset the scroll viewer window to initial size */
  81051. resetWindow(): void;
  81052. protected _getTypeName(): string;
  81053. private _buildClientSizes;
  81054. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81055. protected _postMeasure(): void;
  81056. /**
  81057. * Gets or sets the mouse wheel precision
  81058. * from 0 to 1 with a default value of 0.05
  81059. * */
  81060. get wheelPrecision(): number;
  81061. set wheelPrecision(value: number);
  81062. /** Gets or sets the scroll bar container background color */
  81063. get scrollBackground(): string;
  81064. set scrollBackground(color: string);
  81065. /** Gets or sets the bar color */
  81066. get barColor(): string;
  81067. set barColor(color: string);
  81068. /** Gets or sets the bar image */
  81069. get thumbImage(): Image;
  81070. set thumbImage(value: Image);
  81071. /** Gets or sets the horizontal bar image */
  81072. get horizontalThumbImage(): Image;
  81073. set horizontalThumbImage(value: Image);
  81074. /** Gets or sets the vertical bar image */
  81075. get verticalThumbImage(): Image;
  81076. set verticalThumbImage(value: Image);
  81077. /** Gets or sets the size of the bar */
  81078. get barSize(): number;
  81079. set barSize(value: number);
  81080. /** Gets or sets the length of the thumb */
  81081. get thumbLength(): number;
  81082. set thumbLength(value: number);
  81083. /** Gets or sets the height of the thumb */
  81084. get thumbHeight(): number;
  81085. set thumbHeight(value: number);
  81086. /** Gets or sets the height of the bar image */
  81087. get barImageHeight(): number;
  81088. set barImageHeight(value: number);
  81089. /** Gets or sets the height of the horizontal bar image */
  81090. get horizontalBarImageHeight(): number;
  81091. set horizontalBarImageHeight(value: number);
  81092. /** Gets or sets the height of the vertical bar image */
  81093. get verticalBarImageHeight(): number;
  81094. set verticalBarImageHeight(value: number);
  81095. /** Gets or sets the bar background */
  81096. get barBackground(): string;
  81097. set barBackground(color: string);
  81098. /** Gets or sets the bar background image */
  81099. get barImage(): Image;
  81100. set barImage(value: Image);
  81101. /** Gets or sets the horizontal bar background image */
  81102. get horizontalBarImage(): Image;
  81103. set horizontalBarImage(value: Image);
  81104. /** Gets or sets the vertical bar background image */
  81105. get verticalBarImage(): Image;
  81106. set verticalBarImage(value: Image);
  81107. private _setWindowPosition;
  81108. /** @hidden */
  81109. private _updateScroller;
  81110. _link(host: AdvancedDynamicTexture): void;
  81111. /** @hidden */
  81112. private _addBar;
  81113. /** @hidden */
  81114. private _attachWheel;
  81115. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  81116. /** Releases associated resources */
  81117. dispose(): void;
  81118. }
  81119. }
  81120. declare module BABYLON.GUI {
  81121. /** Class used to render a grid */
  81122. export class DisplayGrid extends Control {
  81123. name?: string | undefined;
  81124. private _cellWidth;
  81125. private _cellHeight;
  81126. private _minorLineTickness;
  81127. private _minorLineColor;
  81128. private _majorLineTickness;
  81129. private _majorLineColor;
  81130. private _majorLineFrequency;
  81131. private _background;
  81132. private _displayMajorLines;
  81133. private _displayMinorLines;
  81134. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  81135. get displayMinorLines(): boolean;
  81136. set displayMinorLines(value: boolean);
  81137. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  81138. get displayMajorLines(): boolean;
  81139. set displayMajorLines(value: boolean);
  81140. /** Gets or sets background color (Black by default) */
  81141. get background(): string;
  81142. set background(value: string);
  81143. /** Gets or sets the width of each cell (20 by default) */
  81144. get cellWidth(): number;
  81145. set cellWidth(value: number);
  81146. /** Gets or sets the height of each cell (20 by default) */
  81147. get cellHeight(): number;
  81148. set cellHeight(value: number);
  81149. /** Gets or sets the tickness of minor lines (1 by default) */
  81150. get minorLineTickness(): number;
  81151. set minorLineTickness(value: number);
  81152. /** Gets or sets the color of minor lines (DarkGray by default) */
  81153. get minorLineColor(): string;
  81154. set minorLineColor(value: string);
  81155. /** Gets or sets the tickness of major lines (2 by default) */
  81156. get majorLineTickness(): number;
  81157. set majorLineTickness(value: number);
  81158. /** Gets or sets the color of major lines (White by default) */
  81159. get majorLineColor(): string;
  81160. set majorLineColor(value: string);
  81161. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  81162. get majorLineFrequency(): number;
  81163. set majorLineFrequency(value: number);
  81164. /**
  81165. * Creates a new GridDisplayRectangle
  81166. * @param name defines the control name
  81167. */
  81168. constructor(name?: string | undefined);
  81169. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81170. protected _getTypeName(): string;
  81171. }
  81172. }
  81173. declare module BABYLON.GUI {
  81174. /**
  81175. * Class used to create slider controls based on images
  81176. */
  81177. export class ImageBasedSlider extends BaseSlider {
  81178. name?: string | undefined;
  81179. private _backgroundImage;
  81180. private _thumbImage;
  81181. private _valueBarImage;
  81182. private _tempMeasure;
  81183. get displayThumb(): boolean;
  81184. set displayThumb(value: boolean);
  81185. /**
  81186. * Gets or sets the image used to render the background
  81187. */
  81188. get backgroundImage(): Image;
  81189. set backgroundImage(value: Image);
  81190. /**
  81191. * Gets or sets the image used to render the value bar
  81192. */
  81193. get valueBarImage(): Image;
  81194. set valueBarImage(value: Image);
  81195. /**
  81196. * Gets or sets the image used to render the thumb
  81197. */
  81198. get thumbImage(): Image;
  81199. set thumbImage(value: Image);
  81200. /**
  81201. * Creates a new ImageBasedSlider
  81202. * @param name defines the control name
  81203. */
  81204. constructor(name?: string | undefined);
  81205. protected _getTypeName(): string;
  81206. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81207. }
  81208. }
  81209. declare module BABYLON.GUI {
  81210. /**
  81211. * Forcing an export so that this code will execute
  81212. * @hidden
  81213. */
  81214. const name = "Statics";
  81215. }
  81216. declare module BABYLON.GUI {
  81217. /**
  81218. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  81219. */
  81220. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  81221. /**
  81222. * Define the instrumented AdvancedDynamicTexture.
  81223. */
  81224. texture: AdvancedDynamicTexture;
  81225. private _captureRenderTime;
  81226. private _renderTime;
  81227. private _captureLayoutTime;
  81228. private _layoutTime;
  81229. private _onBeginRenderObserver;
  81230. private _onEndRenderObserver;
  81231. private _onBeginLayoutObserver;
  81232. private _onEndLayoutObserver;
  81233. /**
  81234. * Gets the perf counter used to capture render time
  81235. */
  81236. get renderTimeCounter(): BABYLON.PerfCounter;
  81237. /**
  81238. * Gets the perf counter used to capture layout time
  81239. */
  81240. get layoutTimeCounter(): BABYLON.PerfCounter;
  81241. /**
  81242. * Enable or disable the render time capture
  81243. */
  81244. get captureRenderTime(): boolean;
  81245. set captureRenderTime(value: boolean);
  81246. /**
  81247. * Enable or disable the layout time capture
  81248. */
  81249. get captureLayoutTime(): boolean;
  81250. set captureLayoutTime(value: boolean);
  81251. /**
  81252. * Instantiates a new advanced dynamic texture instrumentation.
  81253. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  81254. * @param texture Defines the AdvancedDynamicTexture to instrument
  81255. */
  81256. constructor(
  81257. /**
  81258. * Define the instrumented AdvancedDynamicTexture.
  81259. */
  81260. texture: AdvancedDynamicTexture);
  81261. /**
  81262. * Dispose and release associated resources.
  81263. */
  81264. dispose(): void;
  81265. }
  81266. }
  81267. declare module BABYLON.GUI {
  81268. /**
  81269. * Class used to load GUI via XML.
  81270. */
  81271. export class XmlLoader {
  81272. private _nodes;
  81273. private _nodeTypes;
  81274. private _isLoaded;
  81275. private _objectAttributes;
  81276. private _parentClass;
  81277. /**
  81278. * Create a new xml loader
  81279. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  81280. */
  81281. constructor(parentClass?: null);
  81282. private _getChainElement;
  81283. private _getClassAttribute;
  81284. private _createGuiElement;
  81285. private _parseGrid;
  81286. private _parseElement;
  81287. private _prepareSourceElement;
  81288. private _parseElementsFromSource;
  81289. private _parseXml;
  81290. /**
  81291. * Gets if the loading has finished.
  81292. * @returns whether the loading has finished or not
  81293. */
  81294. isLoaded(): boolean;
  81295. /**
  81296. * Gets a loaded node / control by id.
  81297. * @param id the Controls id set in the xml
  81298. * @returns element of type Control
  81299. */
  81300. getNodeById(id: string): any;
  81301. /**
  81302. * Gets all loaded nodes / controls
  81303. * @returns Array of controls
  81304. */
  81305. getNodes(): any;
  81306. /**
  81307. * Initiates the xml layout loading
  81308. * @param xmlFile defines the xml layout to load
  81309. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81310. * @param callback defines the callback called on layout load.
  81311. */
  81312. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81313. }
  81314. }
  81315. declare module BABYLON.GUI {
  81316. /**
  81317. * Class used to create containers for controls
  81318. */
  81319. export class Container3D extends Control3D {
  81320. private _blockLayout;
  81321. /**
  81322. * Gets the list of child controls
  81323. */
  81324. protected _children: Control3D[];
  81325. /**
  81326. * Gets the list of child controls
  81327. */
  81328. get children(): Array<Control3D>;
  81329. /**
  81330. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81331. * This is helpful to optimize layout operation when adding multiple children in a row
  81332. */
  81333. get blockLayout(): boolean;
  81334. set blockLayout(value: boolean);
  81335. /**
  81336. * Creates a new container
  81337. * @param name defines the container name
  81338. */
  81339. constructor(name?: string);
  81340. /**
  81341. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81342. * @returns the current container
  81343. */
  81344. updateLayout(): Container3D;
  81345. /**
  81346. * Gets a boolean indicating if the given control is in the children of this control
  81347. * @param control defines the control to check
  81348. * @returns true if the control is in the child list
  81349. */
  81350. containsControl(control: Control3D): boolean;
  81351. /**
  81352. * Adds a control to the children of this control
  81353. * @param control defines the control to add
  81354. * @returns the current container
  81355. */
  81356. addControl(control: Control3D): Container3D;
  81357. /**
  81358. * This function will be called everytime a new control is added
  81359. */
  81360. protected _arrangeChildren(): void;
  81361. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81362. /**
  81363. * Removes a control from the children of this control
  81364. * @param control defines the control to remove
  81365. * @returns the current container
  81366. */
  81367. removeControl(control: Control3D): Container3D;
  81368. protected _getTypeName(): string;
  81369. /**
  81370. * Releases all associated resources
  81371. */
  81372. dispose(): void;
  81373. /** Control rotation will remain unchanged */
  81374. static readonly UNSET_ORIENTATION: number;
  81375. /** Control will rotate to make it look at sphere central axis */
  81376. static readonly FACEORIGIN_ORIENTATION: number;
  81377. /** Control will rotate to make it look back at sphere central axis */
  81378. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81379. /** Control will rotate to look at z axis (0, 0, 1) */
  81380. static readonly FACEFORWARD_ORIENTATION: number;
  81381. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81382. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81383. }
  81384. }
  81385. declare module BABYLON.GUI {
  81386. /**
  81387. * Class used to manage 3D user interface
  81388. * @see https://doc.babylonjs.com/how_to/gui3d
  81389. */
  81390. export class GUI3DManager implements BABYLON.IDisposable {
  81391. private _scene;
  81392. private _sceneDisposeObserver;
  81393. private _utilityLayer;
  81394. private _rootContainer;
  81395. private _pointerObserver;
  81396. private _pointerOutObserver;
  81397. /** @hidden */
  81398. _lastPickedControl: Control3D;
  81399. /** @hidden */
  81400. _lastControlOver: {
  81401. [pointerId: number]: Control3D;
  81402. };
  81403. /** @hidden */
  81404. _lastControlDown: {
  81405. [pointerId: number]: Control3D;
  81406. };
  81407. /**
  81408. * BABYLON.Observable raised when the point picked by the pointer events changed
  81409. */
  81410. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81411. /** @hidden */
  81412. _sharedMaterials: {
  81413. [key: string]: BABYLON.Material;
  81414. };
  81415. /** Gets the hosting scene */
  81416. get scene(): BABYLON.Scene;
  81417. /** Gets associated utility layer */
  81418. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81419. /**
  81420. * Creates a new GUI3DManager
  81421. * @param scene
  81422. */
  81423. constructor(scene?: BABYLON.Scene);
  81424. private _handlePointerOut;
  81425. private _doPicking;
  81426. /**
  81427. * Gets the root container
  81428. */
  81429. get rootContainer(): Container3D;
  81430. /**
  81431. * Gets a boolean indicating if the given control is in the root child list
  81432. * @param control defines the control to check
  81433. * @returns true if the control is in the root child list
  81434. */
  81435. containsControl(control: Control3D): boolean;
  81436. /**
  81437. * Adds a control to the root child list
  81438. * @param control defines the control to add
  81439. * @returns the current manager
  81440. */
  81441. addControl(control: Control3D): GUI3DManager;
  81442. /**
  81443. * Removes a control from the root child list
  81444. * @param control defines the control to remove
  81445. * @returns the current container
  81446. */
  81447. removeControl(control: Control3D): GUI3DManager;
  81448. /**
  81449. * Releases all associated resources
  81450. */
  81451. dispose(): void;
  81452. }
  81453. }
  81454. declare module BABYLON.GUI {
  81455. /**
  81456. * Class used to transport BABYLON.Vector3 information for pointer events
  81457. */
  81458. export class Vector3WithInfo extends BABYLON.Vector3 {
  81459. /** defines the current mouse button index */
  81460. buttonIndex: number;
  81461. /**
  81462. * Creates a new Vector3WithInfo
  81463. * @param source defines the vector3 data to transport
  81464. * @param buttonIndex defines the current mouse button index
  81465. */
  81466. constructor(source: BABYLON.Vector3,
  81467. /** defines the current mouse button index */
  81468. buttonIndex?: number);
  81469. }
  81470. }
  81471. declare module BABYLON.GUI {
  81472. /**
  81473. * Class used as base class for controls
  81474. */
  81475. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81476. /** Defines the control name */
  81477. name?: string | undefined;
  81478. /** @hidden */
  81479. _host: GUI3DManager;
  81480. private _node;
  81481. private _downCount;
  81482. private _enterCount;
  81483. private _downPointerIds;
  81484. private _isVisible;
  81485. /** Gets or sets the control position in world space */
  81486. get position(): BABYLON.Vector3;
  81487. set position(value: BABYLON.Vector3);
  81488. /** Gets or sets the control scaling in world space */
  81489. get scaling(): BABYLON.Vector3;
  81490. set scaling(value: BABYLON.Vector3);
  81491. /** Callback used to start pointer enter animation */
  81492. pointerEnterAnimation: () => void;
  81493. /** Callback used to start pointer out animation */
  81494. pointerOutAnimation: () => void;
  81495. /** Callback used to start pointer down animation */
  81496. pointerDownAnimation: () => void;
  81497. /** Callback used to start pointer up animation */
  81498. pointerUpAnimation: () => void;
  81499. /**
  81500. * An event triggered when the pointer move over the control
  81501. */
  81502. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81503. /**
  81504. * An event triggered when the pointer move out of the control
  81505. */
  81506. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81507. /**
  81508. * An event triggered when the pointer taps the control
  81509. */
  81510. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81511. /**
  81512. * An event triggered when pointer is up
  81513. */
  81514. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81515. /**
  81516. * An event triggered when a control is clicked on (with a mouse)
  81517. */
  81518. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81519. /**
  81520. * An event triggered when pointer enters the control
  81521. */
  81522. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81523. /**
  81524. * Gets or sets the parent container
  81525. */
  81526. parent: BABYLON.Nullable<Container3D>;
  81527. private _behaviors;
  81528. /**
  81529. * Gets the list of attached behaviors
  81530. * @see https://doc.babylonjs.com/features/behaviour
  81531. */
  81532. get behaviors(): BABYLON.Behavior<Control3D>[];
  81533. /**
  81534. * Attach a behavior to the control
  81535. * @see https://doc.babylonjs.com/features/behaviour
  81536. * @param behavior defines the behavior to attach
  81537. * @returns the current control
  81538. */
  81539. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81540. /**
  81541. * Remove an attached behavior
  81542. * @see https://doc.babylonjs.com/features/behaviour
  81543. * @param behavior defines the behavior to attach
  81544. * @returns the current control
  81545. */
  81546. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81547. /**
  81548. * Gets an attached behavior by name
  81549. * @param name defines the name of the behavior to look for
  81550. * @see https://doc.babylonjs.com/features/behaviour
  81551. * @returns null if behavior was not found else the requested behavior
  81552. */
  81553. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81554. /** Gets or sets a boolean indicating if the control is visible */
  81555. get isVisible(): boolean;
  81556. set isVisible(value: boolean);
  81557. /**
  81558. * Creates a new control
  81559. * @param name defines the control name
  81560. */
  81561. constructor(
  81562. /** Defines the control name */
  81563. name?: string | undefined);
  81564. /**
  81565. * Gets a string representing the class name
  81566. */
  81567. get typeName(): string;
  81568. /**
  81569. * Get the current class name of the control.
  81570. * @returns current class name
  81571. */
  81572. getClassName(): string;
  81573. protected _getTypeName(): string;
  81574. /**
  81575. * Gets the transform node used by this control
  81576. */
  81577. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81578. /**
  81579. * Gets the mesh used to render this control
  81580. */
  81581. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81582. /**
  81583. * Link the control as child of the given node
  81584. * @param node defines the node to link to. Use null to unlink the control
  81585. * @returns the current control
  81586. */
  81587. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81588. /** @hidden **/
  81589. _prepareNode(scene: BABYLON.Scene): void;
  81590. /**
  81591. * Node creation.
  81592. * Can be overriden by children
  81593. * @param scene defines the scene where the node must be attached
  81594. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81595. */
  81596. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81597. /**
  81598. * Affect a material to the given mesh
  81599. * @param mesh defines the mesh which will represent the control
  81600. */
  81601. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81602. /** @hidden */
  81603. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81604. /** @hidden */
  81605. _onPointerEnter(target: Control3D): boolean;
  81606. /** @hidden */
  81607. _onPointerOut(target: Control3D): void;
  81608. /** @hidden */
  81609. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81610. /** @hidden */
  81611. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81612. /** @hidden */
  81613. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81614. /** @hidden */
  81615. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81616. /** @hidden */
  81617. _disposeNode(): void;
  81618. /**
  81619. * Releases all associated resources
  81620. */
  81621. dispose(): void;
  81622. }
  81623. }
  81624. declare module BABYLON.GUI {
  81625. /**
  81626. * Class used as a root to all buttons
  81627. */
  81628. export class AbstractButton3D extends Control3D {
  81629. /**
  81630. * Creates a new button
  81631. * @param name defines the control name
  81632. */
  81633. constructor(name?: string);
  81634. protected _getTypeName(): string;
  81635. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81636. }
  81637. }
  81638. declare module BABYLON.GUI {
  81639. /**
  81640. * Class used to create a button in 3D
  81641. */
  81642. export class Button3D extends AbstractButton3D {
  81643. /** @hidden */
  81644. protected _currentMaterial: BABYLON.Material;
  81645. private _facadeTexture;
  81646. private _content;
  81647. private _contentResolution;
  81648. private _contentScaleRatio;
  81649. /**
  81650. * Gets or sets the texture resolution used to render content (512 by default)
  81651. */
  81652. get contentResolution(): BABYLON.int;
  81653. set contentResolution(value: BABYLON.int);
  81654. /**
  81655. * Gets or sets the texture scale ratio used to render content (2 by default)
  81656. */
  81657. get contentScaleRatio(): number;
  81658. set contentScaleRatio(value: number);
  81659. protected _disposeFacadeTexture(): void;
  81660. protected _resetContent(): void;
  81661. /**
  81662. * Creates a new button
  81663. * @param name defines the control name
  81664. */
  81665. constructor(name?: string);
  81666. /**
  81667. * Gets or sets the GUI 2D content used to display the button's facade
  81668. */
  81669. get content(): Control;
  81670. set content(value: Control);
  81671. /**
  81672. * Apply the facade texture (created from the content property).
  81673. * This function can be overloaded by child classes
  81674. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81675. */
  81676. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81677. protected _getTypeName(): string;
  81678. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81679. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81680. /**
  81681. * Releases all associated resources
  81682. */
  81683. dispose(): void;
  81684. }
  81685. }
  81686. declare module BABYLON.GUI {
  81687. /**
  81688. * Abstract class used to create a container panel deployed on the surface of a volume
  81689. */
  81690. export abstract class VolumeBasedPanel extends Container3D {
  81691. private _columns;
  81692. private _rows;
  81693. private _rowThenColum;
  81694. private _orientation;
  81695. protected _cellWidth: number;
  81696. protected _cellHeight: number;
  81697. /**
  81698. * Gets or sets the distance between elements
  81699. */
  81700. margin: number;
  81701. /**
  81702. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81703. * | Value | Type | Description |
  81704. * | ----- | ----------------------------------- | ----------- |
  81705. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81706. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81707. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81708. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81709. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81710. */
  81711. get orientation(): number;
  81712. set orientation(value: number);
  81713. /**
  81714. * Gets or sets the number of columns requested (10 by default).
  81715. * The panel will automatically compute the number of rows based on number of child controls.
  81716. */
  81717. get columns(): BABYLON.int;
  81718. set columns(value: BABYLON.int);
  81719. /**
  81720. * Gets or sets a the number of rows requested.
  81721. * The panel will automatically compute the number of columns based on number of child controls.
  81722. */
  81723. get rows(): BABYLON.int;
  81724. set rows(value: BABYLON.int);
  81725. /**
  81726. * Creates new VolumeBasedPanel
  81727. */
  81728. constructor();
  81729. protected _arrangeChildren(): void;
  81730. /** Child classes must implement this function to provide correct control positioning */
  81731. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81732. /** Child classes can implement this function to provide additional processing */
  81733. protected _finalProcessing(): void;
  81734. }
  81735. }
  81736. declare module BABYLON.GUI {
  81737. /**
  81738. * Class used to create a container panel deployed on the surface of a cylinder
  81739. */
  81740. export class CylinderPanel extends VolumeBasedPanel {
  81741. private _radius;
  81742. /**
  81743. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81744. */
  81745. get radius(): BABYLON.float;
  81746. set radius(value: BABYLON.float);
  81747. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81748. private _cylindricalMapping;
  81749. }
  81750. }
  81751. declare module BABYLON.GUI {
  81752. /** @hidden */
  81753. export var fluentVertexShader: {
  81754. name: string;
  81755. shader: string;
  81756. };
  81757. }
  81758. declare module BABYLON.GUI {
  81759. /** @hidden */
  81760. export var fluentPixelShader: {
  81761. name: string;
  81762. shader: string;
  81763. };
  81764. }
  81765. declare module BABYLON.GUI {
  81766. /** @hidden */
  81767. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81768. INNERGLOW: boolean;
  81769. BORDER: boolean;
  81770. HOVERLIGHT: boolean;
  81771. TEXTURE: boolean;
  81772. constructor();
  81773. }
  81774. /**
  81775. * Class used to render controls with fluent desgin
  81776. */
  81777. export class FluentMaterial extends BABYLON.PushMaterial {
  81778. /**
  81779. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81780. */
  81781. innerGlowColorIntensity: number;
  81782. /**
  81783. * Gets or sets the inner glow color (white by default)
  81784. */
  81785. innerGlowColor: BABYLON.Color3;
  81786. /**
  81787. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81788. */
  81789. albedoColor: BABYLON.Color3;
  81790. /**
  81791. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81792. */
  81793. renderBorders: boolean;
  81794. /**
  81795. * Gets or sets border width (default is 0.5)
  81796. */
  81797. borderWidth: number;
  81798. /**
  81799. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81800. */
  81801. edgeSmoothingValue: number;
  81802. /**
  81803. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81804. */
  81805. borderMinValue: number;
  81806. /**
  81807. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81808. */
  81809. renderHoverLight: boolean;
  81810. /**
  81811. * Gets or sets the radius used to render the hover light (default is 1.0)
  81812. */
  81813. hoverRadius: number;
  81814. /**
  81815. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81816. */
  81817. hoverColor: BABYLON.Color4;
  81818. /**
  81819. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81820. */
  81821. hoverPosition: BABYLON.Vector3;
  81822. private _albedoTexture;
  81823. /** Gets or sets the texture to use for albedo color */
  81824. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81825. /**
  81826. * Creates a new Fluent material
  81827. * @param name defines the name of the material
  81828. * @param scene defines the hosting scene
  81829. */
  81830. constructor(name: string, scene: BABYLON.Scene);
  81831. needAlphaBlending(): boolean;
  81832. needAlphaTesting(): boolean;
  81833. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81834. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81835. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81836. getActiveTextures(): BABYLON.BaseTexture[];
  81837. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81838. dispose(forceDisposeEffect?: boolean): void;
  81839. clone(name: string): FluentMaterial;
  81840. serialize(): any;
  81841. getClassName(): string;
  81842. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81843. }
  81844. }
  81845. declare module BABYLON.GUI {
  81846. /**
  81847. * Class used to create a holographic button in 3D
  81848. */
  81849. export class HolographicButton extends Button3D {
  81850. private _backPlate;
  81851. private _textPlate;
  81852. private _frontPlate;
  81853. private _text;
  81854. private _imageUrl;
  81855. private _shareMaterials;
  81856. private _frontMaterial;
  81857. private _backMaterial;
  81858. private _plateMaterial;
  81859. private _pickedPointObserver;
  81860. private _tooltipFade;
  81861. private _tooltipTextBlock;
  81862. private _tooltipTexture;
  81863. private _tooltipMesh;
  81864. private _tooltipHoverObserver;
  81865. private _tooltipOutObserver;
  81866. private _disposeTooltip;
  81867. /**
  81868. * Rendering ground id of all the mesh in the button
  81869. */
  81870. set renderingGroupId(id: number);
  81871. get renderingGroupId(): number;
  81872. /**
  81873. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81874. */
  81875. set tooltipText(text: BABYLON.Nullable<string>);
  81876. get tooltipText(): BABYLON.Nullable<string>;
  81877. /**
  81878. * Gets or sets text for the button
  81879. */
  81880. get text(): string;
  81881. set text(value: string);
  81882. /**
  81883. * Gets or sets the image url for the button
  81884. */
  81885. get imageUrl(): string;
  81886. set imageUrl(value: string);
  81887. /**
  81888. * Gets the back material used by this button
  81889. */
  81890. get backMaterial(): FluentMaterial;
  81891. /**
  81892. * Gets the front material used by this button
  81893. */
  81894. get frontMaterial(): FluentMaterial;
  81895. /**
  81896. * Gets the plate material used by this button
  81897. */
  81898. get plateMaterial(): BABYLON.StandardMaterial;
  81899. /**
  81900. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81901. */
  81902. get shareMaterials(): boolean;
  81903. /**
  81904. * Creates a new button
  81905. * @param name defines the control name
  81906. */
  81907. constructor(name?: string, shareMaterials?: boolean);
  81908. protected _getTypeName(): string;
  81909. private _rebuildContent;
  81910. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81911. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81912. private _createBackMaterial;
  81913. private _createFrontMaterial;
  81914. private _createPlateMaterial;
  81915. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81916. /**
  81917. * Releases all associated resources
  81918. */
  81919. dispose(): void;
  81920. }
  81921. }
  81922. declare module BABYLON.GUI {
  81923. /**
  81924. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81925. */
  81926. export class MeshButton3D extends Button3D {
  81927. /** @hidden */
  81928. protected _currentMesh: BABYLON.Mesh;
  81929. /**
  81930. * Creates a new 3D button based on a mesh
  81931. * @param mesh mesh to become a 3D button
  81932. * @param name defines the control name
  81933. */
  81934. constructor(mesh: BABYLON.Mesh, name?: string);
  81935. protected _getTypeName(): string;
  81936. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81937. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81938. }
  81939. }
  81940. declare module BABYLON.GUI {
  81941. /**
  81942. * Class used to create a container panel deployed on the surface of a plane
  81943. */
  81944. export class PlanePanel extends VolumeBasedPanel {
  81945. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81946. }
  81947. }
  81948. declare module BABYLON.GUI {
  81949. /**
  81950. * Class used to create a container panel where items get randomized planar mapping
  81951. */
  81952. export class ScatterPanel extends VolumeBasedPanel {
  81953. private _iteration;
  81954. /**
  81955. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81956. */
  81957. get iteration(): BABYLON.float;
  81958. set iteration(value: BABYLON.float);
  81959. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81960. private _scatterMapping;
  81961. protected _finalProcessing(): void;
  81962. }
  81963. }
  81964. declare module BABYLON.GUI {
  81965. /**
  81966. * Class used to create a container panel deployed on the surface of a sphere
  81967. */
  81968. export class SpherePanel extends VolumeBasedPanel {
  81969. private _radius;
  81970. /**
  81971. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81972. */
  81973. get radius(): BABYLON.float;
  81974. set radius(value: BABYLON.float);
  81975. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81976. private _sphericalMapping;
  81977. }
  81978. }
  81979. declare module BABYLON.GUI {
  81980. /**
  81981. * Class used to create a stack panel in 3D on XY plane
  81982. */
  81983. export class StackPanel3D extends Container3D {
  81984. private _isVertical;
  81985. /**
  81986. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81987. */
  81988. get isVertical(): boolean;
  81989. set isVertical(value: boolean);
  81990. /**
  81991. * Gets or sets the distance between elements
  81992. */
  81993. margin: number;
  81994. /**
  81995. * Creates new StackPanel
  81996. * @param isVertical
  81997. */
  81998. constructor(isVertical?: boolean);
  81999. protected _arrangeChildren(): void;
  82000. }
  82001. }
  82002. declare module BABYLON {
  82003. /**
  82004. * Configuration for glTF validation
  82005. */
  82006. export interface IGLTFValidationConfiguration {
  82007. /**
  82008. * The url of the glTF validator.
  82009. */
  82010. url: string;
  82011. }
  82012. /**
  82013. * glTF validation
  82014. */
  82015. export class GLTFValidation {
  82016. /**
  82017. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  82018. */
  82019. static Configuration: IGLTFValidationConfiguration;
  82020. private static _LoadScriptPromise;
  82021. /**
  82022. * Validate a glTF asset using the glTF-Validator.
  82023. * @param data The JSON of a glTF or the array buffer of a binary glTF
  82024. * @param rootUrl The root url for the glTF
  82025. * @param fileName The file name for the glTF
  82026. * @param getExternalResource The callback to get external resources for the glTF validator
  82027. * @returns A promise that resolves with the glTF validation results once complete
  82028. */
  82029. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  82030. }
  82031. }
  82032. declare module BABYLON {
  82033. /**
  82034. * Mode that determines the coordinate system to use.
  82035. */
  82036. export enum GLTFLoaderCoordinateSystemMode {
  82037. /**
  82038. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  82039. */
  82040. AUTO = 0,
  82041. /**
  82042. * Sets the useRightHandedSystem flag on the scene.
  82043. */
  82044. FORCE_RIGHT_HANDED = 1
  82045. }
  82046. /**
  82047. * Mode that determines what animations will start.
  82048. */
  82049. export enum GLTFLoaderAnimationStartMode {
  82050. /**
  82051. * No animation will start.
  82052. */
  82053. NONE = 0,
  82054. /**
  82055. * The first animation will start.
  82056. */
  82057. FIRST = 1,
  82058. /**
  82059. * All animations will start.
  82060. */
  82061. ALL = 2
  82062. }
  82063. /**
  82064. * Interface that contains the data for the glTF asset.
  82065. */
  82066. export interface IGLTFLoaderData {
  82067. /**
  82068. * The object that represents the glTF JSON.
  82069. */
  82070. json: Object;
  82071. /**
  82072. * The BIN chunk of a binary glTF.
  82073. */
  82074. bin: Nullable<IDataBuffer>;
  82075. }
  82076. /**
  82077. * Interface for extending the loader.
  82078. */
  82079. export interface IGLTFLoaderExtension {
  82080. /**
  82081. * The name of this extension.
  82082. */
  82083. readonly name: string;
  82084. /**
  82085. * Defines whether this extension is enabled.
  82086. */
  82087. enabled: boolean;
  82088. /**
  82089. * Defines the order of this extension.
  82090. * The loader sorts the extensions using these values when loading.
  82091. */
  82092. order?: number;
  82093. }
  82094. /**
  82095. * Loader state.
  82096. */
  82097. export enum GLTFLoaderState {
  82098. /**
  82099. * The asset is loading.
  82100. */
  82101. LOADING = 0,
  82102. /**
  82103. * The asset is ready for rendering.
  82104. */
  82105. READY = 1,
  82106. /**
  82107. * The asset is completely loaded.
  82108. */
  82109. COMPLETE = 2
  82110. }
  82111. /** @hidden */
  82112. export interface IImportMeshAsyncOutput {
  82113. meshes: AbstractMesh[];
  82114. geometries: Geometry[];
  82115. particleSystems: IParticleSystem[];
  82116. skeletons: Skeleton[];
  82117. animationGroups: AnimationGroup[];
  82118. lights: Light[];
  82119. transformNodes: TransformNode[];
  82120. }
  82121. /** @hidden */
  82122. export interface IGLTFLoader extends IDisposable {
  82123. readonly state: Nullable<GLTFLoaderState>;
  82124. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  82125. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  82126. }
  82127. /**
  82128. * File loader for loading glTF files into a scene.
  82129. */
  82130. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82131. /** @hidden */
  82132. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82133. /** @hidden */
  82134. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82135. /**
  82136. * Raised when the asset has been parsed
  82137. */
  82138. onParsedObservable: Observable<IGLTFLoaderData>;
  82139. private _onParsedObserver;
  82140. /**
  82141. * Raised when the asset has been parsed
  82142. */
  82143. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  82144. /**
  82145. * 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.
  82146. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  82147. * Defaults to true.
  82148. * @hidden
  82149. */
  82150. static IncrementalLoading: boolean;
  82151. /**
  82152. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  82153. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  82154. * @hidden
  82155. */
  82156. static HomogeneousCoordinates: boolean;
  82157. /**
  82158. * The coordinate system mode. Defaults to AUTO.
  82159. */
  82160. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  82161. /**
  82162. * The animation start mode. Defaults to FIRST.
  82163. */
  82164. animationStartMode: GLTFLoaderAnimationStartMode;
  82165. /**
  82166. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  82167. */
  82168. compileMaterials: boolean;
  82169. /**
  82170. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  82171. */
  82172. useClipPlane: boolean;
  82173. /**
  82174. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  82175. */
  82176. compileShadowGenerators: boolean;
  82177. /**
  82178. * Defines if the Alpha blended materials are only applied as coverage.
  82179. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  82180. * If true, no extra effects are applied to transparent pixels.
  82181. */
  82182. transparencyAsCoverage: boolean;
  82183. /**
  82184. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  82185. * Enabling will disable offline support and glTF validator.
  82186. * Defaults to false.
  82187. */
  82188. useRangeRequests: boolean;
  82189. /**
  82190. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  82191. */
  82192. createInstances: boolean;
  82193. /**
  82194. * 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.
  82195. */
  82196. alwaysComputeBoundingBox: boolean;
  82197. /**
  82198. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  82199. */
  82200. loadAllMaterials: boolean;
  82201. /**
  82202. * Function called before loading a url referenced by the asset.
  82203. */
  82204. preprocessUrlAsync: (url: string) => Promise<string>;
  82205. /**
  82206. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82207. * 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, ...)
  82208. */
  82209. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  82210. private _onMeshLoadedObserver;
  82211. /**
  82212. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82213. * 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, ...)
  82214. */
  82215. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  82216. /**
  82217. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  82218. */
  82219. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  82220. private _onTextureLoadedObserver;
  82221. /**
  82222. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  82223. */
  82224. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  82225. /**
  82226. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  82227. */
  82228. readonly onMaterialLoadedObservable: Observable<Material>;
  82229. private _onMaterialLoadedObserver;
  82230. /**
  82231. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  82232. */
  82233. set onMaterialLoaded(callback: (material: Material) => void);
  82234. /**
  82235. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  82236. */
  82237. readonly onCameraLoadedObservable: Observable<Camera>;
  82238. private _onCameraLoadedObserver;
  82239. /**
  82240. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  82241. */
  82242. set onCameraLoaded(callback: (camera: Camera) => void);
  82243. /**
  82244. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  82245. * For assets with LODs, raised when all of the LODs are complete.
  82246. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82247. */
  82248. readonly onCompleteObservable: Observable<void>;
  82249. private _onCompleteObserver;
  82250. /**
  82251. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  82252. * For assets with LODs, raised when all of the LODs are complete.
  82253. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82254. */
  82255. set onComplete(callback: () => void);
  82256. /**
  82257. * Observable raised when an error occurs.
  82258. */
  82259. readonly onErrorObservable: Observable<any>;
  82260. private _onErrorObserver;
  82261. /**
  82262. * Callback raised when an error occurs.
  82263. */
  82264. set onError(callback: (reason: any) => void);
  82265. /**
  82266. * Observable raised after the loader is disposed.
  82267. */
  82268. readonly onDisposeObservable: Observable<void>;
  82269. private _onDisposeObserver;
  82270. /**
  82271. * Callback raised after the loader is disposed.
  82272. */
  82273. set onDispose(callback: () => void);
  82274. /**
  82275. * Observable raised after a loader extension is created.
  82276. * Set additional options for a loader extension in this event.
  82277. */
  82278. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  82279. private _onExtensionLoadedObserver;
  82280. /**
  82281. * Callback raised after a loader extension is created.
  82282. */
  82283. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82284. /**
  82285. * Defines if the loader logging is enabled.
  82286. */
  82287. get loggingEnabled(): boolean;
  82288. set loggingEnabled(value: boolean);
  82289. /**
  82290. * Defines if the loader should capture performance counters.
  82291. */
  82292. get capturePerformanceCounters(): boolean;
  82293. set capturePerformanceCounters(value: boolean);
  82294. /**
  82295. * Defines if the loader should validate the asset.
  82296. */
  82297. validate: boolean;
  82298. /**
  82299. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82300. */
  82301. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82302. private _onValidatedObserver;
  82303. /**
  82304. * Callback raised after a loader extension is created.
  82305. */
  82306. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82307. private _loader;
  82308. private _progressCallback?;
  82309. private _requests;
  82310. private static magicBase64Encoded;
  82311. /**
  82312. * Name of the loader ("gltf")
  82313. */
  82314. name: string;
  82315. /** @hidden */
  82316. extensions: ISceneLoaderPluginExtensions;
  82317. /**
  82318. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82319. */
  82320. dispose(): void;
  82321. /** @hidden */
  82322. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82323. /** @hidden */
  82324. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82325. /** @hidden */
  82326. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82327. meshes: AbstractMesh[];
  82328. particleSystems: IParticleSystem[];
  82329. skeletons: Skeleton[];
  82330. animationGroups: AnimationGroup[];
  82331. }>;
  82332. /** @hidden */
  82333. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82334. /** @hidden */
  82335. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82336. /** @hidden */
  82337. canDirectLoad(data: string): boolean;
  82338. /** @hidden */
  82339. directLoad(scene: Scene, data: string): Promise<any>;
  82340. /**
  82341. * The callback that allows custom handling of the root url based on the response url.
  82342. * @param rootUrl the original root url
  82343. * @param responseURL the response url if available
  82344. * @returns the new root url
  82345. */
  82346. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82347. /** @hidden */
  82348. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82349. /**
  82350. * The loader state or null if the loader is not active.
  82351. */
  82352. get loaderState(): Nullable<GLTFLoaderState>;
  82353. /**
  82354. * Returns a promise that resolves when the asset is completely loaded.
  82355. * @returns a promise that resolves when the asset is completely loaded.
  82356. */
  82357. whenCompleteAsync(): Promise<void>;
  82358. /** @hidden */
  82359. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82360. /** @hidden */
  82361. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82362. private _onProgress;
  82363. private _validate;
  82364. private _getLoader;
  82365. private _parseJson;
  82366. private _unpackBinaryAsync;
  82367. private _unpackBinaryV1Async;
  82368. private _unpackBinaryV2Async;
  82369. private static _parseVersion;
  82370. private static _compareVersion;
  82371. private static readonly _logSpaces;
  82372. private _logIndentLevel;
  82373. private _loggingEnabled;
  82374. /** @hidden */
  82375. _log: (message: string) => void;
  82376. /** @hidden */
  82377. _logOpen(message: string): void;
  82378. /** @hidden */
  82379. _logClose(): void;
  82380. private _logEnabled;
  82381. private _logDisabled;
  82382. private _capturePerformanceCounters;
  82383. /** @hidden */
  82384. _startPerformanceCounter: (counterName: string) => void;
  82385. /** @hidden */
  82386. _endPerformanceCounter: (counterName: string) => void;
  82387. private _startPerformanceCounterEnabled;
  82388. private _startPerformanceCounterDisabled;
  82389. private _endPerformanceCounterEnabled;
  82390. private _endPerformanceCounterDisabled;
  82391. }
  82392. }
  82393. declare module BABYLON.GLTF1 {
  82394. /**
  82395. * Enums
  82396. * @hidden
  82397. */
  82398. export enum EComponentType {
  82399. BYTE = 5120,
  82400. UNSIGNED_BYTE = 5121,
  82401. SHORT = 5122,
  82402. UNSIGNED_SHORT = 5123,
  82403. FLOAT = 5126
  82404. }
  82405. /** @hidden */
  82406. export enum EShaderType {
  82407. FRAGMENT = 35632,
  82408. VERTEX = 35633
  82409. }
  82410. /** @hidden */
  82411. export enum EParameterType {
  82412. BYTE = 5120,
  82413. UNSIGNED_BYTE = 5121,
  82414. SHORT = 5122,
  82415. UNSIGNED_SHORT = 5123,
  82416. INT = 5124,
  82417. UNSIGNED_INT = 5125,
  82418. FLOAT = 5126,
  82419. FLOAT_VEC2 = 35664,
  82420. FLOAT_VEC3 = 35665,
  82421. FLOAT_VEC4 = 35666,
  82422. INT_VEC2 = 35667,
  82423. INT_VEC3 = 35668,
  82424. INT_VEC4 = 35669,
  82425. BOOL = 35670,
  82426. BOOL_VEC2 = 35671,
  82427. BOOL_VEC3 = 35672,
  82428. BOOL_VEC4 = 35673,
  82429. FLOAT_MAT2 = 35674,
  82430. FLOAT_MAT3 = 35675,
  82431. FLOAT_MAT4 = 35676,
  82432. SAMPLER_2D = 35678
  82433. }
  82434. /** @hidden */
  82435. export enum ETextureWrapMode {
  82436. CLAMP_TO_EDGE = 33071,
  82437. MIRRORED_REPEAT = 33648,
  82438. REPEAT = 10497
  82439. }
  82440. /** @hidden */
  82441. export enum ETextureFilterType {
  82442. NEAREST = 9728,
  82443. LINEAR = 9728,
  82444. NEAREST_MIPMAP_NEAREST = 9984,
  82445. LINEAR_MIPMAP_NEAREST = 9985,
  82446. NEAREST_MIPMAP_LINEAR = 9986,
  82447. LINEAR_MIPMAP_LINEAR = 9987
  82448. }
  82449. /** @hidden */
  82450. export enum ETextureFormat {
  82451. ALPHA = 6406,
  82452. RGB = 6407,
  82453. RGBA = 6408,
  82454. LUMINANCE = 6409,
  82455. LUMINANCE_ALPHA = 6410
  82456. }
  82457. /** @hidden */
  82458. export enum ECullingType {
  82459. FRONT = 1028,
  82460. BACK = 1029,
  82461. FRONT_AND_BACK = 1032
  82462. }
  82463. /** @hidden */
  82464. export enum EBlendingFunction {
  82465. ZERO = 0,
  82466. ONE = 1,
  82467. SRC_COLOR = 768,
  82468. ONE_MINUS_SRC_COLOR = 769,
  82469. DST_COLOR = 774,
  82470. ONE_MINUS_DST_COLOR = 775,
  82471. SRC_ALPHA = 770,
  82472. ONE_MINUS_SRC_ALPHA = 771,
  82473. DST_ALPHA = 772,
  82474. ONE_MINUS_DST_ALPHA = 773,
  82475. CONSTANT_COLOR = 32769,
  82476. ONE_MINUS_CONSTANT_COLOR = 32770,
  82477. CONSTANT_ALPHA = 32771,
  82478. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82479. SRC_ALPHA_SATURATE = 776
  82480. }
  82481. /** @hidden */
  82482. export interface IGLTFProperty {
  82483. extensions?: {
  82484. [key: string]: any;
  82485. };
  82486. extras?: Object;
  82487. }
  82488. /** @hidden */
  82489. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82490. name?: string;
  82491. }
  82492. /** @hidden */
  82493. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82494. bufferView: string;
  82495. byteOffset: number;
  82496. byteStride: number;
  82497. count: number;
  82498. type: string;
  82499. componentType: EComponentType;
  82500. max?: number[];
  82501. min?: number[];
  82502. name?: string;
  82503. }
  82504. /** @hidden */
  82505. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82506. buffer: string;
  82507. byteOffset: number;
  82508. byteLength: number;
  82509. byteStride: number;
  82510. target?: number;
  82511. }
  82512. /** @hidden */
  82513. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82514. uri: string;
  82515. byteLength?: number;
  82516. type?: string;
  82517. }
  82518. /** @hidden */
  82519. export interface IGLTFShader extends IGLTFChildRootProperty {
  82520. uri: string;
  82521. type: EShaderType;
  82522. }
  82523. /** @hidden */
  82524. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82525. attributes: string[];
  82526. fragmentShader: string;
  82527. vertexShader: string;
  82528. }
  82529. /** @hidden */
  82530. export interface IGLTFTechniqueParameter {
  82531. type: number;
  82532. count?: number;
  82533. semantic?: string;
  82534. node?: string;
  82535. value?: number | boolean | string | Array<any>;
  82536. source?: string;
  82537. babylonValue?: any;
  82538. }
  82539. /** @hidden */
  82540. export interface IGLTFTechniqueCommonProfile {
  82541. lightingModel: string;
  82542. texcoordBindings: Object;
  82543. parameters?: Array<any>;
  82544. }
  82545. /** @hidden */
  82546. export interface IGLTFTechniqueStatesFunctions {
  82547. blendColor?: number[];
  82548. blendEquationSeparate?: number[];
  82549. blendFuncSeparate?: number[];
  82550. colorMask: boolean[];
  82551. cullFace: number[];
  82552. }
  82553. /** @hidden */
  82554. export interface IGLTFTechniqueStates {
  82555. enable: number[];
  82556. functions: IGLTFTechniqueStatesFunctions;
  82557. }
  82558. /** @hidden */
  82559. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82560. parameters: {
  82561. [key: string]: IGLTFTechniqueParameter;
  82562. };
  82563. program: string;
  82564. attributes: {
  82565. [key: string]: string;
  82566. };
  82567. uniforms: {
  82568. [key: string]: string;
  82569. };
  82570. states: IGLTFTechniqueStates;
  82571. }
  82572. /** @hidden */
  82573. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82574. technique?: string;
  82575. values: string[];
  82576. }
  82577. /** @hidden */
  82578. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82579. attributes: {
  82580. [key: string]: string;
  82581. };
  82582. indices: string;
  82583. material: string;
  82584. mode?: number;
  82585. }
  82586. /** @hidden */
  82587. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82588. primitives: IGLTFMeshPrimitive[];
  82589. }
  82590. /** @hidden */
  82591. export interface IGLTFImage extends IGLTFChildRootProperty {
  82592. uri: string;
  82593. }
  82594. /** @hidden */
  82595. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82596. magFilter?: number;
  82597. minFilter?: number;
  82598. wrapS?: number;
  82599. wrapT?: number;
  82600. }
  82601. /** @hidden */
  82602. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82603. sampler: string;
  82604. source: string;
  82605. format?: ETextureFormat;
  82606. internalFormat?: ETextureFormat;
  82607. target?: number;
  82608. type?: number;
  82609. babylonTexture?: Texture;
  82610. }
  82611. /** @hidden */
  82612. export interface IGLTFAmbienLight {
  82613. color?: number[];
  82614. }
  82615. /** @hidden */
  82616. export interface IGLTFDirectionalLight {
  82617. color?: number[];
  82618. }
  82619. /** @hidden */
  82620. export interface IGLTFPointLight {
  82621. color?: number[];
  82622. constantAttenuation?: number;
  82623. linearAttenuation?: number;
  82624. quadraticAttenuation?: number;
  82625. }
  82626. /** @hidden */
  82627. export interface IGLTFSpotLight {
  82628. color?: number[];
  82629. constantAttenuation?: number;
  82630. fallOfAngle?: number;
  82631. fallOffExponent?: number;
  82632. linearAttenuation?: number;
  82633. quadraticAttenuation?: number;
  82634. }
  82635. /** @hidden */
  82636. export interface IGLTFLight extends IGLTFChildRootProperty {
  82637. type: string;
  82638. }
  82639. /** @hidden */
  82640. export interface IGLTFCameraOrthographic {
  82641. xmag: number;
  82642. ymag: number;
  82643. zfar: number;
  82644. znear: number;
  82645. }
  82646. /** @hidden */
  82647. export interface IGLTFCameraPerspective {
  82648. aspectRatio: number;
  82649. yfov: number;
  82650. zfar: number;
  82651. znear: number;
  82652. }
  82653. /** @hidden */
  82654. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82655. type: string;
  82656. }
  82657. /** @hidden */
  82658. export interface IGLTFAnimationChannelTarget {
  82659. id: string;
  82660. path: string;
  82661. }
  82662. /** @hidden */
  82663. export interface IGLTFAnimationChannel {
  82664. sampler: string;
  82665. target: IGLTFAnimationChannelTarget;
  82666. }
  82667. /** @hidden */
  82668. export interface IGLTFAnimationSampler {
  82669. input: string;
  82670. output: string;
  82671. interpolation?: string;
  82672. }
  82673. /** @hidden */
  82674. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82675. channels?: IGLTFAnimationChannel[];
  82676. parameters?: {
  82677. [key: string]: string;
  82678. };
  82679. samplers?: {
  82680. [key: string]: IGLTFAnimationSampler;
  82681. };
  82682. }
  82683. /** @hidden */
  82684. export interface IGLTFNodeInstanceSkin {
  82685. skeletons: string[];
  82686. skin: string;
  82687. meshes: string[];
  82688. }
  82689. /** @hidden */
  82690. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82691. bindShapeMatrix: number[];
  82692. inverseBindMatrices: string;
  82693. jointNames: string[];
  82694. babylonSkeleton?: Skeleton;
  82695. }
  82696. /** @hidden */
  82697. export interface IGLTFNode extends IGLTFChildRootProperty {
  82698. camera?: string;
  82699. children: string[];
  82700. skin?: string;
  82701. jointName?: string;
  82702. light?: string;
  82703. matrix: number[];
  82704. mesh?: string;
  82705. meshes?: string[];
  82706. rotation?: number[];
  82707. scale?: number[];
  82708. translation?: number[];
  82709. babylonNode?: Node;
  82710. }
  82711. /** @hidden */
  82712. export interface IGLTFScene extends IGLTFChildRootProperty {
  82713. nodes: string[];
  82714. }
  82715. /** @hidden */
  82716. export interface IGLTFRuntime {
  82717. extensions: {
  82718. [key: string]: any;
  82719. };
  82720. accessors: {
  82721. [key: string]: IGLTFAccessor;
  82722. };
  82723. buffers: {
  82724. [key: string]: IGLTFBuffer;
  82725. };
  82726. bufferViews: {
  82727. [key: string]: IGLTFBufferView;
  82728. };
  82729. meshes: {
  82730. [key: string]: IGLTFMesh;
  82731. };
  82732. lights: {
  82733. [key: string]: IGLTFLight;
  82734. };
  82735. cameras: {
  82736. [key: string]: IGLTFCamera;
  82737. };
  82738. nodes: {
  82739. [key: string]: IGLTFNode;
  82740. };
  82741. images: {
  82742. [key: string]: IGLTFImage;
  82743. };
  82744. textures: {
  82745. [key: string]: IGLTFTexture;
  82746. };
  82747. shaders: {
  82748. [key: string]: IGLTFShader;
  82749. };
  82750. programs: {
  82751. [key: string]: IGLTFProgram;
  82752. };
  82753. samplers: {
  82754. [key: string]: IGLTFSampler;
  82755. };
  82756. techniques: {
  82757. [key: string]: IGLTFTechnique;
  82758. };
  82759. materials: {
  82760. [key: string]: IGLTFMaterial;
  82761. };
  82762. animations: {
  82763. [key: string]: IGLTFAnimation;
  82764. };
  82765. skins: {
  82766. [key: string]: IGLTFSkins;
  82767. };
  82768. currentScene?: Object;
  82769. scenes: {
  82770. [key: string]: IGLTFScene;
  82771. };
  82772. extensionsUsed: string[];
  82773. extensionsRequired?: string[];
  82774. buffersCount: number;
  82775. shaderscount: number;
  82776. scene: Scene;
  82777. rootUrl: string;
  82778. loadedBufferCount: number;
  82779. loadedBufferViews: {
  82780. [name: string]: ArrayBufferView;
  82781. };
  82782. loadedShaderCount: number;
  82783. importOnlyMeshes: boolean;
  82784. importMeshesNames?: string[];
  82785. dummyNodes: Node[];
  82786. forAssetContainer: boolean;
  82787. }
  82788. /** @hidden */
  82789. export interface INodeToRoot {
  82790. bone: Bone;
  82791. node: IGLTFNode;
  82792. id: string;
  82793. }
  82794. /** @hidden */
  82795. export interface IJointNode {
  82796. node: IGLTFNode;
  82797. id: string;
  82798. }
  82799. }
  82800. declare module BABYLON.GLTF1 {
  82801. /**
  82802. * Utils functions for GLTF
  82803. * @hidden
  82804. */
  82805. export class GLTFUtils {
  82806. /**
  82807. * Sets the given "parameter" matrix
  82808. * @param scene: the Scene object
  82809. * @param source: the source node where to pick the matrix
  82810. * @param parameter: the GLTF technique parameter
  82811. * @param uniformName: the name of the shader's uniform
  82812. * @param shaderMaterial: the shader material
  82813. */
  82814. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82815. /**
  82816. * Sets the given "parameter" matrix
  82817. * @param shaderMaterial: the shader material
  82818. * @param uniform: the name of the shader's uniform
  82819. * @param value: the value of the uniform
  82820. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82821. */
  82822. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82823. /**
  82824. * Returns the wrap mode of the texture
  82825. * @param mode: the mode value
  82826. */
  82827. static GetWrapMode(mode: number): number;
  82828. /**
  82829. * Returns the byte stride giving an accessor
  82830. * @param accessor: the GLTF accessor objet
  82831. */
  82832. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82833. /**
  82834. * Returns the texture filter mode giving a mode value
  82835. * @param mode: the filter mode value
  82836. */
  82837. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82838. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82839. /**
  82840. * Returns a buffer from its accessor
  82841. * @param gltfRuntime: the GLTF runtime
  82842. * @param accessor: the GLTF accessor
  82843. */
  82844. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82845. /**
  82846. * Decodes a buffer view into a string
  82847. * @param view: the buffer view
  82848. */
  82849. static DecodeBufferToText(view: ArrayBufferView): string;
  82850. /**
  82851. * Returns the default material of gltf. Related to
  82852. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82853. * @param scene: the Babylon.js scene
  82854. */
  82855. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82856. private static _DefaultMaterial;
  82857. }
  82858. }
  82859. declare module BABYLON.GLTF1 {
  82860. /**
  82861. * Implementation of the base glTF spec
  82862. * @hidden
  82863. */
  82864. export class GLTFLoaderBase {
  82865. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82866. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82867. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82868. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82869. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82870. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82871. }
  82872. /**
  82873. * glTF V1 Loader
  82874. * @hidden
  82875. */
  82876. export class GLTFLoader implements IGLTFLoader {
  82877. static Extensions: {
  82878. [name: string]: GLTFLoaderExtension;
  82879. };
  82880. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82881. state: Nullable<GLTFLoaderState>;
  82882. dispose(): void;
  82883. private _importMeshAsync;
  82884. /**
  82885. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82886. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82887. * @param scene the scene the meshes should be added to
  82888. * @param forAssetContainer defines if the entities must be stored in the scene
  82889. * @param data gltf data containing information of the meshes in a loaded file
  82890. * @param rootUrl root url to load from
  82891. * @param onProgress event that fires when loading progress has occured
  82892. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82893. */
  82894. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82895. private _loadAsync;
  82896. /**
  82897. * Imports all objects from a loaded gltf file and adds them to the scene
  82898. * @param scene the scene the objects should be added to
  82899. * @param data gltf data containing information of the meshes in a loaded file
  82900. * @param rootUrl root url to load from
  82901. * @param onProgress event that fires when loading progress has occured
  82902. * @returns a promise which completes when objects have been loaded to the scene
  82903. */
  82904. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82905. private _loadShadersAsync;
  82906. private _loadBuffersAsync;
  82907. private _createNodes;
  82908. }
  82909. /** @hidden */
  82910. export abstract class GLTFLoaderExtension {
  82911. private _name;
  82912. constructor(name: string);
  82913. get name(): string;
  82914. /**
  82915. * Defines an override for loading the runtime
  82916. * Return true to stop further extensions from loading the runtime
  82917. */
  82918. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82919. /**
  82920. * Defines an onverride for creating gltf runtime
  82921. * Return true to stop further extensions from creating the runtime
  82922. */
  82923. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82924. /**
  82925. * Defines an override for loading buffers
  82926. * Return true to stop further extensions from loading this buffer
  82927. */
  82928. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82929. /**
  82930. * Defines an override for loading texture buffers
  82931. * Return true to stop further extensions from loading this texture data
  82932. */
  82933. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82934. /**
  82935. * Defines an override for creating textures
  82936. * Return true to stop further extensions from loading this texture
  82937. */
  82938. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82939. /**
  82940. * Defines an override for loading shader strings
  82941. * Return true to stop further extensions from loading this shader data
  82942. */
  82943. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82944. /**
  82945. * Defines an override for loading materials
  82946. * Return true to stop further extensions from loading this material
  82947. */
  82948. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82949. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82950. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82951. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82952. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82953. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82954. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82955. private static LoadTextureBufferAsync;
  82956. private static CreateTextureAsync;
  82957. private static ApplyExtensions;
  82958. }
  82959. }
  82960. declare module BABYLON.GLTF1 {
  82961. /** @hidden */
  82962. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82963. private _bin;
  82964. constructor();
  82965. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82966. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82967. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82968. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82969. }
  82970. }
  82971. declare module BABYLON.GLTF1 {
  82972. /** @hidden */
  82973. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82974. constructor();
  82975. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82976. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82977. private _loadTexture;
  82978. }
  82979. }
  82980. declare module BABYLON.GLTF2.Loader {
  82981. /**
  82982. * Loader interface with an index field.
  82983. */
  82984. export interface IArrayItem {
  82985. /**
  82986. * The index of this item in the array.
  82987. */
  82988. index: number;
  82989. }
  82990. /**
  82991. * Loader interface with additional members.
  82992. */
  82993. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82994. /** @hidden */
  82995. _data?: Promise<ArrayBufferView>;
  82996. /** @hidden */
  82997. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82998. }
  82999. /**
  83000. * Loader interface with additional members.
  83001. */
  83002. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  83003. }
  83004. /** @hidden */
  83005. export interface _IAnimationSamplerData {
  83006. input: Float32Array;
  83007. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  83008. output: Float32Array;
  83009. }
  83010. /**
  83011. * Loader interface with additional members.
  83012. */
  83013. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  83014. /** @hidden */
  83015. _data?: Promise<_IAnimationSamplerData>;
  83016. }
  83017. /**
  83018. * Loader interface with additional members.
  83019. */
  83020. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  83021. channels: IAnimationChannel[];
  83022. samplers: IAnimationSampler[];
  83023. /** @hidden */
  83024. _babylonAnimationGroup?: AnimationGroup;
  83025. }
  83026. /**
  83027. * Loader interface with additional members.
  83028. */
  83029. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  83030. /** @hidden */
  83031. _data?: Promise<ArrayBufferView>;
  83032. }
  83033. /**
  83034. * Loader interface with additional members.
  83035. */
  83036. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  83037. /** @hidden */
  83038. _data?: Promise<ArrayBufferView>;
  83039. /** @hidden */
  83040. _babylonBuffer?: Promise<Buffer>;
  83041. }
  83042. /**
  83043. * Loader interface with additional members.
  83044. */
  83045. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  83046. }
  83047. /**
  83048. * Loader interface with additional members.
  83049. */
  83050. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  83051. /** @hidden */
  83052. _data?: Promise<ArrayBufferView>;
  83053. }
  83054. /**
  83055. * Loader interface with additional members.
  83056. */
  83057. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  83058. }
  83059. /**
  83060. * Loader interface with additional members.
  83061. */
  83062. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  83063. }
  83064. /**
  83065. * Loader interface with additional members.
  83066. */
  83067. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  83068. baseColorTexture?: ITextureInfo;
  83069. metallicRoughnessTexture?: ITextureInfo;
  83070. }
  83071. /**
  83072. * Loader interface with additional members.
  83073. */
  83074. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  83075. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83076. normalTexture?: IMaterialNormalTextureInfo;
  83077. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83078. emissiveTexture?: ITextureInfo;
  83079. /** @hidden */
  83080. _data?: {
  83081. [babylonDrawMode: number]: {
  83082. babylonMaterial: Material;
  83083. babylonMeshes: AbstractMesh[];
  83084. promise: Promise<void>;
  83085. };
  83086. };
  83087. }
  83088. /**
  83089. * Loader interface with additional members.
  83090. */
  83091. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  83092. primitives: IMeshPrimitive[];
  83093. }
  83094. /**
  83095. * Loader interface with additional members.
  83096. */
  83097. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  83098. /** @hidden */
  83099. _instanceData?: {
  83100. babylonSourceMesh: Mesh;
  83101. promise: Promise<any>;
  83102. };
  83103. }
  83104. /**
  83105. * Loader interface with additional members.
  83106. */
  83107. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  83108. /**
  83109. * The parent glTF node.
  83110. */
  83111. parent?: INode;
  83112. /** @hidden */
  83113. _babylonTransformNode?: TransformNode;
  83114. /** @hidden */
  83115. _primitiveBabylonMeshes?: AbstractMesh[];
  83116. /** @hidden */
  83117. _babylonBones?: Bone[];
  83118. /** @hidden */
  83119. _numMorphTargets?: number;
  83120. }
  83121. /** @hidden */
  83122. export interface _ISamplerData {
  83123. noMipMaps: boolean;
  83124. samplingMode: number;
  83125. wrapU: number;
  83126. wrapV: number;
  83127. }
  83128. /**
  83129. * Loader interface with additional members.
  83130. */
  83131. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  83132. /** @hidden */
  83133. _data?: _ISamplerData;
  83134. }
  83135. /**
  83136. * Loader interface with additional members.
  83137. */
  83138. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  83139. }
  83140. /**
  83141. * Loader interface with additional members.
  83142. */
  83143. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  83144. /** @hidden */
  83145. _data?: {
  83146. babylonSkeleton: Skeleton;
  83147. promise: Promise<void>;
  83148. };
  83149. }
  83150. /**
  83151. * Loader interface with additional members.
  83152. */
  83153. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  83154. /** @hidden */
  83155. _textureInfo: ITextureInfo;
  83156. }
  83157. /**
  83158. * Loader interface with additional members.
  83159. */
  83160. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  83161. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  83162. nonColorData?: boolean;
  83163. }
  83164. /**
  83165. * Loader interface with additional members.
  83166. */
  83167. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  83168. accessors?: IAccessor[];
  83169. animations?: IAnimation[];
  83170. buffers?: IBuffer[];
  83171. bufferViews?: IBufferView[];
  83172. cameras?: ICamera[];
  83173. images?: IImage[];
  83174. materials?: IMaterial[];
  83175. meshes?: IMesh[];
  83176. nodes?: INode[];
  83177. samplers?: ISampler[];
  83178. scenes?: IScene[];
  83179. skins?: ISkin[];
  83180. textures?: ITexture[];
  83181. }
  83182. }
  83183. declare module BABYLON.GLTF2 {
  83184. /**
  83185. * Interface for a glTF loader extension.
  83186. */
  83187. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  83188. /**
  83189. * Called after the loader state changes to LOADING.
  83190. */
  83191. onLoading?(): void;
  83192. /**
  83193. * Called after the loader state changes to READY.
  83194. */
  83195. onReady?(): void;
  83196. /**
  83197. * Define this method to modify the default behavior when loading scenes.
  83198. * @param context The context when loading the asset
  83199. * @param scene The glTF scene property
  83200. * @returns A promise that resolves when the load is complete or null if not handled
  83201. */
  83202. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  83203. /**
  83204. * Define this method to modify the default behavior when loading nodes.
  83205. * @param context The context when loading the asset
  83206. * @param node The glTF node property
  83207. * @param assign A function called synchronously after parsing the glTF properties
  83208. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  83209. */
  83210. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83211. /**
  83212. * Define this method to modify the default behavior when loading cameras.
  83213. * @param context The context when loading the asset
  83214. * @param camera The glTF camera property
  83215. * @param assign A function called synchronously after parsing the glTF properties
  83216. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  83217. */
  83218. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83219. /**
  83220. * @hidden
  83221. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  83222. * @param context The context when loading the asset
  83223. * @param primitive The glTF mesh primitive property
  83224. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  83225. */
  83226. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83227. /**
  83228. * @hidden
  83229. * Define this method to modify the default behavior when loading data for mesh primitives.
  83230. * @param context The context when loading the asset
  83231. * @param name The mesh name when loading the asset
  83232. * @param node The glTF node when loading the asset
  83233. * @param mesh The glTF mesh when loading the asset
  83234. * @param primitive The glTF mesh primitive property
  83235. * @param assign A function called synchronously after parsing the glTF properties
  83236. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83237. */
  83238. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83239. /**
  83240. * @hidden
  83241. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  83242. * @param context The context when loading the asset
  83243. * @param material The glTF material property
  83244. * @param assign A function called synchronously after parsing the glTF properties
  83245. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  83246. */
  83247. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83248. /**
  83249. * Define this method to modify the default behavior when creating materials.
  83250. * @param context The context when loading the asset
  83251. * @param material The glTF material property
  83252. * @param babylonDrawMode The draw mode for the Babylon material
  83253. * @returns The Babylon material or null if not handled
  83254. */
  83255. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83256. /**
  83257. * Define this method to modify the default behavior when loading material properties.
  83258. * @param context The context when loading the asset
  83259. * @param material The glTF material property
  83260. * @param babylonMaterial The Babylon material
  83261. * @returns A promise that resolves when the load is complete or null if not handled
  83262. */
  83263. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83264. /**
  83265. * Define this method to modify the default behavior when loading texture infos.
  83266. * @param context The context when loading the asset
  83267. * @param textureInfo The glTF texture info property
  83268. * @param assign A function called synchronously after parsing the glTF properties
  83269. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83270. */
  83271. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83272. /**
  83273. * @hidden
  83274. * Define this method to modify the default behavior when loading textures.
  83275. * @param context The context when loading the asset
  83276. * @param texture The glTF texture property
  83277. * @param assign A function called synchronously after parsing the glTF properties
  83278. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83279. */
  83280. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83281. /**
  83282. * Define this method to modify the default behavior when loading animations.
  83283. * @param context The context when loading the asset
  83284. * @param animation The glTF animation property
  83285. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83286. */
  83287. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83288. /**
  83289. * @hidden
  83290. * Define this method to modify the default behavior when loading skins.
  83291. * @param context The context when loading the asset
  83292. * @param node The glTF node property
  83293. * @param skin The glTF skin property
  83294. * @returns A promise that resolves when the load is complete or null if not handled
  83295. */
  83296. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83297. /**
  83298. * @hidden
  83299. * Define this method to modify the default behavior when loading uris.
  83300. * @param context The context when loading the asset
  83301. * @param property The glTF property associated with the uri
  83302. * @param uri The uri to load
  83303. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83304. */
  83305. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83306. /**
  83307. * Define this method to modify the default behavior when loading buffer views.
  83308. * @param context The context when loading the asset
  83309. * @param bufferView The glTF buffer view property
  83310. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83311. */
  83312. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83313. /**
  83314. * Define this method to modify the default behavior when loading buffers.
  83315. * @param context The context when loading the asset
  83316. * @param buffer The glTF buffer property
  83317. * @param byteOffset The byte offset to load
  83318. * @param byteLength The byte length to load
  83319. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83320. */
  83321. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83322. }
  83323. }
  83324. declare module BABYLON.GLTF2 {
  83325. /**
  83326. * Helper class for working with arrays when loading the glTF asset
  83327. */
  83328. export class ArrayItem {
  83329. /**
  83330. * Gets an item from the given array.
  83331. * @param context The context when loading the asset
  83332. * @param array The array to get the item from
  83333. * @param index The index to the array
  83334. * @returns The array item
  83335. */
  83336. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83337. /**
  83338. * Assign an `index` field to each item of the given array.
  83339. * @param array The array of items
  83340. */
  83341. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83342. }
  83343. /**
  83344. * The glTF 2.0 loader
  83345. */
  83346. export class GLTFLoader implements IGLTFLoader {
  83347. /** @hidden */
  83348. _completePromises: Promise<any>[];
  83349. /** @hidden */
  83350. _forAssetContainer: boolean;
  83351. /** Storage */
  83352. _babylonLights: Light[];
  83353. /** @hidden */
  83354. _disableInstancedMesh: number;
  83355. private _disposed;
  83356. private _parent;
  83357. private _state;
  83358. private _extensions;
  83359. private _rootUrl;
  83360. private _fileName;
  83361. private _uniqueRootUrl;
  83362. private _gltf;
  83363. private _bin;
  83364. private _babylonScene;
  83365. private _rootBabylonMesh;
  83366. private _defaultBabylonMaterialData;
  83367. private static _RegisteredExtensions;
  83368. /**
  83369. * The default glTF sampler.
  83370. */
  83371. static readonly DefaultSampler: ISampler;
  83372. /**
  83373. * Registers a loader extension.
  83374. * @param name The name of the loader extension.
  83375. * @param factory The factory function that creates the loader extension.
  83376. */
  83377. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83378. /**
  83379. * Unregisters a loader extension.
  83380. * @param name The name of the loader extension.
  83381. * @returns A boolean indicating whether the extension has been unregistered
  83382. */
  83383. static UnregisterExtension(name: string): boolean;
  83384. /**
  83385. * The loader state.
  83386. */
  83387. get state(): Nullable<GLTFLoaderState>;
  83388. /**
  83389. * The object that represents the glTF JSON.
  83390. */
  83391. get gltf(): IGLTF;
  83392. /**
  83393. * The BIN chunk of a binary glTF.
  83394. */
  83395. get bin(): Nullable<IDataBuffer>;
  83396. /**
  83397. * The parent file loader.
  83398. */
  83399. get parent(): GLTFFileLoader;
  83400. /**
  83401. * The Babylon scene when loading the asset.
  83402. */
  83403. get babylonScene(): Scene;
  83404. /**
  83405. * The root Babylon mesh when loading the asset.
  83406. */
  83407. get rootBabylonMesh(): Mesh;
  83408. /** @hidden */
  83409. constructor(parent: GLTFFileLoader);
  83410. /** @hidden */
  83411. dispose(): void;
  83412. /** @hidden */
  83413. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  83414. /** @hidden */
  83415. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83416. private _loadAsync;
  83417. private _loadData;
  83418. private _setupData;
  83419. private _loadExtensions;
  83420. private _checkExtensions;
  83421. private _setState;
  83422. private _createRootNode;
  83423. /**
  83424. * Loads a glTF scene.
  83425. * @param context The context when loading the asset
  83426. * @param scene The glTF scene property
  83427. * @returns A promise that resolves when the load is complete
  83428. */
  83429. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83430. private _forEachPrimitive;
  83431. private _getGeometries;
  83432. private _getMeshes;
  83433. private _getTransformNodes;
  83434. private _getSkeletons;
  83435. private _getAnimationGroups;
  83436. private _startAnimations;
  83437. /**
  83438. * Loads a glTF node.
  83439. * @param context The context when loading the asset
  83440. * @param node The glTF node property
  83441. * @param assign A function called synchronously after parsing the glTF properties
  83442. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83443. */
  83444. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83445. private _loadMeshAsync;
  83446. /**
  83447. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83448. * @param context The context when loading the asset
  83449. * @param name The mesh name when loading the asset
  83450. * @param node The glTF node when loading the asset
  83451. * @param mesh The glTF mesh when loading the asset
  83452. * @param primitive The glTF mesh primitive property
  83453. * @param assign A function called synchronously after parsing the glTF properties
  83454. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83455. */
  83456. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83457. private _loadVertexDataAsync;
  83458. private _createMorphTargets;
  83459. private _loadMorphTargetsAsync;
  83460. private _loadMorphTargetVertexDataAsync;
  83461. private static _LoadTransform;
  83462. private _loadSkinAsync;
  83463. private _loadBones;
  83464. private _loadBone;
  83465. private _loadSkinInverseBindMatricesDataAsync;
  83466. private _updateBoneMatrices;
  83467. private _getNodeMatrix;
  83468. /**
  83469. * Loads a glTF camera.
  83470. * @param context The context when loading the asset
  83471. * @param camera The glTF camera property
  83472. * @param assign A function called synchronously after parsing the glTF properties
  83473. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83474. */
  83475. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83476. private _loadAnimationsAsync;
  83477. /**
  83478. * Loads a glTF animation.
  83479. * @param context The context when loading the asset
  83480. * @param animation The glTF animation property
  83481. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83482. */
  83483. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83484. /**
  83485. * @hidden Loads a glTF animation channel.
  83486. * @param context The context when loading the asset
  83487. * @param animationContext The context of the animation when loading the asset
  83488. * @param animation The glTF animation property
  83489. * @param channel The glTF animation channel property
  83490. * @param babylonAnimationGroup The babylon animation group property
  83491. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83492. * @returns A void promise when the channel load is complete
  83493. */
  83494. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83495. private _loadAnimationSamplerAsync;
  83496. private _loadBufferAsync;
  83497. /**
  83498. * Loads a glTF buffer view.
  83499. * @param context The context when loading the asset
  83500. * @param bufferView The glTF buffer view property
  83501. * @returns A promise that resolves with the loaded data when the load is complete
  83502. */
  83503. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83504. private _loadAccessorAsync;
  83505. /** @hidden */
  83506. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83507. private _loadIndicesAccessorAsync;
  83508. private _loadVertexBufferViewAsync;
  83509. private _loadVertexAccessorAsync;
  83510. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83511. /** @hidden */
  83512. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83513. private _createDefaultMaterial;
  83514. /**
  83515. * Creates a Babylon material from a glTF material.
  83516. * @param context The context when loading the asset
  83517. * @param material The glTF material property
  83518. * @param babylonDrawMode The draw mode for the Babylon material
  83519. * @returns The Babylon material
  83520. */
  83521. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83522. /**
  83523. * Loads properties from a glTF material into a Babylon material.
  83524. * @param context The context when loading the asset
  83525. * @param material The glTF material property
  83526. * @param babylonMaterial The Babylon material
  83527. * @returns A promise that resolves when the load is complete
  83528. */
  83529. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83530. /**
  83531. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83532. * @param context The context when loading the asset
  83533. * @param material The glTF material property
  83534. * @param babylonMaterial The Babylon material
  83535. * @returns A promise that resolves when the load is complete
  83536. */
  83537. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83538. /**
  83539. * Loads the alpha properties from a glTF material into a Babylon material.
  83540. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83541. * @param context The context when loading the asset
  83542. * @param material The glTF material property
  83543. * @param babylonMaterial The Babylon material
  83544. */
  83545. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83546. /**
  83547. * Loads a glTF texture info.
  83548. * @param context The context when loading the asset
  83549. * @param textureInfo The glTF texture info property
  83550. * @param assign A function called synchronously after parsing the glTF properties
  83551. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83552. */
  83553. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83554. /** @hidden */
  83555. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83556. /** @hidden */
  83557. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83558. private _loadSampler;
  83559. /**
  83560. * Loads a glTF image.
  83561. * @param context The context when loading the asset
  83562. * @param image The glTF image property
  83563. * @returns A promise that resolves with the loaded data when the load is complete
  83564. */
  83565. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83566. /**
  83567. * Loads a glTF uri.
  83568. * @param context The context when loading the asset
  83569. * @param property The glTF property associated with the uri
  83570. * @param uri The base64 or relative uri
  83571. * @returns A promise that resolves with the loaded data when the load is complete
  83572. */
  83573. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83574. /**
  83575. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83576. * @param babylonObject the Babylon object with metadata
  83577. * @param pointer the JSON pointer
  83578. */
  83579. static AddPointerMetadata(babylonObject: {
  83580. metadata: any;
  83581. }, pointer: string): void;
  83582. private static _GetTextureWrapMode;
  83583. private static _GetTextureSamplingMode;
  83584. private static _GetTypedArrayConstructor;
  83585. private static _GetTypedArray;
  83586. private static _GetNumComponents;
  83587. private static _ValidateUri;
  83588. /** @hidden */
  83589. static _GetDrawMode(context: string, mode: number | undefined): number;
  83590. private _compileMaterialsAsync;
  83591. private _compileShadowGeneratorsAsync;
  83592. private _forEachExtensions;
  83593. private _applyExtensions;
  83594. private _extensionsOnLoading;
  83595. private _extensionsOnReady;
  83596. private _extensionsLoadSceneAsync;
  83597. private _extensionsLoadNodeAsync;
  83598. private _extensionsLoadCameraAsync;
  83599. private _extensionsLoadVertexDataAsync;
  83600. private _extensionsLoadMeshPrimitiveAsync;
  83601. private _extensionsLoadMaterialAsync;
  83602. private _extensionsCreateMaterial;
  83603. private _extensionsLoadMaterialPropertiesAsync;
  83604. private _extensionsLoadTextureInfoAsync;
  83605. private _extensionsLoadTextureAsync;
  83606. private _extensionsLoadAnimationAsync;
  83607. private _extensionsLoadSkinAsync;
  83608. private _extensionsLoadUriAsync;
  83609. private _extensionsLoadBufferViewAsync;
  83610. private _extensionsLoadBufferAsync;
  83611. /**
  83612. * Helper method called by a loader extension to load an glTF extension.
  83613. * @param context The context when loading the asset
  83614. * @param property The glTF property to load the extension from
  83615. * @param extensionName The name of the extension to load
  83616. * @param actionAsync The action to run
  83617. * @returns The promise returned by actionAsync or null if the extension does not exist
  83618. */
  83619. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83620. /**
  83621. * Helper method called by a loader extension to load a glTF extra.
  83622. * @param context The context when loading the asset
  83623. * @param property The glTF property to load the extra from
  83624. * @param extensionName The name of the extension to load
  83625. * @param actionAsync The action to run
  83626. * @returns The promise returned by actionAsync or null if the extra does not exist
  83627. */
  83628. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83629. /**
  83630. * Checks for presence of an extension.
  83631. * @param name The name of the extension to check
  83632. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83633. */
  83634. isExtensionUsed(name: string): boolean;
  83635. /**
  83636. * Increments the indentation level and logs a message.
  83637. * @param message The message to log
  83638. */
  83639. logOpen(message: string): void;
  83640. /**
  83641. * Decrements the indentation level.
  83642. */
  83643. logClose(): void;
  83644. /**
  83645. * Logs a message
  83646. * @param message The message to log
  83647. */
  83648. log(message: string): void;
  83649. /**
  83650. * Starts a performance counter.
  83651. * @param counterName The name of the performance counter
  83652. */
  83653. startPerformanceCounter(counterName: string): void;
  83654. /**
  83655. * Ends a performance counter.
  83656. * @param counterName The name of the performance counter
  83657. */
  83658. endPerformanceCounter(counterName: string): void;
  83659. }
  83660. }
  83661. declare module BABYLON.GLTF2.Loader.Extensions {
  83662. /** @hidden */
  83663. interface IEXTLightsImageBased_LightImageBased {
  83664. _babylonTexture?: BaseTexture;
  83665. _loaded?: Promise<void>;
  83666. }
  83667. /**
  83668. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83669. */
  83670. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83671. /**
  83672. * The name of this extension.
  83673. */
  83674. readonly name: string;
  83675. /**
  83676. * Defines whether this extension is enabled.
  83677. */
  83678. enabled: boolean;
  83679. private _loader;
  83680. private _lights?;
  83681. /** @hidden */
  83682. constructor(loader: GLTFLoader);
  83683. /** @hidden */
  83684. dispose(): void;
  83685. /** @hidden */
  83686. onLoading(): void;
  83687. /** @hidden */
  83688. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83689. private _loadLightAsync;
  83690. }
  83691. }
  83692. declare module BABYLON.GLTF2.Loader.Extensions {
  83693. /**
  83694. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83695. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83696. * !!! Experimental Extension Subject to Changes !!!
  83697. */
  83698. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83699. /**
  83700. * The name of this extension.
  83701. */
  83702. readonly name: string;
  83703. /**
  83704. * Defines whether this extension is enabled.
  83705. */
  83706. enabled: boolean;
  83707. private _loader;
  83708. /** @hidden */
  83709. constructor(loader: GLTFLoader);
  83710. /** @hidden */
  83711. dispose(): void;
  83712. /** @hidden */
  83713. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83714. }
  83715. }
  83716. declare module BABYLON.GLTF2.Loader.Extensions {
  83717. /**
  83718. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83719. */
  83720. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83721. /** The name of this extension. */
  83722. readonly name: string;
  83723. /** Defines whether this extension is enabled. */
  83724. enabled: boolean;
  83725. private _loader;
  83726. /** @hidden */
  83727. constructor(loader: GLTFLoader);
  83728. /** @hidden */
  83729. dispose(): void;
  83730. /** @hidden */
  83731. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83732. }
  83733. }
  83734. declare module BABYLON.GLTF2.Loader.Extensions {
  83735. /**
  83736. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83737. */
  83738. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83739. /**
  83740. * The name of this extension.
  83741. */
  83742. readonly name: string;
  83743. /**
  83744. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83745. */
  83746. dracoCompression?: DracoCompression;
  83747. /**
  83748. * Defines whether this extension is enabled.
  83749. */
  83750. enabled: boolean;
  83751. private _loader;
  83752. /** @hidden */
  83753. constructor(loader: GLTFLoader);
  83754. /** @hidden */
  83755. dispose(): void;
  83756. /** @hidden */
  83757. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83758. }
  83759. }
  83760. declare module BABYLON.GLTF2.Loader.Extensions {
  83761. /**
  83762. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83763. */
  83764. export class KHR_lights implements IGLTFLoaderExtension {
  83765. /**
  83766. * The name of this extension.
  83767. */
  83768. readonly name: string;
  83769. /**
  83770. * Defines whether this extension is enabled.
  83771. */
  83772. enabled: boolean;
  83773. private _loader;
  83774. private _lights?;
  83775. /** @hidden */
  83776. constructor(loader: GLTFLoader);
  83777. /** @hidden */
  83778. dispose(): void;
  83779. /** @hidden */
  83780. onLoading(): void;
  83781. /** @hidden */
  83782. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83783. }
  83784. }
  83785. declare module BABYLON.GLTF2.Loader.Extensions {
  83786. /**
  83787. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83788. */
  83789. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83790. /**
  83791. * The name of this extension.
  83792. */
  83793. readonly name: string;
  83794. /**
  83795. * Defines whether this extension is enabled.
  83796. */
  83797. enabled: boolean;
  83798. /**
  83799. * Defines a number that determines the order the extensions are applied.
  83800. */
  83801. order: number;
  83802. private _loader;
  83803. /** @hidden */
  83804. constructor(loader: GLTFLoader);
  83805. /** @hidden */
  83806. dispose(): void;
  83807. /** @hidden */
  83808. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83809. private _loadSpecularGlossinessPropertiesAsync;
  83810. }
  83811. }
  83812. declare module BABYLON.GLTF2.Loader.Extensions {
  83813. /**
  83814. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83815. */
  83816. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83817. /**
  83818. * The name of this extension.
  83819. */
  83820. readonly name: string;
  83821. /**
  83822. * Defines whether this extension is enabled.
  83823. */
  83824. enabled: boolean;
  83825. /**
  83826. * Defines a number that determines the order the extensions are applied.
  83827. */
  83828. order: number;
  83829. private _loader;
  83830. /** @hidden */
  83831. constructor(loader: GLTFLoader);
  83832. /** @hidden */
  83833. dispose(): void;
  83834. /** @hidden */
  83835. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83836. private _loadUnlitPropertiesAsync;
  83837. }
  83838. }
  83839. declare module BABYLON.GLTF2.Loader.Extensions {
  83840. /**
  83841. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83842. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83843. */
  83844. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83845. /**
  83846. * The name of this extension.
  83847. */
  83848. readonly name: string;
  83849. /**
  83850. * Defines whether this extension is enabled.
  83851. */
  83852. enabled: boolean;
  83853. /**
  83854. * Defines a number that determines the order the extensions are applied.
  83855. */
  83856. order: number;
  83857. private _loader;
  83858. /** @hidden */
  83859. constructor(loader: GLTFLoader);
  83860. /** @hidden */
  83861. dispose(): void;
  83862. /** @hidden */
  83863. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83864. private _loadClearCoatPropertiesAsync;
  83865. }
  83866. }
  83867. declare module BABYLON.GLTF2.Loader.Extensions {
  83868. /**
  83869. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83870. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83871. * !!! Experimental Extension Subject to Changes !!!
  83872. */
  83873. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83874. /**
  83875. * The name of this extension.
  83876. */
  83877. readonly name: string;
  83878. /**
  83879. * Defines whether this extension is enabled.
  83880. */
  83881. enabled: boolean;
  83882. /**
  83883. * Defines a number that determines the order the extensions are applied.
  83884. */
  83885. order: number;
  83886. private _loader;
  83887. /** @hidden */
  83888. constructor(loader: GLTFLoader);
  83889. /** @hidden */
  83890. dispose(): void;
  83891. /** @hidden */
  83892. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83893. private _loadSheenPropertiesAsync;
  83894. }
  83895. }
  83896. declare module BABYLON.GLTF2.Loader.Extensions {
  83897. /**
  83898. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83899. * !!! Experimental Extension Subject to Changes !!!
  83900. */
  83901. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83902. /**
  83903. * The name of this extension.
  83904. */
  83905. readonly name: string;
  83906. /**
  83907. * Defines whether this extension is enabled.
  83908. */
  83909. enabled: boolean;
  83910. /**
  83911. * Defines a number that determines the order the extensions are applied.
  83912. */
  83913. order: number;
  83914. private _loader;
  83915. /** @hidden */
  83916. constructor(loader: GLTFLoader);
  83917. /** @hidden */
  83918. dispose(): void;
  83919. /** @hidden */
  83920. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83921. private _loadSpecularPropertiesAsync;
  83922. }
  83923. }
  83924. declare module BABYLON.GLTF2.Loader.Extensions {
  83925. /**
  83926. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83927. * !!! Experimental Extension Subject to Changes !!!
  83928. */
  83929. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83930. /**
  83931. * Default ior Value from the spec.
  83932. */
  83933. private static readonly _DEFAULT_IOR;
  83934. /**
  83935. * The name of this extension.
  83936. */
  83937. readonly name: string;
  83938. /**
  83939. * Defines whether this extension is enabled.
  83940. */
  83941. enabled: boolean;
  83942. /**
  83943. * Defines a number that determines the order the extensions are applied.
  83944. */
  83945. order: number;
  83946. private _loader;
  83947. /** @hidden */
  83948. constructor(loader: GLTFLoader);
  83949. /** @hidden */
  83950. dispose(): void;
  83951. /** @hidden */
  83952. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83953. private _loadIorPropertiesAsync;
  83954. }
  83955. }
  83956. declare module BABYLON.GLTF2.Loader.Extensions {
  83957. /**
  83958. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83959. * !!! Experimental Extension Subject to Changes !!!
  83960. */
  83961. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83962. /**
  83963. * The name of this extension.
  83964. */
  83965. readonly name: string;
  83966. /**
  83967. * Defines whether this extension is enabled.
  83968. */
  83969. enabled: boolean;
  83970. private _loader;
  83971. private _variants?;
  83972. /** @hidden */
  83973. constructor(loader: GLTFLoader);
  83974. /** @hidden */
  83975. dispose(): void;
  83976. /**
  83977. * Gets the list of available variant names for this asset.
  83978. * @param rootMesh The glTF root mesh
  83979. * @returns the list of all the variant names for this model
  83980. */
  83981. static GetAvailableVariants(rootMesh: Mesh): string[];
  83982. /**
  83983. * Gets the list of available variant names for this asset.
  83984. * @param rootMesh The glTF root mesh
  83985. * @returns the list of all the variant names for this model
  83986. */
  83987. getAvailableVariants(rootMesh: Mesh): string[];
  83988. /**
  83989. * Select a variant given a variant name or a list of variant names.
  83990. * @param rootMesh The glTF root mesh
  83991. * @param variantName The variant name(s) to select.
  83992. */
  83993. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83994. /**
  83995. * Select a variant given a variant name or a list of variant names.
  83996. * @param rootMesh The glTF root mesh
  83997. * @param variantName The variant name(s) to select.
  83998. */
  83999. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84000. /**
  84001. * Reset back to the original before selecting a variant.
  84002. * @param rootMesh The glTF root mesh
  84003. */
  84004. static Reset(rootMesh: Mesh): void;
  84005. /**
  84006. * Reset back to the original before selecting a variant.
  84007. * @param rootMesh The glTF root mesh
  84008. */
  84009. reset(rootMesh: Mesh): void;
  84010. /**
  84011. * Gets the last selected variant name(s) or null if original.
  84012. * @param rootMesh The glTF root mesh
  84013. * @returns The selected variant name(s).
  84014. */
  84015. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84016. /**
  84017. * Gets the last selected variant name(s) or null if original.
  84018. * @param rootMesh The glTF root mesh
  84019. * @returns The selected variant name(s).
  84020. */
  84021. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84022. private static _GetExtensionMetadata;
  84023. /** @hidden */
  84024. onLoading(): void;
  84025. /** @hidden */
  84026. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  84027. }
  84028. }
  84029. declare module BABYLON.GLTF2.Loader.Extensions {
  84030. /**
  84031. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  84032. * !!! Experimental Extension Subject to Changes !!!
  84033. */
  84034. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  84035. /**
  84036. * The name of this extension.
  84037. */
  84038. readonly name: string;
  84039. /**
  84040. * Defines whether this extension is enabled.
  84041. */
  84042. enabled: boolean;
  84043. /**
  84044. * Defines a number that determines the order the extensions are applied.
  84045. */
  84046. order: number;
  84047. private _loader;
  84048. /** @hidden */
  84049. constructor(loader: GLTFLoader);
  84050. /** @hidden */
  84051. dispose(): void;
  84052. /** @hidden */
  84053. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84054. private _loadTransparentPropertiesAsync;
  84055. }
  84056. }
  84057. declare module BABYLON.GLTF2.Loader.Extensions {
  84058. /**
  84059. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  84060. * !!! Experimental Extension Subject to Changes !!!
  84061. */
  84062. export class KHR_materials_translucency 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. /**
  84072. * Defines a number that determines the order the extensions are applied.
  84073. */
  84074. order: number;
  84075. private _loader;
  84076. /** @hidden */
  84077. constructor(loader: GLTFLoader);
  84078. /** @hidden */
  84079. dispose(): void;
  84080. /** @hidden */
  84081. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84082. private _loadTranslucentPropertiesAsync;
  84083. }
  84084. }
  84085. declare module BABYLON.GLTF2.Loader.Extensions {
  84086. /**
  84087. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  84088. */
  84089. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  84090. /**
  84091. * The name of this extension.
  84092. */
  84093. readonly name: string;
  84094. /**
  84095. * Defines whether this extension is enabled.
  84096. */
  84097. enabled: boolean;
  84098. /** @hidden */
  84099. constructor(loader: GLTFLoader);
  84100. /** @hidden */
  84101. dispose(): void;
  84102. }
  84103. }
  84104. declare module BABYLON.GLTF2.Loader.Extensions {
  84105. /**
  84106. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  84107. * !!! Experimental Extension Subject to Changes !!!
  84108. */
  84109. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  84110. /** The name of this extension. */
  84111. readonly name: string;
  84112. /** Defines whether this extension is enabled. */
  84113. enabled: boolean;
  84114. private _loader;
  84115. /** @hidden */
  84116. constructor(loader: GLTFLoader);
  84117. /** @hidden */
  84118. dispose(): void;
  84119. /** @hidden */
  84120. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84121. }
  84122. }
  84123. declare module BABYLON.GLTF2.Loader.Extensions {
  84124. /**
  84125. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  84126. */
  84127. export class KHR_texture_transform implements IGLTFLoaderExtension {
  84128. /**
  84129. * The name of this extension.
  84130. */
  84131. readonly name: string;
  84132. /**
  84133. * Defines whether this extension is enabled.
  84134. */
  84135. enabled: boolean;
  84136. private _loader;
  84137. /** @hidden */
  84138. constructor(loader: GLTFLoader);
  84139. /** @hidden */
  84140. dispose(): void;
  84141. /** @hidden */
  84142. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84143. }
  84144. }
  84145. declare module BABYLON.GLTF2.Loader.Extensions {
  84146. /**
  84147. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  84148. * !!! Experimental Extension Subject to Changes !!!
  84149. */
  84150. export class KHR_xmp implements IGLTFLoaderExtension {
  84151. /**
  84152. * The name of this extension.
  84153. */
  84154. readonly name: string;
  84155. /**
  84156. * Defines whether this extension is enabled.
  84157. */
  84158. enabled: boolean;
  84159. /**
  84160. * Defines a number that determines the order the extensions are applied.
  84161. */
  84162. order: number;
  84163. private _loader;
  84164. /** @hidden */
  84165. constructor(loader: GLTFLoader);
  84166. /** @hidden */
  84167. dispose(): void;
  84168. /**
  84169. * Called after the loader state changes to LOADING.
  84170. */
  84171. onLoading(): void;
  84172. }
  84173. }
  84174. declare module BABYLON.GLTF2.Loader.Extensions {
  84175. /**
  84176. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  84177. */
  84178. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  84179. /**
  84180. * The name of this extension.
  84181. */
  84182. readonly name: string;
  84183. /**
  84184. * Defines whether this extension is enabled.
  84185. */
  84186. enabled: boolean;
  84187. private _loader;
  84188. private _clips;
  84189. private _emitters;
  84190. /** @hidden */
  84191. constructor(loader: GLTFLoader);
  84192. /** @hidden */
  84193. dispose(): void;
  84194. /** @hidden */
  84195. onLoading(): void;
  84196. /** @hidden */
  84197. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84198. /** @hidden */
  84199. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84200. /** @hidden */
  84201. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  84202. private _loadClipAsync;
  84203. private _loadEmitterAsync;
  84204. private _getEventAction;
  84205. private _loadAnimationEventAsync;
  84206. }
  84207. }
  84208. declare module BABYLON.GLTF2.Loader.Extensions {
  84209. /**
  84210. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  84211. */
  84212. export class MSFT_lod implements IGLTFLoaderExtension {
  84213. /**
  84214. * The name of this extension.
  84215. */
  84216. readonly name: string;
  84217. /**
  84218. * Defines whether this extension is enabled.
  84219. */
  84220. enabled: boolean;
  84221. /**
  84222. * Defines a number that determines the order the extensions are applied.
  84223. */
  84224. order: number;
  84225. /**
  84226. * Maximum number of LODs to load, starting from the lowest LOD.
  84227. */
  84228. maxLODsToLoad: number;
  84229. /**
  84230. * Observable raised when all node LODs of one level are loaded.
  84231. * The event data is the index of the loaded LOD starting from zero.
  84232. * Dispose the loader to cancel the loading of the next level of LODs.
  84233. */
  84234. onNodeLODsLoadedObservable: Observable<number>;
  84235. /**
  84236. * Observable raised when all material LODs of one level are loaded.
  84237. * The event data is the index of the loaded LOD starting from zero.
  84238. * Dispose the loader to cancel the loading of the next level of LODs.
  84239. */
  84240. onMaterialLODsLoadedObservable: Observable<number>;
  84241. private _loader;
  84242. private _bufferLODs;
  84243. private _nodeIndexLOD;
  84244. private _nodeSignalLODs;
  84245. private _nodePromiseLODs;
  84246. private _nodeBufferLODs;
  84247. private _materialIndexLOD;
  84248. private _materialSignalLODs;
  84249. private _materialPromiseLODs;
  84250. private _materialBufferLODs;
  84251. /** @hidden */
  84252. constructor(loader: GLTFLoader);
  84253. /** @hidden */
  84254. dispose(): void;
  84255. /** @hidden */
  84256. onReady(): void;
  84257. /** @hidden */
  84258. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84259. /** @hidden */
  84260. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84261. /** @hidden */
  84262. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  84263. /** @hidden */
  84264. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  84265. /** @hidden */
  84266. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  84267. private _loadBufferLOD;
  84268. /**
  84269. * Gets an array of LOD properties from lowest to highest.
  84270. */
  84271. private _getLODs;
  84272. private _disposeTransformNode;
  84273. private _disposeMaterials;
  84274. }
  84275. }
  84276. declare module BABYLON.GLTF2.Loader.Extensions {
  84277. /** @hidden */
  84278. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  84279. readonly name: string;
  84280. enabled: boolean;
  84281. private _loader;
  84282. constructor(loader: GLTFLoader);
  84283. dispose(): void;
  84284. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84285. }
  84286. }
  84287. declare module BABYLON.GLTF2.Loader.Extensions {
  84288. /** @hidden */
  84289. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  84290. readonly name: string;
  84291. enabled: boolean;
  84292. private _loader;
  84293. constructor(loader: GLTFLoader);
  84294. dispose(): void;
  84295. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84296. }
  84297. }
  84298. declare module BABYLON.GLTF2.Loader.Extensions {
  84299. /**
  84300. * Store glTF extras (if present) in BJS objects' metadata
  84301. */
  84302. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  84303. /**
  84304. * The name of this extension.
  84305. */
  84306. readonly name: string;
  84307. /**
  84308. * Defines whether this extension is enabled.
  84309. */
  84310. enabled: boolean;
  84311. private _loader;
  84312. private _assignExtras;
  84313. /** @hidden */
  84314. constructor(loader: GLTFLoader);
  84315. /** @hidden */
  84316. dispose(): void;
  84317. /** @hidden */
  84318. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84319. /** @hidden */
  84320. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84321. /** @hidden */
  84322. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84323. }
  84324. }
  84325. declare module BABYLON {
  84326. /**
  84327. * Class reading and parsing the MTL file bundled with the obj file.
  84328. */
  84329. export class MTLFileLoader {
  84330. /**
  84331. * Invert Y-Axis of referenced textures on load
  84332. */
  84333. static INVERT_TEXTURE_Y: boolean;
  84334. /**
  84335. * All material loaded from the mtl will be set here
  84336. */
  84337. materials: StandardMaterial[];
  84338. /**
  84339. * This function will read the mtl file and create each material described inside
  84340. * This function could be improve by adding :
  84341. * -some component missing (Ni, Tf...)
  84342. * -including the specific options available
  84343. *
  84344. * @param scene defines the scene the material will be created in
  84345. * @param data defines the mtl data to parse
  84346. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84347. * @param forAssetContainer defines if the material should be registered in the scene
  84348. */
  84349. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84350. /**
  84351. * Gets the texture for the material.
  84352. *
  84353. * If the material is imported from input file,
  84354. * We sanitize the url to ensure it takes the textre from aside the material.
  84355. *
  84356. * @param rootUrl The root url to load from
  84357. * @param value The value stored in the mtl
  84358. * @return The Texture
  84359. */
  84360. private static _getTexture;
  84361. }
  84362. }
  84363. declare module BABYLON {
  84364. /**
  84365. * Options for loading OBJ/MTL files
  84366. */
  84367. type MeshLoadOptions = {
  84368. /**
  84369. * Defines if UVs are optimized by default during load.
  84370. */
  84371. OptimizeWithUV: boolean;
  84372. /**
  84373. * Defines custom scaling of UV coordinates of loaded meshes.
  84374. */
  84375. UVScaling: Vector2;
  84376. /**
  84377. * Invert model on y-axis (does a model scaling inversion)
  84378. */
  84379. InvertY: boolean;
  84380. /**
  84381. * Invert Y-Axis of referenced textures on load
  84382. */
  84383. InvertTextureY: boolean;
  84384. /**
  84385. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84386. */
  84387. ImportVertexColors: boolean;
  84388. /**
  84389. * Compute the normals for the model, even if normals are present in the file.
  84390. */
  84391. ComputeNormals: boolean;
  84392. /**
  84393. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84394. */
  84395. SkipMaterials: boolean;
  84396. /**
  84397. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84398. */
  84399. MaterialLoadingFailsSilently: boolean;
  84400. };
  84401. /**
  84402. * OBJ file type loader.
  84403. * This is a babylon scene loader plugin.
  84404. */
  84405. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84406. /**
  84407. * Defines if UVs are optimized by default during load.
  84408. */
  84409. static OPTIMIZE_WITH_UV: boolean;
  84410. /**
  84411. * Invert model on y-axis (does a model scaling inversion)
  84412. */
  84413. static INVERT_Y: boolean;
  84414. /**
  84415. * Invert Y-Axis of referenced textures on load
  84416. */
  84417. static get INVERT_TEXTURE_Y(): boolean;
  84418. static set INVERT_TEXTURE_Y(value: boolean);
  84419. /**
  84420. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84421. */
  84422. static IMPORT_VERTEX_COLORS: boolean;
  84423. /**
  84424. * Compute the normals for the model, even if normals are present in the file.
  84425. */
  84426. static COMPUTE_NORMALS: boolean;
  84427. /**
  84428. * Defines custom scaling of UV coordinates of loaded meshes.
  84429. */
  84430. static UV_SCALING: Vector2;
  84431. /**
  84432. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84433. */
  84434. static SKIP_MATERIALS: boolean;
  84435. /**
  84436. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84437. *
  84438. * Defaults to true for backwards compatibility.
  84439. */
  84440. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84441. /**
  84442. * Defines the name of the plugin.
  84443. */
  84444. name: string;
  84445. /**
  84446. * Defines the extension the plugin is able to load.
  84447. */
  84448. extensions: string;
  84449. /** @hidden */
  84450. obj: RegExp;
  84451. /** @hidden */
  84452. group: RegExp;
  84453. /** @hidden */
  84454. mtllib: RegExp;
  84455. /** @hidden */
  84456. usemtl: RegExp;
  84457. /** @hidden */
  84458. smooth: RegExp;
  84459. /** @hidden */
  84460. vertexPattern: RegExp;
  84461. /** @hidden */
  84462. normalPattern: RegExp;
  84463. /** @hidden */
  84464. uvPattern: RegExp;
  84465. /** @hidden */
  84466. facePattern1: RegExp;
  84467. /** @hidden */
  84468. facePattern2: RegExp;
  84469. /** @hidden */
  84470. facePattern3: RegExp;
  84471. /** @hidden */
  84472. facePattern4: RegExp;
  84473. /** @hidden */
  84474. facePattern5: RegExp;
  84475. private _forAssetContainer;
  84476. private _meshLoadOptions;
  84477. /**
  84478. * Creates loader for .OBJ files
  84479. *
  84480. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84481. */
  84482. constructor(meshLoadOptions?: MeshLoadOptions);
  84483. private static get currentMeshLoadOptions();
  84484. /**
  84485. * Calls synchronously the MTL file attached to this obj.
  84486. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84487. * Without this function materials are not displayed in the first frame (but displayed after).
  84488. * In consequence it is impossible to get material information in your HTML file
  84489. *
  84490. * @param url The URL of the MTL file
  84491. * @param rootUrl
  84492. * @param onSuccess Callback function to be called when the MTL file is loaded
  84493. * @private
  84494. */
  84495. private _loadMTL;
  84496. /**
  84497. * Instantiates a OBJ file loader plugin.
  84498. * @returns the created plugin
  84499. */
  84500. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84501. /**
  84502. * If the data string can be loaded directly.
  84503. *
  84504. * @param data string containing the file data
  84505. * @returns if the data can be loaded directly
  84506. */
  84507. canDirectLoad(data: string): boolean;
  84508. /**
  84509. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84510. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84511. * @param scene the scene the meshes should be added to
  84512. * @param data the OBJ data to load
  84513. * @param rootUrl root url to load from
  84514. * @param onProgress event that fires when loading progress has occured
  84515. * @param fileName Defines the name of the file to load
  84516. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84517. */
  84518. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  84519. meshes: AbstractMesh[];
  84520. particleSystems: IParticleSystem[];
  84521. skeletons: Skeleton[];
  84522. animationGroups: AnimationGroup[];
  84523. }>;
  84524. /**
  84525. * Imports all objects from the loaded OBJ data and adds them to the scene
  84526. * @param scene the scene the objects should be added to
  84527. * @param data the OBJ data to load
  84528. * @param rootUrl root url to load from
  84529. * @param onProgress event that fires when loading progress has occured
  84530. * @param fileName Defines the name of the file to load
  84531. * @returns a promise which completes when objects have been loaded to the scene
  84532. */
  84533. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84534. /**
  84535. * Load into an asset container.
  84536. * @param scene The scene to load into
  84537. * @param data The data to import
  84538. * @param rootUrl The root url for scene and resources
  84539. * @param onProgress The callback when the load progresses
  84540. * @param fileName Defines the name of the file to load
  84541. * @returns The loaded asset container
  84542. */
  84543. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84544. /**
  84545. * Read the OBJ file and create an Array of meshes.
  84546. * Each mesh contains all information given by the OBJ and the MTL file.
  84547. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84548. *
  84549. * @param meshesNames
  84550. * @param scene Scene The scene where are displayed the data
  84551. * @param data String The content of the obj file
  84552. * @param rootUrl String The path to the folder
  84553. * @returns Array<AbstractMesh>
  84554. * @private
  84555. */
  84556. private _parseSolid;
  84557. }
  84558. }
  84559. declare module BABYLON {
  84560. /**
  84561. * STL file type loader.
  84562. * This is a babylon scene loader plugin.
  84563. */
  84564. export class STLFileLoader implements ISceneLoaderPlugin {
  84565. /** @hidden */
  84566. solidPattern: RegExp;
  84567. /** @hidden */
  84568. facetsPattern: RegExp;
  84569. /** @hidden */
  84570. normalPattern: RegExp;
  84571. /** @hidden */
  84572. vertexPattern: RegExp;
  84573. /**
  84574. * Defines the name of the plugin.
  84575. */
  84576. name: string;
  84577. /**
  84578. * Defines the extensions the stl loader is able to load.
  84579. * force data to come in as an ArrayBuffer
  84580. * we'll convert to string if it looks like it's an ASCII .stl
  84581. */
  84582. extensions: ISceneLoaderPluginExtensions;
  84583. /**
  84584. * Import meshes into a scene.
  84585. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84586. * @param scene The scene to import into
  84587. * @param data The data to import
  84588. * @param rootUrl The root url for scene and resources
  84589. * @param meshes The meshes array to import into
  84590. * @param particleSystems The particle systems array to import into
  84591. * @param skeletons The skeletons array to import into
  84592. * @param onError The callback when import fails
  84593. * @returns True if successful or false otherwise
  84594. */
  84595. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84596. /**
  84597. * Load into a scene.
  84598. * @param scene The scene to load into
  84599. * @param data The data to import
  84600. * @param rootUrl The root url for scene and resources
  84601. * @param onError The callback when import fails
  84602. * @returns true if successful or false otherwise
  84603. */
  84604. load(scene: Scene, data: any, rootUrl: string): boolean;
  84605. /**
  84606. * Load into an asset container.
  84607. * @param scene The scene to load into
  84608. * @param data The data to import
  84609. * @param rootUrl The root url for scene and resources
  84610. * @param onError The callback when import fails
  84611. * @returns The loaded asset container
  84612. */
  84613. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84614. private _isBinary;
  84615. private _parseBinary;
  84616. private _parseASCII;
  84617. }
  84618. }
  84619. declare module BABYLON {
  84620. /**
  84621. * Class for generating OBJ data from a Babylon scene.
  84622. */
  84623. export class OBJExport {
  84624. /**
  84625. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84626. * @param mesh defines the list of meshes to serialize
  84627. * @param materials defines if materials should be exported
  84628. * @param matlibname defines the name of the associated mtl file
  84629. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84630. * @returns the OBJ content
  84631. */
  84632. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84633. /**
  84634. * Exports the material(s) of a mesh in .MTL file format (text)
  84635. * @param mesh defines the mesh to extract the material from
  84636. * @returns the mtl content
  84637. */
  84638. static MTL(mesh: Mesh): string;
  84639. }
  84640. }
  84641. declare module BABYLON {
  84642. /** @hidden */
  84643. export var __IGLTFExporterExtension: number;
  84644. /**
  84645. * Interface for extending the exporter
  84646. * @hidden
  84647. */
  84648. export interface IGLTFExporterExtension {
  84649. /**
  84650. * The name of this extension
  84651. */
  84652. readonly name: string;
  84653. /**
  84654. * Defines whether this extension is enabled
  84655. */
  84656. enabled: boolean;
  84657. /**
  84658. * Defines whether this extension is required
  84659. */
  84660. required: boolean;
  84661. }
  84662. }
  84663. declare module BABYLON.GLTF2.Exporter {
  84664. /** @hidden */
  84665. export var __IGLTFExporterExtensionV2: number;
  84666. /**
  84667. * Interface for a glTF exporter extension
  84668. * @hidden
  84669. */
  84670. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84671. /**
  84672. * Define this method to modify the default behavior before exporting a texture
  84673. * @param context The context when loading the asset
  84674. * @param babylonTexture The Babylon.js texture
  84675. * @param mimeType The mime-type of the generated image
  84676. * @returns A promise that resolves with the exported texture
  84677. */
  84678. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84679. /**
  84680. * Define this method to get notified when a texture info is created
  84681. * @param context The context when loading the asset
  84682. * @param textureInfo The glTF texture info
  84683. * @param babylonTexture The Babylon.js texture
  84684. */
  84685. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84686. /**
  84687. * Define this method to modify the default behavior when exporting texture info
  84688. * @param context The context when loading the asset
  84689. * @param meshPrimitive glTF mesh primitive
  84690. * @param babylonSubMesh Babylon submesh
  84691. * @param binaryWriter glTF serializer binary writer instance
  84692. * @returns nullable IMeshPrimitive promise
  84693. */
  84694. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84695. /**
  84696. * Define this method to modify the default behavior when exporting a node
  84697. * @param context The context when exporting the node
  84698. * @param node glTF node
  84699. * @param babylonNode BabylonJS node
  84700. * @returns nullable INode promise
  84701. */
  84702. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84703. [key: number]: number;
  84704. }): Promise<Nullable<INode>>;
  84705. /**
  84706. * Define this method to modify the default behavior when exporting a material
  84707. * @param material glTF material
  84708. * @param babylonMaterial BabylonJS material
  84709. * @returns nullable IMaterial promise
  84710. */
  84711. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84712. /**
  84713. * Define this method to return additional textures to export from a material
  84714. * @param material glTF material
  84715. * @param babylonMaterial BabylonJS material
  84716. * @returns List of textures
  84717. */
  84718. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84719. /** Gets a boolean indicating that this extension was used */
  84720. wasUsed: boolean;
  84721. /** Gets a boolean indicating that this extension is required for the file to work */
  84722. required: boolean;
  84723. /**
  84724. * Called after the exporter state changes to EXPORTING
  84725. */
  84726. onExporting?(): void;
  84727. }
  84728. }
  84729. declare module BABYLON.GLTF2.Exporter {
  84730. /**
  84731. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84732. * @hidden
  84733. */
  84734. export class _GLTFMaterialExporter {
  84735. /**
  84736. * Represents the dielectric specular values for R, G and B
  84737. */
  84738. private static readonly _DielectricSpecular;
  84739. /**
  84740. * Allows the maximum specular power to be defined for material calculations
  84741. */
  84742. private static readonly _MaxSpecularPower;
  84743. /**
  84744. * Mapping to store textures
  84745. */
  84746. private _textureMap;
  84747. /**
  84748. * Numeric tolerance value
  84749. */
  84750. private static readonly _Epsilon;
  84751. /**
  84752. * Reference to the glTF Exporter
  84753. */
  84754. private _exporter;
  84755. constructor(exporter: _Exporter);
  84756. /**
  84757. * Specifies if two colors are approximately equal in value
  84758. * @param color1 first color to compare to
  84759. * @param color2 second color to compare to
  84760. * @param epsilon threshold value
  84761. */
  84762. private static FuzzyEquals;
  84763. /**
  84764. * Gets the materials from a Babylon scene and converts them to glTF materials
  84765. * @param scene babylonjs scene
  84766. * @param mimeType texture mime type
  84767. * @param images array of images
  84768. * @param textures array of textures
  84769. * @param materials array of materials
  84770. * @param imageData mapping of texture names to base64 textures
  84771. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84772. */
  84773. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84774. /**
  84775. * Makes a copy of the glTF material without the texture parameters
  84776. * @param originalMaterial original glTF material
  84777. * @returns glTF material without texture parameters
  84778. */
  84779. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84780. /**
  84781. * Specifies if the material has any texture parameters present
  84782. * @param material glTF Material
  84783. * @returns boolean specifying if texture parameters are present
  84784. */
  84785. _hasTexturesPresent(material: IMaterial): boolean;
  84786. /**
  84787. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84788. * @param babylonStandardMaterial
  84789. * @returns glTF Metallic Roughness Material representation
  84790. */
  84791. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84792. /**
  84793. * Computes the metallic factor
  84794. * @param diffuse diffused value
  84795. * @param specular specular value
  84796. * @param oneMinusSpecularStrength one minus the specular strength
  84797. * @returns metallic value
  84798. */
  84799. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84800. /**
  84801. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84802. * @param glTFMaterial glTF material
  84803. * @param babylonMaterial Babylon material
  84804. */
  84805. private static _SetAlphaMode;
  84806. /**
  84807. * Converts a Babylon Standard Material to a glTF Material
  84808. * @param babylonStandardMaterial BJS Standard Material
  84809. * @param mimeType mime type to use for the textures
  84810. * @param images array of glTF image interfaces
  84811. * @param textures array of glTF texture interfaces
  84812. * @param materials array of glTF material interfaces
  84813. * @param imageData map of image file name to data
  84814. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84815. */
  84816. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84817. private _finishMaterial;
  84818. /**
  84819. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84820. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84821. * @param mimeType mime type to use for the textures
  84822. * @param images array of glTF image interfaces
  84823. * @param textures array of glTF texture interfaces
  84824. * @param materials array of glTF material interfaces
  84825. * @param imageData map of image file name to data
  84826. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84827. */
  84828. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84829. /**
  84830. * Converts an image typed array buffer to a base64 image
  84831. * @param buffer typed array buffer
  84832. * @param width width of the image
  84833. * @param height height of the image
  84834. * @param mimeType mimetype of the image
  84835. * @returns base64 image string
  84836. */
  84837. private _createBase64FromCanvasAsync;
  84838. /**
  84839. * Generates a white texture based on the specified width and height
  84840. * @param width width of the texture in pixels
  84841. * @param height height of the texture in pixels
  84842. * @param scene babylonjs scene
  84843. * @returns white texture
  84844. */
  84845. private _createWhiteTexture;
  84846. /**
  84847. * 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
  84848. * @param texture1 first texture to resize
  84849. * @param texture2 second texture to resize
  84850. * @param scene babylonjs scene
  84851. * @returns resized textures or null
  84852. */
  84853. private _resizeTexturesToSameDimensions;
  84854. /**
  84855. * Converts an array of pixels to a Float32Array
  84856. * Throws an error if the pixel format is not supported
  84857. * @param pixels - array buffer containing pixel values
  84858. * @returns Float32 of pixels
  84859. */
  84860. private _convertPixelArrayToFloat32;
  84861. /**
  84862. * Convert Specular Glossiness Textures to Metallic Roughness
  84863. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84864. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84865. * @param diffuseTexture texture used to store diffuse information
  84866. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84867. * @param factors specular glossiness material factors
  84868. * @param mimeType the mime type to use for the texture
  84869. * @returns pbr metallic roughness interface or null
  84870. */
  84871. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84872. /**
  84873. * Converts specular glossiness material properties to metallic roughness
  84874. * @param specularGlossiness interface with specular glossiness material properties
  84875. * @returns interface with metallic roughness material properties
  84876. */
  84877. private _convertSpecularGlossinessToMetallicRoughness;
  84878. /**
  84879. * Calculates the surface reflectance, independent of lighting conditions
  84880. * @param color Color source to calculate brightness from
  84881. * @returns number representing the perceived brightness, or zero if color is undefined
  84882. */
  84883. private _getPerceivedBrightness;
  84884. /**
  84885. * Returns the maximum color component value
  84886. * @param color
  84887. * @returns maximum color component value, or zero if color is null or undefined
  84888. */
  84889. private _getMaxComponent;
  84890. /**
  84891. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84892. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84893. * @param mimeType mime type to use for the textures
  84894. * @param images array of glTF image interfaces
  84895. * @param textures array of glTF texture interfaces
  84896. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84897. * @param imageData map of image file name to data
  84898. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84899. * @returns glTF PBR Metallic Roughness factors
  84900. */
  84901. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84902. private _getGLTFTextureSampler;
  84903. private _getGLTFTextureWrapMode;
  84904. private _getGLTFTextureWrapModesSampler;
  84905. /**
  84906. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84907. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84908. * @param mimeType mime type to use for the textures
  84909. * @param images array of glTF image interfaces
  84910. * @param textures array of glTF texture interfaces
  84911. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84912. * @param imageData map of image file name to data
  84913. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84914. * @returns glTF PBR Metallic Roughness factors
  84915. */
  84916. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84917. /**
  84918. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84919. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84920. * @param mimeType mime type to use for the textures
  84921. * @param images array of glTF image interfaces
  84922. * @param textures array of glTF texture interfaces
  84923. * @param materials array of glTF material interfaces
  84924. * @param imageData map of image file name to data
  84925. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84926. */
  84927. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84928. private setMetallicRoughnessPbrMaterial;
  84929. private getPixelsFromTexture;
  84930. /**
  84931. * Extracts a texture from a Babylon texture into file data and glTF data
  84932. * @param babylonTexture Babylon texture to extract
  84933. * @param mimeType Mime Type of the babylonTexture
  84934. * @return glTF texture info, or null if the texture format is not supported
  84935. */
  84936. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84937. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84938. /**
  84939. * Builds a texture from base64 string
  84940. * @param base64Texture base64 texture string
  84941. * @param baseTextureName Name to use for the texture
  84942. * @param mimeType image mime type for the texture
  84943. * @param images array of images
  84944. * @param textures array of textures
  84945. * @param imageData map of image data
  84946. * @returns glTF texture info, or null if the texture format is not supported
  84947. */
  84948. private _getTextureInfoFromBase64;
  84949. }
  84950. }
  84951. declare module BABYLON {
  84952. /**
  84953. * Class for holding and downloading glTF file data
  84954. */
  84955. export class GLTFData {
  84956. /**
  84957. * Object which contains the file name as the key and its data as the value
  84958. */
  84959. glTFFiles: {
  84960. [fileName: string]: string | Blob;
  84961. };
  84962. /**
  84963. * Initializes the glTF file object
  84964. */
  84965. constructor();
  84966. /**
  84967. * Downloads the glTF data as files based on their names and data
  84968. */
  84969. downloadFiles(): void;
  84970. }
  84971. }
  84972. declare module BABYLON {
  84973. /**
  84974. * Holds a collection of exporter options and parameters
  84975. */
  84976. export interface IExportOptions {
  84977. /**
  84978. * Function which indicates whether a babylon node should be exported or not
  84979. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84980. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84981. */
  84982. shouldExportNode?(node: Node): boolean;
  84983. /**
  84984. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84985. * @param metadata source metadata to read from
  84986. * @returns the data to store to glTF node extras
  84987. */
  84988. metadataSelector?(metadata: any): any;
  84989. /**
  84990. * The sample rate to bake animation curves
  84991. */
  84992. animationSampleRate?: number;
  84993. /**
  84994. * Begin serialization without waiting for the scene to be ready
  84995. */
  84996. exportWithoutWaitingForScene?: boolean;
  84997. /**
  84998. * Indicates if coordinate system swapping root nodes should be included in export
  84999. */
  85000. includeCoordinateSystemConversionNodes?: boolean;
  85001. }
  85002. /**
  85003. * Class for generating glTF data from a Babylon scene.
  85004. */
  85005. export class GLTF2Export {
  85006. /**
  85007. * Exports the geometry of the scene to .gltf file format asynchronously
  85008. * @param scene Babylon scene with scene hierarchy information
  85009. * @param filePrefix File prefix to use when generating the glTF file
  85010. * @param options Exporter options
  85011. * @returns Returns an object with a .gltf file and associates texture names
  85012. * as keys and their data and paths as values
  85013. */
  85014. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85015. private static _PreExportAsync;
  85016. private static _PostExportAsync;
  85017. /**
  85018. * Exports the geometry of the scene to .glb file format asychronously
  85019. * @param scene Babylon scene with scene hierarchy information
  85020. * @param filePrefix File prefix to use when generating glb file
  85021. * @param options Exporter options
  85022. * @returns Returns an object with a .glb filename as key and data as value
  85023. */
  85024. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85025. }
  85026. }
  85027. declare module BABYLON.GLTF2.Exporter {
  85028. /**
  85029. * @hidden
  85030. */
  85031. export class _GLTFUtilities {
  85032. /**
  85033. * Creates a buffer view based on the supplied arguments
  85034. * @param bufferIndex index value of the specified buffer
  85035. * @param byteOffset byte offset value
  85036. * @param byteLength byte length of the bufferView
  85037. * @param byteStride byte distance between conequential elements
  85038. * @param name name of the buffer view
  85039. * @returns bufferView for glTF
  85040. */
  85041. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  85042. /**
  85043. * Creates an accessor based on the supplied arguments
  85044. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  85045. * @param name The name of the accessor
  85046. * @param type The type of the accessor
  85047. * @param componentType The datatype of components in the attribute
  85048. * @param count The number of attributes referenced by this accessor
  85049. * @param byteOffset The offset relative to the start of the bufferView in bytes
  85050. * @param min Minimum value of each component in this attribute
  85051. * @param max Maximum value of each component in this attribute
  85052. * @returns accessor for glTF
  85053. */
  85054. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  85055. /**
  85056. * Calculates the minimum and maximum values of an array of position floats
  85057. * @param positions Positions array of a mesh
  85058. * @param vertexStart Starting vertex offset to calculate min and max values
  85059. * @param vertexCount Number of vertices to check for min and max values
  85060. * @returns min number array and max number array
  85061. */
  85062. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  85063. min: number[];
  85064. max: number[];
  85065. };
  85066. /**
  85067. * Converts a new right-handed Vector3
  85068. * @param vector vector3 array
  85069. * @returns right-handed Vector3
  85070. */
  85071. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  85072. /**
  85073. * Converts a Vector3 to right-handed
  85074. * @param vector Vector3 to convert to right-handed
  85075. */
  85076. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  85077. /**
  85078. * Converts a three element number array to right-handed
  85079. * @param vector number array to convert to right-handed
  85080. */
  85081. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  85082. /**
  85083. * Converts a new right-handed Vector3
  85084. * @param vector vector3 array
  85085. * @returns right-handed Vector3
  85086. */
  85087. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  85088. /**
  85089. * Converts a Vector3 to right-handed
  85090. * @param vector Vector3 to convert to right-handed
  85091. */
  85092. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  85093. /**
  85094. * Converts a three element number array to right-handed
  85095. * @param vector number array to convert to right-handed
  85096. */
  85097. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  85098. /**
  85099. * Converts a Vector4 to right-handed
  85100. * @param vector Vector4 to convert to right-handed
  85101. */
  85102. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  85103. /**
  85104. * Converts a Vector4 to right-handed
  85105. * @param vector Vector4 to convert to right-handed
  85106. */
  85107. static _GetRightHandedArray4FromRef(vector: number[]): void;
  85108. /**
  85109. * Converts a Quaternion to right-handed
  85110. * @param quaternion Source quaternion to convert to right-handed
  85111. */
  85112. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  85113. /**
  85114. * Converts a Quaternion to right-handed
  85115. * @param quaternion Source quaternion to convert to right-handed
  85116. */
  85117. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  85118. static _NormalizeTangentFromRef(tangent: Vector4): void;
  85119. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  85120. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  85121. }
  85122. }
  85123. declare module BABYLON.GLTF2.Exporter {
  85124. /**
  85125. * Converts Babylon Scene into glTF 2.0.
  85126. * @hidden
  85127. */
  85128. export class _Exporter {
  85129. /**
  85130. * Stores the glTF to export
  85131. */
  85132. _glTF: IGLTF;
  85133. /**
  85134. * Stores all generated buffer views, which represents views into the main glTF buffer data
  85135. */
  85136. _bufferViews: IBufferView[];
  85137. /**
  85138. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  85139. */
  85140. _accessors: IAccessor[];
  85141. /**
  85142. * Stores all the generated nodes, which contains transform and/or mesh information per node
  85143. */
  85144. _nodes: INode[];
  85145. /**
  85146. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  85147. */
  85148. private _scenes;
  85149. /**
  85150. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  85151. */
  85152. private _meshes;
  85153. /**
  85154. * Stores all the generated material information, which represents the appearance of each primitive
  85155. */
  85156. _materials: IMaterial[];
  85157. _materialMap: {
  85158. [materialID: number]: number;
  85159. };
  85160. /**
  85161. * Stores all the generated texture information, which is referenced by glTF materials
  85162. */
  85163. _textures: ITexture[];
  85164. /**
  85165. * Stores all the generated image information, which is referenced by glTF textures
  85166. */
  85167. _images: IImage[];
  85168. /**
  85169. * Stores all the texture samplers
  85170. */
  85171. _samplers: ISampler[];
  85172. /**
  85173. * Stores all the generated glTF skins
  85174. */
  85175. _skins: ISkin[];
  85176. /**
  85177. * Stores all the generated animation samplers, which is referenced by glTF animations
  85178. */
  85179. /**
  85180. * Stores the animations for glTF models
  85181. */
  85182. private _animations;
  85183. /**
  85184. * Stores the total amount of bytes stored in the glTF buffer
  85185. */
  85186. private _totalByteLength;
  85187. /**
  85188. * Stores a reference to the Babylon scene containing the source geometry and material information
  85189. */
  85190. _babylonScene: Scene;
  85191. /**
  85192. * Stores a map of the image data, where the key is the file name and the value
  85193. * is the image data
  85194. */
  85195. _imageData: {
  85196. [fileName: string]: {
  85197. data: Uint8Array;
  85198. mimeType: ImageMimeType;
  85199. };
  85200. };
  85201. protected _orderedImageData: Array<{
  85202. data: Uint8Array;
  85203. mimeType: ImageMimeType;
  85204. }>;
  85205. /**
  85206. * Stores a map of the unique id of a node to its index in the node array
  85207. */
  85208. _nodeMap: {
  85209. [key: number]: number;
  85210. };
  85211. /**
  85212. * Specifies if the source Babylon scene was left handed, and needed conversion.
  85213. */
  85214. _convertToRightHandedSystem: boolean;
  85215. /**
  85216. * Specifies if a Babylon node should be converted to right-handed on export
  85217. */
  85218. _convertToRightHandedSystemMap: {
  85219. [nodeId: number]: boolean;
  85220. };
  85221. _includeCoordinateSystemConversionNodes: boolean;
  85222. /**
  85223. * Baked animation sample rate
  85224. */
  85225. private _animationSampleRate;
  85226. private _options;
  85227. private _localEngine;
  85228. _glTFMaterialExporter: _GLTFMaterialExporter;
  85229. private _extensions;
  85230. private static _ExtensionNames;
  85231. private static _ExtensionFactories;
  85232. private _applyExtension;
  85233. private _applyExtensions;
  85234. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  85235. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  85236. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85237. [key: number]: number;
  85238. }): Promise<Nullable<INode>>;
  85239. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  85240. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  85241. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  85242. private _forEachExtensions;
  85243. private _extensionsOnExporting;
  85244. /**
  85245. * Load glTF serializer extensions
  85246. */
  85247. private _loadExtensions;
  85248. /**
  85249. * Creates a glTF Exporter instance, which can accept optional exporter options
  85250. * @param babylonScene Babylon scene object
  85251. * @param options Options to modify the behavior of the exporter
  85252. */
  85253. constructor(babylonScene: Scene, options?: IExportOptions);
  85254. dispose(): void;
  85255. /**
  85256. * Registers a glTF exporter extension
  85257. * @param name Name of the extension to export
  85258. * @param factory The factory function that creates the exporter extension
  85259. */
  85260. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  85261. /**
  85262. * Un-registers an exporter extension
  85263. * @param name The name fo the exporter extension
  85264. * @returns A boolean indicating whether the extension has been un-registered
  85265. */
  85266. static UnregisterExtension(name: string): boolean;
  85267. /**
  85268. * Lazy load a local engine
  85269. */
  85270. _getLocalEngine(): Engine;
  85271. private reorderIndicesBasedOnPrimitiveMode;
  85272. /**
  85273. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  85274. * clock-wise during export to glTF
  85275. * @param submesh BabylonJS submesh
  85276. * @param primitiveMode Primitive mode of the mesh
  85277. * @param sideOrientation the winding order of the submesh
  85278. * @param vertexBufferKind The type of vertex attribute
  85279. * @param meshAttributeArray The vertex attribute data
  85280. * @param byteOffset The offset to the binary data
  85281. * @param binaryWriter The binary data for the glTF file
  85282. * @param convertToRightHandedSystem Converts the values to right-handed
  85283. */
  85284. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  85285. /**
  85286. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  85287. * clock-wise during export to glTF
  85288. * @param submesh BabylonJS submesh
  85289. * @param primitiveMode Primitive mode of the mesh
  85290. * @param sideOrientation the winding order of the submesh
  85291. * @param vertexBufferKind The type of vertex attribute
  85292. * @param meshAttributeArray The vertex attribute data
  85293. * @param byteOffset The offset to the binary data
  85294. * @param binaryWriter The binary data for the glTF file
  85295. * @param convertToRightHandedSystem Converts the values to right-handed
  85296. */
  85297. private reorderTriangleFillMode;
  85298. /**
  85299. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  85300. * clock-wise during export to glTF
  85301. * @param submesh BabylonJS submesh
  85302. * @param primitiveMode Primitive mode of the mesh
  85303. * @param sideOrientation the winding order of the submesh
  85304. * @param vertexBufferKind The type of vertex attribute
  85305. * @param meshAttributeArray The vertex attribute data
  85306. * @param byteOffset The offset to the binary data
  85307. * @param binaryWriter The binary data for the glTF file
  85308. * @param convertToRightHandedSystem Converts the values to right-handed
  85309. */
  85310. private reorderTriangleStripDrawMode;
  85311. /**
  85312. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85313. * clock-wise during export to glTF
  85314. * @param submesh BabylonJS submesh
  85315. * @param primitiveMode Primitive mode of the mesh
  85316. * @param sideOrientation the winding order of the submesh
  85317. * @param vertexBufferKind The type of vertex attribute
  85318. * @param meshAttributeArray The vertex attribute data
  85319. * @param byteOffset The offset to the binary data
  85320. * @param binaryWriter The binary data for the glTF file
  85321. * @param convertToRightHandedSystem Converts the values to right-handed
  85322. */
  85323. private reorderTriangleFanMode;
  85324. /**
  85325. * Writes the vertex attribute data to binary
  85326. * @param vertices The vertices to write to the binary writer
  85327. * @param byteOffset The offset into the binary writer to overwrite binary data
  85328. * @param vertexAttributeKind The vertex attribute type
  85329. * @param meshAttributeArray The vertex attribute data
  85330. * @param binaryWriter The writer containing the binary data
  85331. * @param convertToRightHandedSystem Converts the values to right-handed
  85332. */
  85333. private writeVertexAttributeData;
  85334. /**
  85335. * Writes mesh attribute data to a data buffer
  85336. * Returns the bytelength of the data
  85337. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85338. * @param meshAttributeArray Array containing the attribute data
  85339. * @param byteStride Specifies the space between data
  85340. * @param binaryWriter The buffer to write the binary data to
  85341. * @param convertToRightHandedSystem Converts the values to right-handed
  85342. */
  85343. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85344. /**
  85345. * Writes mesh attribute data to a data buffer
  85346. * Returns the bytelength of the data
  85347. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85348. * @param meshAttributeArray Array containing the attribute data
  85349. * @param byteStride Specifies the space between data
  85350. * @param binaryWriter The buffer to write the binary data to
  85351. * @param convertToRightHandedSystem Converts the values to right-handed
  85352. */
  85353. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85354. /**
  85355. * Generates glTF json data
  85356. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85357. * @param glTFPrefix Text to use when prefixing a glTF file
  85358. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85359. * @returns json data as string
  85360. */
  85361. private generateJSON;
  85362. /**
  85363. * Generates data for .gltf and .bin files based on the glTF prefix string
  85364. * @param glTFPrefix Text to use when prefixing a glTF file
  85365. * @param dispose Dispose the exporter
  85366. * @returns GLTFData with glTF file data
  85367. */
  85368. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85369. /**
  85370. * Creates a binary buffer for glTF
  85371. * @returns array buffer for binary data
  85372. */
  85373. private _generateBinaryAsync;
  85374. /**
  85375. * Pads the number to a multiple of 4
  85376. * @param num number to pad
  85377. * @returns padded number
  85378. */
  85379. private _getPadding;
  85380. /**
  85381. * @hidden
  85382. */
  85383. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85384. /**
  85385. * Sets the TRS for each node
  85386. * @param node glTF Node for storing the transformation data
  85387. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85388. * @param convertToRightHandedSystem Converts the values to right-handed
  85389. */
  85390. private setNodeTransformation;
  85391. private getVertexBufferFromMesh;
  85392. /**
  85393. * Creates a bufferview based on the vertices type for the Babylon mesh
  85394. * @param kind Indicates the type of vertices data
  85395. * @param componentType Indicates the numerical type used to store the data
  85396. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85397. * @param binaryWriter The buffer to write the bufferview data to
  85398. * @param convertToRightHandedSystem Converts the values to right-handed
  85399. */
  85400. private createBufferViewKind;
  85401. /**
  85402. * Creates a bufferview based on the vertices type for the Babylon mesh
  85403. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85404. * @param babylonMorphTarget the morph target to be exported
  85405. * @param binaryWriter The buffer to write the bufferview data to
  85406. * @param convertToRightHandedSystem Converts the values to right-handed
  85407. */
  85408. private setMorphTargetAttributes;
  85409. /**
  85410. * The primitive mode of the Babylon mesh
  85411. * @param babylonMesh The BabylonJS mesh
  85412. */
  85413. private getMeshPrimitiveMode;
  85414. /**
  85415. * Sets the primitive mode of the glTF mesh primitive
  85416. * @param meshPrimitive glTF mesh primitive
  85417. * @param primitiveMode The primitive mode
  85418. */
  85419. private setPrimitiveMode;
  85420. /**
  85421. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85422. * @param meshPrimitive glTF mesh primitive
  85423. * @param attributeKind vertex attribute
  85424. * @returns boolean specifying if uv coordinates are present
  85425. */
  85426. private setAttributeKind;
  85427. /**
  85428. * Sets data for the primitive attributes of each submesh
  85429. * @param mesh glTF Mesh object to store the primitive attribute information
  85430. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85431. * @param binaryWriter Buffer to write the attribute data to
  85432. * @param convertToRightHandedSystem Converts the values to right-handed
  85433. */
  85434. private setPrimitiveAttributesAsync;
  85435. /**
  85436. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85437. * @param node The node to check
  85438. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85439. */
  85440. private isBabylonCoordinateSystemConvertingNode;
  85441. /**
  85442. * Creates a glTF scene based on the array of meshes
  85443. * Returns the the total byte offset
  85444. * @param babylonScene Babylon scene to get the mesh data from
  85445. * @param binaryWriter Buffer to write binary data to
  85446. */
  85447. private createSceneAsync;
  85448. /**
  85449. * Creates a mapping of Node unique id to node index and handles animations
  85450. * @param babylonScene Babylon Scene
  85451. * @param nodes Babylon transform nodes
  85452. * @param binaryWriter Buffer to write binary data to
  85453. * @returns Node mapping of unique id to index
  85454. */
  85455. private createNodeMapAndAnimationsAsync;
  85456. /**
  85457. * Creates a glTF node from a Babylon mesh
  85458. * @param babylonMesh Source Babylon mesh
  85459. * @param binaryWriter Buffer for storing geometry data
  85460. * @param convertToRightHandedSystem Converts the values to right-handed
  85461. * @param nodeMap Node mapping of unique id to glTF node index
  85462. * @returns glTF node
  85463. */
  85464. private createNodeAsync;
  85465. /**
  85466. * Creates a glTF skin from a Babylon skeleton
  85467. * @param babylonScene Babylon Scene
  85468. * @param nodes Babylon transform nodes
  85469. * @param binaryWriter Buffer to write binary data to
  85470. * @returns Node mapping of unique id to index
  85471. */
  85472. private createSkinsAsync;
  85473. }
  85474. /**
  85475. * @hidden
  85476. *
  85477. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85478. */
  85479. export class _BinaryWriter {
  85480. /**
  85481. * Array buffer which stores all binary data
  85482. */
  85483. private _arrayBuffer;
  85484. /**
  85485. * View of the array buffer
  85486. */
  85487. private _dataView;
  85488. /**
  85489. * byte offset of data in array buffer
  85490. */
  85491. private _byteOffset;
  85492. /**
  85493. * Initialize binary writer with an initial byte length
  85494. * @param byteLength Initial byte length of the array buffer
  85495. */
  85496. constructor(byteLength: number);
  85497. /**
  85498. * Resize the array buffer to the specified byte length
  85499. * @param byteLength
  85500. */
  85501. private resizeBuffer;
  85502. /**
  85503. * Get an array buffer with the length of the byte offset
  85504. * @returns ArrayBuffer resized to the byte offset
  85505. */
  85506. getArrayBuffer(): ArrayBuffer;
  85507. /**
  85508. * Get the byte offset of the array buffer
  85509. * @returns byte offset
  85510. */
  85511. getByteOffset(): number;
  85512. /**
  85513. * Stores an UInt8 in the array buffer
  85514. * @param entry
  85515. * @param byteOffset If defined, specifies where to set the value as an offset.
  85516. */
  85517. setUInt8(entry: number, byteOffset?: number): void;
  85518. /**
  85519. * Stores an UInt16 in the array buffer
  85520. * @param entry
  85521. * @param byteOffset If defined, specifies where to set the value as an offset.
  85522. */
  85523. setUInt16(entry: number, byteOffset?: number): void;
  85524. /**
  85525. * Gets an UInt32 in the array buffer
  85526. * @param entry
  85527. * @param byteOffset If defined, specifies where to set the value as an offset.
  85528. */
  85529. getUInt32(byteOffset: number): number;
  85530. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85531. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85532. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85533. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85534. /**
  85535. * Stores a Float32 in the array buffer
  85536. * @param entry
  85537. */
  85538. setFloat32(entry: number, byteOffset?: number): void;
  85539. /**
  85540. * Stores an UInt32 in the array buffer
  85541. * @param entry
  85542. * @param byteOffset If defined, specifies where to set the value as an offset.
  85543. */
  85544. setUInt32(entry: number, byteOffset?: number): void;
  85545. }
  85546. }
  85547. declare module BABYLON.GLTF2.Exporter {
  85548. /**
  85549. * @hidden
  85550. * Interface to store animation data.
  85551. */
  85552. export interface _IAnimationData {
  85553. /**
  85554. * Keyframe data.
  85555. */
  85556. inputs: number[];
  85557. /**
  85558. * Value data.
  85559. */
  85560. outputs: number[][];
  85561. /**
  85562. * Animation interpolation data.
  85563. */
  85564. samplerInterpolation: AnimationSamplerInterpolation;
  85565. /**
  85566. * Minimum keyframe value.
  85567. */
  85568. inputsMin: number;
  85569. /**
  85570. * Maximum keyframe value.
  85571. */
  85572. inputsMax: number;
  85573. }
  85574. /**
  85575. * @hidden
  85576. */
  85577. export interface _IAnimationInfo {
  85578. /**
  85579. * The target channel for the animation
  85580. */
  85581. animationChannelTargetPath: AnimationChannelTargetPath;
  85582. /**
  85583. * The glTF accessor type for the data.
  85584. */
  85585. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85586. /**
  85587. * Specifies if quaternions should be used.
  85588. */
  85589. useQuaternion: boolean;
  85590. }
  85591. /**
  85592. * @hidden
  85593. * Utility class for generating glTF animation data from BabylonJS.
  85594. */
  85595. export class _GLTFAnimation {
  85596. /**
  85597. * @ignore
  85598. *
  85599. * Creates glTF channel animation from BabylonJS animation.
  85600. * @param babylonTransformNode - BabylonJS mesh.
  85601. * @param animation - animation.
  85602. * @param animationChannelTargetPath - The target animation channel.
  85603. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85604. * @param useQuaternion - Specifies if quaternions are used.
  85605. * @returns nullable IAnimationData
  85606. */
  85607. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85608. private static _DeduceAnimationInfo;
  85609. /**
  85610. * @ignore
  85611. * Create node animations from the transform node animations
  85612. * @param babylonNode
  85613. * @param runtimeGLTFAnimation
  85614. * @param idleGLTFAnimations
  85615. * @param nodeMap
  85616. * @param nodes
  85617. * @param binaryWriter
  85618. * @param bufferViews
  85619. * @param accessors
  85620. * @param convertToRightHandedSystem
  85621. * @param animationSampleRate
  85622. */
  85623. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85624. [key: number]: number;
  85625. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85626. /**
  85627. * @ignore
  85628. * Create individual morph animations from the mesh's morph target animation tracks
  85629. * @param babylonNode
  85630. * @param runtimeGLTFAnimation
  85631. * @param idleGLTFAnimations
  85632. * @param nodeMap
  85633. * @param nodes
  85634. * @param binaryWriter
  85635. * @param bufferViews
  85636. * @param accessors
  85637. * @param convertToRightHandedSystem
  85638. * @param animationSampleRate
  85639. */
  85640. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85641. [key: number]: number;
  85642. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85643. /**
  85644. * @ignore
  85645. * Create node and morph animations from the animation groups
  85646. * @param babylonScene
  85647. * @param glTFAnimations
  85648. * @param nodeMap
  85649. * @param nodes
  85650. * @param binaryWriter
  85651. * @param bufferViews
  85652. * @param accessors
  85653. * @param convertToRightHandedSystemMap
  85654. * @param animationSampleRate
  85655. */
  85656. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85657. [key: number]: number;
  85658. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85659. [nodeId: number]: boolean;
  85660. }, animationSampleRate: number): void;
  85661. private static AddAnimation;
  85662. /**
  85663. * Create a baked animation
  85664. * @param babylonTransformNode BabylonJS mesh
  85665. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85666. * @param animationChannelTargetPath animation target channel
  85667. * @param minFrame minimum animation frame
  85668. * @param maxFrame maximum animation frame
  85669. * @param fps frames per second of the animation
  85670. * @param inputs input key frames of the animation
  85671. * @param outputs output key frame data of the animation
  85672. * @param convertToRightHandedSystem converts the values to right-handed
  85673. * @param useQuaternion specifies if quaternions should be used
  85674. */
  85675. private static _CreateBakedAnimation;
  85676. private static _ConvertFactorToVector3OrQuaternion;
  85677. private static _SetInterpolatedValue;
  85678. /**
  85679. * Creates linear animation from the animation key frames
  85680. * @param babylonTransformNode BabylonJS mesh
  85681. * @param animation BabylonJS animation
  85682. * @param animationChannelTargetPath The target animation channel
  85683. * @param frameDelta The difference between the last and first frame of the animation
  85684. * @param inputs Array to store the key frame times
  85685. * @param outputs Array to store the key frame data
  85686. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85687. * @param useQuaternion Specifies if quaternions are used in the animation
  85688. */
  85689. private static _CreateLinearOrStepAnimation;
  85690. /**
  85691. * Creates cubic spline animation from the animation key frames
  85692. * @param babylonTransformNode BabylonJS mesh
  85693. * @param animation BabylonJS animation
  85694. * @param animationChannelTargetPath The target animation channel
  85695. * @param frameDelta The difference between the last and first frame of the animation
  85696. * @param inputs Array to store the key frame times
  85697. * @param outputs Array to store the key frame data
  85698. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85699. * @param useQuaternion Specifies if quaternions are used in the animation
  85700. */
  85701. private static _CreateCubicSplineAnimation;
  85702. private static _GetBasePositionRotationOrScale;
  85703. /**
  85704. * Adds a key frame value
  85705. * @param keyFrame
  85706. * @param animation
  85707. * @param outputs
  85708. * @param animationChannelTargetPath
  85709. * @param basePositionRotationOrScale
  85710. * @param convertToRightHandedSystem
  85711. * @param useQuaternion
  85712. */
  85713. private static _AddKeyframeValue;
  85714. /**
  85715. * Determine the interpolation based on the key frames
  85716. * @param keyFrames
  85717. * @param animationChannelTargetPath
  85718. * @param useQuaternion
  85719. */
  85720. private static _DeduceInterpolation;
  85721. /**
  85722. * Adds an input tangent or output tangent to the output data
  85723. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85724. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85725. * @param outputs The animation data by keyframe
  85726. * @param animationChannelTargetPath The target animation channel
  85727. * @param interpolation The interpolation type
  85728. * @param keyFrame The key frame with the animation data
  85729. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85730. * @param useQuaternion Specifies if quaternions are used
  85731. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85732. */
  85733. private static AddSplineTangent;
  85734. /**
  85735. * Get the minimum and maximum key frames' frame values
  85736. * @param keyFrames animation key frames
  85737. * @returns the minimum and maximum key frame value
  85738. */
  85739. private static calculateMinMaxKeyFrames;
  85740. }
  85741. }
  85742. declare module BABYLON.GLTF2.Exporter {
  85743. /** @hidden */
  85744. export var textureTransformPixelShader: {
  85745. name: string;
  85746. shader: string;
  85747. };
  85748. }
  85749. declare module BABYLON.GLTF2.Exporter.Extensions {
  85750. /**
  85751. * @hidden
  85752. */
  85753. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85754. private _recordedTextures;
  85755. /** Name of this extension */
  85756. readonly name: string;
  85757. /** Defines whether this extension is enabled */
  85758. enabled: boolean;
  85759. /** Defines whether this extension is required */
  85760. required: boolean;
  85761. /** Reference to the glTF exporter */
  85762. private _wasUsed;
  85763. constructor(exporter: _Exporter);
  85764. dispose(): void;
  85765. /** @hidden */
  85766. get wasUsed(): boolean;
  85767. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85768. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85769. /**
  85770. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85771. * @param babylonTexture
  85772. * @param offset
  85773. * @param rotation
  85774. * @param scale
  85775. * @param scene
  85776. */
  85777. private _textureTransformTextureAsync;
  85778. }
  85779. }
  85780. declare module BABYLON.GLTF2.Exporter.Extensions {
  85781. /**
  85782. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85783. */
  85784. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85785. /** The name of this extension. */
  85786. readonly name: string;
  85787. /** Defines whether this extension is enabled. */
  85788. enabled: boolean;
  85789. /** Defines whether this extension is required */
  85790. required: boolean;
  85791. /** Reference to the glTF exporter */
  85792. private _exporter;
  85793. private _lights;
  85794. /** @hidden */
  85795. constructor(exporter: _Exporter);
  85796. /** @hidden */
  85797. dispose(): void;
  85798. /** @hidden */
  85799. get wasUsed(): boolean;
  85800. /** @hidden */
  85801. onExporting(): void;
  85802. /**
  85803. * Define this method to modify the default behavior when exporting a node
  85804. * @param context The context when exporting the node
  85805. * @param node glTF node
  85806. * @param babylonNode BabylonJS node
  85807. * @param nodeMap Node mapping of unique id to glTF node index
  85808. * @returns nullable INode promise
  85809. */
  85810. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85811. [key: number]: number;
  85812. }): Promise<Nullable<INode>>;
  85813. }
  85814. }
  85815. declare module BABYLON.GLTF2.Exporter.Extensions {
  85816. /**
  85817. * @hidden
  85818. */
  85819. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85820. /** Name of this extension */
  85821. readonly name: string;
  85822. /** Defines whether this extension is enabled */
  85823. enabled: boolean;
  85824. /** Defines whether this extension is required */
  85825. required: boolean;
  85826. /** Reference to the glTF exporter */
  85827. private _textureInfos;
  85828. private _exportedTextures;
  85829. private _wasUsed;
  85830. constructor(exporter: _Exporter);
  85831. dispose(): void;
  85832. /** @hidden */
  85833. get wasUsed(): boolean;
  85834. private _getTextureIndex;
  85835. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85836. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85837. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85838. }
  85839. }
  85840. declare module BABYLON.GLTF2.Exporter.Extensions {
  85841. /**
  85842. * @hidden
  85843. */
  85844. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85845. /** Name of this extension */
  85846. readonly name: string;
  85847. /** Defines whether this extension is enabled */
  85848. enabled: boolean;
  85849. /** Defines whether this extension is required */
  85850. required: boolean;
  85851. private _wasUsed;
  85852. constructor(exporter: _Exporter);
  85853. /** @hidden */
  85854. get wasUsed(): boolean;
  85855. dispose(): void;
  85856. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85857. }
  85858. }
  85859. declare module BABYLON {
  85860. /**
  85861. * Class for generating STL data from a Babylon scene.
  85862. */
  85863. export class STLExport {
  85864. /**
  85865. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85866. * @param meshes list defines the mesh to serialize
  85867. * @param download triggers the automatic download of the file.
  85868. * @param fileName changes the downloads fileName.
  85869. * @param binary changes the STL to a binary type.
  85870. * @param isLittleEndian toggle for binary type exporter.
  85871. * @returns the STL as UTF8 string
  85872. */
  85873. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85874. }
  85875. }
  85876. declare module "babylonjs-gltf2interface" {
  85877. export = BABYLON.GLTF2;
  85878. }
  85879. /**
  85880. * Module for glTF 2.0 Interface
  85881. */
  85882. declare module BABYLON.GLTF2 {
  85883. /**
  85884. * The datatype of the components in the attribute
  85885. */
  85886. const enum AccessorComponentType {
  85887. /**
  85888. * Byte
  85889. */
  85890. BYTE = 5120,
  85891. /**
  85892. * Unsigned Byte
  85893. */
  85894. UNSIGNED_BYTE = 5121,
  85895. /**
  85896. * Short
  85897. */
  85898. SHORT = 5122,
  85899. /**
  85900. * Unsigned Short
  85901. */
  85902. UNSIGNED_SHORT = 5123,
  85903. /**
  85904. * Unsigned Int
  85905. */
  85906. UNSIGNED_INT = 5125,
  85907. /**
  85908. * Float
  85909. */
  85910. FLOAT = 5126,
  85911. }
  85912. /**
  85913. * Specifies if the attirbute is a scalar, vector, or matrix
  85914. */
  85915. const enum AccessorType {
  85916. /**
  85917. * Scalar
  85918. */
  85919. SCALAR = "SCALAR",
  85920. /**
  85921. * Vector2
  85922. */
  85923. VEC2 = "VEC2",
  85924. /**
  85925. * Vector3
  85926. */
  85927. VEC3 = "VEC3",
  85928. /**
  85929. * Vector4
  85930. */
  85931. VEC4 = "VEC4",
  85932. /**
  85933. * Matrix2x2
  85934. */
  85935. MAT2 = "MAT2",
  85936. /**
  85937. * Matrix3x3
  85938. */
  85939. MAT3 = "MAT3",
  85940. /**
  85941. * Matrix4x4
  85942. */
  85943. MAT4 = "MAT4",
  85944. }
  85945. /**
  85946. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85947. */
  85948. const enum AnimationChannelTargetPath {
  85949. /**
  85950. * Translation
  85951. */
  85952. TRANSLATION = "translation",
  85953. /**
  85954. * Rotation
  85955. */
  85956. ROTATION = "rotation",
  85957. /**
  85958. * Scale
  85959. */
  85960. SCALE = "scale",
  85961. /**
  85962. * Weights
  85963. */
  85964. WEIGHTS = "weights",
  85965. }
  85966. /**
  85967. * Interpolation algorithm
  85968. */
  85969. const enum AnimationSamplerInterpolation {
  85970. /**
  85971. * The animated values are linearly interpolated between keyframes
  85972. */
  85973. LINEAR = "LINEAR",
  85974. /**
  85975. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85976. */
  85977. STEP = "STEP",
  85978. /**
  85979. * The animation's interpolation is computed using a cubic spline with specified tangents
  85980. */
  85981. CUBICSPLINE = "CUBICSPLINE",
  85982. }
  85983. /**
  85984. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85985. */
  85986. const enum CameraType {
  85987. /**
  85988. * A perspective camera containing properties to create a perspective projection matrix
  85989. */
  85990. PERSPECTIVE = "perspective",
  85991. /**
  85992. * An orthographic camera containing properties to create an orthographic projection matrix
  85993. */
  85994. ORTHOGRAPHIC = "orthographic",
  85995. }
  85996. /**
  85997. * The mime-type of the image
  85998. */
  85999. const enum ImageMimeType {
  86000. /**
  86001. * JPEG Mime-type
  86002. */
  86003. JPEG = "image/jpeg",
  86004. /**
  86005. * PNG Mime-type
  86006. */
  86007. PNG = "image/png",
  86008. }
  86009. /**
  86010. * The alpha rendering mode of the material
  86011. */
  86012. const enum MaterialAlphaMode {
  86013. /**
  86014. * The alpha value is ignored and the rendered output is fully opaque
  86015. */
  86016. OPAQUE = "OPAQUE",
  86017. /**
  86018. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  86019. */
  86020. MASK = "MASK",
  86021. /**
  86022. * 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)
  86023. */
  86024. BLEND = "BLEND",
  86025. }
  86026. /**
  86027. * The type of the primitives to render
  86028. */
  86029. const enum MeshPrimitiveMode {
  86030. /**
  86031. * Points
  86032. */
  86033. POINTS = 0,
  86034. /**
  86035. * Lines
  86036. */
  86037. LINES = 1,
  86038. /**
  86039. * Line Loop
  86040. */
  86041. LINE_LOOP = 2,
  86042. /**
  86043. * Line Strip
  86044. */
  86045. LINE_STRIP = 3,
  86046. /**
  86047. * Triangles
  86048. */
  86049. TRIANGLES = 4,
  86050. /**
  86051. * Triangle Strip
  86052. */
  86053. TRIANGLE_STRIP = 5,
  86054. /**
  86055. * Triangle Fan
  86056. */
  86057. TRIANGLE_FAN = 6,
  86058. }
  86059. /**
  86060. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86061. */
  86062. const enum TextureMagFilter {
  86063. /**
  86064. * Nearest
  86065. */
  86066. NEAREST = 9728,
  86067. /**
  86068. * Linear
  86069. */
  86070. LINEAR = 9729,
  86071. }
  86072. /**
  86073. * Minification filter. All valid values correspond to WebGL enums
  86074. */
  86075. const enum TextureMinFilter {
  86076. /**
  86077. * Nearest
  86078. */
  86079. NEAREST = 9728,
  86080. /**
  86081. * Linear
  86082. */
  86083. LINEAR = 9729,
  86084. /**
  86085. * Nearest Mip-Map Nearest
  86086. */
  86087. NEAREST_MIPMAP_NEAREST = 9984,
  86088. /**
  86089. * Linear Mipmap Nearest
  86090. */
  86091. LINEAR_MIPMAP_NEAREST = 9985,
  86092. /**
  86093. * Nearest Mipmap Linear
  86094. */
  86095. NEAREST_MIPMAP_LINEAR = 9986,
  86096. /**
  86097. * Linear Mipmap Linear
  86098. */
  86099. LINEAR_MIPMAP_LINEAR = 9987,
  86100. }
  86101. /**
  86102. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86103. */
  86104. const enum TextureWrapMode {
  86105. /**
  86106. * Clamp to Edge
  86107. */
  86108. CLAMP_TO_EDGE = 33071,
  86109. /**
  86110. * Mirrored Repeat
  86111. */
  86112. MIRRORED_REPEAT = 33648,
  86113. /**
  86114. * Repeat
  86115. */
  86116. REPEAT = 10497,
  86117. }
  86118. /**
  86119. * glTF Property
  86120. */
  86121. interface IProperty {
  86122. /**
  86123. * Dictionary object with extension-specific objects
  86124. */
  86125. extensions?: {
  86126. [key: string]: any;
  86127. };
  86128. /**
  86129. * Application-Specific data
  86130. */
  86131. extras?: any;
  86132. }
  86133. /**
  86134. * glTF Child of Root Property
  86135. */
  86136. interface IChildRootProperty extends IProperty {
  86137. /**
  86138. * The user-defined name of this object
  86139. */
  86140. name?: string;
  86141. }
  86142. /**
  86143. * Indices of those attributes that deviate from their initialization value
  86144. */
  86145. interface IAccessorSparseIndices extends IProperty {
  86146. /**
  86147. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86148. */
  86149. bufferView: number;
  86150. /**
  86151. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86152. */
  86153. byteOffset?: number;
  86154. /**
  86155. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  86156. */
  86157. componentType: AccessorComponentType;
  86158. }
  86159. /**
  86160. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  86161. */
  86162. interface IAccessorSparseValues extends IProperty {
  86163. /**
  86164. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86165. */
  86166. bufferView: number;
  86167. /**
  86168. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86169. */
  86170. byteOffset?: number;
  86171. }
  86172. /**
  86173. * Sparse storage of attributes that deviate from their initialization value
  86174. */
  86175. interface IAccessorSparse extends IProperty {
  86176. /**
  86177. * The number of attributes encoded in this sparse accessor
  86178. */
  86179. count: number;
  86180. /**
  86181. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  86182. */
  86183. indices: IAccessorSparseIndices;
  86184. /**
  86185. * 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
  86186. */
  86187. values: IAccessorSparseValues;
  86188. }
  86189. /**
  86190. * 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
  86191. */
  86192. interface IAccessor extends IChildRootProperty {
  86193. /**
  86194. * The index of the bufferview
  86195. */
  86196. bufferView?: number;
  86197. /**
  86198. * The offset relative to the start of the bufferView in bytes
  86199. */
  86200. byteOffset?: number;
  86201. /**
  86202. * The datatype of components in the attribute
  86203. */
  86204. componentType: AccessorComponentType;
  86205. /**
  86206. * Specifies whether integer data values should be normalized
  86207. */
  86208. normalized?: boolean;
  86209. /**
  86210. * The number of attributes referenced by this accessor
  86211. */
  86212. count: number;
  86213. /**
  86214. * Specifies if the attribute is a scalar, vector, or matrix
  86215. */
  86216. type: AccessorType;
  86217. /**
  86218. * Maximum value of each component in this attribute
  86219. */
  86220. max?: number[];
  86221. /**
  86222. * Minimum value of each component in this attribute
  86223. */
  86224. min?: number[];
  86225. /**
  86226. * Sparse storage of attributes that deviate from their initialization value
  86227. */
  86228. sparse?: IAccessorSparse;
  86229. }
  86230. /**
  86231. * Targets an animation's sampler at a node's property
  86232. */
  86233. interface IAnimationChannel extends IProperty {
  86234. /**
  86235. * The index of a sampler in this animation used to compute the value for the target
  86236. */
  86237. sampler: number;
  86238. /**
  86239. * The index of the node and TRS property to target
  86240. */
  86241. target: IAnimationChannelTarget;
  86242. }
  86243. /**
  86244. * The index of the node and TRS property that an animation channel targets
  86245. */
  86246. interface IAnimationChannelTarget extends IProperty {
  86247. /**
  86248. * The index of the node to target
  86249. */
  86250. node: number;
  86251. /**
  86252. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86253. */
  86254. path: AnimationChannelTargetPath;
  86255. }
  86256. /**
  86257. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86258. */
  86259. interface IAnimationSampler extends IProperty {
  86260. /**
  86261. * The index of an accessor containing keyframe input values, e.g., time
  86262. */
  86263. input: number;
  86264. /**
  86265. * Interpolation algorithm
  86266. */
  86267. interpolation?: AnimationSamplerInterpolation;
  86268. /**
  86269. * The index of an accessor, containing keyframe output values
  86270. */
  86271. output: number;
  86272. }
  86273. /**
  86274. * A keyframe animation
  86275. */
  86276. interface IAnimation extends IChildRootProperty {
  86277. /**
  86278. * An array of channels, each of which targets an animation's sampler at a node's property
  86279. */
  86280. channels: IAnimationChannel[];
  86281. /**
  86282. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86283. */
  86284. samplers: IAnimationSampler[];
  86285. }
  86286. /**
  86287. * Metadata about the glTF asset
  86288. */
  86289. interface IAsset extends IChildRootProperty {
  86290. /**
  86291. * A copyright message suitable for display to credit the content creator
  86292. */
  86293. copyright?: string;
  86294. /**
  86295. * Tool that generated this glTF model. Useful for debugging
  86296. */
  86297. generator?: string;
  86298. /**
  86299. * The glTF version that this asset targets
  86300. */
  86301. version: string;
  86302. /**
  86303. * The minimum glTF version that this asset targets
  86304. */
  86305. minVersion?: string;
  86306. }
  86307. /**
  86308. * A buffer points to binary geometry, animation, or skins
  86309. */
  86310. interface IBuffer extends IChildRootProperty {
  86311. /**
  86312. * 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
  86313. */
  86314. uri?: string;
  86315. /**
  86316. * The length of the buffer in bytes
  86317. */
  86318. byteLength: number;
  86319. }
  86320. /**
  86321. * A view into a buffer generally representing a subset of the buffer
  86322. */
  86323. interface IBufferView extends IChildRootProperty {
  86324. /**
  86325. * The index of the buffer
  86326. */
  86327. buffer: number;
  86328. /**
  86329. * The offset into the buffer in bytes
  86330. */
  86331. byteOffset?: number;
  86332. /**
  86333. * The lenth of the bufferView in bytes
  86334. */
  86335. byteLength: number;
  86336. /**
  86337. * The stride, in bytes
  86338. */
  86339. byteStride?: number;
  86340. }
  86341. /**
  86342. * An orthographic camera containing properties to create an orthographic projection matrix
  86343. */
  86344. interface ICameraOrthographic extends IProperty {
  86345. /**
  86346. * The floating-point horizontal magnification of the view. Must not be zero
  86347. */
  86348. xmag: number;
  86349. /**
  86350. * The floating-point vertical magnification of the view. Must not be zero
  86351. */
  86352. ymag: number;
  86353. /**
  86354. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86355. */
  86356. zfar: number;
  86357. /**
  86358. * The floating-point distance to the near clipping plane
  86359. */
  86360. znear: number;
  86361. }
  86362. /**
  86363. * A perspective camera containing properties to create a perspective projection matrix
  86364. */
  86365. interface ICameraPerspective extends IProperty {
  86366. /**
  86367. * The floating-point aspect ratio of the field of view
  86368. */
  86369. aspectRatio?: number;
  86370. /**
  86371. * The floating-point vertical field of view in radians
  86372. */
  86373. yfov: number;
  86374. /**
  86375. * The floating-point distance to the far clipping plane
  86376. */
  86377. zfar?: number;
  86378. /**
  86379. * The floating-point distance to the near clipping plane
  86380. */
  86381. znear: number;
  86382. }
  86383. /**
  86384. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86385. */
  86386. interface ICamera extends IChildRootProperty {
  86387. /**
  86388. * An orthographic camera containing properties to create an orthographic projection matrix
  86389. */
  86390. orthographic?: ICameraOrthographic;
  86391. /**
  86392. * A perspective camera containing properties to create a perspective projection matrix
  86393. */
  86394. perspective?: ICameraPerspective;
  86395. /**
  86396. * Specifies if the camera uses a perspective or orthographic projection
  86397. */
  86398. type: CameraType;
  86399. }
  86400. /**
  86401. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86402. */
  86403. interface IImage extends IChildRootProperty {
  86404. /**
  86405. * 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
  86406. */
  86407. uri?: string;
  86408. /**
  86409. * The image's MIME type
  86410. */
  86411. mimeType?: ImageMimeType;
  86412. /**
  86413. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86414. */
  86415. bufferView?: number;
  86416. }
  86417. /**
  86418. * Material Normal Texture Info
  86419. */
  86420. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86421. /**
  86422. * The scalar multiplier applied to each normal vector of the normal texture
  86423. */
  86424. scale?: number;
  86425. }
  86426. /**
  86427. * Material Occlusion Texture Info
  86428. */
  86429. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86430. /**
  86431. * A scalar multiplier controlling the amount of occlusion applied
  86432. */
  86433. strength?: number;
  86434. }
  86435. /**
  86436. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86437. */
  86438. interface IMaterialPbrMetallicRoughness {
  86439. /**
  86440. * The material's base color factor
  86441. */
  86442. baseColorFactor?: number[];
  86443. /**
  86444. * The base color texture
  86445. */
  86446. baseColorTexture?: ITextureInfo;
  86447. /**
  86448. * The metalness of the material
  86449. */
  86450. metallicFactor?: number;
  86451. /**
  86452. * The roughness of the material
  86453. */
  86454. roughnessFactor?: number;
  86455. /**
  86456. * The metallic-roughness texture
  86457. */
  86458. metallicRoughnessTexture?: ITextureInfo;
  86459. }
  86460. /**
  86461. * The material appearance of a primitive
  86462. */
  86463. interface IMaterial extends IChildRootProperty {
  86464. /**
  86465. * 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
  86466. */
  86467. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86468. /**
  86469. * The normal map texture
  86470. */
  86471. normalTexture?: IMaterialNormalTextureInfo;
  86472. /**
  86473. * The occlusion map texture
  86474. */
  86475. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86476. /**
  86477. * The emissive map texture
  86478. */
  86479. emissiveTexture?: ITextureInfo;
  86480. /**
  86481. * 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
  86482. */
  86483. emissiveFactor?: number[];
  86484. /**
  86485. * The alpha rendering mode of the material
  86486. */
  86487. alphaMode?: MaterialAlphaMode;
  86488. /**
  86489. * The alpha cutoff value of the material
  86490. */
  86491. alphaCutoff?: number;
  86492. /**
  86493. * Specifies whether the material is double sided
  86494. */
  86495. doubleSided?: boolean;
  86496. }
  86497. /**
  86498. * Geometry to be rendered with the given material
  86499. */
  86500. interface IMeshPrimitive extends IProperty {
  86501. /**
  86502. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86503. */
  86504. attributes: {
  86505. [name: string]: number;
  86506. };
  86507. /**
  86508. * The index of the accessor that contains the indices
  86509. */
  86510. indices?: number;
  86511. /**
  86512. * The index of the material to apply to this primitive when rendering
  86513. */
  86514. material?: number;
  86515. /**
  86516. * The type of primitives to render. All valid values correspond to WebGL enums
  86517. */
  86518. mode?: MeshPrimitiveMode;
  86519. /**
  86520. * 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
  86521. */
  86522. targets?: {
  86523. [name: string]: number;
  86524. }[];
  86525. }
  86526. /**
  86527. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86528. */
  86529. interface IMesh extends IChildRootProperty {
  86530. /**
  86531. * An array of primitives, each defining geometry to be rendered with a material
  86532. */
  86533. primitives: IMeshPrimitive[];
  86534. /**
  86535. * Array of weights to be applied to the Morph Targets
  86536. */
  86537. weights?: number[];
  86538. }
  86539. /**
  86540. * A node in the node hierarchy
  86541. */
  86542. interface INode extends IChildRootProperty {
  86543. /**
  86544. * The index of the camera referenced by this node
  86545. */
  86546. camera?: number;
  86547. /**
  86548. * The indices of this node's children
  86549. */
  86550. children?: number[];
  86551. /**
  86552. * The index of the skin referenced by this node
  86553. */
  86554. skin?: number;
  86555. /**
  86556. * A floating-point 4x4 transformation matrix stored in column-major order
  86557. */
  86558. matrix?: number[];
  86559. /**
  86560. * The index of the mesh in this node
  86561. */
  86562. mesh?: number;
  86563. /**
  86564. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86565. */
  86566. rotation?: number[];
  86567. /**
  86568. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86569. */
  86570. scale?: number[];
  86571. /**
  86572. * The node's translation along the x, y, and z axes
  86573. */
  86574. translation?: number[];
  86575. /**
  86576. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86577. */
  86578. weights?: number[];
  86579. }
  86580. /**
  86581. * Texture sampler properties for filtering and wrapping modes
  86582. */
  86583. interface ISampler extends IChildRootProperty {
  86584. /**
  86585. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86586. */
  86587. magFilter?: TextureMagFilter;
  86588. /**
  86589. * Minification filter. All valid values correspond to WebGL enums
  86590. */
  86591. minFilter?: TextureMinFilter;
  86592. /**
  86593. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86594. */
  86595. wrapS?: TextureWrapMode;
  86596. /**
  86597. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86598. */
  86599. wrapT?: TextureWrapMode;
  86600. }
  86601. /**
  86602. * The root nodes of a scene
  86603. */
  86604. interface IScene extends IChildRootProperty {
  86605. /**
  86606. * The indices of each root node
  86607. */
  86608. nodes: number[];
  86609. }
  86610. /**
  86611. * Joints and matrices defining a skin
  86612. */
  86613. interface ISkin extends IChildRootProperty {
  86614. /**
  86615. * 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
  86616. */
  86617. inverseBindMatrices?: number;
  86618. /**
  86619. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86620. */
  86621. skeleton?: number;
  86622. /**
  86623. * 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)
  86624. */
  86625. joints: number[];
  86626. }
  86627. /**
  86628. * A texture and its sampler
  86629. */
  86630. interface ITexture extends IChildRootProperty {
  86631. /**
  86632. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86633. */
  86634. sampler?: number;
  86635. /**
  86636. * The index of the image used by this texture
  86637. */
  86638. source: number;
  86639. }
  86640. /**
  86641. * Reference to a texture
  86642. */
  86643. interface ITextureInfo extends IProperty {
  86644. /**
  86645. * The index of the texture
  86646. */
  86647. index: number;
  86648. /**
  86649. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86650. */
  86651. texCoord?: number;
  86652. }
  86653. /**
  86654. * The root object for a glTF asset
  86655. */
  86656. interface IGLTF extends IProperty {
  86657. /**
  86658. * An array of accessors. An accessor is a typed view into a bufferView
  86659. */
  86660. accessors?: IAccessor[];
  86661. /**
  86662. * An array of keyframe animations
  86663. */
  86664. animations?: IAnimation[];
  86665. /**
  86666. * Metadata about the glTF asset
  86667. */
  86668. asset: IAsset;
  86669. /**
  86670. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86671. */
  86672. buffers?: IBuffer[];
  86673. /**
  86674. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86675. */
  86676. bufferViews?: IBufferView[];
  86677. /**
  86678. * An array of cameras
  86679. */
  86680. cameras?: ICamera[];
  86681. /**
  86682. * Names of glTF extensions used somewhere in this asset
  86683. */
  86684. extensionsUsed?: string[];
  86685. /**
  86686. * Names of glTF extensions required to properly load this asset
  86687. */
  86688. extensionsRequired?: string[];
  86689. /**
  86690. * An array of images. An image defines data used to create a texture
  86691. */
  86692. images?: IImage[];
  86693. /**
  86694. * An array of materials. A material defines the appearance of a primitive
  86695. */
  86696. materials?: IMaterial[];
  86697. /**
  86698. * An array of meshes. A mesh is a set of primitives to be rendered
  86699. */
  86700. meshes?: IMesh[];
  86701. /**
  86702. * An array of nodes
  86703. */
  86704. nodes?: INode[];
  86705. /**
  86706. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86707. */
  86708. samplers?: ISampler[];
  86709. /**
  86710. * The index of the default scene
  86711. */
  86712. scene?: number;
  86713. /**
  86714. * An array of scenes
  86715. */
  86716. scenes?: IScene[];
  86717. /**
  86718. * An array of skins. A skin is defined by joints and matrices
  86719. */
  86720. skins?: ISkin[];
  86721. /**
  86722. * An array of textures
  86723. */
  86724. textures?: ITexture[];
  86725. }
  86726. /**
  86727. * The glTF validation results
  86728. * @ignore
  86729. */
  86730. interface IGLTFValidationResults {
  86731. info: {
  86732. generator: string;
  86733. hasAnimations: boolean;
  86734. hasDefaultScene: boolean;
  86735. hasMaterials: boolean;
  86736. hasMorphTargets: boolean;
  86737. hasSkins: boolean;
  86738. hasTextures: boolean;
  86739. maxAttributesUsed: number;
  86740. primitivesCount: number
  86741. };
  86742. issues: {
  86743. messages: Array<string>;
  86744. numErrors: number;
  86745. numHints: number;
  86746. numInfos: number;
  86747. numWarnings: number;
  86748. truncated: boolean
  86749. };
  86750. mimeType: string;
  86751. uri: string;
  86752. validatedAt: string;
  86753. validatorVersion: string;
  86754. }
  86755. /**
  86756. * The glTF validation options
  86757. */
  86758. interface IGLTFValidationOptions {
  86759. /** Uri to use */
  86760. uri?: string;
  86761. /** Function used to load external resources */
  86762. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86763. /** Boolean indicating that we need to validate accessor data */
  86764. validateAccessorData?: boolean;
  86765. /** max number of issues allowed */
  86766. maxIssues?: number;
  86767. /** Ignored issues */
  86768. ignoredIssues?: Array<string>;
  86769. /** Value to override severy settings */
  86770. severityOverrides?: Object;
  86771. }
  86772. /**
  86773. * The glTF validator object
  86774. * @ignore
  86775. */
  86776. interface IGLTFValidator {
  86777. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86778. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86779. }
  86780. /**
  86781. * Interfaces from the EXT_lights_image_based extension
  86782. */
  86783. /** @hidden */
  86784. interface IEXTLightsImageBased_LightReferenceImageBased {
  86785. light: number;
  86786. }
  86787. /** @hidden */
  86788. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86789. intensity: number;
  86790. rotation: number[];
  86791. specularImageSize: number;
  86792. specularImages: number[][];
  86793. irradianceCoefficients: number[][];
  86794. }
  86795. /** @hidden */
  86796. interface IEXTLightsImageBased {
  86797. lights: IEXTLightsImageBased_LightImageBased[];
  86798. }
  86799. /**
  86800. * Interfaces from the EXT_mesh_gpu_instancing extension
  86801. * !!! Experimental Extension Subject to Changes !!!
  86802. */
  86803. /** @hidden */
  86804. interface IEXTMeshGpuInstancing {
  86805. mesh?: number;
  86806. attributes: { [name: string]: number };
  86807. }
  86808. /**
  86809. * Interfaces from the KHR_draco_mesh_compression extension
  86810. */
  86811. /** @hidden */
  86812. interface IKHRDracoMeshCompression {
  86813. bufferView: number;
  86814. attributes: { [name: string]: number };
  86815. }
  86816. /**
  86817. * Interfaces from the KHR_lights_punctual extension
  86818. */
  86819. /** @hidden */
  86820. const enum IKHRLightsPunctual_LightType {
  86821. DIRECTIONAL = "directional",
  86822. POINT = "point",
  86823. SPOT = "spot"
  86824. }
  86825. /** @hidden */
  86826. interface IKHRLightsPunctual_LightReference {
  86827. light: number;
  86828. }
  86829. /** @hidden */
  86830. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86831. type: IKHRLightsPunctual_LightType;
  86832. color?: number[];
  86833. intensity?: number;
  86834. range?: number;
  86835. spot?: {
  86836. innerConeAngle?: number;
  86837. outerConeAngle?: number;
  86838. };
  86839. }
  86840. /** @hidden */
  86841. interface IKHRLightsPunctual {
  86842. lights: IKHRLightsPunctual_Light[];
  86843. }
  86844. /**
  86845. * Interfaces from the KHR_materials_clearcoat extension
  86846. * !!! Experimental Extension Subject to Changes !!!
  86847. */
  86848. /** @hidden */
  86849. interface IKHRMaterialsClearcoat {
  86850. clearcoatFactor: number;
  86851. clearcoatTexture: ITextureInfo;
  86852. clearcoatRoughnessFactor: number;
  86853. clearcoatRoughnessTexture: ITextureInfo;
  86854. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86855. }
  86856. /**
  86857. * Interfaces from the KHR_materials_ior extension
  86858. * !!! Experimental Extension Subject to Changes !!!
  86859. */
  86860. /** @hidden */
  86861. interface IKHRMaterialsIor {
  86862. ior: number;
  86863. }
  86864. /**
  86865. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86866. */
  86867. /** @hidden */
  86868. interface IKHRMaterialsPbrSpecularGlossiness {
  86869. diffuseFactor: number[];
  86870. diffuseTexture: ITextureInfo;
  86871. specularFactor: number[];
  86872. glossinessFactor: number;
  86873. specularGlossinessTexture: ITextureInfo;
  86874. }
  86875. /**
  86876. * Interfaces from the KHR_materials_sheen extension
  86877. * !!! Experimental Extension Subject to Changes !!!
  86878. */
  86879. /** @hidden */
  86880. interface IKHRMaterialsSheen {
  86881. sheenColorFactor?: number[];
  86882. sheenColorTexture?: ITextureInfo;
  86883. sheenRoughnessFactor?: number;
  86884. sheenRoughnessTexture?: ITextureInfo;
  86885. }
  86886. /**
  86887. * Interfaces from the KHR_materials_specular extension
  86888. * !!! Experimental Extension Subject to Changes !!!
  86889. */
  86890. /** @hidden */
  86891. interface IKHRMaterialsSpecular {
  86892. specularFactor: number;
  86893. specularColorFactor: number[];
  86894. specularTexture: ITextureInfo;
  86895. }
  86896. /**
  86897. * Interfaces from the KHR_materials_transmission extension
  86898. * !!! Experimental Extension Subject to Changes !!!
  86899. */
  86900. /** @hidden */
  86901. interface IKHRMaterialsTransmission {
  86902. transmissionFactor?: number;
  86903. transmissionTexture?: ITextureInfo;
  86904. }
  86905. /**
  86906. * Interfaces from the KHR_materials_translucency extension
  86907. * !!! Experimental Extension Subject to Changes !!!
  86908. */
  86909. /** @hidden */
  86910. interface IKHRMaterialsTranslucency {
  86911. translucencyFactor?: number;
  86912. translucencyTexture?: ITextureInfo;
  86913. }
  86914. /**
  86915. * Interfaces from the KHR_materials_variants extension
  86916. * !!! Experimental Extension Subject to Changes !!!
  86917. */
  86918. /** @hidden */
  86919. interface IKHRMaterialVariants_Mapping extends IProperty {
  86920. mappings: Array<{
  86921. variants: number[];
  86922. material: number;
  86923. }>;
  86924. }
  86925. /** @hidden */
  86926. interface IKHRMaterialVariants_Variant extends IProperty {
  86927. name: string;
  86928. }
  86929. /** @hidden */
  86930. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86931. variants: Array<IKHRMaterialVariants_Variant>;
  86932. }
  86933. /**
  86934. * Interfaces from the KHR_texture_basisu extension
  86935. * !!! Experimental Extension Subject to Changes !!!
  86936. */
  86937. /** @hidden */
  86938. interface IKHRTextureBasisU {
  86939. source: number;
  86940. }
  86941. /**
  86942. * Interfaces from the EXT_texture_webp extension
  86943. */
  86944. /** @hidden */
  86945. interface IEXTTextureWebP {
  86946. source: number;
  86947. }
  86948. /**
  86949. * Interfaces from the KHR_texture_transform extension
  86950. */
  86951. /** @hidden */
  86952. interface IKHRTextureTransform {
  86953. offset?: number[];
  86954. rotation?: number;
  86955. scale?: number[];
  86956. texCoord?: number;
  86957. }
  86958. /**
  86959. * Interfaces from the KHR_xmp extension
  86960. * !!! Experimental Extension Subject to Changes !!!
  86961. */
  86962. /** @hidden */
  86963. interface IKHRXmp_Data {
  86964. [key: string]: unknown;
  86965. }
  86966. /** @hidden */
  86967. interface IKHRXmp_Gltf {
  86968. packets: IKHRXmp_Data[];
  86969. }
  86970. /** @hidden */
  86971. interface IKHRXmp_Node {
  86972. packet: number;
  86973. }
  86974. /**
  86975. * Interfaces from the MSFT_audio_emitter extension
  86976. */
  86977. /** @hidden */
  86978. interface IMSFTAudioEmitter_ClipReference {
  86979. clip: number;
  86980. weight?: number;
  86981. }
  86982. /** @hidden */
  86983. interface IMSFTAudioEmitter_EmittersReference {
  86984. emitters: number[];
  86985. }
  86986. /** @hidden */
  86987. const enum IMSFTAudioEmitter_DistanceModel {
  86988. linear = "linear",
  86989. inverse = "inverse",
  86990. exponential = "exponential",
  86991. }
  86992. /** @hidden */
  86993. interface IMSFTAudioEmitter_Emitter {
  86994. name?: string;
  86995. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86996. refDistance?: number;
  86997. maxDistance?: number;
  86998. rolloffFactor?: number;
  86999. innerAngle?: number;
  87000. outerAngle?: number;
  87001. loop?: boolean;
  87002. volume?: number;
  87003. clips: IMSFTAudioEmitter_ClipReference[];
  87004. }
  87005. /** @hidden */
  87006. const enum IMSFTAudioEmitter_AudioMimeType {
  87007. WAV = "audio/wav",
  87008. }
  87009. /** @hidden */
  87010. interface IMSFTAudioEmitter_Clip extends IProperty {
  87011. uri?: string;
  87012. bufferView?: number;
  87013. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  87014. }
  87015. /** @hidden */
  87016. const enum IMSFTAudioEmitter_AnimationEventAction {
  87017. play = "play",
  87018. pause = "pause",
  87019. stop = "stop",
  87020. }
  87021. /** @hidden */
  87022. interface IMSFTAudioEmitter_AnimationEvent {
  87023. action: IMSFTAudioEmitter_AnimationEventAction;
  87024. emitter: number;
  87025. time: number;
  87026. startOffset?: number;
  87027. }
  87028. /**
  87029. * Interfaces from the MSFT_lod extension
  87030. */
  87031. /** @hidden */
  87032. interface IMSFTLOD {
  87033. ids: number[];
  87034. }
  87035. }
  87036. declare module BABYLON {
  87037. /** @hidden */
  87038. export var cellPixelShader: {
  87039. name: string;
  87040. shader: string;
  87041. };
  87042. }
  87043. declare module BABYLON {
  87044. /** @hidden */
  87045. export var cellVertexShader: {
  87046. name: string;
  87047. shader: string;
  87048. };
  87049. }
  87050. declare module BABYLON {
  87051. export class CellMaterial extends BABYLON.PushMaterial {
  87052. private _diffuseTexture;
  87053. diffuseTexture: BABYLON.BaseTexture;
  87054. diffuseColor: BABYLON.Color3;
  87055. _computeHighLevel: boolean;
  87056. computeHighLevel: boolean;
  87057. private _disableLighting;
  87058. disableLighting: boolean;
  87059. private _maxSimultaneousLights;
  87060. maxSimultaneousLights: number;
  87061. constructor(name: string, scene: BABYLON.Scene);
  87062. needAlphaBlending(): boolean;
  87063. needAlphaTesting(): boolean;
  87064. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87065. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87066. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87067. getAnimatables(): BABYLON.IAnimatable[];
  87068. getActiveTextures(): BABYLON.BaseTexture[];
  87069. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87070. dispose(forceDisposeEffect?: boolean): void;
  87071. getClassName(): string;
  87072. clone(name: string): CellMaterial;
  87073. serialize(): any;
  87074. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  87075. }
  87076. }
  87077. declare module BABYLON {
  87078. export class CustomShaderStructure {
  87079. FragmentStore: string;
  87080. VertexStore: string;
  87081. constructor();
  87082. }
  87083. export class ShaderSpecialParts {
  87084. constructor();
  87085. Fragment_Begin: string;
  87086. Fragment_Definitions: string;
  87087. Fragment_MainBegin: string;
  87088. Fragment_Custom_Diffuse: string;
  87089. Fragment_Before_Lights: string;
  87090. Fragment_Before_Fog: string;
  87091. Fragment_Custom_Alpha: string;
  87092. Fragment_Before_FragColor: string;
  87093. Vertex_Begin: string;
  87094. Vertex_Definitions: string;
  87095. Vertex_MainBegin: string;
  87096. Vertex_Before_PositionUpdated: string;
  87097. Vertex_Before_NormalUpdated: string;
  87098. Vertex_After_WorldPosComputed: string;
  87099. Vertex_MainEnd: string;
  87100. }
  87101. export class CustomMaterial extends BABYLON.StandardMaterial {
  87102. static ShaderIndexer: number;
  87103. CustomParts: ShaderSpecialParts;
  87104. _isCreatedShader: boolean;
  87105. _createdShaderName: string;
  87106. _customUniform: string[];
  87107. _newUniforms: string[];
  87108. _newUniformInstances: {
  87109. [name: string]: any;
  87110. };
  87111. _newSamplerInstances: {
  87112. [name: string]: BABYLON.Texture;
  87113. };
  87114. _customAttributes: string[];
  87115. FragmentShader: string;
  87116. VertexShader: string;
  87117. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87118. ReviewUniform(name: string, arr: string[]): string[];
  87119. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87120. constructor(name: string, scene: BABYLON.Scene);
  87121. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  87122. AddAttribute(name: string): CustomMaterial;
  87123. Fragment_Begin(shaderPart: string): CustomMaterial;
  87124. Fragment_Definitions(shaderPart: string): CustomMaterial;
  87125. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  87126. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  87127. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  87128. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  87129. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  87130. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  87131. Vertex_Begin(shaderPart: string): CustomMaterial;
  87132. Vertex_Definitions(shaderPart: string): CustomMaterial;
  87133. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  87134. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  87135. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  87136. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  87137. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  87138. }
  87139. }
  87140. declare module BABYLON {
  87141. export class ShaderAlebdoParts {
  87142. constructor();
  87143. Fragment_Begin: string;
  87144. Fragment_Definitions: string;
  87145. Fragment_MainBegin: string;
  87146. Fragment_Custom_Albedo: string;
  87147. Fragment_Before_Lights: string;
  87148. Fragment_Custom_MetallicRoughness: string;
  87149. Fragment_Custom_MicroSurface: string;
  87150. Fragment_Before_Fog: string;
  87151. Fragment_Custom_Alpha: string;
  87152. Fragment_Before_FragColor: string;
  87153. Vertex_Begin: string;
  87154. Vertex_Definitions: string;
  87155. Vertex_MainBegin: string;
  87156. Vertex_Before_PositionUpdated: string;
  87157. Vertex_Before_NormalUpdated: string;
  87158. Vertex_After_WorldPosComputed: string;
  87159. Vertex_MainEnd: string;
  87160. }
  87161. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  87162. static ShaderIndexer: number;
  87163. CustomParts: ShaderAlebdoParts;
  87164. _isCreatedShader: boolean;
  87165. _createdShaderName: string;
  87166. _customUniform: string[];
  87167. _newUniforms: string[];
  87168. _newUniformInstances: {
  87169. [name: string]: any;
  87170. };
  87171. _newSamplerInstances: {
  87172. [name: string]: BABYLON.Texture;
  87173. };
  87174. _customAttributes: string[];
  87175. FragmentShader: string;
  87176. VertexShader: string;
  87177. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87178. ReviewUniform(name: string, arr: string[]): string[];
  87179. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87180. constructor(name: string, scene: BABYLON.Scene);
  87181. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  87182. AddAttribute(name: string): PBRCustomMaterial;
  87183. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  87184. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  87185. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  87186. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  87187. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  87188. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  87189. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  87190. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  87191. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  87192. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  87193. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  87194. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  87195. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  87196. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  87197. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  87198. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  87199. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  87200. }
  87201. }
  87202. declare module BABYLON {
  87203. /** @hidden */
  87204. export var firePixelShader: {
  87205. name: string;
  87206. shader: string;
  87207. };
  87208. }
  87209. declare module BABYLON {
  87210. /** @hidden */
  87211. export var fireVertexShader: {
  87212. name: string;
  87213. shader: string;
  87214. };
  87215. }
  87216. declare module BABYLON {
  87217. export class FireMaterial extends BABYLON.PushMaterial {
  87218. private _diffuseTexture;
  87219. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87220. private _distortionTexture;
  87221. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87222. private _opacityTexture;
  87223. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87224. diffuseColor: BABYLON.Color3;
  87225. speed: number;
  87226. private _scaledDiffuse;
  87227. private _lastTime;
  87228. constructor(name: string, scene: BABYLON.Scene);
  87229. needAlphaBlending(): boolean;
  87230. needAlphaTesting(): boolean;
  87231. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87232. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87233. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87234. getAnimatables(): BABYLON.IAnimatable[];
  87235. getActiveTextures(): BABYLON.BaseTexture[];
  87236. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87237. getClassName(): string;
  87238. dispose(forceDisposeEffect?: boolean): void;
  87239. clone(name: string): FireMaterial;
  87240. serialize(): any;
  87241. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  87242. }
  87243. }
  87244. declare module BABYLON {
  87245. /** @hidden */
  87246. export var furPixelShader: {
  87247. name: string;
  87248. shader: string;
  87249. };
  87250. }
  87251. declare module BABYLON {
  87252. /** @hidden */
  87253. export var furVertexShader: {
  87254. name: string;
  87255. shader: string;
  87256. };
  87257. }
  87258. declare module BABYLON {
  87259. export class FurMaterial extends BABYLON.PushMaterial {
  87260. private _diffuseTexture;
  87261. diffuseTexture: BABYLON.BaseTexture;
  87262. private _heightTexture;
  87263. heightTexture: BABYLON.BaseTexture;
  87264. diffuseColor: BABYLON.Color3;
  87265. furLength: number;
  87266. furAngle: number;
  87267. furColor: BABYLON.Color3;
  87268. furOffset: number;
  87269. furSpacing: number;
  87270. furGravity: BABYLON.Vector3;
  87271. furSpeed: number;
  87272. furDensity: number;
  87273. furOcclusion: number;
  87274. furTexture: BABYLON.DynamicTexture;
  87275. private _disableLighting;
  87276. disableLighting: boolean;
  87277. private _maxSimultaneousLights;
  87278. maxSimultaneousLights: number;
  87279. highLevelFur: boolean;
  87280. _meshes: BABYLON.AbstractMesh[];
  87281. private _furTime;
  87282. constructor(name: string, scene: BABYLON.Scene);
  87283. get furTime(): number;
  87284. set furTime(furTime: number);
  87285. needAlphaBlending(): boolean;
  87286. needAlphaTesting(): boolean;
  87287. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87288. updateFur(): void;
  87289. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87290. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87291. getAnimatables(): BABYLON.IAnimatable[];
  87292. getActiveTextures(): BABYLON.BaseTexture[];
  87293. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87294. dispose(forceDisposeEffect?: boolean): void;
  87295. clone(name: string): FurMaterial;
  87296. serialize(): any;
  87297. getClassName(): string;
  87298. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  87299. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  87300. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  87301. }
  87302. }
  87303. declare module BABYLON {
  87304. /** @hidden */
  87305. export var gradientPixelShader: {
  87306. name: string;
  87307. shader: string;
  87308. };
  87309. }
  87310. declare module BABYLON {
  87311. /** @hidden */
  87312. export var gradientVertexShader: {
  87313. name: string;
  87314. shader: string;
  87315. };
  87316. }
  87317. declare module BABYLON {
  87318. export class GradientMaterial extends BABYLON.PushMaterial {
  87319. private _maxSimultaneousLights;
  87320. maxSimultaneousLights: number;
  87321. topColor: BABYLON.Color3;
  87322. topColorAlpha: number;
  87323. bottomColor: BABYLON.Color3;
  87324. bottomColorAlpha: number;
  87325. offset: number;
  87326. scale: number;
  87327. smoothness: number;
  87328. private _disableLighting;
  87329. disableLighting: boolean;
  87330. constructor(name: string, scene: BABYLON.Scene);
  87331. needAlphaBlending(): boolean;
  87332. needAlphaTesting(): boolean;
  87333. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87334. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87335. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87336. getAnimatables(): BABYLON.IAnimatable[];
  87337. dispose(forceDisposeEffect?: boolean): void;
  87338. clone(name: string): GradientMaterial;
  87339. serialize(): any;
  87340. getClassName(): string;
  87341. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87342. }
  87343. }
  87344. declare module BABYLON {
  87345. /** @hidden */
  87346. export var gridPixelShader: {
  87347. name: string;
  87348. shader: string;
  87349. };
  87350. }
  87351. declare module BABYLON {
  87352. /** @hidden */
  87353. export var gridVertexShader: {
  87354. name: string;
  87355. shader: string;
  87356. };
  87357. }
  87358. declare module BABYLON {
  87359. /**
  87360. * The grid materials allows you to wrap any shape with a grid.
  87361. * Colors are customizable.
  87362. */
  87363. export class GridMaterial extends BABYLON.PushMaterial {
  87364. /**
  87365. * Main color of the grid (e.g. between lines)
  87366. */
  87367. mainColor: BABYLON.Color3;
  87368. /**
  87369. * Color of the grid lines.
  87370. */
  87371. lineColor: BABYLON.Color3;
  87372. /**
  87373. * The scale of the grid compared to unit.
  87374. */
  87375. gridRatio: number;
  87376. /**
  87377. * Allows setting an offset for the grid lines.
  87378. */
  87379. gridOffset: BABYLON.Vector3;
  87380. /**
  87381. * The frequency of thicker lines.
  87382. */
  87383. majorUnitFrequency: number;
  87384. /**
  87385. * The visibility of minor units in the grid.
  87386. */
  87387. minorUnitVisibility: number;
  87388. /**
  87389. * The grid opacity outside of the lines.
  87390. */
  87391. opacity: number;
  87392. /**
  87393. * Determine RBG output is premultiplied by alpha value.
  87394. */
  87395. preMultiplyAlpha: boolean;
  87396. private _opacityTexture;
  87397. opacityTexture: BABYLON.BaseTexture;
  87398. private _gridControl;
  87399. /**
  87400. * constructor
  87401. * @param name The name given to the material in order to identify it afterwards.
  87402. * @param scene The scene the material is used in.
  87403. */
  87404. constructor(name: string, scene: BABYLON.Scene);
  87405. /**
  87406. * Returns wehter or not the grid requires alpha blending.
  87407. */
  87408. needAlphaBlending(): boolean;
  87409. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87410. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87411. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87412. /**
  87413. * Dispose the material and its associated resources.
  87414. * @param forceDisposeEffect will also dispose the used effect when true
  87415. */
  87416. dispose(forceDisposeEffect?: boolean): void;
  87417. clone(name: string): GridMaterial;
  87418. serialize(): any;
  87419. getClassName(): string;
  87420. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87421. }
  87422. }
  87423. declare module BABYLON {
  87424. /** @hidden */
  87425. export var lavaPixelShader: {
  87426. name: string;
  87427. shader: string;
  87428. };
  87429. }
  87430. declare module BABYLON {
  87431. /** @hidden */
  87432. export var lavaVertexShader: {
  87433. name: string;
  87434. shader: string;
  87435. };
  87436. }
  87437. declare module BABYLON {
  87438. export class LavaMaterial extends BABYLON.PushMaterial {
  87439. private _diffuseTexture;
  87440. diffuseTexture: BABYLON.BaseTexture;
  87441. noiseTexture: BABYLON.BaseTexture;
  87442. fogColor: BABYLON.Color3;
  87443. speed: number;
  87444. movingSpeed: number;
  87445. lowFrequencySpeed: number;
  87446. fogDensity: number;
  87447. private _lastTime;
  87448. diffuseColor: BABYLON.Color3;
  87449. private _disableLighting;
  87450. disableLighting: boolean;
  87451. private _unlit;
  87452. unlit: boolean;
  87453. private _maxSimultaneousLights;
  87454. maxSimultaneousLights: number;
  87455. private _scaledDiffuse;
  87456. constructor(name: string, scene: BABYLON.Scene);
  87457. needAlphaBlending(): boolean;
  87458. needAlphaTesting(): boolean;
  87459. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87460. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87461. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87462. getAnimatables(): BABYLON.IAnimatable[];
  87463. getActiveTextures(): BABYLON.BaseTexture[];
  87464. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87465. dispose(forceDisposeEffect?: boolean): void;
  87466. clone(name: string): LavaMaterial;
  87467. serialize(): any;
  87468. getClassName(): string;
  87469. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87470. }
  87471. }
  87472. declare module BABYLON {
  87473. /** @hidden */
  87474. export var mixPixelShader: {
  87475. name: string;
  87476. shader: string;
  87477. };
  87478. }
  87479. declare module BABYLON {
  87480. /** @hidden */
  87481. export var mixVertexShader: {
  87482. name: string;
  87483. shader: string;
  87484. };
  87485. }
  87486. declare module BABYLON {
  87487. export class MixMaterial extends BABYLON.PushMaterial {
  87488. /**
  87489. * Mix textures
  87490. */
  87491. private _mixTexture1;
  87492. mixTexture1: BABYLON.BaseTexture;
  87493. private _mixTexture2;
  87494. mixTexture2: BABYLON.BaseTexture;
  87495. /**
  87496. * Diffuse textures
  87497. */
  87498. private _diffuseTexture1;
  87499. diffuseTexture1: BABYLON.Texture;
  87500. private _diffuseTexture2;
  87501. diffuseTexture2: BABYLON.Texture;
  87502. private _diffuseTexture3;
  87503. diffuseTexture3: BABYLON.Texture;
  87504. private _diffuseTexture4;
  87505. diffuseTexture4: BABYLON.Texture;
  87506. private _diffuseTexture5;
  87507. diffuseTexture5: BABYLON.Texture;
  87508. private _diffuseTexture6;
  87509. diffuseTexture6: BABYLON.Texture;
  87510. private _diffuseTexture7;
  87511. diffuseTexture7: BABYLON.Texture;
  87512. private _diffuseTexture8;
  87513. diffuseTexture8: BABYLON.Texture;
  87514. /**
  87515. * Uniforms
  87516. */
  87517. diffuseColor: BABYLON.Color3;
  87518. specularColor: BABYLON.Color3;
  87519. specularPower: number;
  87520. private _disableLighting;
  87521. disableLighting: boolean;
  87522. private _maxSimultaneousLights;
  87523. maxSimultaneousLights: number;
  87524. constructor(name: string, scene: BABYLON.Scene);
  87525. needAlphaBlending(): boolean;
  87526. needAlphaTesting(): boolean;
  87527. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87528. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87529. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87530. getAnimatables(): BABYLON.IAnimatable[];
  87531. getActiveTextures(): BABYLON.BaseTexture[];
  87532. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87533. dispose(forceDisposeEffect?: boolean): void;
  87534. clone(name: string): MixMaterial;
  87535. serialize(): any;
  87536. getClassName(): string;
  87537. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87538. }
  87539. }
  87540. declare module BABYLON {
  87541. /** @hidden */
  87542. export var normalPixelShader: {
  87543. name: string;
  87544. shader: string;
  87545. };
  87546. }
  87547. declare module BABYLON {
  87548. /** @hidden */
  87549. export var normalVertexShader: {
  87550. name: string;
  87551. shader: string;
  87552. };
  87553. }
  87554. declare module BABYLON {
  87555. export class NormalMaterial extends BABYLON.PushMaterial {
  87556. private _diffuseTexture;
  87557. diffuseTexture: BABYLON.BaseTexture;
  87558. diffuseColor: BABYLON.Color3;
  87559. private _disableLighting;
  87560. disableLighting: boolean;
  87561. private _maxSimultaneousLights;
  87562. maxSimultaneousLights: number;
  87563. constructor(name: string, scene: BABYLON.Scene);
  87564. needAlphaBlending(): boolean;
  87565. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87566. needAlphaTesting(): boolean;
  87567. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87568. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87569. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87570. getAnimatables(): BABYLON.IAnimatable[];
  87571. getActiveTextures(): BABYLON.BaseTexture[];
  87572. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87573. dispose(forceDisposeEffect?: boolean): void;
  87574. clone(name: string): NormalMaterial;
  87575. serialize(): any;
  87576. getClassName(): string;
  87577. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87578. }
  87579. }
  87580. declare module BABYLON {
  87581. /** @hidden */
  87582. export var shadowOnlyPixelShader: {
  87583. name: string;
  87584. shader: string;
  87585. };
  87586. }
  87587. declare module BABYLON {
  87588. /** @hidden */
  87589. export var shadowOnlyVertexShader: {
  87590. name: string;
  87591. shader: string;
  87592. };
  87593. }
  87594. declare module BABYLON {
  87595. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87596. private _activeLight;
  87597. private _needAlphaBlending;
  87598. constructor(name: string, scene: BABYLON.Scene);
  87599. shadowColor: BABYLON.Color3;
  87600. needAlphaBlending(): boolean;
  87601. needAlphaTesting(): boolean;
  87602. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87603. get activeLight(): BABYLON.IShadowLight;
  87604. set activeLight(light: BABYLON.IShadowLight);
  87605. private _getFirstShadowLightForMesh;
  87606. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87607. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87608. clone(name: string): ShadowOnlyMaterial;
  87609. serialize(): any;
  87610. getClassName(): string;
  87611. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87612. }
  87613. }
  87614. declare module BABYLON {
  87615. /** @hidden */
  87616. export var simplePixelShader: {
  87617. name: string;
  87618. shader: string;
  87619. };
  87620. }
  87621. declare module BABYLON {
  87622. /** @hidden */
  87623. export var simpleVertexShader: {
  87624. name: string;
  87625. shader: string;
  87626. };
  87627. }
  87628. declare module BABYLON {
  87629. export class SimpleMaterial extends BABYLON.PushMaterial {
  87630. private _diffuseTexture;
  87631. diffuseTexture: BABYLON.BaseTexture;
  87632. diffuseColor: BABYLON.Color3;
  87633. private _disableLighting;
  87634. disableLighting: boolean;
  87635. private _maxSimultaneousLights;
  87636. maxSimultaneousLights: number;
  87637. constructor(name: string, scene: BABYLON.Scene);
  87638. needAlphaBlending(): boolean;
  87639. needAlphaTesting(): boolean;
  87640. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87641. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87642. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87643. getAnimatables(): BABYLON.IAnimatable[];
  87644. getActiveTextures(): BABYLON.BaseTexture[];
  87645. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87646. dispose(forceDisposeEffect?: boolean): void;
  87647. clone(name: string): SimpleMaterial;
  87648. serialize(): any;
  87649. getClassName(): string;
  87650. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87651. }
  87652. }
  87653. declare module BABYLON {
  87654. /** @hidden */
  87655. export var skyPixelShader: {
  87656. name: string;
  87657. shader: string;
  87658. };
  87659. }
  87660. declare module BABYLON {
  87661. /** @hidden */
  87662. export var skyVertexShader: {
  87663. name: string;
  87664. shader: string;
  87665. };
  87666. }
  87667. declare module BABYLON {
  87668. /**
  87669. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87670. * @see https://doc.babylonjs.com/extensions/sky
  87671. */
  87672. export class SkyMaterial extends BABYLON.PushMaterial {
  87673. /**
  87674. * Defines the overall luminance of sky in interval ]0, 1[.
  87675. */
  87676. luminance: number;
  87677. /**
  87678. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87679. */
  87680. turbidity: number;
  87681. /**
  87682. * Defines the sky appearance (light intensity).
  87683. */
  87684. rayleigh: number;
  87685. /**
  87686. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87687. */
  87688. mieCoefficient: number;
  87689. /**
  87690. * Defines the amount of haze particles following the Mie scattering theory.
  87691. */
  87692. mieDirectionalG: number;
  87693. /**
  87694. * Defines the distance of the sun according to the active scene camera.
  87695. */
  87696. distance: number;
  87697. /**
  87698. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87699. * "inclined".
  87700. */
  87701. inclination: number;
  87702. /**
  87703. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87704. * an object direction and a reference direction.
  87705. */
  87706. azimuth: number;
  87707. /**
  87708. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87709. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87710. */
  87711. sunPosition: BABYLON.Vector3;
  87712. /**
  87713. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87714. * .sunPosition property.
  87715. */
  87716. useSunPosition: boolean;
  87717. /**
  87718. * Defines an offset vector used to get a horizon offset.
  87719. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87720. */
  87721. cameraOffset: BABYLON.Vector3;
  87722. private _cameraPosition;
  87723. /**
  87724. * Instantiates a new sky material.
  87725. * This material allows to create dynamic and texture free
  87726. * effects for skyboxes by taking care of the atmosphere state.
  87727. * @see https://doc.babylonjs.com/extensions/sky
  87728. * @param name Define the name of the material in the scene
  87729. * @param scene Define the scene the material belong to
  87730. */
  87731. constructor(name: string, scene: BABYLON.Scene);
  87732. /**
  87733. * Specifies if the material will require alpha blending
  87734. * @returns a boolean specifying if alpha blending is needed
  87735. */
  87736. needAlphaBlending(): boolean;
  87737. /**
  87738. * Specifies if this material should be rendered in alpha test mode
  87739. * @returns false as the sky material doesn't need alpha testing.
  87740. */
  87741. needAlphaTesting(): boolean;
  87742. /**
  87743. * Get the texture used for alpha test purpose.
  87744. * @returns null as the sky material has no texture.
  87745. */
  87746. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87747. /**
  87748. * Get if the submesh is ready to be used and all its information available.
  87749. * Child classes can use it to update shaders
  87750. * @param mesh defines the mesh to check
  87751. * @param subMesh defines which submesh to check
  87752. * @param useInstances specifies that instances should be used
  87753. * @returns a boolean indicating that the submesh is ready or not
  87754. */
  87755. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87756. /**
  87757. * Binds the submesh to this material by preparing the effect and shader to draw
  87758. * @param world defines the world transformation matrix
  87759. * @param mesh defines the mesh containing the submesh
  87760. * @param subMesh defines the submesh to bind the material to
  87761. */
  87762. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87763. /**
  87764. * Get the list of animatables in the material.
  87765. * @returns the list of animatables object used in the material
  87766. */
  87767. getAnimatables(): BABYLON.IAnimatable[];
  87768. /**
  87769. * Disposes the material
  87770. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87771. */
  87772. dispose(forceDisposeEffect?: boolean): void;
  87773. /**
  87774. * Makes a duplicate of the material, and gives it a new name
  87775. * @param name defines the new name for the duplicated material
  87776. * @returns the cloned material
  87777. */
  87778. clone(name: string): SkyMaterial;
  87779. /**
  87780. * Serializes this material in a JSON representation
  87781. * @returns the serialized material object
  87782. */
  87783. serialize(): any;
  87784. /**
  87785. * Gets the current class name of the material e.g. "SkyMaterial"
  87786. * Mainly use in serialization.
  87787. * @returns the class name
  87788. */
  87789. getClassName(): string;
  87790. /**
  87791. * Creates a sky material from parsed material data
  87792. * @param source defines the JSON representation of the material
  87793. * @param scene defines the hosting scene
  87794. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87795. * @returns a new sky material
  87796. */
  87797. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87798. }
  87799. }
  87800. declare module BABYLON {
  87801. /** @hidden */
  87802. export var terrainPixelShader: {
  87803. name: string;
  87804. shader: string;
  87805. };
  87806. }
  87807. declare module BABYLON {
  87808. /** @hidden */
  87809. export var terrainVertexShader: {
  87810. name: string;
  87811. shader: string;
  87812. };
  87813. }
  87814. declare module BABYLON {
  87815. export class TerrainMaterial extends BABYLON.PushMaterial {
  87816. private _mixTexture;
  87817. mixTexture: BABYLON.BaseTexture;
  87818. private _diffuseTexture1;
  87819. diffuseTexture1: BABYLON.Texture;
  87820. private _diffuseTexture2;
  87821. diffuseTexture2: BABYLON.Texture;
  87822. private _diffuseTexture3;
  87823. diffuseTexture3: BABYLON.Texture;
  87824. private _bumpTexture1;
  87825. bumpTexture1: BABYLON.Texture;
  87826. private _bumpTexture2;
  87827. bumpTexture2: BABYLON.Texture;
  87828. private _bumpTexture3;
  87829. bumpTexture3: BABYLON.Texture;
  87830. diffuseColor: BABYLON.Color3;
  87831. specularColor: BABYLON.Color3;
  87832. specularPower: number;
  87833. private _disableLighting;
  87834. disableLighting: boolean;
  87835. private _maxSimultaneousLights;
  87836. maxSimultaneousLights: number;
  87837. constructor(name: string, scene: BABYLON.Scene);
  87838. needAlphaBlending(): boolean;
  87839. needAlphaTesting(): boolean;
  87840. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87841. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87842. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87843. getAnimatables(): BABYLON.IAnimatable[];
  87844. getActiveTextures(): BABYLON.BaseTexture[];
  87845. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87846. dispose(forceDisposeEffect?: boolean): void;
  87847. clone(name: string): TerrainMaterial;
  87848. serialize(): any;
  87849. getClassName(): string;
  87850. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87851. }
  87852. }
  87853. declare module BABYLON {
  87854. /** @hidden */
  87855. export var triplanarPixelShader: {
  87856. name: string;
  87857. shader: string;
  87858. };
  87859. }
  87860. declare module BABYLON {
  87861. /** @hidden */
  87862. export var triplanarVertexShader: {
  87863. name: string;
  87864. shader: string;
  87865. };
  87866. }
  87867. declare module BABYLON {
  87868. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87869. mixTexture: BABYLON.BaseTexture;
  87870. private _diffuseTextureX;
  87871. diffuseTextureX: BABYLON.BaseTexture;
  87872. private _diffuseTextureY;
  87873. diffuseTextureY: BABYLON.BaseTexture;
  87874. private _diffuseTextureZ;
  87875. diffuseTextureZ: BABYLON.BaseTexture;
  87876. private _normalTextureX;
  87877. normalTextureX: BABYLON.BaseTexture;
  87878. private _normalTextureY;
  87879. normalTextureY: BABYLON.BaseTexture;
  87880. private _normalTextureZ;
  87881. normalTextureZ: BABYLON.BaseTexture;
  87882. tileSize: number;
  87883. diffuseColor: BABYLON.Color3;
  87884. specularColor: BABYLON.Color3;
  87885. specularPower: number;
  87886. private _disableLighting;
  87887. disableLighting: boolean;
  87888. private _maxSimultaneousLights;
  87889. maxSimultaneousLights: number;
  87890. constructor(name: string, scene: BABYLON.Scene);
  87891. needAlphaBlending(): boolean;
  87892. needAlphaTesting(): boolean;
  87893. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87894. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87895. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87896. getAnimatables(): BABYLON.IAnimatable[];
  87897. getActiveTextures(): BABYLON.BaseTexture[];
  87898. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87899. dispose(forceDisposeEffect?: boolean): void;
  87900. clone(name: string): TriPlanarMaterial;
  87901. serialize(): any;
  87902. getClassName(): string;
  87903. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87904. }
  87905. }
  87906. declare module BABYLON {
  87907. /** @hidden */
  87908. export var waterPixelShader: {
  87909. name: string;
  87910. shader: string;
  87911. };
  87912. }
  87913. declare module BABYLON {
  87914. /** @hidden */
  87915. export var waterVertexShader: {
  87916. name: string;
  87917. shader: string;
  87918. };
  87919. }
  87920. declare module BABYLON {
  87921. export class WaterMaterial extends BABYLON.PushMaterial {
  87922. renderTargetSize: BABYLON.Vector2;
  87923. private _bumpTexture;
  87924. bumpTexture: BABYLON.BaseTexture;
  87925. diffuseColor: BABYLON.Color3;
  87926. specularColor: BABYLON.Color3;
  87927. specularPower: number;
  87928. private _disableLighting;
  87929. disableLighting: boolean;
  87930. private _maxSimultaneousLights;
  87931. maxSimultaneousLights: number;
  87932. /**
  87933. * Defines the wind force.
  87934. */
  87935. windForce: number;
  87936. /**
  87937. * Defines the direction of the wind in the plane (X, Z).
  87938. */
  87939. windDirection: BABYLON.Vector2;
  87940. /**
  87941. * Defines the height of the waves.
  87942. */
  87943. waveHeight: number;
  87944. /**
  87945. * Defines the bump height related to the bump map.
  87946. */
  87947. bumpHeight: number;
  87948. /**
  87949. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87950. */
  87951. private _bumpSuperimpose;
  87952. bumpSuperimpose: boolean;
  87953. /**
  87954. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87955. */
  87956. private _fresnelSeparate;
  87957. fresnelSeparate: boolean;
  87958. /**
  87959. * Defines wether or not bump Wwves modify the reflection.
  87960. */
  87961. private _bumpAffectsReflection;
  87962. bumpAffectsReflection: boolean;
  87963. /**
  87964. * Defines the water color blended with the refraction (near).
  87965. */
  87966. waterColor: BABYLON.Color3;
  87967. /**
  87968. * Defines the blend factor related to the water color.
  87969. */
  87970. colorBlendFactor: number;
  87971. /**
  87972. * Defines the water color blended with the reflection (far).
  87973. */
  87974. waterColor2: BABYLON.Color3;
  87975. /**
  87976. * Defines the blend factor related to the water color (reflection, far).
  87977. */
  87978. colorBlendFactor2: number;
  87979. /**
  87980. * Defines the maximum length of a wave.
  87981. */
  87982. waveLength: number;
  87983. /**
  87984. * Defines the waves speed.
  87985. */
  87986. waveSpeed: number;
  87987. /**
  87988. * 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.
  87989. */
  87990. waveCount: number;
  87991. /**
  87992. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87993. * will avoid calculating useless pixels in the pixel shader of the water material.
  87994. */
  87995. disableClipPlane: boolean;
  87996. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87997. private _mesh;
  87998. private _refractionRTT;
  87999. private _reflectionRTT;
  88000. private _reflectionTransform;
  88001. private _lastTime;
  88002. private _lastDeltaTime;
  88003. private _useLogarithmicDepth;
  88004. private _waitingRenderList;
  88005. private _imageProcessingConfiguration;
  88006. private _imageProcessingObserver;
  88007. /**
  88008. * Gets a boolean indicating that current material needs to register RTT
  88009. */
  88010. get hasRenderTargetTextures(): boolean;
  88011. /**
  88012. * Constructor
  88013. */
  88014. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  88015. get useLogarithmicDepth(): boolean;
  88016. set useLogarithmicDepth(value: boolean);
  88017. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88018. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88019. addToRenderList(node: any): void;
  88020. enableRenderTargets(enable: boolean): void;
  88021. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  88022. get renderTargetsEnabled(): boolean;
  88023. needAlphaBlending(): boolean;
  88024. needAlphaTesting(): boolean;
  88025. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88026. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88027. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88028. private _createRenderTargets;
  88029. getAnimatables(): BABYLON.IAnimatable[];
  88030. getActiveTextures(): BABYLON.BaseTexture[];
  88031. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88032. dispose(forceDisposeEffect?: boolean): void;
  88033. clone(name: string): WaterMaterial;
  88034. serialize(): any;
  88035. getClassName(): string;
  88036. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  88037. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  88038. }
  88039. }
  88040. declare module BABYLON {
  88041. /** @hidden */
  88042. export var asciiartPixelShader: {
  88043. name: string;
  88044. shader: string;
  88045. };
  88046. }
  88047. declare module BABYLON {
  88048. /**
  88049. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  88050. *
  88051. * It basically takes care rendering the font front the given font size to a texture.
  88052. * This is used later on in the postprocess.
  88053. */
  88054. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  88055. private _font;
  88056. private _text;
  88057. private _charSize;
  88058. /**
  88059. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88060. */
  88061. get charSize(): number;
  88062. /**
  88063. * Create a new instance of the Ascii Art FontTexture class
  88064. * @param name the name of the texture
  88065. * @param font the font to use, use the W3C CSS notation
  88066. * @param text the caracter set to use in the rendering.
  88067. * @param scene the scene that owns the texture
  88068. */
  88069. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88070. /**
  88071. * Gets the max char width of a font.
  88072. * @param font the font to use, use the W3C CSS notation
  88073. * @return the max char width
  88074. */
  88075. private getFontWidth;
  88076. /**
  88077. * Gets the max char height of a font.
  88078. * @param font the font to use, use the W3C CSS notation
  88079. * @return the max char height
  88080. */
  88081. private getFontHeight;
  88082. /**
  88083. * Clones the current AsciiArtTexture.
  88084. * @return the clone of the texture.
  88085. */
  88086. clone(): AsciiArtFontTexture;
  88087. /**
  88088. * Parses a json object representing the texture and returns an instance of it.
  88089. * @param source the source JSON representation
  88090. * @param scene the scene to create the texture for
  88091. * @return the parsed texture
  88092. */
  88093. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  88094. }
  88095. /**
  88096. * Option available in the Ascii Art Post Process.
  88097. */
  88098. export interface IAsciiArtPostProcessOptions {
  88099. /**
  88100. * The font to use following the w3c font definition.
  88101. */
  88102. font?: string;
  88103. /**
  88104. * The character set to use in the postprocess.
  88105. */
  88106. characterSet?: string;
  88107. /**
  88108. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88109. * This number is defined between 0 and 1;
  88110. */
  88111. mixToTile?: number;
  88112. /**
  88113. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88114. * This number is defined between 0 and 1;
  88115. */
  88116. mixToNormal?: number;
  88117. }
  88118. /**
  88119. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  88120. *
  88121. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88122. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  88123. */
  88124. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  88125. /**
  88126. * The font texture used to render the char in the post process.
  88127. */
  88128. private _asciiArtFontTexture;
  88129. /**
  88130. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88131. * This number is defined between 0 and 1;
  88132. */
  88133. mixToTile: number;
  88134. /**
  88135. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88136. * This number is defined between 0 and 1;
  88137. */
  88138. mixToNormal: number;
  88139. /**
  88140. * Instantiates a new Ascii Art Post Process.
  88141. * @param name the name to give to the postprocess
  88142. * @camera the camera to apply the post process to.
  88143. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  88144. */
  88145. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  88146. }
  88147. }
  88148. declare module BABYLON {
  88149. /** @hidden */
  88150. export var digitalrainPixelShader: {
  88151. name: string;
  88152. shader: string;
  88153. };
  88154. }
  88155. declare module BABYLON {
  88156. /**
  88157. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  88158. *
  88159. * It basically takes care rendering the font front the given font size to a texture.
  88160. * This is used later on in the postprocess.
  88161. */
  88162. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  88163. private _font;
  88164. private _text;
  88165. private _charSize;
  88166. /**
  88167. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88168. */
  88169. get charSize(): number;
  88170. /**
  88171. * Create a new instance of the Digital Rain FontTexture class
  88172. * @param name the name of the texture
  88173. * @param font the font to use, use the W3C CSS notation
  88174. * @param text the caracter set to use in the rendering.
  88175. * @param scene the scene that owns the texture
  88176. */
  88177. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88178. /**
  88179. * Gets the max char width of a font.
  88180. * @param font the font to use, use the W3C CSS notation
  88181. * @return the max char width
  88182. */
  88183. private getFontWidth;
  88184. /**
  88185. * Gets the max char height of a font.
  88186. * @param font the font to use, use the W3C CSS notation
  88187. * @return the max char height
  88188. */
  88189. private getFontHeight;
  88190. /**
  88191. * Clones the current DigitalRainFontTexture.
  88192. * @return the clone of the texture.
  88193. */
  88194. clone(): DigitalRainFontTexture;
  88195. /**
  88196. * Parses a json object representing the texture and returns an instance of it.
  88197. * @param source the source JSON representation
  88198. * @param scene the scene to create the texture for
  88199. * @return the parsed texture
  88200. */
  88201. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  88202. }
  88203. /**
  88204. * Option available in the Digital Rain Post Process.
  88205. */
  88206. export interface IDigitalRainPostProcessOptions {
  88207. /**
  88208. * The font to use following the w3c font definition.
  88209. */
  88210. font?: string;
  88211. /**
  88212. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88213. * This number is defined between 0 and 1;
  88214. */
  88215. mixToTile?: number;
  88216. /**
  88217. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88218. * This number is defined between 0 and 1;
  88219. */
  88220. mixToNormal?: number;
  88221. }
  88222. /**
  88223. * DigitalRainPostProcess helps rendering everithing in digital rain.
  88224. *
  88225. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88226. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  88227. */
  88228. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  88229. /**
  88230. * The font texture used to render the char in the post process.
  88231. */
  88232. private _digitalRainFontTexture;
  88233. /**
  88234. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88235. * This number is defined between 0 and 1;
  88236. */
  88237. mixToTile: number;
  88238. /**
  88239. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88240. * This number is defined between 0 and 1;
  88241. */
  88242. mixToNormal: number;
  88243. /**
  88244. * Instantiates a new Digital Rain Post Process.
  88245. * @param name the name to give to the postprocess
  88246. * @camera the camera to apply the post process to.
  88247. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  88248. */
  88249. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  88250. }
  88251. }
  88252. declare module BABYLON {
  88253. /** @hidden */
  88254. export var brickProceduralTexturePixelShader: {
  88255. name: string;
  88256. shader: string;
  88257. };
  88258. }
  88259. declare module BABYLON {
  88260. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  88261. private _numberOfBricksHeight;
  88262. private _numberOfBricksWidth;
  88263. private _jointColor;
  88264. private _brickColor;
  88265. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88266. updateShaderUniforms(): void;
  88267. get numberOfBricksHeight(): number;
  88268. set numberOfBricksHeight(value: number);
  88269. get numberOfBricksWidth(): number;
  88270. set numberOfBricksWidth(value: number);
  88271. get jointColor(): BABYLON.Color3;
  88272. set jointColor(value: BABYLON.Color3);
  88273. get brickColor(): BABYLON.Color3;
  88274. set brickColor(value: BABYLON.Color3);
  88275. /**
  88276. * Serializes this brick procedural texture
  88277. * @returns a serialized brick procedural texture object
  88278. */
  88279. serialize(): any;
  88280. /**
  88281. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  88282. * @param parsedTexture defines parsed texture data
  88283. * @param scene defines the current scene
  88284. * @param rootUrl defines the root URL containing brick procedural texture information
  88285. * @returns a parsed Brick Procedural BABYLON.Texture
  88286. */
  88287. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  88288. }
  88289. }
  88290. declare module BABYLON {
  88291. /** @hidden */
  88292. export var cloudProceduralTexturePixelShader: {
  88293. name: string;
  88294. shader: string;
  88295. };
  88296. }
  88297. declare module BABYLON {
  88298. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  88299. private _skyColor;
  88300. private _cloudColor;
  88301. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88302. updateShaderUniforms(): void;
  88303. get skyColor(): BABYLON.Color4;
  88304. set skyColor(value: BABYLON.Color4);
  88305. get cloudColor(): BABYLON.Color4;
  88306. set cloudColor(value: BABYLON.Color4);
  88307. /**
  88308. * Serializes this cloud procedural texture
  88309. * @returns a serialized cloud procedural texture object
  88310. */
  88311. serialize(): any;
  88312. /**
  88313. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  88314. * @param parsedTexture defines parsed texture data
  88315. * @param scene defines the current scene
  88316. * @param rootUrl defines the root URL containing cloud procedural texture information
  88317. * @returns a parsed Cloud Procedural BABYLON.Texture
  88318. */
  88319. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88320. }
  88321. }
  88322. declare module BABYLON {
  88323. /** @hidden */
  88324. export var fireProceduralTexturePixelShader: {
  88325. name: string;
  88326. shader: string;
  88327. };
  88328. }
  88329. declare module BABYLON {
  88330. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88331. private _time;
  88332. private _speed;
  88333. private _autoGenerateTime;
  88334. private _fireColors;
  88335. private _alphaThreshold;
  88336. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88337. updateShaderUniforms(): void;
  88338. render(useCameraPostProcess?: boolean): void;
  88339. static get PurpleFireColors(): BABYLON.Color3[];
  88340. static get GreenFireColors(): BABYLON.Color3[];
  88341. static get RedFireColors(): BABYLON.Color3[];
  88342. static get BlueFireColors(): BABYLON.Color3[];
  88343. get autoGenerateTime(): boolean;
  88344. set autoGenerateTime(value: boolean);
  88345. get fireColors(): BABYLON.Color3[];
  88346. set fireColors(value: BABYLON.Color3[]);
  88347. get time(): number;
  88348. set time(value: number);
  88349. get speed(): BABYLON.Vector2;
  88350. set speed(value: BABYLON.Vector2);
  88351. get alphaThreshold(): number;
  88352. set alphaThreshold(value: number);
  88353. /**
  88354. * Serializes this fire procedural texture
  88355. * @returns a serialized fire procedural texture object
  88356. */
  88357. serialize(): any;
  88358. /**
  88359. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88360. * @param parsedTexture defines parsed texture data
  88361. * @param scene defines the current scene
  88362. * @param rootUrl defines the root URL containing fire procedural texture information
  88363. * @returns a parsed Fire Procedural BABYLON.Texture
  88364. */
  88365. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88366. }
  88367. }
  88368. declare module BABYLON {
  88369. /** @hidden */
  88370. export var grassProceduralTexturePixelShader: {
  88371. name: string;
  88372. shader: string;
  88373. };
  88374. }
  88375. declare module BABYLON {
  88376. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88377. private _grassColors;
  88378. private _groundColor;
  88379. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88380. updateShaderUniforms(): void;
  88381. get grassColors(): BABYLON.Color3[];
  88382. set grassColors(value: BABYLON.Color3[]);
  88383. get groundColor(): BABYLON.Color3;
  88384. set groundColor(value: BABYLON.Color3);
  88385. /**
  88386. * Serializes this grass procedural texture
  88387. * @returns a serialized grass procedural texture object
  88388. */
  88389. serialize(): any;
  88390. /**
  88391. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88392. * @param parsedTexture defines parsed texture data
  88393. * @param scene defines the current scene
  88394. * @param rootUrl defines the root URL containing grass procedural texture information
  88395. * @returns a parsed Grass Procedural BABYLON.Texture
  88396. */
  88397. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88398. }
  88399. }
  88400. declare module BABYLON {
  88401. /** @hidden */
  88402. export var marbleProceduralTexturePixelShader: {
  88403. name: string;
  88404. shader: string;
  88405. };
  88406. }
  88407. declare module BABYLON {
  88408. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88409. private _numberOfTilesHeight;
  88410. private _numberOfTilesWidth;
  88411. private _amplitude;
  88412. private _jointColor;
  88413. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88414. updateShaderUniforms(): void;
  88415. get numberOfTilesHeight(): number;
  88416. set numberOfTilesHeight(value: number);
  88417. get amplitude(): number;
  88418. set amplitude(value: number);
  88419. get numberOfTilesWidth(): number;
  88420. set numberOfTilesWidth(value: number);
  88421. get jointColor(): BABYLON.Color3;
  88422. set jointColor(value: BABYLON.Color3);
  88423. /**
  88424. * Serializes this marble procedural texture
  88425. * @returns a serialized marble procedural texture object
  88426. */
  88427. serialize(): any;
  88428. /**
  88429. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88430. * @param parsedTexture defines parsed texture data
  88431. * @param scene defines the current scene
  88432. * @param rootUrl defines the root URL containing marble procedural texture information
  88433. * @returns a parsed Marble Procedural BABYLON.Texture
  88434. */
  88435. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88436. }
  88437. }
  88438. declare module BABYLON {
  88439. /** @hidden */
  88440. export var normalMapProceduralTexturePixelShader: {
  88441. name: string;
  88442. shader: string;
  88443. };
  88444. }
  88445. declare module BABYLON {
  88446. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88447. private _baseTexture;
  88448. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88449. updateShaderUniforms(): void;
  88450. render(useCameraPostProcess?: boolean): void;
  88451. resize(size: any, generateMipMaps: any): void;
  88452. get baseTexture(): BABYLON.Texture;
  88453. set baseTexture(texture: BABYLON.Texture);
  88454. /**
  88455. * Serializes this normal map procedural texture
  88456. * @returns a serialized normal map procedural texture object
  88457. */
  88458. serialize(): any;
  88459. /**
  88460. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88461. * @param parsedTexture defines parsed texture data
  88462. * @param scene defines the current scene
  88463. * @param rootUrl defines the root URL containing normal map procedural texture information
  88464. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88465. */
  88466. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88467. }
  88468. }
  88469. declare module BABYLON {
  88470. /** @hidden */
  88471. export var perlinNoiseProceduralTexturePixelShader: {
  88472. name: string;
  88473. shader: string;
  88474. };
  88475. }
  88476. declare module BABYLON {
  88477. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88478. time: number;
  88479. timeScale: number;
  88480. translationSpeed: number;
  88481. private _currentTranslation;
  88482. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88483. updateShaderUniforms(): void;
  88484. render(useCameraPostProcess?: boolean): void;
  88485. resize(size: any, generateMipMaps: any): void;
  88486. /**
  88487. * Serializes this perlin noise procedural texture
  88488. * @returns a serialized perlin noise procedural texture object
  88489. */
  88490. serialize(): any;
  88491. /**
  88492. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88493. * @param parsedTexture defines parsed texture data
  88494. * @param scene defines the current scene
  88495. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88496. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88497. */
  88498. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88499. }
  88500. }
  88501. declare module BABYLON {
  88502. /** @hidden */
  88503. export var roadProceduralTexturePixelShader: {
  88504. name: string;
  88505. shader: string;
  88506. };
  88507. }
  88508. declare module BABYLON {
  88509. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88510. private _roadColor;
  88511. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88512. updateShaderUniforms(): void;
  88513. get roadColor(): BABYLON.Color3;
  88514. set roadColor(value: BABYLON.Color3);
  88515. /**
  88516. * Serializes this road procedural texture
  88517. * @returns a serialized road procedural texture object
  88518. */
  88519. serialize(): any;
  88520. /**
  88521. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88522. * @param parsedTexture defines parsed texture data
  88523. * @param scene defines the current scene
  88524. * @param rootUrl defines the root URL containing road procedural texture information
  88525. * @returns a parsed Road Procedural BABYLON.Texture
  88526. */
  88527. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88528. }
  88529. }
  88530. declare module BABYLON {
  88531. /** @hidden */
  88532. export var starfieldProceduralTexturePixelShader: {
  88533. name: string;
  88534. shader: string;
  88535. };
  88536. }
  88537. declare module BABYLON {
  88538. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88539. private _time;
  88540. private _alpha;
  88541. private _beta;
  88542. private _zoom;
  88543. private _formuparam;
  88544. private _stepsize;
  88545. private _tile;
  88546. private _brightness;
  88547. private _darkmatter;
  88548. private _distfading;
  88549. private _saturation;
  88550. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88551. updateShaderUniforms(): void;
  88552. get time(): number;
  88553. set time(value: number);
  88554. get alpha(): number;
  88555. set alpha(value: number);
  88556. get beta(): number;
  88557. set beta(value: number);
  88558. get formuparam(): number;
  88559. set formuparam(value: number);
  88560. get stepsize(): number;
  88561. set stepsize(value: number);
  88562. get zoom(): number;
  88563. set zoom(value: number);
  88564. get tile(): number;
  88565. set tile(value: number);
  88566. get brightness(): number;
  88567. set brightness(value: number);
  88568. get darkmatter(): number;
  88569. set darkmatter(value: number);
  88570. get distfading(): number;
  88571. set distfading(value: number);
  88572. get saturation(): number;
  88573. set saturation(value: number);
  88574. /**
  88575. * Serializes this starfield procedural texture
  88576. * @returns a serialized starfield procedural texture object
  88577. */
  88578. serialize(): any;
  88579. /**
  88580. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88581. * @param parsedTexture defines parsed texture data
  88582. * @param scene defines the current scene
  88583. * @param rootUrl defines the root URL containing startfield procedural texture information
  88584. * @returns a parsed Starfield Procedural BABYLON.Texture
  88585. */
  88586. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88587. }
  88588. }
  88589. declare module BABYLON {
  88590. /** @hidden */
  88591. export var woodProceduralTexturePixelShader: {
  88592. name: string;
  88593. shader: string;
  88594. };
  88595. }
  88596. declare module BABYLON {
  88597. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88598. private _ampScale;
  88599. private _woodColor;
  88600. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88601. updateShaderUniforms(): void;
  88602. get ampScale(): number;
  88603. set ampScale(value: number);
  88604. get woodColor(): BABYLON.Color3;
  88605. set woodColor(value: BABYLON.Color3);
  88606. /**
  88607. * Serializes this wood procedural texture
  88608. * @returns a serialized wood procedural texture object
  88609. */
  88610. serialize(): any;
  88611. /**
  88612. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88613. * @param parsedTexture defines parsed texture data
  88614. * @param scene defines the current scene
  88615. * @param rootUrl defines the root URL containing wood procedural texture information
  88616. * @returns a parsed Wood Procedural BABYLON.Texture
  88617. */
  88618. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88619. }
  88620. }